mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
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.
This commit is contained in:
@ -47,13 +47,4 @@ extern __pid_t gettid (void) __THROW;
|
||||
# define CLOSE_RANGE_CLOEXEC (1U << 2)
|
||||
#endif
|
||||
|
||||
/* Close all file descriptors in the range FD up to MAX_FD. The flag FLAGS
|
||||
are define by the CLOSE_RANGE prefix. This function behaves like close
|
||||
on the range, but in a fail-safe where it will either fail and not close
|
||||
any file descriptor or close all of them. Gaps where the file descriptor
|
||||
is invalid are ignored. Returns 0 on successor or -1 for failure (and
|
||||
sets errno accordingly). */
|
||||
extern int close_range (unsigned int __fd, unsigned int __max_fd,
|
||||
int __flags) __THROW;
|
||||
|
||||
#endif /* __USE_GNU */
|
||||
|
Reference in New Issue
Block a user