Add 'time' function

This commit is contained in:
Edwin Brady 2014-02-28 10:18:41 +00:00
parent 4fef6507d3
commit 94750e3660
3 changed files with 12 additions and 0 deletions

View File

@ -71,6 +71,9 @@ getEnvironment = getAllPairs 0 []
exit : Int -> IO ()
exit code = mkForeign (FFun "exit" [FInt] FUnit) code
time : IO Int
time = mkForeign (FFun "idris_time" [] FInt)
usleep : Int -> IO ()
usleep i = mkForeign (FFun "usleep" [FInt] FUnit) i

View File

@ -3,6 +3,7 @@
#include <sys/select.h>
#include <fcntl.h>
#include <stdio.h>
#include <time.h>
extern char** environ;
@ -73,3 +74,9 @@ void* idris_stdin() {
char* getEnvPair(int i) {
return *(environ + i);
}
int idris_time() {
time_t t = time(NULL);
return (int)t;
}

View File

@ -21,4 +21,6 @@ void* idris_stdin();
char* getEnvPair(int i);
int idris_time();
#endif