VirtualBox

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

Last change on this file since 21685 was 21685, checked in by vboxsync, 15 years ago

iprt/stdint.h: try use the new one.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.0 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#if 1
37# include <iprt/stdint-new.h>
38#else /* this (old) header */
39
40#ifndef ___iprt_stdint_h
41#define ___iprt_stdint_h
42
43#ifndef __STDC_CONSTANT_MACROS
44# define __STDC_CONSTANT_MACROS
45#endif
46#ifndef __STDC_LIMIT_MACROS
47# define __STDC_LIMIT_MACROS
48#endif
49
50#include <iprt/cdefs.h>
51
52#if !(defined(RT_OS_LINUX) && defined(__KERNEL__)) \
53 && !defined(_MSC_VER) \
54 && !defined(__IBMC__) \
55 && !defined(__IBMCPP__) \
56 && !defined(IPRT_NO_CRT) \
57 && !defined(IPRT_DONT_USE_SYSTEM_STDINT_H) \
58 && !defined(DOXYGEN_RUNNING)
59# include <stdint.h>
60
61# if defined(RT_OS_DARWIN) && defined(KERNEL) && defined(RT_ARCH_AMD64)
62/* Kludge to fix the incorrect 32-bit constant macros in
63 Kernel.framework/Headers/stdin.h. uint32_t and int32_t are
64 int not long as these macros use, which is significant when
65 targeting AMD64. (10a222) */
66# undef INT32_C
67# define INT32_C(c) (c)
68# undef UINT32_C
69# define UINT32_C(c) (c ## U)
70# endif /* 64-bit darwin kludge. */
71
72#else
73
74#if !(defined(RT_OS_LINUX) && defined(__KERNEL__)) || defined(IPRT_NO_CRT) || defined(IPRT_DONT_USE_SYSTEM_STDINT_H) || defined(DOXGEN_RUNNING)
75/* machine specific */
76typedef signed char __int8_t;
77typedef unsigned char __uint8_t;
78typedef short __int16_t;
79typedef unsigned short __uint16_t;
80typedef int __int32_t;
81typedef unsigned int __uint32_t;
82
83# ifdef _MSC_VER
84typedef _int64 __int64_t;
85typedef unsigned _int64 __uint64_t;
86# else
87# if defined(__IBMC__) || defined(__IBMCPP__) /* assume VAC308 without long long. */
88typedef struct { __uint32_t lo,hi; } __int64_t, __uint64_t;
89# else
90typedef long long __int64_t;
91typedef unsigned long long __uint64_t;
92# endif
93# endif
94#endif /* !linux kernel and more */
95
96#if ARCH_BITS == 32 || defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)
97typedef signed long __intptr_t;
98typedef unsigned long __uintptr_t;
99#else
100typedef __int64_t __intptr_t;
101typedef __uint64_t __uintptr_t;
102#endif
103
104
105/* the stuff we use */
106#if (!defined(RT_OS_LINUX) && !defined(__KERNEL__)) || defined(IPRT_NO_CRT)
107#ifndef _INT8_T_DECLARED
108typedef __int8_t int8_t;
109#define _INT8_T_DECLARED
110#endif
111
112#ifndef _INT16_T_DECLARED
113typedef __int16_t int16_t;
114#define _INT16_T_DECLARED
115#endif
116
117#ifndef _INT32_T_DECLARED
118typedef __int32_t int32_t;
119#define _INT32_T_DECLARED
120#endif
121
122#ifndef _INT64_T_DECLARED
123typedef __int64_t int64_t;
124#define _INT64_T_DECLARED
125#endif
126
127#ifndef _UINT8_T_DECLARED
128typedef __uint8_t uint8_t;
129#define _UINT8_T_DECLARED
130#endif
131
132#ifndef _UINT16_T_DECLARED
133typedef __uint16_t uint16_t;
134#define _UINT16_T_DECLARED
135#endif
136
137#ifndef _UINT32_T_DECLARED
138typedef __uint32_t uint32_t;
139#define _UINT32_T_DECLARED
140#endif
141
142#ifndef _UINT64_T_DECLARED
143typedef __uint64_t uint64_t;
144#define _UINT64_T_DECLARED
145#endif
146
147#endif /* !linux kernel || no-crt */
148
149#if !defined(_MSC_VER) || defined(DOXYGEN_RUNNING)
150#ifndef _INTPTR_T_DECLARED
151/** Signed interger type capable of holding a pointer value, very useful for casting. */
152typedef __intptr_t intptr_t;
153/** Unsigned interger type capable of holding a pointer value, very useful for casting. */
154typedef __uintptr_t uintptr_t;
155#define _INTPTR_T_DECLARED
156#endif
157#endif /* !_MSC_VER || DOXYGEN_RUNNING */
158
159#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
160
161#define INT8_C(c) (c)
162#define INT16_C(c) (c)
163#define INT32_C(c) (c)
164#define INT64_C(c) (c ## LL)
165
166#define UINT8_C(c) (c)
167#define UINT16_C(c) (c)
168#define UINT32_C(c) (c ## U)
169#define UINT64_C(c) (c ## ULL)
170
171#define INTMAX_C(c) (c ## LL)
172#define UINTMAX_C(c) (c ## ULL)
173
174#define INT8_MIN (-0x7f-1)
175#define INT16_MIN (-0x7fff-1)
176#define INT32_MIN (-0x7fffffff-1)
177#define INT64_MIN (-0x7fffffffffffffffLL-1)
178
179#define INT8_MAX 0x7f
180#define INT16_MAX 0x7fff
181#define INT32_MAX 0x7fffffff
182#define INT64_MAX 0x7fffffffffffffffLL
183
184#define UINT8_MAX 0xff
185#define UINT16_MAX 0xffff
186#define UINT32_MAX 0xffffffffU
187#define UINT64_MAX 0xffffffffffffffffULL
188
189#endif /* !C++ || __STDC_CONSTANT_MACROS */
190
191#if defined(RT_OS_FREEBSD) && defined(IPRT_DONT_USE_SYSTEM_STDINT_H)
192/* This is a hack to get tstVMStructGC.cpp building on FreeBSD. */
193# define __uintptr_t __bad_uintptr_t
194# define __uint64_t __bad_uint64_t
195# define __uint32_t __bad_uint32_t
196# define __uint16_t __bad_uint16_t
197# define __uint8_t __bad_uint8_t
198# define __intptr_t __bad_intptr_t
199# define __int64_t __bad_int64_t
200# define __int32_t __bad_int32_t
201# define __int16_t __bad_int16_t
202# define __int8_t __bad_int8_t
203#endif
204
205#endif /* ! have usable stdint.h */
206
207#endif
208#endif /* this (old) header */
209
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