flush
[m6w6/ext-psi] / tests / time / time.psi
1 extern int gettimeofday(struct timeval *tv, struct timezone *tz);
2 function psi\gettimeofday(array &$tv = NULL, array &$tz = NULL) : int {
3 let tv = calloc(1, struct timeval);
4 let tz = calloc(1, struct timezone);
5 return to_int(gettimeofday);
6 set $tv = to_array(*tv);
7 set $tz = to_array(*tz);
8 }
9
10 extern char *asctime(struct tm *tm);
11 function psi\asctime(array $tm = NULL) : string {
12 let tm = arrval($tm);
13 return to_string(asctime);
14 }
15
16 extern char *asctime_r(struct tm *tm, char *buf);
17 function psi\asctime_r(array $tm = NULL) : string {
18 let tm = arrval($tm);
19 let buf = calloc(32, char);
20 return to_string(asctime_r);
21 }
22
23 extern struct tm *gmtime(time_t *tp);
24 function psi\gmtime(int $ts) : array {
25 let tp = &intval($ts);
26 return to_array(gmtime);
27 }
28
29 extern struct tm *gmtime_r(time_t *tp, struct tm *buf);
30 function psi\gmtime_r(int $ts) : array {
31 let tp = &intval($ts);
32 let buf = calloc(1, struct tm);
33 return to_array(gmtime_r);
34 }
35
36 extern int nanosleep(struct timespec *rqtp, struct timespec *rmtp);
37 function psi\nanosleep(array $rq = NULL, array &$rm = NULL) : int {
38 let rqtp = arrval($rq);
39 let rmtp = calloc(1, struct timespec);
40 return to_int(nanosleep);
41 set $rm = to_array(*rmtp);
42 }
43
44 extern clock_t times(struct tms *buf);
45 function psi\times(array &$tms = NULL) : int {
46 let buf = calloc(1, struct tms);
47 return to_int(times);
48 set $tms = to_array(*buf);
49 }