diff options
Diffstat (limited to 'sysdeps/unix/sysv')
-rw-r--r-- | sysdeps/unix/sysv/linux/bits/socket.h | 12 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/kernel-features.h | 14 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/preadv.c | 88 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/preadv64.c | 6 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/pwritev.c | 88 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/pwritev64.c | 6 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/readv.c | 46 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/sys/eventfd.h | 2 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/wordsize-64/preadv64.c | 1 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/wordsize-64/pwritev64.c | 1 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/writev.c | 45 |
11 files changed, 261 insertions, 48 deletions
diff --git a/sysdeps/unix/sysv/linux/bits/socket.h b/sysdeps/unix/sysv/linux/bits/socket.h index 72c7335ae5..88062e59ad 100644 --- a/sysdeps/unix/sysv/linux/bits/socket.h +++ b/sysdeps/unix/sysv/linux/bits/socket.h @@ -95,15 +95,20 @@ enum __socket_type #define PF_ASH 18 /* Ash. */ #define PF_ECONET 19 /* Acorn Econet. */ #define PF_ATMSVC 20 /* ATM SVCs. */ +#define PF_RDS 21 /* RDS sockets. */ #define PF_SNA 22 /* Linux SNA Project */ #define PF_IRDA 23 /* IRDA sockets. */ #define PF_PPPOX 24 /* PPPoX sockets. */ #define PF_WANPIPE 25 /* Wanpipe API sockets. */ +#define PF_LLC 26 /* Linux LLC. */ +#define PF_CAN 29 /* Controller Area Network. */ +#define PF_TIPC 30 /* TIPC sockets. */ #define PF_BLUETOOTH 31 /* Bluetooth sockets. */ #define PF_IUCV 32 /* IUCV sockets. */ #define PF_RXRPC 33 /* RxRPC sockets. */ #define PF_ISDN 34 /* mISDN sockets. */ -#define PF_MAX 35 /* For now.. */ +#define PF_PHONET 35 /* Phonet sockets. */ +#define PF_MAX 36 /* For now.. */ /* Address families. */ #define AF_UNSPEC PF_UNSPEC @@ -130,14 +135,19 @@ enum __socket_type #define AF_ASH PF_ASH #define AF_ECONET PF_ECONET #define AF_ATMSVC PF_ATMSVC +#define AF_RDS PF_RDS #define AF_SNA PF_SNA #define AF_IRDA PF_IRDA #define AF_PPPOX PF_PPPOX #define AF_WANPIPE PF_WANPIPE +#define AF_LLC PF_LLC +#define AF_CAN PF_CAN +#define AF_TIPC PF_TIPC #define AF_BLUETOOTH PF_BLUETOOTH #define AF_IUCV PF_IUCV #define AF_RXRPC PF_RXRPC #define AF_ISDN PF_ISDN +#define AF_PHONET PF_PHONET #define AF_MAX PF_MAX /* Socket level values. Others are defined in the appropriate headers. diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h index 29afe27711..a640765b5c 100644 --- a/sysdeps/unix/sysv/linux/kernel-features.h +++ b/sysdeps/unix/sysv/linux/kernel-features.h @@ -462,6 +462,13 @@ # define __ASSUME_SET_ROBUST_LIST 1 #endif +/* Pessimistically assume that 2.6.18 introduced real handling of + large numbers of requests to readv and writev and that we don't + need a fallback. It likely worked for much longer. */ +#if __LINUX_KERNEL_VERSION >= 0x020612 +# define __ASSUME_COMPLETE_READV_WRITEV 1 +#endif + /* Support for PI futexes was added in 2.6.18. */ #if __LINUX_KERNEL_VERSION >= 0x020612 # define __ASSUME_FUTEX_LOCK_PI 1 @@ -522,3 +529,10 @@ #if __LINUX_KERNEL_VERSION >= 0x02061d # define __ASSUME_FUTEX_CLOCK_REALTIME 1 #endif + +/* Support for preadv and pwritev was added in 2.6.30. */ +#if __LINUX_KERNEL_VERSION >= 0x02061e \ + && (defined __i386__ || defined __x86_64__) +# define __ASSUME_PREADV 1 +# define __ASSUME_PWRITEV 1 +#endif diff --git a/sysdeps/unix/sysv/linux/preadv.c b/sysdeps/unix/sysv/linux/preadv.c new file mode 100644 index 0000000000..e2f8238596 --- /dev/null +++ b/sysdeps/unix/sysv/linux/preadv.c @@ -0,0 +1,88 @@ +/* Copyright (C) 2009 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, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <errno.h> +#include <stddef.h> +#include <sys/param.h> +#if __WORDSIZE == 64 +/* Hide the preadv64 declaration. */ +# define preadv64 __redirect_preadv64 +#endif +#include <sys/uio.h> + +#include <sysdep-cancel.h> +#include <sys/syscall.h> +#include <kernel-features.h> + +#ifndef PREADV +# define PREADV preadv +# define PREADV_REPLACEMENT __atomic_preadv_replacement +# define PREAD __pread +# define OFF_T off_t +#endif + +static ssize_t PREADV_REPLACEMENT (int, __const struct iovec *, + int, OFF_T) internal_function; + + +ssize_t +PREADV (fd, vector, count, offset) + int fd; + const struct iovec *vector; + int count; + OFF_T offset; +{ +#ifdef __NR_preadv + ssize_t result; + + if (SINGLE_THREAD_P) + result = INLINE_SYSCALL (preadv, 5, fd, vector, count, offset >> 32, + offset & 0xffffffff); + else + { + int oldtype = LIBC_CANCEL_ASYNC (); + + result = INLINE_SYSCALL (preadv, 5, fd, vector, count, offset >> 32, + offset & 0xffffffff); + + LIBC_CANCEL_RESET (oldtype); + } +# ifdef __ASSUME_PREADV + return result; +# endif +#endif + +#ifndef __ASSUME_PREADV +# ifdef __NR_preadv + if (result >= 0 || errno != ENOSYS) + return result; +# endif + + return PREADV_REPLACEMENT (fd, vector, count, offset); +#endif +} +#if __WORDSIZE == 64 +# undef preadv64 +strong_alias (preadv, preadv64) +#endif + +#ifndef __ASSUME_PREADV +# undef PREADV +# define PREADV static internal_function PREADV_REPLACEMENT +# include <sysdeps/posix/preadv.c> +#endif diff --git a/sysdeps/unix/sysv/linux/preadv64.c b/sysdeps/unix/sysv/linux/preadv64.c new file mode 100644 index 0000000000..739df00257 --- /dev/null +++ b/sysdeps/unix/sysv/linux/preadv64.c @@ -0,0 +1,6 @@ +#define PREADV preadv64 +#define PREADV_REPLACEMENT __atomic_preadv64_replacement +#define PREAD __pread64 +#define OFF_T off64_t + +#include "preadv.c" diff --git a/sysdeps/unix/sysv/linux/pwritev.c b/sysdeps/unix/sysv/linux/pwritev.c new file mode 100644 index 0000000000..df430ffe46 --- /dev/null +++ b/sysdeps/unix/sysv/linux/pwritev.c @@ -0,0 +1,88 @@ +/* Copyright (C) 2009 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, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <errno.h> +#include <stddef.h> +#include <sys/param.h> +#if __WORDSIZE == 64 && !defined PWRITEV +/* Hide the pwritev64 declaration. */ +# define pwritev64 __redirect_pwritev64 +#endif +#include <sys/uio.h> + +#include <sysdep-cancel.h> +#include <sys/syscall.h> +#include <kernel-features.h> + +#ifndef PWRITEV +# define PWRITEV pwritev +# define PWRITEV_REPLACEMENT __atomic_pwritev_replacement +# define PWRITE __pwrite +# define OFF_T off_t +#endif + +static ssize_t PWRITEV_REPLACEMENT (int, __const struct iovec *, + int, OFF_T) internal_function; + + +ssize_t +PWRITEV (fd, vector, count, offset) + int fd; + const struct iovec *vector; + int count; + OFF_T offset; +{ +#ifdef __NR_pwritev + ssize_t result; + + if (SINGLE_THREAD_P) + result = INLINE_SYSCALL (pwritev, 5, fd, vector, count, offset >> 32, + offset & 0xffffffff); + else + { + int oldtype = LIBC_CANCEL_ASYNC (); + + result = INLINE_SYSCALL (pwritev, 5, fd, vector, count, offset >> 32, + offset & 0xffffffff); + + LIBC_CANCEL_RESET (oldtype); + } +# ifdef __ASSUME_PWRITEV + return result; +# endif +#endif + +#ifndef __ASSUME_PWRITEV +# ifdef __NR_pwritev + if (result >= 0 || errno != ENOSYS) + return result; +# endif + + return PWRITEV_REPLACEMENT (fd, vector, count, offset); +#endif +} +#if __WORDSIZE == 64 && defined pwritev64 +# undef pwritev64 +strong_alias (pwritev, pwritev64) +#endif + +#ifndef __ASSUME_PWRITEV +# undef PWRITEV +# define PWRITEV static internal_function PWRITEV_REPLACEMENT +# include <sysdeps/posix/pwritev.c> +#endif diff --git a/sysdeps/unix/sysv/linux/pwritev64.c b/sysdeps/unix/sysv/linux/pwritev64.c new file mode 100644 index 0000000000..1e8168f103 --- /dev/null +++ b/sysdeps/unix/sysv/linux/pwritev64.c @@ -0,0 +1,6 @@ +#define PWRITEV pwritev64 +#define PWRITEV_REPLACEMENT __atomic_pwritev64_replacement +#define PWRITE __pwrite64 +#define OFF_T off64_t + +#include "pwritev.c" diff --git a/sysdeps/unix/sysv/linux/readv.c b/sysdeps/unix/sysv/linux/readv.c index 250c00a075..bff4a3ff74 100644 --- a/sysdeps/unix/sysv/linux/readv.c +++ b/sysdeps/unix/sysv/linux/readv.c @@ -1,5 +1,5 @@ /* readv supports all Linux kernels >= 2.0. - Copyright (C) 1997,1998,2000,2002,2003 Free Software Foundation, Inc. + Copyright (C) 1997,1998,2000,2002,2003,2009 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 @@ -25,6 +25,7 @@ #include <sysdep-cancel.h> #include <sys/syscall.h> #include <bp-checks.h> +#include <kernel-features.h> static ssize_t __atomic_readv_replacement (int, __const struct iovec *, int) internal_function; @@ -36,41 +37,38 @@ static ssize_t __atomic_readv_replacement (int, __const struct iovec *, #endif -/* We should deal with kernel which have a smaller UIO_FASTIOV as well - as a very big count. */ -static ssize_t -do_readv (int fd, const struct iovec *vector, int count) -{ - ssize_t bytes_read; - - bytes_read = INLINE_SYSCALL (readv, 3, fd, CHECK_N (vector, count), count); - - if (bytes_read >= 0 || errno != EINVAL || count <= UIO_FASTIOV) - return bytes_read; - - return __atomic_readv_replacement (fd, vector, count); -} - - ssize_t __libc_readv (fd, vector, count) int fd; const struct iovec *vector; int count; { - if (SINGLE_THREAD_P) - return do_readv (fd, vector, count); + ssize_t result; - int oldtype = LIBC_CANCEL_ASYNC (); + if (SINGLE_THREAD_P) + result = INLINE_SYSCALL (readv, 3, fd, CHECK_N (vector, count), count); + else + { + int oldtype = LIBC_CANCEL_ASYNC (); - int result = do_readv (fd, vector, count); + result = INLINE_SYSCALL (readv, 3, fd, CHECK_N (vector, count), count); - LIBC_CANCEL_RESET (oldtype); + LIBC_CANCEL_RESET (oldtype); + } +#ifdef __ASSUME_COMPLETE_READV_WRITEV return result; +#else + if (result >= 0 || errno != EINVAL || count <= UIO_FASTIOV) + return result; + + return __atomic_readv_replacement (fd, vector, count); +#endif } strong_alias (__libc_readv, __readv) weak_alias (__libc_readv, readv) -#define __libc_readv static internal_function __atomic_readv_replacement -#include <sysdeps/posix/readv.c> +#ifndef __ASSUME_COMPLETE_READV_WRITEV +# define __libc_readv static internal_function __atomic_readv_replacement +# include <sysdeps/posix/readv.c> +#endif diff --git a/sysdeps/unix/sysv/linux/sys/eventfd.h b/sysdeps/unix/sysv/linux/sys/eventfd.h index 7c6cf7196d..d942df4bf9 100644 --- a/sysdeps/unix/sysv/linux/sys/eventfd.h +++ b/sysdeps/unix/sysv/linux/sys/eventfd.h @@ -28,6 +28,8 @@ typedef uint64_t eventfd_t; /* Flags for signalfd. */ enum { + EFD_SEMAPHORE = 1, +#define EFD_SEMAPHORE EFD_SEMAPHORE EFD_CLOEXEC = 02000000, #define EFD_CLOEXEC EFD_CLOEXEC EFD_NONBLOCK = 04000 diff --git a/sysdeps/unix/sysv/linux/wordsize-64/preadv64.c b/sysdeps/unix/sysv/linux/wordsize-64/preadv64.c new file mode 100644 index 0000000000..fd9320cfc7 --- /dev/null +++ b/sysdeps/unix/sysv/linux/wordsize-64/preadv64.c @@ -0,0 +1 @@ +/* Empty since the preadv syscall is equivalent. */ diff --git a/sysdeps/unix/sysv/linux/wordsize-64/pwritev64.c b/sysdeps/unix/sysv/linux/wordsize-64/pwritev64.c new file mode 100644 index 0000000000..8b72a2928b --- /dev/null +++ b/sysdeps/unix/sysv/linux/wordsize-64/pwritev64.c @@ -0,0 +1 @@ +/* Empty since the pwritev syscall is equivalent. */ diff --git a/sysdeps/unix/sysv/linux/writev.c b/sysdeps/unix/sysv/linux/writev.c index 05978665fa..55e915d34d 100644 --- a/sysdeps/unix/sysv/linux/writev.c +++ b/sysdeps/unix/sysv/linux/writev.c @@ -1,5 +1,5 @@ /* writev supports all Linux kernels >= 2.0. - Copyright (C) 1997, 1998, 2000, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1997,1998,2000,2002,2003,2009 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 @@ -25,6 +25,7 @@ #include <sysdep-cancel.h> #include <sys/syscall.h> #include <bp-checks.h> +#include <kernel-features.h> static ssize_t __atomic_writev_replacement (int, const struct iovec *, int) internal_function; @@ -36,40 +37,38 @@ static ssize_t __atomic_writev_replacement (int, const struct iovec *, #endif -/* We should deal with kernel which have a smaller UIO_FASTIOV as well - as a very big count. */ -static ssize_t -do_writev (int fd, const struct iovec *vector, int count) -{ - ssize_t bytes_written; - - bytes_written = INLINE_SYSCALL (writev, 3, fd, CHECK_N (vector, count), count); - - if (bytes_written >= 0 || errno != EINVAL || count <= UIO_FASTIOV) - return bytes_written; - - return __atomic_writev_replacement (fd, vector, count); -} - ssize_t __libc_writev (fd, vector, count) int fd; const struct iovec *vector; int count; { - if (SINGLE_THREAD_P) - return do_writev (fd, vector, count); + ssize_t result; - int oldtype = LIBC_CANCEL_ASYNC (); + if (SINGLE_THREAD_P) + result = INLINE_SYSCALL (writev, 3, fd, CHECK_N (vector, count), count); + else + { + int oldtype = LIBC_CANCEL_ASYNC (); - ssize_t result = do_writev (fd, vector, count); + result = INLINE_SYSCALL (writev, 3, fd, CHECK_N (vector, count), count); - LIBC_CANCEL_RESET (oldtype); + LIBC_CANCEL_RESET (oldtype); + } +#ifdef __ASSUME_COMPLETE_READV_WRITEV return result; +#else + if (result >= 0 || errno != EINVAL || count <= UIO_FASTIOV) + return result; + + return __atomic_writev_replacement (fd, vector, count); +#endif } strong_alias (__libc_writev, __writev) weak_alias (__libc_writev, writev) -#define __libc_writev static internal_function __atomic_writev_replacement -#include <sysdeps/posix/writev.c> +#ifndef __ASSUME_COMPLETE_READV_WRITEV +# define __libc_writev static internal_function __atomic_writev_replacement +# include <sysdeps/posix/writev.c> +#endif |