stdint.h revision 99f2e17ff37c7236875b28350549c127c1e6a642
/** @file
* IPRT - stdint.h wrapper (for backlevel compilers like MSC).
*/
/*
* Copyright (C) 2009 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#ifndef __iprt_stdint_h
#define __iprt_stdint_h
/*
* Use the stdint.h on systems that have one.
*/
#if !(defined(RT_OS_LINUX) && defined(__KERNEL__)) \
&& !(defined(RT_OS_FREEBSD) && defined(_KERNEL)) \
&& !defined(_MSC_VER) \
&& !defined(__IBMC__) \
&& !defined(__IBMCPP__) \
&& !defined(IPRT_NO_CRT) \
&& !defined(IPRT_DONT_USE_SYSTEM_STDINT_H) \
&& !defined(DOXYGEN_RUNNING)
# ifndef __STDC_CONSTANT_MACROS
# define __STDC_CONSTANT_MACROS
# endif
# ifndef __STDC_LIMIT_MACROS
# define __STDC_LIMIT_MACROS
# endif
# include <stdint.h>
/*
* Kludge to fix the incorrect 32-bit constant macros in
* Kernel.framework/Headers/stdin.h. uint32_t and int32_t are
* int not long as these macros use, which is significant when
* targeting AMD64. (10a222)
*/
# endif /* 64-bit darwin kludge. */
# ifndef __STDC_CONSTANT_MACROS
# define __STDC_CONSTANT_MACROS
# endif
# ifndef __STDC_LIMIT_MACROS
# define __STDC_LIMIT_MACROS
# endif
#else /* No system stdint.h */
/*
* Define the types we use.
*/
# if !(defined(RT_OS_LINUX) && defined(__KERNEL__)) \
|| defined(IPRT_NO_CRT) \
|| defined(IPRT_DONT_USE_SYSTEM_STDINT_H) \
|| defined(DOXGEN_RUNNING)
/* Simplify the [u]int64_t type detection mess. */
# ifdef __IBMCPP__
# defined IPRT_STDINT_USE_STRUCT_FOR_64_BIT_TYPES
# endif
# endif
# ifdef __IBMC__
# defined IPRT_STDINT_USE_STRUCT_FOR_64_BIT_TYPES
# endif
# endif
/* x-bit types */
# if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) || defined(RT_ARCH_SPARC) || defined(RT_ARCH_SPARC64)
# if !defined(_INT8_T_DECLARED) && !defined(_INT8_T)
typedef signed char int8_t;
# endif
# if !defined(_UINT8_T_DECLARED) && !defined(_UINT8_T)
typedef unsigned char uint8_t;
# endif
# if !defined(_INT16_T_DECLARED) && !defined(_INT16_T)
typedef signed short int16_t;
# endif
# if !defined(_UINT16_T_DECLARED) && !defined(_UINT16_T)
typedef unsigned short uint16_t;
# endif
# if !defined(_INT32_T_DECLARED) && !defined(_INT32_T)
typedef signed int int32_t;
# endif
# if !defined(_UINT32_T_DECLARED) && !defined(_UINT32_T)
typedef unsigned int uint32_t;
# endif
# if defined(_MSC_VER)
# if !defined(_INT64_T_DECLARED) && !defined(_INT64_T)
# endif
# if !defined(_UINT64_T_DECLARED) && !defined(_UINT64_T)
# endif
# elif defined(IPRT_STDINT_USE_STRUCT_FOR_64_BIT_TYPES)
# if !defined(_INT64_T_DECLARED) && !defined(_INT64_T)
# endif
# if !defined(_UINT64_T_DECLARED) && !defined(_UINT64_T)
# endif
# else /* Use long long for 64-bit types */
# if !defined(_INT64_T_DECLARED) && !defined(_INT64_T)
typedef signed long long int64_t;
# endif
# if !defined(_UINT64_T_DECLARED) && !defined(_UINT64_T)
typedef unsigned long long uint64_t;
# endif
# endif
/* max integer types */
# if !defined(_INTMAX_T_DECLARED) && !defined(_INTMAX_T)
# endif
# if !defined(_UINTMAX_T_DECLARED) && !defined(_UINTMAX_T)
# endif
# else
# error "PORTME: Add architecture. Don't forget to check the [U]INTx_C() and [U]INTMAX_MIN/MAX macros."
# endif
# endif /* !linux kernel or stuff */
/* pointer <-> integer types */
# if !defined(_MSC_VER) || defined(DOXYGEN_RUNNING)
# if ARCH_BITS == 32 \
|| defined(RT_OS_LINUX) \
|| defined(RT_OS_FREEBSD)
# if !defined(_INTPTR_T_DECLARED) && !defined(_INTPTR_T)
typedef signed long intptr_t;
# endif
# if !defined(_UINTPTR_T_DECLARED) && !defined(_UINTPTR_T)
typedef unsigned long uintptr_t;
# endif
# else
# if !defined(_INTPTR_T_DECLARED) && !defined(_INTPTR_T)
# endif
# if !defined(_UINTPTR_T_DECLARED) && !defined(_UINTPTR_T)
# endif
# endif
# endif /* !_MSC_VER */
#endif /* no system stdint.h */
/*
* Make sure the [U]INTx_C(c) macros are present.
* For In C++ source the system stdint.h may have skipped these if it was
* included before we managed to define __STDC_CONSTANT_MACROS. (Kludge alert!)
*/
#if !defined(INT8_C) \
|| !defined(INT16_C) \
|| !defined(INT32_C) \
|| !defined(INT64_C) \
|| !defined(INTMAX_C) \
|| !defined(UINT8_C) \
|| !defined(UINT16_C) \
|| !defined(UINT32_C) \
|| !defined(UINT64_C) \
|| !defined(UINTMAX_C)
#endif
/*
* Make sure the INTx_MIN and [U]INTx_MAX macros are present.
* For In C++ source the system stdint.h may have skipped these if it was
* included before we managed to define __STDC_LIMIT_MACROS. (Kludge alert!)
*/
#if !defined(INT8_MIN) \
|| !defined(INT16_MIN) \
|| !defined(INT32_MIN) \
|| !defined(INT64_MIN) \
|| !defined(INT8_MAX) \
|| !defined(INT16_MAX) \
|| !defined(INT32_MAX) \
|| !defined(INT64_MAX) \
|| !defined(UINT8_MAX) \
|| !defined(UINT16_MAX) \
|| !defined(UINT32_MAX) \
|| !defined(UINT64_MAX)
# define INTMAX_MIN INT64_MIN
# define INTMAX_MAX INT64_MAX
# define UINTMAX_MAX UINT64_MAX
#endif
#endif