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