chiark / gitweb /
tree-wide: add PRI_[NU]SEC, and use time format strings more
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 7 Nov 2016 16:49:25 +0000 (11:49 -0500)
committerSven Eden <yamakuzure@gmx.net>
Mon, 17 Jul 2017 15:58:35 +0000 (17:58 +0200)
src/basic/time-util.c
src/basic/time-util.h

index 2455636843f8e80b13c0fa8f73ff42aa17fe581d..7ee0484258b17c54b49262466613f29fae1b67a6 100644 (file)
@@ -315,7 +315,7 @@ static char *format_timestamp_internal(
                 if (n + 8 > l)
                         return NULL; /* Microseconds part doesn't fit. */
 
                 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 */
         }
 
         /* 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,
 
                         if (j > 0) {
                                 k = snprintf(p, l,
-                                             "%s"USEC_FMT".%0*llu%s",
+                                             "%s"USEC_FMT".%0*"PRI_USEC"%s",
                                              p > buf ? " " : "",
                                              a,
                                              j,
                                              p > buf ? " " : "",
                                              a,
                                              j,
-                                             (unsigned long long) b,
+                                             b,
                                              table[i].suffix);
 
                                 t = 0;
                                              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);
                 r = sysconf(_SC_CLK_TCK);
 
                 assert(r > 0);
-                hz = (unsigned long) r;
+                hz = r;
         }
 
         return DIV_ROUND_UP(u , USEC_PER_SEC / hz);
         }
 
         return DIV_ROUND_UP(u , USEC_PER_SEC / hz);
index eab708c2817e7450ceccfc123ca0da27534728a4..4485d7eb0e3236e69c964497a5d5f0d28fa1ee87 100644 (file)
 typedef uint64_t usec_t;
 typedef uint64_t nsec_t;
 
 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"
 
 
 #include "macro.h"