github.com/afumu/libc@v0.0.6/musl/src/network/sendmsg.c (about) 1 #include <sys/socket.h> 2 #include <limits.h> 3 #include <string.h> 4 #include <errno.h> 5 #include "syscall.h" 6 7 ssize_t sendmsg(int fd, const struct msghdr *msg, int flags) 8 { 9 #if LONG_MAX > INT_MAX 10 struct msghdr h; 11 struct cmsghdr chbuf[1024/sizeof(struct cmsghdr)+1], *c; 12 if (msg) { 13 h = *msg; 14 h.__pad1 = h.__pad2 = 0; 15 msg = &h; 16 if (h.msg_controllen) { 17 if (h.msg_controllen > 1024) { 18 errno = ENOMEM; 19 return -1; 20 } 21 memcpy(chbuf, h.msg_control, h.msg_controllen); 22 h.msg_control = chbuf; 23 for (c=CMSG_FIRSTHDR(&h); c; c=CMSG_NXTHDR(&h,c)) 24 c->__pad1 = 0; 25 } 26 } 27 #endif 28 return socketcall_cp(sendmsg, fd, msg, flags, 0, 0, 0); 29 }