VirtualBox

source: vbox/trunk/include/iprt/stdint.h@ 20362

Last change on this file since 20362 was 16345, checked in by vboxsync, 16 years ago

iprt/stdint.h: [U]INT32_C() is wrong in the 10a222 kernel header (stdint.h), kludge around it.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.9 KB
Line 
1/** @file
2 * IPRT - stdint.h wrapper (for backlevel compilers like MSC).
3 */
4
5/*
6 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 *
25 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
26 * Clara, CA 95054 USA or visit http://www.sun.com if you need
27 * additional information or have any questions.
28 * --------------------------------------------------------------------
29 *
30 * This code is based on:
31 *
32 * Based on various FreeBSD 5.2 headers.
33 *
34 */
35
36#ifndef ___iprt_stdint_h
37#define ___iprt_stdint_h
38
39#ifndef __STDC_CONSTANT_MACROS
40# define __STDC_CONSTANT_MACROS
41#endif
42#ifndef __STDC_LIMIT_MACROS
43# define __STDC_LIMIT_MACROS
44#endif
45
46#include <iprt/cdefs.h>
47
48#if !(defined(RT_OS_LINUX) && defined(__KERNEL__)) \
49 && !defined(_MSC_VER) \
50 && !defined(__IBMC__) \
51 && !defined(__IBMCPP__) \
52 && !defined(IPRT_NO_CRT) \
53 && !defined(IPRT_DONT_USE_SYSTEM_STDINT_H) \
54 && !defined(DOXYGEN_RUNNING)
55# include <stdint.h>
56
57# if defined(RT_OS_DARWIN) && defined(KERNEL) && defined(RT_ARCH_AMD64)
58/* Kludge to fix the incorrect 32-bit constant macros in
59 Kernel.framework/Headers/stdin.h. uint32_t and int32_t are
60 int not long as these macros use, which is significant when
61 targeting AMD64. (10a222) */
62# undef INT32_C
63# define INT32_C(c) (c)
64# undef UINT32_C
65# define UINT32_C(c) (c ## U)
66# endif /* 64-bit darwin kludge. */
67
68#else
69
70#if !(defined(RT_OS_LINUX) && defined(__KERNEL__)) || defined(IPRT_NO_CRT) || defined(IPRT_DONT_USE_SYSTEM_STDINT_H) || defined(DOXGEN_RUNNING)
71/* machine specific */
72typedef signed char __int8_t;
73typedef unsigned char __uint8_t;
74typedef short __int16_t;
75typedef unsigned short __uint16_t;
76typedef int __int32_t;
77typedef unsigned int __uint32_t;
78
79# ifdef _MSC_VER
80typedef _int64 __int64_t;
81typedef unsigned _int64 __uint64_t;
82# else
83# if defined(__IBMC__) || defined(__IBMCPP__) /* assume VAC308 without long long. */
84typedef struct { __uint32_t lo,hi; } __int64_t, __uint64_t;
85# else
86typedef long long __int64_t;
87typedef unsigned long long __uint64_t;
88# endif
89# endif
90#endif /* !linux kernel and more */
91
92#if ARCH_BITS == 32 || defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)
93typedef signed long __intptr_t;
94typedef unsigned long __uintptr_t;
95#else
96typedef __int64_t __intptr_t;
97typedef __uint64_t __uintptr_t;
98#endif
99
100
101/* the stuff we use */
102#if (!defined(RT_OS_LINUX) && !defined(__KERNEL__)) || defined(IPRT_NO_CRT)
103#ifndef _INT8_T_DECLARED
104typedef __int8_t int8_t;
105#define _INT8_T_DECLARED
106#endif
107
108#ifndef _INT16_T_DECLARED
109typedef __int16_t int16_t;
110#define _INT16_T_DECLARED
111#endif
112
113#ifndef _INT32_T_DECLARED
114typedef __int32_t int32_t;
115#define _INT32_T_DECLARED
116#endif
117
118#ifndef _INT64_T_DECLARED
119typedef __int64_t int64_t;
120#define _INT64_T_DECLARED
121#endif
122
123#ifndef _UINT8_T_DECLARED
124typedef __uint8_t uint8_t;
125#define _UINT8_T_DECLARED
126#endif
127
128#ifndef _UINT16_T_DECLARED
129typedef __uint16_t uint16_t;
130#define _UINT16_T_DECLARED
131#endif
132
133#ifndef _UINT32_T_DECLARED
134typedef __uint32_t uint32_t;
135#define _UINT32_T_DECLARED
136#endif
137
138#ifndef _UINT64_T_DECLARED
139typedef __uint64_t uint64_t;
140#define _UINT64_T_DECLARED
141#endif
142
143#endif /* !linux kernel || no-crt */
144
145#if !defined(_MSC_VER) || defined(DOXYGEN_RUNNING)
146#ifndef _INTPTR_T_DECLARED
147/** Signed interger type capable of holding a pointer value, very useful for casting. */
148typedef __intptr_t intptr_t;
149/** Unsigned interger type capable of holding a pointer value, very useful for casting. */
150typedef __uintptr_t uintptr_t;
151#define _INTPTR_T_DECLARED
152#endif
153#endif /* !_MSC_VER || DOXYGEN_RUNNING */
154
155#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
156
157#define INT8_C(c) (c)
158#define INT16_C(c) (c)
159#define INT32_C(c) (c)
160#define INT64_C(c) (c ## LL)
161
162#define UINT8_C(c) (c)
163#define UINT16_C(c) (c)
164#define UINT32_C(c) (c ## U)
165#define UINT64_C(c) (c ## ULL)
166
167#define INTMAX_C(c) (c ## LL)
168#define UINTMAX_C(c) (c ## ULL)
169
170#define INT8_MIN (-0x7f-1)
171#define INT16_MIN (-0x7fff-1)
172#define INT32_MIN (-0x7fffffff-1)
173#define INT64_MIN (-0x7fffffffffffffffLL-1)
174
175#define INT8_MAX 0x7f
176#define INT16_MAX 0x7fff
177#define INT32_MAX 0x7fffffff
178#define INT64_MAX 0x7fffffffffffffffLL
179
180#define UINT8_MAX 0xff
181#define UINT16_MAX 0xffff
182#define UINT32_MAX 0xffffffffU
183#define UINT64_MAX 0xffffffffffffffffULL
184
185#endif /* !C++ || __STDC_CONSTANT_MACROS */
186
187#if defined(RT_OS_FREEBSD) && defined(IPRT_DONT_USE_SYSTEM_STDINT_H)
188/* This is a hack to get tstVMStructGC.cpp building on FreeBSD. */
189# define __uintptr_t __bad_uintptr_t
190# define __uint64_t __bad_uint64_t
191# define __uint32_t __bad_uint32_t
192# define __uint16_t __bad_uint16_t
193# define __uint8_t __bad_uint8_t
194# define __intptr_t __bad_intptr_t
195# define __int64_t __bad_int64_t
196# define __int32_t __bad_int32_t
197# define __int16_t __bad_int16_t
198# define __int8_t __bad_int8_t
199#endif
200
201#endif /* ! have usable stdint.h */
202
203#endif
204
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette