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>
+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.
}
# 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 {
#include <setjmp.h>
#include <stdlib.h>
#include "pthreadP.h"
+#include "atomic.h"
/* This function is responsible for calling all registered cleanup
}
}
}
+
+
+/* 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;
+ }
+}
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);
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);
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);
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);
__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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
int
pause (void)
{
- int oldtype;
- int result;
+ int oldtype = CANCEL_ASYNC ();
- CANCEL_ASYNC (oldtype);
-
- result = __libc_pause ();
+ int result = __libc_pause ();
CANCEL_RESET (oldtype);
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);
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);
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);
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);
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);
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);
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);
#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
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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;
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;
else
result = errno;
#else
- result = __sigwait (set, sig);
+ int result = __sigwait (set, sig);
#endif
CANCEL_RESET (oldtype);
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);
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);
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);
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);
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);
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);
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);
/* 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
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);
} 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)
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,
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)
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