aboutsummaryrefslogtreecommitdiff
path: root/socket
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@codesourcery.com>2012-11-03 18:29:46 +0100
committerThomas Schwinge <thomas@codesourcery.com>2012-11-20 19:26:04 +0100
commit123be9deda8eb24ef15fb889248984e6d23bb8b4 (patch)
tree8d875402831e2eb1923b9d3ef8d88bcee14ad2c6 /socket
parentcf9a5d186154b1ad4a8459fafa135dcd822e5f3b (diff)
downloadglibc-123be9deda8eb24ef15fb889248984e6d23bb8b4.zip
glibc-123be9deda8eb24ef15fb889248984e6d23bb8b4.tar.gz
glibc-123be9deda8eb24ef15fb889248984e6d23bb8b4.tar.bz2
Add recvmmsg and sendmmsg to the generic glibc API.
Diffstat (limited to 'socket')
-rw-r--r--socket/Makefile2
-rw-r--r--socket/Versions6
-rw-r--r--socket/recvmmsg.c31
-rw-r--r--socket/sendmmsg.c32
-rw-r--r--socket/sys/socket.h31
5 files changed, 101 insertions, 1 deletions
diff --git a/socket/Makefile b/socket/Makefile
index e3a90b8..6037f3f 100644
--- a/socket/Makefile
+++ b/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 a/socket/Versions b/socket/Versions
index 7a96b1e..dcad329 100644
--- a/socket/Versions
+++ b/socket/Versions
@@ -34,4 +34,10 @@ libc {
GLIBC_2.10 {
accept4;
}
+ GLIBC_2.17 {
+ recvmmsg; sendmmsg;
+ }
+ GLIBC_PRIVATE {
+ __sendmmsg;
+ }
}
diff --git a/socket/recvmmsg.c b/socket/recvmmsg.c
new file mode 100644
index 0000000..2d6d474
--- /dev/null
+++ b/socket/recvmmsg.c
@@ -0,0 +1,31 @@
+/* Receive multiple messages on a socket. Stub version.
+ Copyright (C) 2010-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;
+}
+stub_warning (recvmmsg)
diff --git a/socket/sendmmsg.c b/socket/sendmmsg.c
new file mode 100644
index 0000000..ed93f49
--- /dev/null
+++ b/socket/sendmmsg.c
@@ -0,0 +1,32 @@
+/* Send multiple messages on a socket. Stub version.
+ Copyright (C) 2011-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 a/socket/sys/socket.h b/socket/sys/socket.h
index 787c2b9..3810a37 100644
--- a/socket/sys/socket.h
+++ b/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