Commit bbe0c239 authored by Mart Lubbers's avatar Mart Lubbers

add error detection and free pointer

parent 980806ed
implementation module System.Time implementation module System.Time
import StdString, StdArray, StdClass, StdOverloaded, StdInt import StdString, StdArray, StdClass, StdOverloaded, StdInt, StdMisc
import System._Pointer, System._Posix import System._Pointer, System._Posix
import Text import Text
...@@ -171,8 +171,8 @@ nsTime :: !*World -> (!Timespec, !*World) ...@@ -171,8 +171,8 @@ nsTime :: !*World -> (!Timespec, !*World)
nsTime w nsTime w
# (p, w) = mallocSt 16 w # (p, w) = mallocSt 16 w
# (r, w) = clock_gettime 0 p w # (r, w) = clock_gettime 0 p w
= derefTimespec p w //For completeness sake
| r == -1 = abort "clock_gettime error: everyone should have permission to open CLOCK_REALTIME?"
//Include world to force evaluation order... # (tv_sec, p) = readIntP p 0
derefTimespec :: !Pointer !*w -> (!Timespec, !*w) # (tv_nsec, p) = readIntP p 8
derefTimespec p w = ({Timespec | tv_sec = readInt p 0, tv_nsec = readInt p 8}, w) = ({Timespec | tv_sec = tv_sec, tv_nsec = tv_nsec}, freeSt p w)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment