on master help sign in
Add 'time' function
commit94750e3660d9c9b95a46703cbd42a32cb5a07e87 authorEdwin Brady <ecb10@st-andrews.ac.uk> dateFri 28 Feb 2014, 10:18 (13 years ago) parent4fef650
3 files changed+12
libs/base/System.idr+3 rts/idris_stdfgn.c+7 rts/idris_stdfgn.h+2
libs/base/System.idr+3
@@ -71,6 +71,9 @@ getEnvironment = getAllPairs 0 []
7171exit : Int -> IO ()
7272exit code = mkForeign (FFun "exit" [FInt] FUnit) code
7373
74+time : IO Int
75+time = mkForeign (FFun "idris_time" [] FInt)
76+
7477usleep : Int -> IO ()
7578usleep i = mkForeign (FFun "usleep" [FInt] FUnit) i
7679
rts/idris_stdfgn.c+7
@@ -3,6 +3,7 @@
33#include <sys/select.h>
44#include <fcntl.h>
55#include <stdio.h>
6+#include <time.h>
67
78extern char** environ;
89
@@ -73,3 +74,9 @@ void* idris_stdin() {
7374char* getEnvPair(int i) {
7475 return *(environ + i);
7576}
77+
78+int idris_time() {
79+ time_t t = time(NULL);
80+ return (int)t;
81+}
82+
rts/idris_stdfgn.h+2
@@ -21,4 +21,6 @@ void* idris_stdin();
2121
2222char* getEnvPair(int i);
2323
24+int idris_time();
25+
2426#endif