Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/assimp/Compiler/pstdint.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*  A portable stdint.h
0002  ****************************************************************************
0003  *  BSD License:
0004  ****************************************************************************
0005  *
0006  *  Copyright (c) 2005-2016 Paul Hsieh
0007  *  All rights reserved.
0008  *
0009  *  Redistribution and use in source and binary forms, with or without
0010  *  modification, are permitted provided that the following conditions
0011  *  are met:
0012  *
0013  *  1. Redistributions of source code must retain the above copyright
0014  *     notice, this list of conditions and the following disclaimer.
0015  *  2. Redistributions in binary form must reproduce the above copyright
0016  *     notice, this list of conditions and the following disclaimer in the
0017  *     documentation and/or other materials provided with the distribution.
0018  *  3. The name of the author may not be used to endorse or promote products
0019  *     derived from this software without specific prior written permission.
0020  *
0021  *  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
0022  *  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
0023  *  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
0024  *  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
0025  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
0026  *  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0027  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0028  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0029  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
0030  *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0031  *
0032  ****************************************************************************
0033  *
0034  *  Version 0.1.15.4
0035  *
0036  *  The ANSI C standard committee, for the C99 standard, specified the
0037  *  inclusion of a new standard include file called stdint.h.  This is
0038  *  a very useful and long desired include file which contains several
0039  *  very precise definitions for integer scalar types that is
0040  *  critically important for making portable several classes of
0041  *  applications including cryptography, hashing, variable length
0042  *  integer libraries and so on.  But for most developers its likely
0043  *  useful just for programming sanity.
0044  *
0045  *  The problem is that some compiler vendors chose to ignore the C99
0046  *  standard and some older compilers have no opportunity to be updated.
0047  *  Because of this situation, simply including stdint.h in your code
0048  *  makes it unportable.
0049  *
0050  *  So that's what this file is all about.  Its an attempt to build a
0051  *  single universal include file that works on as many platforms as
0052  *  possible to deliver what stdint.h is supposed to.  Even compilers
0053  *  that already come with stdint.h can use this file instead without
0054  *  any loss of functionality.  A few things that should be noted about
0055  *  this file:
0056  *
0057  *    1) It is not guaranteed to be portable and/or present an identical
0058  *       interface on all platforms.  The extreme variability of the
0059  *       ANSI C standard makes this an impossibility right from the
0060  *       very get go. Its really only meant to be useful for the vast
0061  *       majority of platforms that possess the capability of
0062  *       implementing usefully and precisely defined, standard sized
0063  *       integer scalars.  Systems which are not intrinsically 2s
0064  *       complement may produce invalid constants.
0065  *
0066  *    2) There is an unavoidable use of non-reserved symbols.
0067  *
0068  *    3) Other standard include files are invoked.
0069  *
0070  *    4) This file may come in conflict with future platforms that do
0071  *       include stdint.h.  The hope is that one or the other can be
0072  *       used with no real difference.
0073  *
0074  *    5) In the current version, if your platform can't represent
0075  *       int32_t, int16_t and int8_t, it just dumps out with a compiler
0076  *       error.
0077  *
0078  *    6) 64 bit integers may or may not be defined.  Test for their
0079  *       presence with the test: #ifdef INT64_MAX or #ifdef UINT64_MAX.
0080  *       Note that this is different from the C99 specification which
0081  *       requires the existence of 64 bit support in the compiler.  If
0082  *       this is not defined for your platform, yet it is capable of
0083  *       dealing with 64 bits then it is because this file has not yet
0084  *       been extended to cover all of your system's capabilities.
0085  *
0086  *    7) (u)intptr_t may or may not be defined.  Test for its presence
0087  *       with the test: #ifdef PTRDIFF_MAX.  If this is not defined
0088  *       for your platform, then it is because this file has not yet
0089  *       been extended to cover all of your system's capabilities, not
0090  *       because its optional.
0091  *
0092  *    8) The following might not been defined even if your platform is
0093  *       capable of defining it:
0094  *
0095  *       WCHAR_MIN
0096  *       WCHAR_MAX
0097  *       (u)int64_t
0098  *       PTRDIFF_MIN
0099  *       PTRDIFF_MAX
0100  *       (u)intptr_t
0101  *
0102  *    9) The following have not been defined:
0103  *
0104  *       WINT_MIN
0105  *       WINT_MAX
0106  *
0107  *   10) The criteria for defining (u)int_least(*)_t isn't clear,
0108  *       except for systems which don't have a type that precisely
0109  *       defined 8, 16, or 32 bit types (which this include file does
0110  *       not support anyways). Default definitions have been given.
0111  *
0112  *   11) The criteria for defining (u)int_fast(*)_t isn't something I
0113  *       would trust to any particular compiler vendor or the ANSI C
0114  *       committee.  It is well known that "compatible systems" are
0115  *       commonly created that have very different performance
0116  *       characteristics from the systems they are compatible with,
0117  *       especially those whose vendors make both the compiler and the
0118  *       system.  Default definitions have been given, but its strongly
0119  *       recommended that users never use these definitions for any
0120  *       reason (they do *NOT* deliver any serious guarantee of
0121  *       improved performance -- not in this file, nor any vendor's
0122  *       stdint.h).
0123  *
0124  *   12) The following macros:
0125  *
0126  *       PRINTF_INTMAX_MODIFIER
0127  *       PRINTF_INT64_MODIFIER
0128  *       PRINTF_INT32_MODIFIER
0129  *       PRINTF_INT16_MODIFIER
0130  *       PRINTF_LEAST64_MODIFIER
0131  *       PRINTF_LEAST32_MODIFIER
0132  *       PRINTF_LEAST16_MODIFIER
0133  *       PRINTF_INTPTR_MODIFIER
0134  *
0135  *       are strings which have been defined as the modifiers required
0136  *       for the "d", "u" and "x" printf formats to correctly output
0137  *       (u)intmax_t, (u)int64_t, (u)int32_t, (u)int16_t, (u)least64_t,
0138  *       (u)least32_t, (u)least16_t and (u)intptr_t types respectively.
0139  *       PRINTF_INTPTR_MODIFIER is not defined for some systems which
0140  *       provide their own stdint.h.  PRINTF_INT64_MODIFIER is not
0141  *       defined if INT64_MAX is not defined.  These are an extension
0142  *       beyond what C99 specifies must be in stdint.h.
0143  *
0144  *       In addition, the following macros are defined:
0145  *
0146  *       PRINTF_INTMAX_HEX_WIDTH
0147  *       PRINTF_INT64_HEX_WIDTH
0148  *       PRINTF_INT32_HEX_WIDTH
0149  *       PRINTF_INT16_HEX_WIDTH
0150  *       PRINTF_INT8_HEX_WIDTH
0151  *       PRINTF_INTMAX_DEC_WIDTH
0152  *       PRINTF_INT64_DEC_WIDTH
0153  *       PRINTF_INT32_DEC_WIDTH
0154  *       PRINTF_INT16_DEC_WIDTH
0155  *       PRINTF_UINT8_DEC_WIDTH
0156  *       PRINTF_UINTMAX_DEC_WIDTH
0157  *       PRINTF_UINT64_DEC_WIDTH
0158  *       PRINTF_UINT32_DEC_WIDTH
0159  *       PRINTF_UINT16_DEC_WIDTH
0160  *       PRINTF_UINT8_DEC_WIDTH
0161  *
0162  *       Which specifies the maximum number of characters required to
0163  *       print the number of that type in either hexadecimal or decimal.
0164  *       These are an extension beyond what C99 specifies must be in
0165  *       stdint.h.
0166  *
0167  *  Compilers tested (all with 0 warnings at their highest respective
0168  *  settings): Borland Turbo C 2.0, WATCOM C/C++ 11.0 (16 bits and 32
0169  *  bits), Microsoft Visual C++ 6.0 (32 bit), Microsoft Visual Studio
0170  *  .net (VC7), Intel C++ 4.0, GNU gcc v3.3.3
0171  *
0172  *  This file should be considered a work in progress.  Suggestions for
0173  *  improvements, especially those which increase coverage are strongly
0174  *  encouraged.
0175  *
0176  *  Acknowledgements
0177  *
0178  *  The following people have made significant contributions to the
0179  *  development and testing of this file:
0180  *
0181  *  Chris Howie
0182  *  John Steele Scott
0183  *  Dave Thorup
0184  *  John Dill
0185  *  Florian Wobbe
0186  *  Christopher Sean Morrison
0187  *  Mikkel Fahnoe Jorgensen
0188  *
0189  */
0190 
0191 #include <stddef.h>
0192 #include <limits.h>
0193 #include <signal.h>
0194 
0195 /*
0196  *  For gcc with _STDINT_H, fill in the PRINTF_INT*_MODIFIER macros, and
0197  *  do nothing else.  On the Mac OS X version of gcc this is _STDINT_H_.
0198  */
0199 
0200 #if ((defined(__SUNPRO_C) && __SUNPRO_C >= 0x570) || (defined(_MSC_VER) && _MSC_VER >= 1600) || (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (__GNUC__ > 3 || defined(_STDINT_H) || defined(_STDINT_H_) || defined (__UINT_FAST64_TYPE__)) )) && !defined (_PSTDINT_H_INCLUDED)
0201 #include <stdint.h>
0202 #define _PSTDINT_H_INCLUDED
0203 # if defined(__GNUC__) && (defined(__x86_64__) || defined(__ppc64__)) && !(defined(__APPLE__) && defined(__MACH__))
0204 #  ifndef PRINTF_INT64_MODIFIER
0205 #   define PRINTF_INT64_MODIFIER "l"
0206 #  endif
0207 #  ifndef PRINTF_INT32_MODIFIER
0208 #   define PRINTF_INT32_MODIFIER ""
0209 #  endif
0210 # else
0211 #  ifndef PRINTF_INT64_MODIFIER
0212 #   define PRINTF_INT64_MODIFIER "ll"
0213 #  endif
0214 #  ifndef PRINTF_INT32_MODIFIER
0215 #   if (UINT_MAX == UINT32_MAX)
0216 #    define PRINTF_INT32_MODIFIER ""
0217 #   else
0218 #    define PRINTF_INT32_MODIFIER "l"
0219 #   endif
0220 #  endif
0221 # endif
0222 # ifndef PRINTF_INT16_MODIFIER
0223 #  define PRINTF_INT16_MODIFIER "h"
0224 # endif
0225 # ifndef PRINTF_INTMAX_MODIFIER
0226 #  define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
0227 # endif
0228 # ifndef PRINTF_INT64_HEX_WIDTH
0229 #  define PRINTF_INT64_HEX_WIDTH "16"
0230 # endif
0231 # ifndef PRINTF_UINT64_HEX_WIDTH
0232 #  define PRINTF_UINT64_HEX_WIDTH "16"
0233 # endif
0234 # ifndef PRINTF_INT32_HEX_WIDTH
0235 #  define PRINTF_INT32_HEX_WIDTH "8"
0236 # endif
0237 # ifndef PRINTF_UINT32_HEX_WIDTH
0238 #  define PRINTF_UINT32_HEX_WIDTH "8"
0239 # endif
0240 # ifndef PRINTF_INT16_HEX_WIDTH
0241 #  define PRINTF_INT16_HEX_WIDTH "4"
0242 # endif
0243 # ifndef PRINTF_UINT16_HEX_WIDTH
0244 #  define PRINTF_UINT16_HEX_WIDTH "4"
0245 # endif
0246 # ifndef PRINTF_INT8_HEX_WIDTH
0247 #  define PRINTF_INT8_HEX_WIDTH "2"
0248 # endif
0249 # ifndef PRINTF_UINT8_HEX_WIDTH
0250 #  define PRINTF_UINT8_HEX_WIDTH "2"
0251 # endif
0252 # ifndef PRINTF_INT64_DEC_WIDTH
0253 #  define PRINTF_INT64_DEC_WIDTH "19"
0254 # endif
0255 # ifndef PRINTF_UINT64_DEC_WIDTH
0256 #  define PRINTF_UINT64_DEC_WIDTH "20"
0257 # endif
0258 # ifndef PRINTF_INT32_DEC_WIDTH
0259 #  define PRINTF_INT32_DEC_WIDTH "10"
0260 # endif
0261 # ifndef PRINTF_UINT32_DEC_WIDTH
0262 #  define PRINTF_UINT32_DEC_WIDTH "10"
0263 # endif
0264 # ifndef PRINTF_INT16_DEC_WIDTH
0265 #  define PRINTF_INT16_DEC_WIDTH "5"
0266 # endif
0267 # ifndef PRINTF_UINT16_DEC_WIDTH
0268 #  define PRINTF_UINT16_DEC_WIDTH "5"
0269 # endif
0270 # ifndef PRINTF_INT8_DEC_WIDTH
0271 #  define PRINTF_INT8_DEC_WIDTH "3"
0272 # endif
0273 # ifndef PRINTF_UINT8_DEC_WIDTH
0274 #  define PRINTF_UINT8_DEC_WIDTH "3"
0275 # endif
0276 # ifndef PRINTF_INTMAX_HEX_WIDTH
0277 #  define PRINTF_INTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH
0278 # endif
0279 # ifndef PRINTF_UINTMAX_HEX_WIDTH
0280 #  define PRINTF_UINTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH
0281 # endif
0282 # ifndef PRINTF_INTMAX_DEC_WIDTH
0283 #  define PRINTF_INTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH
0284 # endif
0285 # ifndef PRINTF_UINTMAX_DEC_WIDTH
0286 #  define PRINTF_UINTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH
0287 # endif
0288 
0289 /*
0290  *  Something really weird is going on with Open Watcom.  Just pull some of
0291  *  these duplicated definitions from Open Watcom's stdint.h file for now.
0292  */
0293 
0294 # if defined (__WATCOMC__) && __WATCOMC__ >= 1250
0295 #  if !defined (INT64_C)
0296 #   define INT64_C(x)   (x + (INT64_MAX - INT64_MAX))
0297 #  endif
0298 #  if !defined (UINT64_C)
0299 #   define UINT64_C(x)  (x + (UINT64_MAX - UINT64_MAX))
0300 #  endif
0301 #  if !defined (INT32_C)
0302 #   define INT32_C(x)   (x + (INT32_MAX - INT32_MAX))
0303 #  endif
0304 #  if !defined (UINT32_C)
0305 #   define UINT32_C(x)  (x + (UINT32_MAX - UINT32_MAX))
0306 #  endif
0307 #  if !defined (INT16_C)
0308 #   define INT16_C(x)   (x)
0309 #  endif
0310 #  if !defined (UINT16_C)
0311 #   define UINT16_C(x)  (x)
0312 #  endif
0313 #  if !defined (INT8_C)
0314 #   define INT8_C(x)   (x)
0315 #  endif
0316 #  if !defined (UINT8_C)
0317 #   define UINT8_C(x)  (x)
0318 #  endif
0319 #  if !defined (UINT64_MAX)
0320 #   define UINT64_MAX  18446744073709551615ULL
0321 #  endif
0322 #  if !defined (INT64_MAX)
0323 #   define INT64_MAX  9223372036854775807LL
0324 #  endif
0325 #  if !defined (UINT32_MAX)
0326 #   define UINT32_MAX  4294967295UL
0327 #  endif
0328 #  if !defined (INT32_MAX)
0329 #   define INT32_MAX  2147483647L
0330 #  endif
0331 #  if !defined (INTMAX_MAX)
0332 #   define INTMAX_MAX INT64_MAX
0333 #  endif
0334 #  if !defined (INTMAX_MIN)
0335 #   define INTMAX_MIN INT64_MIN
0336 #  endif
0337 # endif
0338 #endif
0339 
0340 /*
0341  *  I have no idea what is the truly correct thing to do on older Solaris.
0342  *  From some online discussions, this seems to be what is being
0343  *  recommended.  For people who actually are developing on older Solaris,
0344  *  what I would like to know is, does this define all of the relevant
0345  *  macros of a complete stdint.h?  Remember, in pstdint.h 64 bit is
0346  *  considered optional.
0347  */
0348 
0349 #if (defined(__SUNPRO_C) && __SUNPRO_C >= 0x420) && !defined(_PSTDINT_H_INCLUDED)
0350 #include <sys/inttypes.h>
0351 #define _PSTDINT_H_INCLUDED
0352 #endif
0353 
0354 #ifndef _PSTDINT_H_INCLUDED
0355 #define _PSTDINT_H_INCLUDED
0356 
0357 #ifndef SIZE_MAX
0358 # define SIZE_MAX (~(size_t)0)
0359 #endif
0360 
0361 /*
0362  *  Deduce the type assignments from limits.h under the assumption that
0363  *  integer sizes in bits are powers of 2, and follow the ANSI
0364  *  definitions.
0365  */
0366 
0367 #ifndef UINT8_MAX
0368 # define UINT8_MAX 0xff
0369 #endif
0370 #if !defined(uint8_t) && !defined(_UINT8_T) && !defined(vxWorks)
0371 # if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S)
0372     typedef unsigned char uint8_t;
0373 #   define UINT8_C(v) ((uint8_t) v)
0374 # else
0375 #   error "Platform not supported"
0376 # endif
0377 #endif
0378 
0379 #ifndef INT8_MAX
0380 # define INT8_MAX 0x7f
0381 #endif
0382 #ifndef INT8_MIN
0383 # define INT8_MIN INT8_C(0x80)
0384 #endif
0385 #if !defined(int8_t) && !defined(_INT8_T) && !defined(vxWorks)
0386 # if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S)
0387     typedef signed char int8_t;
0388 #   define INT8_C(v) ((int8_t) v)
0389 # else
0390 #   error "Platform not supported"
0391 # endif
0392 #endif
0393 
0394 #ifndef UINT16_MAX
0395 # define UINT16_MAX 0xffff
0396 #endif
0397 #if !defined(uint16_t) && !defined(_UINT16_T) && !defined(vxWorks)
0398 #if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S)
0399   typedef unsigned int uint16_t;
0400 # ifndef PRINTF_INT16_MODIFIER
0401 #  define PRINTF_INT16_MODIFIER ""
0402 # endif
0403 # define UINT16_C(v) ((uint16_t) (v))
0404 #elif (USHRT_MAX == UINT16_MAX)
0405   typedef unsigned short uint16_t;
0406 # define UINT16_C(v) ((uint16_t) (v))
0407 # ifndef PRINTF_INT16_MODIFIER
0408 #  define PRINTF_INT16_MODIFIER "h"
0409 # endif
0410 #else
0411 #error "Platform not supported"
0412 #endif
0413 #endif
0414 
0415 #ifndef INT16_MAX
0416 # define INT16_MAX 0x7fff
0417 #endif
0418 #ifndef INT16_MIN
0419 # define INT16_MIN INT16_C(0x8000)
0420 #endif
0421 #if !defined(int16_t) && !defined(_INT16_T) && !defined(vxWorks)
0422 #if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S)
0423   typedef signed int int16_t;
0424 # define INT16_C(v) ((int16_t) (v))
0425 # ifndef PRINTF_INT16_MODIFIER
0426 #  define PRINTF_INT16_MODIFIER ""
0427 # endif
0428 #elif (SHRT_MAX == INT16_MAX)
0429   typedef signed short int16_t;
0430 # define INT16_C(v) ((int16_t) (v))
0431 # ifndef PRINTF_INT16_MODIFIER
0432 #  define PRINTF_INT16_MODIFIER "h"
0433 # endif
0434 #else
0435 #error "Platform not supported"
0436 #endif
0437 #endif
0438 
0439 #ifndef UINT32_MAX
0440 # define UINT32_MAX (0xffffffffUL)
0441 #endif
0442 #if !defined(uint32_t) && !defined(_UINT32_T) && !defined(vxWorks)
0443 #if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S)
0444   typedef unsigned long uint32_t;
0445 # define UINT32_C(v) v ## UL
0446 # ifndef PRINTF_INT32_MODIFIER
0447 #  define PRINTF_INT32_MODIFIER "l"
0448 # endif
0449 #elif (UINT_MAX == UINT32_MAX)
0450   typedef unsigned int uint32_t;
0451 # ifndef PRINTF_INT32_MODIFIER
0452 #  define PRINTF_INT32_MODIFIER ""
0453 # endif
0454 # define UINT32_C(v) v ## U
0455 #elif (USHRT_MAX == UINT32_MAX)
0456   typedef unsigned short uint32_t;
0457 # define UINT32_C(v) ((unsigned short) (v))
0458 # ifndef PRINTF_INT32_MODIFIER
0459 #  define PRINTF_INT32_MODIFIER ""
0460 # endif
0461 #else
0462 #error "Platform not supported"
0463 #endif
0464 #endif
0465 
0466 #ifndef INT32_MAX
0467 # define INT32_MAX (0x7fffffffL)
0468 #endif
0469 #ifndef INT32_MIN
0470 # define INT32_MIN INT32_C(0x80000000)
0471 #endif
0472 #if !defined(int32_t) && !defined(_INT32_T) && !defined(vxWorks)
0473 #if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S)
0474   typedef signed long int32_t;
0475 # define INT32_C(v) v ## L
0476 # ifndef PRINTF_INT32_MODIFIER
0477 #  define PRINTF_INT32_MODIFIER "l"
0478 # endif
0479 #elif (INT_MAX == INT32_MAX)
0480   typedef signed int int32_t;
0481 # define INT32_C(v) v
0482 # ifndef PRINTF_INT32_MODIFIER
0483 #  define PRINTF_INT32_MODIFIER ""
0484 # endif
0485 #elif (SHRT_MAX == INT32_MAX)
0486   typedef signed short int32_t;
0487 # define INT32_C(v) ((short) (v))
0488 # ifndef PRINTF_INT32_MODIFIER
0489 #  define PRINTF_INT32_MODIFIER ""
0490 # endif
0491 #else
0492 #error "Platform not supported"
0493 #endif
0494 #endif
0495 
0496 /*
0497  *  The macro stdint_int64_defined is temporarily used to record
0498  *  whether or not 64 integer support is available.  It must be
0499  *  defined for any 64 integer extensions for new platforms that are
0500  *  added.
0501  */
0502 
0503 #undef stdint_int64_defined
0504 #if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined (S_SPLINT_S)
0505 # if (__STDC__ && __STDC_VERSION__ >= 199901L) || defined (S_SPLINT_S)
0506 #  define stdint_int64_defined
0507    typedef long long int64_t;
0508    typedef unsigned long long uint64_t;
0509 #  define UINT64_C(v) v ## ULL
0510 #  define  INT64_C(v) v ## LL
0511 #  ifndef PRINTF_INT64_MODIFIER
0512 #   define PRINTF_INT64_MODIFIER "ll"
0513 #  endif
0514 # endif
0515 #endif
0516 
0517 #if !defined (stdint_int64_defined)
0518 # if defined(__GNUC__) && !defined(vxWorks)
0519 #  define stdint_int64_defined
0520    __extension__ typedef long long int64_t;
0521    __extension__ typedef unsigned long long uint64_t;
0522 #  define UINT64_C(v) v ## ULL
0523 #  define  INT64_C(v) v ## LL
0524 #  ifndef PRINTF_INT64_MODIFIER
0525 #   define PRINTF_INT64_MODIFIER "ll"
0526 #  endif
0527 # elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S)
0528 #  define stdint_int64_defined
0529    typedef long long int64_t;
0530    typedef unsigned long long uint64_t;
0531 #  define UINT64_C(v) v ## ULL
0532 #  define  INT64_C(v) v ## LL
0533 #  ifndef PRINTF_INT64_MODIFIER
0534 #   define PRINTF_INT64_MODIFIER "ll"
0535 #  endif
0536 # elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC)
0537 #  define stdint_int64_defined
0538    typedef __int64 int64_t;
0539    typedef unsigned __int64 uint64_t;
0540 #  define UINT64_C(v) v ## UI64
0541 #  define  INT64_C(v) v ## I64
0542 #  ifndef PRINTF_INT64_MODIFIER
0543 #   define PRINTF_INT64_MODIFIER "I64"
0544 #  endif
0545 # endif
0546 #endif
0547 
0548 #if !defined (LONG_LONG_MAX) && defined (INT64_C)
0549 # define LONG_LONG_MAX INT64_C (9223372036854775807)
0550 #endif
0551 #ifndef ULONG_LONG_MAX
0552 # define ULONG_LONG_MAX UINT64_C (18446744073709551615)
0553 #endif
0554 
0555 #if !defined (INT64_MAX) && defined (INT64_C)
0556 # define INT64_MAX INT64_C (9223372036854775807)
0557 #endif
0558 #if !defined (INT64_MIN) && defined (INT64_C)
0559 # define INT64_MIN INT64_C (-9223372036854775808)
0560 #endif
0561 #if !defined (UINT64_MAX) && defined (INT64_C)
0562 # define UINT64_MAX UINT64_C (18446744073709551615)
0563 #endif
0564 
0565 /*
0566  *  Width of hexadecimal for number field.
0567  */
0568 
0569 #ifndef PRINTF_INT64_HEX_WIDTH
0570 # define PRINTF_INT64_HEX_WIDTH "16"
0571 #endif
0572 #ifndef PRINTF_INT32_HEX_WIDTH
0573 # define PRINTF_INT32_HEX_WIDTH "8"
0574 #endif
0575 #ifndef PRINTF_INT16_HEX_WIDTH
0576 # define PRINTF_INT16_HEX_WIDTH "4"
0577 #endif
0578 #ifndef PRINTF_INT8_HEX_WIDTH
0579 # define PRINTF_INT8_HEX_WIDTH "2"
0580 #endif
0581 #ifndef PRINTF_INT64_DEC_WIDTH
0582 # define PRINTF_INT64_DEC_WIDTH "19"
0583 #endif
0584 #ifndef PRINTF_INT32_DEC_WIDTH
0585 # define PRINTF_INT32_DEC_WIDTH "10"
0586 #endif
0587 #ifndef PRINTF_INT16_DEC_WIDTH
0588 # define PRINTF_INT16_DEC_WIDTH "5"
0589 #endif
0590 #ifndef PRINTF_INT8_DEC_WIDTH
0591 # define PRINTF_INT8_DEC_WIDTH "3"
0592 #endif
0593 #ifndef PRINTF_UINT64_DEC_WIDTH
0594 # define PRINTF_UINT64_DEC_WIDTH "20"
0595 #endif
0596 #ifndef PRINTF_UINT32_DEC_WIDTH
0597 # define PRINTF_UINT32_DEC_WIDTH "10"
0598 #endif
0599 #ifndef PRINTF_UINT16_DEC_WIDTH
0600 # define PRINTF_UINT16_DEC_WIDTH "5"
0601 #endif
0602 #ifndef PRINTF_UINT8_DEC_WIDTH
0603 # define PRINTF_UINT8_DEC_WIDTH "3"
0604 #endif
0605 
0606 /*
0607  *  Ok, lets not worry about 128 bit integers for now.  Moore's law says
0608  *  we don't need to worry about that until about 2040 at which point
0609  *  we'll have bigger things to worry about.
0610  */
0611 
0612 #ifdef stdint_int64_defined
0613   typedef int64_t intmax_t;
0614   typedef uint64_t uintmax_t;
0615 # define  INTMAX_MAX   INT64_MAX
0616 # define  INTMAX_MIN   INT64_MIN
0617 # define UINTMAX_MAX  UINT64_MAX
0618 # define UINTMAX_C(v) UINT64_C(v)
0619 # define  INTMAX_C(v)  INT64_C(v)
0620 # ifndef PRINTF_INTMAX_MODIFIER
0621 #   define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
0622 # endif
0623 # ifndef PRINTF_INTMAX_HEX_WIDTH
0624 #  define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
0625 # endif
0626 # ifndef PRINTF_INTMAX_DEC_WIDTH
0627 #  define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
0628 # endif
0629 #else
0630   typedef int32_t intmax_t;
0631   typedef uint32_t uintmax_t;
0632 # define  INTMAX_MAX   INT32_MAX
0633 # define UINTMAX_MAX  UINT32_MAX
0634 # define UINTMAX_C(v) UINT32_C(v)
0635 # define  INTMAX_C(v)  INT32_C(v)
0636 # ifndef PRINTF_INTMAX_MODIFIER
0637 #   define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER
0638 # endif
0639 # ifndef PRINTF_INTMAX_HEX_WIDTH
0640 #  define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH
0641 # endif
0642 # ifndef PRINTF_INTMAX_DEC_WIDTH
0643 #  define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH
0644 # endif
0645 #endif
0646 
0647 /*
0648  *  Because this file currently only supports platforms which have
0649  *  precise powers of 2 as bit sizes for the default integers, the
0650  *  least definitions are all trivial.  Its possible that a future
0651  *  version of this file could have different definitions.
0652  */
0653 
0654 #ifndef stdint_least_defined
0655   typedef   int8_t   int_least8_t;
0656   typedef  uint8_t  uint_least8_t;
0657   typedef  int16_t  int_least16_t;
0658   typedef uint16_t uint_least16_t;
0659   typedef  int32_t  int_least32_t;
0660   typedef uint32_t uint_least32_t;
0661 # define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER
0662 # define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER
0663 # define  UINT_LEAST8_MAX  UINT8_MAX
0664 # define   INT_LEAST8_MAX   INT8_MAX
0665 # define UINT_LEAST16_MAX UINT16_MAX
0666 # define  INT_LEAST16_MAX  INT16_MAX
0667 # define UINT_LEAST32_MAX UINT32_MAX
0668 # define  INT_LEAST32_MAX  INT32_MAX
0669 # define   INT_LEAST8_MIN   INT8_MIN
0670 # define  INT_LEAST16_MIN  INT16_MIN
0671 # define  INT_LEAST32_MIN  INT32_MIN
0672 # ifdef stdint_int64_defined
0673     typedef  int64_t  int_least64_t;
0674     typedef uint64_t uint_least64_t;
0675 #   define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER
0676 #   define UINT_LEAST64_MAX UINT64_MAX
0677 #   define  INT_LEAST64_MAX  INT64_MAX
0678 #   define  INT_LEAST64_MIN  INT64_MIN
0679 # endif
0680 #endif
0681 #undef stdint_least_defined
0682 
0683 /*
0684  *  The ANSI C committee pretending to know or specify anything about
0685  *  performance is the epitome of misguided arrogance.  The mandate of
0686  *  this file is to *ONLY* ever support that absolute minimum
0687  *  definition of the fast integer types, for compatibility purposes.
0688  *  No extensions, and no attempt to suggest what may or may not be a
0689  *  faster integer type will ever be made in this file.  Developers are
0690  *  warned to stay away from these types when using this or any other
0691  *  stdint.h.
0692  */
0693 
0694 typedef   int_least8_t   int_fast8_t;
0695 typedef  uint_least8_t  uint_fast8_t;
0696 typedef  int_least16_t  int_fast16_t;
0697 typedef uint_least16_t uint_fast16_t;
0698 typedef  int_least32_t  int_fast32_t;
0699 typedef uint_least32_t uint_fast32_t;
0700 #define  UINT_FAST8_MAX  UINT_LEAST8_MAX
0701 #define   INT_FAST8_MAX   INT_LEAST8_MAX
0702 #define UINT_FAST16_MAX UINT_LEAST16_MAX
0703 #define  INT_FAST16_MAX  INT_LEAST16_MAX
0704 #define UINT_FAST32_MAX UINT_LEAST32_MAX
0705 #define  INT_FAST32_MAX  INT_LEAST32_MAX
0706 #define   INT_FAST8_MIN   INT_LEAST8_MIN
0707 #define  INT_FAST16_MIN  INT_LEAST16_MIN
0708 #define  INT_FAST32_MIN  INT_LEAST32_MIN
0709 #ifdef stdint_int64_defined
0710   typedef  int_least64_t  int_fast64_t;
0711   typedef uint_least64_t uint_fast64_t;
0712 # define UINT_FAST64_MAX UINT_LEAST64_MAX
0713 # define  INT_FAST64_MAX  INT_LEAST64_MAX
0714 # define  INT_FAST64_MIN  INT_LEAST64_MIN
0715 #endif
0716 
0717 #undef stdint_int64_defined
0718 
0719 /*
0720  *  Whatever piecemeal, per compiler thing we can do about the wchar_t
0721  *  type limits.
0722  */
0723 
0724 #if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__) && !defined(vxWorks)
0725 # include <wchar.h>
0726 # ifndef WCHAR_MIN
0727 #  define WCHAR_MIN 0
0728 # endif
0729 # ifndef WCHAR_MAX
0730 #  define WCHAR_MAX ((wchar_t)-1)
0731 # endif
0732 #endif
0733 
0734 /*
0735  *  Whatever piecemeal, per compiler/platform thing we can do about the
0736  *  (u)intptr_t types and limits.
0737  */
0738 
0739 #if (defined (_MSC_VER) && defined (_UINTPTR_T_DEFINED)) || defined (_UINTPTR_T)
0740 # define STDINT_H_UINTPTR_T_DEFINED
0741 #endif
0742 
0743 #ifndef STDINT_H_UINTPTR_T_DEFINED
0744 # if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (_WIN64) || defined (__ppc64__)
0745 #  define stdint_intptr_bits 64
0746 # elif defined (__WATCOMC__) || defined (__TURBOC__)
0747 #  if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
0748 #    define stdint_intptr_bits 16
0749 #  else
0750 #    define stdint_intptr_bits 32
0751 #  endif
0752 # elif defined (__i386__) || defined (_WIN32) || defined (WIN32) || defined (__ppc64__)
0753 #  define stdint_intptr_bits 32
0754 # elif defined (__INTEL_COMPILER)
0755 /* TODO -- what did Intel do about x86-64? */
0756 # else
0757 /* #error "This platform might not be supported yet" */
0758 # endif
0759 
0760 # ifdef stdint_intptr_bits
0761 #  define stdint_intptr_glue3_i(a,b,c)  a##b##c
0762 #  define stdint_intptr_glue3(a,b,c)    stdint_intptr_glue3_i(a,b,c)
0763 #  ifndef PRINTF_INTPTR_MODIFIER
0764 #    define PRINTF_INTPTR_MODIFIER      stdint_intptr_glue3(PRINTF_INT,stdint_intptr_bits,_MODIFIER)
0765 #  endif
0766 #  ifndef PTRDIFF_MAX
0767 #    define PTRDIFF_MAX                 stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
0768 #  endif
0769 #  ifndef PTRDIFF_MIN
0770 #    define PTRDIFF_MIN                 stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
0771 #  endif
0772 #  ifndef UINTPTR_MAX
0773 #    define UINTPTR_MAX                 stdint_intptr_glue3(UINT,stdint_intptr_bits,_MAX)
0774 #  endif
0775 #  ifndef INTPTR_MAX
0776 #    define INTPTR_MAX                  stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
0777 #  endif
0778 #  ifndef INTPTR_MIN
0779 #    define INTPTR_MIN                  stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
0780 #  endif
0781 #  ifndef INTPTR_C
0782 #    define INTPTR_C(x)                 stdint_intptr_glue3(INT,stdint_intptr_bits,_C)(x)
0783 #  endif
0784 #  ifndef UINTPTR_C
0785 #    define UINTPTR_C(x)                stdint_intptr_glue3(UINT,stdint_intptr_bits,_C)(x)
0786 #  endif
0787   typedef stdint_intptr_glue3(uint,stdint_intptr_bits,_t) uintptr_t;
0788   typedef stdint_intptr_glue3( int,stdint_intptr_bits,_t)  intptr_t;
0789 # else
0790 /* TODO -- This following is likely wrong for some platforms, and does
0791    nothing for the definition of uintptr_t. */
0792   typedef ptrdiff_t intptr_t;
0793 # endif
0794 # define STDINT_H_UINTPTR_T_DEFINED
0795 #endif
0796 
0797 /*
0798  *  Assumes sig_atomic_t is signed and we have a 2s complement machine.
0799  */
0800 
0801 #ifndef SIG_ATOMIC_MAX
0802 # define SIG_ATOMIC_MAX ((((sig_atomic_t) 1) << (sizeof (sig_atomic_t)*CHAR_BIT-1)) - 1)
0803 #endif
0804 
0805 #endif
0806 
0807 #if defined (__TEST_PSTDINT_FOR_CORRECTNESS)
0808 
0809 /*
0810  *  Please compile with the maximum warning settings to make sure macros are
0811  *  not defined more than once.
0812  */
0813 
0814 #include <stdlib.h>
0815 #include <stdio.h>
0816 #include <string.h>
0817 
0818 #define glue3_aux(x,y,z) x ## y ## z
0819 #define glue3(x,y,z) glue3_aux(x,y,z)
0820 
0821 #define DECLU(bits) glue3(uint,bits,_t) glue3(u,bits,) = glue3(UINT,bits,_C) (0);
0822 #define DECLI(bits) glue3(int,bits,_t) glue3(i,bits,) = glue3(INT,bits,_C) (0);
0823 
0824 #define DECL(us,bits) glue3(DECL,us,) (bits)
0825 
0826 #define TESTUMAX(bits) glue3(u,bits,) = ~glue3(u,bits,); if (glue3(UINT,bits,_MAX) != glue3(u,bits,)) printf ("Something wrong with UINT%d_MAX\n", bits)
0827 
0828 #define REPORTERROR(msg) { err_n++; if (err_first <= 0) err_first = __LINE__; printf msg; }
0829 
0830 int main () {
0831     int err_n = 0;
0832     int err_first = 0;
0833     DECL(I,8)
0834     DECL(U,8)
0835     DECL(I,16)
0836     DECL(U,16)
0837     DECL(I,32)
0838     DECL(U,32)
0839 #ifdef INT64_MAX
0840     DECL(I,64)
0841     DECL(U,64)
0842 #endif
0843     intmax_t imax = INTMAX_C(0);
0844     uintmax_t umax = UINTMAX_C(0);
0845     char str0[256], str1[256];
0846 
0847     sprintf (str0, "%" PRINTF_INT32_MODIFIER "d", INT32_C(2147483647));
0848     if (0 != strcmp (str0, "2147483647")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str0));
0849     if (atoi(PRINTF_INT32_DEC_WIDTH) != (int) strlen(str0)) REPORTERROR (("Something wrong with PRINTF_INT32_DEC_WIDTH : %s\n", PRINTF_INT32_DEC_WIDTH));
0850     sprintf (str0, "%" PRINTF_INT32_MODIFIER "u", UINT32_C(4294967295));
0851     if (0 != strcmp (str0, "4294967295")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str0));
0852     if (atoi(PRINTF_UINT32_DEC_WIDTH) != (int) strlen(str0)) REPORTERROR (("Something wrong with PRINTF_UINT32_DEC_WIDTH : %s\n", PRINTF_UINT32_DEC_WIDTH));
0853 #ifdef INT64_MAX
0854     sprintf (str1, "%" PRINTF_INT64_MODIFIER "d", INT64_C(9223372036854775807));
0855     if (0 != strcmp (str1, "9223372036854775807")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str1));
0856     if (atoi(PRINTF_INT64_DEC_WIDTH) != (int) strlen(str1)) REPORTERROR (("Something wrong with PRINTF_INT64_DEC_WIDTH : %s, %d\n", PRINTF_INT64_DEC_WIDTH, (int) strlen(str1)));
0857     sprintf (str1, "%" PRINTF_INT64_MODIFIER "u", UINT64_C(18446744073709550591));
0858     if (0 != strcmp (str1, "18446744073709550591")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str1));
0859     if (atoi(PRINTF_UINT64_DEC_WIDTH) != (int) strlen(str1)) REPORTERROR (("Something wrong with PRINTF_UINT64_DEC_WIDTH : %s, %d\n", PRINTF_UINT64_DEC_WIDTH, (int) strlen(str1)));
0860 #endif
0861 
0862     sprintf (str0, "%d %x\n", 0, ~0);
0863 
0864     sprintf (str1, "%d %x\n",  i8, ~0);
0865     if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i8 : %s\n", str1));
0866     sprintf (str1, "%u %x\n",  u8, ~0);
0867     if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u8 : %s\n", str1));
0868     sprintf (str1, "%d %x\n",  i16, ~0);
0869     if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i16 : %s\n", str1));
0870     sprintf (str1, "%u %x\n",  u16, ~0);
0871     if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u16 : %s\n", str1));
0872     sprintf (str1, "%" PRINTF_INT32_MODIFIER "d %x\n",  i32, ~0);
0873     if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i32 : %s\n", str1));
0874     sprintf (str1, "%" PRINTF_INT32_MODIFIER "u %x\n",  u32, ~0);
0875     if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u32 : %s\n", str1));
0876 #ifdef INT64_MAX
0877     sprintf (str1, "%" PRINTF_INT64_MODIFIER "d %x\n",  i64, ~0);
0878     if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i64 : %s\n", str1));
0879 #endif
0880     sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "d %x\n",  imax, ~0);
0881     if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with imax : %s\n", str1));
0882     sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "u %x\n",  umax, ~0);
0883     if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with umax : %s\n", str1));
0884 
0885     TESTUMAX(8);
0886     TESTUMAX(16);
0887     TESTUMAX(32);
0888 #ifdef INT64_MAX
0889     TESTUMAX(64);
0890 #endif
0891 
0892 #define STR(v) #v
0893 #define Q(v) printf ("sizeof " STR(v) " = %u\n", (unsigned) sizeof (v));
0894     if (err_n) {
0895         printf ("pstdint.h is not correct.  Please use sizes below to correct it:\n");
0896     }
0897 
0898     Q(int)
0899     Q(unsigned)
0900     Q(long int)
0901     Q(short int)
0902     Q(int8_t)
0903     Q(int16_t)
0904     Q(int32_t)
0905 #ifdef INT64_MAX
0906     Q(int64_t)
0907 #endif
0908 
0909     return EXIT_SUCCESS;
0910 }
0911 
0912 #endif