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