summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--6/gengas.c3
-rwxr-xr-xconfigure2
-rw-r--r--lib/std/alloc.myr2
-rw-r--r--lib/std/syswrap+posixy.myr5
-rw-r--r--lib/sys/bld.sub11
-rw-r--r--lib/sys/sys+freebsd-x64.myr1
-rw-r--r--lib/sys/sys+openbsd-x64.myr34
-rw-r--r--lib/thread/bld.sub4
-rw-r--r--lib/thread/spawn+openbsd.myr12
9 files changed, 66 insertions, 8 deletions
diff --git a/6/gengas.c b/6/gengas.c
index 04a774b..a591d3c 100644
--- a/6/gengas.c
+++ b/6/gengas.c
@@ -373,7 +373,8 @@ static void gentype(FILE *fd, Type *ty)
ty->isemitted = 1;
b = tydescblob(ty);
- b->iscomdat = 1;
+ if (b->isglobl)
+ b->iscomdat = 1;
writeblob(fd, b);
blobfree(b);
}
diff --git a/configure b/configure
index 543a4e9..f069ba4 100755
--- a/configure
+++ b/configure
@@ -83,7 +83,7 @@ case $OS in
;;
*OpenBSD*)
echo '#define Symprefix ""' >> config.h
- echo '#define Defaultasm Gnugas' >> config.h
+ echo '#define Defaultasm Gnugaself' >> config.h
echo 'export SYS=openbsd' >> config.mk
echo 'const Linkcmd = ["ld", "-static", "-nopie", "-o"]' >> mbld/config.myr
echo 'const Sys = "OpenBSD"' >> mbld/config.myr
diff --git a/lib/std/alloc.myr b/lib/std/alloc.myr
index 00d36b6..65053f3 100644
--- a/lib/std/alloc.myr
+++ b/lib/std/alloc.myr
@@ -289,7 +289,7 @@ const mkslab = {bkt
*/
p = getmem(Slabsz*2)
if p == Failmem
- die("Unable to mmap")
+ die("Unable to get memory")
;;
s = align(p castto(size), Slabsz) castto(slab#)
diff --git a/lib/std/syswrap+posixy.myr b/lib/std/syswrap+posixy.myr
index 668ebc7..13ab684 100644
--- a/lib/std/syswrap+posixy.myr
+++ b/lib/std/syswrap+posixy.myr
@@ -105,7 +105,10 @@ const execv = {cmd, args; -> sys.execv(cmd, args) castto(errno)}
const execve = {cmd, args, env; -> sys.execve(cmd, args, env) castto(errno)}
/* memory stuff */
-const getmem = {sz; -> sys.mmap(0 castto(byte#), sz castto(sys.size), sys.Mprotrw, sys.Mpriv | sys.Manon, -1, 0)}
+const getmem = {sz;
+ sz = (sz + 4095) & ~4095
+ -> sys.mmap(0 castto(byte#), sz castto(sys.size), sys.Mprotrw, sys.Mpriv | sys.Manon, -1, 0)
+}
const freemem = {p, sz; sys.munmap(p, sz castto(sys.size))}
const curtime = {
var tm, sec, nsec
diff --git a/lib/sys/bld.sub b/lib/sys/bld.sub
index 866152d..a6babf2 100644
--- a/lib/sys/bld.sub
+++ b/lib/sys/bld.sub
@@ -1,22 +1,29 @@
lib sys =
+ systypes.myr
+
sys+freebsd-x64.myr
sys+linux-x64.myr
sys+osx-x64.myr
+ sys+openbsd-x64.myr
sys+plan9-x64.myr
+
syscall+freebsd-x64.s
syscall+linux-x64.s
syscall+osx-x64.s
syscall+plan9-x64.s
+ syscall+openbsd-x64.s
+
syserrno+linux.myr
syserrno+osx.myr
syserrno+freebsd.myr
- systypes.myr
+ syserrno+openbsd.myr
+
ifreq+freebsd.myr
ifreq+linux.myr
ifreq+osx.myr
ifreq+openbsd.myr
ifreq+plan9.myr
- ifreq.myr # dummy file: plan9 doesn't have ifreq
+
util+plan9-x64.s
util+posixy-x64.s
;;
diff --git a/lib/sys/sys+freebsd-x64.myr b/lib/sys/sys+freebsd-x64.myr
index 1362282..f664117 100644
--- a/lib/sys/sys+freebsd-x64.myr
+++ b/lib/sys/sys+freebsd-x64.myr
@@ -256,7 +256,6 @@ pkg sys =
const Sobintime : sockopt = 0x2000 /* timestamp received dgram traffic */
const Sonooffload : sockopt = 0x4000 /* socket cannot be offloaded */
const Sonoddp : sockopt = 0x8000 /* disable direct data placement */
-
/* network protocols */
const Ipproto_ip : sockproto = 0
diff --git a/lib/sys/sys+openbsd-x64.myr b/lib/sys/sys+openbsd-x64.myr
index 018c1d5..3e97509 100644
--- a/lib/sys/sys+openbsd-x64.myr
+++ b/lib/sys/sys+openbsd-x64.myr
@@ -10,6 +10,7 @@ pkg sys =
type mopt = int64 /* memory mapping options */
type socktype = int64 /* socket type */
type sockproto = int64 /* socket protocol */
+ type sockopt = int32 /* socket option */
type sockfam = uint8 /* socket family */
type filemode = uint32
type filetype = uint8
@@ -218,6 +219,32 @@ pkg sys =
const Sockraw : socktype = 3
const Sockrdm : socktype = 4
const Sockseqpacket : socktype = 5
+ const Solsock : socktype = 0xffff
+
+ const Sodebug : sockopt = 0x0001 /* turn on debugging info recording */
+ const Soacceptconn : sockopt = 0x0002 /* socket has had listen() */
+ const Soreuseaddr : sockopt = 0x0004 /* allow local address reuse */
+ const Sokeepalive : sockopt = 0x0008 /* keep connections alive */
+ const Sodontroute : sockopt = 0x0010 /* just use interface addresses */
+ const Sobroadcast : sockopt = 0x0020 /* permit sending of broadcast msgs */
+ const Souseloopback : sockopt = 0x0040 /* bypass hardware when possible */
+ const Solinger : sockopt = 0x0080 /* linger on close if data present */
+ const Sooobinline : sockopt = 0x0100 /* leave received OOB data in line */
+ const Soreuseport : sockopt = 0x0200 /* allow local address & port reuse */
+ const Sotimestamp : sockopt = 0x0800 /* timestamp received dgram traffic */
+ const Sobindany : sockopt = 0x1000 /* allow bind to any address */
+ const Sosndbuf : sockopt = 0x1001 /* send buffer size */
+ const Sorcvbuf : sockopt = 0x1002 /* receive buffer size */
+ const Sosndlowat : sockopt = 0x1003 /* send low-water mark */
+ const Sorcvlowat : sockopt = 0x1004 /* receive low-water mark */
+ const Sosndtimeo : sockopt = 0x1005 /* send timeout */
+ const Sorcvtimeo : sockopt = 0x1006 /* receive timeout */
+ const Soerror : sockopt = 0x1007 /* get error status and clear */
+ const Sotype : sockopt = 0x1008 /* get socket type */
+ const Sonetproc : sockopt = 0x1020 /* multiplex; network processing */
+ const Sortable : sockopt = 0x1021 /* routing table to be used */
+ const Sopeercred : sockopt = 0x1022 /* get connect-time credentials */
+ const Sosplice : sockopt = 0x1023 /* splice data to other socket */
/* network protocols */
const Ipproto_ip : sockproto = 0
@@ -537,6 +564,8 @@ pkg sys =
const accept : (sock : fd, addr : sockaddr#, len : size# -> fd)
const listen : (sock : fd, backlog : int -> int)
const bind : (sock : fd, addr : sockaddr#, len : size -> int)
+ const setsockopt : (sock : fd, lev : socktype, opt : sockopt, val : void#, len : size -> int)
+ const getsockopt : (sock : fd, lev : socktype, opt : sockopt, val : void#, len : size# -> int)
/* memory mapping */
const munmap : (addr:byte#, len:size -> int64)
@@ -651,11 +680,14 @@ const connect = {sock, addr, len; -> syscall(Sysconnect, a(sock), a(addr), a(len
const accept = {sock, addr, len; -> syscall(Sysaccept, a(sock), a(addr), a(len)) castto(fd)}
const listen = {sock, backlog; -> syscall(Syslisten, a(sock), a(backlog)) castto(int)}
const bind = {sock, addr, len; -> syscall(Sysbind, a(sock), a(addr), a(len)) castto(int)}
+const setsockopt = {sock, lev, opt, val, len; -> syscall(Syssetsockopt, a(sock), a(lev), a(opt), a(val), a(len)) castto(int)}
+const getsockopt = {sock, lev, opt, val, len; -> syscall(Syssetsockopt, a(sock), a(lev), a(opt), a(val), a(len)) castto(int)}
/* memory management */
const munmap = {addr, len; -> syscall(Sysmunmap, a(addr), a(len))}
const mmap = {addr, len, prot, flags, fd, off;
- -> syscall(Sysmmap, a(addr), a(len), a(prot), a(flags), a(fd), a(off)) castto(byte#)}
+ -> syscall(Sysmmap, a(addr), a(len), a(prot), a(flags), a(fd), a(off)) castto(byte#)
+}
/* time */
const clock_getres = {clk, ts; -> syscall(Sysclock_getres, clockid(clk), a(ts)) castto(int32)}
diff --git a/lib/thread/bld.sub b/lib/thread/bld.sub
index 378e17f..3d0ce27 100644
--- a/lib/thread/bld.sub
+++ b/lib/thread/bld.sub
@@ -25,6 +25,10 @@ lib thread =
spawn+plan9.myr
atomic-impl+plan9-x64.s
+ # openbsd impl of thread primitives
+ spawn+openbsd.myr
+
+
atomic-impl+x64.s
atomic.myr
diff --git a/lib/thread/spawn+openbsd.myr b/lib/thread/spawn+openbsd.myr
new file mode 100644
index 0000000..92cca94
--- /dev/null
+++ b/lib/thread/spawn+openbsd.myr
@@ -0,0 +1,12 @@
+use std
+
+pkg thread =
+ type tid = uint64
+
+ const spawn : (fn : (-> void) -> std.result(tid, byte[:]))
+;;
+
+const spawn = {fn;
+ std.die("threads not supported yet on openbsd\n")
+ -> `std.Fail "not supported"
+}