powerpc: Call direct system calls for socket operations

Message ID 1435724523-25285-1-git-send-email-raji@linux.vnet.ibm.com
State Superseded
Delegated to: Andreas Schwab
Headers

Commit Message

Rajalakshmi S July 1, 2015, 4:22 a.m. UTC
  Explicit system calls for the socket operations were added in Linux kernel
in commit 86250b9d12ca for powerpc. This patch make use of those instead of
calling socketcall to save number of cycles on networking syscalls.

2015-07-01  Rajalakshmi Srinivasaraghavan  <raji@linux.vnet.ibm.com>

	* sysdeps/unix/sysv/linux/powerpc/kernel-features.h: Define new macros.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/accept.c: New file.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/bind.c: New file.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/connect.c: New file.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/getpeername.c: New file.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/getsockname.c: New file.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/getsockopt.c: New file.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/listen.c: New file.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/recv.c: New file.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/recvfrom.c: New file.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/recvmsg.c: New file.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/send.c: New file.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/sendmsg.c: New file.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/sendto.c: New file.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/setsockopt.c: New file.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/shutdown.c: New file.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/socket.c: New file.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/socketpair.c: New file.
---
 sysdeps/unix/sysv/linux/powerpc/kernel-features.h  | 21 +++++++++++++
 sysdeps/unix/sysv/linux/powerpc/powerpc64/accept.c | 34 ++++++++++++++++++++
 sysdeps/unix/sysv/linux/powerpc/powerpc64/bind.c   | 32 +++++++++++++++++++
 .../unix/sysv/linux/powerpc/powerpc64/connect.c    | 35 +++++++++++++++++++++
 .../sysv/linux/powerpc/powerpc64/getpeername.c     | 32 +++++++++++++++++++
 .../sysv/linux/powerpc/powerpc64/getsockname.c     | 32 +++++++++++++++++++
 .../unix/sysv/linux/powerpc/powerpc64/getsockopt.c | 32 +++++++++++++++++++
 sysdeps/unix/sysv/linux/powerpc/powerpc64/listen.c | 32 +++++++++++++++++++
 sysdeps/unix/sysv/linux/powerpc/powerpc64/recv.c   | 34 ++++++++++++++++++++
 .../unix/sysv/linux/powerpc/powerpc64/recvfrom.c   | 36 ++++++++++++++++++++++
 .../unix/sysv/linux/powerpc/powerpc64/recvmsg.c    | 34 ++++++++++++++++++++
 sysdeps/unix/sysv/linux/powerpc/powerpc64/send.c   | 35 +++++++++++++++++++++
 .../unix/sysv/linux/powerpc/powerpc64/sendmsg.c    | 34 ++++++++++++++++++++
 sysdeps/unix/sysv/linux/powerpc/powerpc64/sendto.c | 36 ++++++++++++++++++++++
 .../unix/sysv/linux/powerpc/powerpc64/setsockopt.c | 32 +++++++++++++++++++
 .../unix/sysv/linux/powerpc/powerpc64/shutdown.c   | 32 +++++++++++++++++++
 sysdeps/unix/sysv/linux/powerpc/powerpc64/socket.c | 32 +++++++++++++++++++
 .../unix/sysv/linux/powerpc/powerpc64/socketpair.c | 32 +++++++++++++++++++
 18 files changed, 587 insertions(+)
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/accept.c
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/bind.c
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/connect.c
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/getpeername.c
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/getsockname.c
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/getsockopt.c
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/listen.c
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/recv.c
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/recvfrom.c
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/recvmsg.c
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/send.c
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/sendmsg.c
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/sendto.c
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/setsockopt.c
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/shutdown.c
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/socket.c
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/socketpair.c
  

Comments

Andreas Schwab July 1, 2015, 7:02 a.m. UTC | #1
Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com> writes:

> Explicit system calls for the socket operations were added in Linux kernel
> in commit 86250b9d12ca for powerpc. This patch make use of those instead of
> calling socketcall to save number of cycles on networking syscalls.
>
> 2015-07-01  Rajalakshmi Srinivasaraghavan  <raji@linux.vnet.ibm.com>
>
> 	* sysdeps/unix/sysv/linux/powerpc/kernel-features.h: Define new macros.
> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/accept.c: New file.
> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/bind.c: New file.
> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/connect.c: New file.
> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/getpeername.c: New file.
> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/getsockname.c: New file.
> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/getsockopt.c: New file.
> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/listen.c: New file.
> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/recv.c: New file.
> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/recvfrom.c: New file.
> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/recvmsg.c: New file.
> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/send.c: New file.
> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/sendmsg.c: New file.
> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/sendto.c: New file.
> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/setsockopt.c: New file.
> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/shutdown.c: New file.
> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/socket.c: New file.
> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/socketpair.c: New file.

IMHO it would make sense to put these checks directly in
sysdeps/unix/sysv/linux/accept.c etc, since other architectures are
expected to follow.

Andreas.
  
Rajalakshmi S July 1, 2015, 8:02 a.m. UTC | #2
On 07/01/2015 12:32 PM, Andreas Schwab wrote:
> Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com> writes:
>
>> Explicit system calls for the socket operations were added in Linux kernel
>> in commit 86250b9d12ca for powerpc. This patch make use of those instead of
>> calling socketcall to save number of cycles on networking syscalls.
>>
>> 2015-07-01  Rajalakshmi Srinivasaraghavan  <raji@linux.vnet.ibm.com>
>>
>> 	* sysdeps/unix/sysv/linux/powerpc/kernel-features.h: Define new macros.
>> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/accept.c: New file.
>> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/bind.c: New file.
>> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/connect.c: New file.
>> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/getpeername.c: New file.
>> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/getsockname.c: New file.
>> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/getsockopt.c: New file.
>> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/listen.c: New file.
>> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/recv.c: New file.
>> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/recvfrom.c: New file.
>> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/recvmsg.c: New file.
>> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/send.c: New file.
>> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/sendmsg.c: New file.
>> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/sendto.c: New file.
>> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/setsockopt.c: New file.
>> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/shutdown.c: New file.
>> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/socket.c: New file.
>> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/socketpair.c: New file.
>
> IMHO it would make sense to put these checks directly in
> sysdeps/unix/sysv/linux/accept.c etc, since other architectures are
> expected to follow.
>
> Andreas.
>
If I move this new code to sysdeps/unix/sysv/linux/*.c , do you mean 
macro __ASSUME_*_SYSCALL will be defined in
future in sysdeps/unix/sysv/linux/*/kernel-features.h by respective arch 
developers based on the kernel version added?
  
Andreas Schwab July 1, 2015, 8:10 a.m. UTC | #3
Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com> writes:

> If I move this new code to sysdeps/unix/sysv/linux/*.c , do you mean macro
> __ASSUME_*_SYSCALL will be defined in
> future in sysdeps/unix/sysv/linux/*/kernel-features.h by respective arch
> developers based on the kernel version added?

Yes, that's the plan.

Andreas.
  
Joseph Myers July 1, 2015, 4:32 p.m. UTC | #4
On Wed, 1 Jul 2015, Andreas Schwab wrote:

> Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com> writes:
> 
> > If I move this new code to sysdeps/unix/sysv/linux/*.c , do you mean macro
> > __ASSUME_*_SYSCALL will be defined in
> > future in sysdeps/unix/sysv/linux/*/kernel-features.h by respective arch
> > developers based on the kernel version added?
> 
> Yes, that's the plan.

In addition, though this is independent of the present patch:

There are a limited number of architectures using socketcall.  Rather than 
having the sysdeps/unix/sysv/linux/*.c files being the socketcall 
versions, I think it might be cleaner if those versions went in 
sysdeps/unix/sysv/linux/socketcall/ and there were appropriate Implies 
files.  Then, it would not be necessary to duplicate the syscalls.list 
entries for non-socketcall architectures (in generic/ and in the directory 
for each non-socketcall non-generic architecture).  Rather, syscalls.list 
entries for these syscalls could appear just once, probably in 
sysdeps/unix/syscalls.list but failing that in 
sysdeps/unix/sysv/linux/syscalls.list.  (Note that 
sysdeps/unix/syscalls.list has entries for some syscalls that differ, e.g. 
in the exact set of strong and weak names, from those in subdirectories of 
sysdeps/unix/sysv/linux/, so care would need to be taken about reconciling 
the differences when making any such change.)

Then, when the minimum kernel version becomes recent enough for a given 
architecture that it no longer needs to use socketcall at all because the 
relevant syscalls can just be assumed, the Implies file for that 
architecture would be removed (and if all such Implies files end up being 
removed, the socketcall directory would be removed as well).
  

Patch

diff --git a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
index 6d93491..46bd53f 100644
--- a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
@@ -36,6 +36,27 @@ 
 #endif
 #define __ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL	1
 
+/* New syscalls added for PowerPC in 2.6.37.  */
+#if __LINUX_KERNEL_VERSION >= 0x020625
+# define __ASSUME_SOCKET_SYSCALL	1
+# define __ASSUME_BIND_SYSCALL	1
+# define __ASSUME_CONNECT_SYSCALL	1
+# define __ASSUME_LISTEN_SYSCALL	1
+# define __ASSUME_ACCEPT_SYSCALL	1
+# define __ASSUME_GETSOCKNAME_SYSCALL	1
+# define __ASSUME_GETPEERNAME_SYSCALL	1
+# define __ASSUME_SOCKETPAIR_SYSCALL	1
+# define __ASSUME_SEND_SYSCALL	1
+# define __ASSUME_SENDTO_SYSCALL	1
+# define __ASSUME_RECV_SYSCALL	1
+# define __ASSUME_RECVFROM_SYSCALL	1
+# define __ASSUME_SHUTDOWN_SYSCALL	1
+# define __ASSUME_GETSOCKOPT_SYSCALL	1
+# define __ASSUME_SETSOCKOPT_SYSCALL	1
+# define __ASSUME_SENDMSG_SYSCALL	1
+# define __ASSUME_RECVMSG_SYSCALL	1
+#endif
+
 #include_next <kernel-features.h>
 
 /* PowerPC64 IPC is always 64-bit and does not use __IPC_64.  */
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/accept.c b/sysdeps/unix/sysv/linux/powerpc/powerpc64/accept.c
new file mode 100644
index 0000000..e1b71b1
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/accept.c
@@ -0,0 +1,34 @@ 
+/* 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 <signal.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <kernel-features.h>
+#include <sys/syscall.h>
+#include <sysdep-cancel.h>
+
+#if defined __ASSUME_ACCEPT_SYSCALL && defined __NR_accept
+int
+__libc_accept (int fd, __SOCKADDR_ARG addr, socklen_t *len)
+{
+  return SYSCALL_CANCEL (accept, fd, addr.__sockaddr__, len);
+}
+weak_alias (__libc_accept, accept)
+libc_hidden_def (accept)
+#else
+#include <sysdeps/unix/sysv/linux/accept.c>
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/bind.c b/sysdeps/unix/sysv/linux/powerpc/powerpc64/bind.c
new file mode 100644
index 0000000..8cf1485
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/bind.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 <signal.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <kernel-features.h>
+#include <sys/syscall.h>
+
+#if defined __ASSUME_BIND_SYSCALL && defined __NR_bind
+int
+__bind (int fd, __CONST_SOCKADDR_ARG addr, socklen_t len)
+{
+  return INLINE_SYSCALL (bind, 3, fd, addr.__sockaddr__, len);
+}
+weak_alias (__bind, bind)
+#else
+#include <sysdeps/unix/sysv/linux/bind.c>
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/connect.c b/sysdeps/unix/sysv/linux/powerpc/powerpc64/connect.c
new file mode 100644
index 0000000..b9ead9c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/connect.c
@@ -0,0 +1,35 @@ 
+/* 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 <signal.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <kernel-features.h>
+#include <sys/syscall.h>
+#include <sysdep-cancel.h>
+
+#if defined __ASSUME_CONNECT_SYSCALL && defined __NR_connect
+int
+__libc_connect (int fd, __CONST_SOCKADDR_ARG addr, socklen_t len)
+{
+  return SYSCALL_CANCEL (connect, fd, addr.__sockaddr__, len);
+}
+weak_alias (__libc_connect, connect)
+weak_alias (__libc_connect, __connect)
+libc_hidden_weak (__connect)
+#else
+#include <sysdeps/unix/sysv/linux/connect.c>
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/getpeername.c b/sysdeps/unix/sysv/linux/powerpc/powerpc64/getpeername.c
new file mode 100644
index 0000000..33f658a
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/getpeername.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 <signal.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <kernel-features.h>
+#include <sys/syscall.h>
+
+#if defined __ASSUME_GETPEERNAME_SYSCALL && defined __NR_getpeername
+int
+__getpeername (int fd, __SOCKADDR_ARG addr, socklen_t *len)
+{
+  return INLINE_SYSCALL (getpeername, 3, fd, addr.__sockaddr__, len);
+}
+weak_alias (__getpeername, getpeername)
+#else
+#include <sysdeps/unix/sysv/linux/getpeername.c>
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/getsockname.c b/sysdeps/unix/sysv/linux/powerpc/powerpc64/getsockname.c
new file mode 100644
index 0000000..1e4f2bb
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/getsockname.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 <signal.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <kernel-features.h>
+#include <sys/syscall.h>
+
+#if defined __ASSUME_GETSOCKNAME_SYSCALL && defined __NR_getsockname
+int
+__getsockname (int fd, __SOCKADDR_ARG addr, socklen_t *len)
+{
+  return INLINE_SYSCALL (getsockname, 3, fd, addr.__sockaddr__, len);
+}
+weak_alias (__getsockname, getsockname)
+#else
+#include <sysdeps/unix/sysv/linux/getsockname.c>
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/getsockopt.c b/sysdeps/unix/sysv/linux/powerpc/powerpc64/getsockopt.c
new file mode 100644
index 0000000..bcdb0e7
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/getsockopt.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 <signal.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <kernel-features.h>
+#include <sys/syscall.h>
+
+#if defined __ASSUME_GETSOCKOPT_SYSCALL && defined __NR_getsockopt
+int
+__getsockopt (int fd, int level, int optname, void *optval, socklen_t *len)
+{
+  return INLINE_SYSCALL (getsockopt, 5, fd, level, optname, optval, len);
+}
+weak_alias (__getsockopt, getsockopt)
+#else
+#include <sysdeps/unix/sysv/linux/getsockopt.c>
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/listen.c b/sysdeps/unix/sysv/linux/powerpc/powerpc64/listen.c
new file mode 100644
index 0000000..a11ba0b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/listen.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 <signal.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <kernel-features.h>
+#include <sys/syscall.h>
+
+#if defined __ASSUME_LISTEN_SYSCALL && defined __NR_listen
+int
+listen (int fd, int backlog)
+{
+  return INLINE_SYSCALL (listen, 2, fd, backlog);
+}
+weak_alias (listen, __listen)
+#else
+#include <sysdeps/unix/sysv/linux/listen.c>
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/recv.c b/sysdeps/unix/sysv/linux/powerpc/powerpc64/recv.c
new file mode 100644
index 0000000..489302e
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/recv.c
@@ -0,0 +1,34 @@ 
+/* 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 <signal.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <kernel-features.h>
+#include <sys/syscall.h>
+#include <sysdep-cancel.h>
+
+#if defined __ASSUME_RECV_SYSCALL && defined __NR_recv
+ssize_t
+__libc_recv (int fd, void *buf, size_t len, int flags)
+{
+  return SYSCALL_CANCEL (recv, fd, buf, len, flags);
+}
+weak_alias (__libc_recv, recv)
+weak_alias (__libc_recv, __recv)
+#else
+#include <sysdeps/unix/sysv/linux/recv.c>
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/recvfrom.c b/sysdeps/unix/sysv/linux/powerpc/powerpc64/recvfrom.c
new file mode 100644
index 0000000..c55866d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/recvfrom.c
@@ -0,0 +1,36 @@ 
+/* 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 <signal.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <kernel-features.h>
+#include <sys/syscall.h>
+#include <sysdep-cancel.h>
+
+#if defined __ASSUME_RECVFROM_SYSCALL && defined __NR_recvfrom
+ssize_t
+__libc_recvfrom (int fd, void *buf, size_t len, int flags,
+                 __SOCKADDR_ARG addr, socklen_t *addrlen)
+{
+  return SYSCALL_CANCEL (recvfrom, fd, buf, len, flags, addr.__sockaddr__,
+                         addrlen);
+}
+weak_alias (__libc_recvfrom, recvfrom)
+weak_alias (__libc_recvfrom, __recvfrom)
+#else
+#include <sysdeps/unix/sysv/linux/recvfrom.c>
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/recvmsg.c b/sysdeps/unix/sysv/linux/powerpc/powerpc64/recvmsg.c
new file mode 100644
index 0000000..f573f79
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/recvmsg.c
@@ -0,0 +1,34 @@ 
+/* 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 <signal.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <kernel-features.h>
+#include <sys/syscall.h>
+#include <sysdep-cancel.h>
+
+#if defined __ASSUME_RECVMSG_SYSCALL && defined __NR_recvmsg
+ssize_t
+__libc_recvmsg (int fd, struct msghdr *msg, int flags)
+{
+  return SYSCALL_CANCEL (recvmsg, fd, msg, flags);
+}
+weak_alias (__libc_recvmsg, recvmsg)
+weak_alias (__libc_recvmsg, __recvmsg)
+#else
+#include <sysdeps/unix/sysv/linux/recvmsg.c>
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/send.c b/sysdeps/unix/sysv/linux/powerpc/powerpc64/send.c
new file mode 100644
index 0000000..b941ea4
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/send.c
@@ -0,0 +1,35 @@ 
+/* 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 <signal.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <kernel-features.h>
+#include <sys/syscall.h>
+#include <sysdep-cancel.h>
+
+#if defined __ASSUME_SEND_SYSCALL && defined __NR_send
+ssize_t
+__libc_send (int fd, const void *buf, size_t len, int flags)
+{
+  return SYSCALL_CANCEL (send, fd, buf, len, flags);
+}
+weak_alias (__libc_send, send)
+weak_alias (__libc_send, __send)
+libc_hidden_def (__send)
+#else
+#include <sysdeps/unix/sysv/linux/send.c>
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sendmsg.c b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sendmsg.c
new file mode 100644
index 0000000..a62c95f
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sendmsg.c
@@ -0,0 +1,34 @@ 
+/* 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 <signal.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <kernel-features.h>
+#include <sys/syscall.h>
+#include <sysdep-cancel.h>
+
+#if defined __ASSUME_SENDMSG_SYSCALL && defined __NR_sendmsg
+ssize_t
+__libc_sendmsg (int fd, const struct msghdr *msg, int flags)
+{
+  return SYSCALL_CANCEL (sendmsg, fd, msg, flags);
+}
+weak_alias (__libc_sendmsg, sendmsg)
+weak_alias (__libc_sendmsg, __sendmsg)
+#else
+#include <sysdeps/unix/sysv/linux/sendmsg.c>
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sendto.c b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sendto.c
new file mode 100644
index 0000000..858233f
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sendto.c
@@ -0,0 +1,36 @@ 
+/* 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 <signal.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <kernel-features.h>
+#include <sys/syscall.h>
+#include <sysdep-cancel.h>
+
+#if defined __ASSUME_SENDTO_SYSCALL && defined __NR_sendto
+ssize_t
+__libc_sendto (int fd, const void *buf, size_t len, int flags,
+               __CONST_SOCKADDR_ARG addr, socklen_t addrlen)
+{
+  return SYSCALL_CANCEL (sendto, fd, buf, len, flags, addr.__sockaddr__,
+                         addrlen);
+}
+weak_alias (__libc_sendto, sendto)
+weak_alias (__libc_sendto, __sendto)
+#else
+#include <sysdeps/unix/sysv/linux/sendto.c>
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/setsockopt.c b/sysdeps/unix/sysv/linux/powerpc/powerpc64/setsockopt.c
new file mode 100644
index 0000000..111226c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/setsockopt.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 <signal.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <kernel-features.h>
+#include <sys/syscall.h>
+
+#if defined __ASSUME_SETSOCKOPT_SYSCALL && defined __NR_setsockopt
+int
+setsockopt (int fd, int level, int optname, const void *optval, socklen_t len)
+{
+  return INLINE_SYSCALL (setsockopt, 5, fd, level, optname, optval, len);
+}
+weak_alias (setsockopt, __setsockopt)
+#else
+#include <sysdeps/unix/sysv/linux/setsockopt.c>
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/shutdown.c b/sysdeps/unix/sysv/linux/powerpc/powerpc64/shutdown.c
new file mode 100644
index 0000000..409519b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/shutdown.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 <signal.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <kernel-features.h>
+#include <sys/syscall.h>
+
+#if defined __ASSUME_SHUTDOWN_SYSCALL && defined __NR_shutdown
+int
+__shutdown (int fd, int how)
+{
+  return INLINE_SYSCALL (shutdown, 2, fd, how);
+}
+weak_alias (__shutdown, shutdown)
+#else
+#include <sysdeps/unix/sysv/linux/shutdown.c>
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/socket.c b/sysdeps/unix/sysv/linux/powerpc/powerpc64/socket.c
new file mode 100644
index 0000000..22bb635
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/socket.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 <signal.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <kernel-features.h>
+#include <sys/syscall.h>
+
+#if defined __ASSUME_SOCKET_SYSCALL && defined __NR_socket
+int
+__socket (int fd, int type, int domain)
+{
+  return INLINE_SYSCALL (socket, 3, fd, type, domain);
+}
+weak_alias (__socket, socket)
+#else
+#include <sysdeps/unix/sysv/linux/socket.c>
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/socketpair.c b/sysdeps/unix/sysv/linux/powerpc/powerpc64/socketpair.c
new file mode 100644
index 0000000..2fee61c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/socketpair.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 <signal.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <kernel-features.h>
+#include <sys/syscall.h>
+
+#if defined __ASSUME_SOCKETPAIR_SYSCALL && defined __NR_socketpair
+int
+__socketpair (int domain, int type, int protocol, int sv[2])
+{
+  return INLINE_SYSCALL (socketpair, 4, domain, type, protocol, sv);
+}
+weak_alias (__socketpair, socketpair)
+#else
+#include <sysdeps/unix/sysv/linux/socketpair.c>
+#endif