From dc277394ee50fb4992a77f57f61800fbb9850fae Mon Sep 17 00:00:00 2001 From: Edwin Brady Date: Wed, 1 Jul 2015 13:56:57 +0100 Subject: [PATCH] Fix 'time' to return Integer rather than Int This way, the time in seconds actually fits... --- libs/base/System.idr | 5 +++-- libs/effects/Effect/System.idr | 4 ++-- rts/idris_stdfgn.c | 5 +++-- rts/idris_stdfgn.h | 4 +++- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/libs/base/System.idr b/libs/base/System.idr index 411d04cef..932885543 100644 --- a/libs/base/System.idr +++ b/libs/base/System.idr @@ -73,8 +73,9 @@ exit : Int -> IO () exit code = foreign FFI_C "exit" (Int -> IO ()) code ||| Get the Unix time -time : IO Int -time = foreign FFI_C "idris_time" (IO Int) +time : IO Integer +time = do MkRaw t <- foreign FFI_C "idris_time" (IO (Raw Integer)) + return t usleep : Int -> IO () usleep i = foreign FFI_C "usleep" (Int -> IO ()) i diff --git a/libs/effects/Effect/System.idr b/libs/effects/Effect/System.idr index c4c4a3f6d..5c2bd128f 100644 --- a/libs/effects/Effect/System.idr +++ b/libs/effects/Effect/System.idr @@ -9,7 +9,7 @@ import Control.IOExcept data System : Effect where Args : sig System (List String) - Time : sig System Int + Time : sig System Integer GetEnv : String -> sig System (Maybe String) CSystem : String -> sig System Int @@ -33,7 +33,7 @@ SYSTEM = MkEff () System getArgs : Eff (List String) [SYSTEM] getArgs = call Args -time : Eff Int [SYSTEM] +time : Eff Integer [SYSTEM] time = call Time getEnv : String -> Eff (Maybe String) [SYSTEM] diff --git a/rts/idris_stdfgn.c b/rts/idris_stdfgn.c index 8e40f7ee5..a96bb43c5 100644 --- a/rts/idris_stdfgn.c +++ b/rts/idris_stdfgn.c @@ -1,5 +1,6 @@ #include "idris_stdfgn.h" #include "idris_rts.h" +#include "idris_gmp.h" #include "idris_gc.h" #include #include @@ -80,9 +81,9 @@ char* getEnvPair(int i) { return *(environ + i); } -int idris_time() { +VAL idris_time() { time_t t = time(NULL); - return (int)t; + return MKBIGI(t); } void idris_forceGC(void* vm) { diff --git a/rts/idris_stdfgn.h b/rts/idris_stdfgn.h index 44170fd12..36776bfc4 100644 --- a/rts/idris_stdfgn.h +++ b/rts/idris_stdfgn.h @@ -1,6 +1,8 @@ #ifndef _IDRISSTDFGN_H #define _IDRISSTDFGN_H +#include "idris_rts.h" + // A collection of useful standard functions to be used by the prelude. void putStr(char* str); @@ -22,7 +24,7 @@ void* idris_stdin(); char* getEnvPair(int i); -int idris_time(); +VAL idris_time(); void idris_forceGC();