24 lines
623 B
Text
24 lines
623 B
Text
include 'std/std.fa'
|
|
include 'std/mem/gmem.fa'
|
|
|
|
macro TIMESPEC_SZ %LONG_SZ 2 mul end
|
|
|
|
fun main [ str str int ] eo
|
|
%TIMESPEC_SZ #malloc as timespec -- Allocate a structure called timespec
|
|
|
|
"I will sleep for 5 seconds and 0 nanoseconds"
|
|
%puts
|
|
|
|
@timespec deref 5 set -- long timespec.time_t = 5
|
|
@timespec deref %LONG_SZ add 0 set -- long timespec.tv_nsec = 0
|
|
|
|
0 @timespec deref
|
|
%SYS_nanosleep sys 3 -- nanosleep(*timespec, NULL)
|
|
|
|
%TIMESPEC_SZ @timespec deref
|
|
#mfree 1 drop -- Free the structure
|
|
|
|
%EXIT_SUCCESS %exit
|
|
end
|
|
|
|
#main
|