]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/test/test-sizeof.c
Merge pull request #4362 from poettering/journalbootlistfix
[thirdparty/systemd.git] / src / test / test-sizeof.c
CommitLineData
fed527aa
ZJS
1/***
2 This file is part of systemd.
3
4 Copyright 2016 Zbigniew Jędrzejewski-Szmek
5
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
10
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
18***/
19
20#include "log.h"
21#include "time-util.h"
22
23/* Print information about various types. Useful when diagnosing
24 * gcc diagnostics on an unfamiliar architecture. */
25
26#pragma GCC diagnostic ignored "-Wtype-limits"
27
28#define info(t) \
29 log_info("%s → %zu bits%s", STRINGIFY(t), \
30 sizeof(t)*CHAR_BIT, \
31 strstr(STRINGIFY(t), "signed") ? "" : \
32 ((t)-1 < (t)0 ? ", signed" : ", unsigned"));
33
34int main(void) {
35 info(char);
36 info(signed char);
37 info(unsigned char);
38 info(short unsigned);
39 info(unsigned);
40 info(long unsigned);
41 info(long long unsigned);
42
43 info(float);
44 info(double);
45 info(long double);
46
47 info(size_t);
48 info(ssize_t);
49 info(time_t);
50 info(usec_t);
51
52 return 0;
53}