Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(550)

Side by Side Diff: fusl/src/network/sendmmsg.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fusl/src/network/send.c ('k') | fusl/src/network/sendmsg.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #define _GNU_SOURCE
2 #include <sys/socket.h>
3 #include <limits.h>
4 #include <errno.h>
5 #include "syscall.h"
6
7 int sendmmsg(int fd, struct mmsghdr *msgvec, unsigned int vlen, unsigned int fla gs)
8 {
9 #if LONG_MAX > INT_MAX
10 /* Can't use the syscall directly because the kernel has the wrong
11 * idea for the types of msg_iovlen, msg_controllen, and cmsg_len,
12 * and the cmsg blocks cannot be modified in-place. */
13 int i;
14 if (vlen > IOV_MAX) vlen = IOV_MAX; /* This matches the kernel. */
15 if (!vlen) return 0;
16 for (i=0; i<vlen; i++) {
17 /* As an unfortunate inconsistency, the sendmmsg API uses
18 * unsigned int for the resulting msg_len, despite sendmsg
19 * returning ssize_t. However Linux limits the total bytes
20 * sent by sendmsg to INT_MAX, so the assignment is safe. */
21 ssize_t r = sendmsg(fd, &msgvec[i].msg_hdr, flags);
22 if (r < 0) goto error;
23 msgvec[i].msg_len = r;
24 }
25 error:
26 return i ? i : -1;
27 #else
28 return syscall_cp(SYS_sendmmsg, fd, msgvec, vlen, flags);
29 #endif
30 }
OLDNEW
« no previous file with comments | « fusl/src/network/send.c ('k') | fusl/src/network/sendmsg.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698