[PATCH v2] io: Refactor close_range and closefrom
Adhemerval Zanella
adhemerval.zanella@linaro.org
Wed Nov 24 11:36:16 GMT 2021
On 24/11/2021 06:52, Florian Weimer wrote:
> * Adhemerval Zanella via Libc-alpha:
>
>> diff --git a/include/unistd.h b/include/unistd.h
>> index 7849562c42..927d249380 100644
>> --- a/include/unistd.h
>> +++ b/include/unistd.h
>> @@ -3,6 +3,9 @@
>>
>> # ifndef _ISOMAC
>>
>> +# include <stdbool.h>
>> +# include <kernel-features.h>
>> +
>> libc_hidden_proto (_exit, __noreturn__)
>> # ifndef NO_RTLD_HIDDEN
>> rtld_hidden_proto (_exit, __noreturn__)
>> @@ -158,7 +161,14 @@ extern int __brk (void *__addr) attribute_hidden;
>> extern int __close (int __fd);
>> libc_hidden_proto (__close)
>> extern int __libc_close (int __fd);
>> +#if __ASSUME_CLOSE_RANGE
>> +static inline _Bool __closefrom_fallback (int __lowfd, _Bool dirfd_fallback)
>> +{
>> + return false;
>> +}
>> +#else
>> extern _Bool __closefrom_fallback (int __lowfd, _Bool) attribute_hidden;
>> +#endif
>> extern ssize_t __read (int __fd, void *__buf, size_t __nbytes);
>> libc_hidden_proto (__read)
>> extern ssize_t __write (int __fd, const void *__buf, size_t __n);
>
> #if indentation seems off.
Ack.
>
> I expect this will break the Hurd build because it does not define
> __ASSUME_CLOSE_RANGE in its <kernel-features.h>.
> diff --git a/sysdeps/mach/hurd/kernel-features.h b/sysdeps/mach/hurd/kernel-features.h
> index 7d4eaee0a6..5fd37a6d7b 100644
> --- a/sysdeps/mach/hurd/kernel-features.h
> +++ b/sysdeps/mach/hurd/kernel-features.h
> @@ -19,3 +19,5 @@
> /* This file can define __ASSUME_* macros checked by certain source files.
> Almost none of these are used outside of sysdeps/unix/sysv/linux code.
> But those referring to POSIX-level features like O_* flags can be. */
> +
> +#define __ASSUME_CLOSE_RANGE 1
It does add it here (I also checked with a build for i688-gnu).
>
> Thanks,
> Florian
>
More information about the Libc-alpha
mailing list