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, array &$tz = NULL) : int {
17 let tp = calloc(1, sizeof(struct timeval));
18 let tz = calloc(1, sizeof(struct timezone));
19 return gettimeofday(tp, tz) as to_int(gettimeofday);
20 set $tv = to_array(*tp,
23 set $tz = to_array(*tz,
24 to_int(tz_minuteswest),
28 // extern char *asctime(struct tm *tm);
29 function psi\asctime(array $tm) : string {
41 return asctime(tm) as to_string(asctime);
44 // extern char *asctime_r(struct tm *tm, char *buf);
45 function psi\asctime_r(array $tm) : string {
57 let buf = calloc(32, sizeof(char));
58 return asctime_r(tm, buf) as to_string(asctime_r);
61 // extern struct tm *gmtime(time_t *t);
62 function psi\gmtime(int $ts) : array {
64 return gmtime(t) as to_array(*gmtime,
77 // extern struct tm *gmtime_r(time_t *t, struct tm *buf);
78 function psi\gmtime_r(int $ts) : array {
80 let buf = calloc(1, sizeof(struct tm));
81 return gmtime_r(t, buf) as to_array(*gmtime_r,
94 // extern int nanosleep(struct timespec *rqts, struct timespec *rmts);
95 function psi\nanosleep(array $rq = NULL, array &$rm = NULL) : int {
96 let rqts = &arrval($rq,
100 let rmts = calloc(1, sizeof(struct timespec));
101 return nanosleep(rqts, rmts) as to_int(nanosleep);
102 set $rm = to_array(*rmts,
109 // extern clock_t times(struct tms *buf);
110 function psi\times(array &$tms = NULL) : int {
111 let buf = calloc(1, sizeof(struct tms));
112 return times(buf) as to_int(times);
113 set $tms = to_array(*buf,
122 function psi\tzset() : void {
123 return tzset() as void(tzset);
126 function psi\tzname() : array {
127 return tzname_get() as to_array(*tzname_get, 2, to_string(*tzname_get));