Path: blob/master/Utilities/cmlibuv/include/uv/stdint-msvc2008.h
3156 views
// ISO C9x compliant stdint.h for Microsoft Visual Studio1// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N11242//3// Copyright (c) 2006-2008 Alexander Chemeris4//5// Redistribution and use in source and binary forms, with or without6// modification, are permitted provided that the following conditions are met:7//8// 1. Redistributions of source code must retain the above copyright notice,9// this list of conditions and the following disclaimer.10//11// 2. Redistributions in binary form must reproduce the above copyright12// notice, this list of conditions and the following disclaimer in the13// documentation and/or other materials provided with the distribution.14//15// 3. The name of the author may be used to endorse or promote products16// derived from this software without specific prior written permission.17//18// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED19// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF20// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO21// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,22// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,23// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;24// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,25// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR26// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF27// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.28//29///////////////////////////////////////////////////////////////////////////////3031#ifndef _MSC_VER // [32#error "Use this header only with Microsoft Visual C++ compilers!"33#endif // _MSC_VER ]3435#ifndef _MSC_STDINT_H_ // [36#define _MSC_STDINT_H_3738#if _MSC_VER > 100039#pragma once40#endif4142#include <limits.h>4344// For Visual Studio 6 in C++ mode and for many Visual Studio versions when45// compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'46// or compiler give many errors like this:47// error C2733: second C linkage of overloaded function 'wmemchr' not allowed48#ifdef __cplusplus49extern "C" {50#endif51# include <wchar.h>52#ifdef __cplusplus53}54#endif5556// Define _W64 macros to mark types changing their size, like intptr_t.57#ifndef _W6458# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 130059# define _W64 __w6460# else61# define _W6462# endif63#endif646566// 7.18.1 Integer types6768// 7.18.1.1 Exact-width integer types6970// Visual Studio 6 and Embedded Visual C++ 4 doesn't71// realize that, e.g. char has the same size as __int872// so we give up on __intX for them.73#if (_MSC_VER < 1300)74typedef signed char int8_t;75typedef signed short int16_t;76typedef signed int int32_t;77typedef unsigned char uint8_t;78typedef unsigned short uint16_t;79typedef unsigned int uint32_t;80#else81typedef signed __int8 int8_t;82typedef signed __int16 int16_t;83typedef signed __int32 int32_t;84typedef unsigned __int8 uint8_t;85typedef unsigned __int16 uint16_t;86typedef unsigned __int32 uint32_t;87#endif88typedef signed __int64 int64_t;89typedef unsigned __int64 uint64_t;909192// 7.18.1.2 Minimum-width integer types93typedef int8_t int_least8_t;94typedef int16_t int_least16_t;95typedef int32_t int_least32_t;96typedef int64_t int_least64_t;97typedef uint8_t uint_least8_t;98typedef uint16_t uint_least16_t;99typedef uint32_t uint_least32_t;100typedef uint64_t uint_least64_t;101102// 7.18.1.3 Fastest minimum-width integer types103typedef int8_t int_fast8_t;104typedef int16_t int_fast16_t;105typedef int32_t int_fast32_t;106typedef int64_t int_fast64_t;107typedef uint8_t uint_fast8_t;108typedef uint16_t uint_fast16_t;109typedef uint32_t uint_fast32_t;110typedef uint64_t uint_fast64_t;111112// 7.18.1.4 Integer types capable of holding object pointers113#ifdef _WIN64 // [114typedef signed __int64 intptr_t;115typedef unsigned __int64 uintptr_t;116#else // _WIN64 ][117typedef _W64 signed int intptr_t;118typedef _W64 unsigned int uintptr_t;119#endif // _WIN64 ]120121// 7.18.1.5 Greatest-width integer types122typedef int64_t intmax_t;123typedef uint64_t uintmax_t;124125126// 7.18.2 Limits of specified-width integer types127128#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259129130// 7.18.2.1 Limits of exact-width integer types131#define INT8_MIN ((int8_t)_I8_MIN)132#define INT8_MAX _I8_MAX133#define INT16_MIN ((int16_t)_I16_MIN)134#define INT16_MAX _I16_MAX135#define INT32_MIN ((int32_t)_I32_MIN)136#define INT32_MAX _I32_MAX137#define INT64_MIN ((int64_t)_I64_MIN)138#define INT64_MAX _I64_MAX139#define UINT8_MAX _UI8_MAX140#define UINT16_MAX _UI16_MAX141#define UINT32_MAX _UI32_MAX142#define UINT64_MAX _UI64_MAX143144// 7.18.2.2 Limits of minimum-width integer types145#define INT_LEAST8_MIN INT8_MIN146#define INT_LEAST8_MAX INT8_MAX147#define INT_LEAST16_MIN INT16_MIN148#define INT_LEAST16_MAX INT16_MAX149#define INT_LEAST32_MIN INT32_MIN150#define INT_LEAST32_MAX INT32_MAX151#define INT_LEAST64_MIN INT64_MIN152#define INT_LEAST64_MAX INT64_MAX153#define UINT_LEAST8_MAX UINT8_MAX154#define UINT_LEAST16_MAX UINT16_MAX155#define UINT_LEAST32_MAX UINT32_MAX156#define UINT_LEAST64_MAX UINT64_MAX157158// 7.18.2.3 Limits of fastest minimum-width integer types159#define INT_FAST8_MIN INT8_MIN160#define INT_FAST8_MAX INT8_MAX161#define INT_FAST16_MIN INT16_MIN162#define INT_FAST16_MAX INT16_MAX163#define INT_FAST32_MIN INT32_MIN164#define INT_FAST32_MAX INT32_MAX165#define INT_FAST64_MIN INT64_MIN166#define INT_FAST64_MAX INT64_MAX167#define UINT_FAST8_MAX UINT8_MAX168#define UINT_FAST16_MAX UINT16_MAX169#define UINT_FAST32_MAX UINT32_MAX170#define UINT_FAST64_MAX UINT64_MAX171172// 7.18.2.4 Limits of integer types capable of holding object pointers173#ifdef _WIN64 // [174# define INTPTR_MIN INT64_MIN175# define INTPTR_MAX INT64_MAX176# define UINTPTR_MAX UINT64_MAX177#else // _WIN64 ][178# define INTPTR_MIN INT32_MIN179# define INTPTR_MAX INT32_MAX180# define UINTPTR_MAX UINT32_MAX181#endif // _WIN64 ]182183// 7.18.2.5 Limits of greatest-width integer types184#define INTMAX_MIN INT64_MIN185#define INTMAX_MAX INT64_MAX186#define UINTMAX_MAX UINT64_MAX187188// 7.18.3 Limits of other integer types189190#ifdef _WIN64 // [191# define PTRDIFF_MIN _I64_MIN192# define PTRDIFF_MAX _I64_MAX193#else // _WIN64 ][194# define PTRDIFF_MIN _I32_MIN195# define PTRDIFF_MAX _I32_MAX196#endif // _WIN64 ]197198#define SIG_ATOMIC_MIN INT_MIN199#define SIG_ATOMIC_MAX INT_MAX200201#ifndef SIZE_MAX // [202# ifdef _WIN64 // [203# define SIZE_MAX _UI64_MAX204# else // _WIN64 ][205# define SIZE_MAX _UI32_MAX206# endif // _WIN64 ]207#endif // SIZE_MAX ]208209// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>210#ifndef WCHAR_MIN // [211# define WCHAR_MIN 0212#endif // WCHAR_MIN ]213#ifndef WCHAR_MAX // [214# define WCHAR_MAX _UI16_MAX215#endif // WCHAR_MAX ]216217#define WINT_MIN 0218#define WINT_MAX _UI16_MAX219220#endif // __STDC_LIMIT_MACROS ]221222223// 7.18.4 Limits of other integer types224225#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260226227// 7.18.4.1 Macros for minimum-width integer constants228229#define INT8_C(val) val##i8230#define INT16_C(val) val##i16231#define INT32_C(val) val##i32232#define INT64_C(val) val##i64233234#define UINT8_C(val) val##ui8235#define UINT16_C(val) val##ui16236#define UINT32_C(val) val##ui32237#define UINT64_C(val) val##ui64238239// 7.18.4.2 Macros for greatest-width integer constants240#define INTMAX_C INT64_C241#define UINTMAX_C UINT64_C242243#endif // __STDC_CONSTANT_MACROS ]244245246#endif // _MSC_STDINT_H_ ]247248249