projects
/
m6w6
/
ext-psi
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
#pragma lib
[m6w6/ext-psi]
/
psi.d
/
time.psi
diff --git
a/psi.d/time.psi
b/psi.d/time.psi
index 7fb3cb905a981203d5671aaf79a99b0d5c2ca63b..84c47bac40f5b4a3a0cbc1d6ef4c81f6c03639a6 100644
(file)
--- a/
psi.d/time.psi
+++ b/
psi.d/time.psi
@@
-1,3
+1,11
@@
+#ifdef __linux__ /* old, anyway */
+#pragma lib "rt";
+#endif
+
+#include <sys/time.h>
+#include <time.h>
+#include <sys/times.h>
+
// extern time_t time(time_t *t);
function psi\time() : int {
let t = NULL;
// extern time_t time(time_t *t);
function psi\time() : int {
let t = NULL;
@@
-6,8
+14,8
@@
function psi\time() : int {
// extern int gettimeofday(struct timeval *tp, struct timezone *tz);
function psi\gettimeofday(array &$tv = NULL, array &$tz = NULL) : int {
// extern int gettimeofday(struct timeval *tp, struct timezone *tz);
function psi\gettimeofday(array &$tv = NULL, array &$tz = NULL) : int {
- let tp = calloc(1,
psi\SIZEOF_STRUCT_TIMEVAL
);
- let tz = calloc(1,
psi\SIZEOF_STRUCT_TIMEZONE
);
+ let tp = calloc(1,
sizeof(struct timeval)
);
+ let tz = calloc(1,
sizeof(struct timezone)
);
return gettimeofday(tp, tz) as to_int(gettimeofday);
set $tv = to_array(*tp,
to_int(tv_sec),
return gettimeofday(tp, tz) as to_int(gettimeofday);
set $tv = to_array(*tp,
to_int(tv_sec),
@@
-46,7
+54,7
@@
function psi\asctime_r(array $tm) : string {
intval($tm_yday),
intval($tm_isdst)
);
intval($tm_yday),
intval($tm_isdst)
);
- let buf = calloc(32,
psi\SIZEOF_CHAR
);
+ let buf = calloc(32,
sizeof(char)
);
return asctime_r(tm, buf) as to_string(asctime_r);
}
return asctime_r(tm, buf) as to_string(asctime_r);
}
@@
-69,7
+77,7
@@
function psi\gmtime(int $ts) : array {
// extern struct tm *gmtime_r(time_t *t, struct tm *buf);
function psi\gmtime_r(int $ts) : array {
let t = &intval($ts);
// extern struct tm *gmtime_r(time_t *t, struct tm *buf);
function psi\gmtime_r(int $ts) : array {
let t = &intval($ts);
- let buf = calloc(1,
psi\SIZEOF_STRUCT_TM
);
+ let buf = calloc(1,
sizeof(struct tm)
);
return gmtime_r(t, buf) as to_array(*gmtime_r,
to_int(tm_sec),
to_int(tm_min),
return gmtime_r(t, buf) as to_array(*gmtime_r,
to_int(tm_sec),
to_int(tm_min),
@@
-89,7
+97,7
@@
function psi\nanosleep(array $rq = NULL, array &$rm = NULL) : int {
intval($tv_sec),
intval($tv_nsec)
);
intval($tv_sec),
intval($tv_nsec)
);
- let rmts = calloc(1,
psi\SIZEOF_STRUCT_TIMESPEC
);
+ let rmts = calloc(1,
sizeof(struct timespec)
);
return nanosleep(rqts, rmts) as to_int(nanosleep);
set $rm = to_array(*rmts,
to_int(tv_sec),
return nanosleep(rqts, rmts) as to_int(nanosleep);
set $rm = to_array(*rmts,
to_int(tv_sec),
@@
-97,9
+105,10
@@
function psi\nanosleep(array $rq = NULL, array &$rm = NULL) : int {
);
}
);
}
+
// extern clock_t times(struct tms *buf);
function psi\times(array &$tms = NULL) : int {
// extern clock_t times(struct tms *buf);
function psi\times(array &$tms = NULL) : int {
- let buf = calloc(1,
psi\SIZEOF_STRUCT_TMS
);
+ let buf = calloc(1,
sizeof(struct tms)
);
return times(buf) as to_int(times);
set $tms = to_array(*buf,
to_int(tms_utime),
return times(buf) as to_int(times);
set $tms = to_array(*buf,
to_int(tms_utime),
@@
-108,3
+117,12
@@
function psi\times(array &$tms = NULL) : int {
to_int(tms_cstime)
);
}
to_int(tms_cstime)
);
}
+
+
+function psi\tzset() : void {
+ return tzset() as void(tzset);
+}
+
+function psi\tzname() : array {
+ return tzname_get() as to_array(*tzname_get, 2, to_string(*tzname_get));
+}