#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 *tcp, const long addr)
{
- if (addr == 0)
- return stpcpy(buf, "NULL");
-
- if (!verbose(tcp) || (exiting(tcp) && syserror(tcp)))
- return buf + sprintf(buf, "%#lx", addr);
-
- if (bitness == BITNESS_32 || current_time_t_is_compat)
- {
- struct timeval32 tv;
+ struct timezone tz;
- 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);
- }
+ if (umove_or_printaddr(tcp, addr, &tz))
+ return;
- return buf + sprintf(buf, "%#lx", addr);
-}
-
-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;
}