11d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// ISO C9x  compliant stdint.h for Microsoft Visual Studio
21d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
31d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman//
41d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman//  Copyright (c) 2006-2008 Alexander Chemeris
51d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman//
61d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// Redistribution and use in source and binary forms, with or without
71d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// modification, are permitted provided that the following conditions are met:
81d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman//
91d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman//   1. Redistributions of source code must retain the above copyright notice,
101d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman//      this list of conditions and the following disclaimer.
111d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman//
121d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman//   2. Redistributions in binary form must reproduce the above copyright
131d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman//      notice, this list of conditions and the following disclaimer in the
141d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman//      documentation and/or other materials provided with the distribution.
151d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman//
161d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman//   3. The name of the author may be used to endorse or promote products
171d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman//      derived from this software without specific prior written permission.
181d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman//
191d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
201d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
211d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
221d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
231d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
241d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
251d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
261d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
271d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
281d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
291d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman//
301d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman///////////////////////////////////////////////////////////////////////////////
311d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
321d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#ifndef _MSC_VER // [
331d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#error "Use this header only with Microsoft Visual C++ compilers!"
341d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#endif // _MSC_VER ]
351d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
361d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#ifndef _MSC_STDINT_H_ // [
371d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define _MSC_STDINT_H_
381d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
391d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#if _MSC_VER > 1000
401d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#pragma once
411d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#endif
421d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
431d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#include <limits.h>
441d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
451d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// For Visual Studio 6 in C++ mode and for many Visual Studio versions when
461d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
471d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// or compiler give many errors like this:
481d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman//   error C2733: second C linkage of overloaded function 'wmemchr' not allowed
491d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#ifdef __cplusplus
501d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartmanextern "C" {
511d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#endif
521d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#  include <wchar.h>
531d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#ifdef __cplusplus
541d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman}
551d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#endif
561d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
571d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// Define _W64 macros to mark types changing their size, like intptr_t.
581d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#ifndef _W64
591d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#  if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
601d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#     define _W64 __w64
611d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#  else
621d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#     define _W64
631d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#  endif
641d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#endif
651d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
661d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
671d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// 7.18.1 Integer types
681d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
691d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// 7.18.1.1 Exact-width integer types
701d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
711d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// Visual Studio 6 and Embedded Visual C++ 4 doesn't
721d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// realize that, e.g. char has the same size as __int8
731d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// so we give up on __intX for them.
741d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#if (_MSC_VER < 1300)
751d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman   typedef char              int8_t;
761d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman   typedef short             int16_t;
771d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman   typedef int               int32_t;
781d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman   typedef unsigned char     uint8_t;
791d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman   typedef unsigned short    uint16_t;
801d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman   typedef unsigned int      uint32_t;
811d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#else
821d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman   typedef __int8            int8_t;
831d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman   typedef __int16           int16_t;
841d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman   typedef __int32           int32_t;
851d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman   typedef unsigned __int8   uint8_t;
861d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman   typedef unsigned __int16  uint16_t;
871d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman   typedef unsigned __int32  uint32_t;
881d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#endif
891d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartmantypedef __int64              int64_t;
901d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartmantypedef unsigned __int64     uint64_t;
911d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
921d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
931d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// 7.18.1.2 Minimum-width integer types
941d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartmantypedef int8_t    int_least8_t;
951d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartmantypedef int16_t   int_least16_t;
961d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartmantypedef int32_t   int_least32_t;
971d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartmantypedef int64_t   int_least64_t;
981d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartmantypedef uint8_t   uint_least8_t;
991d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartmantypedef uint16_t  uint_least16_t;
1001d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartmantypedef uint32_t  uint_least32_t;
1011d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartmantypedef uint64_t  uint_least64_t;
1021d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
1031d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// 7.18.1.3 Fastest minimum-width integer types
1041d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartmantypedef int8_t    int_fast8_t;
1051d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartmantypedef int16_t   int_fast16_t;
1061d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartmantypedef int32_t   int_fast32_t;
1071d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartmantypedef int64_t   int_fast64_t;
1081d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartmantypedef uint8_t   uint_fast8_t;
1091d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartmantypedef uint16_t  uint_fast16_t;
1101d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartmantypedef uint32_t  uint_fast32_t;
1111d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartmantypedef uint64_t  uint_fast64_t;
1121d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
1131d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// 7.18.1.4 Integer types capable of holding object pointers
1141d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#ifdef _WIN64 // [
1151d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman   typedef __int64           intptr_t;
1161d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman   typedef unsigned __int64  uintptr_t;
1171d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#else // _WIN64 ][
1181d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman   typedef _W64 int               intptr_t;
1191d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman   typedef _W64 unsigned int      uintptr_t;
1201d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#endif // _WIN64 ]
1211d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
1221d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// 7.18.1.5 Greatest-width integer types
1231d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartmantypedef int64_t   intmax_t;
1241d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartmantypedef uint64_t  uintmax_t;
1251d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
1261d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
1271d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// 7.18.2 Limits of specified-width integer types
1281d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
1291d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [   See footnote 220 at page 257 and footnote 221 at page 259
1301d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
1311d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// 7.18.2.1 Limits of exact-width integer types
1321d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INT8_MIN     ((int8_t)_I8_MIN)
1331d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INT8_MAX     _I8_MAX
1341d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INT16_MIN    ((int16_t)_I16_MIN)
1351d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INT16_MAX    _I16_MAX
1361d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INT32_MIN    ((int32_t)_I32_MIN)
1371d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INT32_MAX    _I32_MAX
1381d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INT64_MIN    ((int64_t)_I64_MIN)
1391d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INT64_MAX    _I64_MAX
1401d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define UINT8_MAX    _UI8_MAX
1411d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define UINT16_MAX   _UI16_MAX
1421d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define UINT32_MAX   _UI32_MAX
1431d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define UINT64_MAX   _UI64_MAX
1441d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
1451d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// 7.18.2.2 Limits of minimum-width integer types
1461d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INT_LEAST8_MIN    INT8_MIN
1471d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INT_LEAST8_MAX    INT8_MAX
1481d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INT_LEAST16_MIN   INT16_MIN
1491d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INT_LEAST16_MAX   INT16_MAX
1501d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INT_LEAST32_MIN   INT32_MIN
1511d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INT_LEAST32_MAX   INT32_MAX
1521d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INT_LEAST64_MIN   INT64_MIN
1531d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INT_LEAST64_MAX   INT64_MAX
1541d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define UINT_LEAST8_MAX   UINT8_MAX
1551d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define UINT_LEAST16_MAX  UINT16_MAX
1561d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define UINT_LEAST32_MAX  UINT32_MAX
1571d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define UINT_LEAST64_MAX  UINT64_MAX
1581d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
1591d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// 7.18.2.3 Limits of fastest minimum-width integer types
1601d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INT_FAST8_MIN    INT8_MIN
1611d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INT_FAST8_MAX    INT8_MAX
1621d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INT_FAST16_MIN   INT16_MIN
1631d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INT_FAST16_MAX   INT16_MAX
1641d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INT_FAST32_MIN   INT32_MIN
1651d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INT_FAST32_MAX   INT32_MAX
1661d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INT_FAST64_MIN   INT64_MIN
1671d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INT_FAST64_MAX   INT64_MAX
1681d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define UINT_FAST8_MAX   UINT8_MAX
1691d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define UINT_FAST16_MAX  UINT16_MAX
1701d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define UINT_FAST32_MAX  UINT32_MAX
1711d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define UINT_FAST64_MAX  UINT64_MAX
1721d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
1731d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// 7.18.2.4 Limits of integer types capable of holding object pointers
1741d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#ifdef _WIN64 // [
1751d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#  define INTPTR_MIN   INT64_MIN
1761d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#  define INTPTR_MAX   INT64_MAX
1771d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#  define UINTPTR_MAX  UINT64_MAX
1781d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#else // _WIN64 ][
1791d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#  define INTPTR_MIN   INT32_MIN
1801d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#  define INTPTR_MAX   INT32_MAX
1811d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#  define UINTPTR_MAX  UINT32_MAX
1821d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#endif // _WIN64 ]
1831d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
1841d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// 7.18.2.5 Limits of greatest-width integer types
1851d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INTMAX_MIN   INT64_MIN
1861d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INTMAX_MAX   INT64_MAX
1871d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define UINTMAX_MAX  UINT64_MAX
1881d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
1891d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// 7.18.3 Limits of other integer types
1901d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
1911d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#ifdef _WIN64 // [
1921d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#  define PTRDIFF_MIN  _I64_MIN
1931d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#  define PTRDIFF_MAX  _I64_MAX
1941d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#else  // _WIN64 ][
1951d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#  define PTRDIFF_MIN  _I32_MIN
1961d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#  define PTRDIFF_MAX  _I32_MAX
1971d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#endif  // _WIN64 ]
1981d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
1991d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define SIG_ATOMIC_MIN  INT_MIN
2001d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define SIG_ATOMIC_MAX  INT_MAX
2011d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
2021d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#ifndef SIZE_MAX // [
2031d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#  ifdef _WIN64 // [
2041d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#     define SIZE_MAX  _UI64_MAX
2051d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#  else // _WIN64 ][
2061d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#     define SIZE_MAX  _UI32_MAX
2071d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#  endif // _WIN64 ]
2081d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#endif // SIZE_MAX ]
2091d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
2101d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
2111d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#ifndef WCHAR_MIN // [
2121d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#  define WCHAR_MIN  0
2131d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#endif  // WCHAR_MIN ]
2141d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#ifndef WCHAR_MAX // [
2151d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#  define WCHAR_MAX  _UI16_MAX
2161d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#endif  // WCHAR_MAX ]
2171d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
2181d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define WINT_MIN  0
2191d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define WINT_MAX  _UI16_MAX
2201d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
2211d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#endif // __STDC_LIMIT_MACROS ]
2221d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
2231d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
2241d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// 7.18.4 Limits of other integer types
2251d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
2261d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [   See footnote 224 at page 260
2271d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
2281d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// 7.18.4.1 Macros for minimum-width integer constants
2291d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
2301d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INT8_C(val)  val##i8
2311d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INT16_C(val) val##i16
2321d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INT32_C(val) val##i32
2331d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INT64_C(val) val##i64
2341d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
2351d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define UINT8_C(val)  val##ui8
2361d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define UINT16_C(val) val##ui16
2371d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define UINT32_C(val) val##ui32
2381d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define UINT64_C(val) val##ui64
2391d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
2401d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman// 7.18.4.2 Macros for greatest-width integer constants
2411d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define INTMAX_C   INT64_C
2421d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#define UINTMAX_C  UINT64_C
2431d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
2441d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#endif // __STDC_CONSTANT_MACROS ]
2451d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
2461d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman
2471d80c6a8d34f59543f7df1963c22d7efa292bcb0Greg Hartman#endif // _MSC_STDINT_H_ ]
248