io: Refactor close_range and closefrom
commit456b3c08b6fe78938af5d12b6869dc8c704696d6
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 8 Nov 2021 13:20:23 +0000 (8 10:20 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 24 Nov 2021 12:09:37 +0000 (24 09:09 -0300)
treebea5ff2432a7f589afccc126efb5ac8ab3b2c2b9
parente186fc5a31e46f2cbf5ea1a75223b4412907f3d8
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.
15 files changed:
include/unistd.h
io/Makefile
io/close_range.c [moved from sysdeps/unix/sysv/linux/closefrom.c with 59% similarity]
io/closefrom.c
io/tst-close_range.c [moved from sysdeps/unix/sysv/linux/tst-close_range.c with 98% similarity]
posix/unistd.h
sysdeps/mach/hurd/Makefile
sysdeps/mach/hurd/bits/unistd_ext.h
sysdeps/mach/hurd/closefrom.c [deleted file]
sysdeps/mach/hurd/kernel-features.h
sysdeps/unix/sysv/linux/Makefile
sysdeps/unix/sysv/linux/bits/unistd_ext.h
sysdeps/unix/sysv/linux/closefrom_fallback.c
sysdeps/unix/sysv/linux/kernel-features.h
sysdeps/unix/sysv/linux/syscalls.list