about summary refs log tree commit diff stats
path: root/402time.mu
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-11-02 00:07:07 -0800
committerKartik Agaram <vc@akkartik.com>2020-11-02 00:07:07 -0800
commit951c3f4c92358d3962154a4ef24a19366ea8a619 (patch)
treee458ba9bd3e7759c24fd7850c56472fd62662078 /402time.mu
parentc8e41a470f1c3ee1dbf7b881a3dec31633e39085 (diff)
downloadmu-951c3f4c92358d3962154a4ef24a19366ea8a619.tar.gz
7158
Diffstat (limited to '402time.mu')
-rw-r--r--402time.mu12
1 files changed, 8 insertions, 4 deletions
diff --git a/402time.mu b/402time.mu
index c95c4e14..5407b6b7 100644
--- a/402time.mu
+++ b/402time.mu
@@ -3,23 +3,27 @@ type timespec {
   tv_nsec: int
 }
 
+# return time in seconds since epoch
 # TODO: y2038
-fn time -> secs/eax: int {
+fn time -> _/eax: int {
   var t: timespec
   var clock/ebx: int <- copy 0  # CLOCK_MONOTONIC
   var t-addr/ecx: (addr timespec) <- address t
   syscall_clock_gettime
   var t-secs-addr/ecx: (addr int) <- get t-addr, tv_sec
-  secs <- copy *t-secs-addr
+  var secs/eax: int <- copy *t-secs-addr
+  return secs
 }
 
-fn ntime -> nsecs/eax: int {
+# return time in nanoseconds since epoch
+fn ntime -> _/eax: int {
   var t: timespec
   var clock/ebx: int <- copy 0  # CLOCK_MONOTONIC
   var t-addr/ecx: (addr timespec) <- address t
   syscall_clock_gettime
   var t-nsecs-addr/ecx: (addr int) <- get t-addr, tv_nsec
-  nsecs <- copy *t-nsecs-addr
+  var nsecs/eax: int <- copy *t-nsecs-addr
+  return nsecs
 }
 
 # nsecs must be less than 999999999 or 0x3b9ac9ff nanoseconds