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: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: "Carlos O'Donell" <carlos at redhat dot com>
- Cc: Florian Weimer <fweimer at redhat dot com>, Szabolcs Nagy <Szabolcs dot Nagy at arm dot com>, nd <nd at arm dot com>, Zack Weinberg <zackw at panix dot com>, GNU C Library <libc-alpha at sourceware dot org>
- Date: Mon, 1 Jul 2019 13:56:15 -0700
- 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> <CAKCAbMj2G7_1bAuE+5X0qvNGMTMN9QenzOpgJmkwC4LK_mrGzA@mail.gmail.com> <87y3266czw.fsf@oldenburg2.str.redhat.com> <c35c19da-b775-3435-d38e-702f30bc6ac3@arm.com> <87ef3y6bpv.fsf@oldenburg2.str.redhat.com> <17fed83c-e000-ccbf-9900-104fc20a6273@arm.com> <874l4u6bad.fsf@oldenburg2.str.redhat.com> <2df99c26-7a4c-02ba-a50e-7557c5581a9b@arm.com> <87muiks0ur.fsf@oldenburg2.str.redhat.com> <368c6bd5-39ec-8ea0-4d86-719158e1acdc@redhat.com>
On Fri, Jun 14, 2019 at 7:27 AM Carlos O'Donell <carlos@redhat.com> wrote:
>
> On 6/14/19 10:22 AM, Florian Weimer wrote:
> > * Szabolcs Nagy:
> >
> >> On 12/06/2019 17:03, Florian Weimer wrote:
> >>> * Szabolcs Nagy:
> >>>
> >>>> On 12/06/2019 16:54, Florian Weimer wrote:
> >>>>> Linux: Fix __glibc_has_include use for <sys/stat.h> and statx
> >>>>>
> >>>>> The identifier linux is used as a predefined macro, so the actually used
> >>>>> path is 1/stat.h or 1/stat64.h. Using the quote-based version triggers
> >>>>> a file lookup for /usr/include/bits/linux/stat.h (or whatever directory
> >>>>> is used to store bits/statx.h), but since bits/ is pretty much reserved
> >>>>> by glibc, this appears to be acceptable.
> >>>>>
> >>>>> This is related to GCC PR 80005: incorrect macro expansion of the
> >>>>> argument of __has_include.
> >>>>>
> >>>>> Suggested by Zack Weinberg.
> >>>>>
> >>>>> 2019-06-12 Florian Weimer <fweimer@redhat.com>
> >>>>>
> >>>>> * sysdeps/unix/sysv/linux/bits/statx.h: Use string literal in
> >>>>> argument to __glibc_has_include to inhibit macro expansion.
> >>>>>
> >>>>> diff --git a/sysdeps/unix/sysv/linux/bits/statx.h b/sysdeps/unix/sysv/linux/bits/statx.h
> >>>>> index d36f44efc6..3599f85a47 100644
> >>>>> --- a/sysdeps/unix/sysv/linux/bits/statx.h
> >>>>> +++ b/sysdeps/unix/sysv/linux/bits/statx.h
> >>>>> @@ -23,8 +23,8 @@
> >>>>> #endif
> >>>>>
> >>>>> /* Use the Linux kernel header if available. */
> >>>>> -#if __glibc_has_include (<linux/stat.h>)
> >>>>> -# include <linux/stat.h>
> >>>>> +#if __glibc_has_include ("linux/stat.h")
> >>>>> +# include "linux/stat.h"
> >>>>
> >>>> i would add a comment here with the gcc bug number as a
> >>>> reminder in case anybody wonders about ""
> >>>
> >>> What about this?
> >>>
> >>> /* Use "" to work around incorrect macro expansion of the __has_include
> >>> argument (GCC PR 80005). */
> >>
> >> looks good.
> >
> > Thanks. Updated patch below. I plan to push this soon.
> >
> > Florian
> >
> > Linux: Fix __glibc_has_include use for <sys/stat.h> and statx
> >
> > The identifier linux is used as a predefined macro, so the actually
> > used path is 1/stat.h or 1/stat64.h. Using the quote-based version
> > triggers a file lookup for /usr/include/bits/linux/stat.h (or whatever
> > directory is used to store bits/statx.h), but since bits/ is pretty
> > much reserved by glibc, this appears to be acceptable.
> >
> > This is related to GCC PR 80005: incorrect macro expansion of the
> > argument of __has_include.
> >
> > Suggested by Zack Weinberg.
> >
> > 2019-06-14 Florian Weimer <fweimer@redhat.com>
> >
> > * sysdeps/unix/sysv/linux/bits/statx.h: Use string literal in
> > argument to __glibc_has_include to inhibit macro expansion.
>
> LGTM. FYI, Rich Felker tweeted about this :-)
>
> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
>
> > diff --git a/sysdeps/unix/sysv/linux/bits/statx.h b/sysdeps/unix/sysv/linux/bits/statx.h
> > index d36f44efc6..206878723f 100644
> > --- a/sysdeps/unix/sysv/linux/bits/statx.h
> > +++ b/sysdeps/unix/sysv/linux/bits/statx.h
> > @@ -23,8 +23,11 @@
> > #endif
> >
> > /* Use the Linux kernel header if available. */
> > -#if __glibc_has_include (<linux/stat.h>)
> > -# include <linux/stat.h>
> > +
> > +/* Use "" to work around incorrect macro expansion of the
> > + __has_include argument (GCC PR 80005). */
> > +#if __glibc_has_include ("linux/stat.h")
> > +# include "linux/stat.h"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This may have caused:
https://sourceware.org/bugzilla/show_bug.cgi?id=24752
> > # ifdef STATX_TYPE
> > # define __statx_timestamp_defined 1
> > # define __statx_defined 1
> >
>
>
> --
> Cheers,
> Carlos.
--
H.J.