Linux: Convert '__close_nocancel_nostatus' to a standalone handler

Make '__close_nocancel_nostatus' standalone.  This is a generic version
analogous to '__close_nocancel'.  Platforms may choose to implement an
inline variant instead where the syscall invocation code sequence is
short enough to be beneficial over a function call.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
This commit is contained in:
Maciej W. Rozycki 2025-06-24 21:17:25 +01:00
parent 3b0d495ac4
commit 36bcbc6b5b
4 changed files with 34 additions and 8 deletions

View File

@ -612,6 +612,7 @@ endif
ifeq ($(subdir),io)
sysdep_routines += \
close_nocancel \
close_nocancel_nostatus \
fallocate \
fallocate64 \
fcntl_nocancel \

View File

@ -346,6 +346,7 @@ libc {
__read_nocancel;
__pread64_nocancel;
__close_nocancel;
__close_nocancel_nostatus;
__sigtimedwait;
# functions used by nscd
__netlink_assert_response;

View File

@ -0,0 +1,28 @@
/* Linux close syscall implementation -- non-cancellable, no errno update.
Copyright (C) 2025 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#include <unistd.h>
#include <sysdep-cancel.h>
#include <not-cancel.h>
void
__close_nocancel_nostatus (int fd)
{
INTERNAL_SYSCALL_CALL (close, fd);
}
libc_hidden_def (__close_nocancel_nostatus)

View File

@ -53,6 +53,9 @@ __typeof (__write) __write_nocancel;
/* Uncancelable close. */
__typeof (__close) __close_nocancel;
/* Uncancellable close that does not also set errno in case of failure. */
void __close_nocancel_nostatus (int);
/* Uncancelable fcntl. */
int __fcntl64_nocancel (int, int, ...);
@ -65,17 +68,10 @@ hidden_proto (__read_nocancel)
hidden_proto (__pread64_nocancel)
hidden_proto (__write_nocancel)
hidden_proto (__close_nocancel)
hidden_proto (__close_nocancel_nostatus)
hidden_proto (__fcntl64_nocancel)
#endif
/* Non cancellable close syscall that does not also set errno in case of
failure. */
static inline void
__close_nocancel_nostatus (int fd)
{
INTERNAL_SYSCALL_CALL (close, fd);
}
/* Non cancellable writev syscall that does not also set errno in case of
failure. */
static inline void