15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/**
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * This file has no copyright assigned and is placed in the Public Domain.
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * This file was originally part of the w64 mingw-runtime package.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* ISO C9x  7.18  Integer types <stdint.h>
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Based on ISO/IEC SC22/WG14 9899 Committee draft (SC22 N2794)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *  THIS SOFTWARE IS NOT COPYRIGHTED
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *  Contributor: Danny Smith <danny_r_smith_2001@yahoo.co.nz>
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *  Modified for libusb/MSVC: Pete Batard <pbatard@gmail.com>
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *  This source code is offered for use in the public domain. You may
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *  use, modify or distribute it freely.
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *  This code is distributed in the hope that it will be useful but
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *  DISCLAIMED. This includes but is not limited to warranties of
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *  Date: 2010-04-02
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef _MSC_VER
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#error This header should only be used with Microsoft compilers
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef _STDINT_H
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define _STDINT_H
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef _INTPTR_T_DEFINED
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define _INTPTR_T_DEFINED
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef __intptr_t_defined
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define __intptr_t_defined
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#undef intptr_t
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifdef _WIN64
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  typedef __int64 intptr_t;
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  typedef int intptr_t;
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif /* _WIN64 */
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif /* __intptr_t_defined */
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif /* _INTPTR_T_DEFINED */
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef _UINTPTR_T_DEFINED
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define _UINTPTR_T_DEFINED
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef __uintptr_t_defined
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define __uintptr_t_defined
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#undef uintptr_t
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifdef _WIN64
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  typedef unsigned __int64 uintptr_t;
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  typedef unsigned int uintptr_t;
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif /* _WIN64 */
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif /* __uintptr_t_defined */
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif /* _UINTPTR_T_DEFINED */
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef _PTRDIFF_T_DEFINED
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define _PTRDIFF_T_DEFINED
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef _PTRDIFF_T_
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define _PTRDIFF_T_
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#undef ptrdiff_t
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifdef _WIN64
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  typedef __int64 ptrdiff_t;
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  typedef int ptrdiff_t;
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif /* _WIN64 */
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif /* _PTRDIFF_T_ */
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif /* _PTRDIFF_T_DEFINED */
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef _WCHAR_T_DEFINED
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define _WCHAR_T_DEFINED
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef __cplusplus
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  typedef unsigned short wchar_t;
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif /* C++ */
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif /* _WCHAR_T_DEFINED */
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef _WCTYPE_T_DEFINED
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define _WCTYPE_T_DEFINED
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef _WINT_T
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define _WINT_T
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  typedef unsigned short wint_t;
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  typedef unsigned short wctype_t;
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif /* _WINT_T */
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif /* _WCTYPE_T_DEFINED */
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 7.18.1.1  Exact-width integer types */
885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef __int8 int8_t;
895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef unsigned __int8   uint8_t;
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef __int16  int16_t;
915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef unsigned __int16  uint16_t;
925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef __int32  int32_t;
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef unsigned __int32  uint32_t;
945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef __int64  int64_t;
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef unsigned __int64   uint64_t;
965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 7.18.1.2  Minimum-width integer types */
985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef signed char int_least8_t;
995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef unsigned char   uint_least8_t;
1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef short  int_least16_t;
1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef unsigned short  uint_least16_t;
1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef int  int_least32_t;
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef unsigned   uint_least32_t;
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef __int64  int_least64_t;
1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef unsigned __int64   uint_least64_t;
1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*  7.18.1.3  Fastest minimum-width integer types
1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *  Not actually guaranteed to be fastest for all purposes
1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *  Here we use the exact-width types for 8 and 16-bit ints.
1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef __int8 int_fast8_t;
1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef unsigned __int8 uint_fast8_t;
1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef __int16  int_fast16_t;
1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef unsigned __int16  uint_fast16_t;
1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef __int32  int_fast32_t;
1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef unsigned  __int32  uint_fast32_t;
1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef __int64  int_fast64_t;
1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef unsigned __int64   uint_fast64_t;
1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 7.18.1.5  Greatest-width integer types */
1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef __int64  intmax_t;
1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef unsigned __int64   uintmax_t;
1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 7.18.2  Limits of specified-width integer types */
1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 7.18.2.1  Limits of exact-width integer types */
1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INT8_MIN (-128)
1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INT16_MIN (-32768)
1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INT32_MIN (-2147483647 - 1)
1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INT64_MIN  (-9223372036854775807LL - 1)
1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INT8_MAX 127
1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INT16_MAX 32767
1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INT32_MAX 2147483647
1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INT64_MAX 9223372036854775807LL
1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define UINT8_MAX 255
1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define UINT16_MAX 65535
1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define UINT32_MAX 0xffffffffU  /* 4294967295U */
1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define UINT64_MAX 0xffffffffffffffffULL /* 18446744073709551615ULL */
1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 7.18.2.2  Limits of minimum-width integer types */
1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INT_LEAST8_MIN INT8_MIN
1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INT_LEAST16_MIN INT16_MIN
1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INT_LEAST32_MIN INT32_MIN
1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INT_LEAST64_MIN INT64_MIN
1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INT_LEAST8_MAX INT8_MAX
1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INT_LEAST16_MAX INT16_MAX
1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INT_LEAST32_MAX INT32_MAX
1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INT_LEAST64_MAX INT64_MAX
1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define UINT_LEAST8_MAX UINT8_MAX
1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define UINT_LEAST16_MAX UINT16_MAX
1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define UINT_LEAST32_MAX UINT32_MAX
1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define UINT_LEAST64_MAX UINT64_MAX
1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 7.18.2.3  Limits of fastest minimum-width integer types */
1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INT_FAST8_MIN INT8_MIN
1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INT_FAST16_MIN INT16_MIN
1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INT_FAST32_MIN INT32_MIN
1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INT_FAST64_MIN INT64_MIN
1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INT_FAST8_MAX INT8_MAX
1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INT_FAST16_MAX INT16_MAX
1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INT_FAST32_MAX INT32_MAX
1675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INT_FAST64_MAX INT64_MAX
1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define UINT_FAST8_MAX UINT8_MAX
1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define UINT_FAST16_MAX UINT16_MAX
1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define UINT_FAST32_MAX UINT32_MAX
1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define UINT_FAST64_MAX UINT64_MAX
1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 7.18.2.4  Limits of integer types capable of holding
1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    object pointers */
1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifdef _WIN64
1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INTPTR_MIN INT64_MIN
1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INTPTR_MAX INT64_MAX
1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define UINTPTR_MAX UINT64_MAX
1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else
1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INTPTR_MIN INT32_MIN
1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INTPTR_MAX INT32_MAX
1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define UINTPTR_MAX UINT32_MAX
1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 7.18.2.5  Limits of greatest-width integer types */
1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INTMAX_MIN INT64_MIN
1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INTMAX_MAX INT64_MAX
1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define UINTMAX_MAX UINT64_MAX
1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 7.18.3  Limits of other integer types */
1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifdef _WIN64
1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PTRDIFF_MIN INT64_MIN
1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PTRDIFF_MAX INT64_MAX
1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else
1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PTRDIFF_MIN INT32_MIN
1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PTRDIFF_MAX INT32_MAX
1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define SIG_ATOMIC_MIN INT32_MIN
2015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define SIG_ATOMIC_MAX INT32_MAX
2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef SIZE_MAX
2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifdef _WIN64
2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define SIZE_MAX UINT64_MAX
2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else
2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define SIZE_MAX UINT32_MAX
2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef WCHAR_MIN  /* also in wchar.h */
2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define WCHAR_MIN 0U
2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define WCHAR_MAX 0xffffU
2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * wint_t is unsigned short for compatibility with MS runtime
2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define WINT_MIN 0U
2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define WINT_MAX 0xffffU
2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 7.18.4  Macros for integer constants */
2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 7.18.4.1  Macros for minimum-width integer constants
2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    Accoding to Douglas Gwyn <gwyn@arl.mil>:
2285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	"This spec was changed in ISO/IEC 9899:1999 TC1; in ISO/IEC
2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	9899:1999 as initially published, the expansion was required
2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	to be an integer constant of precisely matching type, which
2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	is impossible to accomplish for the shorter types on most
2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	platforms, because C99 provides no standard way to designate
2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	an integer constant with width less than that of type int.
2345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	TC1 changed this to require just an integer constant
2355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	*expression* with *promoted* type."
2365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	The trick used here is from Clive D W Feather.
2385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/
2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INT8_C(val) (INT_LEAST8_MAX-INT_LEAST8_MAX+(val))
2415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INT16_C(val) (INT_LEAST16_MAX-INT_LEAST16_MAX+(val))
2425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INT32_C(val) (INT_LEAST32_MAX-INT_LEAST32_MAX+(val))
2435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*  The 'trick' doesn't work in C89 for long long because, without
2445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    suffix, (val) will be evaluated as int, not intmax_t */
2455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INT64_C(val) val##i64
2465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define UINT8_C(val) (val)
2485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define UINT16_C(val) (val)
2495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define UINT32_C(val) (val##i32)
2505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define UINT64_C(val) val##ui64
2515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 7.18.4.2  Macros for greatest-width integer constants */
2535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INTMAX_C(val) val##i64
2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define UINTMAX_C(val) val##ui64
2555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
257