ref: 1db9bc54f99b5489d34b7c048fe3909b0279a317
parent: 2cd9927f90410e345fab398fe2573fe6971ef3b0
author: iriri <iri@konnichiwastevenspielbergde.su>
date: Sat Aug 11 15:11:19 EDT 2018
Make timespec/timeval struct members signed to simplify arithmetic. Every single conversion except for one for OS X is uint64 to int64.
--- a/lib/std/syswrap+posixy.myr
+++ b/lib/std/syswrap+posixy.myr
@@ -139,7 +139,7 @@
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
--- a/lib/std/syswrap-ss+freebsd.myr
+++ b/lib/std/syswrap-ss+freebsd.myr
@@ -16,8 +16,8 @@
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)
--- a/lib/std/syswrap-ss+linux.myr
+++ b/lib/std/syswrap-ss+linux.myr
@@ -13,8 +13,8 @@
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)
--- a/lib/std/syswrap-ss+netbsd.myr
+++ b/lib/std/syswrap-ss+netbsd.myr
@@ -22,8 +22,8 @@
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)
--- a/lib/std/syswrap-ss+openbsd.myr
+++ b/lib/std/syswrap-ss+openbsd.myr
@@ -22,8 +22,8 @@
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)
--- a/lib/std/syswrap-ss+osx.myr
+++ b/lib/std/syswrap-ss+osx.myr
@@ -17,8 +17,8 @@
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#), \
--- a/lib/sys/sys+freebsd-x64.myr
+++ b/lib/sys/sys+freebsd-x64.myr
@@ -262,13 +262,13 @@
;;
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
--- a/lib/sys/sys+linux-x64.myr
+++ b/lib/sys/sys+linux-x64.myr
@@ -102,13 +102,13 @@
;;
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
--- a/lib/sys/sys+netbsd-x64.myr
+++ b/lib/sys/sys+netbsd-x64.myr
@@ -50,13 +50,13 @@
;;
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
--- a/lib/sys/sys+openbsd-x64.myr
+++ b/lib/sys/sys+openbsd-x64.myr
@@ -35,13 +35,13 @@
;;
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 sleep = {time
var req, rem
- req = [.sec = time, .nsec = 0]
+ req = [.sec = (time : int64), .nsec = 0]
-> nanosleep(&req, &rem)
}
--- a/lib/sys/sys+openbsd:6.1-x64.myr
+++ b/lib/sys/sys+openbsd:6.1-x64.myr
@@ -44,13 +44,13 @@
;;
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 @@
const sleep = {time
var req, rem
- req = [.sec = time, .nsec = 0]
+ req = [.sec = (time : int64), .nsec = 0]
-> nanosleep(&req, &rem)
}
--- a/lib/sys/sys+openbsd:6.2-x64.myr
+++ b/lib/sys/sys+openbsd:6.2-x64.myr
@@ -49,13 +49,13 @@
;;
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 @@
const sleep = {time
var req, rem
- req = [.sec = time, .nsec = 0]
+ req = [.sec = (time : int64), .nsec = 0]
-> nanosleep(&req, &rem)
}
--- a/lib/sys/sys+openbsd:6.3-x64.myr
+++ b/lib/sys/sys+openbsd:6.3-x64.myr
@@ -55,13 +55,13 @@
;;
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 @@
const sleep = {time
var req, rem
- req = [.sec = time, .nsec = 0]
+ req = [.sec = (time : int64), .nsec = 0]
-> nanosleep(&req, &rem)
}
--- a/lib/sys/sys+osx-x64.myr
+++ b/lib/sys/sys+osx-x64.myr
@@ -25,13 +25,13 @@
;;
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 @@
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 @@
-> (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 @@
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 @@
var tv
tv.sec = ts.sec
- tv.usec = ts.nsec / 1000
+ tv.usec = (ts.nsec / 1000 : int32)
-> settimeofday(&tv, (0 : timezone#))
}
--- 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 sleep = {time
var req, rem
- req = [.sec = time, .nsec = 0]
+ req = [.sec = (time : int64), .nsec = 0]
-> nanosleep(&req, &rem)
}
--- 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 sleep = {time
var req, rem
- req = [.sec = time, .nsec = 0]
+ req = [.sec = (time : int64), .nsec = 0]
-> nanosleep(&req, &rem)
}
--- 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 sleep = {time
var req, rem
- req = [.sec = time, .nsec = 0]
+ req = [.sec = (time : int64), .nsec = 0]
-> nanosleep(&req, &rem)
}