This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[tschwinge/sendmmsg] Add recvmmsg and sendmmsg to the generic glibc API


Hi!

Finally getting back to this issue.


On Sat, 23 Jun 2012 11:07:26 +0200, I wrote:
> On Fri, 22 Jun 2012 15:06:53 +0200, I wrote:
> > On 30 Mar 2012 11:43:09 -0000, drepper@sourceware.org wrote:
> > > http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=c030f70c8796c7743c3aa97d6beff3bd5b8dcd5d
> > > 
> > > commit c030f70c8796c7743c3aa97d6beff3bd5b8dcd5d
> > > Author: Ulrich Drepper <drepper@gmail.com>
> > > Date:   Fri Mar 30 07:42:29 2012 -0400
> > > 
> > >     Speed up DNS by avoiding a system call if possible
> > 
> > This patch adds a call to the (currently) Linux-specific sendmmsg to
> > generic code:
> > 
> >     res_send.c: In function 'send_dg':
> >     res_send.c:1113:22: error: array type has incomplete element type
> >            struct mmsghdr reqs[2];
> >                           ^
> >     res_send.c:1132:7: warning: implicit declaration of function 'sendmmsg' [-Wimplicit-function-declaration]
> >            int ndg = sendmmsg (pfd[0].fd, reqs, 2, MSG_NOSIGNAL);
> >            ^
> > 
> > > +	* resolv/res_send.c (send_dg): Use sendmmsg if we have to write two
> > > +	requests to save a system call.
> > 
> > > +++ b/resolv/res_send.c
> > > [...]
> > > +		    int ndg = sendmmsg (pfd[0].fd, reqs, 2, MSG_NOSIGNAL);
> > 
> > How do people want me to solve this?  a) Make the code use sendmmsg only
> > if it is is available, or b) add a generic ENOSYS sendmmsg stub
> > (appropriately versioned for 2.16/2.17) and move struct sendmmsg etc. to
> > a generic place?  (The existing code already does and has to do the
> > correct thing if sendmmsg "returns" ENOSYS (and probes only once), as
> > this will also happen with older Linux kernels.)  I'd tend towards b)
> > because we might add a sendmmsg implementation for GNU/Hurd later on.
> 
> This got a little bit more involved, I'm afraid.  If you feel more
> comfortable that way, I'm fine with holding the patch back until after
> the release, but would appreciate a quick review if the general approach
> is fine.
> 
> Cross-build-tested for i686-gnu, Âmake checkÂ-tested for
> x86_64-linux-gnu, where I also compared all *.o *.os to those without the
> patch using GCC's contrib/compare-debug (no notable differences), and
> also the resulting symbol version information looks as expected.

On Mon, 25 Jun 2012 16:32:06 -0700 (PDT), Roland McGrath <roland@hack.frob.com> wrote:
> I think this is the right way to go: adding sendmmsg/recvmmsg to the
> generic libc API.  They are generally useful interfaces and there is
> nothing intrinsically Linuxoid about them.

OK, thanks.

> At least when not given a
> timeout, they could be implemented in terms of sendmsg/recvmsg.  So
> perhaps we ought to have a sysdeps/posix implementation that the Hurd
> would use instead of stubs (and folks can consider adding new RPCs).
> Then perhaps the Linux fallback case should be that instead of stubs, too.

Sounds reasonable, but that's for later: let's first solve this issue
here.

> This certainly has to wait for 2.17.  Please file a bugzilla report
> for it, update your change to use GLIBC_2.17 for the symbol version
> additions, and publish the change on a private branch for others to
> look at.

I have now updated the patch (symbol versions, also added for all ports),
rebased it on current sources, and published it as the tschwinge/sendmmsg
branch.

Did I generally get the versioning stuff right?  That aside, especially
the changes to the four sysdeps/unix/sysv/linux/*mmsg.* files are
sufficiently hairy that they need to be scrutinized closely for that they
do the right thing for all the possible cases.

commit 2d5d0c27cdc6c975ba020e880e94ad3841f11ca3
Author: Thomas Schwinge <thomas@schwinge.name>
Date:   Thu Nov 1 23:40:02 2012 +0100

    Add recvmmsg and sendmmsg to the generic glibc API.

diff --git ChangeLog ChangeLog
index bea7626..8409f1b 100644
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,49 @@
+2012-11-01  Thomas Schwinge  <thomas@codesourcery.com>
+
+	* sysdeps/unix/sysv/linux/bits/socket.h (struct mmsghdr, recvmmsg)
+	(sendmmsg): Move declarations...
+	* socket/sys/socket.h: ... here.
+	* socket/recvmmsg.c: New file.
+	* socket/sendmmsg.c: New file.
+	* sysdeps/unix/sysv/linux/internal_recvmmsg.S [__ASSUME_RECVMMSG]
+	(recvmmsg): Rename to __recvmmsg, create weak alias and make
+	definition of __recvmmsg hidden.
+	* sysdeps/unix/sysv/linux/recvmmsg.c (recvmmsg): Likewise.
+	Include <socket/recvmmsg.c> for ENOSYS stub.
+	* sysdeps/unix/sysv/linux/internal_sendmmsg.S [__ASSUME_SENDMMSG]
+	(sendmmsg): Rename to __sendmmsg, create weak alias and make
+	definition of __sendmmsg hidden.
+	* sysdeps/unix/sysv/linux/sendmmsg.c (sendmmsg): Likewise.
+	Include <socket/sendmmsg.c> for ENOSYS stub.
+	* sysdeps/unix/sysv/linux/Makefile [subdir=socket]
+	(sysdep_routines): Move recvmmsg and sendmmsg...
+	* socket/Makefile (routines): ... here.
+	* socket/Versions (GLIBC_2.17): Add __sendmmsg, recvmmsg, and
+	sendmmsg.
+	* include/sys/socket.h (__recvmmsg, __sendmmsg): Add declarations.
+	* resolv/res_send.c (send_dg): Invoke __sendmmsg instead of
+	sendmmsg.
+	* sysdeps/unix/sysv/linux/i386/nptl/libc.abilist (GLIBC_2.17): Add
+	__sendmmsg.
+	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/nptl/libc.abilist
+	(GLIBC_2.17): Likewise.
+	* sysdeps/unix/sysv/linux/powerpc/powerpc64/nptl/libc.abilist
+	(GLIBC_2.17): Likewise.
+	* sysdeps/unix/sysv/linux/s390/s390-32/nptl/libc.abilist
+	(GLIBC_2.17): Likewise.
+	* sysdeps/unix/sysv/linux/s390/s390-64/nptl/libc.abilist
+	(GLIBC_2.17): Likewise.
+	* sysdeps/unix/sysv/linux/sh/nptl/libc.abilist (GLIBC_2.17):
+	Likewise.
+	* sysdeps/unix/sysv/linux/sparc/sparc32/nptl/libc.abilist
+	(GLIBC_2.17): Likewise.
+	* sysdeps/unix/sysv/linux/sparc/sparc64/nptl/libc.abilist
+	(GLIBC_2.17): Likewise.
+	* sysdeps/unix/sysv/linux/x86_64/64/nptl/libc.abilist
+	(GLIBC_2.17): Likewise.
+	* sysdeps/unix/sysv/linux/x86_64/x32/nptl/libc.abilist
+	(GLIBC_2.17): Likewise.
+
 2012-11-01  Andreas Schwab  <schwab@linux-m68k.org>
 
 	* scripts/check-local-headers.sh: Ignore c++ headers.
diff --git include/sys/socket.h include/sys/socket.h
index ec08857..821a9c0 100644
--- include/sys/socket.h
+++ include/sys/socket.h
@@ -91,6 +91,10 @@ extern ssize_t __libc_sendmsg (int __fd, const struct msghdr *__message,
 extern ssize_t __sendmsg (int __fd, const struct msghdr *__message,
 			  int __flags) attribute_hidden;
 
+extern int __sendmmsg (int __fd, struct mmsghdr *__vmessages,
+                       unsigned int __vlen, int __flags);
+libc_hidden_proto (__sendmmsg)
+
 /* Receive a message as described by MESSAGE from socket FD.
    Returns the number of bytes read or -1 for errors.  */
 extern ssize_t __libc_recvmsg (int __fd, struct msghdr *__message,
@@ -98,6 +102,11 @@ extern ssize_t __libc_recvmsg (int __fd, struct msghdr *__message,
 extern ssize_t __recvmsg (int __fd, struct msghdr *__message,
 			  int __flags) attribute_hidden;
 
+extern int __recvmmsg (int __fd, struct mmsghdr *__vmessages,
+                       unsigned int __vlen, int __flags,
+                       const struct timespec *__tmo);
+libc_hidden_proto (__recvmmsg)
+
 /* Set socket FD's option OPTNAME at protocol level LEVEL
    to *OPTVAL (which is OPTLEN bytes long).
    Returns 0 on success, -1 for errors.  */
diff --git ports/ChangeLog.alpha ports/ChangeLog.alpha
index 7bfdda3..c237a30 100644
--- ports/ChangeLog.alpha
+++ ports/ChangeLog.alpha
@@ -1,3 +1,8 @@
+2012-11-01  Thomas Schwinge  <thomas@codesourcery.com>
+
+	* sysdeps/unix/sysv/linux/alpha/nptl/libc.abilist (GLIBC_2.17):
+	Add __sendmmsg.
+
 2012-11-01  Andreas Jaeger  <aj@suse.de>
 
 	* sysdeps/unix/sysv/linux/alpha/bits/fcntl.h: Remove all
diff --git ports/ChangeLog.arm ports/ChangeLog.arm
index 0b76f5e..5d78122 100644
--- ports/ChangeLog.arm
+++ ports/ChangeLog.arm
@@ -1,3 +1,8 @@
+2012-11-01  Thomas Schwinge  <thomas@codesourcery.com>
+
+	* sysdeps/unix/sysv/linux/arm/nptl/libc.abilist (GLIBC_2.17):
+	Add __sendmmsg.
+
 2012-10-22  Roland McGrath  <roland@hack.frob.com>
 
 	* sysdeps/unix/sysv/linux/arm/nptl/libc.abilist
diff --git ports/ChangeLog.ia64 ports/ChangeLog.ia64
index 1531304..3eec77c 100644
--- ports/ChangeLog.ia64
+++ ports/ChangeLog.ia64
@@ -1,3 +1,8 @@
+2012-11-01  Thomas Schwinge  <thomas@codesourcery.com>
+
+	* sysdeps/unix/sysv/linux/ia64/nptl/libc.abilist (GLIBC_2.17):
+	Add __sendmmsg.
+
 2012-10-30  Joseph Myers  <joseph@codesourcery.com>
 
 	[BZ #14047]
diff --git ports/ChangeLog.m68k ports/ChangeLog.m68k
index ac879c1..7e9a3f6 100644
--- ports/ChangeLog.m68k
+++ ports/ChangeLog.m68k
@@ -1,3 +1,10 @@
+2012-11-01  Thomas Schwinge  <thomas@codesourcery.com>
+
+	* sysdeps/unix/sysv/linux/m68k/coldfire/nptl/libc.abilist
+	(GLIBC_2.17): Add __sendmmsg.
+	* sysdeps/unix/sysv/linux/m68k/m680x0/nptl/libc.abilist
+	(GLIBC_2.17): Likewise.
+
 2012-10-25  Andreas Jaeger  <aj@suse.de>
 
 	* sysdeps/unix/sysv/linux/m68k/bits/fcntl.h: Remove all
diff --git ports/ChangeLog.mips ports/ChangeLog.mips
index 3652ff9..0450431 100644
--- ports/ChangeLog.mips
+++ ports/ChangeLog.mips
@@ -1,5 +1,14 @@
 2012-11-01  Thomas Schwinge  <thomas@codesourcery.com>
 
+	* sysdeps/unix/sysv/linux/mips/mips32/nptl/libc.abilist
+	(GLIBC_2.17): Add __sendmmsg.
+	* sysdeps/unix/sysv/linux/mips/mips64/n32/nptl/libc.abilist
+	(GLIBC_2.17): Likewise.
+	* sysdeps/unix/sysv/linux/mips/mips64/n64/nptl/libc.abilist
+	(GLIBC_2.17): Likewise.
+
+2012-11-01  Thomas Schwinge  <thomas@codesourcery.com>
+
 	* sysdeps/unix/sysv/linux/mips/configure: Regenerate.
 
 	* sysdeps/unix/sysv/linux/mips/mips64/n32/nptl/libc.abilist
diff --git ports/ChangeLog.powerpc ports/ChangeLog.powerpc
index 758853e..8a0b1b7 100644
--- ports/ChangeLog.powerpc
+++ ports/ChangeLog.powerpc
@@ -1,3 +1,8 @@
+2012-11-01  Thomas Schwinge  <thomas@codesourcery.com>
+
+	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/nptl/libc.abilist
+	(GLIBC_2.17): Add __sendmmsg.
+
 2012-10-31  Andreas Schwab  <schwab@linux-m68k.org>
 
 	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/nptl/libc.abilist:
diff --git ports/ChangeLog.tile ports/ChangeLog.tile
index 1f04349..110204c 100644
--- ports/ChangeLog.tile
+++ ports/ChangeLog.tile
@@ -1,3 +1,12 @@
+2012-11-01  Thomas Schwinge  <thomas@codesourcery.com>
+
+	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/nptl/libc.abilist
+	(GLIBC_2.17): Add __sendmmsg.
+	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/nptl/libc.abilist
+	(GLIBC_2.17): Likewise.
+	* sysdeps/unix/sysv/linux/tile/tilepro/nptl/libc.abilist
+	(GLIBC_2.17): Likewise.
+
 2012-10-30  Chris Metcalf  <cmetcalf@tilera.com>
 
 	* sysdeps/tile/dl-machine.h: Use new DL_AFTER_LOAD macro
diff --git ports/sysdeps/unix/sysv/linux/alpha/nptl/libc.abilist ports/sysdeps/unix/sysv/linux/alpha/nptl/libc.abilist
index 1d0cc7e..0ce8e1f 100644
--- ports/sysdeps/unix/sysv/linux/alpha/nptl/libc.abilist
+++ ports/sysdeps/unix/sysv/linux/alpha/nptl/libc.abilist
@@ -1813,6 +1813,7 @@ GLIBC_2.16
  timespec_get F
 GLIBC_2.17
  GLIBC_2.17 A
+ __sendmmsg F
  clock_getcpuclockid F
  clock_getres F
  clock_gettime F
diff --git ports/sysdeps/unix/sysv/linux/arm/nptl/libc.abilist ports/sysdeps/unix/sysv/linux/arm/nptl/libc.abilist
index ceab6b2..e4c0674 100644
--- ports/sysdeps/unix/sysv/linux/arm/nptl/libc.abilist
+++ ports/sysdeps/unix/sysv/linux/arm/nptl/libc.abilist
@@ -80,6 +80,7 @@ GLIBC_2.16
  timespec_get F
 GLIBC_2.17
  GLIBC_2.17 A
+ __sendmmsg F
  clock_getcpuclockid F
  clock_getres F
  clock_gettime F
diff --git ports/sysdeps/unix/sysv/linux/ia64/nptl/libc.abilist ports/sysdeps/unix/sysv/linux/ia64/nptl/libc.abilist
index b3510fe..d5cf29c 100644
--- ports/sysdeps/unix/sysv/linux/ia64/nptl/libc.abilist
+++ ports/sysdeps/unix/sysv/linux/ia64/nptl/libc.abilist
@@ -80,6 +80,7 @@ GLIBC_2.16
  timespec_get F
 GLIBC_2.17
  GLIBC_2.17 A
+ __sendmmsg F
  clock_getcpuclockid F
  clock_getres F
  clock_gettime F
diff --git ports/sysdeps/unix/sysv/linux/m68k/coldfire/nptl/libc.abilist ports/sysdeps/unix/sysv/linux/m68k/coldfire/nptl/libc.abilist
index 3c40379..e17e324 100644
--- ports/sysdeps/unix/sysv/linux/m68k/coldfire/nptl/libc.abilist
+++ ports/sysdeps/unix/sysv/linux/m68k/coldfire/nptl/libc.abilist
@@ -81,6 +81,7 @@ GLIBC_2.16
  timespec_get F
 GLIBC_2.17
  GLIBC_2.17 A
+ __sendmmsg F
  clock_getcpuclockid F
  clock_getres F
  clock_gettime F
diff --git ports/sysdeps/unix/sysv/linux/m68k/m680x0/nptl/libc.abilist ports/sysdeps/unix/sysv/linux/m68k/m680x0/nptl/libc.abilist
index f998b1b..db61e00 100644
--- ports/sysdeps/unix/sysv/linux/m68k/m680x0/nptl/libc.abilist
+++ ports/sysdeps/unix/sysv/linux/m68k/m680x0/nptl/libc.abilist
@@ -1769,6 +1769,7 @@ GLIBC_2.16
  timespec_get F
 GLIBC_2.17
  GLIBC_2.17 A
+ __sendmmsg F
  clock_getcpuclockid F
  clock_getres F
  clock_gettime F
diff --git ports/sysdeps/unix/sysv/linux/mips/mips32/nptl/libc.abilist ports/sysdeps/unix/sysv/linux/mips/mips32/nptl/libc.abilist
index 7378869..91defd2 100644
--- ports/sysdeps/unix/sysv/linux/mips/mips32/nptl/libc.abilist
+++ ports/sysdeps/unix/sysv/linux/mips/mips32/nptl/libc.abilist
@@ -2244,6 +2244,7 @@ _gp_disp
  _gp_disp A
 GLIBC_2.17
  GLIBC_2.17 A
+ __sendmmsg F
  clock_getcpuclockid F
  clock_getres F
  clock_gettime F
diff --git ports/sysdeps/unix/sysv/linux/mips/mips64/n32/nptl/libc.abilist ports/sysdeps/unix/sysv/linux/mips/mips64/n32/nptl/libc.abilist
index df2e637..42c5904 100644
--- ports/sysdeps/unix/sysv/linux/mips/mips64/n32/nptl/libc.abilist
+++ ports/sysdeps/unix/sysv/linux/mips/mips64/n32/nptl/libc.abilist
@@ -1392,6 +1392,7 @@ GLIBC_2.16
  timespec_get F
 GLIBC_2.17
  GLIBC_2.17 A
+ __sendmmsg F
  clock_getcpuclockid F
  clock_getres F
  clock_gettime F
diff --git ports/sysdeps/unix/sysv/linux/mips/mips64/n64/nptl/libc.abilist ports/sysdeps/unix/sysv/linux/mips/mips64/n64/nptl/libc.abilist
index 22b3068..d88c2f2 100644
--- ports/sysdeps/unix/sysv/linux/mips/mips64/n64/nptl/libc.abilist
+++ ports/sysdeps/unix/sysv/linux/mips/mips64/n64/nptl/libc.abilist
@@ -1390,6 +1390,7 @@ GLIBC_2.16
  timespec_get F
 GLIBC_2.17
  GLIBC_2.17 A
+ __sendmmsg F
  clock_getcpuclockid F
  clock_getres F
  clock_gettime F
diff --git ports/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/nptl/libc.abilist ports/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/nptl/libc.abilist
index 0efc6b5..157fbfc 100644
--- ports/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/nptl/libc.abilist
+++ ports/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/nptl/libc.abilist
@@ -1775,6 +1775,7 @@ GLIBC_2.16
 GLIBC_2.17
  GLIBC_2.17 A
  __ppc_get_timebase_freq F
+ __sendmmsg F
  clock_getcpuclockid F
  clock_getres F
  clock_gettime F
diff --git ports/sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/nptl/libc.abilist ports/sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/nptl/libc.abilist
index d79b2df..d730e6c 100644
--- ports/sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/nptl/libc.abilist
+++ ports/sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/nptl/libc.abilist
@@ -2082,6 +2082,7 @@ GLIBC_2.16
  timespec_get F
 GLIBC_2.17
  GLIBC_2.17 A
+ __sendmmsg F
  clock_getcpuclockid F
  clock_getres F
  clock_gettime F
diff --git ports/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/nptl/libc.abilist ports/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/nptl/libc.abilist
index f617405..71e192b 100644
--- ports/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/nptl/libc.abilist
+++ ports/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/nptl/libc.abilist
@@ -2082,6 +2082,7 @@ GLIBC_2.16
  timespec_get F
 GLIBC_2.17
  GLIBC_2.17 A
+ __sendmmsg F
  clock_getcpuclockid F
  clock_getres F
  clock_gettime F
diff --git ports/sysdeps/unix/sysv/linux/tile/tilepro/nptl/libc.abilist ports/sysdeps/unix/sysv/linux/tile/tilepro/nptl/libc.abilist
index d79b2df..d730e6c 100644
--- ports/sysdeps/unix/sysv/linux/tile/tilepro/nptl/libc.abilist
+++ ports/sysdeps/unix/sysv/linux/tile/tilepro/nptl/libc.abilist
@@ -2082,6 +2082,7 @@ GLIBC_2.16
  timespec_get F
 GLIBC_2.17
  GLIBC_2.17 A
+ __sendmmsg F
  clock_getcpuclockid F
  clock_getres F
  clock_gettime F
diff --git resolv/res_send.c resolv/res_send.c
index 0a28cd7..c790031 100644
--- resolv/res_send.c
+++ resolv/res_send.c
@@ -1129,7 +1129,7 @@ send_dg(res_state statp,
 		    reqs[1].msg_hdr.msg_control = NULL;
 		    reqs[1].msg_hdr.msg_controllen = 0;
 
-		    int ndg = sendmmsg (pfd[0].fd, reqs, 2, MSG_NOSIGNAL);
+		    int ndg = __sendmmsg (pfd[0].fd, reqs, 2, MSG_NOSIGNAL);
 		    if (__builtin_expect (ndg == 2, 1))
 		      {
 			if (reqs[0].msg_len != buflen
diff --git socket/Makefile socket/Makefile
index e3a90b8..6037f3f 100644
--- socket/Makefile
+++ socket/Makefile
@@ -26,7 +26,7 @@ headers	:= sys/socket.h sys/un.h bits/sockaddr.h bits/socket.h \
 routines := accept bind connect getpeername getsockname getsockopt	\
 	    listen recv recvfrom recvmsg send sendmsg sendto		\
 	    setsockopt shutdown socket socketpair isfdtype opensock	\
-	    sockatmark accept4
+	    sockatmark accept4 recvmmsg sendmmsg
 
 aux	 := have_sock_cloexec
 
diff --git socket/Versions socket/Versions
index 7a96b1e..347433f 100644
--- socket/Versions
+++ socket/Versions
@@ -34,4 +34,10 @@ libc {
   GLIBC_2.10 {
     accept4;
   }
+  GLIBC_2.17 {
+    # functions used in other libraries
+    __sendmmsg;
+
+    recvmmsg; sendmmsg;
+  }
 }
diff --git socket/recvmmsg.c socket/recvmmsg.c
new file mode 100644
index 0000000..0bc6450
--- /dev/null
+++ socket/recvmmsg.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 2012 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 <sys/socket.h>
+
+/* Receive up to VLEN messages as described by VMESSAGES from socket FD.
+   Returns the number of bytes read or -1 for errors.  */
+int
+__recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
+	    const struct timespec *tmo)
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+libc_hidden_def (__recvmmsg)
+
+weak_alias (__recvmmsg, recvmmsg)
+
+stub_warning (recvmmsg)
diff --git socket/sendmmsg.c socket/sendmmsg.c
new file mode 100644
index 0000000..f717037
--- /dev/null
+++ socket/sendmmsg.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 2012 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 <sys/socket.h>
+
+/* Send a VLEN messages as described by VMESSAGES to socket FD.
+   Returns the number of datagrams successfully written or -1 for errors.  */
+int
+__sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+libc_hidden_def (__sendmmsg)
+
+weak_alias (__sendmmsg, sendmmsg)
+
+stub_warning (sendmmsg)
diff --git socket/sys/socket.h socket/sys/socket.h
index 787c2b9..3810a37 100644
--- socket/sys/socket.h
+++ socket/sys/socket.h
@@ -97,6 +97,16 @@ typedef union { __SOCKADDR_ALLTYPES
 # undef __SOCKADDR_ONETYPE
 #endif
 
+#ifdef __USE_GNU
+/* For `recvmmsg' and `sendmmsg'.  */
+struct mmsghdr
+  {
+    struct msghdr msg_hdr;	/* Actual message header.  */
+    unsigned int msg_len;	/* Number of received or sent bytes for the
+				   entry.  */
+  };
+#endif
+
 
 /* Create a new socket of type TYPE in domain DOMAIN, using
    protocol PROTOCOL.  If PROTOCOL is zero, one is chosen automatically.
@@ -175,6 +185,16 @@ extern ssize_t recvfrom (int __fd, void *__restrict __buf, size_t __n,
 extern ssize_t sendmsg (int __fd, const struct msghdr *__message,
 			int __flags);
 
+#ifdef __USE_GNU
+/* Send a VLEN messages as described by VMESSAGES to socket FD.
+   Returns the number of datagrams successfully written or -1 for errors.
+
+   This function is a cancellation point and therefore not marked with
+   __THROW.  */
+extern int sendmmsg (int __fd, struct mmsghdr *__vmessages,
+		     unsigned int __vlen, int __flags);
+#endif
+
 /* Receive a message as described by MESSAGE from socket FD.
    Returns the number of bytes read or -1 for errors.
 
@@ -182,6 +202,17 @@ extern ssize_t sendmsg (int __fd, const struct msghdr *__message,
    __THROW.  */
 extern ssize_t recvmsg (int __fd, struct msghdr *__message, int __flags);
 
+#ifdef __USE_GNU
+/* Receive up to VLEN messages as described by VMESSAGES from socket FD.
+   Returns the number of bytes read or -1 for errors.
+
+   This function is a cancellation point and therefore not marked with
+   __THROW.  */
+extern int recvmmsg (int __fd, struct mmsghdr *__vmessages,
+		     unsigned int __vlen, int __flags,
+		     const struct timespec *__tmo);
+#endif
+
 
 /* Put the current value for socket FD's option OPTNAME at protocol level LEVEL
    into OPTVAL (which is *OPTLEN bytes long), and set *OPTLEN to the value's
diff --git sysdeps/unix/sysv/linux/Makefile sysdeps/unix/sysv/linux/Makefile
index 8e5361c..ecd9c2c 100644
--- sysdeps/unix/sysv/linux/Makefile
+++ sysdeps/unix/sysv/linux/Makefile
@@ -12,8 +12,7 @@ CFLAGS-malloc.c += -DMORECORE_CLEARS=2
 endif
 
 ifeq ($(subdir),socket)
-sysdep_routines += internal_accept4 recvmmsg internal_recvmmsg sendmmsg \
-		   internal_sendmmsg
+sysdep_routines += internal_accept4 internal_recvmmsg internal_sendmmsg
 endif
 
 ifeq ($(subdir),misc)
diff --git sysdeps/unix/sysv/linux/bits/socket.h sysdeps/unix/sysv/linux/bits/socket.h
index 309cba7..df8f167 100644
--- sysdeps/unix/sysv/linux/bits/socket.h
+++ sysdeps/unix/sysv/linux/bits/socket.h
@@ -235,16 +235,6 @@ struct msghdr
     int msg_flags;		/* Flags on received message.  */
   };
 
-#ifdef __USE_GNU
-/* For `recvmmsg' and 'sendmmsg'.  */
-struct mmsghdr
-  {
-    struct msghdr msg_hdr;	/* Actual message header.  */
-    unsigned int msg_len;	/* Number of received or sent bytes
-				   for the entry.  */
-  };
-#endif
-
 /* Structure used for storage of ancillary data object information.  */
 struct cmsghdr
   {
@@ -389,27 +379,4 @@ struct linger
     int l_linger;		/* Time to linger.  */
   };
 
-
-__BEGIN_DECLS
-
-#ifdef __USE_GNU
-/* Receive up to VLEN messages as described by VMESSAGES from socket FD.
-   Returns the number of bytes read or -1 for errors.
-
-   This function is a cancellation point and therefore not marked with
-   __THROW.  */
-extern int recvmmsg (int __fd, struct mmsghdr *__vmessages,
-		     unsigned int __vlen, int __flags,
-		     const struct timespec *__tmo);
-
-/* Send a VLEN messages as described by VMESSAGES to socket FD.
-   Return the number of datagrams successfully written or -1 for errors.
-This function is a cancellation point and therefore not marked with
-   __THROW.  */
-extern int sendmmsg (int __fd, struct mmsghdr *__vmessages,
-		     unsigned int __vlen, int __flags);
-#endif
-
-__END_DECLS
-
 #endif	/* bits/socket.h */
diff --git sysdeps/unix/sysv/linux/i386/nptl/libc.abilist sysdeps/unix/sysv/linux/i386/nptl/libc.abilist
index 67d5929..c057117 100644
--- sysdeps/unix/sysv/linux/i386/nptl/libc.abilist
+++ sysdeps/unix/sysv/linux/i386/nptl/libc.abilist
@@ -1813,6 +1813,7 @@ GLIBC_2.16
  timespec_get F
 GLIBC_2.17
  GLIBC_2.17 A
+ __sendmmsg F
  clock_getcpuclockid F
  clock_getres F
  clock_gettime F
diff --git sysdeps/unix/sysv/linux/internal_recvmmsg.S sysdeps/unix/sysv/linux/internal_recvmmsg.S
index 66c1357..18e6da8 100644
--- sysdeps/unix/sysv/linux/internal_recvmmsg.S
+++ sysdeps/unix/sysv/linux/internal_recvmmsg.S
@@ -2,13 +2,14 @@
 #include <sys/syscall.h>
 #if !defined __NR_recvmmsg && defined __NR_socketcall
 # define socket	recvmmsg
-# ifdef __ASSUME_RECVMMSG
-#  define __socket recvmmsg
-# else
+# ifndef __ASSUME_RECVMMSG
 #  define __socket __internal_recvmmsg
+#  define NO_WEAK_ALIAS
 # endif
 # define NARGS 5
 # define NEED_CANCELLATION
-# define NO_WEAK_ALIAS
 # include <socket.S>
+# ifdef __ASSUME_RECVMMSG
+libc_hidden_def (__recvmmsg)
+# endif
 #endif
diff --git sysdeps/unix/sysv/linux/internal_sendmmsg.S sysdeps/unix/sysv/linux/internal_sendmmsg.S
index f5152c9..e6681f0 100644
--- sysdeps/unix/sysv/linux/internal_sendmmsg.S
+++ sysdeps/unix/sysv/linux/internal_sendmmsg.S
@@ -2,13 +2,14 @@
 #include <sys/syscall.h>
 #if !defined __NR_sendmmsg && defined __NR_socketcall
 # define socket	sendmmsg
-# ifdef __ASSUME_SENDMMSG
-#  define __socket sendmmsg
-# else
+# ifndef __ASSUME_SENDMMSG
 #  define __socket __internal_sendmmsg
+#  define NO_WEAK_ALIAS
 # endif
 # define NARGS 4
 # define NEED_CANCELLATION
-# define NO_WEAK_ALIAS
 # include <socket.S>
+# ifdef __ASSUME_SENDMMSG
+libc_hidden_def (__sendmmsg)
+# endif
 #endif
diff --git sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/nptl/libc.abilist sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/nptl/libc.abilist
index 8e45958..4f4ee1e 100644
--- sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/nptl/libc.abilist
+++ sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/nptl/libc.abilist
@@ -1775,6 +1775,7 @@ GLIBC_2.16
 GLIBC_2.17
  GLIBC_2.17 A
  __ppc_get_timebase_freq F
+ __sendmmsg F
  clock_getcpuclockid F
  clock_getres F
  clock_gettime F
diff --git sysdeps/unix/sysv/linux/powerpc/powerpc64/nptl/libc.abilist sysdeps/unix/sysv/linux/powerpc/powerpc64/nptl/libc.abilist
index 8eaaccd..3e7c8d6 100644
--- sysdeps/unix/sysv/linux/powerpc/powerpc64/nptl/libc.abilist
+++ sysdeps/unix/sysv/linux/powerpc/powerpc64/nptl/libc.abilist
@@ -81,6 +81,7 @@ GLIBC_2.16
 GLIBC_2.17
  GLIBC_2.17 A
  __ppc_get_timebase_freq F
+ __sendmmsg F
  clock_getcpuclockid F
  clock_getres F
  clock_gettime F
diff --git sysdeps/unix/sysv/linux/recvmmsg.c sysdeps/unix/sysv/linux/recvmmsg.c
index 32fc8df..782b933 100644
--- sysdeps/unix/sysv/linux/recvmmsg.c
+++ sysdeps/unix/sysv/linux/recvmmsg.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2010 Free Software Foundation, Inc.
+/* Copyright (C) 2010-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Andreas Schwab <schwab@redhat.com>, 2010.
 
@@ -26,8 +26,8 @@
 
 #ifdef __NR_recvmmsg
 int
-recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
-	  const struct timespec *tmo)
+__recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
+	    const struct timespec *tmo)
 {
   if (SINGLE_THREAD_P)
     return INLINE_SYSCALL (recvmmsg, 5, fd, vmessages, vlen, flags, tmo);
@@ -40,6 +40,9 @@ recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
 
   return result;
 }
+libc_hidden_def (__recvmmsg)
+
+weak_alias (__recvmmsg, recvmmsg)
 #elif defined __NR_socketcall
 # ifndef __ASSUME_RECVMMSG
 extern int __internal_recvmmsg (int fd, struct mmsghdr *vmessages,
@@ -50,8 +53,8 @@ extern int __internal_recvmmsg (int fd, struct mmsghdr *vmessages,
 static int have_recvmmsg;
 
 int
-recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
-	  const struct timespec *tmo)
+__recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
+	    const struct timespec *tmo)
 {
   if (__builtin_expect (have_recvmmsg >= 0, 1))
     {
@@ -84,16 +87,13 @@ recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
   __set_errno (ENOSYS);
   return -1;
 }
+libc_hidden_def (__recvmmsg)
+
+weak_alias (__recvmmsg, recvmmsg)
 # else
-/* When __ASSUME_RECVMMSG recvmmsg is defined in internal_recvmmsg.S.  */
+/* When __ASSUME_RECVMMSG, __recvmmsg and recvmmsg are defined in
+   internal_recvmmsg.S.  */
 # endif
 #else
-int
-recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
-	  const struct timespec *tmo)
-{
-  __set_errno (ENOSYS);
-  return -1;
-}
-stub_warning (recvmmsg)
+# include <socket/recvmmsg.c>
 #endif
diff --git sysdeps/unix/sysv/linux/s390/s390-32/nptl/libc.abilist sysdeps/unix/sysv/linux/s390/s390-32/nptl/libc.abilist
index d9914ff..7c9f7ed 100644
--- sysdeps/unix/sysv/linux/s390/s390-32/nptl/libc.abilist
+++ sysdeps/unix/sysv/linux/s390/s390-32/nptl/libc.abilist
@@ -1765,6 +1765,7 @@ GLIBC_2.16
  timespec_get F
 GLIBC_2.17
  GLIBC_2.17 A
+ __sendmmsg F
  clock_getcpuclockid F
  clock_getres F
  clock_gettime F
diff --git sysdeps/unix/sysv/linux/s390/s390-64/nptl/libc.abilist sysdeps/unix/sysv/linux/s390/s390-64/nptl/libc.abilist
index ef1ead3..f267284 100644
--- sysdeps/unix/sysv/linux/s390/s390-64/nptl/libc.abilist
+++ sysdeps/unix/sysv/linux/s390/s390-64/nptl/libc.abilist
@@ -86,6 +86,7 @@ GLIBC_2.16
  timespec_get F
 GLIBC_2.17
  GLIBC_2.17 A
+ __sendmmsg F
  clock_getcpuclockid F
  clock_getres F
  clock_gettime F
diff --git sysdeps/unix/sysv/linux/sendmmsg.c sysdeps/unix/sysv/linux/sendmmsg.c
index 0674419..606291a 100644
--- sysdeps/unix/sysv/linux/sendmmsg.c
+++ sysdeps/unix/sysv/linux/sendmmsg.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011 Free Software Foundation, Inc.
+/* Copyright (C) 2011-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
 
@@ -26,7 +26,7 @@
 
 #ifdef __NR_sendmmsg
 int
-sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
+__sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
 {
   if (SINGLE_THREAD_P)
     return INLINE_SYSCALL (sendmmsg, 4, fd, vmessages, vlen, flags);
@@ -39,6 +39,9 @@ sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
 
   return result;
 }
+libc_hidden_def (__sendmmsg)
+
+weak_alias (__sendmmsg, sendmmsg)
 #elif defined __NR_socketcall
 # ifndef __ASSUME_SENDMMSG
 extern int __internal_sendmmsg (int fd, struct mmsghdr *vmessages,
@@ -48,7 +51,7 @@ extern int __internal_sendmmsg (int fd, struct mmsghdr *vmessages,
 static int have_sendmmsg;
 
 int
-sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
+__sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
 {
   if (__builtin_expect (have_sendmmsg >= 0, 1))
     {
@@ -81,15 +84,12 @@ sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
   __set_errno (ENOSYS);
   return -1;
 }
+libc_hidden_def (__sendmmsg)
+
+weak_alias (__sendmmsg, sendmmsg)
 # else
 /* When __ASSUME_SENDMMSG sendmmsg is defined in internal_sendmmsg.S.  */
 # endif
 #else
-int
-sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
-{
-  __set_errno (ENOSYS);
-  return -1;
-}
-stub_warning (sendmmsg)
+# include <socket/sendmmsg.c>
 #endif
diff --git sysdeps/unix/sysv/linux/sh/nptl/libc.abilist sysdeps/unix/sysv/linux/sh/nptl/libc.abilist
index 733b550..fb57092 100644
--- sysdeps/unix/sysv/linux/sh/nptl/libc.abilist
+++ sysdeps/unix/sysv/linux/sh/nptl/libc.abilist
@@ -86,6 +86,7 @@ GLIBC_2.16
  timespec_get F
 GLIBC_2.17
  GLIBC_2.17 A
+ __sendmmsg F
  clock_getcpuclockid F
  clock_getres F
  clock_gettime F
diff --git sysdeps/unix/sysv/linux/sparc/sparc32/nptl/libc.abilist sysdeps/unix/sysv/linux/sparc/sparc32/nptl/libc.abilist
index 3a96ea8..b52edb8 100644
--- sysdeps/unix/sysv/linux/sparc/sparc32/nptl/libc.abilist
+++ sysdeps/unix/sysv/linux/sparc/sparc32/nptl/libc.abilist
@@ -1770,6 +1770,7 @@ GLIBC_2.16
  timespec_get F
 GLIBC_2.17
  GLIBC_2.17 A
+ __sendmmsg F
  clock_getcpuclockid F
  clock_getres F
  clock_gettime F
diff --git sysdeps/unix/sysv/linux/sparc/sparc64/nptl/libc.abilist sysdeps/unix/sysv/linux/sparc/sparc64/nptl/libc.abilist
index aa892b8..0d1082e 100644
--- sysdeps/unix/sysv/linux/sparc/sparc64/nptl/libc.abilist
+++ sysdeps/unix/sysv/linux/sparc/sparc64/nptl/libc.abilist
@@ -91,6 +91,7 @@ GLIBC_2.16
  timespec_get F
 GLIBC_2.17
  GLIBC_2.17 A
+ __sendmmsg F
  clock_getcpuclockid F
  clock_getres F
  clock_gettime F
diff --git sysdeps/unix/sysv/linux/x86_64/64/nptl/libc.abilist sysdeps/unix/sysv/linux/x86_64/64/nptl/libc.abilist
index a42d424..df0c33e 100644
--- sysdeps/unix/sysv/linux/x86_64/64/nptl/libc.abilist
+++ sysdeps/unix/sysv/linux/x86_64/64/nptl/libc.abilist
@@ -82,6 +82,7 @@ GLIBC_2.16
  timespec_get F
 GLIBC_2.17
  GLIBC_2.17 A
+ __sendmmsg F
  clock_getcpuclockid F
  clock_getres F
  clock_gettime F
diff --git sysdeps/unix/sysv/linux/x86_64/x32/nptl/libc.abilist sysdeps/unix/sysv/linux/x86_64/x32/nptl/libc.abilist
index 108b80f..e48ca2a 100644
--- sysdeps/unix/sysv/linux/x86_64/x32/nptl/libc.abilist
+++ sysdeps/unix/sysv/linux/x86_64/x32/nptl/libc.abilist
@@ -2080,6 +2080,7 @@ GLIBC_2.16
  xprt_unregister F
 GLIBC_2.17
  GLIBC_2.17 A
+ __sendmmsg F
  clock_getcpuclockid F
  clock_getres F
  clock_gettime F


GrÃÃe,
 Thomas

Attachment: pgp00000.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]