Skip to content

Commit 9c869d0

Browse files
committed
meson: unify linux/stat.h check with other checks and use _GNU_SOURCE
Using _GNU_SOURCE is better because that's how we include the headers in the actual build, and some headers define different stuff when it is defined. sys/stat.h for example defines 'struct statx' conditionally.
1 parent dc6e572 commit 9c869d0

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

meson.build

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -421,11 +421,9 @@ decl_headers = '''
421421
#include <uchar.h>
422422
#include <linux/ethtool.h>
423423
#include <linux/fib_rules.h>
424-
#include <linux/stat.h>
425424
#include <sys/stat.h>
426425
'''
427426
# FIXME: key_serial_t is only defined in keyutils.h, this is bound to fail
428-
# FIXME: these should use -D_GNU_SOURCE, since that is defined at build time
429427

430428
foreach decl : ['char16_t',
431429
'char32_t',
@@ -436,13 +434,23 @@ foreach decl : ['char16_t',
436434
]
437435

438436
# We get -1 if the size cannot be determined
439-
have = cc.sizeof(decl, prefix : decl_headers) > 0
437+
have = cc.sizeof(decl, prefix : decl_headers, args : '-D_GNU_SOURCE') > 0
438+
439+
if decl == 'struct statx'
440+
if have
441+
want_linux_stat_h = false
442+
else
443+
have = cc.sizeof(decl,
444+
prefix : decl_headers + '#include <linux/stat.h>',
445+
args : '-D_GNU_SOURCE') > 0
446+
want_linux_stat_h = have
447+
endif
448+
endif
449+
440450
conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
441451
endforeach
442452

443-
conf.set10('HAVE_STRUCT_STATX_IN_SYS_STAT_H', cc.sizeof('struct statx', prefix : '''
444-
#include <sys/stat.h>
445-
''', args : '-D_GNU_SOURCE') > 0)
453+
conf.set10('WANT_LINUX_STAT_H', want_linux_stat_h)
446454

447455
foreach decl : [['IFLA_INET6_ADDR_GEN_MODE', 'linux/if_link.h'],
448456
['IN6_ADDR_GEN_MODE_STABLE_PRIVACY', 'linux/if_link.h'],

src/basic/missing.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include <uchar.h>
2525
#include <unistd.h>
2626

27-
#if !HAVE_STRUCT_STATX_IN_SYS_STAT_H
27+
#if WANT_LINUX_STAT_H
2828
#include <linux/stat.h>
2929
#endif
3030

0 commit comments

Comments
 (0)