This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [glibc] <sys/stat.h>: Use Linux UAPI header for statx if available and useful
- From: Zack Weinberg <zackw at panix dot com>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Wed, 12 Jun 2019 11:21:20 -0400
- Subject: Re: [glibc] <sys/stat.h>: Use Linux UAPI header for statx if available and useful
- References: <20190612110504.66041.qmail@sourceware.org> <87ftoe7utd.fsf@oldenburg2.str.redhat.com>
On Wed, Jun 12, 2019 at 10:16 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> > +#if __glibc_has_include (<linux/stat.h>)
...
>
> It turns out that this does not work as expected in some configurations
> because linux is a macro, defined to 1, and it's expanded in this
> context
I wonder how much stuff still depends on these legacy user-namespace
OS-specific macros. Would anyone even notice if we put
#undef linux
#undef unix
at the top of features.h? The GCC manual has said "We are slowly
phasing out all predefined macros which are outside the reserved
namespace" [1] since, um, 2001 give or take? but I don't think anyone
has ever done any actual work on getting rid of them :-/
> Is there a way to inhibit macro expansion in this context? Maybe with
> token pasting?
The easiest thing that comes to mind is to write __glibc_has_include
("linux/stat.h") instead. Then the preprocessor would see the argument
as a string literal and not expand "linux", and there shouldn't be a
/usr/include/sys/linux/stat.h ever, so it would come out equivalently.
Well, I guess someone could be using -iquote, but do we really need to
support the situation where someone pointed -iquote at a directory
containing a linux/stat.h, and at the same time there's no
linux/stat.h in the <> search path?
zw
[1] https://gcc.gnu.org/onlinedocs/gcc-8.2.0/cpp/System-specific-Predefined-Macros.html