diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2021-11-08 10:20:23 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2021-11-24 09:09:37 -0300 |
commit | 456b3c08b6fe78938af5d12b6869dc8c704696d6 (patch) | |
tree | bea5ff2432a7f589afccc126efb5ac8ab3b2c2b9 /include | |
parent | e186fc5a31e46f2cbf5ea1a75223b4412907f3d8 (diff) | |
download | glibc-456b3c08b6fe78938af5d12b6869dc8c704696d6.tar glibc-456b3c08b6fe78938af5d12b6869dc8c704696d6.tar.gz glibc-456b3c08b6fe78938af5d12b6869dc8c704696d6.tar.bz2 glibc-456b3c08b6fe78938af5d12b6869dc8c704696d6.zip |
io: Refactor close_range and closefrom
Now that Hurd implementis both close_range and closefrom (f2c996597d),
we can make close_range() a base ABI, and make the default closefrom()
implementation on top of close_range().
The generic closefrom() implementation based on __getdtablesize() is
moved to generic close_range(). On Linux it will be overriden by
the auto-generation syscall while on Hurd it will be a system specific
implementation.
The closefrom() now calls close_range() and __closefrom_fallback().
Since on Hurd close_range() does not fail, __closefrom_fallback() is an
empty static inline function set by__ASSUME_CLOSE_RANGE.
The __ASSUME_CLOSE_RANGE also allows optimize Linux
__closefrom_fallback() implementation when --enable-kernel=5.9 or
higher is used.
Finally the Linux specific tst-close_range.c is moved to io and
enabled as default. The Linuxism and CLOSE_RANGE_UNSHARE are
guarded so it can be built for Hurd (I have not actually test it).
Checked on x86_64-linux-gnu, i686-linux-gnu, and with a i686-gnu
build.
Diffstat (limited to 'include')
-rw-r--r-- | include/unistd.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/unistd.h b/include/unistd.h index 7849562c42..2bcdd494e1 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); |