@@ -196,7 +196,7 @@ sysdep_routines += cthreads
endif
ifeq (io, $(subdir))
-sysdep_routines += f_setlk close_nocancel_nostatus \
+sysdep_routines += f_setlk close_nocancel close_nocancel_nostatus \
open_nocancel openat_nocancel read_nocancel \
pread64_nocancel write_nocancel pwrite64_nocancel
endif
@@ -13,6 +13,7 @@ libc {
GLIBC_PRIVATE {
# Functions shared with the dynamic linker
__access; __access_noerrno; __libc_read; __libc_write; __libc_lseek64;
+ __close_nocancel;
__open_nocancel;
__read_nocancel; __pread64_nocancel;
__write_nocancel;
@@ -55,6 +56,7 @@ ld {
# functions that must be shared with libc
__access; __access_noerrno; __libc_read; __libc_write; __libc_lseek64;
+ __close_nocancel;
__open_nocancel;
__read_nocancel; __pread64_nocancel;
__write_nocancel;
@@ -19,14 +19,18 @@
#include <unistd.h>
#include <hurd.h>
#include <hurd/fd.h>
+#include <sysdep-cancel.h>
/* Close the file descriptor FD. */
int
__close (int fd)
{
error_t err;
+ int cancel_oldtype;
+ cancel_oldtype = LIBC_CANCEL_ASYNC();
err = HURD_FD_USE (fd, _hurd_fd_close (descriptor));
+ LIBC_CANCEL_RESET (cancel_oldtype);
return err ? __hurd_fail (err) : 0;
}
new file mode 100644
@@ -0,0 +1,34 @@
+/* Copyright (C) 1991-2020 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 <errno.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+#include <not-cancel.h>
+
+/* Close the file descriptor FD. */
+int
+__close_nocancel (int fd)
+{
+ error_t err;
+
+ err = HURD_FD_USE (fd, _hurd_fd_close (descriptor));
+
+ return err ? __hurd_fail (err) : 0;
+}
+libc_hidden_def (__close_nocancel)
@@ -353,6 +353,7 @@ weak_alias (__open, __open64)
weak_alias (__open, __open_nocancel)
check_no_hidden(__close);
+check_no_hidden(__close_nocancel);
int weak_function
__close (int fd)
{
@@ -360,6 +361,7 @@ __close (int fd)
__mach_port_deallocate (__mach_task_self (), (mach_port_t) fd);
return 0;
}
+weak_alias (__close, __close_nocancel)
check_no_hidden(__pread64);
check_no_hidden(__pread64_nocancel);
@@ -19,7 +19,8 @@ ld.so: _dl_catch_exception + REL R_386_GLOB_DAT
ld.so: __open ?
ld.so: __open64 ?
ld.so: __open_nocancel
-ld.so: __close
+ld.so: __close ?
+ld.so: __close_nocancel
ld.so: __read ?
ld.so: __read_nocancel
ld.so: __pread64
@@ -28,9 +28,8 @@
#include <hurd.h>
#include <hurd/fd.h>
-/* For now we have none. Map the name to the normal functions. */
-#define __close_nocancel(fd) \
- __close (fd)
+/* Non cancellable close syscall. */
+__typeof (__close) __close_nocancel;
void __close_nocancel_nostatus (int fd);
@@ -64,12 +63,15 @@ __typeof (__writev) __writev_nocancel;
/* Non cancellable writev syscall with no status. */
void __writev_nocancel_nostatus (int fd, const struct iovec *vector, int count);
+/* For now we have none. Map the name to the normal functions. */
# define __waitpid_nocancel(pid, stat_loc, options) \
__waitpid (pid, stat_loc, options)
#define __fcntl64_nocancel(fd, cmd, ...) \
__fcntl64 (fd, cmd, __VA_ARGS__)
#if IS_IN (libc)
+hidden_proto (__close_nocancel)
+hidden_proto (__close_nocancel_nostatus)
hidden_proto (__open_nocancel)
hidden_proto (__openat_nocancel)
hidden_proto (__read_nocancel)
@@ -78,7 +80,6 @@ hidden_proto (__write_nocancel)
hidden_proto (__pwrite64_nocancel)
hidden_proto (__writev_nocancel)
hidden_proto (__writev_nocancel_nostatus)
-hidden_proto (__close_nocancel_nostatus)
#endif
#endif /* NOT_CANCEL_H */