summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2020-05-11 19:12:20 -0700
committerOri Bernstein <ori@eigenstate.org>2020-05-11 19:12:20 -0700
commit552823815f7c52c16111045b638ba8bab322e7ac (patch)
tree92466c2c0bfb0d487dab21c091f1434ab2074f28
parent690ab7aa8e6c56a4ae8a2bd5bce58d1df681234e (diff)
downloadmc-master.tar.gz
add OSX recvfrom, fix UDP announce (thanks Int21h)HEADmaster
system call to libsys for OS X and also made a minor edit to announcesock so it would work with UDP.
-rw-r--r--lib/std/listen+posixy.myr6
-rw-r--r--lib/sys/sys+osx-x64.myr2
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/std/listen+posixy.myr b/lib/std/listen+posixy.myr
index e8018e9..1a792aa 100644
--- a/lib/std/listen+posixy.myr
+++ b/lib/std/listen+posixy.myr
@@ -91,8 +91,10 @@ const announcesock = {proto, str
if sys.bind(sock, sa, sz) < 0
-> `Err "failed to bind socket"
;;
- if sys.listen((sock : sys.fd), 10) < 0
- -> `Err "unable to listen on socket"
+ if proto == sys.Sockstream
+ if sys.listen((sock : sys.fd), 10) < 0
+ -> `Err "unable to listen on socket"
+ ;;
;;
-> `Ok mk([.lfd=(sock : fd)])
}
diff --git a/lib/sys/sys+osx-x64.myr b/lib/sys/sys+osx-x64.myr
index 0597074..a926156 100644
--- a/lib/sys/sys+osx-x64.myr
+++ b/lib/sys/sys+osx-x64.myr
@@ -813,6 +813,7 @@ pkg sys =
const bind : (sock : fd, addr : sockaddr#, len : size -> int)
const setsockopt : (sock : fd, lev : sockproto, opt : sockopt, val : void#, len : size -> int)
const getsockopt : (sock : fd, lev : sockproto, opt : sockopt, val : void#, len : size# -> int)
+ const recvfrom : (sock : fd, buf : byte[:], flags : int, addr : sockaddr#, addr_len : size# -> int)
/* memory mapping */
const munmap : (addr:byte#, len:size -> int64)
@@ -1005,6 +1006,7 @@ const listen = {sock, backlog; -> (syscall(Syslisten, a(sock), a(backlog)) : int
const bind = {sock, addr, len; -> (syscall(Sysbind, a(sock), a(addr), a(len)) : int)}
const setsockopt = {sock, lev, opt, val, len; -> (syscall(Syssetsockopt, a(sock), a(lev), a(opt), a(val), a(len)) : int)}
const getsockopt = {sock, lev, opt, val, len; -> (syscall(Syssetsockopt, a(sock), a(lev), a(opt), a(val), a(len)) : int)}
+const recvfrom = {sock, buf, flags, addr, addr_len; -> (syscall(Sysrecvfrom, a(sock), (buf : byte#), a(buf.len), a(flags), a(addr), a(addr_len)) : int)}
/* memory management */
const munmap = {addr, len; -> syscall(Sysmunmap, a(addr), a(len))}