OpenMPI 0.1.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

opal_stdint.h
1 /*
2 * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
3 * University Research and Technology
4 * Corporation. All rights reserved.
5 * Copyright (c) 2004-2005 The University of Tennessee and The University
6 * of Tennessee Research Foundation. All rights
7 * reserved.
8 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9 * University of Stuttgart. All rights reserved.
10 * Copyright (c) 2004-2005 The Regents of the University of California.
11 * All rights reserved.
12 * $COPYRIGHT$
13 *
14 * Additional copyrights may follow
15 *
16 * $HEADER$
17 *
18 * This file includes the C99 stdint.h file if available, and otherwise
19 * defines fixed-width types according to the SIZEOF information
20 * gathered by configure.
21 */
22
23 #ifndef OPAL_STDINT_H
24 #define OPAL_STDINT_H 1
25
26 /*
27 * Include what we can and define what is missing.
28 */
29 #include <limits.h>
30
31 #ifdef HAVE_SYS_TYPES_H
32 #include <sys/types.h>
33 #endif
34
35 /* 8-bit */
36
37 #if SIZEOF_CHAR == 1
38
39 #ifndef HAVE_INT8_T
40 typedef signed char int8_t;
41 #endif
42
43 #ifndef HAVE_UINT8_T
44 typedef unsigned char uint8_t;
45 #endif
46
47 #else
48
49 #error Failed to define 8-bit types
50
51 #endif
52
53 /* 16-bit */
54
55 #if SIZEOF_SHORT == 2
56
57 #ifndef HAVE_INT16_T
58 typedef signed short int16_t;
59 #endif
60
61 #ifndef HAVE_UINT16_T
62 typedef unsigned short uint16_t;
63 #endif
64
65 #else
66
67 #error Failed to define 16-bit types
68
69 #endif
70
71 /* 32-bit */
72
73 #if SIZEOF_INT == 4
74
75 #ifndef HAVE_INT32_T
76 typedef signed int int32_t;
77 #endif
78
79 #ifndef HAVE_UINT32_T
80 typedef unsigned int uint32_t;
81 #endif
82
83 #elif SIZEOF_LONG == 4
84
85 #ifndef HAVE_INT32_T
86 typedef signed long int32_t;
87 #endif
88
89 #ifndef HAVE_UINT32_T
90 typedef unsigned long uint32_t;
91 #endif
92
93 #else
94
95 #error Failed to define 32-bit types
96
97 #endif
98
99 /* 64-bit */
100
101 #if SIZEOF_INT == 8
102
103 #ifndef HAVE_INT64_T
104 typedef signed int int64_t;
105 #endif
106
107 #ifndef HAVE_UINT64_T
108 typedef unsigned int uint64_t;
109 #endif
110
111 #elif SIZEOF_LONG == 8
112
113 #ifndef HAVE_INT64_T
114 typedef signed long int64_t;
115 #endif
116
117 #ifndef HAVE_UINT64_T
118 typedef unsigned long uint64_t;
119 #endif
120
121 #elif HAVE_LONG_LONG && SIZEOF_LONG_LONG == 8
122
123 #ifndef HAVE_INT64_T
124 typedef signed long long int64_t;
125 #endif
126
127 #ifndef HAVE_UINT64_T
128 typedef unsigned long long uint64_t;
129 #endif
130
131 #else
132
133 #error Failed to define 64-bit types
134
135 #endif
136
137 /* Pointers */
138
139 #if SIZEOF_VOID_P == SIZEOF_INT
140
141 #ifndef HAVE_INTPTR_T
142 typedef signed int intptr_t;
143 #endif
144
145 #ifndef HAVE_UINTPTR_T
146 typedef unsigned int uintptr_t;
147 #endif
148
149 #elif SIZEOF_VOID_P == SIZEOF_LONG
150
151 #ifndef HAVE_INTPTR_T
152 typedef signed long intptr_t;
153 #endif
154
155 #ifndef HAVE_UINTPTR_T
156 typedef unsigned long uintptr_t;
157 #endif
158
159 #elif HAVE_LONG_LONG && SIZEOF_VOID_P == SIZEOF_LONG_LONG
160
161 #ifndef HAVE_INTPTR_T
162 typedef signed long long intptr_t;
163 #endif
164 #ifndef HAVE_UINTPTR_T
165 typedef unsigned long long uintptr_t;
166 #endif
167
168 #else
169
170 #error Failed to define pointer-sized integer types
171
172 #endif
173
174 /* fix up some constants that may be missing */
175 #ifndef SIZE_MAX
176 # if SIZEOF_VOID_P == SIZEOF_INT
177 # define SIZE_MAX UINT_MAX
178 # elif SIZEOF_VOID_P == SIZEOF_LONG
179 # define SIZE_MAX ULONG_MAX
180 # else
181 # error Failed to find value for SIZE_MAX
182 # endif
183 #endif /* ifndef SIZE_MAX */
184
185
186 /* inttypes.h printf specifiers */
187 #ifdef HAVE_INTTYPES_H
188 # include <inttypes.h>
189 #else
190
191 # if SIZEOF_LONG == 8
192 # define __PRI64_PREFIX "l"
193 # define __PRIPTR_PREFIX "l"
194 # else
195 # define __PRI64_PREFIX "ll"
196 # define __PRIPTR_PREFIX
197 # endif
198
199 /* Decimal notation. */
200 # define PRId8 "d"
201 # define PRId16 "d"
202 # define PRId32 "d"
203 # define PRId64 __PRI64_PREFIX "d"
204
205 # define PRIdLEAST8 "d"
206 # define PRIdLEAST16 "d"
207 # define PRIdLEAST32 "d"
208 # define PRIdLEAST64 __PRI64_PREFIX "d"
209
210 # define PRIdFAST8 "d"
211 # define PRIdFAST16 __PRIPTR_PREFIX "d"
212 # define PRIdFAST32 __PRIPTR_PREFIX "d"
213 # define PRIdFAST64 __PRI64_PREFIX "d"
214
215 # define PRIi8 "i"
216 # define PRIi16 "i"
217 # define PRIi32 "i"
218 # define PRIi64 __PRI64_PREFIX "i"
219
220 # define PRIiLEAST8 "i"
221 # define PRIiLEAST16 "i"
222 # define PRIiLEAST32 "i"
223 # define PRIiLEAST64 __PRI64_PREFIX "i"
224
225 # define PRIiFAST8 "i"
226 # define PRIiFAST16 __PRIPTR_PREFIX "i"
227 # define PRIiFAST32 __PRIPTR_PREFIX "i"
228 # define PRIiFAST64 __PRI64_PREFIX "i"
229
230 /* Octal notation. */
231 # define PRIo8 "o"
232 # define PRIo16 "o"
233 # define PRIo32 "o"
234 # define PRIo64 __PRI64_PREFIX "o"
235
236 # define PRIoLEAST8 "o"
237 # define PRIoLEAST16 "o"
238 # define PRIoLEAST32 "o"
239 # define PRIoLEAST64 __PRI64_PREFIX "o"
240
241 # define PRIoFAST8 "o"
242 # define PRIoFAST16 __PRIPTR_PREFIX "o"
243 # define PRIoFAST32 __PRIPTR_PREFIX "o"
244 # define PRIoFAST64 __PRI64_PREFIX "o"
245
246 /* Unsigned integers. */
247 # define PRIu8 "u"
248 # define PRIu16 "u"
249 # define PRIu32 "u"
250 # define PRIu64 __PRI64_PREFIX "u"
251
252 # define PRIuLEAST8 "u"
253 # define PRIuLEAST16 "u"
254 # define PRIuLEAST32 "u"
255 # define PRIuLEAST64 __PRI64_PREFIX "u"
256
257 # define PRIuFAST8 "u"
258 # define PRIuFAST16 __PRIPTR_PREFIX "u"
259 # define PRIuFAST32 __PRIPTR_PREFIX "u"
260 # define PRIuFAST64 __PRI64_PREFIX "u"
261
262 /* lowercase hexadecimal notation. */
263 # define PRIx8 "x"
264 # define PRIx16 "x"
265 # define PRIx32 "x"
266 # define PRIx64 __PRI64_PREFIX "x"
267
268 # define PRIxLEAST8 "x"
269 # define PRIxLEAST16 "x"
270 # define PRIxLEAST32 "x"
271 # define PRIxLEAST64 __PRI64_PREFIX "x"
272
273 # define PRIxFAST8 "x"
274 # define PRIxFAST16 __PRIPTR_PREFIX "x"
275 # define PRIxFAST32 __PRIPTR_PREFIX "x"
276 # define PRIxFAST64 __PRI64_PREFIX "x"
277
278 /* UPPERCASE hexadecimal notation. */
279 # define PRIX8 "X"
280 # define PRIX16 "X"
281 # define PRIX32 "X"
282 # define PRIX64 __PRI64_PREFIX "X"
283
284 # define PRIXLEAST8 "X"
285 # define PRIXLEAST16 "X"
286 # define PRIXLEAST32 "X"
287 # define PRIXLEAST64 __PRI64_PREFIX "X"
288
289 # define PRIXFAST8 "X"
290 # define PRIXFAST16 __PRIPTR_PREFIX "X"
291 # define PRIXFAST32 __PRIPTR_PREFIX "X"
292 # define PRIXFAST64 __PRI64_PREFIX "X"
293
294 /* Macros for printing `intmax_t' and `uintmax_t'. */
295 # define PRIdMAX __PRI64_PREFIX "d"
296 # define PRIiMAX __PRI64_PREFIX "i"
297 # define PRIoMAX __PRI64_PREFIX "o"
298 # define PRIuMAX __PRI64_PREFIX "u"
299 # define PRIxMAX __PRI64_PREFIX "x"
300 # define PRIXMAX __PRI64_PREFIX "X"
301
302 /* Macros for printing `intptr_t' and `uintptr_t'. */
303 # define PRIdPTR __PRIPTR_PREFIX "d"
304 # define PRIiPTR __PRIPTR_PREFIX "i"
305 # define PRIoPTR __PRIPTR_PREFIX "o"
306 # define PRIuPTR __PRIPTR_PREFIX "u"
307 # define PRIxPTR __PRIPTR_PREFIX "x"
308 # define PRIXPTR __PRIPTR_PREFIX "X"
309
310 #endif
311
312 #ifndef PRIsize_t
313 # if defined(ACCEPT_C99)
314 # define PRIsize_t "zu"
315 # elif SIZEOF_SIZE_T == SIZEOF_LONG
316 # define PRIsize_t "lu"
317 # elif SIZEOF_SIZE_T == SIZEOF_LONG_LONG
318 # define PRIsize_t "llu"
319 # else
320 # define PRIsize_t "u"
321 # endif
322 #endif
323
324 #endif /* OPAL_STDINT_H */
325