mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
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.
This commit is contained in:
parent
0e50bfaefd
commit
85db59b794
16
meson.build
16
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
|
||||
|
Loading…
Reference in New Issue
Block a user