]> pd.if.org Git - pdclib/blob - includes/stdint.h
PDCLib includes with quotes, not <>.
[pdclib] / includes / stdint.h
1 /* Integer types <stdint.h>
2
3    This file is part of the Public Domain C Library (PDCLib).
4    Permission is granted to use, modify, and / or redistribute at will.
5 */
6
7 #ifndef _PDCLIB_STDINT_H
8 #define _PDCLIB_STDINT_H _PDCLIB_STDINT_H
9 #include "_PDCLIB_int.h"
10
11 /* Exact-width integer types. */
12
13 typedef _PDCLIB_int8_t  int8_t;
14 typedef _PDCLIB_int16_t int16_t;
15 typedef _PDCLIB_int32_t int32_t;
16 typedef _PDCLIB_int64_t int64_t;
17
18 typedef _PDCLIB_uint8_t  uint8_t;
19 typedef _PDCLIB_uint16_t uint16_t;
20 typedef _PDCLIB_uint32_t uint32_t;
21 typedef _PDCLIB_uint64_t uint64_t;
22
23 /* Minimum-width integer types */
24
25 /* You are allowed to add more types here, e.g. int_least24_t. For the standard
26    types, int_leastN_t is equivalent to the corresponding exact type intN_t by
27    definition.
28 */
29
30 typedef _PDCLIB_int8_t  int_least8_t;
31 typedef _PDCLIB_int16_t int_least16_t;
32 typedef _PDCLIB_int32_t int_least32_t;
33 typedef _PDCLIB_int64_t int_least64_t;
34
35 typedef _PDCLIB_uint8_t  uint_least8_t;
36 typedef _PDCLIB_uint16_t uint_least16_t;
37 typedef _PDCLIB_uint32_t uint_least32_t;
38 typedef _PDCLIB_uint64_t uint_least64_t;
39
40 /* Fastest minimum-width integer types */
41
42 /* You are allowed to add more types here, e.g. int_fast24_t. */
43
44 typedef _PDCLIB_int_fast8_t  int_fast8_t;
45 typedef _PDCLIB_int_fast16_t int_fast16_t;
46 typedef _PDCLIB_int_fast32_t int_fast32_t;
47 typedef _PDCLIB_int_fast64_t int_fast64_t;
48
49 typedef _PDCLIB_uint_fast8_t  uint_fast8_t;
50 typedef _PDCLIB_uint_fast16_t uint_fast16_t;
51 typedef _PDCLIB_uint_fast32_t uint_fast32_t;
52 typedef _PDCLIB_uint_fast64_t uint_fast64_t;
53
54 /* Integer types capable of holding object pointers */
55
56 typedef _PDCLIB_intptr_t  intptr_t;
57 typedef _PDCLIB_uintptr_t uintptr_t;
58
59 /* Greatest-width integer types */
60
61 typedef _PDCLIB_intmax_t  intmax_t;
62 typedef _PDCLIB_uintmax_t uintmax_t;
63
64 /* Limits of specified-width integer types */
65
66 #ifdef __cplusplus
67 #ifndef __STDC_LIMIT_MACROS
68 #define _PDCLIB_NO_LIMIT_MACROS
69 #endif
70 #endif
71
72 #ifndef _PDCLIB_NO_LIMIT_MACROS
73
74 /* Limits of exact-width integer types */
75
76 #define INT8_MIN  _PDCLIB_INT8_MIN
77 #define INT8_MAX  _PDCLIB_INT8_MAX
78 #define UINT8_MAX _PDCLIB_UINT8_MAX
79
80 #define INT16_MIN  _PDCLIB_INT16_MIN
81 #define INT16_MAX  _PDCLIB_INT16_MAX
82 #define UINT16_MAX _PDCLIB_UINT16_MAX
83
84 #define INT32_MIN  _PDCLIB_INT32_MIN
85 #define INT32_MAX  _PDCLIB_INT32_MAX
86 #define UINT32_MAX _PDCLIB_UINT32_MAX
87
88 #define INT64_MIN  _PDCLIB_INT64_MIN
89 #define INT64_MAX  _PDCLIB_INT64_MAX
90 #define UINT64_MAX _PDCLIB_UINT64_MAX
91
92 /* Limits of minimum-width integer types */
93
94 /* For the standard widths, least and exact types are equivalent.
95    You are allowed to add more types here, e.g. int_least24_t.
96 */
97
98 #define INT_LEAST8_MIN  INT8_MIN
99 #define INT_LEAST8_MAX  INT8_MAX
100 #define UINT_LEAST8_MAX UINT8_MAX
101
102 #define INT_LEAST16_MIN  INT16_MIN
103 #define INT_LEAST16_MAX  INT16_MAX
104 #define UINT_LEAST16_MAX UINT16_MAX
105
106 #define INT_LEAST32_MIN  INT32_MIN
107 #define INT_LEAST32_MAX  INT32_MAX
108 #define UINT_LEAST32_MAX UINT32_MAX
109
110 #define INT_LEAST64_MIN  INT64_MIN
111 #define INT_LEAST64_MAX  INT64_MAX
112 #define UINT_LEAST64_MAX UINT64_MAX
113
114 /* Limits of fastest minimum-width integer types */
115
116 #define INT_FAST8_MIN  _PDCLIB_INT_FAST8_MIN
117 #define INT_FAST8_MAX  _PDCLIB_INT_FAST8_MAX
118 #define UINT_FAST8_MAX _PDCLIB_UINT_FAST8_MAX
119
120 #define INT_FAST16_MIN  _PDCLIB_INT_FAST16_MIN
121 #define INT_FAST16_MAX  _PDCLIB_INT_FAST16_MAX
122 #define UINT_FAST16_MAX _PDCLIB_UINT_FAST16_MAX
123
124 #define INT_FAST32_MIN  _PDCLIB_INT_FAST32_MIN
125 #define INT_FAST32_MAX  _PDCLIB_INT_FAST32_MAX
126 #define UINT_FAST32_MAX _PDCLIB_UINT_FAST32_MAX
127
128 #define INT_FAST64_MIN  _PDCLIB_INT_FAST64_MIN
129 #define INT_FAST64_MAX  _PDCLIB_INT_FAST64_MAX
130 #define UINT_FAST64_MAX _PDCLIB_UINT_FAST64_MAX
131
132 /* Limits of integer types capable of holding object pointers */
133
134 #define INTPTR_MIN  _PDCLIB_INTPTR_MIN
135 #define INTPTR_MAX  _PDCLIB_INTPTR_MAX
136 #define UINTPTR_MAX _PDCLIB_UINTPTR_MAX
137
138 /* Limits of greatest-width integer types */
139
140 #define INTMAX_MIN  _PDCLIB_INTMAX_MIN
141 #define INTMAX_MAX  _PDCLIB_INTMAX_MAX
142 #define UINTMAX_MAX _PDCLIB_UINTMAX_MAX
143
144 /* Limits of other integer types */
145
146 #define PTRDIFF_MIN _PDCLIB_PTRDIFF_MIN
147 #define PTRDIFF_MAX _PDCLIB_PTRDIFF_MAX
148
149 #define SIG_ATOMIC_MIN _PDCLIB_SIG_ATOMIC_MIN
150 #define SIG_ATOMIC_MAX _PDCLIB_SIG_ATOMIC_MAX
151
152 #define SIZE_MAX _PDCLIB_SIZE_MAX
153
154 #ifndef _PDCLIB_WCHAR_MIN_MAX_DEFINED
155 #define _PDCLIB_WCHAR_MIN_MAX_DEFINED
156 #define WCHAR_MIN _PDCLIB_WCHAR_MIN
157 #define WCHAR_MAX _PDCLIB_WCHAR_MAX
158 #endif
159
160 #define WINT_MIN _PDCLIB_WINT_MIN
161 #define WINT_MAX _PDCLIB_WINT_MAX
162
163 #endif
164
165 /* Macros for integer constants */
166
167 #ifdef __cplusplus
168 #ifndef __STDC_CONSTANT_MACROS
169 #define _PDCLIB_NO_CONSTANT_MACROS
170 #endif
171 #endif
172
173 #ifndef _PDCLIB_NO_CONSTANT_MACROS
174
175 /* Macros for minimum-width integer constants */
176
177 /* As the minimum-width types - for the required widths of 8, 16, 32, and 64
178    bits - are expressed in terms of the exact-width types, the mechanism for
179    these macros is to append the literal of that exact-width type to the macro
180    parameter.
181    This is considered a hack, as the author is not sure his understanding of
182    the requirements of this macro is correct. Any input appreciated.
183 */
184
185 /* Expand to an integer constant of specified value and type int_leastN_t */
186
187 #define INT8_C( value )  value
188 #define INT16_C( value ) value
189 #define INT32_C( value ) _PDCLIB_concat( value, _PDCLIB_INT32_LITERAL )
190 #define INT64_C( value ) _PDCLIB_concat( value, _PDCLIB_INT64_LITERAL )
191
192 /* Expand to an integer constant of specified value and type uint_leastN_t */
193
194 #define UINT8_C( value )  value
195 #define UINT16_C( value ) value
196 #define UINT32_C( value ) _PDCLIB_concat( value, _PDCLIB_UINT32_LITERAL )
197 #define UINT64_C( value ) _PDCLIB_concat( value, _PDCLIB_UINT64_LITERAL )
198
199 /* Macros for greatest-width integer constants */
200
201 /* Expand to an integer constant of specified value and type intmax_t */
202 #define INTMAX_C( value ) _PDCLIB_INTMAX_C( value )
203
204 /* Expand to an integer constant of specified value and type uintmax_t */
205 #define UINTMAX_C( value ) _PDCLIB_UINTMAX_C( value )
206
207 #endif
208
209 #endif