]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/test/test-sizeof.c
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / test / test-sizeof.c
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
fed527aa
ZJS
2/***
3 This file is part of systemd.
4
5 Copyright 2016 Zbigniew Jędrzejewski-Szmek
6
7 systemd is free software; you can redistribute it and/or modify it
8 under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation; either version 2.1 of the License, or
10 (at your option) any later version.
11
12 systemd is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with systemd; If not, see <http://www.gnu.org/licenses/>.
19***/
20
61d1a5a2
ZJS
21#include <stdio.h>
22
fed527aa
ZJS
23#include "time-util.h"
24
25/* Print information about various types. Useful when diagnosing
26 * gcc diagnostics on an unfamiliar architecture. */
27
28#pragma GCC diagnostic ignored "-Wtype-limits"
29
30#define info(t) \
61d1a5a2
ZJS
31 printf("%s → %zu bits%s\n", STRINGIFY(t), \
32 sizeof(t)*CHAR_BIT, \
33 strstr(STRINGIFY(t), "signed") ? "" : \
34 ((t)-1 < (t)0 ? ", signed" : ", unsigned"));
fed527aa 35
26e1f724
ZJS
36enum Enum {
37 enum_value,
38};
39
40enum BigEnum {
41 big_enum_value = UINT64_C(-1),
42};
43
fed527aa
ZJS
44int main(void) {
45 info(char);
46 info(signed char);
47 info(unsigned char);
48 info(short unsigned);
49 info(unsigned);
50 info(long unsigned);
51 info(long long unsigned);
0c183e96
ZJS
52 info(__syscall_ulong_t);
53 info(__syscall_slong_t);
fed527aa
ZJS
54
55 info(float);
56 info(double);
57 info(long double);
58
59 info(size_t);
60 info(ssize_t);
61 info(time_t);
62 info(usec_t);
0c183e96 63 info(__time_t);
98d93199
ZJS
64 info(pid_t);
65 info(gid_t);
fed527aa 66
26e1f724
ZJS
67 info(enum Enum);
68 info(enum BigEnum);
69
fed527aa
ZJS
70 return 0;
71}