summaryrefslogtreecommitdiff
path: root/lib/sys
diff options
context:
space:
mode:
authoririri <iri@konnichiwastevenspielbergde.su>2018-08-11 19:11:19 -0700
committerOri Bernstein <ori@eigenstate.org>2018-08-14 22:34:01 -0700
commit1db9bc54f99b5489d34b7c048fe3909b0279a317 (patch)
treea157381448158d43b059fb37b35e23d86074f26a /lib/sys
parent2cd9927f90410e345fab398fe2573fe6971ef3b0 (diff)
downloadmc-1db9bc54f99b5489d34b7c048fe3909b0279a317.tar.gz
Make timespec/timeval struct members signed to simplify arithmetic.
Every single conversion except for one for OS X is uint64 to int64.
Diffstat (limited to 'lib/sys')
-rw-r--r--lib/sys/sys+freebsd-x64.myr8
-rw-r--r--lib/sys/sys+linux-x64.myr8
-rw-r--r--lib/sys/sys+netbsd-x64.myr8
-rw-r--r--lib/sys/sys+openbsd-x64.myr10
-rw-r--r--lib/sys/sys+openbsd:6.1-x64.myr10
-rw-r--r--lib/sys/sys+openbsd:6.2-x64.myr10
-rw-r--r--lib/sys/sys+openbsd:6.3-x64.myr10
-rw-r--r--lib/sys/sys+osx-x64.myr23
8 files changed, 47 insertions, 40 deletions
diff --git a/lib/sys/sys+freebsd-x64.myr b/lib/sys/sys+freebsd-x64.myr
index a140f0a..e1cfb69 100644
--- a/lib/sys/sys+freebsd-x64.myr
+++ b/lib/sys/sys+freebsd-x64.myr
@@ -262,13 +262,13 @@ pkg sys =
;;
type timespec = struct
- sec : uint64
- nsec : uint64
+ sec : int64
+ nsec : int64
;;
type timeval = struct
- sec : uint64
- usec : uint64
+ sec : int64
+ usec : int64
;;
type itimerval = struct
diff --git a/lib/sys/sys+linux-x64.myr b/lib/sys/sys+linux-x64.myr
index 575143d..1cebb12 100644
--- a/lib/sys/sys+linux-x64.myr
+++ b/lib/sys/sys+linux-x64.myr
@@ -102,13 +102,13 @@ pkg sys =
;;
type timespec = struct
- sec : uint64
- nsec : uint64
+ sec : int64
+ nsec : int64
;;
type timeval = struct
- sec : uint64
- usec : uint64
+ sec : int64
+ usec : int64
;;
type timex = struct
diff --git a/lib/sys/sys+netbsd-x64.myr b/lib/sys/sys+netbsd-x64.myr
index f380afe..8e22c0b 100644
--- a/lib/sys/sys+netbsd-x64.myr
+++ b/lib/sys/sys+netbsd-x64.myr
@@ -50,13 +50,13 @@ pkg sys =
;;
type timespec = struct
- sec : uint64
- nsec : uint64
+ sec : int64
+ nsec : int64
;;
type timeval = struct
- sec : uint64
- usec : uint64
+ sec : int64
+ usec : int64
;;
type rusage = struct
diff --git a/lib/sys/sys+openbsd-x64.myr b/lib/sys/sys+openbsd-x64.myr
index 454567a..a260134 100644
--- a/lib/sys/sys+openbsd-x64.myr
+++ b/lib/sys/sys+openbsd-x64.myr
@@ -35,13 +35,13 @@ pkg sys =
;;
type timespec = struct
- sec : uint64
- nsec : uint64
+ sec : int64
+ nsec : int64
;;
type timeval = struct
- sec : uint64
- usec : uint64
+ sec : int64
+ usec : int64
;;
@@ -751,7 +751,7 @@ const clock_settime = {clk, ts; -> (syscall(Sysclock_settime, clockid(clk), a(ts
const sleep = {time
var req, rem
- req = [.sec = time, .nsec = 0]
+ req = [.sec = (time : int64), .nsec = 0]
-> nanosleep(&req, &rem)
}
diff --git a/lib/sys/sys+openbsd:6.1-x64.myr b/lib/sys/sys+openbsd:6.1-x64.myr
index ced1a80..9314394 100644
--- a/lib/sys/sys+openbsd:6.1-x64.myr
+++ b/lib/sys/sys+openbsd:6.1-x64.myr
@@ -44,13 +44,13 @@ pkg sys =
;;
type timespec = struct
- sec : uint64
- nsec : uint64
+ sec : int64
+ nsec : int64
;;
type timeval = struct
- sec : uint64
- usec : uint64
+ sec : int64
+ usec : int64
;;
@@ -1168,7 +1168,7 @@ pkg sys =
const sleep = {time
var req, rem
- req = [.sec = time, .nsec = 0]
+ req = [.sec = (time : int64), .nsec = 0]
-> nanosleep(&req, &rem)
}
diff --git a/lib/sys/sys+openbsd:6.2-x64.myr b/lib/sys/sys+openbsd:6.2-x64.myr
index 672c844..598d381 100644
--- a/lib/sys/sys+openbsd:6.2-x64.myr
+++ b/lib/sys/sys+openbsd:6.2-x64.myr
@@ -49,13 +49,13 @@ pkg sys =
;;
type timespec = struct
- sec : uint64
- nsec : uint64
+ sec : int64
+ nsec : int64
;;
type timeval = struct
- sec : uint64
- usec : uint64
+ sec : int64
+ usec : int64
;;
type timezone = struct
@@ -1174,7 +1174,7 @@ pkg sys =
const sleep = {time
var req, rem
- req = [.sec = time, .nsec = 0]
+ req = [.sec = (time : int64), .nsec = 0]
-> nanosleep(&req, &rem)
}
diff --git a/lib/sys/sys+openbsd:6.3-x64.myr b/lib/sys/sys+openbsd:6.3-x64.myr
index 82a6b17..d013643 100644
--- a/lib/sys/sys+openbsd:6.3-x64.myr
+++ b/lib/sys/sys+openbsd:6.3-x64.myr
@@ -55,13 +55,13 @@ pkg sys =
;;
type timespec = struct
- sec : uint64
- nsec : uint64
+ sec : int64
+ nsec : int64
;;
type timeval = struct
- sec : uint64
- usec : uint64
+ sec : int64
+ usec : int64
;;
type timezone = struct
@@ -1173,7 +1173,7 @@ pkg sys =
const sleep = {time
var req, rem
- req = [.sec = time, .nsec = 0]
+ req = [.sec = (time : int64), .nsec = 0]
-> nanosleep(&req, &rem)
}
diff --git a/lib/sys/sys+osx-x64.myr b/lib/sys/sys+osx-x64.myr
index 1917ffe..ba97c36 100644
--- a/lib/sys/sys+osx-x64.myr
+++ b/lib/sys/sys+osx-x64.myr
@@ -25,13 +25,13 @@ pkg sys =
;;
type timespec = struct
- sec : uint64
- nsec : uint32
+ sec : int64
+ nsec : int64
;;
type timeval = struct
- sec : uint64
- usec : uint32
+ sec : int64
+ usec : int32
;;
type timezone = struct
@@ -825,7 +825,6 @@ pkg sys =
const clock_getres : (clk : clock, ts : timespec# -> int)
const clock_gettime : (clk : clock, ts : timespec# -> int)
const clock_settime : (clk : clock, ts : timespec# -> int)
- /* FIXME: HACK HACK HACK -- does nothing */
const sleep : (time : uint64 -> int32)
/* system information */
@@ -896,7 +895,15 @@ const bsdthread_terminate = {stk , len , port , sem
-> (syscall(Sysbsdthread_terminate, a(stk), a(len), a(port), a(sem)) : int)
}
-const sleep = {time; -> 0}
+const sleep = {time
+ -> sys.select( \
+ 0, \
+ (0 : sys.fdset#), \
+ (0 : sys.fdset#), \
+ (0 : sys.fdset#), \
+ &[.sec = (time : int64), .usec = 0] \
+ )
+}
const execv = {cmd, args
var p, cargs, i
@@ -1021,7 +1028,7 @@ const clock_gettime = {clk, ts
ret = gettimeofday(&tv, (0 : timezone#))
ts.sec = tv.sec
- ts.nsec = tv.usec * 1000
+ ts.nsec = (tv.usec * 1000 : int64)
-> ret
}
@@ -1029,7 +1036,7 @@ const clock_settime = {clk, ts
var tv
tv.sec = ts.sec
- tv.usec = ts.nsec / 1000
+ tv.usec = (ts.nsec / 1000 : int32)
-> settimeofday(&tv, (0 : timezone#))
}