~ubuntu-branches/ubuntu/warty/aqsis/warty

« back to all changes in this revision

Viewing changes to boost/boost/cstdint.hpp

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2004-08-24 07:25:04 UTC
  • Revision ID: james.westby@ubuntu.com-20040824072504-zf993vnevvisdsvb
Tags: upstream-0.9.1
ImportĀ upstreamĀ versionĀ 0.9.1

Show diffs side-by-side

added added

removed removed

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