aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/sysv')
-rw-r--r--sysdeps/unix/sysv/linux/Makefile4
-rw-r--r--sysdeps/unix/sysv/linux/accept.S6
-rw-r--r--sysdeps/unix/sysv/linux/accept.c31
-rw-r--r--sysdeps/unix/sysv/linux/accept4.c25
-rw-r--r--sysdeps/unix/sysv/linux/arm/internal_accept4.S6
-rw-r--r--sysdeps/unix/sysv/linux/arm/internal_recvmmsg.S6
-rw-r--r--sysdeps/unix/sysv/linux/arm/internal_sendmmsg.S6
-rw-r--r--sysdeps/unix/sysv/linux/bind.S3
-rw-r--r--sysdeps/unix/sysv/linux/bind.c29
-rw-r--r--sysdeps/unix/sysv/linux/connect.S7
-rw-r--r--sysdeps/unix/sysv/linux/connect.c32
-rw-r--r--sysdeps/unix/sysv/linux/getpeername.S3
-rw-r--r--sysdeps/unix/sysv/linux/getpeername.c29
-rw-r--r--sysdeps/unix/sysv/linux/getsockname.S3
-rw-r--r--sysdeps/unix/sysv/linux/getsockname.c29
-rw-r--r--sysdeps/unix/sysv/linux/getsockopt.S3
-rw-r--r--sysdeps/unix/sysv/linux/getsockopt.c29
-rw-r--r--sysdeps/unix/sysv/linux/hppa/socket.S10
-rw-r--r--sysdeps/unix/sysv/linux/i386/accept4.S177
-rw-r--r--sysdeps/unix/sysv/linux/i386/internal_accept4.S1
-rw-r--r--sysdeps/unix/sysv/linux/i386/socket.S122
-rw-r--r--sysdeps/unix/sysv/linux/internal_accept4.S24
-rw-r--r--sysdeps/unix/sysv/linux/internal_recvmmsg.S24
-rw-r--r--sysdeps/unix/sysv/linux/internal_sendmmsg.S25
-rw-r--r--sysdeps/unix/sysv/linux/kernel-features.h5
-rw-r--r--sysdeps/unix/sysv/linux/listen.S5
-rw-r--r--sysdeps/unix/sysv/linux/listen.c29
-rw-r--r--sysdeps/unix/sysv/linux/m68k/socket.S122
-rw-r--r--sysdeps/unix/sysv/linux/microblaze/socket.S126
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips32/internal_accept4.S2
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips32/internal_recvmmsg.S2
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips32/internal_sendmmsg.S2
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/powerpc32/socket.S118
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/powerpc64/socket.S134
-rw-r--r--sysdeps/unix/sysv/linux/recv.S6
-rw-r--r--sysdeps/unix/sysv/linux/recv.c31
-rw-r--r--sysdeps/unix/sysv/linux/recvfrom.S6
-rw-r--r--sysdeps/unix/sysv/linux/recvfrom.c33
-rw-r--r--sysdeps/unix/sysv/linux/recvmmsg.c25
-rw-r--r--sysdeps/unix/sysv/linux/recvmsg.S6
-rw-r--r--sysdeps/unix/sysv/linux/recvmsg.c31
-rw-r--r--sysdeps/unix/sysv/linux/s390/s390-32/socket.S142
-rw-r--r--sysdeps/unix/sysv/linux/s390/s390-64/socket.S136
-rw-r--r--sysdeps/unix/sysv/linux/send.S7
-rw-r--r--sysdeps/unix/sysv/linux/send.c32
-rw-r--r--sysdeps/unix/sysv/linux/sendmmsg.c22
-rw-r--r--sysdeps/unix/sysv/linux/sendmsg.S6
-rw-r--r--sysdeps/unix/sysv/linux/sendmsg.c31
-rw-r--r--sysdeps/unix/sysv/linux/sendto.S6
-rw-r--r--sysdeps/unix/sysv/linux/sendto.c33
-rw-r--r--sysdeps/unix/sysv/linux/setsockopt.S5
-rw-r--r--sysdeps/unix/sysv/linux/setsockopt.c29
-rw-r--r--sysdeps/unix/sysv/linux/sh/socket.S179
-rw-r--r--sysdeps/unix/sysv/linux/shutdown.S3
-rw-r--r--sysdeps/unix/sysv/linux/shutdown.c29
-rw-r--r--sysdeps/unix/sysv/linux/socket.c29
-rw-r--r--sysdeps/unix/sysv/linux/socketcall.h55
-rw-r--r--sysdeps/unix/sysv/linux/socketpair.S3
-rw-r--r--sysdeps/unix/sysv/linux/socketpair.c29
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc32/socket.S116
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc64/socket.S118
61 files changed, 609 insertions, 1718 deletions
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index c26a12fa11..bfbabd4b4b 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -11,10 +11,6 @@ ifeq ($(subdir),malloc)
CFLAGS-malloc.c += -DMORECORE_CLEARS=2
endif
-ifeq ($(subdir),socket)
-sysdep_routines += internal_accept4 internal_recvmmsg internal_sendmmsg
-endif
-
ifeq ($(subdir),misc)
include $(firstword $(wildcard $(sysdirs:=/sysctl.mk)))
diff --git a/sysdeps/unix/sysv/linux/accept.S b/sysdeps/unix/sysv/linux/accept.S
deleted file mode 100644
index 491ebe2ab2..0000000000
--- a/sysdeps/unix/sysv/linux/accept.S
+++ /dev/null
@@ -1,6 +0,0 @@
-#define socket accept
-#define __socket __libc_accept
-#define NARGS 3
-#define NEED_CANCELLATION
-#include <socket.S>
-libc_hidden_def (accept)
diff --git a/sysdeps/unix/sysv/linux/accept.c b/sysdeps/unix/sysv/linux/accept.c
new file mode 100644
index 0000000000..72d42a7d85
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/accept.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 2015 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <signal.h>
+#include <sys/socket.h>
+
+#include <sysdep-cancel.h>
+#include <socketcall.h>
+
+int
+__libc_accept (int fd, __SOCKADDR_ARG addr, socklen_t *len)
+{
+ return SOCKETCALL_CANCEL (accept, fd, addr.__sockaddr__, len);
+}
+weak_alias (__libc_accept, accept)
+libc_hidden_def (accept)
diff --git a/sysdeps/unix/sysv/linux/accept4.c b/sysdeps/unix/sysv/linux/accept4.c
index 5dbcef3ef0..ec6b4c236d 100644
--- a/sysdeps/unix/sysv/linux/accept4.c
+++ b/sysdeps/unix/sysv/linux/accept4.c
@@ -50,11 +50,14 @@ accept4 (int fd, __SOCKADDR_ARG addr, socklen_t *addr_len, int flags)
return result;
}
#elif defined __NR_socketcall
-# ifndef __ASSUME_ACCEPT4_SOCKETCALL
-extern int __internal_accept4 (int fd, __SOCKADDR_ARG addr,
- socklen_t *addr_len, int flags)
- attribute_hidden;
-
+# include <socketcall.h>
+# ifdef __ASSUME_ACCEPT4_SOCKETCALL
+int
+accept4 (int fd, __SOCKADDR_ARG addr, socklen_t *addr_len, int flags)
+{
+ return SOCKETCALL_CANCEL (accept4, fd, addr.__sockaddr__, addr_len, flags);
+}
+# else
static int have_accept4;
int
@@ -62,7 +65,8 @@ accept4 (int fd, __SOCKADDR_ARG addr, socklen_t *addr_len, int flags)
{
if (__glibc_likely (have_accept4 >= 0))
{
- int ret = __internal_accept4 (fd, addr, addr_len, flags);
+ int ret = SOCKETCALL_CANCEL (accept4, fd, addr.__sockaddr__, addr_len,
+ flags);
/* The kernel returns -EINVAL for unknown socket operations.
We need to convert that error to an ENOSYS error. */
if (__builtin_expect (ret < 0, 0)
@@ -72,7 +76,7 @@ accept4 (int fd, __SOCKADDR_ARG addr, socklen_t *addr_len, int flags)
/* Try another call, this time with the FLAGS parameter
cleared and an invalid file descriptor. This call will not
cause any harm and it will return immediately. */
- ret = __internal_accept4 (-1, addr, addr_len, 0);
+ ret = SOCKETCALL_CANCEL (invalid, -1);
if (errno == EINVAL)
{
have_accept4 = -1;
@@ -90,11 +94,8 @@ accept4 (int fd, __SOCKADDR_ARG addr, socklen_t *addr_len, int flags)
__set_errno (ENOSYS);
return -1;
}
-# else
-/* When __ASSUME_ACCEPT4_SOCKETCALL accept4 is defined in
- internal_accept4.S. */
-# endif
-#else
+# endif /* __ASSUME_ACCEPT4_SOCKETCALL */
+#else /* __NR_socketcall */
int
accept4 (int fd, __SOCKADDR_ARG addr, socklen_t *addr_len, int flags)
{
diff --git a/sysdeps/unix/sysv/linux/arm/internal_accept4.S b/sysdeps/unix/sysv/linux/arm/internal_accept4.S
deleted file mode 100644
index eeb5f50a26..0000000000
--- a/sysdeps/unix/sysv/linux/arm/internal_accept4.S
+++ /dev/null
@@ -1,6 +0,0 @@
-/* Tag_ABI_align8_preserved: This code preserves 8-byte
- alignment in any callee. */
- .eabi_attribute 25, 1
-/* Tag_ABI_align8_needed: This code may require 8-byte alignment from
- the caller. */
- .eabi_attribute 24, 1
diff --git a/sysdeps/unix/sysv/linux/arm/internal_recvmmsg.S b/sysdeps/unix/sysv/linux/arm/internal_recvmmsg.S
deleted file mode 100644
index eeb5f50a26..0000000000
--- a/sysdeps/unix/sysv/linux/arm/internal_recvmmsg.S
+++ /dev/null
@@ -1,6 +0,0 @@
-/* Tag_ABI_align8_preserved: This code preserves 8-byte
- alignment in any callee. */
- .eabi_attribute 25, 1
-/* Tag_ABI_align8_needed: This code may require 8-byte alignment from
- the caller. */
- .eabi_attribute 24, 1
diff --git a/sysdeps/unix/sysv/linux/arm/internal_sendmmsg.S b/sysdeps/unix/sysv/linux/arm/internal_sendmmsg.S
deleted file mode 100644
index eeb5f50a26..0000000000
--- a/sysdeps/unix/sysv/linux/arm/internal_sendmmsg.S
+++ /dev/null
@@ -1,6 +0,0 @@
-/* Tag_ABI_align8_preserved: This code preserves 8-byte
- alignment in any callee. */
- .eabi_attribute 25, 1
-/* Tag_ABI_align8_needed: This code may require 8-byte alignment from
- the caller. */
- .eabi_attribute 24, 1
diff --git a/sysdeps/unix/sysv/linux/bind.S b/sysdeps/unix/sysv/linux/bind.S
deleted file mode 100644
index 61fb5ebff8..0000000000
--- a/sysdeps/unix/sysv/linux/bind.S
+++ /dev/null
@@ -1,3 +0,0 @@
-#define socket bind
-#define NARGS 3
-#include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/bind.c b/sysdeps/unix/sysv/linux/bind.c
new file mode 100644
index 0000000000..db72df6c77
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/bind.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 2015 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <signal.h>
+#include <sys/socket.h>
+
+#include <socketcall.h>
+
+int
+__bind (int fd, __CONST_SOCKADDR_ARG addr, socklen_t len)
+{
+ return SOCKETCALL (bind, fd, addr.__sockaddr__, len, 0, 0, 0);
+}
+weak_alias (__bind, bind)
diff --git a/sysdeps/unix/sysv/linux/connect.S b/sysdeps/unix/sysv/linux/connect.S
deleted file mode 100644
index 21fc4a64c9..0000000000
--- a/sysdeps/unix/sysv/linux/connect.S
+++ /dev/null
@@ -1,7 +0,0 @@
-#define socket connect
-#define __socket __libc_connect
-#define NARGS 3
-#define NEED_CANCELLATION
-#include <socket.S>
-weak_alias (__libc_connect, __connect)
-libc_hidden_weak (__connect)
diff --git a/sysdeps/unix/sysv/linux/connect.c b/sysdeps/unix/sysv/linux/connect.c
new file mode 100644
index 0000000000..dd17e8ca97
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/connect.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 2015 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <signal.h>
+#include <sys/socket.h>
+
+#include <sysdep-cancel.h>
+#include <socketcall.h>
+
+int
+__libc_connect (int fd, __CONST_SOCKADDR_ARG addr, socklen_t len)
+{
+ return SOCKETCALL_CANCEL (connect, fd, addr.__sockaddr__, len);
+}
+weak_alias (__libc_connect, connect)
+weak_alias (__libc_connect, __connect)
+libc_hidden_weak (__connect)
diff --git a/sysdeps/unix/sysv/linux/getpeername.S b/sysdeps/unix/sysv/linux/getpeername.S
deleted file mode 100644
index a6d8e86d4e..0000000000
--- a/sysdeps/unix/sysv/linux/getpeername.S
+++ /dev/null
@@ -1,3 +0,0 @@
-#define socket getpeername
-#define NARGS 3
-#include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/getpeername.c b/sysdeps/unix/sysv/linux/getpeername.c
new file mode 100644
index 0000000000..05fd2e8e31
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/getpeername.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 2015 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <signal.h>
+#include <sys/socket.h>
+
+#include <socketcall.h>
+
+int
+__getpeername (int fd, __SOCKADDR_ARG addr, socklen_t *len)
+{
+ return SOCKETCALL (getpeername, fd, addr.__sockaddr__, len);
+}
+weak_alias (__getpeername, getpeername)
diff --git a/sysdeps/unix/sysv/linux/getsockname.S b/sysdeps/unix/sysv/linux/getsockname.S
deleted file mode 100644
index c138be9da5..0000000000
--- a/sysdeps/unix/sysv/linux/getsockname.S
+++ /dev/null
@@ -1,3 +0,0 @@
-#define socket getsockname
-#define NARGS 3
-#include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/getsockname.c b/sysdeps/unix/sysv/linux/getsockname.c
new file mode 100644
index 0000000000..6c84acec25
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/getsockname.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 2015 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <signal.h>
+#include <sys/socket.h>
+
+#include <socketcall.h>
+
+int
+__getsockname (int fd, __SOCKADDR_ARG addr, socklen_t *len)
+{
+ return SOCKETCALL (getsockname, fd, addr.__sockaddr__, len);
+}
+weak_alias (__getsockname, getsockname)
diff --git a/sysdeps/unix/sysv/linux/getsockopt.S b/sysdeps/unix/sysv/linux/getsockopt.S
deleted file mode 100644
index 6f982082ae..0000000000
--- a/sysdeps/unix/sysv/linux/getsockopt.S
+++ /dev/null
@@ -1,3 +0,0 @@
-#define socket getsockopt
-#define NARGS 5
-#include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/getsockopt.c b/sysdeps/unix/sysv/linux/getsockopt.c
new file mode 100644
index 0000000000..ba5681b410
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/getsockopt.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 2015 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <signal.h>
+#include <sys/socket.h>
+
+#include <socketcall.h>
+
+int
+__getsockopt (int fd, int level, int optname, void *optval, socklen_t *len)
+{
+ return SOCKETCALL (getsockopt, fd, level, optname, optval, len);
+}
+weak_alias (__getsockopt, getsockopt)
diff --git a/sysdeps/unix/sysv/linux/hppa/socket.S b/sysdeps/unix/sysv/linux/hppa/socket.S
deleted file mode 100644
index dfbb721a82..0000000000
--- a/sysdeps/unix/sysv/linux/hppa/socket.S
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <sysdep.h>
-
- .globl __socket
-PSEUDO(__socket, socket, 3)
-
-PSEUDO_END(__socket)
-
-#ifndef NO_WEAK_ALIAS
-weak_alias (__socket, socket)
-#endif
diff --git a/sysdeps/unix/sysv/linux/i386/accept4.S b/sysdeps/unix/sysv/linux/i386/accept4.S
deleted file mode 100644
index 6ed8395d09..0000000000
--- a/sysdeps/unix/sysv/linux/i386/accept4.S
+++ /dev/null
@@ -1,177 +0,0 @@
-/* Copyright (C) 1995-2015 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
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep-cancel.h>
-#include <socketcall.h>
-#include <tls.h>
-#include <kernel-features.h>
-
-#define EINVAL 22
-#define ENOSYS 38
-
-#ifdef __ASSUME_ACCEPT4_SOCKETCALL
-# define errlabel SYSCALL_ERROR_LABEL
-#else
-# define errlabel .Lerr
- .data
-have_accept4:
- .long 0
-#endif
-
- .text
-/* The socket-oriented system calls are handled unusally in Linux/i386.
- They are all gated through the single `socketcall' system call number.
- `socketcall' takes two arguments: the first is the subcode, specifying
- which socket function is being called; and the second is a pointer to
- the arguments to the specific function. */
-
-.globl __libc_accept4
-ENTRY (__libc_accept4)
-#ifdef CENABLE
- SINGLE_THREAD_P
- jne 1f
-#endif
-
- /* Save registers. */
- movl %ebx, %edx
- cfi_register (3, 2)
-
- movl $SYS_ify(socketcall), %eax /* System call number in %eax. */
-
- movl $SOCKOP_accept4, %ebx /* Subcode is first arg to syscall. */
- lea 4(%esp), %ecx /* Address of args is 2nd arg. */
-
- /* Do the system call trap. */
- ENTER_KERNEL
-
- /* Restore registers. */
- movl %edx, %ebx
- cfi_restore (3)
-
- /* %eax is < 0 if there was an error. */
- cmpl $-125, %eax
- jae errlabel
-
- /* Successful; return the syscall's value. */
- ret
-
-
-#ifdef CENABLE
- /* We need one more register. */
-1: pushl %esi
- cfi_adjust_cfa_offset(4)
-
- /* Enable asynchronous cancellation. */
- CENABLE
- movl %eax, %esi
- cfi_offset(6, -8) /* %esi */
-
- /* Save registers. */
- movl %ebx, %edx
- cfi_register (3, 2)
-
- movl $SYS_ify(socketcall), %eax /* System call number in %eax. */
-
- movl $SOCKOP_accept4, %ebx /* Subcode is first arg to syscall. */
- lea 8(%esp), %ecx /* Address of args is 2nd arg. */
-
- /* Do the system call trap. */
- ENTER_KERNEL
-
- /* Restore registers. */
- movl %edx, %ebx
- cfi_restore (3)
-
- /* Restore the cancellation. */
- xchgl %esi, %eax
- CDISABLE
-
- /* Restore registers. */
- movl %esi, %eax
- popl %esi
- cfi_restore (6)
- cfi_adjust_cfa_offset(-4)
-
- /* %eax is < 0 if there was an error. */
- cmpl $-125, %eax
- jae errlabel
-
- /* Successful; return the syscall's value. */
- ret
-#endif
-
-#ifndef __ASSUME_ACCEPT4_SOCKETCALL
- /* The kernel returns -EINVAL for unknown socket operations.
- We need to convert that error to an ENOSYS error. */
-.Lerr: cmpl $-EINVAL, %eax
- jne SYSCALL_ERROR_LABEL
-
- /* Save registers. */
- pushl %ebx
- cfi_adjust_cfa_offset(4)
- cfi_offset(ebx, -8)
-
-# ifdef PIC
- SETUP_PIC_REG (dx)
- addl $_GLOBAL_OFFSET_TABLE_, %edx
- movl have_accept4@GOTOFF(%edx), %eax
-# else
- movl have_accept4, %eax
-# endif
- testl %eax, %eax
- jne 1f
-
- /* Try another call, this time with the FLAGS parameter
- cleared and an invalid file descriptor. This call will not
- cause any harm and it will return immediately. */
- movl $-1, 8(%esp)
- movl $0, 20(%esp)
-
- movl $SYS_ify(socketcall), %eax /* System call number in %eax. */
-
- movl $SOCKOP_accept4, %ebx /* Subcode is first arg to syscall. */
- lea 8(%esp), %ecx /* Address of args is 2nd arg. */
-
- /* Do the system call trap. */
- ENTER_KERNEL
-
- cmpl $-EINVAL, %eax
- movl $-1, %eax
- je 3f
- movl $1, %eax
-3:
-# ifdef PIC
- movl %eax, have_accept4@GOTOFF(%edx)
-# else
- movl %eax, have_accept4
-# endif
-
- testl %eax, %eax
-
-1: movl $-EINVAL, %eax
- jns 2f
- movl $-ENOSYS, %eax
-
- /* Restore registers. */
-2: popl %ebx
- cfi_restore (ebx)
-
- jmp SYSCALL_ERROR_LABEL
-#endif
-PSEUDO_END (__libc_accept4)
-
-weak_alias (__libc_accept4, accept4)
diff --git a/sysdeps/unix/sysv/linux/i386/internal_accept4.S b/sysdeps/unix/sysv/linux/i386/internal_accept4.S
deleted file mode 100644
index c3f1630494..0000000000
--- a/sysdeps/unix/sysv/linux/i386/internal_accept4.S
+++ /dev/null
@@ -1 +0,0 @@
-/* Not needed, accept4.S has everything. */
diff --git a/sysdeps/unix/sysv/linux/i386/socket.S b/sysdeps/unix/sysv/linux/i386/socket.S
deleted file mode 100644
index d87390c662..0000000000
--- a/sysdeps/unix/sysv/linux/i386/socket.S
+++ /dev/null
@@ -1,122 +0,0 @@
-/* Copyright (C) 1995-2015 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
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep-cancel.h>
-#include <socketcall.h>
-#include <tls.h>
-
-#define P(a, b) P2(a, b)
-#define P2(a, b) a##b
-
- .text
-/* The socket-oriented system calls are handled unusally in Linux/i386.
- They are all gated through the single `socketcall' system call number.
- `socketcall' takes two arguments: the first is the subcode, specifying
- which socket function is being called; and the second is a pointer to
- the arguments to the specific function.
-
- The .S files for the other calls just #define socket and #include this. */
-
-#ifndef __socket
-# ifndef NO_WEAK_ALIAS
-# define __socket P(__,socket)
-# else
-# define __socket socket
-# endif
-#endif
-
-.globl __socket
-ENTRY (__socket)
-#if defined NEED_CANCELLATION && defined CENABLE
- SINGLE_THREAD_P
- jne 1f
-#endif
-
- /* Save registers. */
- movl %ebx, %edx
- cfi_register (3, 2)
-
- movl $SYS_ify(socketcall), %eax /* System call number in %eax. */
-
- /* Use ## so `socket' is a separate token that might be #define'd. */
- movl $P(SOCKOP_,socket), %ebx /* Subcode is first arg to syscall. */
- lea 4(%esp), %ecx /* Address of args is 2nd arg. */
-
- /* Do the system call trap. */
- ENTER_KERNEL
-
- /* Restore registers. */
- movl %edx, %ebx
- cfi_restore (3)
-
- /* %eax is < 0 if there was an error. */
- cmpl $-125, %eax
- jae SYSCALL_ERROR_LABEL
-
- /* Successful; return the syscall's value. */
- ret
-
-
-#if defined NEED_CANCELLATION && defined CENABLE
- /* We need one more register. */
-1: pushl %esi
- cfi_adjust_cfa_offset(4)
-
- /* Enable asynchronous cancellation. */
- CENABLE
- movl %eax, %esi
- cfi_offset(6, -8) /* %esi */
-
- /* Save registers. */
- movl %ebx, %edx
- cfi_register (3, 2)
-
- movl $SYS_ify(socketcall), %eax /* System call number in %eax. */
-
- /* Use ## so `socket' is a separate token that might be #define'd. */
- movl $P(SOCKOP_,socket), %ebx /* Subcode is first arg to syscall. */
- lea 8(%esp), %ecx /* Address of args is 2nd arg. */
-
- /* Do the system call trap. */
- ENTER_KERNEL
-
- /* Restore registers. */
- movl %edx, %ebx
- cfi_restore (3)
-
- /* Restore the cancellation. */
- xchgl %esi, %eax
- CDISABLE
-
- /* Restore registers. */
- movl %esi, %eax
- popl %esi
- cfi_restore (6)
- cfi_adjust_cfa_offset(-4)
-
- /* %eax is < 0 if there was an error. */
- cmpl $-125, %eax
- jae SYSCALL_ERROR_LABEL
-
- /* Successful; return the syscall's value. */
- ret
-#endif
-PSEUDO_END (__socket)
-
-#ifndef NO_WEAK_ALIAS
-weak_alias (__socket, socket)
-#endif
diff --git a/sysdeps/unix/sysv/linux/internal_accept4.S b/sysdeps/unix/sysv/linux/internal_accept4.S
deleted file mode 100644
index f0c61b55b1..0000000000
--- a/sysdeps/unix/sysv/linux/internal_accept4.S
+++ /dev/null
@@ -1,24 +0,0 @@
-#include <kernel-features.h>
-#include <sys/syscall.h>
-
-/* Do not use the accept4 syscall on socketcall architectures unless
- it was added at the same time as the socketcall support or can be
- assumed to be present. */
-#if defined __ASSUME_SOCKETCALL \
- && !defined __ASSUME_ACCEPT4_SYSCALL_WITH_SOCKETCALL \
- && !defined __ASSUME_ACCEPT4_SYSCALL
-# undef __NR_accept4
-#endif
-
-#if !defined __NR_accept4 && defined __NR_socketcall
-# define socket accept4
-# ifdef __ASSUME_ACCEPT4_SOCKETCALL
-# define __socket accept4
-# else
-# define __socket __internal_accept4
-# endif
-# define NARGS 4
-# define NEED_CANCELLATION
-# define NO_WEAK_ALIAS
-# include <socket.S>
-#endif
diff --git a/sysdeps/unix/sysv/linux/internal_recvmmsg.S b/sysdeps/unix/sysv/linux/internal_recvmmsg.S
deleted file mode 100644
index 6b776b9d6a..0000000000
--- a/sysdeps/unix/sysv/linux/internal_recvmmsg.S
+++ /dev/null
@@ -1,24 +0,0 @@
-#include <kernel-features.h>
-#include <sys/syscall.h>
-
-/* Do not use the recvmmsg syscall on socketcall architectures unless
- it was added at the same time as the socketcall support or can be
- assumed to be present. */
-#if defined __ASSUME_SOCKETCALL \
- && !defined __ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL \
- && !defined __ASSUME_RECVMMSG_SYSCALL
-# undef __NR_recvmmsg
-#endif
-
-#if !defined __NR_recvmmsg && defined __NR_socketcall
-# define socket recvmmsg
-# ifdef __ASSUME_RECVMMSG_SOCKETCALL
-# 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/internal_sendmmsg.S b/sysdeps/unix/sysv/linux/internal_sendmmsg.S
deleted file mode 100644
index 4d903ea729..0000000000
--- a/sysdeps/unix/sysv/linux/internal_sendmmsg.S
+++ /dev/null
@@ -1,25 +0,0 @@
-#include <kernel-features.h>
-#include <sys/syscall.h>
-
-/* Do not use the sendmmsg syscall on socketcall architectures unless
- it was added at the same time as the socketcall support or can be
- assumed to be present. */
-#if defined __ASSUME_SOCKETCALL \
- && !defined __ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL \
- && !defined __ASSUME_SENDMMSG_SYSCALL
-# undef __NR_sendmmsg
-#endif
-
-#if !defined __NR_sendmmsg && defined __NR_socketcall
-# define socket sendmmsg
-# ifndef __ASSUME_SENDMMSG_SOCKETCALL
-# define __socket __internal_sendmmsg
-# define NO_WEAK_ALIAS
-# endif
-# define NARGS 4
-# define NEED_CANCELLATION
-# include <socket.S>
-# ifdef __ASSUME_SENDMMSG_SOCKETCALL
-libc_hidden_def (__sendmmsg)
-# endif
-#endif
diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h
index 2ca6f101ec..8f09459b1c 100644
--- a/sysdeps/unix/sysv/linux/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/kernel-features.h
@@ -41,9 +41,8 @@
#define __ASSUME_SENDFILE 1
/* Some architectures use the socketcall multiplexer for some or all
- socket-related operations, via a socket.S file in glibc, instead of
- separate syscalls. __ASSUME_SOCKETCALL is defined for such
- architectures. */
+ socket-related operations instead of separate syscalls.
+ __ASSUME_SOCKETCALL is defined for such architectures. */
/* Linux 2.3.39 introduced IPC64. Except for powerpc. Linux 2.4.0 on
PPC introduced a correct IPC64. But PowerPC64 does not support a
diff --git a/sysdeps/unix/sysv/linux/listen.S b/sysdeps/unix/sysv/linux/listen.S
deleted file mode 100644
index bed6a05f25..0000000000
--- a/sysdeps/unix/sysv/linux/listen.S
+++ /dev/null
@@ -1,5 +0,0 @@
-#define socket listen
-#define NARGS 2
-#define NO_WEAK_ALIAS 1
-#include <socket.S>
-weak_alias (listen, __listen)
diff --git a/sysdeps/unix/sysv/linux/listen.c b/sysdeps/unix/sysv/linux/listen.c
new file mode 100644
index 0000000000..2e387a492c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/listen.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 2015 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <signal.h>
+#include <sys/socket.h>
+
+#include <socketcall.h>
+
+int
+listen (int fd, int backlog)
+{
+ return SOCKETCALL (listen, fd, backlog);
+}
+weak_alias (listen, __listen);
diff --git a/sysdeps/unix/sysv/linux/m68k/socket.S b/sysdeps/unix/sysv/linux/m68k/socket.S
deleted file mode 100644
index c1dc14c2fd..0000000000
--- a/sysdeps/unix/sysv/linux/m68k/socket.S
+++ /dev/null
@@ -1,122 +0,0 @@
-/* Copyright (C) 1996-2015 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
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep-cancel.h>
-#include <socketcall.h>
-
-#define P(a, b) P2(a, b)
-#define P2(a, b) a##b
-
- .text
-/* The socket-oriented system calls are handled unusally in Linux.
- They are all gated through the single `socketcall' system call number.
- `socketcall' takes two arguments: the first is the subcode, specifying
- which socket function is being called; and the second is a pointer to
- the arguments to the specific function.
-
- The .S files for the other calls just #define socket and #include this. */
-
-#ifndef __socket
-#ifndef NO_WEAK_ALIAS
-#define __socket P(__,socket)
-#else
-#define __socket socket
-#endif
-#endif
-
-.globl __socket
-ENTRY (__socket)
-#ifdef NEED_CANCELLATION
-# if !defined CENABLE || !defined CDISABLE
-# error CENABLE and/or CDISABLE is not defined
-# endif
- SINGLE_THREAD_P
- jne 1f
-#endif
-
- /* Save registers. */
- move.l %d2, %a0
- cfi_register (%d2, %a0)
-
- move.l #SYS_ify (socketcall), %d0 /* System call number in %d0. */
-
- /* Use ## so `socket' is a separate token that might be #define'd. */
- move.l #P (SOCKOP_,socket), %d1 /* Subcode is first arg to syscall. */
- lea 4(%sp), %a1 /* Address of args is 2nd arg. */
- move.l %a1, %d2
-
- /* Do the system call trap. */
- trap #0
-
- /* Restore registers. */
- move.l %a0, %d2
- cfi_restore (%d2)
-
- /* %d0 is < 0 if there was an error. */
- tst.l %d0
- jmi SYSCALL_ERROR_LABEL
-
- /* Successful; return the syscall's value. */
- rts
-
-#ifdef NEED_CANCELLATION
-1: /* Enable asynchronous cancellation. */
- CENABLE
-
- /* Save D2. */
- move.l %d2, -(%sp)
- cfi_adjust_cfa_offset (4)
- cfi_rel_offset (%d2, 0)
-
- /* Save the result of CENABLE. */
- move.l %d0, -(%sp)
- cfi_adjust_cfa_offset (4)
-
- /* Use ## so `socket' is a separate token that might be #define'd. */
- move.l #P (SOCKOP_,socket), %d1 /* Subcode is first arg to syscall. */
- lea 4+8(%sp), %a1 /* Address of args is 2nd arg. */
- move.l %a1, %d2
-
- move.l #SYS_ify (socketcall), %d0 /* System call number in %d0. */
- /* Do the system call trap. */
- trap #0
-
- /* Restore cancellation. */
- move.l %d0, %d2
- CDISABLE
- addq.l #4, %sp
- cfi_adjust_cfa_offset (-4)
- move.l %d2, %d0
-
- /* Restore registers. */
- move.l (%sp)+, %d2
- cfi_adjust_cfa_offset (-4)
- cfi_restore (%d2)
-
- /* %d0 is < 0 if there was an error. */
- tst.l %d0
- jmi SYSCALL_ERROR_LABEL
-
- /* Successful; return the syscall's value. */
- rts
-#endif
-
-PSEUDO_END (__socket)
-
-#ifndef NO_WEAK_ALIAS
-weak_alias (__socket, socket)
-#endif
diff --git a/sysdeps/unix/sysv/linux/microblaze/socket.S b/sysdeps/unix/sysv/linux/microblaze/socket.S
deleted file mode 100644
index a3b40484fd..0000000000
--- a/sysdeps/unix/sysv/linux/microblaze/socket.S
+++ /dev/null
@@ -1,126 +0,0 @@
-/* Copyright (C) 2009-2015 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
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep-cancel.h>
-#include <socketcall.h>
-
-#define P(a, b) P2(a, b)
-#define P2(a, b) a##b
-
-/* The socket-oriented system calls are handled unusally in Linux.
- They are all gated through the single `socketcall' system call number.
- `socketcall' takes two arguments: the first is the subcode, specifying
- which socket function is being called; and the second is a pointer to
- the arguments to the specific function.
-
- The .S files for the other calls just #define socket and #include this.
- They also #define a 'number-of-arguments' word in NARGS, which
- defaults to 3. */
-
-#ifndef NARGS
-# ifdef socket
-# error NARGS not defined
-# endif
-# define NARGS 3
-#endif
-
-/* Stack usage:
- 0 - r15 (return address)
- 4 - 12 args to syscall
- 16 - scratch for cancellation state
- 20 - scratch for return value
-*/
-#define stackadjust 24
-
-#ifndef __socket
-# ifndef NO_WEAK_ALIAS
-# define __socket P(__,socket)
-# else
-# define __socket socket
-# endif
-#endif
-
- .text
-ENTRY(__socket)
- addik r1,r1,-stackadjust
- swi r15,r1,0
-#if NARGS >= 1
- swi r5,r1,stackadjust+4
-#endif
-#if NARGS >= 2
- swi r6,r1,stackadjust+8
-#endif
-#if NARGS >= 3
- swi r7,r1,stackadjust+12
-#endif
-#if NARGS >= 4
- swi r8,r1,stackadjust+16
-#endif
-#if NARGS >= 5
- swi r9,r1,stackadjust+20
-#endif
-#if NARGS >= 6
- swi r10,r1,stackadjust+24
-#endif
-/* The rest of the args (if any) are on the caller's stack already. */
-
-#if defined NEED_CANCELLATION && defined CENABLE
- SINGLE_THREAD_P(r12)
- bnei r12,L(socket_cancel)
-#endif
-
- addik r12,r0,SYS_ify(socketcall)
- addik r5,r0,P(SOCKOP_,socket)
- addik r6,r1,stackadjust+4
- brki r14,8
- addk r0,r0,r0
- lwi r15,r1,0
- addik r1,r1,stackadjust
- addik r4,r0,-4095
- cmpu r4,r4,r3
- bgei r4,SYSCALL_ERROR_LABEL
- rtsd r15,8
- addk r0,r0,r0
-
-#if defined NEED_CANCELLATION && defined CENABLE
-L(socket_cancel):
- CENABLE
- swi r3,r1,16
- addik r12,r0,SYS_ify(socketcall)
- addik r5,r0,P(SOCKOP_,socket)
- addik r6,r1,stackadjust+4
- brki r14,8
- addk r0,r0,r0
- swi r3,r1,20
- lwi r5,r1,16
- CDISABLE
- lwi r3,r1,20
- lwi r15,r1,0
- addik r1,r1,stackadjust
- addik r4,r0,-4095
- cmpu r4,r4,r3
- bgei r4,SYSCALL_ERROR_LABEL
- rtsd r15,8
- addk r0,r0,r0
-#endif
-
-PSEUDO_END (__socket)
-
-#ifndef NO_WEAK_ALIAS
-weak_alias (__socket, socket)
-#endif
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/internal_accept4.S b/sysdeps/unix/sysv/linux/mips/mips32/internal_accept4.S
deleted file mode 100644
index 30434d7334..0000000000
--- a/sysdeps/unix/sysv/linux/mips/mips32/internal_accept4.S
+++ /dev/null
@@ -1,2 +0,0 @@
-/* MIPS does not have socket.S and the socketcall syscall should
- generally be avoided, though it exists. */
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/internal_recvmmsg.S b/sysdeps/unix/sysv/linux/mips/mips32/internal_recvmmsg.S
deleted file mode 100644
index 30434d7334..0000000000
--- a/sysdeps/unix/sysv/linux/mips/mips32/internal_recvmmsg.S
+++ /dev/null
@@ -1,2 +0,0 @@
-/* MIPS does not have socket.S and the socketcall syscall should
- generally be avoided, though it exists. */
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/internal_sendmmsg.S b/sysdeps/unix/sysv/linux/mips/mips32/internal_sendmmsg.S
deleted file mode 100644
index 30434d7334..0000000000
--- a/sysdeps/unix/sysv/linux/mips/mips32/internal_sendmmsg.S
+++ /dev/null
@@ -1,2 +0,0 @@
-/* MIPS does not have socket.S and the socketcall syscall should
- generally be avoided, though it exists. */
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/socket.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/socket.S
deleted file mode 100644
index 7dc59b470f..0000000000
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/socket.S
+++ /dev/null
@@ -1,118 +0,0 @@
-/* Copyright (C) 1995-2015 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
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep-cancel.h>
-#include <socketcall.h>
-
-#define P(a, b) P2(a, b)
-#define P2(a, b) a##b
-
-/* The socket-oriented system calls are handled unusally in Linux.
- They are all gated through the single `socketcall' system call number.
- `socketcall' takes two arguments: the first is the subcode, specifying
- which socket function is being called; and the second is a pointer to
- the arguments to the specific function.
-
- The .S files for the other calls just #define socket and #include this.
- They also #define a 'number-of-arguments' word in NARGS, which
- defaults to 3. */
-
-#ifndef NARGS
-#ifdef socket
-#error NARGS not defined
-#endif
-#define NARGS 3
-#endif
-
-/* 0(r1) and 4(r1) are reserved by the ABI, 8(r1), 12(r1), 16(r1) are used
- for temp saves. 44(r1) is used to save r30. */
-#define stackblock 20
-
-#ifndef __socket
-# ifndef NO_WEAK_ALIAS
-# define __socket P(__,socket)
-# else
-# define __socket socket
-# endif
-#endif
-
- .text
-ENTRY(__socket)
- stwu r1,-48(r1)
- cfi_adjust_cfa_offset(48)
-#if NARGS >= 1
- stw r3,stackblock(r1)
-#endif
-#if NARGS >= 2
- stw r4,4+stackblock(r1)
-#endif
-#if NARGS >= 3
- stw r5,8+stackblock(r1)
-#endif
-#if NARGS >= 4
- stw r6,12+stackblock(r1)
-#endif
-#if NARGS >= 5
- stw r7,16+stackblock(r1)
-#endif
-#if NARGS >= 6
- stw r8,20+stackblock(r1)
-#endif
-#if NARGS >= 7
-#error too many arguments!
-#endif
-
-#if defined NEED_CANCELLATION && defined CENABLE
- SINGLE_THREAD_P
- bne- .Lsocket_cancel
-#endif
-
- li r3,P(SOCKOP_,socket)
- addi r4,r1,stackblock
- DO_CALL(SYS_ify(socketcall))
- addi r1,r1,48
- PSEUDO_RET
-
-#if defined NEED_CANCELLATION && defined CENABLE
-.Lsocket_cancel:
- mflr r9
- stw r9,52(r1)
- cfi_offset (lr, 4)
- CENABLE
- stw r3,16(r1)
- li r3,P(SOCKOP_,socket)
- addi r4,r1,stackblock
- DO_CALL(SYS_ify(socketcall))
- mfcr r0
- stw r3,8(r1)
- stw r0,12(r1)
- lwz r3,16(r1)
- CDISABLE
- lwz r4,52(r1)
- lwz r0,12(r1)
- lwz r3,8(r1)
- mtlr r4
- mtcr r0
- addi r1,r1,48
- PSEUDO_RET
-#endif
-
-PSEUDO_END (__socket)
-
-#ifndef NO_WEAK_ALIAS
-weak_alias (__socket, socket)
-#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/socket.S b/sysdeps/unix/sysv/linux/powerpc/powerpc64/socket.S
deleted file mode 100644
index 102844416c..0000000000
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/socket.S
+++ /dev/null
@@ -1,134 +0,0 @@
-/* Copyright (C) 1995-2015 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 Library General Public License as
- published by the Free Software Foundation; either version 2 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- see <http://www.gnu.org/licenses/>. */
-
-#include <sysdep-cancel.h>
-#include <socketcall.h>
-
-#define P(a, b) P2(a, b)
-#define P2(a, b) a##b
-
-/* The socket-oriented system calls are handled unusally in Linux.
- They are all gated through the single `socketcall' system call number.
- `socketcall' takes two arguments: the first is the subcode, specifying
- which socket function is being called; and the second is a pointer to
- the arguments to the specific function.
-
- The .S files for the other calls just #define socket and #include this.
- They also #define a 'number-of-arguments' word in NARGS, which
- defaults to 3. */
-
-#ifndef NARGS
-#ifdef socket
-#error NARGS not defined
-#endif
-#define NARGS 3
-#endif
-
-#ifndef __socket
-# ifndef NO_WEAK_ALIAS
-# define __socket P(__,socket)
-# else
-# define __socket socket
-# endif
-#endif
-
-#if _CALL_ELF == 2
-#define FRAMESIZE (FRAME_MIN_SIZE+16+64)
-#define stackblock (FRAME_MIN_SIZE+16)
-#else
-#define FRAMESIZE (FRAME_MIN_SIZE+16)
-#define stackblock (FRAMESIZE+FRAME_PARM_SAVE) /* offset to parm save area. */
-#endif
-
- .text
-ENTRY(__socket)
- CALL_MCOUNT NARGS
- stdu r1,-FRAMESIZE(r1)
- cfi_adjust_cfa_offset(FRAMESIZE)
-#if NARGS >= 1
- std r3,stackblock(r1)
-#endif
-#if NARGS >= 2
- std r4,8+stackblock(r1)
-#endif
-#if NARGS >= 3
- std r5,16+stackblock(r1)
-#endif
-#if NARGS >= 4
- std r6,24+stackblock(r1)
-#endif
-#if NARGS >= 5
- std r7,32+stackblock(r1)
-#endif
-#if NARGS >= 6
- std r8,40+stackblock(r1)
-#endif
-#if NARGS >= 7
- std r9,48+stackblock(r1)
-#endif
-#if NARGS >= 8
- std r10,56+stackblock(r1)
-#endif
-#if NARGS >= 9
-#error too many arguments!
-#endif
-
-#if defined NEED_CANCELLATION && defined CENABLE
- SINGLE_THREAD_P
- bne- .Lsocket_cancel
-#endif
-
- li r3,P(SOCKOP_,socket)
- addi r4,r1,stackblock
- DO_CALL(SYS_ify(socketcall))
- addi r1,r1,FRAMESIZE
- cfi_adjust_cfa_offset(-FRAMESIZE)
- PSEUDO_RET
-
-#if defined NEED_CANCELLATION && defined CENABLE
-.Lsocket_cancel:
- cfi_adjust_cfa_offset(FRAMESIZE)
- mflr r9
- std r9,FRAMESIZE+FRAME_LR_SAVE(r1)
- cfi_offset (lr, FRAME_LR_SAVE)
- CENABLE
- std r3,FRAME_MIN_SIZE+8(r1)
- li r3,P(SOCKOP_,socket)
- addi r4,r1,stackblock
- DO_CALL(SYS_ify(socketcall))
- mfcr r0
- std r3,FRAME_MIN_SIZE(r1)
- std r0,FRAMESIZE+FRAME_CR_SAVE(r1)
- cfi_offset (cr, FRAME_CR_SAVE)
- ld r3,FRAME_MIN_SIZE+8(r1)
- CDISABLE
- ld r4,FRAMESIZE+FRAME_LR_SAVE(r1)
- ld r0,FRAMESIZE+FRAME_CR_SAVE(r1)
- ld r3,FRAME_MIN_SIZE(r1)
- mtlr r4
- mtcr r0
- addi r1,r1,FRAMESIZE
- cfi_adjust_cfa_offset(-FRAMESIZE)
- cfi_restore(lr)
- cfi_restore(cr)
- PSEUDO_RET
-#endif
-PSEUDO_END (__socket)
-
-#ifndef NO_WEAK_ALIAS
-weak_alias (__socket, socket)
-#endif
diff --git a/sysdeps/unix/sysv/linux/recv.S b/sysdeps/unix/sysv/linux/recv.S
deleted file mode 100644
index 331844abc1..0000000000
--- a/sysdeps/unix/sysv/linux/recv.S
+++ /dev/null
@@ -1,6 +0,0 @@
-#define socket recv
-#define __socket __libc_recv
-#define NARGS 4
-#define NEED_CANCELLATION
-#include <socket.S>
-weak_alias (__libc_recv, __recv)
diff --git a/sysdeps/unix/sysv/linux/recv.c b/sysdeps/unix/sysv/linux/recv.c
new file mode 100644
index 0000000000..d2e80d5a80
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/recv.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 2015 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <signal.h>
+#include <sys/socket.h>
+
+#include <sysdep-cancel.h>
+#include <socketcall.h>
+
+ssize_t
+__libc_recv (int fd, void *buf, size_t len, int flags)
+{
+ return SOCKETCALL_CANCEL (recv, fd, buf, len, flags);
+}
+weak_alias (__libc_recv, recv)
+weak_alias (__libc_recv, __recv)
diff --git a/sysdeps/unix/sysv/linux/recvfrom.S b/sysdeps/unix/sysv/linux/recvfrom.S
deleted file mode 100644
index ccbb0a75da..0000000000
--- a/sysdeps/unix/sysv/linux/recvfrom.S
+++ /dev/null
@@ -1,6 +0,0 @@
-#define socket recvfrom
-#define __socket __libc_recvfrom
-#define NARGS 6
-#define NEED_CANCELLATION
-#include <socket.S>
-weak_alias (__libc_recvfrom, __recvfrom)
diff --git a/sysdeps/unix/sysv/linux/recvfrom.c b/sysdeps/unix/sysv/linux/recvfrom.c
new file mode 100644
index 0000000000..90eb40d603
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/recvfrom.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 2015 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <signal.h>
+#include <sys/socket.h>
+
+#include <sysdep-cancel.h>
+#include <socketcall.h>
+
+ssize_t
+__libc_recvfrom (int fd, void *buf, size_t len, int flags,
+ __SOCKADDR_ARG addr, socklen_t *addrlen)
+{
+ return SOCKETCALL_CANCEL (recvfrom, fd, buf, len, flags, addr.__sockaddr__,
+ addrlen);
+}
+weak_alias (__libc_recvfrom, recvfrom)
+weak_alias (__libc_recvfrom, __recvfrom)
diff --git a/sysdeps/unix/sysv/linux/recvmmsg.c b/sysdeps/unix/sysv/linux/recvmmsg.c
index c3a4874447..1f9f04d360 100644
--- a/sysdeps/unix/sysv/linux/recvmmsg.c
+++ b/sysdeps/unix/sysv/linux/recvmmsg.c
@@ -49,12 +49,15 @@ recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
return result;
}
#elif defined __NR_socketcall
-# ifndef __ASSUME_RECVMMSG_SOCKETCALL
-extern int __internal_recvmmsg (int fd, struct mmsghdr *vmessages,
- unsigned int vlen, int flags,
- struct timespec *tmo)
- attribute_hidden;
-
+# include <socketcall.h>
+# ifdef __ASSUME_RECVMMSG_SOCKETCALL
+int
+recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
+ struct timespec *tmo)
+{
+ return SOCKETCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, tmo);
+}
+# else
static int have_recvmmsg;
int
@@ -63,7 +66,8 @@ recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
{
if (__glibc_likely (have_recvmmsg >= 0))
{
- int ret = __internal_recvmmsg (fd, vmessages, vlen, flags, tmo);
+ int ret = SOCKETCALL_CANCEL (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)
@@ -74,7 +78,7 @@ recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
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);
+ ret = SOCKETCALL_CANCEL (invalid, -1);
if (errno == EINVAL)
{
have_recvmmsg = -1;
@@ -92,10 +96,7 @@ recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
__set_errno (ENOSYS);
return -1;
}
-# else
-/* When __ASSUME_RECVMMSG_SOCKETCALL recvmmsg is defined in
- internal_recvmmsg.S. */
-# endif
+# endif /* __ASSUME_RECVMMSG_SOCKETCALL */
#else
# include <socket/recvmmsg.c>
#endif
diff --git a/sysdeps/unix/sysv/linux/recvmsg.S b/sysdeps/unix/sysv/linux/recvmsg.S
deleted file mode 100644
index d44bc39f92..0000000000
--- a/sysdeps/unix/sysv/linux/recvmsg.S
+++ /dev/null
@@ -1,6 +0,0 @@
-#define socket recvmsg
-#define __socket __libc_recvmsg
-#define NARGS 3
-#define NEED_CANCELLATION
-#include <socket.S>
-weak_alias (__libc_recvmsg, __recvmsg)
diff --git a/sysdeps/unix/sysv/linux/recvmsg.c b/sysdeps/unix/sysv/linux/recvmsg.c
new file mode 100644
index 0000000000..cd7c9ca581
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/recvmsg.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 2015 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <signal.h>
+#include <sys/socket.h>
+
+#include <sysdep-cancel.h>
+#include <socketcall.h>
+
+ssize_t
+__libc_recvmsg (int fd, struct msghdr *msg, int flags)
+{
+ return SOCKETCALL_CANCEL (recvmsg, fd, msg, flags);
+}
+weak_alias (__libc_recvmsg, recvmsg)
+weak_alias (__libc_recvmsg, __recvmsg)
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/socket.S b/sysdeps/unix/sysv/linux/s390/s390-32/socket.S
deleted file mode 100644
index 4611e52f24..0000000000
--- a/sysdeps/unix/sysv/linux/s390/s390-32/socket.S
+++ /dev/null
@@ -1,142 +0,0 @@
-/* Copyright (C) 2000-2015 Free Software Foundation, Inc.
- Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
- 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
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep-cancel.h>
-#include <socketcall.h>
-
-/* &%/$&!! preprocessor */
-#define P(a, b) P2(a, b)
-#define P2(a, b) a##b
-
- .text
-/* The socket-oriented system calls are handled unusally in Linux.
- They are all gated through the single `socketcall' system call number.
- `socketcall' takes two arguments: the first is the subcode, specifying
- which socket function is being called; and the second is a pointer to
- the arguments to the specific function.
-
- The .S files for the other calls just #define socket and #include this. */
-
-#ifndef __socket
-#ifndef NO_WEAK_ALIAS
-#define __socket P(__,socket)
-#else
-#define __socket socket
-#endif
-#endif
-
-#ifndef NARGS /* the socket.o object is compiled directly ... */
-#define NARGS 3
-#endif
-
-.globl __socket
-ENTRY(__socket)
- /* Save registers and setup stack. */
- stm %r6,%r15,24(%r15) /* save registers */
- cfi_offset (%r15, -36)
- cfi_offset (%r14, -40)
- cfi_offset (%r13, -44)
- cfi_offset (%r12, -48)
- cfi_offset (%r11, -52)
- cfi_offset (%r10, -56)
- cfi_offset (%r9, -60)
- cfi_offset (%r8, -64)
- cfi_offset (%r7, -68)
- cfi_offset (%r6, -72)
- lr %r1,%r15
- l %r0,4(0,%r15) /* load eos */
- ahi %r15,-120 /* buy stack space */
- cfi_adjust_cfa_offset (120)
- st %r1,0(0,%r15) /* store back chain */
- st %r0,4(0,%r15) /* store eos */
-
- /* Reorder arguments */
-#if (NARGS >= 6)
- mvc 0x74(4,%r15),216(%r15) /* move between parameter lists */
-#endif
-#if (NARGS >= 5)
- st %r6,0x70(0,%r15) /* store into parameter list */
-#endif
-#if (NARGS >= 4)
- st %r5,0x6C(0,%r15) /* store into parameter list */
-#endif
-#if (NARGS >= 3)
- st %r4,0x68(0,%r15) /* store into parameter list */
-#endif
-#if (NARGS >= 2)
- st %r3,0x64(0,%r15) /* store into parameter list */
- st %r2,0x60(0,%r15)
-#endif
-
-#if defined NEED_CANCELLATION && defined CENABLE
- SINGLE_THREAD_P (%r4)
- jne L(socket_cancel)
-#endif
-
- /* load subcode for socket syscall */
- lhi %r2,P(SOCKOP_,socket)
- la %r3,0x60(0,%r15) /* load address of parameter list */
-
- /* Do the system call trap. */
- svc SYS_ify(socketcall)
-
-4:
- l %r15,0(0,%r15) /* load back chain */
- lm %r6,15,24(%r15) /* load registers */
-
- /* gpr2 is < 0 if there was an error. */
- lhi %r0,-125
- clr %r2,%r0
- jnl SYSCALL_ERROR_LABEL
-
- /* Successful; return the syscall's value. */
- br %r14
-
-#if defined NEED_CANCELLATION && defined CENABLE
-L(socket_cancel):
- basr %r13,0
-1: l %r1,2f-1b(%r13)
- /* call CENABLE. */
- bas %r14,0(%r13,%r1)
- lr %r0,%r2
-
- /* load subcode for socket syscall */
- lhi %r2,P(SOCKOP_,socket)
- la %r3,0x60(0,%r15) /* load address of parameter list */
-
- /* Do the system call trap. */
- svc SYS_ify(socketcall)
-
- l %r3,3f-1b(%r13)
- lr %r12,%r2
- lr %r2,%r0
- /* call CDISABLE. */
- bas %r14,0(%r13,%r3)
- lr %r2,%r12
- j 4b
-
-2: .long CENABLE-1b
-3: .long CDISABLE-1b
-#endif
-
- SYSCALL_ERROR_HANDLER
-END (__socket)
-
-#ifndef NO_WEAK_ALIAS
-weak_alias (__socket, socket)
-#endif
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/socket.S b/sysdeps/unix/sysv/linux/s390/s390-64/socket.S
deleted file mode 100644
index 26b39f9611..0000000000
--- a/sysdeps/unix/sysv/linux/s390/s390-64/socket.S
+++ /dev/null
@@ -1,136 +0,0 @@
-/* Copyright (C) 2001-2015 Free Software Foundation, Inc.
- Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
- 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
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep-cancel.h>
-#include <socketcall.h>
-
-/* &%/$&!! preprocessor */
-#define P(a, b) P2(a, b)
-#define P2(a, b) a##b
-
- .text
-/* The socket-oriented system calls are handled unusally in Linux.
- They are all gated through the single `socketcall' system call number.
- `socketcall' takes two arguments: the first is the subcode, specifying
- which socket function is being called; and the second is a pointer to
- the arguments to the specific function.
-
- The .S files for the other calls just #define socket and #include this. */
-
-#ifndef __socket
-#ifndef NO_WEAK_ALIAS
-#define __socket P(__,socket)
-#else
-#define __socket socket
-#endif
-#endif
-
-#ifndef NARGS /* The socket.o object is compiled directly ... */
-#define NARGS 3
-#endif
-
-.globl __socket
-ENTRY(__socket)
- /* Save registers and setup stack. */
- stmg %r6,%r15,48(%r15) /* Save registers. */
- cfi_offset (%r15,-40)
- cfi_offset (%r14,-48)
- cfi_offset (%r13,-56)
- cfi_offset (%r12,-64)
- cfi_offset (%r11,-72)
- cfi_offset (%r10,-80)
- cfi_offset (%r9,-88)
- cfi_offset (%r8,-96)
- cfi_offset (%r7,-104)
- cfi_offset (%r6,-112)
- lgr %r1,%r15
- lg %r0,8(%r15) /* Load eos. */
- aghi %r15,-208 /* Buy stack space. */
- cfi_adjust_cfa_offset (208)
- stg %r1,0(%r15) /* Store back chain. */
- stg %r0,8(%r15) /* Store eos. */
-
- /* Reorder arguments. */
-#if (NARGS >= 6)
- mvc 200(8,%r15),368(%r15) /* Move between parameter lists. */
-#endif
-#if (NARGS >= 5)
- stg %r6,192(%r15) /* Store into parameter list. */
-#endif
-#if (NARGS >= 4)
- stg %r5,184(%r15) /* Store into parameter list. */
-#endif
-#if (NARGS >= 3)
- stg %r4,176(%r15) /* Store into parameter list. */
-#endif
-#if (NARGS >= 2)
- stg %r3,168(%r15) /* Store into parameter list. */
- stg %r2,160(%r15)
-#endif
-
-#if defined NEED_CANCELLATION && defined CENABLE
- SINGLE_THREAD_P
- jne L(socket_cancel)
-#endif
-
- /* Load subcode for socket syscall. */
- lghi %r2,P(SOCKOP_,socket)
- la %r3,160(%r15) /* Load address of parameter list. */
-
- /* Do the system call trap. */
- svc SYS_ify(socketcall)
-
-4:
- lg %r15,0(%r15) /* Load back chain. */
- lmg %r6,15,48(%r15) /* Load registers. */
-
- /* gpr2 is < 0 if there was an error. */
- lghi %r0,-125
- clgr %r2,%r0
- jgnl SYSCALL_ERROR_LABEL
-
- /* Successful; return the syscall's value. */
- br %r14
-
-#if defined NEED_CANCELLATION && defined CENABLE
-L(socket_cancel):
- brasl %r14,CENABLE
- lr %r0,%r2
-
- /* Load subcode for socket syscall. */
- lghi %r2,P(SOCKOP_,socket)
- la %r3,160(%r15) /* Load address of parameter list. */
-
- /* Do the system call trap. */
- svc SYS_ify(socketcall)
-
- lgr %r12,%r2
- lr %r2,%r0
- brasl %r14,CDISABLE
-
- lgr %r2,%r12
- j 4b
-#endif
-
- SYSCALL_ERROR_HANDLER
-END (__socket)
-
-#ifndef NO_WEAK_ALIAS
-weak_alias (__socket, socket)
-#endif
-
diff --git a/sysdeps/unix/sysv/linux/send.S b/sysdeps/unix/sysv/linux/send.S
deleted file mode 100644
index 259748f44c..0000000000
--- a/sysdeps/unix/sysv/linux/send.S
+++ /dev/null
@@ -1,7 +0,0 @@
-#define socket send
-#define __socket __libc_send
-#define NARGS 4
-#define NEED_CANCELLATION
-#include <socket.S>
-weak_alias (__libc_send, __send)
-libc_hidden_def (__send)
diff --git a/sysdeps/unix/sysv/linux/send.c b/sysdeps/unix/sysv/linux/send.c
new file mode 100644
index 0000000000..f87ea86672
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/send.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 2015 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <signal.h>
+#include <sys/socket.h>
+
+#include <sysdep-cancel.h>
+#include <socketcall.h>
+
+ssize_t
+__libc_send (int fd, const void *buf, size_t len, int flags)
+{
+ return SOCKETCALL_CANCEL (send, fd, buf, len, flags);
+}
+weak_alias (__libc_send, send)
+weak_alias (__libc_send, __send)
+libc_hidden_def (__send)
diff --git a/sysdeps/unix/sysv/linux/sendmmsg.c b/sysdeps/unix/sysv/linux/sendmmsg.c
index a95aff19ef..e535cc0207 100644
--- a/sysdeps/unix/sysv/linux/sendmmsg.c
+++ b/sysdeps/unix/sysv/linux/sendmmsg.c
@@ -50,11 +50,14 @@ __sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
libc_hidden_def (__sendmmsg)
weak_alias (__sendmmsg, sendmmsg)
#elif defined __NR_socketcall
-# ifndef __ASSUME_SENDMMSG_SOCKETCALL
-extern int __internal_sendmmsg (int fd, struct mmsghdr *vmessages,
- unsigned int vlen, int flags)
- attribute_hidden;
-
+# include <socketcall.h>
+# ifdef __ASSUME_SENDMMSG_SOCKETCALL
+int
+__sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
+{
+ return SOCKETCALL_CANCEL (sendmmsg, fd, vmessages, vlen, flags);
+}
+# else
static int have_sendmmsg;
int
@@ -62,7 +65,7 @@ __sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
{
if (__glibc_likely (have_sendmmsg >= 0))
{
- int ret = __internal_sendmmsg (fd, vmessages, vlen, flags);
+ int ret = SOCKETCALL_CANCEL (sendmmsg, fd, vmessages, vlen, flags);
/* The kernel returns -EINVAL for unknown socket operations.
We need to convert that error to an ENOSYS error. */
if (__builtin_expect (ret < 0, 0)
@@ -73,7 +76,7 @@ __sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
descriptor and all other parameters cleared. This call
will not cause any harm and it will return
immediately. */
- ret = __internal_sendmmsg (-1, 0, 0, 0);
+ ret = SOCKETCALL_CANCEL (invalid, -1);
if (errno == EINVAL)
{
have_sendmmsg = -1;
@@ -91,12 +94,9 @@ __sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
__set_errno (ENOSYS);
return -1;
}
+# endif /* __ASSUME_SENDMMSG_SOCKETCALL */
libc_hidden_def (__sendmmsg)
weak_alias (__sendmmsg, sendmmsg)
-# else
-/* When __ASSUME_SENDMMSG_SOCKETCALL sendmmsg is defined in
- internal_sendmmsg.S. */
-# endif
#else
# include <socket/sendmmsg.c>
#endif
diff --git a/sysdeps/unix/sysv/linux/sendmsg.S b/sysdeps/unix/sysv/linux/sendmsg.S
deleted file mode 100644
index a220894cc6..0000000000
--- a/sysdeps/unix/sysv/linux/sendmsg.S
+++ /dev/null
@@ -1,6 +0,0 @@
-#define socket sendmsg
-#define __socket __libc_sendmsg
-#define NARGS 3
-#define NEED_CANCELLATION
-#include <socket.S>
-weak_alias (__libc_sendmsg, __sendmsg)
diff --git a/sysdeps/unix/sysv/linux/sendmsg.c b/sysdeps/unix/sysv/linux/sendmsg.c
new file mode 100644
index 0000000000..e69ac3e1b7
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sendmsg.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 2015 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <signal.h>
+#include <sys/socket.h>
+
+#include <sysdep-cancel.h>
+#include <socketcall.h>
+
+ssize_t
+__libc_sendmsg (int fd, const struct msghdr *msg, int flags)
+{
+ return SOCKETCALL_CANCEL (sendmsg, fd, msg, flags);
+}
+weak_alias (__libc_sendmsg, sendmsg)
+weak_alias (__libc_sendmsg, __sendmsg)
diff --git a/sysdeps/unix/sysv/linux/sendto.S b/sysdeps/unix/sysv/linux/sendto.S
deleted file mode 100644
index a65e44fb61..0000000000
--- a/sysdeps/unix/sysv/linux/sendto.S
+++ /dev/null
@@ -1,6 +0,0 @@
-#define socket sendto
-#define __socket __libc_sendto
-#define NARGS 6
-#define NEED_CANCELLATION
-#include <socket.S>
-weak_alias (__libc_sendto, __sendto)
diff --git a/sysdeps/unix/sysv/linux/sendto.c b/sysdeps/unix/sysv/linux/sendto.c
new file mode 100644
index 0000000000..d2896a60ec
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sendto.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 2015 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <signal.h>
+#include <sys/socket.h>
+
+#include <sysdep-cancel.h>
+#include <socketcall.h>
+
+ssize_t
+__libc_sendto (int fd, const void *buf, size_t len, int flags,
+ __CONST_SOCKADDR_ARG addr, socklen_t addrlen)
+{
+ return SOCKETCALL_CANCEL (sendto, fd, buf, len, flags, addr.__sockaddr__,
+ addrlen);
+}
+weak_alias (__libc_sendto, sendto)
+weak_alias (__libc_sendto, __sendto)
diff --git a/sysdeps/unix/sysv/linux/setsockopt.S b/sysdeps/unix/sysv/linux/setsockopt.S
deleted file mode 100644
index 4e40ccba57..0000000000
--- a/sysdeps/unix/sysv/linux/setsockopt.S
+++ /dev/null
@@ -1,5 +0,0 @@
-#define socket setsockopt
-#define NARGS 5
-#define NO_WEAK_ALIAS 1
-#include <socket.S>
-weak_alias (setsockopt, __setsockopt)
diff --git a/sysdeps/unix/sysv/linux/setsockopt.c b/sysdeps/unix/sysv/linux/setsockopt.c
new file mode 100644
index 0000000000..626c55b5a5
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/setsockopt.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 2015 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <signal.h>
+#include <sys/socket.h>
+
+#include <socketcall.h>
+
+int
+setsockopt (int fd, int level, int optname, const void *optval, socklen_t len)
+{
+ return SOCKETCALL (setsockopt, fd, level, optname, optval, len);
+}
+weak_alias (setsockopt, __setsockopt)
diff --git a/sysdeps/unix/sysv/linux/sh/socket.S b/sysdeps/unix/sysv/linux/sh/socket.S
deleted file mode 100644
index ee99e840c1..0000000000
--- a/sysdeps/unix/sysv/linux/sh/socket.S
+++ /dev/null
@@ -1,179 +0,0 @@
-/* Copyright (C) 1999-2015 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
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep-cancel.h>
-#include <socketcall.h>
-#include <tls.h>
-
-#define P(a, b) P2(a, b)
-#define P2(a, b) a##b
-
- .text
-/* The socket-oriented system calls are handled unusally in Linux.
- They are all gated through the single `socketcall' system call number.
- `socketcall' takes two arguments: the first is the subcode, specifying
- which socket function is being called; and the second is a pointer to
- the arguments to the specific function.
-
- The .S files for the other calls just #define socket and #include this. */
-
-#ifndef __socket
-#ifndef NO_WEAK_ALIAS
-#define __socket P(__,socket)
-#else
-#define __socket socket
-#endif
-#endif
-
-#define PUSHARGS_1 mov.l r4,@-r15; \
- cfi_adjust_cfa_offset (4); \
- cfi_rel_offset (r4, 0)
-#define PUSHARGS_2 mov.l r5,@-r15; \
- cfi_adjust_cfa_offset (4); \
- cfi_rel_offset (r5, 0); \
- PUSHARGS_1
-#define PUSHARGS_3 mov.l r6,@-r15; \
- cfi_adjust_cfa_offset (4); \
- cfi_rel_offset (r6, 0); \
- PUSHARGS_2
-#define PUSHARGS_4 mov.l r7,@-r15; \
- cfi_adjust_cfa_offset (4); \
- cfi_rel_offset (r7, 0); \
- PUSHARGS_3
-#define PUSHARGS_5 PUSHARGS_4 /* Caller has already pushed arg 5 */
-#define PUSHARGS_6 PUSHARGS_4 /* Caller has already pushed arg 5,6 */
-
-#define POPARGS_1 add #4,r15; cfi_adjust_cfa_offset (-4)
-#define POPARGS_2 add #8,r15; cfi_adjust_cfa_offset (-8)
-#define POPARGS_3 add #12,r15; cfi_adjust_cfa_offset (-12)
-#define POPARGS_4 add #16,r15; cfi_adjust_cfa_offset (-16)
-#define POPARGS_5 POPARGS_4
-#define POPARGS_6 POPARGS_4
-
-#define ADJUSTCFI_1 cfi_adjust_cfa_offset (4); \
- cfi_offset (r4, -4)
-#define ADJUSTCFI_2 cfi_adjust_cfa_offset (8); \
- cfi_offset (r4, -4); \
- cfi_offset (r5, -8)
-#define ADJUSTCFI_3 cfi_adjust_cfa_offset (12); \
- cfi_offset (r4, -4); \
- cfi_offset (r5, -8); \
- cfi_offset (r6, -12)
-#define ADJUSTCFI_4 cfi_adjust_cfa_offset (16); \
- cfi_offset (r4, -4); \
- cfi_offset (r5, -8); \
- cfi_offset (r6, -12); \
- cfi_offset (r7, -16)
-#define ADJUSTCFI_5 ADJUSTCFI_4
-#define ADJUSTCFI_6 ADJUSTCFI_4
-
-#ifndef NARGS
-/* If we were called with no wrapper, this is really socket(). */
-#define NARGS 3
-#endif
-
-.globl __socket
-ENTRY (__socket)
- /* This will not work in the case of a socket call being interrupted
- by a signal. If the signal handler uses any stack the arguments
- to socket will be trashed. The results of a restart of any
- socket call are then unpredictable. */
-
- /* Push args onto the stack. */
- P(PUSHARGS_,NARGS)
-
-#if defined NEED_CANCELLATION && defined CENABLE
- SINGLE_THREAD_P
- bf .Lsocket_cancel
-#endif
-
- /* Do the system call trap. */
- mov #+P(SOCKOP_,socket), r4
- mov r15, r5
- mov.l .L1,r3
- trapa #0x12
-
- /* Pop args off the stack */
- P(POPARGS_,NARGS)
-
- mov r0, r1
- mov #-12, r2
- shad r2, r1
- not r1, r1 // r1=0 means r0 = -1 to -4095
- tst r1, r1 // i.e. error in linux
- bf .Lpseudo_end
-.Lsyscall_error:
- SYSCALL_ERROR_HANDLER
-.Lpseudo_end:
- /* Successful; return the syscall's value. */
- rts
- nop
-
-#if defined NEED_CANCELLATION && defined CENABLE
-.Lsocket_cancel:
- /* Enable asynchronous cancellation. */
- P(ADJUSTCFI_,NARGS)
- sts.l pr,@-r15
- cfi_adjust_cfa_offset (4)
- cfi_rel_offset (pr, 0)
- CENABLE
- lds.l @r15+,pr
- cfi_adjust_cfa_offset (-4)
- cfi_restore (pr)
-
- /* Do the system call trap. */
- mov #+P(SOCKOP_,socket), r4
- mov r15, r5
- mov.l .L1,r3
- trapa #0x12
-
- sts.l pr,@-r15
- cfi_adjust_cfa_offset (4)
- cfi_rel_offset (pr, 0)
- mov.l r0,@-r15
- cfi_adjust_cfa_offset (4)
- cfi_rel_offset (r0, 0)
- CDISABLE
- mov.l @r15+,r0
- cfi_adjust_cfa_offset (-4)
- cfi_restore (r0)
- lds.l @r15+,pr
- cfi_adjust_cfa_offset (-4)
- cfi_restore (pr)
-
- /* Pop args off the stack */
- P(POPARGS_,NARGS)
-
- mov r0, r1
- mov #-12, r2
- shad r2, r1
- not r1, r1 // r1=0 means r0 = -1 to -4095
- tst r1, r1 // i.e. error in linux
- bf .Lpseudo_end
- bra .Lsyscall_error
- nop
-#endif
-
- .align 2
-.L1:
- .long SYS_ify(socketcall)
-
-PSEUDO_END (__socket)
-
-#ifndef NO_WEAK_ALIAS
-weak_alias (__socket, socket)
-#endif
diff --git a/sysdeps/unix/sysv/linux/shutdown.S b/sysdeps/unix/sysv/linux/shutdown.S
deleted file mode 100644
index e2462d0eca..0000000000
--- a/sysdeps/unix/sysv/linux/shutdown.S
+++ /dev/null
@@ -1,3 +0,0 @@
-#define socket shutdown
-#define NARGS 2
-#include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/shutdown.c b/sysdeps/unix/sysv/linux/shutdown.c
new file mode 100644
index 0000000000..8b3a3d87f5
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/shutdown.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 2015 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <signal.h>
+#include <sys/socket.h>
+
+#include <socketcall.h>
+
+int
+__shutdown (int fd, int how)
+{
+ return SOCKETCALL (shutdown, fd, how);
+}
+weak_alias (__shutdown, shutdown)
diff --git a/sysdeps/unix/sysv/linux/socket.c b/sysdeps/unix/sysv/linux/socket.c
new file mode 100644
index 0000000000..fcb4775c6b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/socket.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 2015 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <signal.h>
+#include <sys/socket.h>
+
+#include <socketcall.h>
+
+int
+__socket (int fd, int type, int domain)
+{
+ return SOCKETCALL (socket, fd, type, domain);
+}
+weak_alias (__socket, socket)
diff --git a/sysdeps/unix/sysv/linux/socketcall.h b/sysdeps/unix/sysv/linux/socketcall.h
index e59067d34c..f652239ef3 100644
--- a/sysdeps/unix/sysv/linux/socketcall.h
+++ b/sysdeps/unix/sysv/linux/socketcall.h
@@ -25,6 +25,7 @@
We cannot use an enum here because the values are used in assembler
code. */
+#define SOCKOP_invalid -1
#define SOCKOP_socket 1
#define SOCKOP_bind 2
#define SOCKOP_connect 3
@@ -46,4 +47,58 @@
#define SOCKOP_recvmmsg 19
#define SOCKOP_sendmmsg 20
+#define __SOCKETCALL1(name, a1) \
+ INLINE_SYSCALL (socketcall, 2, name, \
+ ((long int [1]) { (long int) (a1) }))
+#define __SOCKETCALL2(name, a1, a2) \
+ INLINE_SYSCALL (socketcall, 2, name, \
+ ((long int [2]) { (long int) (a1), (long int) (a2) }))
+#define __SOCKETCALL3(name, a1, a2, a3) \
+ INLINE_SYSCALL (socketcall, 2, name, \
+ ((long int [3]) { (long int) (a1), (long int) (a2), (long int) (a3) }))
+#define __SOCKETCALL4(name, a1, a2, a3, a4) \
+ INLINE_SYSCALL (socketcall, 2, name, \
+ ((long int [4]) { (long int) (a1), (long int) (a2), (long int) (a3), \
+ (long int) (a4) }))
+#define __SOCKETCALL5(name, a1, a2, a3, a4, a5) \
+ INLINE_SYSCALL (socketcall, 2, name, \
+ ((long int [5]) { (long int) (a1), (long int) (a2), (long int) (a3), \
+ (long int) (a4), (long int) (a5) }))
+#define __SOCKETCALL6(name, a1, a2, a3, a4, a5, a6) \
+ INLINE_SYSCALL (socketcall, 2, name, \
+ ((long int [6]) { (long int) (a1), (long int) (a2), (long int) (a3), \
+ (long int) (a4), (long int) (a5), (long int) (a6) }))
+
+#define __SOCKETCALL_NARGS_X(a,b,c,d,e,f,g,h,n,...) n
+#define __SOCKETCALL_NARGS(...) \
+ __SOCKETCALL_NARGS_X (__VA_ARGS__,7,6,5,4,3,2,1,0,)
+#define __SOCKETCALL_CONCAT_X(a,b) a##b
+#define __SOCKETCALL_CONCAT(a,b) __SOCKETCALL_CONCAT_X (a, b)
+#define __SOCKETCALL_DISP(b,...) \
+ __SOCKETCALL_CONCAT (b,__SOCKETCALL_NARGS(__VA_ARGS__))(__VA_ARGS__)
+
+#define __SOCKETCALL(...) __SOCKETCALL_DISP (__SOCKETCALL, __VA_ARGS__)
+
+
+#define SOCKETCALL(name, args...) \
+ ({ \
+ long int sc_ret = __SOCKETCALL (SOCKOP_##name, args); \
+ sc_ret; \
+ })
+
+
+#if IS_IN (libc)
+# define __pthread_enable_asynccancel __libc_enable_asynccancel
+# define __pthread_disable_asynccancel __libc_disable_asynccancel
+#endif
+
+#define SOCKETCALL_CANCEL(name, args...) \
+ ({ \
+ int oldtype = LIBC_CANCEL_ASYNC (); \
+ long int sc_ret = __SOCKETCALL (SOCKOP_##name, args); \
+ LIBC_CANCEL_RESET (oldtype); \
+ sc_ret; \
+ })
+
+
#endif /* sys/socketcall.h */
diff --git a/sysdeps/unix/sysv/linux/socketpair.S b/sysdeps/unix/sysv/linux/socketpair.S
deleted file mode 100644
index c954ad1a4b..0000000000
--- a/sysdeps/unix/sysv/linux/socketpair.S
+++ /dev/null
@@ -1,3 +0,0 @@
-#define socket socketpair
-#define NARGS 4
-#include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/socketpair.c b/sysdeps/unix/sysv/linux/socketpair.c
new file mode 100644
index 0000000000..cb70bcf1f0
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/socketpair.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 2015 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <signal.h>
+#include <sys/socket.h>
+
+#include <socketcall.h>
+
+int
+__socketpair (int domain, int type, int protocol, int sv[2])
+{
+ return SOCKETCALL (socketpair, domain, type, protocol, sv);
+}
+weak_alias (__socketpair, socketpair)
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/socket.S b/sysdeps/unix/sysv/linux/sparc/sparc32/socket.S
deleted file mode 100644
index 59c81649ec..0000000000
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/socket.S
+++ /dev/null
@@ -1,116 +0,0 @@
-/* Copyright (C) 1997-2015 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Miguel de Icaza <miguel@gnu.ai.mit.edu>, 1997.
-
- 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
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep-cancel.h>
-#include <socketcall.h>
-
-#define P(a, b) P2(a, b)
-#define P2(a, b) a##b
-
-#ifndef NARGS
-#ifdef socket
-#error NARGS not defined
-#endif
-#define NARGS 3
-#endif
-
- .text
-/* The socket-oriented system calls are handled unusually in Linux.
- They are all gated through the single `socketcall' system call number.
- `socketcall' takes two arguments: the first is the subcode, specifying
- which socket function is being called; and the second is a pointer to
- the arguments to the specific function.
-
- The .S files for the other calls just #define socket and #include this. */
-
-#ifndef __socket
-# ifndef NO_WEAK_ALIAS
-# define __socket P(__,socket)
-# else
-# define __socket socket
-# endif
-#endif
-
- .globl __syscall_error
-ENTRY (__socket)
-
- /* Drop up to 6 arguments (recvfrom) into the memory allocated by
- the caller for varargs, since that's really what we have. */
- st %o0, [%sp + 68 + 0]
- st %o1, [%sp + 68 + 4]
-#if NARGS > 2
- st %o2, [%sp + 68 + 8]
-#if NARGS > 3
- st %o3, [%sp + 68 + 12]
-#if NARGS > 4
- st %o4, [%sp + 68 + 16]
-#if NARGS > 5
- st %o5, [%sp + 68 + 20]
-#endif
-#endif
-#endif
-#endif
-
-#if defined NEED_CANCELLATION && defined CENABLE
- SINGLE_THREAD_P
- cmp %g1, 0
- bne .Lsocket_cancel
-#endif
- mov P(SOCKOP_,socket), %o0 /* arg 1: socket subfunction */
- add %sp, 68, %o1 /* arg 2: parameter block */
- LOADSYSCALL(socketcall)
- t 0x10
- bcc 1f
- mov %o7, %g1
- call __syscall_error
- mov %g1, %o7
-1: jmpl %o7 + 8, %g0
- nop
-
-#if defined NEED_CANCELLATION && defined CENABLE
-.Lsocket_cancel:
- save %sp, -96, %sp
- cfi_def_cfa_register(%fp)
- cfi_window_save
- cfi_register(%o7, %i7)
- CENABLE
- nop
- mov %o0, %l0
- add %sp, 68 + 96, %o1
- mov P(SOCKOP_,socket), %o0
- LOADSYSCALL(socketcall)
- t 0x10
- bcc 1f
- mov %o0, %l1
- CDISABLE;
- mov %l0, %o0;
- call __syscall_error;
- mov %l1, %o0;
- b 1f
- mov -1, %l1;
-1: CDISABLE
- mov %l0, %o0
-2: jmpl %i7 + 8, %g0
- restore %g0, %l1, %o0
-#endif
-
-END (__socket)
-
-#ifndef NO_WEAK_ALIAS
-weak_alias (__socket, socket)
-#endif
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/socket.S b/sysdeps/unix/sysv/linux/sparc/sparc64/socket.S
deleted file mode 100644
index b680165653..0000000000
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/socket.S
+++ /dev/null
@@ -1,118 +0,0 @@
-/* Copyright (C) 1997-2015 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Miguel de Icaza <miguel@gnu.ai.mit.edu>, 1997.
-
- 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
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep-cancel.h>
-#include <socketcall.h>
-
-#define P(a, b) P2(a, b)
-#define P2(a, b) a##b
-
-#ifndef NARGS
-#ifdef socket
-#error NARGS not defined
-#endif
-#define NARGS 3
-#endif
-
- .text
-/* The socket-oriented system calls are handled unusually in Linux.
- They are all gated through the single `socketcall' system call number.
- `socketcall' takes two arguments: the first is the subcode, specifying
- which socket function is being called; and the second is a pointer to
- the arguments to the specific function.
-
- The .S files for the other calls just #define socket and #include this. */
-
-#ifndef __socket
-# ifndef NO_WEAK_ALIAS
-# define __socket P(__,socket)
-# else
-# define __socket socket
-# endif
-#endif
-
- .globl __syscall_error
-ENTRY(__socket)
-
- /* Drop up to 6 arguments (recvfrom) into the memory allocated by
- the caller for varargs, since that's really what we have. */
- stx %o0, [%sp + STACK_BIAS + 128 + 0]
- stx %o1, [%sp + STACK_BIAS + 128 + 8]
-#if NARGS > 2
- stx %o2, [%sp + STACK_BIAS + 128 + 16]
-#if NARGS > 3
- stx %o3, [%sp + STACK_BIAS + 128 + 24]
-#if NARGS > 4
- stx %o4, [%sp + STACK_BIAS + 128 + 32]
-#if NARGS > 5
- stx %o5, [%sp + STACK_BIAS + 128 + 40]
-#endif
-#endif
-#endif
-#endif
-
-#if defined NEED_CANCELLATION && defined CENABLE
- SINGLE_THREAD_P
- cmp %g1, 0
- bne .Lsocket_cancel
-#endif
- mov P(SOCKOP_,socket), %o0 /* arg 1: socket subfunction */
- add %sp, STACK_BIAS + 128, %o1 /* arg 2: parameter block */
- LOADSYSCALL(socketcall)
- ta 0x6d
-
- bcc,pt %xcc, 1f
- mov %o7, %g1
- call __syscall_error
- mov %g1, %o7
-1: retl
- nop
-
-#if defined NEED_CANCELLATION && defined CENABLE
-.Lsocket_cancel:
- save %sp, -160, %sp
- cfi_def_cfa_register (%fp)
- cfi_window_save
- cfi_register (%o7, %i7)
- CENABLE
- nop
- mov %o0, %l0
- add %sp, 160 + STACK_BIAS + 128, %o1
- mov P(SOCKOP_,socket), %o0
- LOADSYSCALL(socketcall)
- ta 0x6d
-
- bcc,pt %xcc, 1f
- mov %o0, %l1
- CDISABLE;
- mov %l0, %o0;
- call __syscall_error;
- mov %l1, %o0;
- ba,pt %xcc, 2f
- mov -1, %l1;
-1: CDISABLE
- mov %l0, %o0
-2: jmpl %i7 + 8, %g0
- restore %g0, %l1, %o0
-#endif
-
-END(__socket)
-
-#ifndef NO_WEAK_ALIAS
-weak_alias (__socket, socket)
-#endif