build: check if std-predef.h exists

Fix build on FreeBSD / non-glibc systems

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2019-04-14 03:45:04 +01:00
parent c5224dad56
commit 8900400516
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
2 changed files with 6 additions and 0 deletions

View File

@ -49,6 +49,10 @@ endif
add_global_arguments('-D_GNU_SOURCE', language: 'c')
if cc.has_header('stdc-predef.h')
add_global_arguments('-DHAS_STDC_PREDEF_H', language: 'c')
endif
warns = [ 'all', 'extra', 'no-unused-parameter', 'nonnull', 'shadow', 'no-type-limits',
'implicit-fallthrough', 'no-unknown-warning-option', 'no-missing-braces', 'conversion' ]
foreach w : warns

View File

@ -2,7 +2,9 @@
// Copyright (c) 2018 Yuxuan Shui <yshuiv7@gmail.com>
#pragma once
#ifdef HAS_STDC_PREDEF_H
#include <stdc-predef.h>
#endif
#define auto __auto_type
#define likely(x) __builtin_expect(!!(x), 1)