1 #ifdef __linux__ /* old, anyway */
9 // extern time_t time(time_t *t);
10 function psi\time() : int {
12 return time(t) as to_int(time);
15 // extern int gettimeofday(struct timeval *tp, struct timezone *tz);
16 function psi\gettimeofday(array &$tv = NULL) : int {
17 let tp = calloc(1, sizeof(struct timeval));
19 return gettimeofday(tp, tz) as to_int(gettimeofday);
20 set $tv = to_array(*tp,
25 // extern char *asctime(struct tm *tm);
26 function psi\asctime(array $tm) : string {
38 return asctime(tm) as to_string(asctime);
41 // extern char *asctime_r(struct tm *tm, char *buf);
42 function psi\asctime_r(array $tm) : string {
54 let buf = calloc(32, sizeof(char));
55 return asctime_r(tm, buf) as to_string(asctime_r);
58 // extern struct tm *gmtime(time_t *t);
59 function psi\gmtime(int $ts) : array {
61 return gmtime(t) as to_array(*gmtime,
74 // extern struct tm *gmtime_r(time_t *t, struct tm *buf);
75 function psi\gmtime_r(int $ts) : array {
77 let buf = calloc(1, sizeof(struct tm));
78 return gmtime_r(t, buf) as to_array(*gmtime_r,
91 // extern int nanosleep(struct timespec *rqts, struct timespec *rmts);
92 function psi\nanosleep(array $rq = NULL, array &$rm = NULL) : int {
93 let rqts = &arrval($rq,
97 let rmts = calloc(1, sizeof(struct timespec));
98 return nanosleep(rqts, rmts) as to_int(nanosleep);
99 set $rm = to_array(*rmts,
106 // extern clock_t times(struct tms *buf);
107 function psi\times(array &$tms = NULL) : int {
108 let buf = calloc(1, sizeof(struct tms));
109 return times(buf) as to_int(times);
110 set $tms = to_array(*buf,
119 function psi\tzset() : void {
120 return tzset() as void(tzset);
123 function psi\tzname() : array {
124 return tzname_get() as to_array(*tzname_get, 2, to_string(*tzname_get));