Commit a4f159ea authored by Philippe Gerum's avatar Philippe Gerum
Browse files

lib/cobalt: add sendmmsg(), recvmmsg() syscalls

parent fbf5f1be
......@@ -33,9 +33,17 @@ COBALT_DECL(int, socket(int protocol_family,
COBALT_DECL(ssize_t, recvmsg(int fd,
struct msghdr *msg, int flags));
COBALT_DECL(int, recvmmsg(int fd,
struct mmsghdr *msgvec, unsigned int vlen,
unsigned int flags, struct timespec *timeout));
COBALT_DECL(ssize_t, sendmsg(int fd,
const struct msghdr *msg, int flags));
COBALT_DECL(int, sendmmsg(int fd,
struct mmsghdr *msgvec, unsigned int vlen,
unsigned int flags));
COBALT_DECL(ssize_t, recvfrom(int fd, void *buf, size_t len, int flags,
struct sockaddr *from, socklen_t *fromlen));
......
......@@ -59,7 +59,9 @@
--wrap read
--wrap write
--wrap recvmsg
--wrap recvmmsg
--wrap sendmsg
--wrap sendmmsg
--wrap recvfrom
--wrap sendto
--wrap recv
......
......@@ -227,6 +227,23 @@ COBALT_IMPL(ssize_t, recvmsg, (int fd, struct msghdr *msg, int flags))
return __STD(recvmsg(fd, msg, flags));
}
COBALT_IMPL(int, recvmmsg, (int fd, struct mmsghdr *msgvec, unsigned int vlen,
unsigned int flags, struct timespec *timeout))
{
int ret, oldtype;
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
ret = XENOMAI_SYSCALL5(sc_cobalt_recvmmsg, fd, msgvec, vlen, flags, timeout);
pthread_setcanceltype(oldtype, NULL);
if (ret != -EBADF && ret != -ENOSYS)
return set_errno(ret);
return __STD(recvmmsg(fd, msgvec, vlen, flags, timeout));
}
static ssize_t do_sendmsg(int fd, const struct msghdr *msg, int flags)
{
int ret, oldtype;
......@@ -251,6 +268,23 @@ COBALT_IMPL(ssize_t, sendmsg, (int fd, const struct msghdr *msg, int flags))
return __STD(sendmsg(fd, msg, flags));
}
COBALT_IMPL(int, sendmmsg, (int fd, struct mmsghdr *msgvec,
unsigned int vlen, unsigned int flags))
{
int ret, oldtype;
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
ret = XENOMAI_SYSCALL4(sc_cobalt_sendmmsg, fd, msgvec, vlen, flags);
pthread_setcanceltype(oldtype, NULL);
if (ret != -EBADF && ret != -ENOSYS)
return set_errno(ret);
return __STD(sendmmsg(fd, msgvec, vlen, flags));
}
COBALT_IMPL(ssize_t, recvfrom, (int fd, void *buf, size_t len, int flags,
struct sockaddr *from, socklen_t *fromlen))
{
......
......@@ -256,12 +256,26 @@ ssize_t __real_recvmsg(int fd, struct msghdr * msg, int flags)
return recvmsg(fd, msg, flags);
}
__weak
int __real_recvmmsg(int fd, struct mmsghdr *msgvec, unsigned int vlen,
unsigned int flags, struct timespec *timeout)
{
return recvmmsg(fd, msgvec, vlen, flags, timeout);
}
__weak
ssize_t __real_sendmsg(int fd, const struct msghdr * msg, int flags)
{
return sendmsg(fd, msg, flags);
}
__weak
int __real_sendmmsg(int fd, struct mmsghdr *msgvec, unsigned int vlen,
unsigned int flags)
{
return sendmmsg(fd, msgvec, vlen, flags);
}
__weak
ssize_t __real_recvfrom(int fd, void *buf, size_t len, int flags,
struct sockaddr * from, socklen_t * fromlen)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment