Path: blob/devel/elmergrid/src/metis-5.1.0/GKlib/ms_stdint.h
3206 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 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 wrap <wchar.h> include with 'extern "C++" {}'45// or compiler give many errors like this:46// error C2733: second C linkage of overloaded function 'wmemchr' not allowed47#if (_MSC_VER < 1300) && defined(__cplusplus)48extern "C++" {49#endif50# include <wchar.h>51#if (_MSC_VER < 1300) && defined(__cplusplus)52}53#endif5455// 7.18.1 Integer types5657// 7.18.1.1 Exact-width integer types58typedef __int8 int8_t;59typedef __int16 int16_t;60typedef __int32 int32_t;61typedef __int64 int64_t;62typedef unsigned __int8 uint8_t;63typedef unsigned __int16 uint16_t;64typedef unsigned __int32 uint32_t;65typedef unsigned __int64 uint64_t;6667// 7.18.1.2 Minimum-width integer types68typedef int8_t int_least8_t;69typedef int16_t int_least16_t;70typedef int32_t int_least32_t;71typedef int64_t int_least64_t;72typedef uint8_t uint_least8_t;73typedef uint16_t uint_least16_t;74typedef uint32_t uint_least32_t;75typedef uint64_t uint_least64_t;7677// 7.18.1.3 Fastest minimum-width integer types78typedef int8_t int_fast8_t;79typedef int16_t int_fast16_t;80typedef int32_t int_fast32_t;81typedef int64_t int_fast64_t;82typedef uint8_t uint_fast8_t;83typedef uint16_t uint_fast16_t;84typedef uint32_t uint_fast32_t;85typedef uint64_t uint_fast64_t;8687// 7.18.1.4 Integer types capable of holding object pointers88#ifdef _WIN64 // [89typedef __int64 intptr_t;90typedef unsigned __int64 uintptr_t;91#else // _WIN64 ][92typedef int intptr_t;93typedef unsigned int uintptr_t;94#endif // _WIN64 ]9596// 7.18.1.5 Greatest-width integer types97typedef int64_t intmax_t;98typedef uint64_t uintmax_t;99100101// 7.18.2 Limits of specified-width integer types102103#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259104105// 7.18.2.1 Limits of exact-width integer types106#define INT8_MIN ((int8_t)_I8_MIN)107#define INT8_MAX _I8_MAX108#define INT16_MIN ((int16_t)_I16_MIN)109#define INT16_MAX _I16_MAX110#define INT32_MIN ((int32_t)_I32_MIN)111#define INT32_MAX _I32_MAX112#define INT64_MIN ((int64_t)_I64_MIN)113#define INT64_MAX _I64_MAX114#define UINT8_MAX _UI8_MAX115#define UINT16_MAX _UI16_MAX116#define UINT32_MAX _UI32_MAX117#define UINT64_MAX _UI64_MAX118119// 7.18.2.2 Limits of minimum-width integer types120#define INT_LEAST8_MIN INT8_MIN121#define INT_LEAST8_MAX INT8_MAX122#define INT_LEAST16_MIN INT16_MIN123#define INT_LEAST16_MAX INT16_MAX124#define INT_LEAST32_MIN INT32_MIN125#define INT_LEAST32_MAX INT32_MAX126#define INT_LEAST64_MIN INT64_MIN127#define INT_LEAST64_MAX INT64_MAX128#define UINT_LEAST8_MAX UINT8_MAX129#define UINT_LEAST16_MAX UINT16_MAX130#define UINT_LEAST32_MAX UINT32_MAX131#define UINT_LEAST64_MAX UINT64_MAX132133// 7.18.2.3 Limits of fastest minimum-width integer types134#define INT_FAST8_MIN INT8_MIN135#define INT_FAST8_MAX INT8_MAX136#define INT_FAST16_MIN INT16_MIN137#define INT_FAST16_MAX INT16_MAX138#define INT_FAST32_MIN INT32_MIN139#define INT_FAST32_MAX INT32_MAX140#define INT_FAST64_MIN INT64_MIN141#define INT_FAST64_MAX INT64_MAX142#define UINT_FAST8_MAX UINT8_MAX143#define UINT_FAST16_MAX UINT16_MAX144#define UINT_FAST32_MAX UINT32_MAX145#define UINT_FAST64_MAX UINT64_MAX146147// 7.18.2.4 Limits of integer types capable of holding object pointers148#ifdef _WIN64 // [149# define INTPTR_MIN INT64_MIN150# define INTPTR_MAX INT64_MAX151# define UINTPTR_MAX UINT64_MAX152#else // _WIN64 ][153# define INTPTR_MIN INT32_MIN154# define INTPTR_MAX INT32_MAX155# define UINTPTR_MAX UINT32_MAX156#endif // _WIN64 ]157158// 7.18.2.5 Limits of greatest-width integer types159#define INTMAX_MIN INT64_MIN160#define INTMAX_MAX INT64_MAX161#define UINTMAX_MAX UINT64_MAX162163// 7.18.3 Limits of other integer types164165#ifdef _WIN64 // [166# define PTRDIFF_MIN _I64_MIN167# define PTRDIFF_MAX _I64_MAX168#else // _WIN64 ][169# define PTRDIFF_MIN _I32_MIN170# define PTRDIFF_MAX _I32_MAX171#endif // _WIN64 ]172173#define SIG_ATOMIC_MIN INT_MIN174#define SIG_ATOMIC_MAX INT_MAX175176#ifndef SIZE_MAX // [177# ifdef _WIN64 // [178# define SIZE_MAX _UI64_MAX179# else // _WIN64 ][180# define SIZE_MAX _UI32_MAX181# endif // _WIN64 ]182#endif // SIZE_MAX ]183184// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>185#ifndef WCHAR_MIN // [186# define WCHAR_MIN 0187#endif // WCHAR_MIN ]188#ifndef WCHAR_MAX // [189# define WCHAR_MAX _UI16_MAX190#endif // WCHAR_MAX ]191192#define WINT_MIN 0193#define WINT_MAX _UI16_MAX194195#endif // __STDC_LIMIT_MACROS ]196197198// 7.18.4 Limits of other integer types199200#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260201202// 7.18.4.1 Macros for minimum-width integer constants203204#define INT8_C(val) val##i8205#define INT16_C(val) val##i16206#define INT32_C(val) val##i32207#define INT64_C(val) val##i64208209#define UINT8_C(val) val##ui8210#define UINT16_C(val) val##ui16211#define UINT32_C(val) val##ui32212#define UINT64_C(val) val##ui64213214// 7.18.4.2 Macros for greatest-width integer constants215#define INTMAX_C INT64_C216#define UINTMAX_C UINT64_C217218#endif // __STDC_CONSTANT_MACROS ]219220221#endif // _MSC_STDINT_H_ ]222223224