summaryrefslogtreecommitdiff
path: root/lib/sys
diff options
context:
space:
mode:
authoririri <iri@konnichiwastevenspielbergde.su>2018-06-23 02:07:49 +0300
committeririri <iri@konnichiwastevenspielbergde.su>2018-06-23 03:14:55 +0300
commit7c2f25e309226a9506ea4b37e94e560017e83994 (patch)
treec30bb516e4666515b3b39892ac7c7748b32c0031 /lib/sys
parent5d5d5e417324785a9fc78ffd14a4ad5393e0fb06 (diff)
downloadmc-7c2f25e309226a9506ea4b37e94e560017e83994.tar.gz
Add semaphores and wrapper for various futexesque system calls
Diffstat (limited to 'lib/sys')
-rw-r--r--lib/sys/sys+freebsd-x64.myr7
-rw-r--r--lib/sys/sys+osx-x64.myr23
-rw-r--r--lib/sys/syserrno+linux.myr1
-rw-r--r--lib/sys/syserrno+osx.myr1
4 files changed, 32 insertions, 0 deletions
diff --git a/lib/sys/sys+freebsd-x64.myr b/lib/sys/sys+freebsd-x64.myr
index 440f396..a140f0a 100644
--- a/lib/sys/sys+freebsd-x64.myr
+++ b/lib/sys/sys+freebsd-x64.myr
@@ -581,6 +581,13 @@ pkg sys =
node : uint8[_Uuidnodesz];
;;
+ const Umtxabstime = 1
+ type _umtx_time = struct
+ _timeout : timespec
+ _flags : uint32
+ _clockid : uint32
+ ;;
+
/* open options */
const Ordonly : fdopt = 0x0
const Owronly : fdopt = 0x1
diff --git a/lib/sys/sys+osx-x64.myr b/lib/sys/sys+osx-x64.myr
index 3de3875..bd1f427 100644
--- a/lib/sys/sys+osx-x64.myr
+++ b/lib/sys/sys+osx-x64.myr
@@ -18,6 +18,7 @@ pkg sys =
type machport = int32
type signo = int32
type sigflags = int32
+ type ulockop = uint32
type fdset = struct
bits : int32[1024/4]
@@ -388,6 +389,14 @@ pkg sys =
const Sigusr1 : signo = 30 /* user defined signal 1 */
const Sigusr2 : signo = 31 /* user defined signal 2 */
+ /* ulock ops */
+ const Ulockcompareandwait : ulockop = 0x00000001
+ const Ulockunfairlock : ulockop = 0x00000002
+ const Ulockulfwakeall : ulockop = 0x00000100
+ const Ulockulfwakethread : ulockop = 0x00000200
+ const Ulockwaitworkqdatacontention : ulockop = 0x00010000
+ const Ulocknoerrno : ulockop = 0x01000000
+
/* syscalls.
note, creat() implemented as open(path, Creat|Trunc|Wronly) */
const Syssyscall : scno = 0x2000000
@@ -737,6 +746,8 @@ pkg sys =
const Syspid_resume : scno = 0x20001af
const Sysfileport_makeport : scno = 0x20001b0
const Sysfileport_makefd : scno = 0x20001b1
+ const Sysulock_wait : scno = 0x2000203
+ const Sysulock_wake : scno = 0x2000204
extern const syscall : (sc:scno, args:... -> int64)
@@ -823,6 +834,10 @@ pkg sys =
new : void#, newsz : size# \
-> int)
+ /* ulock */
+ const ulock_wait : (op : ulockop, uaddr : uint64#, val : uint64, timeout : uint32 -> int)
+ const ulock_wake : (op : ulockop, uaddr : uint64#, wakeval : uint64 -> int)
+
/* filled by start code */
extern var __cenvp : byte##
;;
@@ -1081,6 +1096,14 @@ const sysctl = {mib, old, oldsz, new, newsz
(mib : int#), a(mib.len), old, oldsz, new, newsz) : int)
}
+const ulock_wait = {op, uaddr, val, timeout
+ -> (syscall(Sysulock_wait, a(op), uaddr, val, a(timeout)) : int)
+}
+
+const ulock_wake = {op, uaddr, wakeval
+ -> (syscall(Sysulock_wake, a(op), uaddr, a(wakeval)) : int)
+}
+
const waitstatus = {st
if st < 0
-> `Waitfail st
diff --git a/lib/sys/syserrno+linux.myr b/lib/sys/syserrno+linux.myr
index 18a3fc2..a1bf690 100644
--- a/lib/sys/syserrno+linux.myr
+++ b/lib/sys/syserrno+linux.myr
@@ -35,4 +35,5 @@ pkg sys =
const Epipe : errno = -32 /* Broken pipe */
const Edom : errno = -33 /* Math argument out of domain of func */
const Erange : errno = -34 /* Math result not representable */
+ const Etimedout : errno = -110 /* Operation timed out */
;;
diff --git a/lib/sys/syserrno+osx.myr b/lib/sys/syserrno+osx.myr
index 7b5d888..3544308 100644
--- a/lib/sys/syserrno+osx.myr
+++ b/lib/sys/syserrno+osx.myr
@@ -51,4 +51,5 @@ pkg sys =
const Eprototype : errno = -41 /* Protocol wrong type for socket */
const Enoprotoopt : errno = -42 /* Protocol not available */
const Eprotonosupport : errno = -43 /* Protocol not supported */
+ const Etimedout : errno = -60 /* Operation timed out */
;;