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