summaryrefslogtreecommitdiff
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
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.
-rw-r--r--lib/std/syswrap+posixy.myr2
-rw-r--r--lib/std/syswrap-ss+freebsd.myr4
-rw-r--r--lib/std/syswrap-ss+linux.myr4
-rw-r--r--lib/std/syswrap-ss+netbsd.myr4
-rw-r--r--lib/std/syswrap-ss+openbsd.myr4
-rw-r--r--lib/std/syswrap-ss+osx.myr4
-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
-rw-r--r--support/syscall-gen/specials+openbsd:6.1-x64.frag2
-rw-r--r--support/syscall-gen/specials+openbsd:6.2-x64.frag2
-rw-r--r--support/syscall-gen/specials+openbsd:6.3-x64.frag2
17 files changed, 61 insertions, 54 deletions
diff --git a/lib/std/syswrap+posixy.myr b/lib/std/syswrap+posixy.myr
index b3b9baa..41c6e89 100644
--- a/lib/std/syswrap+posixy.myr
+++ b/lib/std/syswrap+posixy.myr
@@ -139,7 +139,7 @@ const curtime = {
if sys.clock_gettime(`sys.Clockrealtime, &tm) == 0
sec = tm.sec
- nsec = (tm.nsec : uint64)
+ nsec = tm.nsec
-> ((sec*1_000_000 + nsec/1000) : time)
else
-> -1
diff --git a/lib/std/syswrap-ss+freebsd.myr b/lib/std/syswrap-ss+freebsd.myr
index f445d17..0cad82a 100644
--- a/lib/std/syswrap-ss+freebsd.myr
+++ b/lib/std/syswrap-ss+freebsd.myr
@@ -16,8 +16,8 @@ const nanosleep = {nsecs
var req, rem
var s, ns
- s = nsecs / 1_000_000_000
- ns = nsecs % 1_000_000_000
+ s = (nsecs / 1_000_000_000 : int64)
+ ns = (nsecs % 1_000_000_000 : int64)
req = [.sec = s, .nsec = ns]
-> (sys.nanosleep(&req, &rem) : errno)
diff --git a/lib/std/syswrap-ss+linux.myr b/lib/std/syswrap-ss+linux.myr
index c4b7795..760a7db 100644
--- a/lib/std/syswrap-ss+linux.myr
+++ b/lib/std/syswrap-ss+linux.myr
@@ -13,8 +13,8 @@ const nanosleep = {nsecs
var req, rem
var s, ns
- s = nsecs / 1_000_000_000
- ns = nsecs % 1_000_000_000
+ s = (nsecs / 1_000_000_000 : int64)
+ ns = (nsecs % 1_000_000_000 : int64)
req = [.sec = s, .nsec = ns]
-> (sys.nanosleep(&req, &rem) : errno)
diff --git a/lib/std/syswrap-ss+netbsd.myr b/lib/std/syswrap-ss+netbsd.myr
index 42605ab..0f4ed65 100644
--- a/lib/std/syswrap-ss+netbsd.myr
+++ b/lib/std/syswrap-ss+netbsd.myr
@@ -22,8 +22,8 @@ const nanosleep = {nsecs
var req, rem
var s, ns
- s = nsecs / 1_000_000_000
- ns = nsecs % 1_000_000_000
+ s = (nsecs / 1_000_000_000 : int64)
+ ns = (nsecs % 1_000_000_000 : int64)
req = [.sec = s, .nsec = ns]
-> (sys.nanosleep(&req, &rem) : errno)
diff --git a/lib/std/syswrap-ss+openbsd.myr b/lib/std/syswrap-ss+openbsd.myr
index 42605ab..0f4ed65 100644
--- a/lib/std/syswrap-ss+openbsd.myr
+++ b/lib/std/syswrap-ss+openbsd.myr
@@ -22,8 +22,8 @@ const nanosleep = {nsecs
var req, rem
var s, ns
- s = nsecs / 1_000_000_000
- ns = nsecs % 1_000_000_000
+ s = (nsecs / 1_000_000_000 : int64)
+ ns = (nsecs % 1_000_000_000 : int64)
req = [.sec = s, .nsec = ns]
-> (sys.nanosleep(&req, &rem) : errno)
diff --git a/lib/std/syswrap-ss+osx.myr b/lib/std/syswrap-ss+osx.myr
index a773949..53a1db1 100644
--- a/lib/std/syswrap-ss+osx.myr
+++ b/lib/std/syswrap-ss+osx.myr
@@ -17,8 +17,8 @@ extern const put : (fmt : byte[:], args : ... -> int64)
const nanosleep = {nsecs
var s, us
- s = nsecs / 1_000_000_000
- us = (nsecs % 1_000_000_000 / 1000 : uint32)
+ s = (nsecs / 1_000_000_000 : int64)
+ us = (nsecs % 1_000_000_000 / 1000 : int32)
-> (sys.select( \
0, \
(0 : sys.fdset#), \
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#))
}
diff --git a/support/syscall-gen/specials+openbsd:6.1-x64.frag b/support/syscall-gen/specials+openbsd:6.1-x64.frag
index 4cc3843..b326ec1 100644
--- a/support/syscall-gen/specials+openbsd:6.1-x64.frag
+++ b/support/syscall-gen/specials+openbsd:6.1-x64.frag
@@ -190,7 +190,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/support/syscall-gen/specials+openbsd:6.2-x64.frag b/support/syscall-gen/specials+openbsd:6.2-x64.frag
index 4cc3843..b326ec1 100644
--- a/support/syscall-gen/specials+openbsd:6.2-x64.frag
+++ b/support/syscall-gen/specials+openbsd:6.2-x64.frag
@@ -190,7 +190,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/support/syscall-gen/specials+openbsd:6.3-x64.frag b/support/syscall-gen/specials+openbsd:6.3-x64.frag
index 4cc3843..b326ec1 100644
--- a/support/syscall-gen/specials+openbsd:6.3-x64.frag
+++ b/support/syscall-gen/specials+openbsd:6.3-x64.frag
@@ -190,7 +190,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)
}