diff options
Diffstat (limited to 'sysdeps/unix/sysv/linux')
-rw-r--r-- | sysdeps/unix/sysv/linux/Makefile | 2 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/getlogin_r.c | 17 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/internal_recvmmsg.S | 14 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/kernel-features.h | 55 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/recvmmsg.c | 100 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/sh/sh4/register-dump.h | 4 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/socketcall.h | 1 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/sys/timex.h | 6 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/syscalls.list | 1 |
9 files changed, 153 insertions, 47 deletions
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index 91c123b2b3..9c53b2d228 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -12,7 +12,7 @@ CFLAGS-malloc.c += -DMORECORE_CLEARS=2 endif ifeq ($(subdir),socket) -sysdep_routines += internal_accept4 +sysdep_routines += internal_accept4 recvmmsg internal_recvmmsg endif ifeq ($(subdir),misc) diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c index d9c66fe259..dad2671e80 100644 --- a/sysdeps/unix/sysv/linux/getlogin_r.c +++ b/sysdeps/unix/sysv/linux/getlogin_r.c @@ -81,13 +81,22 @@ __getlogin_r_loginuid (name, namesize) if (tpwd == NULL) goto fail; - strncpy (name, pwd.pw_name, namesize - 1); - name[namesize - 1] = '\0'; - + int result = 0; + size_t needed = strlen (pwd.pw_name) + 1; + if (needed > namesize) + { + __set_errno (ERANGE); + result = ERANGE; + goto out; + } + + memcpy (name, pwd.pw_name, needed); + + out: if (use_malloc) free (buf); - return 0; + return result; } diff --git a/sysdeps/unix/sysv/linux/internal_recvmmsg.S b/sysdeps/unix/sysv/linux/internal_recvmmsg.S new file mode 100644 index 0000000000..66c1357940 --- /dev/null +++ b/sysdeps/unix/sysv/linux/internal_recvmmsg.S @@ -0,0 +1,14 @@ +#include <kernel-features.h> +#include <sys/syscall.h> +#if !defined __NR_recvmmsg && defined __NR_socketcall +# define socket recvmmsg +# ifdef __ASSUME_RECVMMSG +# define __socket recvmmsg +# else +# define __socket __internal_recvmmsg +# endif +# define NARGS 5 +# define NEED_CANCELLATION +# define NO_WEAK_ALIAS +# include <socket.S> +#endif diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h index 275668b23c..b3f2456150 100644 --- a/sysdeps/unix/sysv/linux/kernel-features.h +++ b/sysdeps/unix/sysv/linux/kernel-features.h @@ -176,7 +176,7 @@ distinguish this version from other 2.4.0 releases. Therefore play save and assume it available is for 2.4.1 and up. However, SH is lame, and still does not have a 64-bit inode field. */ -#if __LINUX_KERNEL_VERSION >= 132097 && !defined __alpha__ && !defined __sh__ +#if __LINUX_KERNEL_VERSION >= 132097 && !defined __sh__ # define __ASSUME_ST_INO_64_BIT 1 #endif @@ -270,11 +270,6 @@ # define __ASSUME_VFORK_SYSCALL 1 #endif -/* Alpha switched to a 64-bit timeval sometime before 2.2.0. */ -#if __LINUX_KERNEL_VERSION >= 131584 && defined __alpha__ -# define __ASSUME_TIMEVAL64 1 -#endif - /* The late 2.5 kernels saw a lot of new CLONE_* flags. Summarize their availability with one define. The changes were made first for i386 and the have to be done separately for the other archs. @@ -327,12 +322,9 @@ # define __ASSUME_CORRECT_SI_PID 1 #endif -/* The tgkill syscall was instroduced for i386 in 2.5.75. For Alpha - it was introduced in 2.6.0-test1 which unfortunately cannot be - distinguished from 2.6.0. On x86-64, ppc, and ppc64 it was - introduced in 2.6.0-test3. */ +/* The tgkill syscall was instroduced for i386 in 2.5.75. On x86-64, + ppc, and ppc64 it was introduced in 2.6.0-test3. */ #if (__LINUX_KERNEL_VERSION >= 132427 && defined __i386__) \ - || (__LINUX_KERNEL_VERSION >= 132609 && defined __alpha__) \ || (__LINUX_KERNEL_VERSION >= 132609 && defined __x86_64__) \ || (__LINUX_KERNEL_VERSION >= 132609 && defined __powerpc__) \ || (__LINUX_KERNEL_VERSION >= 132609 && defined __sh__) @@ -342,8 +334,7 @@ /* The utimes syscall has been available for some architectures forever. For x86 it was introduced after 2.5.75, for x86-64, ppc, and ppc64 it was introduced in 2.6.0-test3. */ -#if defined __alpha__ || defined __ia64__ \ - || defined __sparc__ \ +#if defined __ia64__ || defined __sparc__ \ || (__LINUX_KERNEL_VERSION > 132427 && defined __i386__) \ || (__LINUX_KERNEL_VERSION > 132609 && defined __x86_64__) \ || (__LINUX_KERNEL_VERSION >= 132609 && defined __powerpc__) \ @@ -410,11 +401,6 @@ # define __ASSUME_WAITID_SYSCALL 1 #endif -/* Starting with version 2.6.9, SSI_IEEE_RAISE_EXCEPTION exists. */ -#if __LINUX_KERNEL_VERSION >= 0x020609 && defined __alpha__ -# define __ASSUME_IEEE_RAISE_EXCEPTION 1 -#endif - /* On sparc64 stat64/lstat64/fstat64 syscalls were introduced in 2.6.12. */ #if __LINUX_KERNEL_VERSION >= 0x02060c && defined __sparc__ \ && defined __arch64__ @@ -431,34 +417,28 @@ /* pselect/ppoll were introduced just after 2.6.16-rc1. Due to the way the kernel versions are advertised we can only rely on 2.6.17 to have the code. On x86_64 and SH this appeared first in 2.6.19-rc1, - on ia64 in 2.6.22-rc1 and on alpha just after 2.6.22-rc1. */ + on ia64 in 2.6.22-rc1. */ #if __LINUX_KERNEL_VERSION >= 0x020611 \ - && ((!defined __x86_64__ && !defined __sh__ && !defined __ia64__ \ - && !defined __alpha__) \ + && ((!defined __x86_64__ && !defined __sh__ && !defined __ia64__) \ || (__LINUX_KERNEL_VERSION >= 0x020613 \ && (defined __x86_64__ || defined __sh__)) \ - || (__LINUX_KERNEL_VERSION >= 0x020616 && defined __ia64__) \ - || (__LINUX_KERNEL_VERSION >= 0x020617 && defined __alpha__)) + || (__LINUX_KERNEL_VERSION >= 0x020616 && defined __ia64__)) # define __ASSUME_PSELECT 1 # define __ASSUME_PPOLL 1 #endif /* The *at syscalls were introduced just after 2.6.16-rc1. Due to the way the kernel versions are advertised we can only rely on 2.6.17 to have - the code. On PPC they were introduced in 2.6.17-rc1, on SH in 2.6.19-rc1 - and on Alpha just after 2.6.22-rc1. */ + the code. On PPC they were introduced in 2.6.17-rc1, + on SH in 2.6.19-rc1. */ #if __LINUX_KERNEL_VERSION >= 0x020611 \ - && ((!defined __sh__ && !defined __alpha__) \ - || (__LINUX_KERNEL_VERSION >= 0x020613 && defined __sh__) \ - || (__LINUX_KERNEL_VERSION >= 0x020617 && defined __alpha__)) + && (!defined __sh__ || __LINUX_KERNEL_VERSION >= 0x020613) # define __ASSUME_ATFCTS 1 #endif /* Support for inter-process robust mutexes was added in 2.6.17. */ #if __LINUX_KERNEL_VERSION >= 0x020611 \ - && ((!defined __sh__ && !defined __alpha__) \ - || (__LINUX_KERNEL_VERSION >= 0x020613 && defined __sh__) \ - || (__LINUX_KERNEL_VERSION >= 0x020617 && defined __alpha__)) + && (!defined __sh__ || __LINUX_KERNEL_VERSION >= 0x020613) # define __ASSUME_SET_ROBUST_LIST 1 #endif @@ -474,11 +454,10 @@ # define __ASSUME_FUTEX_LOCK_PI 1 #endif -/* Support for utimensat syscall was added in 2.6.22, on alpha and s390 +/* Support for utimensat syscall was added in 2.6.22, on SH only after 2.6.22-rc1. */ #if __LINUX_KERNEL_VERSION >= 0x020616 \ - && ((!defined __sh__ && !defined __alpha__) \ - || __LINUX_KERNEL_VERSION >= 0x020617) + && (!defined __sh__ || __LINUX_KERNEL_VERSION >= 0x020617) # define __ASSUME_UTIMENSAT 1 #endif @@ -490,8 +469,7 @@ /* Support for fallocate was added in 2.6.23, on s390 only after 2.6.23-rc1. */ #if __LINUX_KERNEL_VERSION >= 0x020617 \ - && ((!defined __s390__ && !defined __alpha__) \ - || (__LINUX_KERNEL_VERSION >= 0x020618 && defined __s390__)) + && (!defined __s390__ || __LINUX_KERNEL_VERSION >= 0x020618) # define __ASSUME_FALLOCATE 1 #endif @@ -547,3 +525,8 @@ #if __LINUX_KERNEL_VERSION >= 0x020620 # define __ASSUME_F_GETOWN_EX 1 #endif + +/* Support for the recvmmsg syscall was added in 2.6.33. */ +#if __LINUX_KERNEL_VERSION >= 0x020621 +# define __ASSUME_RECVMMSG 1 +#endif diff --git a/sysdeps/unix/sysv/linux/recvmmsg.c b/sysdeps/unix/sysv/linux/recvmmsg.c new file mode 100644 index 0000000000..0c08171d4c --- /dev/null +++ b/sysdeps/unix/sysv/linux/recvmmsg.c @@ -0,0 +1,100 @@ +/* Copyright (C) 2010 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Andreas Schwab <schwab@redhat.com>, 2010. + + 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 <sys/socket.h> + +#include <sysdep-cancel.h> +#include <sys/syscall.h> +#include <kernel-features.h> + + +#ifdef __NR_recvmmsg +int +recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags, + const struct timespec *tmo) +{ + if (SINGLE_THREAD_P) + return INLINE_SYSCALL (recvmmsg, 5, fd, vmessages, vlen, flags, tmo); + + int oldtype = LIBC_CANCEL_ASYNC (); + + int result = INLINE_SYSCALL (recvmmsg, 5, fd, vmessages, vlen, flags, tmo); + + LIBC_CANCEL_RESET (oldtype); + + return result; +} +#elif defined __NR_socketcall +# ifndef __ASSUME_RECVMMSG +extern int __internal_recvmmsg (int fd, struct mmsghdr *vmessages, + unsigned int vlen, int flags, + const struct timespec *tmo) + attribute_hidden; + +static int have_recvmmsg; + +int +recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags, + const struct timespec *tmo) +{ + if (__builtin_expect (have_recvmmsg >= 0, 1)) + { + int ret = __internal_recvmmsg (fd, vmessages, vlen, flags, tmo); + /* The kernel returns -EINVAL for unknown socket operations. + We need to convert that error to an ENOSYS error. */ + if (__builtin_expect (ret < 0, 0) + && have_recvmmsg == 0 + && errno == EINVAL) + { + /* Try another call, this time with an invalid file + descriptor and all other parameters cleared. This call + will not cause any harm and it will return + immediately. */ + ret = __internal_recvmmsg (-1, 0, 0, 0, 0); + if (errno == EINVAL) + { + have_recvmmsg = -1; + __set_errno (ENOSYS); + } + else + { + have_recvmmsg = 1; + __set_errno (EINVAL); + } + return -1; + } + return ret; + } + __set_errno (ENOSYS); + return -1; +} +# else +/* When __ASSUME_RECVMMSG recvmmsg is defined in internal_recvmmsg.S. */ +# endif +#else +int +recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags, + const struct timespec *tmo) +{ + __set_errno (ENOSYS); + return -1; +} +stub_warning (recvmmsg) +#endif diff --git a/sysdeps/unix/sysv/linux/sh/sh4/register-dump.h b/sysdeps/unix/sysv/linux/sh/sh4/register-dump.h index e3c9c0e639..92df0858e1 100644 --- a/sysdeps/unix/sysv/linux/sh/sh4/register-dump.h +++ b/sysdeps/unix/sysv/linux/sh/sh4/register-dump.h @@ -1,5 +1,5 @@ /* Dump registers. - Copyright (C) 1999, 2000, 2009 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2009, 2010 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 @@ -58,7 +58,7 @@ register_dump (int fd, struct sigcontext *ctx) { char regs[22][8]; char fpregs[34][8]; - struct iovec iov[112]; + struct iovec iov[22 * 2 + 34 * 2 + 2]; size_t nr = 0; #define ADD_STRING(str) \ diff --git a/sysdeps/unix/sysv/linux/socketcall.h b/sysdeps/unix/sysv/linux/socketcall.h index adf01b6e10..bab4e4a510 100644 --- a/sysdeps/unix/sysv/linux/socketcall.h +++ b/sysdeps/unix/sysv/linux/socketcall.h @@ -44,5 +44,6 @@ #define SOCKOP_sendmsg 16 #define SOCKOP_recvmsg 17 #define SOCKOP_accept4 18 +#define SOCKOP_recvmmsg 19 #endif /* sys/socketcall.h */ diff --git a/sysdeps/unix/sysv/linux/sys/timex.h b/sysdeps/unix/sysv/linux/sys/timex.h index e10311f70f..13b94d6f4f 100644 --- a/sysdeps/unix/sysv/linux/sys/timex.h +++ b/sysdeps/unix/sysv/linux/sys/timex.h @@ -140,9 +140,9 @@ __BEGIN_DECLS extern int __adjtimex (struct timex *__ntx) __THROW; extern int adjtimex (struct timex *__ntx) __THROW; -#if defined __GNUC__ && __GNUC__ >= 2 -extern int ntp_gettime (struct ntptimeval *__ntv) - __asm__ ("ntp_gettimex") __THROW; +#ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (ntp_gettime, (struct ntptimeval *__ntv), + ntp_gettimex); #else extern int ntp_gettimex (struct ntptimeval *__ntv) __THROW; # define ntp_gettime ntp_gettimex diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list index a1a449eb4b..a87906a4e3 100644 --- a/sysdeps/unix/sysv/linux/syscalls.list +++ b/sysdeps/unix/sysv/linux/syscalls.list @@ -53,7 +53,6 @@ prctl EXTRA prctl i:iiiii __prctl prctl putpmsg - putpmsg i:ippii putpmsg query_module EXTRA query_module i:sipip query_module quotactl EXTRA quotactl i:isip quotactl -recvmmsg EXTRA recvmmsg Ci:ipiip recvmmsg remap_file_pages - remap_file_pages i:piiii __remap_file_pages remap_file_pages sched_getp - sched_getparam i:ip __sched_getparam sched_getparam sched_gets - sched_getscheduler i:i __sched_getscheduler sched_getscheduler |