This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] <sys/stat.h>: Use Linux kernel UAPI header if available and useful
On Jun 11 2019, Florian Weimer <fweimer@redhat.com> wrote:
> * Andreas Schwab:
>
>> On Jun 11 2019, Florian Weimer <fweimer@redhat.com> wrote:
>>
>>> * Andreas Schwab:
>>>
>>>> On Jun 11 2019, Florian Weimer <fweimer@redhat.com> wrote:
>>>>
>>>>> Alternative, we could compile statx_generic separately and directly
>>>>> include <io/bits/statx-generic.h>, bypassing the sysdeps search path.
>>>>> But that means we cannot include <sys/stat.h>, but we need it for the
>>>>> AT_* constants.
>>>>
>>>> If struct statx is put in a separate file it can be included twice, with
>>>> arrangment for defining, say, struct statx_internal the second time.
>>>
>>> You mean like this?
>>>
>>> #include <sys/stat.h>
>>> /* Change the tag of the struct definition. */
>>> #define statx statx_original
>>> #include <bits/types/struct_statx.h>
>>> #undef statx
>>>
>>> I still consider this a preprocessor hack.
>>
>> It is only needed as long as the fallback is needed.
>
> Sure, except that the fallback is also used on Hurd, so I assume that
> code is here to stay.
When it is no longer needed on Linux it can be simplified anyway.
>>> I would prefer the static assert to this.
>>
>> In any case, the assertion is in the wrong place, since only the
>> fallback needs it.
>
> Only on Linux, we potentially compile against an out-of-tree definition
> of struct statx, so this is why I added the assert there.
But it's the Linux version that doesn't really care about the size.
statx_generic is really operating on its own, non-changing definition of
struct statx, and I think that should be made explicit.
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."