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 85dba1f3c9
commit 41fd229230
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') 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', warns = [ 'all', 'extra', 'no-unused-parameter', 'nonnull', 'shadow', 'no-type-limits',
'implicit-fallthrough', 'no-unknown-warning-option', 'no-missing-braces', 'conversion' ] 'implicit-fallthrough', 'no-unknown-warning-option', 'no-missing-braces', 'conversion' ]
foreach w : warns foreach w : warns

View File

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