on master help sign in
Fix 'time' to return Integer rather than Int

This way, the time in seconds actually fits...

commitdc277394ee50fb4992a77f57f61800fbb9850fae authorEdwin Brady <ecb10@st-andrews.ac.uk> dateWed 1 Jul 2015, 13:56 (11 years ago) parent4f8d10f
4 files changed+11−7
libs/base/System.idr+3−2 libs/effects/Effect/System.idr+2−2 rts/idris_stdfgn.c+3−2 rts/idris_stdfgn.h+3−1
libs/base/System.idr+3−2
@@ -73,8 +73,9 @@ exit : Int -> IO ()
7373exit code = foreign FFI_C "exit" (Int -> IO ()) code
7474
7575||| Get the Unix time
76−time : IO Int
77−time = foreign FFI_C "idris_time" (IO Int)
76+time : IO Integer
77+time = do MkRaw t <- foreign FFI_C "idris_time" (IO (Raw Integer))
78+ return t
7879
7980usleep : Int -> IO ()
8081usleep i = foreign FFI_C "usleep" (Int -> IO ()) i
libs/effects/Effect/System.idr+2−2
@@ -9,7 +9,7 @@ import Control.IOExcept
99
1010data System : Effect where
1111 Args : sig System (List String)
12− Time : sig System Int
12+ Time : sig System Integer
1313 GetEnv : String -> sig System (Maybe String)
1414 CSystem : String -> sig System Int
1515
@@ -33,7 +33,7 @@ SYSTEM = MkEff () System
3333getArgs : Eff (List String) [SYSTEM]
3434getArgs = call Args
3535
36−time : Eff Int [SYSTEM]
36+time : Eff Integer [SYSTEM]
3737time = call Time
3838
3939getEnv : String -> Eff (Maybe String) [SYSTEM]
rts/idris_stdfgn.c+3−2
@@ -1,5 +1,6 @@
11#include "idris_stdfgn.h"
22#include "idris_rts.h"
3+#include "idris_gmp.h"
34#include "idris_gc.h"
45#include <sys/select.h>
56#include <fcntl.h>
@@ -80,9 +81,9 @@ char* getEnvPair(int i) {
8081 return *(environ + i);
8182}
8283
83−int idris_time() {
84+VAL idris_time() {
8485 time_t t = time(NULL);
85− return (int)t;
86+ return MKBIGI(t);
8687}
8788
8889void idris_forceGC(void* vm) {
rts/idris_stdfgn.h+3−1
@@ -1,6 +1,8 @@
11#ifndef _IDRISSTDFGN_H
22#define _IDRISSTDFGN_H
33
4+#include "idris_rts.h"
5+
46// A collection of useful standard functions to be used by the prelude.
57
68void putStr(char* str);
@@ -22,7 +24,7 @@ void* idris_stdin();
2224
2325char* getEnvPair(int i);
2426
25−int idris_time();
27+VAL idris_time();
2628
2729void idris_forceGC();
2830