]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/format-util.h
9925a5e9918dff24e5daa7573fe399f9c772ef30
[thirdparty/systemd.git] / src / basic / format-util.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 #include <inttypes.h>
5 #include <net/if.h>
6
7 #if SIZEOF_PID_T == 4
8 # define PID_PRI PRIi32
9 #elif SIZEOF_PID_T == 2
10 # define PID_PRI PRIi16
11 #else
12 # error Unknown pid_t size
13 #endif
14 #define PID_FMT "%" PID_PRI
15
16 #if SIZEOF_UID_T == 4
17 # define UID_FMT "%" PRIu32
18 #elif SIZEOF_UID_T == 2
19 # define UID_FMT "%" PRIu16
20 #else
21 # error Unknown uid_t size
22 #endif
23
24 #if SIZEOF_GID_T == 4
25 # define GID_FMT "%" PRIu32
26 #elif SIZEOF_GID_T == 2
27 # define GID_FMT "%" PRIu16
28 #else
29 # error Unknown gid_t size
30 #endif
31
32 #if SIZEOF_TIME_T == 8
33 # define PRI_TIME PRIi64
34 #elif SIZEOF_TIME_T == 4
35 # define PRI_TIME "li"
36 #else
37 # error Unknown time_t size
38 #endif
39
40 #if defined __x86_64__ && defined __ILP32__
41 # define PRI_TIMEX PRIi64
42 #else
43 # define PRI_TIMEX "li"
44 #endif
45
46 #if SIZEOF_RLIM_T == 8
47 # define RLIM_FMT "%" PRIu64
48 #elif SIZEOF_RLIM_T == 4
49 # define RLIM_FMT "%" PRIu32
50 #else
51 # error Unknown rlim_t size
52 #endif
53
54 #if SIZEOF_DEV_T == 8
55 # define DEV_FMT "%" PRIu64
56 #elif SIZEOF_DEV_T == 4
57 # define DEV_FMT "%" PRIu32
58 #else
59 # error Unknown dev_t size
60 #endif
61
62 #if SIZEOF_INO_T == 8
63 # define INO_FMT "%" PRIu64
64 #elif SIZEOF_INO_T == 4
65 # define INO_FMT "%" PRIu32
66 #else
67 # error Unknown ino_t size
68 #endif
69
70 char *format_ifname(int ifindex, char buf[static IF_NAMESIZE + 1]);