summaryrefslogtreecommitdiff
path: root/libc/inet/socketcalls.c
diff options
context:
space:
mode:
authorGuo Ren <ren_guo@c-sky.com>2017-09-27 13:31:35 +0800
committerWaldemar Brodkorb <wbx@uclibc-ng.org>2017-10-01 08:54:33 +0200
commit6e15fafa20066634a58d412b259b117a47ca46d1 (patch)
tree78e2bfabc8a9b13926c93bf12d1e35aba14abe78 /libc/inet/socketcalls.c
parent7cfd2112acbc7a9dfcd9f8a23e550672934a2545 (diff)
recvmmsg/sendmmsg: add recvmmsg sendmmsg support.
The recvmmsg and sendmmsg is very important for UDP stream application. If we only use recvmsg for UDP stream, it will only copy one mtu size of data in a syscall. And recvmmsg copy as many as you want in a syscall. So recvmmsg is more efficient,and some applications will depends on the recvmmsg and sendmmsg, eg: UDP media stream player. Signed-off-by: Guo Ren <ren_guo@c-sky.com>
Diffstat (limited to 'libc/inet/socketcalls.c')
-rw-r--r--libc/inet/socketcalls.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/libc/inet/socketcalls.c b/libc/inet/socketcalls.c
index 1fef8100b..cb281407e 100644
--- a/libc/inet/socketcalls.c
+++ b/libc/inet/socketcalls.c
@@ -29,6 +29,8 @@
#define SYS_SENDMSG 16
#define SYS_RECVMSG 17
#define SYS_ACCEPT4 18
+#define SYS_RECVMMSG 19
+#define SYS_SENDMMSG 20
#endif
/* exposed on x86 since Linux commit 9dea5dc921b5f4045a18c63eb92e84dc274d17eb */
@@ -283,6 +285,30 @@ CANCELLABLE_SYSCALL(ssize_t, recvmsg, (int sockfd, struct msghdr *msg, int flags
lt_libc_hidden(recvmsg)
#endif
+#ifdef L_recvmmsg
+static ssize_t __NC(recvmmsg)(int sockfd, struct mmsghdr *msg, size_t vlen,
+ int flags, struct timespec *tmo)
+{
+# ifdef __NR_recvmmsg
+ return (ssize_t)INLINE_SYSCALL(recvmmsg, 5, sockfd, msg, vlen, flags, tmo);
+# else
+ unsigned long args[5];
+
+ args[0] = sockfd;
+ args[1] = (unsigned long) msg;
+ args[2] = vlen;
+ args[3] = flags;
+ args[4] = (unsigned long) tmo;
+ return (ssize_t)__socketcall(SYS_RECVMMSG, args);
+# endif
+}
+CANCELLABLE_SYSCALL(ssize_t, recvmmsg,
+ (int sockfd, struct mmsghdr *msg, size_t vlen, int flags,
+ struct timespec *tmo),
+ (sockfd, msg, vlen, flags, tmo))
+lt_libc_hidden(recvmmsg)
+#endif
+
#ifdef L_send
static ssize_t __NC(send)(int sockfd, const void *buffer, size_t len, int flags)
{
@@ -324,6 +350,28 @@ CANCELLABLE_SYSCALL(ssize_t, sendmsg, (int sockfd, const struct msghdr *msg, int
lt_libc_hidden(sendmsg)
#endif
+#ifdef L_sendmmsg
+static ssize_t __NC(sendmmsg)(int sockfd, struct mmsghdr *msg, size_t vlen,
+ int flags)
+{
+# ifdef __NR_sendmmsg
+ return (ssize_t)INLINE_SYSCALL(sendmmsg, 4, sockfd, msg, vlen, flags);
+# else
+ unsigned long args[4];
+
+ args[0] = sockfd;
+ args[1] = (unsigned long) msg;
+ args[2] = vlen;
+ args[3] = flags;
+ return (ssize_t)__socketcall(SYS_SENDMMSG, args);
+# endif
+}
+CANCELLABLE_SYSCALL(ssize_t, sendmmsg,
+ (int sockfd, struct mmsghdr *msg, size_t vlen, int flags),
+ (sockfd, msg, vlen, flags))
+lt_libc_hidden(sendmmsg)
+#endif
+
#ifdef L_sendto
ssize_t __NC(sendto)(int sockfd, const void *buffer, size_t len, int flags,
const struct sockaddr *to, socklen_t tolen)