VirtualBox

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

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

OSE header fixe

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.6 KB
Line 
1/** @file
2 * IPRT - stdint.h wrapper (for backlevel compilers like MSC).
3 */
4
5/*
6 * Copyright (C) 2009 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#ifndef __iprt_stdint_h
31#define __iprt_stdint_h
32
33#include <iprt/cdefs.h>
34
35
36/*
37 * Use the stdint.h on systems that have one.
38 */
39#if !(defined(RT_OS_LINUX) && defined(__KERNEL__)) \
40 && !defined(_MSC_VER) \
41 && !defined(__IBMC__) \
42 && !defined(__IBMCPP__) \
43 && !defined(IPRT_NO_CRT) \
44 && !defined(IPRT_DONT_USE_SYSTEM_STDINT_H) \
45 && !defined(DOXYGEN_RUNNING)
46
47# ifndef __STDC_CONSTANT_MACROS
48# define __STDC_CONSTANT_MACROS
49# endif
50# ifndef __STDC_LIMIT_MACROS
51# define __STDC_LIMIT_MACROS
52# endif
53# include <stdint.h>
54
55# if defined(RT_OS_DARWIN) && defined(KERNEL) && defined(RT_ARCH_AMD64)
56 /*
57 * Kludge to fix the incorrect 32-bit constant macros in
58 * Kernel.framework/Headers/stdin.h. uint32_t and int32_t are
59 * int not long as these macros use, which is significant when
60 * targeting AMD64. (10a222)
61 */
62# undef INT32_C
63# define INT32_C(Value) (Value)
64# undef UINT32_C
65# define UINT32_C(Value) (Value ## U)
66# endif /* 64-bit darwin kludge. */
67
68#else /* No system stdint.h */
69
70/*
71 * Define the types we use.
72 * The linux kernel defines all these in linux/types.h, so skip it.
73 */
74# if !(defined(RT_OS_LINUX) && defined(__KERNEL__)) \
75 || defined(IPRT_NO_CRT) \
76 || defined(IPRT_DONT_USE_SYSTEM_STDINT_H) \
77 || defined(DOXGEN_RUNNING)
78
79 /* Simplify the [u]int64_t type detection mess. */
80# undef IPRT_STDINT_USE_STRUCT_FOR_64_BIT_TYPES
81# ifdef __IBMCPP__
82# if __IBMCPP__ < 350 && (defined(__WINDOWS__) || defined(_AIX) || defined(__OS2__))
83# defined IPRT_STDINT_USE_STRUCT_FOR_64_BIT_TYPES
84# endif
85# endif
86# ifdef __IBMC__
87# if __IBMC__ < 350 && (defined(__WINDOWS__) || defined(_AIX) || defined(__OS2__))
88# defined IPRT_STDINT_USE_STRUCT_FOR_64_BIT_TYPES
89# endif
90# endif
91
92 /* x-bit types */
93# if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
94# if !defined(_INT8_T_DECLARED) && !defined(_INT8_T)
95typedef signed char int8_t;
96# endif
97# if !defined(_UINT8_T_DECLARED) && !defined(_UINT8_T)
98typedef unsigned char uint8_t;
99# endif
100# if !defined(_INT16_T_DECLARED) && !defined(_INT16_T)
101typedef signed short int16_t;
102# endif
103# if !defined(_UINT16_T_DECLARED) && !defined(_UINT16_T)
104typedef unsigned short uint16_t;
105# endif
106# if !defined(_INT32_T_DECLARED) && !defined(_INT32_T)
107typedef signed int int32_t;
108# endif
109# if !defined(_UINT32_T_DECLARED) && !defined(_UINT32_T)
110typedef unsigned int uint32_t;
111# endif
112# if defined(_MSC_VER)
113# if !defined(_INT64_T_DECLARED) && !defined(_INT64_T)
114typedef signed _int64 int64_t;
115# endif
116# if !defined(_UINT64_T_DECLARED) && !defined(_UINT64_T)
117typedef unsigned _int64 uint64_t;
118# endif
119# elif defined(IPRT_STDINT_USE_STRUCT_FOR_64_BIT_TYPES)
120# if !defined(_INT64_T_DECLARED) && !defined(_INT64_T)
121typedef struct { uint32_t lo; int32_t hi; } int64_t;
122# endif
123# if !defined(_UINT64_T_DECLARED) && !defined(_UINT64_T)
124typedef struct { uint32_t lo; uint32_t hi; } uint64_t;
125# endif
126# else /* Use long long for 64-bit types */
127# if !defined(_INT64_T_DECLARED) && !defined(_INT64_T)
128typedef signed long long int64_t;
129# endif
130# if !defined(_UINT64_T_DECLARED) && !defined(_UINT64_T)
131typedef unsigned long long uint64_t;
132# endif
133# endif
134
135 /* max integer types */
136# if !defined(_INTMAX_T_DECLARED) && !defined(_INTMAX_T)
137typedef int64_t intmax_t;
138# endif
139# if !defined(_UINTMAX_T_DECLARED) && !defined(_UINTMAX_T)
140typedef uint64_t uintmax_t;
141# endif
142
143# else
144# error "PORTME: Add architecture. Don't forget to check the [U]INTx_C() and [U]INTMAX_MIN/MAX macros."
145# endif
146
147# endif /* !linux kernel or stuff */
148
149 /* pointer <-> integer types */
150# if !defined(_MSC_VER) || defined(DOXYGEN_RUNNING)
151# if ARCH_BITS == 32 \
152 || defined(RT_OS_LINUX) \
153 || defined(RT_OS_FREEBSD)
154# if !defined(_INTPTR_T_DECLARED) && !defined(_INTPTR_T)
155typedef signed long intptr_t;
156# endif
157# if !defined(_UINTPTR_T_DECLARED) && !defined(_UINTPTR_T)
158typedef unsigned long uintptr_t;
159# endif
160# else
161# if !defined(_INTPTR_T_DECLARED) && !defined(_INTPTR_T)
162typedef int64_t intptr_t;
163# endif
164# if !defined(_UINTPTR_T_DECLARED) && !defined(_UINTPTR_T)
165typedef uint64_t uintptr_t;
166# endif
167# endif
168# endif /* !_MSC_VER */
169
170#endif /* no system stdint.h */
171
172
173/*
174 * Make sure the [U]INTx_C(c) macros are present.
175 * For In C++ source the system stdint.h may have skipped these if it was
176 * included before we managed to define __STDC_CONSTANT_MACROS. (Kludge alert!)
177 */
178#if !defined(INT8_C) \
179 || !defined(INT16_C) \
180 || !defined(INT32_C) \
181 || !defined(INT64_C) \
182 || !defined(INTMAX_C) \
183 || !defined(UINT8_C) \
184 || !defined(UINT16_C) \
185 || !defined(UINT32_C) \
186 || !defined(UINT64_C) \
187 || !defined(UINTMAX_C)
188# define INT8_C(Value) (Value)
189# define INT16_C(Value) (Value)
190# define INT32_C(Value) (Value)
191# define INT64_C(Value) (Value ## LL)
192# define UINT8_C(Value) (Value)
193# define UINT16_C(Value) (Value)
194# define UINT32_C(Value) (Value ## U)
195# define UINT64_C(Value) (Value ## ULL)
196# define INTMAX_C(Value) INT64_C(Value)
197# define UINTMAX_C(Value) UINT64_C(Value)
198#endif
199
200
201/*
202 * Make sure the INTx_MIN and [U]INTx_MAX macros are present.
203 * For In C++ source the system stdint.h may have skipped these if it was
204 * included before we managed to define __STDC_LIMIT_MACROS. (Kludge alert!)
205 */
206#if !defined(INT8_MIN) \
207 || !defined(INT16_MIN) \
208 || !defined(INT32_MIN) \
209 || !defined(INT64_MIN) \
210 || !defined(INT8_MAX) \
211 || !defined(INT16_MAX) \
212 || !defined(INT32_MAX) \
213 || !defined(INT64_MAX) \
214 || !defined(UINT8_MAX) \
215 || !defined(UINT16_MAX) \
216 || !defined(UINT32_MAX) \
217 || !defined(UINT64_MAX)
218# define INT8_MIN (INT8_C(-0x7f) - 1)
219# define INT16_MIN (INT16_C(-0x7fff) - 1)
220# define INT32_MIN (INT32_C(-0x7fffffff) - 1)
221# define INT64_MIN (INT64_C(-0x7fffffffffffffff) - 1)
222# define INT8_MAX INT8_C(0x7f)
223# define INT16_MAX INT16_C(0x7fff)
224# define INT32_MAX INT32_C(0x7fffffff)
225# define INT64_MAX INT64_C(0x7fffffffffffffff)
226# define UINT8_MAX UINT8_C(0xff)
227# define UINT16_MAX UINT16_C(0xffff)
228# define UINT32_MAX UINT32_C(0xffffffff)
229# define UINT64_MAX UINT64_C(0xffffffffffffffff)
230
231# define INTMAX_MIN INT64_MIN
232# define INTMAX_MAX INT64_MAX
233# define UINTMAX_MAX UINT64_MAX
234#endif
235
236#endif
237
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