Using <linux/stat.h> for _GNU_SOURCE

Joseph Myers joseph@codesourcery.com
Mon Nov 6 15:58:00 GMT 2017


On Mon, 6 Nov 2017, Florian Weimer wrote:

> Would it be possible to include <linux/stat.h> (not <asm/stat.h>) from
> <sys/stat.h> for _GNU_SOURCE?  We'd need to add redefinition guards for the
> S_* macros defined in <linux/stat.h>, but otherwise, the header looks quite
> clean.

S_* appear to have conditionals

#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)

in <linux/stat.h>, so I don't think any guards are needed.

> This would allow us to obtain the STX_* constants and struct statx from the
> uapi header, without maintaining our own copy of that information. Or wouldn't

Note that if you start using any such constants and types in glibc such 
that they need to be available when glibc is built, that would imply a 
major change in the minimum supported kernel headers version for building 
glibc (as opposed to the minimum kernel version supported at runtime, so 
less problematic), from 3.2 to 4.11.

-- 
Joseph S. Myers
joseph@codesourcery.com



More information about the Libc-alpha mailing list