configure: add --enable-psi-maintainer-mode
[m6w6/ext-psi] / psi.d / time.psi
index 13959da809a39360888a6bac356f7c7682027ce8..25bc4e86f8d1efbc53eaefc1fa770586920059cb 100644 (file)
@@ -1,3 +1,4 @@
+// extern time_t time(time_t *t);
 function psi\time() : int {
        let t = NULL;
        return to_int(time);
@@ -17,14 +18,34 @@ function psi\gettimeofday(array &$tv = NULL, array &$tz = NULL) : int {
 }
 
 // extern char *asctime(struct tm *tm);
-function psi\asctime(array $tm = NULL) : string {
-       let tm = &arrval($tm);
+function psi\asctime(array $tm) : string {
+       let tm = &arrval($tm,
+               intval($tm_sec),
+               intval($tm_min),
+               intval($tm_hour),
+               intval($tm_mday),
+               intval($tm_mon),
+               intval($tm_year),
+               intval($tm_wday),
+               intval($tm_yday),
+               intval($tm_isdst)
+       );
        return to_string(asctime);
 }
 
 // extern char *asctime_r(struct tm *tm, char *buf);
-function psi\asctime_r(array $tm = NULL) : string {
-       let tm = &arrval($tm);
+function psi\asctime_r(array $tm) : string {
+       let tm = &arrval($tm,
+               intval($tm_sec),
+               intval($tm_min),
+               intval($tm_hour),
+               intval($tm_mday),
+               intval($tm_mon),
+               intval($tm_year),
+               intval($tm_wday),
+               intval($tm_yday),
+               intval($tm_isdst)
+       );
        let buf = calloc(32, psi\SIZEOF_CHAR);
        return to_string(asctime_r);
 }
@@ -64,7 +85,10 @@ function psi\gmtime_r(int $ts) : array {
 
 // extern int nanosleep(struct timespec *rqts, struct timespec *rmts);
 function psi\nanosleep(array $rq = NULL, array &$rm = NULL) : int {
-       let rqts = &arrval($rq);
+       let rqts = &arrval($rq,
+               intval($tv_sec),
+               intval($tv_nsec)
+       );
        let rmts = calloc(1, psi\SIZEOF_STRUCT_TIMESPEC);
        return to_int(nanosleep);
        set $rm = to_array(*rmts,
@@ -77,7 +101,7 @@ function psi\nanosleep(array $rq = NULL, array &$rm = NULL) : int {
 function psi\times(array &$tms = NULL) : int {
        let buf = calloc(1, psi\SIZEOF_STRUCT_TMS);
        return to_int(times);
-       set $tms = to_array(buf,
+       set $tms = to_array(*buf,
                to_int(tms_utime),
                to_int(tms_stime),
                to_int(tms_cutime),