]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Linux: Convert '__close_nocancel_nostatus' to a standalone handler
authorMaciej W. Rozycki <macro@redhat.com>
Tue, 24 Jun 2025 20:17:25 +0000 (21:17 +0100)
committerMaciej W. Rozycki <macro@redhat.com>
Tue, 24 Jun 2025 20:17:25 +0000 (21:17 +0100)
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>
sysdeps/unix/sysv/linux/Makefile
sysdeps/unix/sysv/linux/Versions
sysdeps/unix/sysv/linux/close_nocancel_nostatus.c [new file with mode: 0644]
sysdeps/unix/sysv/linux/not-cancel.h

index c6b2db83775bba34e7d3992729f42b9b20a99a46..c47cbdf4280c700d1d3c2203f598243b08c26344 100644 (file)
@@ -612,6 +612,7 @@ endif
 ifeq ($(subdir),io)
 sysdep_routines += \
   close_nocancel \
+  close_nocancel_nostatus \
   fallocate \
   fallocate64 \
   fcntl_nocancel \
index b721331bf71d8b09bc545006ae0796938cb49152..585dec7689e72028e064e2f52c77505af073758e 100644 (file)
@@ -346,6 +346,7 @@ libc {
     __read_nocancel;
     __pread64_nocancel;
     __close_nocancel;
+    __close_nocancel_nostatus;
     __sigtimedwait;
     # functions used by nscd
     __netlink_assert_response;
diff --git a/sysdeps/unix/sysv/linux/close_nocancel_nostatus.c b/sysdeps/unix/sysv/linux/close_nocancel_nostatus.c
new file mode 100644 (file)
index 0000000..b1df5ed
--- /dev/null
@@ -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)
index 73761ab04b341ce4aafe21908344bf9da756afb5..5ac6dd4c71f639333d8f987ae42eaa308bb32a6d 100644 (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