This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] <sys/stat.h>: Use Linux kernel UAPI header if available and useful


On 6/11/19 5:06 PM, Florian Weimer wrote:
> * Carlos O'Donell:
> 
>>> diff --git a/io/bits/statx-generic.h b/io/bits/statx-generic.h
>>> new file mode 100644
>>> index 0000000000..1f5abbf148
>>> --- /dev/null
>>> +++ b/io/bits/statx-generic.h
>>> @@ -0,0 +1,60 @@
>>> +/* Generic statx-related definitions and declarations.
>>> +   Copyright (C) 2018-2019 Free Software Foundation, Inc.
>>
>> s/2018-2019/2019/g
>>
>> This looks like a new-from-scratch file even if it's based on the 
>> other stat.h header.
> 
> I disagree, it contains more than twenty lines from the old file, not
> counting the copyright header.

OK, I hadn't looked that closely at this, but if it's more than 15
lines, then sure.

>> So if __has_include is not defined this is all #if 0, and removed.
>>
>> So in the use case that the compiler is new enough:
>>
>> - If sys/stat.h is included first we check to see if linux/stat.h file is
>>   includeable and then do so, and avoid including our own definitions.
>>
>> - If linux/stat.h is included first we again detect it is includeable,
>>   include it again (idempotent), and avoid our own definitions.
> 
> Note that we also need to cover the case where <linux/stat.h> exists,
> but does not contain the statx definitions.  Hence the STATX_TYPE check
> below.

I had not considered that case. Nice that you had STATX_TYPE to test for.

>>> +# include <linux/stat.h>
>>> +# ifdef STATX_TYPE
>>> +#  define __statx_timestamp_defined 1
>>> +#  define __statx_defined 1
>>> +# endif
>>> +#endif
>>> +
>>> +#include <bits/statx-generic.h>
> 
> Thanks,
> Florian
> 


-- 
Cheers,
Carlos.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]