on master help sign in
Add 'time' function
94750e3Edwin Brady
libs/base/System.idr+3
@@ -71,6 +71,9 @@ getEnvironment = getAllPairs 0 []
71exit : Int -> IO ()
71exit : Int -> IO ()
72exit code = mkForeign (FFun "exit" [FInt] FUnit) code
72exit code = mkForeign (FFun "exit" [FInt] FUnit) code
73
73
74+time : IO Int
75+time = mkForeign (FFun "idris_time" [] FInt)
76+
74usleep : Int -> IO ()
77usleep : Int -> IO ()
75usleep i = mkForeign (FFun "usleep" [FInt] FUnit) i
78usleep i = mkForeign (FFun "usleep" [FInt] FUnit) i
76
79
rts/idris_stdfgn.c+7
@@ -3,6 +3,7 @@
3#include <sys/select.h>
3#include <sys/select.h>
4#include <fcntl.h>
4#include <fcntl.h>
5#include <stdio.h>
5#include <stdio.h>
6+#include <time.h>
6
7
7extern char** environ;
8extern char** environ;
8
9
@@ -73,3 +74,9 @@ void* idris_stdin() {
73char* getEnvPair(int i) {
74char* getEnvPair(int i) {
74 return *(environ + i);
75 return *(environ + i);
75}
76}
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();
21
21
22char* getEnvPair(int i);
22char* getEnvPair(int i);
23
23
24+int idris_time();
25+
24#endif
26#endif