ref: 765ff439ba6b29b36c6df8ea3923fac9f5e39eaf
parent: 37423477a77f0b24b85acc6af52aa460570921a6
author: Ori Bernstein <ori@eigenstate.org>
date: Sat May 14 10:53:06 EDT 2016
Regenerate builds for OpenBSD. And patch up libstd to matcht .
--- a/lib/std/syswrap-ss+openbsd.myr
+++ b/lib/std/syswrap-ss+openbsd.myr
@@ -5,7 +5,9 @@
use "die.use"
pkg std =
+ const nanosleep : (nsecs : uint64 -> errno)
$noret const exit : (status:int -> void)
+
pkglocal const bgetcwd : (buf : byte[:] -> errno)
;;
@@ -14,3 +16,15 @@
const bgetcwd = {buf
-> (sys.__getcwd(buf) - 1) castto(errno)
}
+
+const nanosleep = {nsecs
+ var req, rem
+ var s, ns
+
+ s = nsecs / 1_000_000_000
+ ns = nsecs % 1_000_000_000
+ req = [.sec = s, .nsec = ns]
+
+ -> sys.nanosleep(&req, &rem) castto(errno)
+}
+
--- a/lib/thread/bld.sub
+++ b/lib/thread/bld.sub
@@ -1,6 +1,7 @@
lib thread =
common.myr
- hookstd.myr # install thread hooks
+ hookstd.myr # install thread hooks
+ mutex.myr # fallback, for unimplemented platforms
# linux impl of basic thread primitives
#condvar+linux.myr
@@ -16,7 +17,6 @@
# osx impl of thread primitives
#condvar+osx.myr
- mutex+osx.myr
spawn+osx.myr
start+osx-x64.s
--- a/lib/thread/mutex+osx.myr
+++ /dev/null
@@ -1,65 +1,0 @@
-use std
-use sys
-
-
-use "atomic.use"
-use "common.use"
-
-pkg thread =
- type mutex = struct
- _state : uint32
- ;;
-
- const mkmtx : (-> mutex)
- const mtxlock : (mtx : mutex# -> void)
- const mtxtrylock : (mtx : mutex# -> bool)
- const mtxunlock : (mtx : mutex# -> void)
-;;
-
-const mkmtx = {
- -> [._state = 0]
-}
-
-/* a shitty spinlock */
-const mtxlock = {mtx
- /* first fast */
- for var i = 0; i < 1000; i++
- if xcas(&mtx._state, 0, 1) == 0
- -> void
- ;;
- std.nanosleep(0)
- ;;
-
- /* then slower */
- for var i = 0; i < 1000; i++
- if xcas(&mtx._state, 0, 1) == 0
- -> void
- ;;
- std.nanosleep(10_000) /* 10 us */
- ;;
-
- /* even slower */
- for var i = 0; i < 1000; i++
- if xcas(&mtx._state, 0, 1) == 0
- -> void
- ;;
- std.nanosleep(100_000) /* 100 us */
- ;;
-
- /* I'm rip van winkle! */
- while true
- if xcas(&mtx._state, 0, 1) == 0
- -> void
- ;;
- std.nanosleep(1000_000) /* 1 ms */
- ;;
-}
-
-const mtxtrylock = {mtx
- -> xcas(&mtx._state, 0, 1) == 0
-}
-
-
-const mtxunlock = {mtx
- xset(&mtx._state, 0)
-}
--- /dev/null
+++ b/lib/thread/mutex.myr
@@ -1,0 +1,65 @@
+use std
+use sys
+
+
+use "atomic.use"
+use "common.use"
+
+pkg thread =
+ type mutex = struct
+ _state : uint32
+ ;;
+
+ const mkmtx : (-> mutex)
+ const mtxlock : (mtx : mutex# -> void)
+ const mtxtrylock : (mtx : mutex# -> bool)
+ const mtxunlock : (mtx : mutex# -> void)
+;;
+
+const mkmtx = {
+ -> [._state = 0]
+}
+
+/* a shitty spinlock */
+const mtxlock = {mtx
+ /* first fast */
+ for var i = 0; i < 1000; i++
+ if xcas(&mtx._state, 0, 1) == 0
+ -> void
+ ;;
+ std.nanosleep(0)
+ ;;
+
+ /* then slower */
+ for var i = 0; i < 1000; i++
+ if xcas(&mtx._state, 0, 1) == 0
+ -> void
+ ;;
+ std.nanosleep(10_000) /* 10 us */
+ ;;
+
+ /* even slower */
+ for var i = 0; i < 1000; i++
+ if xcas(&mtx._state, 0, 1) == 0
+ -> void
+ ;;
+ std.nanosleep(100_000) /* 100 us */
+ ;;
+
+ /* I'm rip van winkle! */
+ while true
+ if xcas(&mtx._state, 0, 1) == 0
+ -> void
+ ;;
+ std.nanosleep(1000_000) /* 1 ms */
+ ;;
+}
+
+const mtxtrylock = {mtx
+ -> xcas(&mtx._state, 0, 1) == 0
+}
+
+
+const mtxunlock = {mtx
+ xset(&mtx._state, 0)
+}
--- a/mk/bootstrap/bootstrap+OpenBSD-amd64.sh
+++ b/mk/bootstrap/bootstrap+OpenBSD-amd64.sh
@@ -9,7 +9,7 @@
echo $pwd/6/6m ifreq+openbsd.myr && $pwd/6/6m ifreq+openbsd.myr &&\
echo as -g -o util.o util+posixy-x64.s && as -g -o util.o util+posixy-x64.s &&\
echo as -g -o syscall.o syscall+openbsd-x64.s && as -g -o syscall.o syscall+openbsd-x64.s &&\
-echo $pwd/muse/muse -o sys ifreq.use systypes.use syserrno.use sys.use && $pwd/muse/muse -o sys ifreq.use systypes.use syserrno.use sys.use &&\
+echo $pwd/muse/muse -o libsys.use -p sys ifreq.use systypes.use syserrno.use sys.use && $pwd/muse/muse -o libsys.use -p sys ifreq.use systypes.use syserrno.use sys.use &&\
echo ar -rcs libsys.a util.o syscall.o ifreq.o systypes.o syserrno.o sys.o && ar -rcs libsys.a util.o syscall.o ifreq.o systypes.o syserrno.o sys.o &&\
echo cd $pwd/lib/std && cd $pwd/lib/std &&\
echo $pwd/6/6m -I ../sys -I . types.myr && $pwd/6/6m -I ../sys -I . types.myr &&\
@@ -92,7 +92,7 @@
echo $pwd/6/6m -I ../sys -I . swap.myr && $pwd/6/6m -I ../sys -I . swap.myr &&\
echo $pwd/6/6m -I ../sys -I . dial+posixy.myr && $pwd/6/6m -I ../sys -I . dial+posixy.myr &&\
echo as -g -o memops-impl.o memops-impl+posixy-x64.s && as -g -o memops-impl.o memops-impl+posixy-x64.s &&\
-echo $pwd/muse/muse -o std fmtfuncs.use fmt.use try.use pathjoin.use strjoin.use sljoin.use slpush.use strstrip.use htab.use now.use getcwd.use rand.use syswrap-ss.use slurp.use varargs.use listen.use strbuf.use clear.use slput.use strsplit.use introspect.use mktemp.use alloc.use optparse.use memops.use fltbits.use striter.use sldup.use fltfmt.use extremum.use option.use errno.use wait.use slcp.use writeall.use putint.use consts.use syswrap.use readall.use sort.use blat.use diriter.use mk.use swap.use hassuffix.use execvp.use ipparse.use types.use slpop.use strfind.use utf.use dialparse.use cstrconv.use search.use die.use units.use result.use bitset.use dir.use env.use resolve.use intparse.use hasprefix.use mkpath.use getint.use dirname.use sleq.use endian.use iterutil.use spork.use assert.use cmp.use chartype.use bigint.use threadhooks.use slfill.use hashfuncs.use fndup.use dial.use && $pwd/muse/muse -o std fmtfuncs.use fmt.use try.use pathjoin.use strjoin.use sljoin.use slpush.use strstrip.use htab.use now.use getcwd.use rand.use syswrap-ss.use slurp.use varargs.use listen.use strbuf.use clear.use slput.use strsplit.use introspect.use mktemp.use alloc.use optparse.use memops.use fltbits.use striter.use sldup.use fltfmt.use extremum.use option.use errno.use wait.use slcp.use writeall.use putint.use consts.use syswrap.use readall.use sort.use blat.use diriter.use mk.use swap.use hassuffix.use execvp.use ipparse.use types.use slpop.use strfind.use utf.use dialparse.use cstrconv.use search.use die.use units.use result.use bitset.use dir.use env.use resolve.use intparse.use hasprefix.use mkpath.use getint.use dirname.use sleq.use endian.use iterutil.use spork.use assert.use cmp.use chartype.use bigint.use threadhooks.use slfill.use hashfuncs.use fndup.use dial.use &&\
+echo $pwd/muse/muse -o libstd.use -p std fmtfuncs.use fmt.use try.use pathjoin.use strjoin.use sljoin.use slpush.use strstrip.use htab.use now.use getcwd.use rand.use syswrap-ss.use slurp.use varargs.use listen.use strbuf.use clear.use slput.use strsplit.use introspect.use mktemp.use alloc.use optparse.use memops.use fltbits.use striter.use sldup.use fltfmt.use extremum.use option.use errno.use wait.use slcp.use writeall.use putint.use consts.use syswrap.use readall.use sort.use blat.use diriter.use mk.use swap.use hassuffix.use execvp.use ipparse.use types.use slpop.use strfind.use utf.use dialparse.use cstrconv.use search.use die.use units.use result.use bitset.use dir.use env.use resolve.use intparse.use hasprefix.use mkpath.use getint.use dirname.use sleq.use endian.use iterutil.use spork.use assert.use cmp.use chartype.use bigint.use threadhooks.use slfill.use hashfuncs.use fndup.use dial.use && $pwd/muse/muse -o libstd.use -p std fmtfuncs.use fmt.use try.use pathjoin.use strjoin.use sljoin.use slpush.use strstrip.use htab.use now.use getcwd.use rand.use syswrap-ss.use slurp.use varargs.use listen.use strbuf.use clear.use slput.use strsplit.use introspect.use mktemp.use alloc.use optparse.use memops.use fltbits.use striter.use sldup.use fltfmt.use extremum.use option.use errno.use wait.use slcp.use writeall.use putint.use consts.use syswrap.use readall.use sort.use blat.use diriter.use mk.use swap.use hassuffix.use execvp.use ipparse.use types.use slpop.use strfind.use utf.use dialparse.use cstrconv.use search.use die.use units.use result.use bitset.use dir.use env.use resolve.use intparse.use hasprefix.use mkpath.use getint.use dirname.use sleq.use endian.use iterutil.use spork.use assert.use cmp.use chartype.use bigint.use threadhooks.use slfill.use hashfuncs.use fndup.use dial.use &&\
echo ar -rcs libstd.a fmtfuncs.o fmt.o try.o pathjoin.o strjoin.o memops-impl.o sljoin.o slpush.o strstrip.o htab.o now.o getcwd.o rand.o syswrap-ss.o slurp.o varargs.o listen.o strbuf.o clear.o slput.o strsplit.o introspect.o mktemp.o alloc.o optparse.o memops.o fltbits.o striter.o sldup.o fltfmt.o extremum.o option.o errno.o wait.o slcp.o writeall.o putint.o consts.o syswrap.o readall.o sort.o blat.o diriter.o mk.o swap.o hassuffix.o execvp.o ipparse.o types.o slpop.o strfind.o utf.o dialparse.o cstrconv.o search.o die.o units.o result.o bitset.o dir.o env.o resolve.o intparse.o hasprefix.o mkpath.o getint.o dirname.o sleq.o endian.o iterutil.o spork.o assert.o cmp.o chartype.o bigint.o threadhooks.o slfill.o hashfuncs.o fndup.o dial.o && ar -rcs libstd.a fmtfuncs.o fmt.o try.o pathjoin.o strjoin.o memops-impl.o sljoin.o slpush.o strstrip.o htab.o now.o getcwd.o rand.o syswrap-ss.o slurp.o varargs.o listen.o strbuf.o clear.o slput.o strsplit.o introspect.o mktemp.o alloc.o optparse.o memops.o fltbits.o striter.o sldup.o fltfmt.o extremum.o option.o errno.o wait.o slcp.o writeall.o putint.o consts.o syswrap.o readall.o sort.o blat.o diriter.o mk.o swap.o hassuffix.o execvp.o ipparse.o types.o slpop.o strfind.o utf.o dialparse.o cstrconv.o search.o die.o units.o result.o bitset.o dir.o env.o resolve.o intparse.o hasprefix.o mkpath.o getint.o dirname.o sleq.o endian.o iterutil.o spork.o assert.o cmp.o chartype.o bigint.o threadhooks.o slfill.o hashfuncs.o fndup.o dial.o &&\
echo cd $pwd/lib/regex && cd $pwd/lib/regex &&\
echo $pwd/6/6m -I ../std -I ../sys types.myr && $pwd/6/6m -I ../std -I ../sys types.myr &&\
@@ -99,7 +99,7 @@
echo $pwd/6/6m -I ../std -I ../sys interp.myr && $pwd/6/6m -I ../std -I ../sys interp.myr &&\
echo $pwd/6/6m -I ../std -I ../sys ranges.myr && $pwd/6/6m -I ../std -I ../sys ranges.myr &&\
echo $pwd/6/6m -I ../std -I ../sys compile.myr && $pwd/6/6m -I ../std -I ../sys compile.myr &&\
-echo $pwd/muse/muse -o regex interp.use types.use compile.use ranges.use && $pwd/muse/muse -o regex interp.use types.use compile.use ranges.use &&\
+echo $pwd/muse/muse -o libregex.use -p regex interp.use types.use compile.use ranges.use && $pwd/muse/muse -o libregex.use -p regex interp.use types.use compile.use ranges.use &&\
echo ar -rcs libregex.a interp.o types.o compile.o ranges.o && ar -rcs libregex.a interp.o types.o compile.o ranges.o &&\
echo cd $pwd/lib/bio && cd $pwd/lib/bio &&\
echo $pwd/6/6m -I ../sys -I ../std bio.myr && $pwd/6/6m -I ../sys -I ../std bio.myr &&\
@@ -106,7 +106,7 @@
echo $pwd/6/6m -I ../sys -I ../std puti.myr && $pwd/6/6m -I ../sys -I ../std puti.myr &&\
echo $pwd/6/6m -I ../sys -I ../std iter.myr && $pwd/6/6m -I ../sys -I ../std iter.myr &&\
echo $pwd/6/6m -I ../sys -I ../std geti.myr && $pwd/6/6m -I ../sys -I ../std geti.myr &&\
-echo $pwd/muse/muse -o bio puti.use bio.use geti.use iter.use && $pwd/muse/muse -o bio puti.use bio.use geti.use iter.use &&\
+echo $pwd/muse/muse -o libbio.use -p bio puti.use bio.use geti.use iter.use && $pwd/muse/muse -o libbio.use -p bio puti.use bio.use geti.use iter.use &&\
echo ar -rcs libbio.a puti.o bio.o geti.o iter.o && ar -rcs libbio.a puti.o bio.o geti.o iter.o &&\
echo cd $pwd/mbld && cd $pwd/mbld &&\
echo $pwd/6/6m -I ../lib/regex -I ../lib/bio -I ../lib/std -I ../lib/sys config.myr && $pwd/6/6m -I ../lib/regex -I ../lib/bio -I ../lib/std -I ../lib/sys config.myr &&\