#include <signal.h>
#include <sys/timex.h>
-#ifndef UTIME_NOW
-#define UTIME_NOW ((1l << 30) - 1l)
-#endif
-#ifndef UTIME_OMIT
-#define UTIME_OMIT ((1l << 30) - 2l)
-#endif
-
-#if SUPPORTED_PERSONALITIES > 1
-# if defined X86_64 || defined X32
-# define current_time_t_is_compat (current_personality == 1)
-# else
-# define current_time_t_is_compat (current_wordsize == 4)
-# endif
-#else
-# define current_time_t_is_compat 0
-#endif
-
-struct timeval32
-{
- u_int32_t tv_sec, tv_usec;
-};
-
-void
-printtv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness, int special)
-{
- char buf[TIMEVAL_TEXT_BUFSIZE];
- sprinttv(buf, tcp, addr, bitness, special);
- tprints(buf);
-}
-
-static char *
-do_sprinttv(char *buf, const uintmax_t sec, const uintmax_t usec,
- const int special)
-{
- if (special) {
- switch (usec) {
- case UTIME_NOW:
- return stpcpy(buf, "UTIME_NOW");
- case UTIME_OMIT:
- return stpcpy(buf, "UTIME_OMIT");
- }
- }
- return buf + sprintf(buf, "{%ju, %ju}", sec, usec);
-}
-
-char *
-sprinttv(char *buf, struct tcb *tcp, long addr, enum bitness_t bitness, int special)
+static void
+print_timezone(struct tcb *const tcp, const kernel_ureg_t addr)
{
- if (addr == 0)
- return stpcpy(buf, "NULL");
-
- if (!verbose(tcp) || (exiting(tcp) && syserror(tcp)))
- return buf + sprintf(buf, "%#lx", addr);
+ struct timezone tz;
- if (bitness == BITNESS_32 || current_time_t_is_compat)
- {
- struct timeval32 tv;
+ if (umove_or_printaddr(tcp, addr, &tz))
+ return;
- if (umove(tcp, addr, &tv) >= 0)
- return do_sprinttv(buf, tv.tv_sec, tv.tv_usec, special);
- } else {
- struct timeval tv;
-
- if (umove(tcp, addr, &tv) >= 0)
- return do_sprinttv(buf, tv.tv_sec, tv.tv_usec, special);
- }
-
- return buf + sprintf(buf, "%#lx", addr);
-}
-
-void
-print_timespec(struct tcb *tcp, long addr)
-{
- char buf[TIMESPEC_TEXT_BUFSIZE];
- sprint_timespec(buf, tcp, addr);
- tprints(buf);
-}
-
-void
-sprint_timespec(char *buf, struct tcb *tcp, long addr)
-{
- if (addr == 0)
- strcpy(buf, "NULL");
- else if (!verbose(tcp))
- sprintf(buf, "%#lx", addr);
- else {
- int rc;
-
-#if SUPPORTED_PERSONALITIES > 1
- if (current_time_t_is_compat) {
- struct timeval32 tv;
-
- rc = umove(tcp, addr, &tv);
- if (rc >= 0)
- sprintf(buf, "{%u, %u}",
- tv.tv_sec, tv.tv_usec);
- } else
-#endif
- {
- struct timespec ts;
-
- rc = umove(tcp, addr, &ts);
- if (rc >= 0)
- sprintf(buf, "{%ju, %ju}",
- (uintmax_t) ts.tv_sec,
- (uintmax_t) ts.tv_nsec);
- }
- if (rc < 0)
- strcpy(buf, "{...}");
- }
+ tprintf("{tz_minuteswest=%d, tz_dsttime=%d}",
+ tz.tz_minuteswest, tz.tz_dsttime);
}
SYS_FUNC(gettimeofday)
{
if (exiting(tcp)) {
- printtv(tcp, tcp->u_arg[0]);
+ print_timeval(tcp, tcp->u_arg[0]);
tprints(", ");
- printtv(tcp, tcp->u_arg[1]);
+ print_timezone(tcp, tcp->u_arg[1]);
}
return 0;
}
SYS_FUNC(osf_gettimeofday)
{
if (exiting(tcp)) {
- printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0);
+ print_timeval32(tcp, tcp->u_arg[0]);
tprints(", ");
- printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
+ print_timezone(tcp, tcp->u_arg[1]);
}
return 0;
}
SYS_FUNC(settimeofday)
{
- printtv(tcp, tcp->u_arg[0]);
+ print_timeval(tcp, tcp->u_arg[0]);
tprints(", ");
- printtv(tcp, tcp->u_arg[1]);
+ print_timezone(tcp, tcp->u_arg[1]);
return RVAL_DECODED;
}
#ifdef ALPHA
SYS_FUNC(osf_settimeofday)
{
- printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0);
+ print_timeval32(tcp, tcp->u_arg[0]);
tprints(", ");
- printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
+ print_timezone(tcp, tcp->u_arg[1]);
return RVAL_DECODED;
}
#endif
-SYS_FUNC(adjtime)
-{
- if (entering(tcp)) {
- printtv(tcp, tcp->u_arg[0]);
- tprints(", ");
- } else {
- printtv(tcp, tcp->u_arg[1]);
- }
- return 0;
-}
-
SYS_FUNC(nanosleep)
{
if (entering(tcp)) {
#include "xlat/adjtimex_state.h"
static int
-do_adjtimex(struct tcb *tcp, long addr)
+do_adjtimex(struct tcb *const tcp, const kernel_ureg_t addr)
{
if (print_timex(tcp, addr))
return 0;
- tcp->auxstr = xlookup(adjtimex_state, tcp->u_rval);
+ tcp->auxstr = xlookup(adjtimex_state, (unsigned long) tcp->u_rval);
if (tcp->auxstr)
return RVAL_STR;
return 0;
{
printclockname(tcp->u_arg[0]);
tprints(", ");
- printtv(tcp, tcp->u_arg[1]);
+ print_timespec(tcp, tcp->u_arg[1]);
return RVAL_DECODED;
}
printclockname(tcp->u_arg[0]);
tprints(", ");
} else {
- printtv(tcp, tcp->u_arg[1]);
+ print_timespec(tcp, tcp->u_arg[1]);
}
return 0;
}
tprints(", ");
printflags(clockflags, tcp->u_arg[1], "TIMER_???");
tprints(", ");
- printtv(tcp, tcp->u_arg[2]);
+ print_timespec(tcp, tcp->u_arg[2]);
tprints(", ");
} else {
- printtv(tcp, tcp->u_arg[3]);
+ /*
+ * Second (returned) timespec is only significant
+ * if syscall was interrupted and flags is not TIMER_ABSTIME.
+ */
+ if (!tcp->u_arg[1] && is_erestart(tcp)) {
+ temporarily_clear_syserror(tcp);
+ print_timespec(tcp, tcp->u_arg[3]);
+ restore_cleared_syserror(tcp);
+ } else {
+ printaddr(tcp->u_arg[3]);
+ }
}
return 0;
}
#include "xlat/timerfdflags.h"
-SYS_FUNC(timerfd)
-{
- tprintf("%ld, ", tcp->u_arg[0]);
- printclockname(tcp->u_arg[0]);
- tprints(", ");
- printflags(timerfdflags, tcp->u_arg[2], "TFD_???");
- tprints(", ");
- print_itimerspec(tcp, tcp->u_arg[3]);
-
- return RVAL_DECODED | RVAL_FD;
-}
-
SYS_FUNC(timerfd_create)
{
printclockname(tcp->u_arg[0]);
SYS_FUNC(timerfd_settime)
{
- printfd(tcp, tcp->u_arg[0]);
- tprints(", ");
- printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
- tprints(", ");
- print_itimerspec(tcp, tcp->u_arg[2]);
- tprints(", ");
- print_itimerspec(tcp, tcp->u_arg[3]);
-
- return RVAL_DECODED;
+ if (entering(tcp)) {
+ printfd(tcp, tcp->u_arg[0]);
+ tprints(", ");
+ printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
+ tprints(", ");
+ print_itimerspec(tcp, tcp->u_arg[2]);
+ tprints(", ");
+ } else {
+ print_itimerspec(tcp, tcp->u_arg[3]);
+ }
+ return 0;
}
SYS_FUNC(timerfd_gettime)