diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2016-11-07 11:49:25 -0500 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2017-07-17 17:58:35 +0200 |
commit | 02c8b7deae8dab578eea3cd59bb0f2c876669319 (patch) | |
tree | 4c8f9efb87db0f1ed62759dbc779f3003df4e12a | |
parent | 5e7ea707e798e8d56142e4b138781ca20007b0d2 (diff) |
tree-wide: add PRI_[NU]SEC, and use time format strings more
-rw-r--r-- | src/basic/time-util.c | 8 | ||||
-rw-r--r-- | src/basic/time-util.h | 6 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/basic/time-util.c b/src/basic/time-util.c index 245563684..7ee048425 100644 --- a/src/basic/time-util.c +++ b/src/basic/time-util.c @@ -315,7 +315,7 @@ static char *format_timestamp_internal( if (n + 8 > l) return NULL; /* Microseconds part doesn't fit. */ - sprintf(buf + n, ".%06llu", (unsigned long long) (t % USEC_PER_SEC)); + sprintf(buf + n, ".%06"PRI_USEC, t % USEC_PER_SEC); } /* Append the timezone */ @@ -509,11 +509,11 @@ char *format_timespan(char *buf, size_t l, usec_t t, usec_t accuracy) { if (j > 0) { k = snprintf(p, l, - "%s"USEC_FMT".%0*llu%s", + "%s"USEC_FMT".%0*"PRI_USEC"%s", p > buf ? " " : "", a, j, - (unsigned long long) b, + b, table[i].suffix); t = 0; @@ -1341,7 +1341,7 @@ unsigned long usec_to_jiffies(usec_t u) { r = sysconf(_SC_CLK_TCK); assert(r > 0); - hz = (unsigned long) r; + hz = r; } return DIV_ROUND_UP(u , USEC_PER_SEC / hz); diff --git a/src/basic/time-util.h b/src/basic/time-util.h index eab708c28..4485d7eb0 100644 --- a/src/basic/time-util.h +++ b/src/basic/time-util.h @@ -29,8 +29,10 @@ typedef uint64_t usec_t; typedef uint64_t nsec_t; -#define NSEC_FMT "%" PRIu64 -#define USEC_FMT "%" PRIu64 +#define PRI_NSEC PRIu64 +#define PRI_USEC PRIu64 +#define NSEC_FMT "%" PRI_NSEC +#define USEC_FMT "%" PRI_USEC #include "macro.h" |