From e972120d60a53ec2a179cedb632efdd69b37365a Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 25 Dec 2017 12:01:14 +0100 Subject: [PATCH] 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. --- meson.build | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/meson.build b/meson.build index c9ce60a97..aea61990c 100644 --- a/meson.build +++ b/meson.build @@ -518,33 +518,29 @@ foreach ident : ['secure_getenv', '__secure_getenv'] endforeach foreach ident : [ - ['memfd_create', '''#define _GNU_SOURCE -// #include '''], + ['memfd_create', '''#include '''], ['gettid', '''#include '''], ['pivot_root', '''#include '''], # no known header declares pivot_root - ['name_to_handle_at', '''#define _GNU_SOURCE - #include + ['name_to_handle_at', '''#include #include #include '''], - ['setns', '''#define _GNU_SOURCE - #include '''], + ['setns', '''#include '''], ['renameat2', '''#include '''], ['kcmp', '''#include '''], ['keyctl', '''#include #include '''], - ['copy_file_range', '''#define _GNU_SOURCE -// #include + ['copy_file_range', '''#include #include '''], ['bpf', '''#include #include '''], ['explicit_bzero' , '''#include '''], ] - 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 ''') +if cc.has_function('getrandom', prefix : '''#include ''', args : '-D_GNU_SOURCE') conf.set10('USE_SYS_RANDOM_H', true) conf.set10('HAVE_GETRANDOM', true) else -- 2.30.2