chiark / gitweb /
Merge pull request #3 from elogind/dev_v226-r1
[elogind.git] / src / shared / formats-util.h
1 #pragma once
2
3 /***
4   This file is part of systemd.
5
6   Copyright 2015 Ronny Chevalier
7
8   systemd is free software; you can redistribute it and/or modify it
9   under the terms of the GNU Lesser General Public License as published by
10   the Free Software Foundation; either version 2.1 of the License, or
11   (at your option) any later version.
12
13   systemd is distributed in the hope that it will be useful, but
14   WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16   Lesser General Public License for more details.
17
18   You should have received a copy of the GNU Lesser General Public License
19   along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 ***/
21
22 #include <inttypes.h>
23
24 #if SIZEOF_PID_T == 4
25 #  define PID_PRI PRIi32
26 #elif SIZEOF_PID_T == 2
27 #  define PID_PRI PRIi16
28 #else
29 #  error Unknown pid_t size
30 #endif
31 #define PID_FMT "%" PID_PRI
32
33 #if SIZEOF_UID_T == 4
34 #  define UID_FMT "%" PRIu32
35 #elif SIZEOF_UID_T == 2
36 #  define UID_FMT "%" PRIu16
37 #else
38 #  error Unknown uid_t size
39 #endif
40
41 #if SIZEOF_GID_T == 4
42 #  define GID_FMT "%" PRIu32
43 #elif SIZEOF_GID_T == 2
44 #  define GID_FMT "%" PRIu16
45 #else
46 #  error Unknown gid_t size
47 #endif
48
49 #if SIZEOF_TIME_T == 8
50 #  define PRI_TIME PRIi64
51 #elif SIZEOF_TIME_T == 4
52 #  define PRI_TIME PRIu32
53 #else
54 #  error Unknown time_t size
55 #endif
56
57 #if SIZEOF_RLIM_T == 8
58 #  define RLIM_FMT "%" PRIu64
59 #elif SIZEOF_RLIM_T == 4
60 #  define RLIM_FMT "%" PRIu32
61 #else
62 #  error Unknown rlim_t size
63 #endif