mirror of
https://github.com/ilyakooo0/Idris-dev.git
synced 2024-09-22 14:38:20 +03:00
Add 'time' function
This commit is contained in:
parent
4fef6507d3
commit
94750e3660
@ -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
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -21,4 +21,6 @@ void* idris_stdin();
|
||||
|
||||
char* getEnvPair(int i);
|
||||
|
||||
int idris_time();
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user