From 3f7ad363fb4eaf2239db3edaceba965a801636e7 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Fri, 17 May 2019 16:16:29 +0000 Subject: [PATCH] print_timespec.h: parametrize TIMESPEC_T.tv_nsec This is going to be used to implement a parser of SO_TIMESTAMP_NEW control message. * print_timespec.h [!TIMESPEC_NSEC] (TIMESPEC_NSEC): Define to tv_sec. (TIMESPEC_TO_SEC_NSEC, timespec_fmt, print_timespec_t_utime): Use TIMESPEC_NSEC instead of tv_sec. --- print_timespec.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/print_timespec.h b/print_timespec.h index 9d759e05..9199d530 100644 --- a/print_timespec.h +++ b/print_timespec.h @@ -8,6 +8,10 @@ #include "xstring.h" +#ifndef TIMESPEC_NSEC +# define TIMESPEC_NSEC tv_nsec +#endif + #ifndef UTIME_NOW # define UTIME_NOW ((1l << 30) - 1l) #endif @@ -16,9 +20,11 @@ #endif #define TIMESPEC_TO_SEC_NSEC(t_) \ - ((long long) (t_)->tv_sec), zero_extend_signed_to_ull((t_)->tv_nsec) + ((long long) (t_)->tv_sec), \ + zero_extend_signed_to_ull((t_)->TIMESPEC_NSEC) -static const char timespec_fmt[] = "{tv_sec=%lld, tv_nsec=%llu}"; +static const char timespec_fmt[] = + "{tv_sec=%lld, " STRINGIFY_VAL(TIMESPEC_NSEC) "=%llu}"; static void print_sec_nsec(long long sec, unsigned long long nsec) @@ -110,7 +116,7 @@ SPRINT_TIMESPEC(struct tcb *const tcp, const kernel_ulong_t addr) static void print_timespec_t_utime(const TIMESPEC_T *t) { - switch (t->tv_nsec) { + switch (t->TIMESPEC_NSEC) { case UTIME_NOW: case UTIME_OMIT: if (xlat_verbose(xlat_verbosity) != XLAT_STYLE_ABBREV) @@ -119,7 +125,7 @@ print_timespec_t_utime(const TIMESPEC_T *t) break; (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE - ? tprints_comment : tprints)(t->tv_nsec == UTIME_NOW + ? tprints_comment : tprints)(t->TIMESPEC_NSEC == UTIME_NOW ? "UTIME_NOW" : "UTIME_OMIT"); break; default: -- 2.40.0