diff options
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/time-util.h | 3 | ||||
-rw-r--r-- | src/shared/util.h | 18 |
2 files changed, 20 insertions, 1 deletions
diff --git a/src/shared/time-util.h b/src/shared/time-util.h index 913821a6bd..96f2ec8fa3 100644 --- a/src/shared/time-util.h +++ b/src/shared/time-util.h @@ -27,6 +27,9 @@ typedef uint64_t usec_t; typedef uint64_t nsec_t; +#define NSEC_FMT "%" PRIu64 +#define USEC_FMT "%" PRIu64 + #include "macro.h" typedef struct dual_timestamp { diff --git a/src/shared/util.h b/src/shared/util.h index f6d2cedd88..d9720d0a36 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -42,6 +42,22 @@ #include <mntent.h> #include <sys/socket.h> +#if SIZEOF_PID_T == 4 +# define PID_FMT "%" PRIu32 +#elif SIZEOF_PID_T == 2 +# define PID_FMT "%" PRIu16 +#else +# error Unknown pid_t size +#endif + +#if SIZEOF_UID_T == 4 +# define UID_FMT "%" PRIu32 +#elif SIZEOF_UID_T == 2 +# define UID_FMT "%" PRIu16 +#else +# error Unknown uid_t size +#endif + #include "macro.h" #include "time-util.h" @@ -763,7 +779,7 @@ int unlink_noerrno(const char *path); pid_t _pid_ = (pid); \ char *_r_; \ _r_ = alloca(sizeof("/proc/") -1 + DECIMAL_STR_MAX(pid_t) + 1 + sizeof(field)); \ - sprintf(_r_, "/proc/%lu/" field, (unsigned long) _pid_); \ + sprintf(_r_, "/proc/"PID_FMT"/" field, _pid_); \ _r_; \ }) |