diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-12-25 12:01:14 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2017-12-25 12:10:14 +0100 |
commit | 85db59b794d1ca7f16ea816c916bb4472958cc1b (patch) | |
tree | 90f56ed2ed591d1f2412be22f3d112c48a0f18c0 /meson.build | |
parent | meson: define _GNU_SOURCE to detect copy_file_range() (#7734) (diff) | |
download | systemd-85db59b794d1ca7f16ea816c916bb4472958cc1b.tar.xz systemd-85db59b794d1ca7f16ea816c916bb4472958cc1b.zip |
meson: use "args" for setting _GNU_SOURCE when checking for functions
This reworks how we set _GNU_SOURCE when checking for the availability
of functions:
1. We set it for most of the functions we look for. After all we set it
for our entire built anyway, and it's usually how Linux-specific
definitions in glibc are protected these days. Given that we usually
have checks for such modern stuff only anyway, let's just blanket enable
it.
2. Use "args" instead of "prefix" to set the macro. This is what is
suggested in the meson docs, hence let's do it.
Diffstat (limited to '')
-rw-r--r-- | meson.build | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/meson.build b/meson.build index f3a65b3893..eda9e382bf 100644 --- a/meson.build +++ b/meson.build @@ -454,33 +454,29 @@ foreach ident : ['secure_getenv', '__secure_getenv'] endforeach foreach ident : [ - ['memfd_create', '''#define _GNU_SOURCE - #include <sys/mman.h>'''], + ['memfd_create', '''#include <sys/mman.h>'''], ['gettid', '''#include <sys/types.h>'''], ['pivot_root', '''#include <stdlib.h>'''], # no known header declares pivot_root - ['name_to_handle_at', '''#define _GNU_SOURCE - #include <sys/types.h> + ['name_to_handle_at', '''#include <sys/types.h> #include <sys/stat.h> #include <fcntl.h>'''], - ['setns', '''#define _GNU_SOURCE - #include <sched.h>'''], + ['setns', '''#include <sched.h>'''], ['renameat2', '''#include <stdio.h>'''], ['kcmp', '''#include <linux/kcmp.h>'''], ['keyctl', '''#include <sys/types.h> #include <keyutils.h>'''], - ['copy_file_range', '''#define _GNU_SOURCE - #include <sys/syscall.h> + ['copy_file_range', '''#include <sys/syscall.h> #include <unistd.h>'''], ['bpf', '''#include <sys/syscall.h> #include <unistd.h>'''], ['explicit_bzero' , '''#include <string.h>'''], ] - have = cc.has_function(ident[0], prefix : ident[1]) + have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE') conf.set10('HAVE_' + ident[0].to_upper(), have) endforeach -if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''') +if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE') conf.set10('USE_SYS_RANDOM_H', true) conf.set10('HAVE_GETRANDOM', true) else |