From 36bcbc6b5bb81eab436c7ed82348a25c4a34fa73 Mon Sep 17 00:00:00 2001 From: "Maciej W. Rozycki" Date: Tue, 24 Jun 2025 21:17:25 +0100 Subject: [PATCH] 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 --- sysdeps/unix/sysv/linux/Makefile | 1 + sysdeps/unix/sysv/linux/Versions | 1 + .../unix/sysv/linux/close_nocancel_nostatus.c | 28 +++++++++++++++++++ sysdeps/unix/sysv/linux/not-cancel.h | 12 +++----- 4 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/close_nocancel_nostatus.c diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index c6b2db8377..c47cbdf428 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -612,6 +612,7 @@ endif ifeq ($(subdir),io) sysdep_routines += \ close_nocancel \ + close_nocancel_nostatus \ fallocate \ fallocate64 \ fcntl_nocancel \ diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions index b721331bf7..585dec7689 100644 --- a/sysdeps/unix/sysv/linux/Versions +++ b/sysdeps/unix/sysv/linux/Versions @@ -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 index 0000000000..b1df5ed022 --- /dev/null +++ b/sysdeps/unix/sysv/linux/close_nocancel_nostatus.c @@ -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 + . */ + +#include +#include +#include + +void +__close_nocancel_nostatus (int fd) +{ + INTERNAL_SYSCALL_CALL (close, fd); +} +libc_hidden_def (__close_nocancel_nostatus) diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h index 73761ab04b..5ac6dd4c71 100644 --- a/sysdeps/unix/sysv/linux/not-cancel.h +++ b/sysdeps/unix/sysv/linux/not-cancel.h @@ -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