]> git.lyx.org Git - lyx.git/blob - boost/boost/cstdint.hpp
update to boost 1.32.0
[lyx.git] / boost / boost / cstdint.hpp
1 //  boost cstdint.hpp header file  ------------------------------------------//
2
3 //  (C) Copyright Beman Dawes 1999. 
4 //  (C) Copyright Jens Mauer 2001  
5 //  (C) Copyright John Maddock 2001 
6 //  Distributed under the Boost
7 //  Software License, Version 1.0. (See accompanying file
8 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9
10 //  See http://www.boost.org/libs/integer for documentation.
11
12 //  Revision History
13 //   31 Oct 01  use BOOST_HAS_LONG_LONG to check for "long long" (Jens M.)
14 //   16 Apr 01  check LONGLONG_MAX when looking for "long long" (Jens Maurer)
15 //   23 Jan 01  prefer "long" over "int" for int32_t and intmax_t (Jens Maurer)
16 //   12 Nov 00  Merged <boost/stdint.h> (Jens Maurer)
17 //   23 Sep 00  Added INTXX_C macro support (John Maddock).
18 //   22 Sep 00  Better 64-bit support (John Maddock)
19 //   29 Jun 00  Reimplement to avoid including stdint.h within namespace boost
20 //    8 Aug 99  Initial version (Beman Dawes)
21
22
23 #ifndef BOOST_CSTDINT_HPP
24 #define BOOST_CSTDINT_HPP
25
26 #include <boost/config.hpp>
27
28
29 #ifdef BOOST_HAS_STDINT_H
30
31 // The following #include is an implementation artifact; not part of interface.
32 # ifdef __hpux
33 // HP-UX has a vaguely nice <stdint.h> in a non-standard location
34 #   include <inttypes.h>
35 #   ifdef __STDC_32_MODE__
36       // this is triggered with GCC, because it defines __cplusplus < 199707L
37 #     define BOOST_NO_INT64_T
38 #   endif 
39 # elif defined(__FreeBSD__) || defined(__IBMCPP__)
40 #   include <inttypes.h>
41 # else
42 #   include <stdint.h>
43 # endif
44
45 namespace boost
46 {
47
48   using ::int8_t;             
49   using ::int_least8_t;       
50   using ::int_fast8_t;        
51   using ::uint8_t;            
52   using ::uint_least8_t;      
53   using ::uint_fast8_t;       
54                      
55   using ::int16_t;            
56   using ::int_least16_t;      
57   using ::int_fast16_t;       
58   using ::uint16_t;           
59   using ::uint_least16_t;     
60   using ::uint_fast16_t;      
61                      
62   using ::int32_t;            
63   using ::int_least32_t;      
64   using ::int_fast32_t;       
65   using ::uint32_t;           
66   using ::uint_least32_t;     
67   using ::uint_fast32_t;      
68                      
69 # ifndef BOOST_NO_INT64_T
70
71   using ::int64_t;            
72   using ::int_least64_t;      
73   using ::int_fast64_t;       
74   using ::uint64_t;           
75   using ::uint_least64_t;     
76   using ::uint_fast64_t;      
77                      
78 # endif
79
80   using ::intmax_t;      
81   using ::uintmax_t;     
82
83 } // namespace boost
84
85 #elif defined(__FreeBSD__) && (__FreeBSD__ <= 4) || defined(__osf__)
86 // FreeBSD and Tru64 have an <inttypes.h> that contains much of what we need.
87 # include <inttypes.h>
88
89 namespace boost {
90
91   using ::int8_t;             
92   typedef int8_t int_least8_t;       
93   typedef int8_t int_fast8_t;        
94   using ::uint8_t;            
95   typedef uint8_t uint_least8_t;      
96   typedef uint8_t uint_fast8_t;       
97                      
98   using ::int16_t;            
99   typedef int16_t int_least16_t;      
100   typedef int16_t int_fast16_t;       
101   using ::uint16_t;           
102   typedef uint16_t uint_least16_t;     
103   typedef uint16_t uint_fast16_t;      
104                      
105   using ::int32_t;            
106   typedef int32_t int_least32_t;      
107   typedef int32_t int_fast32_t;       
108   using ::uint32_t;           
109   typedef uint32_t uint_least32_t;     
110   typedef uint32_t uint_fast32_t;      
111          
112 # ifndef BOOST_NO_INT64_T          
113
114   using ::int64_t;            
115   typedef int64_t int_least64_t;      
116   typedef int64_t int_fast64_t;       
117   using ::uint64_t;           
118   typedef uint64_t uint_least64_t;     
119   typedef uint64_t uint_fast64_t;      
120
121   typedef int64_t intmax_t;
122   typedef uint64_t uintmax_t;
123
124 # else
125
126   typedef int32_t intmax_t;
127   typedef uint32_t uintmax_t;
128
129 # endif
130
131 } // namespace boost
132
133 #else  // BOOST_HAS_STDINT_H
134
135 # include <boost/limits.hpp> // implementation artifact; not part of interface
136
137
138 namespace boost
139 {
140
141 //  These are fairly safe guesses for some 16-bit, and most 32-bit and 64-bit
142 //  platforms.  For other systems, they will have to be hand tailored.
143 //
144 //  Because the fast types are assumed to be the same as the undecorated types,
145 //  it may be possible to hand tailor a more efficient implementation.  Such
146 //  an optimization may be illusionary; on the Intel x86-family 386 on, for
147 //  example, byte arithmetic and load/stores are as fast as "int" sized ones.
148
149 //  8-bit types  ------------------------------------------------------------//
150
151 # if UCHAR_MAX == 0xff
152      typedef signed char     int8_t;
153      typedef signed char     int_least8_t;
154      typedef signed char     int_fast8_t;
155      typedef unsigned char   uint8_t;
156      typedef unsigned char   uint_least8_t;
157      typedef unsigned char   uint_fast8_t;
158 # else
159 #    error defaults not correct; you must hand modify boost/cstdint.hpp
160 # endif
161
162 //  16-bit types  -----------------------------------------------------------//
163
164 # if USHRT_MAX == 0xffff
165 #  if defined(__crayx1)
166      // The Cray X1 has a 16-bit short, however it is not recommend
167      // for use in performance critical code.
168      typedef short           int16_t;
169      typedef short           int_least16_t;
170      typedef int             int_fast16_t;
171      typedef unsigned short  uint16_t;
172      typedef unsigned short  uint_least16_t;
173      typedef unsigned int    uint_fast16_t;
174 #  else
175      typedef short           int16_t;
176      typedef short           int_least16_t;
177      typedef short           int_fast16_t;
178      typedef unsigned short  uint16_t;
179      typedef unsigned short  uint_least16_t;
180      typedef unsigned short  uint_fast16_t;
181 #  endif
182 # elif (USHRT_MAX == 0xffffffff) && defined(CRAY)
183      // no 16-bit types on Cray:
184      typedef short           int_least16_t;
185      typedef short           int_fast16_t;
186      typedef unsigned short  uint_least16_t;
187      typedef unsigned short  uint_fast16_t;
188 # else
189 #    error defaults not correct; you must hand modify boost/cstdint.hpp
190 # endif
191
192 //  32-bit types  -----------------------------------------------------------//
193
194 # if ULONG_MAX == 0xffffffff
195      typedef long            int32_t;
196      typedef long            int_least32_t;
197      typedef long            int_fast32_t;
198      typedef unsigned long   uint32_t;
199      typedef unsigned long   uint_least32_t;
200      typedef unsigned long   uint_fast32_t;
201 # elif UINT_MAX == 0xffffffff
202      typedef int             int32_t;
203      typedef int             int_least32_t;
204      typedef int             int_fast32_t;
205      typedef unsigned int    uint32_t;
206      typedef unsigned int    uint_least32_t;
207      typedef unsigned int    uint_fast32_t;
208 # else
209 #    error defaults not correct; you must hand modify boost/cstdint.hpp
210 # endif
211
212 //  64-bit types + intmax_t and uintmax_t  ----------------------------------//
213
214 # if defined(BOOST_HAS_LONG_LONG) && \
215    !defined(BOOST_MSVC) && !defined(__BORLANDC__) && \
216    (!defined(__GLIBCPP__) || defined(_GLIBCPP_USE_LONG_LONG)) && \
217    (defined(ULLONG_MAX) || defined(ULONG_LONG_MAX) || defined(ULONGLONG_MAX))
218 #    if defined(__hpux)
219      // HP-UX's value of ULONG_LONG_MAX is unusable in preprocessor expressions
220 #    elif (defined(ULLONG_MAX) && ULLONG_MAX == 18446744073709551615ULL) || (defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 18446744073709551615ULL) || (defined(ULONGLONG_MAX) && ULONGLONG_MAX == 18446744073709551615ULL)
221                                                                  // 2**64 - 1
222 #    else
223 #       error defaults not correct; you must hand modify boost/cstdint.hpp
224 #    endif
225
226      typedef  ::boost::long_long_type            intmax_t;
227      typedef  ::boost::ulong_long_type   uintmax_t;
228      typedef  ::boost::long_long_type            int64_t;
229      typedef  ::boost::long_long_type            int_least64_t;
230      typedef  ::boost::long_long_type            int_fast64_t;
231      typedef  ::boost::ulong_long_type   uint64_t;
232      typedef  ::boost::ulong_long_type   uint_least64_t;
233      typedef  ::boost::ulong_long_type   uint_fast64_t;
234
235 # elif ULONG_MAX != 0xffffffff
236
237 #    if ULONG_MAX == 18446744073709551615 // 2**64 - 1
238      typedef long                 intmax_t;
239      typedef unsigned long        uintmax_t;
240      typedef long                 int64_t;
241      typedef long                 int_least64_t;
242      typedef long                 int_fast64_t;
243      typedef unsigned long        uint64_t;
244      typedef unsigned long        uint_least64_t;
245      typedef unsigned long        uint_fast64_t;
246 #    else
247 #       error defaults not correct; you must hand modify boost/cstdint.hpp
248 #    endif
249 # elif defined(__GNUC__) && defined(BOOST_HAS_LONG_LONG)
250      __extension__ typedef long long            intmax_t;
251      __extension__ typedef unsigned long long   uintmax_t;
252      __extension__ typedef long long            int64_t;
253      __extension__ typedef long long            int_least64_t;
254      __extension__ typedef long long            int_fast64_t;
255      __extension__ typedef unsigned long long   uint64_t;
256      __extension__ typedef unsigned long long   uint_least64_t;
257      __extension__ typedef unsigned long long   uint_fast64_t;
258 # elif defined(BOOST_HAS_MS_INT64)
259      //
260      // we have Borland/Intel/Microsoft __int64:
261      //
262      typedef __int64             intmax_t;
263      typedef unsigned __int64    uintmax_t;
264      typedef __int64             int64_t;
265      typedef __int64             int_least64_t;
266      typedef __int64             int_fast64_t;
267      typedef unsigned __int64    uint64_t;
268      typedef unsigned __int64    uint_least64_t;
269      typedef unsigned __int64    uint_fast64_t;
270 # else // assume no 64-bit integers
271 #  define BOOST_NO_INT64_T
272      typedef int32_t              intmax_t;
273      typedef uint32_t             uintmax_t;
274 # endif
275
276 } // namespace boost
277
278
279 #endif // BOOST_HAS_STDINT_H
280
281 #endif // BOOST_CSTDINT_HPP
282
283
284 /****************************************************
285
286 Macro definition section:
287
288 Define various INTXX_C macros only if
289 __STDC_CONSTANT_MACROS is defined.
290
291 Undefine the macros if __STDC_CONSTANT_MACROS is
292 not defined and the macros are (cf <cassert>).
293
294 Added 23rd September 2000 (John Maddock).
295 Modified 11th September 2001 to be excluded when
296 BOOST_HAS_STDINT_H is defined (John Maddock).
297
298 ******************************************************/
299
300 #if defined(__STDC_CONSTANT_MACROS) && !defined(BOOST__STDC_CONSTANT_MACROS_DEFINED) && !defined(BOOST_HAS_STDINT_H)
301 # define BOOST__STDC_CONSTANT_MACROS_DEFINED
302 # if defined(BOOST_HAS_MS_INT64)
303 //
304 // Borland/Intel/Microsoft compilers have width specific suffixes:
305 //
306 #  define INT8_C(value)     value##i8
307 #  define INT16_C(value)    value##i16
308 #  define INT32_C(value)    value##i32
309 #  define INT64_C(value)    value##i64
310 #  ifdef __BORLANDC__
311     // Borland bug: appending ui8 makes the type a signed char
312 #   define UINT8_C(value)    static_cast<unsigned char>(value##u)
313 #  else
314 #   define UINT8_C(value)    value##ui8
315 #  endif
316 #  define UINT16_C(value)   value##ui16
317 #  define UINT32_C(value)   value##ui32
318 #  define UINT64_C(value)   value##ui64
319 #  define INTMAX_C(value)   value##i64
320 #  define UINTMAX_C(value)  value##ui64
321
322 # else
323 //  do it the old fashioned way:
324
325 //  8-bit types  ------------------------------------------------------------//
326
327 #  if UCHAR_MAX == 0xff
328 #   define INT8_C(value) static_cast<boost::int8_t>(value)
329 #   define UINT8_C(value) static_cast<boost::uint8_t>(value##u)
330 #  endif
331
332 //  16-bit types  -----------------------------------------------------------//
333
334 #  if USHRT_MAX == 0xffff
335 #   define INT16_C(value) static_cast<boost::int16_t>(value)
336 #   define UINT16_C(value) static_cast<boost::uint16_t>(value##u)
337 #  endif
338
339 //  32-bit types  -----------------------------------------------------------//
340
341 #  if UINT_MAX == 0xffffffff
342 #   define INT32_C(value) value
343 #   define UINT32_C(value) value##u
344 #  elif ULONG_MAX == 0xffffffff
345 #   define INT32_C(value) value##L
346 #   define UINT32_C(value) value##uL
347 #  endif
348
349 //  64-bit types + intmax_t and uintmax_t  ----------------------------------//
350
351 #  if defined(BOOST_HAS_LONG_LONG) && \
352     (defined(ULLONG_MAX) || defined(ULONG_LONG_MAX) || defined(ULONGLONG_MAX))
353
354 #    if defined(__hpux)
355      // HP-UX's value of ULONG_LONG_MAX is unusable in preprocessor expressions
356 #    elif (defined(ULLONG_MAX) && ULLONG_MAX == 18446744073709551615U) ||  \
357         (defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 18446744073709551615U) ||  \
358         (defined(ULONGLONG_MAX) && ULONGLONG_MAX == 18446744073709551615U)
359
360 #    else
361 #       error defaults not correct; you must hand modify boost/cstdint.hpp
362 #    endif
363 #    define INT64_C(value) value##LL
364 #    define UINT64_C(value) value##uLL
365 #  elif ULONG_MAX != 0xffffffff
366
367 #    if ULONG_MAX == 18446744073709551615 // 2**64 - 1
368 #       define INT64_C(value) value##L
369 #       define UINT64_C(value) value##uL
370 #    else
371 #       error defaults not correct; you must hand modify boost/cstdint.hpp
372 #    endif
373 #  endif
374
375 #  ifdef BOOST_NO_INT64_T
376 #   define INTMAX_C(value) INT32_C(value)
377 #   define UINTMAX_C(value) UINT32_C(value)
378 #  else
379 #   define INTMAX_C(value) INT64_C(value)
380 #   define UINTMAX_C(value) UINT64_C(value)
381 #  endif
382
383 # endif // Borland/Microsoft specific width suffixes
384
385
386 #elif defined(BOOST__STDC_CONSTANT_MACROS_DEFINED) && !defined(__STDC_CONSTANT_MACROS) && !defined(BOOST_HAS_STDINT_H)
387 //
388 // undef all the macros:
389 //
390 # undef INT8_C
391 # undef INT16_C
392 # undef INT32_C
393 # undef INT64_C
394 # undef UINT8_C
395 # undef UINT16_C
396 # undef UINT32_C
397 # undef UINT64_C
398 # undef INTMAX_C
399 # undef UINTMAX_C
400
401 #endif // __STDC_CONSTANT_MACROS_DEFINED etc.
402
403
404
405