summaryrefslogtreecommitdiff
path: root/lib/sys
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2017-06-25 00:22:48 -0700
committerOri Bernstein <ori@eigenstate.org>2017-06-25 01:08:54 -0700
commit71af8b2acb1e7eefa2101f0074e4fe0a631a6220 (patch)
tree0ec7f54c256f52326d3a0818c5caea6f218b0e4c /lib/sys
parentfb8cbb2339df748749c588b20f787e2973c2fd36 (diff)
downloadmc-71af8b2acb1e7eefa2101f0074e4fe0a631a6220.tar.gz
Add sendmsg/recvmsg for linux-x64
Also, make sockproto int32 so that the level field in cmsghdr has the correct size.
Diffstat (limited to 'lib/sys')
-rw-r--r--lib/sys/sys+linux-x64.myr43
1 files changed, 42 insertions, 1 deletions
diff --git a/lib/sys/sys+linux-x64.myr b/lib/sys/sys+linux-x64.myr
index 4594a04..2fd2392 100644
--- a/lib/sys/sys+linux-x64.myr
+++ b/lib/sys/sys+linux-x64.myr
@@ -17,9 +17,11 @@ pkg sys =
type mprot = int64 /* memory protection */
type mopt = int64 /* memory mapping options */
type socktype = int64 /* socket type */
- type sockproto = int64 /* socket protocol */
+ type sockproto = int32 /* socket protocol */
type sockfam = uint16 /* socket family */
type sockopt = int64
+ type msgflags = uint32
+ type cmsgtype = uint32
type epollflags = uint32
type epollop = uint32
@@ -154,6 +156,28 @@ pkg sys =
revents : pollevt
;;
+ type iovec = struct
+ base : byte#
+ len : uint64
+ ;;
+
+ type msghdr = struct
+ name : sockaddr#
+ namelen : int32
+ iov : iovec#
+ iovlen : uint64
+ control : byte#
+ controllen : uint64
+ flags : msgflags
+ ;;
+
+ type cmsghdr = struct
+ len : uint64
+ level : sockproto
+ cmtype : cmsgtype
+ data : byte[...]
+ ;;
+
/* clone options */
const Clonesignal : cloneopt = 0xff
const Clonevm : cloneopt = 0x100
@@ -273,6 +297,19 @@ pkg sys =
const Ipproto_udp : sockproto = 17
const Ipproto_raw : sockproto = 255
+ /* message flags */
+ const Msgoob : msgflags = 0x0001
+ const Msgpeek : msgflags = 0x0002
+ const Msgdontroute : msgflags = 0x0004
+ const Msgctrunc : msgflags = 0x0008
+ const Msgtrunc : msgflags = 0x0020
+ const Msgeor : msgflags = 0x0080
+ const Msgwaitall : msgflags = 0x0100
+ const Msgnosignal : msgflags = 0x4000
+
+ /* ancillary data */
+ const Scmrights : cmsgtype = 1
+
/* epoll flags */
const Epollcloexec : epollflags = 0o2000000
@@ -747,6 +784,8 @@ pkg sys =
const getdents64 : (fd:fd, buf : byte[:] -> int64)
const chdir : (p : byte[:] -> int64)
const getcwd : (buf : byte[:] -> int64)
+ const sendmsg : (fd:fd, msg:msghdr#, flags:msgflags -> int64)
+ const recvmsg : (fd:fd, msg:msghdr#, flags:msgflags -> int64)
/* signals */
const sigaction : (sig : signo, act : sigaction#, oact : sigaction# -> int)
@@ -877,6 +916,8 @@ generic ioctl = {fd, req, arg; -> (syscall(Sysioctl, a(fd), a(req), a(arg)) : in
const getdents64 = {fd, buf; -> syscall(Sysgetdents64, a(fd), (buf : byte#), a(buf.len))}
const chdir = {dir; -> syscall(Syschdir, cstring(dir))}
const getcwd = {buf; -> syscall(Sysgetcwd, a(buf), a(buf.len))}
+const sendmsg = {fd, msg, flags; -> syscall(Syssendmsg, a(fd), msg, a(flags))}
+const recvmsg = {fd, msg, flags; -> syscall(Sysrecvmsg, a(fd), msg, a(flags))}
/* file stuff */
const pipe = {fds; -> syscall(Syspipe, a(fds))}