projects
/
m6w6
/
ext-psi
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
set psi as module for register functions
[m6w6/ext-psi]
/
psi.d
/
time.psi
diff --git
a/psi.d/time.psi
b/psi.d/time.psi
index 9302b136f5fcbb8b4f8aa910a359515fbc9dc1cf..716e17610bd5b8613671417d488018c6c1ec8685 100644
(file)
--- a/
psi.d/time.psi
+++ b/
psi.d/time.psi
@@
-1,14
+1,22
@@
+#ifdef linux /* old, anyway */
+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;
- return to_int(time);
+ return t
ime(t) as t
o_int(time);
}
// 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
);
- return to_int(gettimeofday);
+ 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),
to_int(tv_usec));
set $tv = to_array(*tp,
to_int(tv_sec),
to_int(tv_usec));
@@
-18,22
+26,42
@@
function psi\gettimeofday(array &$tv = NULL, array &$tz = NULL) : int {
}
// extern char *asctime(struct tm *tm);
}
// extern char *asctime(struct tm *tm);
-function psi\asctime(array $tm = NULL) : string {
- let tm = &arrval($tm);
- return to_string(asctime);
+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 asctime(tm) as to_string(asctime);
}
// extern char *asctime_r(struct tm *tm, char *buf);
}
// extern char *asctime_r(struct tm *tm, char *buf);
-function psi\asctime_r(array $tm = NULL) : string {
- let tm = &arrval($tm);
- let buf = calloc(32, psi\SIZEOF_CHAR);
- return to_string(asctime_r);
+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, sizeof(char));
+ return asctime_r(tm, buf) as to_string(asctime_r);
}
// extern struct tm *gmtime(time_t *t);
function psi\gmtime(int $ts) : array {
let t = &intval($ts);
}
// extern struct tm *gmtime(time_t *t);
function psi\gmtime(int $ts) : array {
let t = &intval($ts);
- return to_array(*gmtime,
+ return
gmtime(t) as
to_array(*gmtime,
to_int(tm_sec),
to_int(tm_min),
to_int(tm_hour),
to_int(tm_sec),
to_int(tm_min),
to_int(tm_hour),
@@
-49,8
+77,8
@@
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
);
- return to_array(*gmtime_r,
+ 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),
to_int(tm_hour),
to_int(tm_sec),
to_int(tm_min),
to_int(tm_hour),
@@
-65,19
+93,23
@@
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 {
// extern int nanosleep(struct timespec *rqts, struct timespec *rmts);
function psi\nanosleep(array $rq = NULL, array &$rm = NULL) : int {
- let rqts = &arrval($rq);
- let rmts = calloc(1, psi\SIZEOF_STRUCT_TIMESPEC);
- return to_int(nanosleep);
+ let rqts = &arrval($rq,
+ intval($tv_sec),
+ intval($tv_nsec)
+ );
+ let rmts = calloc(1, sizeof(struct timespec));
+ return nanosleep(rqts, rmts) as to_int(nanosleep);
set $rm = to_array(*rmts,
to_int(tv_sec),
to_int(tv_nsec)
);
}
set $rm = to_array(*rmts,
to_int(tv_sec),
to_int(tv_nsec)
);
}
+
// 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
);
- return to_int(times);
+ let buf = calloc(1,
sizeof(struct tms)
);
+ return t
imes(buf) as t
o_int(times);
set $tms = to_array(*buf,
to_int(tms_utime),
to_int(tms_stime),
set $tms = to_array(*buf,
to_int(tms_utime),
to_int(tms_stime),
@@
-85,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));
+}