1 |
2 |
drasko |
/*
|
2 |
|
|
* Australian Public Licence B (OZPLB)
|
3 |
|
|
*
|
4 |
|
|
* Version 1-0
|
5 |
|
|
*
|
6 |
|
|
* Copyright (c) 2004 National ICT Australia
|
7 |
|
|
*
|
8 |
|
|
* All rights reserved.
|
9 |
|
|
*
|
10 |
|
|
* Developed by: Embedded, Real-time and Operating Systems Program (ERTOS)
|
11 |
|
|
* National ICT Australia
|
12 |
|
|
* http://www.ertos.nicta.com.au
|
13 |
|
|
*
|
14 |
|
|
* Permission is granted by National ICT Australia, free of charge, to
|
15 |
|
|
* any person obtaining a copy of this software and any associated
|
16 |
|
|
* documentation files (the "Software") to deal with the Software without
|
17 |
|
|
* restriction, including (without limitation) the rights to use, copy,
|
18 |
|
|
* modify, adapt, merge, publish, distribute, communicate to the public,
|
19 |
|
|
* sublicense, and/or sell, lend or rent out copies of the Software, and
|
20 |
|
|
* to permit persons to whom the Software is furnished to do so, subject
|
21 |
|
|
* to the following conditions:
|
22 |
|
|
*
|
23 |
|
|
* * Redistributions of source code must retain the above copyright
|
24 |
|
|
* notice, this list of conditions and the following disclaimers.
|
25 |
|
|
*
|
26 |
|
|
* * Redistributions in binary form must reproduce the above
|
27 |
|
|
* copyright notice, this list of conditions and the following
|
28 |
|
|
* disclaimers in the documentation and/or other materials provided
|
29 |
|
|
* with the distribution.
|
30 |
|
|
*
|
31 |
|
|
* * Neither the name of National ICT Australia, nor the names of its
|
32 |
|
|
* contributors, may be used to endorse or promote products derived
|
33 |
|
|
* from this Software without specific prior written permission.
|
34 |
|
|
*
|
35 |
|
|
* EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT
|
36 |
|
|
* PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND
|
37 |
|
|
* NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS,
|
38 |
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
39 |
|
|
* BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS
|
40 |
|
|
* REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE,
|
41 |
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT,
|
42 |
|
|
* THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF
|
43 |
|
|
* ERRORS, WHETHER OR NOT DISCOVERABLE.
|
44 |
|
|
*
|
45 |
|
|
* TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL
|
46 |
|
|
* NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL
|
47 |
|
|
* THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT,
|
48 |
|
|
* NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER
|
49 |
|
|
* LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR
|
50 |
|
|
* OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS
|
51 |
|
|
* OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR
|
52 |
|
|
* OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT,
|
53 |
|
|
* CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN
|
54 |
|
|
* CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER
|
55 |
|
|
* DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS
|
56 |
|
|
* CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS,
|
57 |
|
|
* DAMAGES OR OTHER LIABILITY.
|
58 |
|
|
*
|
59 |
|
|
* If applicable legislation implies representations, warranties, or
|
60 |
|
|
* conditions, or imposes obligations or liability on National ICT
|
61 |
|
|
* Australia or one of its contributors in respect of the Software that
|
62 |
|
|
* cannot be wholly or partly excluded, restricted or modified, the
|
63 |
|
|
* liability of National ICT Australia or the contributor is limited, to
|
64 |
|
|
* the full extent permitted by the applicable legislation, at its
|
65 |
|
|
* option, to:
|
66 |
|
|
* a. in the case of goods, any one or more of the following:
|
67 |
|
|
* i. the replacement of the goods or the supply of equivalent goods;
|
68 |
|
|
* ii. the repair of the goods;
|
69 |
|
|
* iii. the payment of the cost of replacing the goods or of acquiring
|
70 |
|
|
* equivalent goods;
|
71 |
|
|
* iv. the payment of the cost of having the goods repaired; or
|
72 |
|
|
* b. in the case of services:
|
73 |
|
|
* i. the supplying of the services again; or
|
74 |
|
|
* ii. the payment of the cost of having the services supplied again.
|
75 |
|
|
*
|
76 |
|
|
* The construction, validity and performance of this licence is governed
|
77 |
|
|
* by the laws in force in New South Wales, Australia.
|
78 |
|
|
*/
|
79 |
|
|
#ifndef _STDINT_H_
|
80 |
|
|
#define _STDINT_H_
|
81 |
|
|
|
82 |
|
|
#include <limits.h>
|
83 |
|
|
|
84 |
|
|
/*
|
85 |
|
|
* 7.18.1.1 Exact-width integers
|
86 |
|
|
*/
|
87 |
|
|
#include <arch/stdint.h>
|
88 |
|
|
|
89 |
|
|
/*
|
90 |
|
|
* 7.18.2.1 Limits of exact-wdith integer types
|
91 |
|
|
*/
|
92 |
|
|
#define INT8_MIN SCHAR_MIN
|
93 |
|
|
#define INT16_MIN SHRT_MIN
|
94 |
|
|
#define INT32_MIN INT_MIN
|
95 |
|
|
#define INT64_MIN LLONG_MIN
|
96 |
|
|
|
97 |
|
|
#define INT8_MAX SCHAR_MAX
|
98 |
|
|
#define INT16_MAX SHRT_MAX
|
99 |
|
|
#define INT32_MAX INT_MAX
|
100 |
|
|
#define INT64_MAX LLONG_MAX
|
101 |
|
|
|
102 |
|
|
#define UINT8_MAX UCHAR_MAX
|
103 |
|
|
#define UINT16_MAX USHRT_MAX
|
104 |
|
|
#define UINT32_MAX UINT_MAX
|
105 |
|
|
#define UINT64_MAX ULLONG_MAX
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
#ifndef __ARCH_HAS_LEAST
|
109 |
|
|
/*
|
110 |
|
|
* 7.18.1.2 Minimum-width integers
|
111 |
|
|
*/
|
112 |
|
|
typedef int8_t int_least8_t;
|
113 |
|
|
typedef int16_t int_least16_t;
|
114 |
|
|
typedef int32_t int_least32_t;
|
115 |
|
|
typedef int64_t int_least64_t;
|
116 |
|
|
|
117 |
|
|
typedef uint8_t uint_least8_t;
|
118 |
|
|
typedef uint16_t uint_least16_t;
|
119 |
|
|
typedef uint32_t uint_least32_t;
|
120 |
|
|
typedef uint64_t uint_least64_t;
|
121 |
|
|
|
122 |
|
|
/*
|
123 |
|
|
* 7.18.2.2 Limits of minimum-width integers
|
124 |
|
|
*/
|
125 |
|
|
#define INT_LEAST8_MIN INT8_MIN
|
126 |
|
|
#define INT_LEAST16_MIN INT16_MIN
|
127 |
|
|
#define INT_LEAST32_MIN INT32_MIN
|
128 |
|
|
#define INT_LEAST64_MIN INT64_MIN
|
129 |
|
|
|
130 |
|
|
#define INT_LEAST8_MAX INT8_MAX
|
131 |
|
|
#define INT_LEAST16_MAX INT16_MAX
|
132 |
|
|
#define INT_LEAST32_MAX INT32_MAX
|
133 |
|
|
#define INT_LEAST64_MAX INT64_MAX
|
134 |
|
|
|
135 |
|
|
#define UINT_LEAST8_MAX UINT8_MAX
|
136 |
|
|
#define UINT_LEAST16_MAX UINT16_MAX
|
137 |
|
|
#define UINT_LEAST32_MAX UINT32_MAX
|
138 |
|
|
#define UINT_LEAST64_MAX UINT64_MAX
|
139 |
|
|
#else
|
140 |
|
|
#undef __ARCH_HAS_LEAST
|
141 |
|
|
#endif
|
142 |
|
|
|
143 |
|
|
|
144 |
|
|
#ifndef __ARCH_HAS_FAST
|
145 |
|
|
/*
|
146 |
|
|
* 7.8.1.3 Fastest minimum-width integer types
|
147 |
|
|
* Note -- We fulfil the spec, however we don't really know
|
148 |
|
|
* which are fastest here. I assume `int' is probably fastest
|
149 |
|
|
* more most, and should be used for [u]int_fast[8,16,32]_t.
|
150 |
|
|
*/
|
151 |
|
|
|
152 |
|
|
typedef int8_t int_fast8_t;
|
153 |
|
|
typedef int16_t int_fast16_t;
|
154 |
|
|
typedef int32_t int_fast32_t;
|
155 |
|
|
typedef int64_t int_fast64_t;
|
156 |
|
|
|
157 |
|
|
typedef uint8_t uint_fast8_t;
|
158 |
|
|
typedef uint16_t uint_fast16_t;
|
159 |
|
|
typedef uint32_t uint_fast32_t;
|
160 |
|
|
typedef uint64_t uint_fast64_t;
|
161 |
|
|
|
162 |
|
|
/*
|
163 |
|
|
* 7.18.2.2 Limits of fastest minimum-width integers
|
164 |
|
|
*/
|
165 |
|
|
#define INT_FAST8_MIN INT8_MIN
|
166 |
|
|
#define INT_FAST16_MIN INT16_MIN
|
167 |
|
|
#define INT_FAST32_MIN INT32_MIN
|
168 |
|
|
#define INT_FAST64_MIN INT64_MIN
|
169 |
|
|
|
170 |
|
|
#define INT_FAST8_MAX INT8_MAX
|
171 |
|
|
#define INT_FAST16_MAX INT16_MAX
|
172 |
|
|
#define INT_FAST32_MAX INT32_MAX
|
173 |
|
|
#define INT_FAST64_MAX INT64_MAX
|
174 |
|
|
|
175 |
|
|
#define UINT_FAST8_MAX UINT8_MAX
|
176 |
|
|
#define UINT_FAST16_MAX UINT16_MAX
|
177 |
|
|
#define UINT_FAST32_MAX UINT32_MAX
|
178 |
|
|
#define UINT_FAST64_MAX UINT64_MAX
|
179 |
|
|
#else
|
180 |
|
|
#undef __ARCH_HAS_FAST
|
181 |
|
|
#endif
|
182 |
|
|
|
183 |
|
|
/*
|
184 |
|
|
* 7.18.1.4 Integer types capable of holding object pointers
|
185 |
|
|
* We should fix this to be 32/64 clean.
|
186 |
|
|
*/
|
187 |
|
|
#if __PTR_SIZE==32
|
188 |
|
|
typedef int32_t intptr_t;
|
189 |
|
|
typedef uint32_t uintptr_t;
|
190 |
|
|
|
191 |
|
|
#define INTPTR_MIN INT32_MIN
|
192 |
|
|
#define INTPTR_MAX INT32_MAX
|
193 |
|
|
#define UINTPTR_MAX UINT32_MAX
|
194 |
|
|
|
195 |
|
|
#elif __PTR_SIZE==64
|
196 |
|
|
typedef int64_t intptr_t;
|
197 |
|
|
typedef uint64_t uintptr_t;
|
198 |
|
|
|
199 |
|
|
#define INTPTR_MIN INT64_MIN
|
200 |
|
|
#define INTPTR_MAX INT64_MAX
|
201 |
|
|
#define UINTPTR_MAX UINT64_MAX
|
202 |
|
|
#else
|
203 |
|
|
#error Unknown pointer size
|
204 |
|
|
#endif
|
205 |
|
|
|
206 |
|
|
#undef __PTR_SIZE
|
207 |
|
|
|
208 |
|
|
/*
|
209 |
|
|
* 7.18.1.5 Greatest-wdith integer types
|
210 |
|
|
*/
|
211 |
|
|
typedef long long int intmax_t;
|
212 |
|
|
typedef unsigned long long int uintmax_t;
|
213 |
|
|
|
214 |
|
|
/*
|
215 |
|
|
* 7.18.2.5 Limits of greateast-width integer types
|
216 |
|
|
*/
|
217 |
|
|
#define INTMAX_MIN LLONG_MIN
|
218 |
|
|
#define INTMAX_MAX LLONG_MAX
|
219 |
|
|
#define UINTMAX_MAX ULLONG_MAX
|
220 |
|
|
|
221 |
|
|
/*
|
222 |
|
|
* 7.18.3 Limits of other integer types
|
223 |
|
|
*/
|
224 |
|
|
/* FIXME: Check these limits are correct */
|
225 |
|
|
#define PTRDIFF_MIN INTPTR_MIN
|
226 |
|
|
#define PTRDIFF_MAX INTPTR_MAX
|
227 |
|
|
|
228 |
|
|
#define SIG_ATOMIC_MIN INT_MIN
|
229 |
|
|
#define SIG_ATOMIC_MAX INT_MAX
|
230 |
|
|
|
231 |
|
|
#define SIZE_MAX UINTPTR_MAX
|
232 |
|
|
|
233 |
|
|
#define WCHAR_MIN 0
|
234 |
|
|
#define WCHAR_MAX UINT16_MAX
|
235 |
|
|
|
236 |
|
|
#define WINT_MIN 0
|
237 |
|
|
#define WINT_MAX UINT16_MAX
|
238 |
|
|
|
239 |
|
|
/*
|
240 |
|
|
* 7.18.4 Macros for integer constants
|
241 |
|
|
*/
|
242 |
|
|
|
243 |
|
|
#define INT8_C(x) (int8_t)(x)
|
244 |
|
|
#define INT16_C(x) (int16_t)(x)
|
245 |
|
|
#define INT32_C(x) (int32_t)(x)
|
246 |
|
|
#define INT64_C(x) (int64_t)(x)
|
247 |
|
|
#define UINT8_C(x) (uint8_t)(x)
|
248 |
|
|
#define UINT16_C(x) (uint16_t)(x)
|
249 |
|
|
#define UINT32_C(x) (uint32_t)(x)
|
250 |
|
|
#define UINT64_C(x) (uint64_t)(x)
|
251 |
|
|
|
252 |
|
|
#define INT_FAST8_C(x) (int_fast8_t)(x)
|
253 |
|
|
#define INT_FAST16_C(x) (int_fast16_t)(x)
|
254 |
|
|
#define INT_FAST32_C(x) (int_fast32_t)(x)
|
255 |
|
|
#define INT_FAST64_C(x) (int_fast64_t)(x)
|
256 |
|
|
#define UINT_FAST8_C(x) (uint_fast8_t)(x)
|
257 |
|
|
#define UINT_FAST16_C(x) (uint_fast16_t)(x)
|
258 |
|
|
#define UINT_FAST32_C(x) (uint_fast32_t)(x)
|
259 |
|
|
#define UINT_FAST64_C(x) (uint_fast64_t)(x)
|
260 |
|
|
|
261 |
|
|
#define INT_LEAST8_C(x) (int_least8_t)(x)
|
262 |
|
|
#define INT_LEAST16_C(x) (int_least16_t)(x)
|
263 |
|
|
#define INT_LEAST32_C(x) (int_least32_t)(x)
|
264 |
|
|
#define INT_LEAST64_C(x) (int_least64_t)(x)
|
265 |
|
|
#define UINT_LEAST8_C(x) (uint_least8_t)(x)
|
266 |
|
|
#define UINT_LEAST16_C(x) (uint_least16_t)(x)
|
267 |
|
|
#define UINT_LEAST32_C(x) (uint_least32_t)(x)
|
268 |
|
|
#define UINT_LEAST64_C(x) (uint_least64_t)(x)
|
269 |
|
|
|
270 |
|
|
#define INTPTR_C(x) (intptr_t)(x)
|
271 |
|
|
#define UINTPTR_C(x) (uintptr_t)(x)
|
272 |
|
|
|
273 |
|
|
#define INTMAX_C(x) (intmax_t)(x)
|
274 |
|
|
#define UINTMAX_C(x) (uintmax_t)(x)
|
275 |
|
|
|
276 |
|
|
#endif /* _STDINT_H_ */
|