flush
[m6w6/ext-psi] / tests / time / time.psi
1 typedef long time_t;
2 typedef int suseconds_t;
3
4 struct timespec {
5 time_t tv_sec;
6 long tv_nsec;
7 }
8
9 struct timeval {
10 time_t tv_sec;
11 suseconds_t tv_usec;
12 }
13
14 struct timezone {
15 int tz_minuteswest;
16 int tz_dsttime;
17 }
18
19 struct tm {
20 int tm_sec;
21 int tm_min;
22 int tm_hour;
23 int tm_mday;
24 int tm_mon;
25 int tm_year;
26 int tm_wday;
27 int tm_yday;
28 int tm_isdst;
29 long tm_gmtoff;
30 char *tm_zone;
31 }
32
33 extern int gettimeofday(struct timeval *tv, struct timezone *tz);
34 function psi\gettimeofday(array &$tv = NULL, array &$tz = NULL) : int {
35 let tv = calloc(1, struct timeval);
36 let tz = calloc(1, struct timezone);
37 return to_int(gettimeofday);
38 set $tv = to_array(*tv);
39 set $tz = to_array(*tz);
40 }
41
42 extern char *asctime(struct tm *tm);
43 function psi\asctime(array $tm = NULL) : string {
44 let tm = arrval($tm);
45 return to_string(asctime);
46 }
47
48
49 extern struct tm *gmtime(time_t tp);
50 function psi\gmtime(int $ts) : array {
51 let tp = &intval($ts);
52 return to_array(gmtime);
53 }
54
55 extern int nanosleep(struct timespec *rqtp, struct timespec *rmtp);
56 function psi\nanosleep(array $rq = NULL, array &$rm = NULL) : int {
57 let rqtp = arrval($rq);
58 let rmtp = calloc(1, struct timespec);
59 return to_int(nanosleep);
60 set $rm = to_array(*rmtp);
61 }