This source file includes following definitions.
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include <config.h>
20
21 #include <limits.h>
22
23 #include "verify.h"
24
25 #if 4 < __GNUC__ + (3 <= __GNUC_MINOR__)
26 # pragma GCC diagnostic ignored "-Woverlength-strings"
27 #endif
28
29 #define verify_width(width, min, max) \
30 verify ((max) >> ((width) - 1 - ((min) < 0)) == 1)
31
32
33 #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
34 #define TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT)
35 #define TYPE_MINIMUM(t) ((t) ~ TYPE_MAXIMUM (t))
36 #define TYPE_MAXIMUM(t) \
37 ((t) (! TYPE_SIGNED (t) \
38 ? (t) -1 \
39 : ((((t) 1 << (TYPE_WIDTH (t) - 2)) - 1) * 2 + 1)))
40
41
42
43 int type_bits[] =
44 {
45 CHAR_BIT,
46 WORD_BIT,
47 LONG_BIT
48 };
49 verify_width (CHAR_BIT, CHAR_MIN, CHAR_MAX);
50 verify_width (WORD_BIT, INT_MIN, INT_MAX);
51 verify_width (LONG_BIT, LONG_MIN, LONG_MAX);
52
53
54
55 char limits1[] = { CHAR_MIN, CHAR_MAX };
56 verify (TYPE_MINIMUM (char) == CHAR_MIN);
57 verify (TYPE_MAXIMUM (char) == CHAR_MAX);
58
59 signed char limits2[] = { SCHAR_MIN, SCHAR_MAX };
60 verify (TYPE_MINIMUM (signed char) == SCHAR_MIN);
61 verify (TYPE_MAXIMUM (signed char) == SCHAR_MAX);
62
63 unsigned char limits3[] = { UCHAR_MAX };
64 verify (TYPE_MINIMUM (unsigned char) == 0);
65 verify (TYPE_MAXIMUM (unsigned char) == UCHAR_MAX);
66
67 short limits4[] = { SHRT_MIN, SHRT_MAX };
68 verify (TYPE_MINIMUM (short int) == SHRT_MIN);
69 verify (TYPE_MAXIMUM (short int) == SHRT_MAX);
70
71 unsigned short limits5[] = { USHRT_MAX };
72 verify (TYPE_MINIMUM (unsigned short int) == 0);
73 verify (TYPE_MAXIMUM (unsigned short int) == USHRT_MAX);
74
75 int limits6[] = { INT_MIN, INT_MAX };
76 verify (TYPE_MINIMUM (int) == INT_MIN);
77 verify (TYPE_MAXIMUM (int) == INT_MAX);
78
79 unsigned int limits7[] = { UINT_MAX };
80 verify (TYPE_MINIMUM (unsigned int) == 0);
81 verify (TYPE_MAXIMUM (unsigned int) == UINT_MAX);
82
83 long limits8[] = { LONG_MIN, LONG_MAX };
84 verify (TYPE_MINIMUM (long int) == LONG_MIN);
85 verify (TYPE_MAXIMUM (long int) == LONG_MAX);
86
87 unsigned long limits9[] = { ULONG_MAX };
88 verify (TYPE_MINIMUM (unsigned long int) == 0);
89 verify (TYPE_MAXIMUM (unsigned long int) == ULONG_MAX);
90
91 long long limits10[] = { LLONG_MIN, LLONG_MAX };
92 verify (TYPE_MINIMUM (long long int) == LLONG_MIN);
93 verify (TYPE_MAXIMUM (long long int) == LLONG_MAX);
94
95 unsigned long long limits11[] = { ULLONG_MAX };
96 verify (TYPE_MINIMUM (unsigned long long int) == 0);
97 verify (TYPE_MAXIMUM (unsigned long long int) == ULLONG_MAX);
98
99
100
101 verify_width (CHAR_WIDTH, CHAR_MIN, CHAR_MAX);
102 verify_width (SCHAR_WIDTH, SCHAR_MIN, SCHAR_MAX);
103 verify_width (UCHAR_WIDTH, 0, UCHAR_MAX);
104 verify_width (SHRT_WIDTH, SHRT_MIN, SHRT_MAX);
105 verify_width (USHRT_WIDTH, 0, USHRT_MAX);
106 verify_width (INT_WIDTH, INT_MIN, INT_MAX);
107 verify_width (UINT_WIDTH, 0, UINT_MAX);
108 verify_width (LONG_WIDTH, LONG_MIN, LONG_MAX);
109 verify_width (ULONG_WIDTH, 0, ULONG_MAX);
110 verify_width (LLONG_WIDTH, LLONG_MIN, LLONG_MAX);
111 verify_width (ULLONG_WIDTH, 0, ULLONG_MAX);
112
113
114
115 int bool_attrs[] = { BOOL_MAX, BOOL_WIDTH };
116 verify (BOOL_MAX == (((1U << (BOOL_WIDTH - 1)) - 1) * 2) + 1);
117
118 int
119 main (void)
120 {
121 return 0;
122 }