-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtime.af
More file actions
26 lines (20 loc) · 737 Bytes
/
Copy pathtime.af
File metadata and controls
26 lines (20 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use' lang.af
use' time.af
fun: main { -- err }
\ Allocate a C-compatible struct on the system stack,
\ and get the address. We can now use it with `libc`.
alloca' Timespec { inst }
if CLOCK_MONOTONIC inst .clock_gettime .then
.errno " unable to get time" .os_err .throw
end
" mono seconds: " .log inst .Timespec_sec @ .log_int .lf
" mono nanos: " .log inst .Timespec_nsec @ .log_int .lf
if CLOCK_REALTIME inst .clock_gettime .then
.errno " unable to get time" .os_err .throw
end
" real seconds: " .log inst .Timespec_sec @ .log_int .lf
" real nanos: " .log inst .Timespec_nsec @ .log_int .lf
" CPU elapsed: " .log .clock .log_int .lf
" Unix seconds: " .log nil .time .log_int .lf
end
.main