[PATCH 1/2] Make timespec/timeval struct members signed to simplify arithmatic.
[Thread Prev] | [Thread Next]
- Subject: [PATCH 1/2] Make timespec/timeval struct members signed to simplify arithmatic.
- From: iriri <iri@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Reply-to: myrddin-dev@xxxxxxxxxxxxxx
- Date: Sat, 28 Jul 2018 17:52:40 -0700
- To: "myrddin-dev" <myrddin-dev@xxxxxxxxxxxxxx>
`time_t` is typedef'd as a 64 bit signed integer on all four platforms.
---
lib/std/syswrap+posixy.myr | 2 +-
lib/std/syswrap-ss+freebsd.myr | 4 ++--
lib/std/syswrap-ss+linux.myr | 4 ++--
lib/std/syswrap-ss+openbsd.myr | 4 ++--
lib/std/syswrap-ss+osx.myr | 4 ++--
lib/sys/sys+freebsd-x64.myr | 8 ++++----
lib/sys/sys+linux-x64.myr | 8 ++++----
lib/sys/sys+openbsd-x64.myr | 8 ++++----
lib/sys/sys+openbsd:6.1-x64.myr | 8 ++++----
lib/sys/sys+openbsd:6.2-x64.myr | 8 ++++----
lib/sys/sys+openbsd:6.3-x64.myr | 8 ++++----
lib/sys/sys+osx-x64.myr | 12 ++++++------
12 files changed, 39 insertions(+), 39 deletions(-)
diff --git a/lib/std/syswrap+posixy.myr b/lib/std/syswrap+posixy.myr
index b3b9baa8..41c6e89a 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 f445d176..0cad82a5 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 c4b77951..760a7db0 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+openbsd.myr b/lib/std/syswrap-ss+openbsd.myr
index 42605ab5..0f4ed65d 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 a7739495..53a1db1e 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 a140f0af..e1cfb692 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 575143d6..1cebb123 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+openbsd-x64.myr b/lib/sys/sys+openbsd-x64.myr
index 454567a4..ca868cc2 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
;;
diff --git a/lib/sys/sys+openbsd:6.1-x64.myr b/lib/sys/sys+openbsd:6.1-x64.myr
index ced1a80e..b033e5af 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
;;
diff --git a/lib/sys/sys+openbsd:6.2-x64.myr b/lib/sys/sys+openbsd:6.2-x64.myr
index 672c844a..1c5c553b 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
diff --git a/lib/sys/sys+openbsd:6.3-x64.myr b/lib/sys/sys+openbsd:6.3-x64.myr
index 82a6b172..2311bcfd 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
diff --git a/lib/sys/sys+osx-x64.myr b/lib/sys/sys+osx-x64.myr
index 1917ffeb..f105002c 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
@@ -1021,7 +1021,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 +1029,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#))
}
--
2.18.0
- Prev by Date: Re: union member already defined?
- Next by Date: [PATCH 2/2] Fix futex timeouts, handle futex error codes, and add mtxtimedlock, semtimedwait, and condtimedwait.
- Previous by thread: Re: union member already defined?
- Next by thread: [PATCH 2/2] Fix futex timeouts, handle futex error codes, and add mtxtimedlock, semtimedwait, and condtimedwait.
- Index(es):