and add _nocancel variants.
* sysdeps/mach/hurd/pread64.c (__libc_pread64): Call __pread64_nocancel
surrounded by enabling async cancel, to replace implementation moved to...
* sysdeps/mach/hurd/pread64_nocancel.c (__pread64_nocancel): ... here.
* sysdeps/mach/hurd/read.c (__libc_read): Call __read_nocancel surrounded by
enabling async cancel, to replace implementation moved to...
* sysdeps/mach/hurd/read_nocancel.c (__read_nocancel): ... here.
* sysdeps/mach/hurd/Makefile (sysdep_routines): Add read_nocancel and
pread64_nocancel.
* sysdeps/mach/hurd/not-cancel.h (__read_nocancel, __pread64_nocancel):
Replace macros with prototypes with a hidden proto on libc.
* sysdeps/mach/hurd/dl-sysdep.c: Include <not-cancel.h>.
(__pread64_nocancel): New alias, check that it is not hidden.
(__read_nocancel): New alias, check that it is not hidden.
* sysdeps/mach/hurd/Versions (libc.GLIBC_PRIVATE): Add __read_nocancel and
__pread64_nocancel.
(ld.GLIBC_2.1): Add __pread64.
(ld.GLIBC_PRIVATE): Add __read_nocancel and __pread64_nocancel.
* sysdeps/mach/hurd/i386/ld.abilist (__pread64): Add symbol.
* sysdeps/mach/hurd/i386/localplt.data (__read_nocancel, __pread64,
__pread64_nocancel): Add references.
endif
ifeq (io, $(subdir))
-sysdep_routines += f_setlk close_nocancel_nostatus
+sysdep_routines += f_setlk close_nocancel_nostatus read_nocancel \
+ pread64_nocancel
endif
ifeq ($(subdir),sunrpc)
GLIBC_PRIVATE {
# Functions shared with the dynamic linker
__access; __access_noerrno; __libc_read; __libc_write; __libc_lseek64;
+ __read_nocancel; __pread64_nocancel;
__libc_lock_self0; __getcwd;
_dl_init_first;
_exit; _hurd_intr_rpc_mach_msg;
abort;
}
+ GLIBC_2.1 {
+ # functions that must be shared with libc
+ __pread64;
+ }
GLIBC_2.2 {
# functions that must be shared with libc
__open64;
# functions that must be shared with libc
__access; __access_noerrno; __libc_read; __libc_write; __libc_lseek64;
+ __read_nocancel; __pread64_nocancel;
__libc_lock_self0; __getcwd;
}
}
#include <dl-tunables.h>
#include <not-errno.h>
+#include <not-cancel.h>
extern void __mach_init (void);
}
check_no_hidden(__pread64);
+check_no_hidden(__pread64_nocancel);
__ssize_t weak_function
__pread64 (int fd, void *buf, size_t nbytes, off64_t offset)
{
return nread;
}
libc_hidden_weak (__pread64)
+weak_alias (__pread64, __pread64_nocancel)
check_no_hidden(__read);
+check_no_hidden(__read_nocancel);
__ssize_t weak_function
__read (int fd, void *buf, size_t nbytes)
{
return __pread64 (fd, buf, nbytes, -1);
}
libc_hidden_weak (__read)
+weak_alias (__read, __read_nocancel)
check_no_hidden(__write);
__ssize_t weak_function
GLIBC_2.2.6 __mmap F
GLIBC_2.2.6 __open F
GLIBC_2.2.6 __open64 F
+GLIBC_2.2.6 __pread64 F
GLIBC_2.2.6 __read F
GLIBC_2.2.6 __sbrk F
GLIBC_2.2.6 __strtoul_internal F
ld.so: __open ?
ld.so: __open64
ld.so: __close
-ld.so: __read
+ld.so: __read ?
+ld.so: __read_nocancel
+ld.so: __pread64
+ld.so: __pread64_nocancel
ld.so: __write
ld.so: __writev
ld.so: __libc_lseek64
void __close_nocancel_nostatus (int fd);
-#define __read_nocancel(fd, buf, n) \
- __read (fd, buf, n)
-#define __pread64_nocancel(fd, buf, count, offset) \
- __pread64 (fd, buf, count, offset)
+/* Non cancellable read syscall. */
+__typeof (__read) __read_nocancel;
+
+/* Non cancellable pread syscall (LFS version). */
+__typeof (__pread64) __pread64_nocancel;
+
#define __write_nocancel(fd, buf, n) \
__write (fd, buf, n)
#define __writev_nocancel_nostatus(fd, iov, n) \
#define __fcntl64_nocancel(fd, cmd, ...) \
__fcntl64 (fd, cmd, __VA_ARGS__)
-#if IS_IN (libc) || IS_IN (rtld)
+#if IS_IN (libc)
+hidden_proto (__read_nocancel)
+hidden_proto (__pread64_nocancel)
hidden_proto (__close_nocancel_nostatus)
#endif
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#include <errno.h>
-#include <unistd.h>
-#include <hurd/fd.h>
+#include <sysdep-cancel.h>
+#include <not-cancel.h>
ssize_t
__libc_pread64 (int fd, void *buf, size_t nbytes, off64_t offset)
{
- error_t err;
- if (offset < 0)
- err = EINVAL;
- else
- err = HURD_FD_USE (fd, _hurd_fd_read (descriptor, buf, &nbytes, offset));
- return err ? __hurd_dfail (fd, err) : nbytes;
+ ssize_t ret;
+ int cancel_oldtype = LIBC_CANCEL_ASYNC();
+ ret = __pread64_nocancel (fd, buf, nbytes, offset);
+ LIBC_CANCEL_RESET (cancel_oldtype);
+ return ret;
}
#ifndef __libc_pread64
--- /dev/null
+/* Read block from given position in file without changing file pointer.
+ Hurd version.
+ Copyright (C) 2001-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/fd.h>
+#include <not-cancel.h>
+
+ssize_t
+__pread64_nocancel (int fd, void *buf, size_t nbytes, off64_t offset)
+{
+ error_t err;
+ if (offset < 0)
+ err = EINVAL;
+ else
+ err = HURD_FD_USE (fd, _hurd_fd_read (descriptor, buf, &nbytes, offset));
+ return err ? __hurd_dfail (fd, err) : nbytes;
+}
+libc_hidden_weak (__pread64_nocancel)
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#include <errno.h>
-#include <unistd.h>
-#include <hurd/fd.h>
+#include <sysdep-cancel.h>
+#include <not-cancel.h>
/* Read NBYTES into BUF from FD. Return the number read or -1. */
ssize_t
__libc_read (int fd, void *buf, size_t nbytes)
{
- error_t err = HURD_FD_USE (fd, _hurd_fd_read (descriptor, buf, &nbytes, -1));
- return err ? __hurd_dfail (fd, err) : nbytes;
+ ssize_t ret;
+ int cancel_oldtype = LIBC_CANCEL_ASYNC();
+ ret = __read_nocancel (fd, buf, nbytes);
+ LIBC_CANCEL_RESET (cancel_oldtype);
+ return ret;
}
libc_hidden_def (__libc_read)
weak_alias (__libc_read, __read)
--- /dev/null
+/* Copyright (C) 1993-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/fd.h>
+#include <not-cancel.h>
+
+/* Read NBYTES into BUF from FD. Return the number read or -1. */
+ssize_t
+__read_nocancel (int fd, void *buf, size_t nbytes)
+{
+ error_t err = HURD_FD_USE (fd, _hurd_fd_read (descriptor, buf, &nbytes, -1));
+ return err ? __hurd_dfail (fd, err) : nbytes;
+}
+libc_hidden_weak (__read_nocancel)