summaryrefslogtreecommitdiff
path: root/libstd
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-03-02 22:13:03 -0800
committerOri Bernstein <ori@eigenstate.org>2015-03-02 22:17:21 -0800
commitb4fe2c27b3a89e1e6ded71a147b6421df607855f (patch)
tree9ebb00158532c8bdfd0b267287ac8d3403670b62 /libstd
parent3385db479e93b1300a10a0f638a4454e6e4a0fdd (diff)
downloadmc-b4fe2c27b3a89e1e6ded71a147b6421df607855f.tar.gz
Add some syscalls to support libthread.
Diffstat (limited to 'libstd')
-rw-r--r--libstd/sys+linux-x64.myr49
-rw-r--r--libstd/syswrap+posixy.myr3
2 files changed, 45 insertions, 7 deletions
diff --git a/libstd/sys+linux-x64.myr b/libstd/sys+linux-x64.myr
index 0c5c01a..82375ef 100644
--- a/libstd/sys+linux-x64.myr
+++ b/libstd/sys+linux-x64.myr
@@ -1,20 +1,25 @@
use "systypes.use"
pkg sys =
- type pid = int64 /* process id */
type scno = int64 /* syscall */
+
+ /* processes/threads */
+ type pid = int /* process id */
+ type tid = int /* thread id */
+ type cloneopt = int64 /* options for clone(2) */
+
+ /* file descriptor manipulation */
type fdopt = int64 /* fd options */
type fd = int32 /* fd */
+ type whence = uint64 /* seek from whence */
+ type filemode = uint32 /*
+
type mprot = int64 /* memory protection */
type mopt = int64 /* memory mapping options */
-
type socktype = int64 /* socket type */
type sockproto = int64 /* socket protocol */
type sockfam = uint16 /* socket family */
- type whence = uint64
- type filemode = uint32
-
type epollflags = uint32
type epollop = uint32
type epollevttype = uint32
@@ -120,6 +125,33 @@ pkg sys =
revents : pollevt
;;
+ /* clone options */
+ const Clonesignal : cloneopt = 0xff
+ const Clonevm : cloneopt = 0x100
+ const Clonefs : cloneopt = 0x200
+ const Clonefiles : cloneopt = 0x400
+ const Clonesighand : cloneopt = 0x800
+ const Cloneptrace : cloneopt = 0x2000
+ const Clonevfork : cloneopt = 0x4000
+ const Cloneparent : cloneopt = 0x8000
+ const Clonethread : cloneopt = 0x10000
+ const Clonenewns : cloneopt = 0x20000
+ const Clonesysvsem : cloneopt = 0x40000
+ const Clonesettls : cloneopt = 0x80000
+ const Cloneparentsettid : cloneopt = 0x100000
+ const Clonechildcleartid: cloneopt = 0x200000
+ const Clonedetached : cloneopt = 0x400000
+ const Cloneuntraced : cloneopt = 0x800000
+ const Clonechildsettid : cloneopt = 0x1000000
+ const Clonenewuts : cloneopt = 0x4000000
+ const Clonenewipc : cloneopt = 0x8000000
+ const Clonenewuser : cloneopt = 0x10000000
+ const Clonenewpid : cloneopt = 0x20000000
+ const Clonenewnet : cloneopt = 0x40000000
+ const Cloneio : cloneopt = 0x80000000
+
+ type ptregs = struct
+ ;;
/* open options */
const Ordonly : fdopt = 0x0
@@ -547,10 +579,12 @@ pkg sys =
/* process management */
const exit : (status:int -> void)
+ const exit_group : (status:int -> void)
const getpid : ( -> pid)
const kill : (pid:pid, sig:int64 -> int64)
const fork : (-> pid)
- const clone : (flags : uint64, stk : void#, ptid : void#, ctid : void#, ptreg : void# -> pid)
+ /* FIXME: where the fuck is 'struct pt_reg' defined?? */
+ const clone : (flags : cloneopt, stk : byte#, ptid : pid#, ctid : pid#, ptreg : byte# -> pid)
const wait4 : (pid:pid, loc:int32#, opt : int64, usage:rusage# -> int64)
const waitpid : (pid:pid, loc:int32#, opt : int64 -> int64)
const execv : (cmd : byte[:], args : byte[:][:] -> int64)
@@ -558,6 +592,8 @@ pkg sys =
/* wrappers to extract wait status */
const waitstatus : (st : int32 -> waitstatus)
+ /* threading */
+ const futex : (uaddr : int#, op : futexop, val : int, timeout : timespec#, uaddr2 : int#, val3 : int#)
/* file manipulation */
const open : (path:byte[:], opts:fdopt -> fd)
@@ -625,6 +661,7 @@ extern const alloca : (sz : size -> byte#)
/* process management */
const exit = {status; syscall(Sysexit, a(status))}
+const exit_group = {status; syscall(Sysexit_group, a(status))}
const getpid = {; -> syscall(Sysgetpid) castto(pid)}
const kill = {pid, sig; -> syscall(Syskill, a(pid), a(sig))}
const fork = {; -> syscall(Sysfork) castto(pid)}
diff --git a/libstd/syswrap+posixy.myr b/libstd/syswrap+posixy.myr
index 7863279..63f3535 100644
--- a/libstd/syswrap+posixy.myr
+++ b/libstd/syswrap+posixy.myr
@@ -101,7 +101,8 @@ const suicide = {; sys.kill(sys.getpid(), 6)} /* kill self with sigabort */
const fork = {; -> sys.fork() castto(pid)}
const execv = {cmd, args; -> sys.execv(cmd, args)}
const execve = {cmd, args, env; -> sys.execve(cmd, args, env)}
-const exit = {status; sys.exit(status)}
+const exit = {status; sys.exit_group(status)}
+const sleep = {time; sys.sleep(time)}
/* memory stuff */
const getmem = {sz; -> sys.mmap(0 castto(byte#), sz castto(sys.size), sys.Mprotrw, sys.Mpriv | sys.Manon, -1, 0)}