*/
#include "defs.h"
-#include <sys/timex.h>
-
-#include "xlat/adjtimex_modes.h"
-#include "xlat/adjtimex_status.h"
-
-#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
-
-struct timeval32
-{
- u_int32_t tv_sec, tv_usec;
-};
-static void
-tprint_timeval32(struct tcb *tcp, const struct timeval32 *tv)
-{
- tprintf("{%u, %u}", tv->tv_sec, tv->tv_usec);
-}
+#include DEF_MPERS_TYPE(struct_timex)
-static int
-tprint_timex32(struct tcb *tcp, long addr)
-{
- struct {
- unsigned int modes;
- int offset;
- int freq;
- int maxerror;
- int esterror;
- int status;
- int constant;
- int precision;
- int tolerance;
- struct timeval32 time;
- int tick;
- int ppsfreq;
- int jitter;
- int shift;
- int stabil;
- int jitcnt;
- int calcnt;
- int errcnt;
- int stbcnt;
- } tx;
-
- if (umove_or_printaddr(tcp, addr, &tx))
- return -1;
+#include <sys/timex.h>
+typedef struct timex struct_timex;
- tprints("{modes=");
- printflags(adjtimex_modes, tx.modes, "ADJ_???");
- tprintf(", offset=%d, freq=%d, maxerror=%d, ",
- tx.offset, tx.freq, tx.maxerror);
- tprintf("esterror=%u, status=", tx.esterror);
- printflags(adjtimex_status, tx.status, "STA_???");
- tprintf(", constant=%d, precision=%u, ",
- tx.constant, tx.precision);
- tprintf("tolerance=%d, time=", tx.tolerance);
- tprint_timeval32(tcp, &tx.time);
- tprintf(", tick=%d, ppsfreq=%d, jitter=%d",
- tx.tick, tx.ppsfreq, tx.jitter);
- tprintf(", shift=%d, stabil=%d, jitcnt=%d",
- tx.shift, tx.stabil, tx.jitcnt);
- tprintf(", calcnt=%d, errcnt=%d, stbcnt=%d",
- tx.calcnt, tx.errcnt, tx.stbcnt);
- tprints("}");
- return 0;
-}
-#endif /* SUPPORTED_PERSONALITIES > 1 */
+#include MPERS_DEFS
-static void
-tprint_timeval(struct tcb *tcp, const struct timeval *tv)
-{
- tprintf("{%ju, %ju}", (uintmax_t) tv->tv_sec, (uintmax_t) tv->tv_usec);
-}
+#include "xlat/adjtimex_modes.h"
+#include "xlat/adjtimex_status.h"
-int
-tprint_timex(struct tcb *tcp, long addr)
+MPERS_PRINTER_DECL(int, print_timex, struct tcb *tcp, const long addr)
{
- struct timex tx;
+ struct_timex tx;
-#if SUPPORTED_PERSONALITIES > 1
- if (current_time_t_is_compat)
- return tprint_timex32(tcp, addr);
-#endif
if (umove_or_printaddr(tcp, addr, &tx))
return -1;
(intmax_t) tx.offset, (intmax_t) tx.freq,
(uintmax_t) tx.maxerror, (uintmax_t) tx.esterror);
printflags(adjtimex_status, tx.status, "STA_???");
- tprintf(", constant=%jd, precision=%ju, tolerance=%jd, time=",
+ tprintf(", constant=%jd, precision=%ju, tolerance=%jd",
(intmax_t) tx.constant, (uintmax_t) tx.precision,
(intmax_t) tx.tolerance);
- tprint_timeval(tcp, &tx.time);
+ tprintf(", time={%jd, %jd}",
+ (intmax_t) tx.time.tv_sec, (intmax_t) tx.time.tv_usec);
tprintf(", tick=%jd, ppsfreq=%jd, jitter=%jd",
(intmax_t) tx.tick, (intmax_t) tx.ppsfreq, (intmax_t) tx.jitter);
tprintf(", shift=%d, stabil=%jd, jitcnt=%jd",
tx.shift, (intmax_t) tx.stabil, (intmax_t) tx.jitcnt);
tprintf(", calcnt=%jd, errcnt=%jd, stbcnt=%jd",
(intmax_t) tx.calcnt, (intmax_t) tx.errcnt, (intmax_t) tx.stbcnt);
+#ifdef HAVE_STRUCT_TIMEX_TAI
+ tprintf(", tai=%d", tx.tai);
+#endif
tprints("}");
return 0;
}