diff options
49 files changed, 288 insertions, 247 deletions
diff --git a/ChangeLog b/ChangeLog index e8e14deb3c..879f9ba959 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2002-12-08 Ulrich Drepper <drepper@redhat.com> + * scripts/output-format.sed: Fix bug in one of the s expressions + which used / for one too many things. + * include/unistd.h: Declare __libc_close. 2002-12-07 Ulrich Drepper <drepper@redhat.com> diff --git a/nptl/ChangeLog b/nptl/ChangeLog index d2544922a6..f9686e09cb 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -1,3 +1,58 @@ +2002-12-08 Ulrich Drepper <drepper@redhat.com> + + * pthreadP.h: Declare __pthread_enable_asynccancel and + __pthread_disable_asynccancel. + (CANCEL_ASYNC): Use __pthread_enable_asynccancel. + (CANCEL_RESET): Use __pthread_disable_asynccancel. + * cancellation.c (__pthread_enable_asynccancel): New function. + (__pthread_disable_asynccancel): New function. + * pt-accept.c: Adjust for CANCEL_ASYNC and CANCEL_RESET change. + * pt-close.c: Likewise. + * pt-connect.c: Likewise. + * pt-creat.c: Likewise. + * pt-fcntl.c: Likewise. + * pt-fsync.c: Likewise. + * pt-lseek.c: Likewise. + * pt-lseek64.c: Likewise. + * pt-msgrcv.c: Likewise. + * pt-msgsnd.c: Likewise. + * pt-msync.c: Likewise. + * pt-nanosleep.c: Likewise. + * pt-open.c: Likewise. + * pt-open64.c: Likewise. + * pt-pause.c: Likewise. + * pt-poll.c: Likewise. + * pt-pread.c: Likewise. + * pt-pread64.c: Likewise. + * pt-pselect.c: Likewise. + * pt-pwrite.c: Likewise. + * pt-pwrite64.c: Likewise. + * pt-read.c: Likewise. + * pt-readv.c: Likewise. + * pt-recv.c: Likewise. + * pt-recvfrom.c: Likewise. + * pt-recvmsg.c: Likewise. + * pt-select.c: Likewise. + * pt-send.c: Likewise. + * pt-sendmsg.c: Likewise. + * pt-sendto.c: Likewise. + * pt-sigpause.c: Likewise. + * pt-sigsuspend.c: Likewise. + * pt-sigtimedwait.c: Likewise. + * pt-sigwait.c: Likewise. + * pt-sigwaitinfo.c: Likewise. + * pt-system.c: Likewise. + * pt-tcdrain.c: Likewise. + * pt-wait.c: Likewise. + * pt-waitid.c: Likewise. + * pt-waitpid.c: Likewise. + * pt-write.c: Likewise. + * pt-writev.c: Likewise. + + * pt-sigpause.c (sigsuspend): Call __sigsuspend. + (__xpg_sigpause): New function. + * Versions (libpthread:GLIBC_2.3.2): Add __xpg_sigpause. + 2002-12-07 Ulrich Drepper <drepper@redhat.com> * Makefile (CFLAGS-ftrylockfile.c): Add -D_IO_MTSAFE_IO. diff --git a/nptl/Versions b/nptl/Versions index ce11c67295..e85db80a3a 100644 --- a/nptl/Versions +++ b/nptl/Versions @@ -190,12 +190,12 @@ libpthread { } # XXX Adjust number for final release. - GLIBC_2.3.1 { + GLIBC_2.3.2 { # Proposed API extensions. pthread_tryjoin_np; pthread_timedjoin_np; creat; poll; pselect; readv; select; sigpause; sigsuspend; sigwait; - sigwaitinfo; waitid; writev; + sigwaitinfo; waitid; writev; __xpg_sigpause; } GLIBC_PRIVATE { diff --git a/nptl/cancellation.c b/nptl/cancellation.c index 890b26ec4e..3cdc574880 100644 --- a/nptl/cancellation.c +++ b/nptl/cancellation.c @@ -20,6 +20,7 @@ #include <setjmp.h> #include <stdlib.h> #include "pthreadP.h" +#include "atomic.h" /* This function is responsible for calling all registered cleanup @@ -90,3 +91,64 @@ __cleanup_thread (struct pthread *self, char *currentframe) } } } + + +/* The next two functions are similar to pthread_setcanceltype() but + more specialized for the use in the cancelable functions like write(). + They do not need to check parameters etc. */ +int +attribute_hidden +__pthread_enable_asynccancel (void) +{ + struct pthread *self = THREAD_SELF; + int oldval; + + while (1) + { + oldval = THREAD_GETMEM (self, cancelhandling); + int newval = oldval | CANCELTYPE_BITMASK; + + if (newval == oldval) + break; + + if (atomic_compare_and_exchange_acq (&self->cancelhandling, newval, + oldval) == 0) + { + if (CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS (newval)) + { + THREAD_SETMEM (self, result, PTHREAD_CANCELED); + __do_cancel (CURRENT_STACK_FRAME); + } + + break; + } + } + + return oldval; +} + + +void +attribute_hidden +__pthread_disable_asynccancel (int oldtype) +{ + /* If asynchronous cancellation was enabled before we do not have + anything to do. */ + if (oldtype & CANCELTYPE_BITMASK) + return; + + struct pthread *self = THREAD_SELF; + + while (1) + { + int oldval = THREAD_GETMEM (self, cancelhandling); + int newval = oldval & ~CANCELTYPE_BITMASK; + + if (newval == oldval) + break; + + if (atomic_compare_and_exchange_acq (&self->cancelhandling, newval, + oldval) == 0) + break; + } +} diff --git a/nptl/pt-accept.c b/nptl/pt-accept.c index 09e2c52efd..1b25e9eff8 100644 --- a/nptl/pt-accept.c +++ b/nptl/pt-accept.c @@ -27,12 +27,9 @@ int accept (int fd, __SOCKADDR_ARG addr, socklen_t *addr_len) { - int oldtype; - int result; + int oldtype = CANCEL_ASYNC (); - CANCEL_ASYNC (oldtype); - - result = __libc_accept (fd, addr, addr_len); + int result = __libc_accept (fd, addr, addr_len); CANCEL_RESET (oldtype); diff --git a/nptl/pt-close.c b/nptl/pt-close.c index 85115c9c23..0edde5ea5d 100644 --- a/nptl/pt-close.c +++ b/nptl/pt-close.c @@ -27,15 +27,12 @@ int __close (int fd) { - int oldtype; - int result; - - CANCEL_ASYNC (oldtype); + int oldtype = CANCEL_ASYNC (); #ifdef INLINE_SYSCALL - result = INLINE_SYSCALL (close, 1, fd); + int result = INLINE_SYSCALL (close, 1, fd); #else - result = __libc_close (fd); + int result = __libc_close (fd); #endif CANCEL_RESET (oldtype); diff --git a/nptl/pt-connect.c b/nptl/pt-connect.c index 105cb6218d..44d2e3ae21 100644 --- a/nptl/pt-connect.c +++ b/nptl/pt-connect.c @@ -27,12 +27,9 @@ int __connect (int fd, __CONST_SOCKADDR_ARG addr, socklen_t addr_len) { - int oldtype; - int result; + int oldtype = CANCEL_ASYNC (); - CANCEL_ASYNC (oldtype); - - result = __libc_connect (fd, addr, addr_len); + int result = __libc_connect (fd, addr, addr_len); CANCEL_RESET (oldtype); diff --git a/nptl/pt-creat.c b/nptl/pt-creat.c index bdb5e4f561..f1783f1f60 100644 --- a/nptl/pt-creat.c +++ b/nptl/pt-creat.c @@ -28,15 +28,12 @@ int creat (const char *pathname, mode_t mode) { - int result; - int oldtype; - - CANCEL_ASYNC (oldtype); + int oldtype = CANCEL_ASYNC (); #if defined INLINE_SYSCALL && defined __NR_creat - result = INLINE_SYSCALL (creat, 2, pathname, mode); + int result = INLINE_SYSCALL (creat, 2, pathname, mode); #else - result = __libc_open (pathname, O_WRONLY|O_CREAT|O_TRUNC, mode); + int result = __libc_open (pathname, O_WRONLY|O_CREAT|O_TRUNC, mode); #endif CANCEL_RESET (oldtype); diff --git a/nptl/pt-fcntl.c b/nptl/pt-fcntl.c index 194f6ca52b..9d7f68e4c1 100644 --- a/nptl/pt-fcntl.c +++ b/nptl/pt-fcntl.c @@ -30,18 +30,17 @@ int __fcntl (int fd, int cmd, ...) { int oldtype; - int result; va_list ap; if (cmd == F_SETLKW) - CANCEL_ASYNC (oldtype); + oldtype = CANCEL_ASYNC (); va_start (ap, cmd); #ifdef INLINE_SYSCALL - result = INLINE_SYSCALL (fcntl, 3, fd, cmd, va_arg (ap, long int)); + int result = INLINE_SYSCALL (fcntl, 3, fd, cmd, va_arg (ap, long int)); #else - result = __libc_fcntl (fd, cmd, va_arg (ap, long int)); + int result = __libc_fcntl (fd, cmd, va_arg (ap, long int)); #endif va_end (ap); diff --git a/nptl/pt-fsync.c b/nptl/pt-fsync.c index 6c41912a7b..91fd266ed9 100644 --- a/nptl/pt-fsync.c +++ b/nptl/pt-fsync.c @@ -27,15 +27,12 @@ int fsync (int fd) { - int oldtype; - int result; - - CANCEL_ASYNC (oldtype); + int oldtype = CANCEL_ASYNC (); #ifdef INLINE_SYSCALL - result = INLINE_SYSCALL (fsync, 1, fd); + int result = INLINE_SYSCALL (fsync, 1, fd); #else - result = __libc_fsync (fd); + int result = __libc_fsync (fd); #endif CANCEL_RESET (oldtype); diff --git a/nptl/pt-lseek.c b/nptl/pt-lseek.c index 31e3ef700e..9b530ea9e7 100644 --- a/nptl/pt-lseek.c +++ b/nptl/pt-lseek.c @@ -27,15 +27,12 @@ off_t __lseek (int fd, off_t offset, int whence) { - int oldtype; - off_t result; - - CANCEL_ASYNC (oldtype); + int oldtype = CANCEL_ASYNC (); #ifdef INLINE_SYSCALL - result = INLINE_SYSCALL (lseek, 3, fd, offset, whence); + off_t result = INLINE_SYSCALL (lseek, 3, fd, offset, whence); #else - result = __libc_lseek (fd, offset, whence); + off_t result = __libc_lseek (fd, offset, whence); #endif CANCEL_RESET (oldtype); diff --git a/nptl/pt-lseek64.c b/nptl/pt-lseek64.c index f9faa16402..bdedd6e1cf 100644 --- a/nptl/pt-lseek64.c +++ b/nptl/pt-lseek64.c @@ -27,12 +27,9 @@ off64_t lseek64 (int fd, off64_t offset, int whence) { - int oldtype; - off64_t result; + int oldtype = CANCEL_ASYNC (); - CANCEL_ASYNC (oldtype); - - result = __libc_lseek64 (fd, offset, whence); + off64_t result = __libc_lseek64 (fd, offset, whence); CANCEL_RESET (oldtype); diff --git a/nptl/pt-msgrcv.c b/nptl/pt-msgrcv.c index b8bf6bc56c..383cefaa40 100644 --- a/nptl/pt-msgrcv.c +++ b/nptl/pt-msgrcv.c @@ -27,12 +27,9 @@ int msgrcv (int msqid, void *msgp, size_t msgsz, long int msgtyp, int msgflg) { - int oldtype; - int result; + int oldtype = CANCEL_ASYNC (); - CANCEL_ASYNC (oldtype); - - result = __libc_msgrcv (msqid, msgp, msgsz, msgtyp, msgflg); + int result = __libc_msgrcv (msqid, msgp, msgsz, msgtyp, msgflg); CANCEL_RESET (oldtype); diff --git a/nptl/pt-msgsnd.c b/nptl/pt-msgsnd.c index 4297f9dc4e..bc09779c2e 100644 --- a/nptl/pt-msgsnd.c +++ b/nptl/pt-msgsnd.c @@ -28,16 +28,13 @@ int msgsnd (int msqid, const void *msgp, size_t msgsz, int msgflg) { - int result; - int oldtype; + int oldtype = CANCEL_ASYNC (); - CANCEL_ASYNC (oldtype); - -#ifdef INLINE_SYSCALL - result = INLINE_SYSCALL (ipc, 5, IPCOP_msgsnd, msqid, msgsz, - msgflg, (void *) msgp); +#if defined INLINE_SYSCALL && defined __NR_ipc + int result = INLINE_SYSCALL (ipc, 5, IPCOP_msgsnd, msqid, msgsz, + msgflg, (void *) msgp); #else - result = __libc_msgsnd (msqid, msgp, msgsz, msgflg); + int result = __libc_msgsnd (msqid, msgp, msgsz, msgflg); #endif CANCEL_RESET (oldtype); diff --git a/nptl/pt-msync.c b/nptl/pt-msync.c index c1d64454ca..18f3eeb284 100644 --- a/nptl/pt-msync.c +++ b/nptl/pt-msync.c @@ -27,15 +27,12 @@ int msync (void *addr, size_t length, int flags) { - int oldtype; - int result; - - CANCEL_ASYNC (oldtype); + int oldtype = CANCEL_ASYNC (); #ifdef INLINE_SYSCALL - result = INLINE_SYSCALL (msync, 3, addr, length, flags); + int result = INLINE_SYSCALL (msync, 3, addr, length, flags); #else - result = __libc_msync (addr, length, flags); + int result = __libc_msync (addr, length, flags); #endif CANCEL_RESET (oldtype); diff --git a/nptl/pt-nanosleep.c b/nptl/pt-nanosleep.c index 1d6cbb5170..91f111766a 100644 --- a/nptl/pt-nanosleep.c +++ b/nptl/pt-nanosleep.c @@ -27,15 +27,12 @@ int __nanosleep (const struct timespec *requested_time, struct timespec *remaining) { - int oldtype; - int result; - - CANCEL_ASYNC (oldtype); + int oldtype = CANCEL_ASYNC (); #ifdef INLINE_SYSCALL - result = INLINE_SYSCALL (nanosleep, 2, requested_time, remaining); + int result = INLINE_SYSCALL (nanosleep, 2, requested_time, remaining); #else - result = __libc_nanosleep (requested_time, remaining); + int result = __libc_nanosleep (requested_time, remaining); #endif CANCEL_RESET (oldtype); diff --git a/nptl/pt-open.c b/nptl/pt-open.c index 00e06b1956..be790b8b90 100644 --- a/nptl/pt-open.c +++ b/nptl/pt-open.c @@ -28,20 +28,18 @@ int __open (const char *pathname, int flags, ...) { - int oldtype; - int result; va_list ap; va_start (ap, flags); - CANCEL_ASYNC (oldtype); + int oldtype = CANCEL_ASYNC (); #ifdef INLINE_SYSCALL - result = INLINE_SYSCALL (open, 3, pathname, flags, - va_arg (ap, __typeof ((mode_t) 0 + 0))); + int result = INLINE_SYSCALL (open, 3, pathname, flags, + va_arg (ap, __typeof ((mode_t) 0 + 0))); #else - result = __libc_open (pathname, flags, - va_arg (ap, __typeof ((mode_t) 0 + 0))); + int result = __libc_open (pathname, flags, + va_arg (ap, __typeof ((mode_t) 0 + 0))); #endif CANCEL_RESET (oldtype); diff --git a/nptl/pt-open64.c b/nptl/pt-open64.c index 25eec281f4..27757f5ed4 100644 --- a/nptl/pt-open64.c +++ b/nptl/pt-open64.c @@ -29,20 +29,18 @@ int __open64 (const char *pathname, int flags, ...) { - int oldtype; - int result; va_list ap; va_start (ap, flags); - CANCEL_ASYNC (oldtype); + int oldtype = CANCEL_ASYNC (); #if defined INLINE_SYSCALL && defined O_LARGEFILE - result = INLINE_SYSCALL (open, 3, pathname, flags | O_LARGEFILE, - va_arg (ap, __typeof ((mode_t) 0 + 0))); + int result = INLINE_SYSCALL (open, 3, pathname, flags | O_LARGEFILE, + va_arg (ap, __typeof ((mode_t) 0 + 0))); #else - result = __libc_open64 (pathname, flags, - va_arg (ap, __typeof ((mode_t) 0 + 0))); + int result = __libc_open64 (pathname, flags, + va_arg (ap, __typeof ((mode_t) 0 + 0))); #endif CANCEL_RESET (oldtype); diff --git a/nptl/pt-pause.c b/nptl/pt-pause.c index dbc6250789..bb878f0500 100644 --- a/nptl/pt-pause.c +++ b/nptl/pt-pause.c @@ -27,12 +27,9 @@ int pause (void) { - int oldtype; - int result; + int oldtype = CANCEL_ASYNC (); - CANCEL_ASYNC (oldtype); - - result = __libc_pause (); + int result = __libc_pause (); CANCEL_RESET (oldtype); diff --git a/nptl/pt-poll.c b/nptl/pt-poll.c index 65da7e6434..53b432bc7e 100644 --- a/nptl/pt-poll.c +++ b/nptl/pt-poll.c @@ -27,15 +27,12 @@ int poll (struct pollfd *fds, nfds_t nfds, int timeout) { - int result; - int oldtype; - - CANCEL_ASYNC (oldtype); + int oldtype =CANCEL_ASYNC (); #ifdef INLINE_SYSCALL - result = INLINE_SYSCALL (poll, 3, fds, nfds, timeout); + int result = INLINE_SYSCALL (poll, 3, fds, nfds, timeout); #else - result = __poll (fds, nfds, timeout); + int result = __poll (fds, nfds, timeout); #endif CANCEL_RESET (oldtype); diff --git a/nptl/pt-pread.c b/nptl/pt-pread.c index bcc7e0dc0c..6169ca8532 100644 --- a/nptl/pt-pread.c +++ b/nptl/pt-pread.c @@ -27,12 +27,9 @@ ssize_t pread (int fd, void *buf, size_t count, off_t offset) { - int oldtype; - ssize_t result; + int oldtype = CANCEL_ASYNC (); - CANCEL_ASYNC (oldtype); - - result = __libc_pread (fd, buf, count, offset); + ssize_t result = __libc_pread (fd, buf, count, offset); CANCEL_RESET (oldtype); diff --git a/nptl/pt-pread64.c b/nptl/pt-pread64.c index 1cf85f49b1..a80e3e0852 100644 --- a/nptl/pt-pread64.c +++ b/nptl/pt-pread64.c @@ -27,12 +27,9 @@ ssize_t __pread64 (int fd, void *buf, size_t count, off64_t offset) { - int oldtype; - ssize_t result; + int oldtype = CANCEL_ASYNC (); - CANCEL_ASYNC (oldtype); - - result = __libc_pread64 (fd, buf, count, offset); + ssize_t result = __libc_pread64 (fd, buf, count, offset); CANCEL_RESET (oldtype); diff --git a/nptl/pt-pselect.c b/nptl/pt-pselect.c index e935a07ccd..542a103925 100644 --- a/nptl/pt-pselect.c +++ b/nptl/pt-pselect.c @@ -28,12 +28,10 @@ int pselect (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const struct timespec *timeout, const sigset_t *sigmask) { - int result; - int oldtype; + int oldtype = CANCEL_ASYNC (); - CANCEL_ASYNC (oldtype); - - result = __pselect (nfds, readfds, writefds, exceptfds, timeout, sigmask); + int result = __pselect (nfds, readfds, writefds, exceptfds, timeout, + sigmask); CANCEL_RESET (oldtype); diff --git a/nptl/pt-pwrite.c b/nptl/pt-pwrite.c index 28910f60b7..e3906a1868 100644 --- a/nptl/pt-pwrite.c +++ b/nptl/pt-pwrite.c @@ -27,12 +27,9 @@ ssize_t pwrite (int fd, const void *buf, size_t count, off_t offset) { - int oldtype; - ssize_t result; + int oldtype = CANCEL_ASYNC (); - CANCEL_ASYNC (oldtype); - - result = __libc_pwrite (fd, buf, count, offset); + ssize_t result = __libc_pwrite (fd, buf, count, offset); CANCEL_RESET (oldtype); diff --git a/nptl/pt-pwrite64.c b/nptl/pt-pwrite64.c index abe4106182..18a9621220 100644 --- a/nptl/pt-pwrite64.c +++ b/nptl/pt-pwrite64.c @@ -27,12 +27,9 @@ ssize_t __pwrite64 (int fd, const void *buf, size_t count, off64_t offset) { - int oldtype; - ssize_t result; + int oldtype = CANCEL_ASYNC (); - CANCEL_ASYNC (oldtype); - - result = __libc_pwrite64 (fd, buf, count, offset); + ssize_t result = __libc_pwrite64 (fd, buf, count, offset); CANCEL_RESET (oldtype); diff --git a/nptl/pt-read.c b/nptl/pt-read.c index 8f31f0ceb4..7eaafa0cd6 100644 --- a/nptl/pt-read.c +++ b/nptl/pt-read.c @@ -27,15 +27,12 @@ ssize_t __read (int fd, void *buf, size_t count) { - int oldtype; - ssize_t result; - - CANCEL_ASYNC (oldtype); + int oldtype = CANCEL_ASYNC (); #ifdef INLINE_SYSCALL - result = INLINE_SYSCALL (read, 3, fd, buf, count); + ssize_t result = INLINE_SYSCALL (read, 3, fd, buf, count); #else - result = __libc_read (fd, buf, count); + ssize_t result = __libc_read (fd, buf, count); #endif CANCEL_RESET (oldtype); diff --git a/nptl/pt-readv.c b/nptl/pt-readv.c index 9f6e653d4f..e81c8306a1 100644 --- a/nptl/pt-readv.c +++ b/nptl/pt-readv.c @@ -24,9 +24,11 @@ #include "pthreadP.h" -/* Not all versions of the kernel support the large number of records. */ +/* Not all versions of the kernel support extremely the large number + of records. */ #ifndef UIO_FASTIOV -# define UIO_FASTIOV 8 /* 8 is a safe number. */ +/* 1024 is what the kernels with NPTL support use. */ +# define UIO_FASTIOV 1024 #endif @@ -36,21 +38,29 @@ readv (fd, vector, count) const struct iovec *vector; int count; { - int oldtype; - ssize_t result; - - CANCEL_ASYNC (oldtype); + int oldtype = CANCEL_ASYNC (); + ssize_t result; #ifdef INTERNAL_SYSCALL result = INTERNAL_SYSCALL (readv, 3, fd, vector, count); - if (INTERNAL_SYSCALL_ERROR_P (result) - && __builtin_expect (count > UIO_FASTIOV, 0)) -#elif defined INLINE_SYSCALL + if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result), 0)) + { + if (count <= UIO_FASTIOV) + { + __set_errno (INTERNAL_SYSCALL_ERRNO (result)); + result = -1; + } + else + result = __libc_readv (fd, vector, count); + } +#else +# if defined INLINE_SYSCALL result = INLINE_SYSCALL (readv, 3, fd, vector, count); if (result < 0 && errno == EINVAL && __builtin_expect (count > UIO_FASTIOV, 0)) -#endif +# endif result = __libc_readv (fd, vector, count); +#endif CANCEL_RESET (oldtype); diff --git a/nptl/pt-recv.c b/nptl/pt-recv.c index 0b9f7056a3..1280447864 100644 --- a/nptl/pt-recv.c +++ b/nptl/pt-recv.c @@ -27,12 +27,9 @@ ssize_t recv (int fd, __ptr_t buf, size_t n, int flags) { - int oldtype; - ssize_t result; + int oldtype = CANCEL_ASYNC (); - CANCEL_ASYNC (oldtype); - - result = __libc_recv (fd, buf, n, flags); + ssize_t result = __libc_recv (fd, buf, n, flags); CANCEL_RESET (oldtype); diff --git a/nptl/pt-recvfrom.c b/nptl/pt-recvfrom.c index 095b0b4b58..27d0195297 100644 --- a/nptl/pt-recvfrom.c +++ b/nptl/pt-recvfrom.c @@ -28,12 +28,9 @@ ssize_t recvfrom (int fd, __ptr_t buf, size_t n, int flags, __SOCKADDR_ARG addr, socklen_t *addr_len) { - int oldtype; - ssize_t result; + int oldtype = CANCEL_ASYNC (); - CANCEL_ASYNC (oldtype); - - result = __libc_recvfrom (fd, buf, n, flags, addr, addr_len); + ssize_t result = __libc_recvfrom (fd, buf, n, flags, addr, addr_len); CANCEL_RESET (oldtype); diff --git a/nptl/pt-recvmsg.c b/nptl/pt-recvmsg.c index e5ceaaad0c..e4f7dbfd39 100644 --- a/nptl/pt-recvmsg.c +++ b/nptl/pt-recvmsg.c @@ -27,12 +27,9 @@ ssize_t recvmsg (int fd, struct msghdr *message, int flags) { - int oldtype; - ssize_t result; + int oldtype = CANCEL_ASYNC (); - CANCEL_ASYNC (oldtype); - - result = __libc_recvmsg (fd, message, flags); + ssize_t result = __libc_recvmsg (fd, message, flags); CANCEL_RESET (oldtype); diff --git a/nptl/pt-select.c b/nptl/pt-select.c index 03e10cd08e..cb795c5936 100644 --- a/nptl/pt-select.c +++ b/nptl/pt-select.c @@ -28,16 +28,13 @@ int select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) { - int result; - int oldtype; - - CANCEL_ASYNC (oldtype); + int oldtype = CANCEL_ASYNC (); #if defined INLINE_SYSCALL && defined __NR__newselect - result = INLINE_SYSCALL (_newselect, 5, nfds, readfds, writefds, exceptfds, - timeout); + int result = INLINE_SYSCALL (_newselect, 5, nfds, readfds, writefds, + exceptfds, timeout); #else - result = __select (nfds, readfds, writefds, exceptfds, timeout); + int result = __select (nfds, readfds, writefds, exceptfds, timeout); #endif CANCEL_RESET (oldtype); diff --git a/nptl/pt-send.c b/nptl/pt-send.c index 90221adc24..5af725e36f 100644 --- a/nptl/pt-send.c +++ b/nptl/pt-send.c @@ -27,12 +27,9 @@ ssize_t __send (int fd, const __ptr_t buf, size_t n, int flags) { - int oldtype; - ssize_t result; + int oldtype = CANCEL_ASYNC (); - CANCEL_ASYNC (oldtype); - - result = __libc_send (fd, buf, n, flags); + ssize_t result = __libc_send (fd, buf, n, flags); CANCEL_RESET (oldtype); diff --git a/nptl/pt-sendmsg.c b/nptl/pt-sendmsg.c index 5b4d8b93cc..8017f0d402 100644 --- a/nptl/pt-sendmsg.c +++ b/nptl/pt-sendmsg.c @@ -27,12 +27,9 @@ ssize_t sendmsg (int fd, const struct msghdr *message, int flags) { - int oldtype; - ssize_t result; + int oldtype = CANCEL_ASYNC (); - CANCEL_ASYNC (oldtype); - - result = __libc_sendmsg (fd, message, flags); + ssize_t result = __libc_sendmsg (fd, message, flags); CANCEL_RESET (oldtype); diff --git a/nptl/pt-sendto.c b/nptl/pt-sendto.c index 6a81e61df2..1123bc41cb 100644 --- a/nptl/pt-sendto.c +++ b/nptl/pt-sendto.c @@ -28,12 +28,9 @@ ssize_t sendto (int fd, const __ptr_t buf, size_t n, int flags, __CONST_SOCKADDR_ARG addr, socklen_t addr_len) { - int oldtype; - ssize_t result; + int oldtype = CANCEL_ASYNC (); - CANCEL_ASYNC (oldtype); - - result = __libc_sendto (fd, buf, n, flags, addr, addr_len); + ssize_t result = __libc_sendto (fd, buf, n, flags, addr, addr_len); CANCEL_RESET (oldtype); diff --git a/nptl/pt-sigpause.c b/nptl/pt-sigpause.c index ad78662839..e35026bdf4 100644 --- a/nptl/pt-sigpause.c +++ b/nptl/pt-sigpause.c @@ -28,12 +28,22 @@ int sigpause (int mask) { - int oldtype; - int result; + int oldtype = CANCEL_ASYNC (); - CANCEL_ASYNC (oldtype); + int result = __sigpause (mask, 0); - result = sigpause (mask); + CANCEL_RESET (oldtype); + + return result; +} + + +int +__xpg_sigpause (int sig) +{ + int oldtype = CANCEL_ASYNC (); + + int result = __sigpause (sig, 1); CANCEL_RESET (oldtype); diff --git a/nptl/pt-sigsuspend.c b/nptl/pt-sigsuspend.c index d345b5dc50..e531a5b45c 100644 --- a/nptl/pt-sigsuspend.c +++ b/nptl/pt-sigsuspend.c @@ -27,15 +27,12 @@ int sigsuspend (const sigset_t *set) { - int result; - int oldtype; - - CANCEL_ASYNC (oldtype); + int oldtype = CANCEL_ASYNC (); #ifdef INLINE_SYSCALL - result = INLINE_SYSCALL (rt_sigsuspend, 2, set, _NSIG / 8); + int result = INLINE_SYSCALL (rt_sigsuspend, 2, set, _NSIG / 8); #else - result = __sigsuspend (set); + int result = __sigsuspend (set); #endif CANCEL_RESET (oldtype); diff --git a/nptl/pt-sigtimedwait.c b/nptl/pt-sigtimedwait.c index c2940f397e..f2a00d4c88 100644 --- a/nptl/pt-sigtimedwait.c +++ b/nptl/pt-sigtimedwait.c @@ -28,15 +28,13 @@ int sigtimedwait (const sigset_t *set, siginfo_t *info, const struct timespec *timeout) { - int result; - int oldtype; - - CANCEL_ASYNC (oldtype); + int oldtype = CANCEL_ASYNC (); #ifdef INLINE_SYSCALL - result = INLINE_SYSCALL (rt_sigtimedwait, 4, set, info, timeout, _NSIG / 8); + int result = INLINE_SYSCALL (rt_sigtimedwait, 4, set, info, timeout, + _NSIG / 8); #else - result = __sigtimedwait (set, info, timeout); + int result = __sigtimedwait (set, info, timeout); #endif CANCEL_RESET (oldtype); diff --git a/nptl/pt-sigwait.c b/nptl/pt-sigwait.c index efd05ed7d9..88dca893b8 100644 --- a/nptl/pt-sigwait.c +++ b/nptl/pt-sigwait.c @@ -27,13 +27,11 @@ int sigwait (const sigset_t *set, int *sig) { - int result; - int oldtype; - - CANCEL_ASYNC (oldtype); + int oldtype = CANCEL_ASYNC (); #ifdef INTERNAL_SYSCALL - result = INTERNAL_SYSCALL (rt_sigtimedwait, 4, set, NULL, NULL, _NSIG / 8); + int result = INTERNAL_SYSCALL (rt_sigtimedwait, 4, set, NULL, NULL, + _NSIG / 8); if (! INTERNAL_SYSCALL_ERROR_P (result)) { *sig = result; @@ -42,7 +40,7 @@ sigwait (const sigset_t *set, int *sig) else result = INTERNAL_SYSCALL_ERRNO (result); #elif defined INLINE_SYSCALL - result = INLINE_SYSCALL (rt_sigtimedwait, 4, set, NULL, NULL, _NSIG / 8); + int result = INLINE_SYSCALL (rt_sigtimedwait, 4, set, NULL, NULL, _NSIG / 8); if (result != -1) { *sig = result; @@ -51,7 +49,7 @@ sigwait (const sigset_t *set, int *sig) else result = errno; #else - result = __sigwait (set, sig); + int result = __sigwait (set, sig); #endif CANCEL_RESET (oldtype); diff --git a/nptl/pt-sigwaitinfo.c b/nptl/pt-sigwaitinfo.c index 961293b06c..49f402df17 100644 --- a/nptl/pt-sigwaitinfo.c +++ b/nptl/pt-sigwaitinfo.c @@ -27,15 +27,12 @@ int sigwaitinfo (const sigset_t *set, siginfo_t *info) { - int result; - int oldtype; - - CANCEL_ASYNC (oldtype); + int oldtype = CANCEL_ASYNC (); #ifdef INLINE_SYSCALL - result = INLINE_SYSCALL (rt_sigtimedwait, 4, set, info, NULL, _NSIG / 8); + int result = INLINE_SYSCALL (rt_sigtimedwait, 4, set, info, NULL, _NSIG / 8); #else - result = __sigwaitinfo (set, info); + int result = __sigwaitinfo (set, info); #endif CANCEL_RESET (oldtype); diff --git a/nptl/pt-system.c b/nptl/pt-system.c index 2572c477c8..d02f451893 100644 --- a/nptl/pt-system.c +++ b/nptl/pt-system.c @@ -27,12 +27,9 @@ int system (const char *line) { - int oldtype; - int result; + int oldtype = CANCEL_ASYNC (); - CANCEL_ASYNC (oldtype); - - result = __libc_system (line); + int result = __libc_system (line); CANCEL_RESET (oldtype); diff --git a/nptl/pt-tcdrain.c b/nptl/pt-tcdrain.c index 65af7b8092..ba1c4b77b4 100644 --- a/nptl/pt-tcdrain.c +++ b/nptl/pt-tcdrain.c @@ -27,12 +27,9 @@ int tcdrain (int fd) { - int oldtype; - int result; + int oldtype = CANCEL_ASYNC (); - CANCEL_ASYNC (oldtype); - - result = __libc_tcdrain (fd); + int result = __libc_tcdrain (fd); CANCEL_RESET (oldtype); diff --git a/nptl/pt-wait.c b/nptl/pt-wait.c index 951bba6b44..fa25f21343 100644 --- a/nptl/pt-wait.c +++ b/nptl/pt-wait.c @@ -27,12 +27,9 @@ pid_t __wait (__WAIT_STATUS_DEFN stat_loc) { - int oldtype; - pid_t result; + int oldtype = CANCEL_ASYNC (); - CANCEL_ASYNC (oldtype); - - result = __libc_wait (stat_loc); + pid_t result = __libc_wait (stat_loc); CANCEL_RESET (oldtype); diff --git a/nptl/pt-waitid.c b/nptl/pt-waitid.c index 977e5d4b77..ee8633cf49 100644 --- a/nptl/pt-waitid.c +++ b/nptl/pt-waitid.c @@ -27,12 +27,9 @@ int waitid (idtype_t idtype, id_t id, siginfo_t *infop, int options) { - int oldtype; - int result; + int oldtype = CANCEL_ASYNC (); - CANCEL_ASYNC (oldtype); - - result = __waitid (idtype, id, infop, options); + int result = __waitid (idtype, id, infop, options); CANCEL_RESET (oldtype); diff --git a/nptl/pt-waitpid.c b/nptl/pt-waitpid.c index 413328bea9..86fa30c4b4 100644 --- a/nptl/pt-waitpid.c +++ b/nptl/pt-waitpid.c @@ -27,12 +27,9 @@ pid_t waitpid (pid_t pid, int *stat_loc, int options) { - int oldtype; - pid_t result; + int oldtype = CANCEL_ASYNC (); - CANCEL_ASYNC (oldtype); - - result = __libc_waitpid (pid, stat_loc, options); + pid_t result = __libc_waitpid (pid, stat_loc, options); CANCEL_RESET (oldtype); diff --git a/nptl/pt-write.c b/nptl/pt-write.c index 190bea90ae..c8856e0835 100644 --- a/nptl/pt-write.c +++ b/nptl/pt-write.c @@ -27,15 +27,12 @@ ssize_t __write (int fd, const void *buf, size_t count) { - int oldtype; - ssize_t result; - - CANCEL_ASYNC (oldtype); + int oldtype = CANCEL_ASYNC (); #ifdef INLINE_SYSCALL - result = INLINE_SYSCALL (write, 3, fd, buf, count); + ssize_t result = INLINE_SYSCALL (write, 3, fd, buf, count); #else - result = __libc_write (fd, buf, count); + ssize_t result = __libc_write (fd, buf, count); #endif CANCEL_RESET (oldtype); diff --git a/nptl/pt-writev.c b/nptl/pt-writev.c index c1dda350aa..99e876c902 100644 --- a/nptl/pt-writev.c +++ b/nptl/pt-writev.c @@ -26,7 +26,8 @@ /* Not all versions of the kernel support the large number of records. */ #ifndef UIO_FASTIOV -# define UIO_FASTIOV 8 /* 8 is a safe number. */ +/* 1024 is what the kernels with NPTL support use. */ +# define UIO_FASTIOV 1024 #endif @@ -36,21 +37,29 @@ writev (fd, vector, count) const struct iovec *vector; int count; { - int oldtype; - ssize_t result; - - CANCEL_ASYNC (oldtype); + int oldtype = CANCEL_ASYNC (); + ssize_t result; #ifdef INTERNAL_SYSCALL result = INTERNAL_SYSCALL (writev, 3, fd, vector, count); - if (INTERNAL_SYSCALL_ERROR_P (result) - && __builtin_expect (count > UIO_FASTIOV, 0)) -#elif defined INLINE_SYSCALL + if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result), 0)) + { + if (count <= UIO_FASTIOV) + { + __set_errno (INTERNAL_SYSCALL_ERRNO (result)); + result = -1; + } + else + result = __libc_writev (fd, vector, count); + } +#else +# if defined INLINE_SYSCALL result = INLINE_SYSCALL (writev, 3, fd, vector, count); if (result < 0 && errno == EINVAL && __builtin_expect (count > UIO_FASTIOV, 0)) -#endif +# endif result = __libc_writev (fd, vector, count); +#endif CANCEL_RESET (oldtype); diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h index 74243d1382..c90b782722 100644 --- a/nptl/pthreadP.h +++ b/nptl/pthreadP.h @@ -79,11 +79,11 @@ extern int __pthread_debug attribute_hidden; } while (0) /* Set cancellation mode to asynchronous. */ -#define CANCEL_ASYNC(oldtype) \ - __pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype) +#define CANCEL_ASYNC() \ + __pthread_enable_asynccancel () /* Reset to previous cancellation mode. */ #define CANCEL_RESET(oldtype) \ - __pthread_setcanceltype (oldtype, NULL) + __pthread_disable_asynccancel (oldtype) /* Function performing the cancellation. */ extern void __do_cancel (char *currentframe) @@ -187,6 +187,8 @@ extern int __pthread_atfork (void (*prepare) (void), void (*parent) (void), void (*child) (void)); extern int __pthread_kill (pthread_t threadid, int signo); extern int __pthread_setcanceltype (int type, int *oldtype); +extern int __pthread_enable_asynccancel (void) attribute_hidden; +extern void __pthread_disable_asynccancel (int oldtype) attribute_hidden; /* Special versions which use non-exported functions. */ extern void _GI_pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer, diff --git a/nptl/sem_unlink.c b/nptl/sem_unlink.c index 87440f6932..92288df8be 100644 --- a/nptl/sem_unlink.c +++ b/nptl/sem_unlink.c @@ -33,7 +33,7 @@ sem_unlink (name) size_t namelen; /* Determine where the shmfs is mounted. */ - INTDEF(__pthread_once) (&__namedsem_once, __where_is_shmfs); + INTUSE(__pthread_once) (&__namedsem_once, __where_is_shmfs); /* If we don't know the mount points there is nothing we can do. Ever. */ if (mountpoint.dir == NULL) diff --git a/scripts/output-format.sed b/scripts/output-format.sed index f083a0911c..61e658a152 100644 --- a/scripts/output-format.sed +++ b/scripts/output-format.sed @@ -18,7 +18,7 @@ G s/\n// s/^\([^,]*\),\([^,]*\),B/OUTPUT_FORMAT(\1)/p s/^\([^,]*\),\([^,]*\),L/OUTPUT_FORMAT(\2)/p -/,/s/^/*** BUG in libc/scripts/output-format.sed *** /p +/,/s|^|*** BUG in libc/scripts/output-format.sed *** |p q : q s/"//g |