]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
fed527aa | 2 | |
0985c7c4 | 3 | #include <sched.h> |
61d1a5a2 | 4 | #include <stdio.h> |
dccca82b | 5 | #include <string.h> |
61d1a5a2 | 6 | |
54781add ZJS |
7 | #define __STDC_WANT_IEC_60559_TYPES_EXT__ |
8 | #include <float.h> | |
9 | ||
fed527aa ZJS |
10 | #include "time-util.h" |
11 | ||
12 | /* Print information about various types. Useful when diagnosing | |
13 | * gcc diagnostics on an unfamiliar architecture. */ | |
14 | ||
15 | #pragma GCC diagnostic ignored "-Wtype-limits" | |
16 | ||
23cfbcc3 ZJS |
17 | #define info(t) \ |
18 | printf("%s → %zu bits%s, %zu byte alignment\n", STRINGIFY(t), \ | |
19 | sizeof(t)*CHAR_BIT, \ | |
20 | strstr(STRINGIFY(t), "signed") ? "" : \ | |
21 | (t)-1 < (t)0 ? ", signed" : ", unsigned", \ | |
22 | __alignof__(t)) | |
fed527aa | 23 | |
26e1f724 ZJS |
24 | enum Enum { |
25 | enum_value, | |
26 | }; | |
27 | ||
28 | enum BigEnum { | |
994282d2 ZJS |
29 | big_enum_value = UINT64_C(1), |
30 | }; | |
31 | ||
32 | enum BigEnum2 { | |
33 | big_enum2_pos = UINT64_C(1), | |
34 | big_enum2_neg = UINT64_C(-1), | |
26e1f724 ZJS |
35 | }; |
36 | ||
fed527aa ZJS |
37 | int main(void) { |
38 | info(char); | |
39 | info(signed char); | |
40 | info(unsigned char); | |
41 | info(short unsigned); | |
42 | info(unsigned); | |
43 | info(long unsigned); | |
44 | info(long long unsigned); | |
0c183e96 ZJS |
45 | info(__syscall_ulong_t); |
46 | info(__syscall_slong_t); | |
fed527aa ZJS |
47 | |
48 | info(float); | |
49 | info(double); | |
50 | info(long double); | |
51 | ||
54781add | 52 | #ifdef FLT128_MAX |
e07d3893 ZJS |
53 | info(_Float128); |
54 | info(_Float64); | |
55 | info(_Float64x); | |
56 | info(_Float32); | |
57 | info(_Float32x); | |
58 | #endif | |
59 | ||
fed527aa ZJS |
60 | info(size_t); |
61 | info(ssize_t); | |
62 | info(time_t); | |
63 | info(usec_t); | |
0c183e96 | 64 | info(__time_t); |
98d93199 | 65 | info(pid_t); |
85f8fa4d | 66 | info(uid_t); |
98d93199 | 67 | info(gid_t); |
fed527aa | 68 | |
0985c7c4 ZJS |
69 | info(__cpu_mask); |
70 | ||
26e1f724 ZJS |
71 | info(enum Enum); |
72 | info(enum BigEnum); | |
994282d2 ZJS |
73 | info(enum BigEnum2); |
74 | assert_cc(sizeof(enum BigEnum2) == 8); | |
75 | printf("big_enum2_pos → %zu\n", sizeof(big_enum2_pos)); | |
76 | printf("big_enum2_neg → %zu\n", sizeof(big_enum2_neg)); | |
26e1f724 | 77 | |
fed527aa ZJS |
78 | return 0; |
79 | } |