~ubuntu-branches/ubuntu/raring/virtualbox-ose/raring

« back to all changes in this revision

Viewing changes to include/iprt/stdint.h

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2009-12-18 16:44:29 UTC
  • mfrom: (0.3.3 upstream) (0.4.6 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091218164429-jd34ccexpv5na11a
Tags: 3.1.2-dfsg-1ubuntu1
* Merge from Debian unstable (LP: #498219), remaining changes:
  - Disable update action
    - debian/patches/u01-disable-update-action.dpatch
  - VirtualBox should go in Accessories, not in System tools (LP: #288590)
    - debian/virtualbox-ose-qt.files/virtualbox-ose.desktop
  - Add Apport hook
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Add Launchpad integration
    - debian/control
    - debian/lpi-bug.xpm
    - debian/patches/u02-lp-integration.dpatch
* Fixes the following bugs:
  - Kernel module fails to build with Linux >= 2.6.32 (LP: #474625)
  - X.Org drivers need to be rebuilt against X-Server 1.7 (LP: #495935)
  - The *-source packages try to build the kernel modules even though the
    kernel headers aren't available (LP: #473334)
* Replace *-source packages with transitional packages for *-dkms.
* Adapt u01-disable-update-action.dpatch and u02-lp-integration.dpatch for
  new upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 */
4
4
 
5
5
/*
6
 
 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
 
6
 * Copyright (C) 2009 Sun Microsystems, Inc.
7
7
 *
8
8
 * This file is part of VirtualBox Open Source Edition (OSE), as
9
9
 * available from http://www.virtualbox.org. This file is free software;
25
25
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
26
26
 * Clara, CA 95054 USA or visit http://www.sun.com if you need
27
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
28
 */
35
29
 
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
 
30
#ifndef __iprt_stdint_h
 
31
#define __iprt_stdint_h
45
32
 
46
33
#include <iprt/cdefs.h>
47
34
 
 
35
 
 
36
/*
 
37
 * Use the stdint.h on systems that have one.
 
38
 */
48
39
#if !(defined(RT_OS_LINUX) && defined(__KERNEL__))  \
 
40
  && !(defined(RT_OS_FREEBSD) && defined(_KERNEL)) \
49
41
  && !defined(_MSC_VER) \
50
42
  && !defined(__IBMC__) \
51
43
  && !defined(__IBMCPP__) \
52
44
  && !defined(IPRT_NO_CRT) \
53
45
  && !defined(IPRT_DONT_USE_SYSTEM_STDINT_H) \
54
46
  && !defined(DOXYGEN_RUNNING)
 
47
 
 
48
# ifndef __STDC_CONSTANT_MACROS
 
49
#  define __STDC_CONSTANT_MACROS
 
50
# endif
 
51
# ifndef __STDC_LIMIT_MACROS
 
52
#  define __STDC_LIMIT_MACROS
 
53
# endif
55
54
# include <stdint.h>
56
55
 
57
56
# 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) */
 
57
 /*
 
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
  */
62
63
#  undef  INT32_C
63
 
#  define INT32_C(c)        (c)
 
64
#  define INT32_C(Value)    (Value)
64
65
#  undef  UINT32_C
65
 
#  define UINT32_C(c)       (c ## U)
 
66
#  define UINT32_C(Value)   (Value ## U)
66
67
# endif /* 64-bit darwin kludge. */
67
68
 
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 */
72
 
typedef signed char         __int8_t;
73
 
typedef unsigned char       __uint8_t;
74
 
typedef short               __int16_t;
75
 
typedef unsigned short      __uint16_t;
76
 
typedef int                 __int32_t;
77
 
typedef unsigned int        __uint32_t;
78
 
 
79
 
# ifdef _MSC_VER
80
 
typedef _int64              __int64_t;
81
 
typedef unsigned _int64     __uint64_t;
82
 
# else
83
 
#  if defined(__IBMC__) || defined(__IBMCPP__) /* assume VAC308 without long long. */
84
 
typedef struct { __uint32_t lo,hi; } __int64_t, __uint64_t;
85
 
#  else
86
 
typedef long long           __int64_t;
87
 
typedef 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)
93
 
typedef signed long             __intptr_t;
94
 
typedef unsigned long           __uintptr_t;
95
 
#else
96
 
typedef __int64_t               __intptr_t;
97
 
typedef __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
104
 
typedef __int8_t        int8_t;
105
 
#define _INT8_T_DECLARED
106
 
#endif
107
 
 
108
 
#ifndef _INT16_T_DECLARED
109
 
typedef __int16_t       int16_t;
110
 
#define _INT16_T_DECLARED
111
 
#endif
112
 
 
113
 
#ifndef _INT32_T_DECLARED
114
 
typedef __int32_t       int32_t;
115
 
#define _INT32_T_DECLARED
116
 
#endif
117
 
 
118
 
#ifndef _INT64_T_DECLARED
119
 
typedef __int64_t       int64_t;
120
 
#define _INT64_T_DECLARED
121
 
#endif
122
 
 
123
 
#ifndef _UINT8_T_DECLARED
124
 
typedef __uint8_t       uint8_t;
125
 
#define _UINT8_T_DECLARED
126
 
#endif
127
 
 
128
 
#ifndef _UINT16_T_DECLARED
129
 
typedef __uint16_t      uint16_t;
130
 
#define _UINT16_T_DECLARED
131
 
#endif
132
 
 
133
 
#ifndef _UINT32_T_DECLARED
134
 
typedef __uint32_t      uint32_t;
135
 
#define _UINT32_T_DECLARED
136
 
#endif
137
 
 
138
 
#ifndef _UINT64_T_DECLARED
139
 
typedef __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. */
148
 
typedef __intptr_t              intptr_t;
149
 
/** Unsigned interger type capable of holding a pointer value, very useful for casting. */
150
 
typedef __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 */
 
69
#elif defined(RT_OS_FREEBSD) && defined(_KERNEL) \
 
70
 
 
71
# ifndef __STDC_CONSTANT_MACROS
 
72
#  define __STDC_CONSTANT_MACROS
 
73
# endif
 
74
# ifndef __STDC_LIMIT_MACROS
 
75
#  define __STDC_LIMIT_MACROS
 
76
# endif
 
77
# include <sys/stdint.h>
 
78
 
 
79
#else /* No system stdint.h */
 
80
 
 
81
/*
 
82
 * Define the types we use.
 
83
 * The linux kernel defines all these in linux/types.h, so skip it.
 
84
 */
 
85
# if !(defined(RT_OS_LINUX) && defined(__KERNEL__)) \
 
86
  || defined(IPRT_NO_CRT) \
 
87
  || defined(IPRT_DONT_USE_SYSTEM_STDINT_H) \
 
88
  || defined(DOXGEN_RUNNING)
 
89
 
 
90
    /* Simplify the [u]int64_t type detection mess. */
 
91
# undef IPRT_STDINT_USE_STRUCT_FOR_64_BIT_TYPES
 
92
# ifdef __IBMCPP__
 
93
#  if __IBMCPP__ < 350 && (defined(__WINDOWS__) || defined(_AIX) || defined(__OS2__))
 
94
#   defined IPRT_STDINT_USE_STRUCT_FOR_64_BIT_TYPES
 
95
#  endif
 
96
# endif
 
97
# ifdef __IBMC__
 
98
#  if __IBMC__   < 350 && (defined(__WINDOWS__) || defined(_AIX) || defined(__OS2__))
 
99
#   defined IPRT_STDINT_USE_STRUCT_FOR_64_BIT_TYPES
 
100
#  endif
 
101
# endif
 
102
 
 
103
    /* x-bit types */
 
104
#  if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
 
105
#   if !defined(_INT8_T_DECLARED)   && !defined(_INT8_T)
 
106
typedef signed char         int8_t;
 
107
#   endif
 
108
#   if !defined(_UINT8_T_DECLARED)  && !defined(_UINT8_T)
 
109
typedef unsigned char       uint8_t;
 
110
#   endif
 
111
#   if !defined(_INT16_T_DECLARED)  && !defined(_INT16_T)
 
112
typedef signed short        int16_t;
 
113
#   endif
 
114
#   if !defined(_UINT16_T_DECLARED) && !defined(_UINT16_T)
 
115
typedef unsigned short      uint16_t;
 
116
#   endif
 
117
#   if !defined(_INT32_T_DECLARED)  && !defined(_INT32_T)
 
118
typedef signed int          int32_t;
 
119
#   endif
 
120
#   if !defined(_UINT32_T_DECLARED) && !defined(_UINT32_T)
 
121
typedef unsigned int        uint32_t;
 
122
#   endif
 
123
#   if defined(_MSC_VER)
 
124
#    if !defined(_INT64_T_DECLARED)  && !defined(_INT64_T)
 
125
typedef signed _int64       int64_t;
 
126
#    endif
 
127
#    if !defined(_UINT64_T_DECLARED) && !defined(_UINT64_T)
 
128
typedef unsigned _int64     uint64_t;
 
129
#    endif
 
130
#   elif defined(IPRT_STDINT_USE_STRUCT_FOR_64_BIT_TYPES)
 
131
#    if !defined(_INT64_T_DECLARED)  && !defined(_INT64_T)
 
132
typedef struct { uint32_t lo; int32_t hi; }     int64_t;
 
133
#    endif
 
134
#    if !defined(_UINT64_T_DECLARED) && !defined(_UINT64_T)
 
135
typedef struct { uint32_t lo; uint32_t hi; }    uint64_t;
 
136
#    endif
 
137
#   else /* Use long long for 64-bit types */
 
138
#    if !defined(_INT64_T_DECLARED)  && !defined(_INT64_T)
 
139
typedef signed long long    int64_t;
 
140
#    endif
 
141
#    if !defined(_UINT64_T_DECLARED) && !defined(_UINT64_T)
 
142
typedef unsigned long long  uint64_t;
 
143
#    endif
 
144
#   endif
 
145
 
 
146
    /* max integer types */
 
147
#   if !defined(_INTMAX_T_DECLARED)  && !defined(_INTMAX_T)
 
148
typedef int64_t             intmax_t;
 
149
#   endif
 
150
#   if !defined(_UINTMAX_T_DECLARED) && !defined(_UINTMAX_T)
 
151
typedef uint64_t            uintmax_t;
 
152
#   endif
 
153
 
 
154
#  else
 
155
#   error "PORTME: Add architecture. Don't forget to check the [U]INTx_C() and [U]INTMAX_MIN/MAX macros."
 
156
#  endif
 
157
 
 
158
# endif /* !linux kernel or stuff */
 
159
 
 
160
    /* pointer <-> integer types */
 
161
# if !defined(_MSC_VER) || defined(DOXYGEN_RUNNING)
 
162
#  if ARCH_BITS == 32 \
 
163
   || defined(RT_OS_LINUX) \
 
164
   || defined(RT_OS_FREEBSD)
 
165
#   if !defined(_INTPTR_T_DECLARED)  && !defined(_INTPTR_T)
 
166
typedef signed long         intptr_t;
 
167
#   endif
 
168
#   if !defined(_UINTPTR_T_DECLARED) && !defined(_UINTPTR_T)
 
169
typedef unsigned long       uintptr_t;
 
170
#   endif
 
171
#  else
 
172
#   if !defined(_INTPTR_T_DECLARED)  && !defined(_INTPTR_T)
 
173
typedef int64_t             intptr_t;
 
174
#   endif
 
175
#   if !defined(_UINTPTR_T_DECLARED) && !defined(_UINTPTR_T)
 
176
typedef uint64_t            uintptr_t;
 
177
#   endif
 
178
#  endif
 
179
# endif /* !_MSC_VER */
 
180
 
 
181
#endif /* no system stdint.h */
 
182
 
 
183
 
 
184
/*
 
185
 * Make sure the [U]INTx_C(c) macros are present.
 
186
 * For In C++ source the system stdint.h may have skipped these if it was
 
187
 * included before we managed to define __STDC_CONSTANT_MACROS. (Kludge alert!)
 
188
 */
 
189
#if !defined(INT8_C) \
 
190
 || !defined(INT16_C) \
 
191
 || !defined(INT32_C) \
 
192
 || !defined(INT64_C) \
 
193
 || !defined(INTMAX_C) \
 
194
 || !defined(UINT8_C) \
 
195
 || !defined(UINT16_C) \
 
196
 || !defined(UINT32_C) \
 
197
 || !defined(UINT64_C) \
 
198
 || !defined(UINTMAX_C)
 
199
# define INT8_C(Value)      (Value)
 
200
# define INT16_C(Value)     (Value)
 
201
# define INT32_C(Value)     (Value)
 
202
# define INT64_C(Value)     (Value ## LL)
 
203
# define UINT8_C(Value)     (Value)
 
204
# define UINT16_C(Value)    (Value)
 
205
# define UINT32_C(Value)    (Value ## U)
 
206
# define UINT64_C(Value)    (Value ## ULL)
 
207
# define INTMAX_C(Value)    INT64_C(Value)
 
208
# define UINTMAX_C(Value)   UINT64_C(Value)
 
209
#endif
 
210
 
 
211
 
 
212
/*
 
213
 * Make sure the INTx_MIN and [U]INTx_MAX macros are present.
 
214
 * For In C++ source the system stdint.h may have skipped these if it was
 
215
 * included before we managed to define __STDC_LIMIT_MACROS. (Kludge alert!)
 
216
 */
 
217
#if !defined(INT8_MIN) \
 
218
 || !defined(INT16_MIN) \
 
219
 || !defined(INT32_MIN) \
 
220
 || !defined(INT64_MIN) \
 
221
 || !defined(INT8_MAX) \
 
222
 || !defined(INT16_MAX) \
 
223
 || !defined(INT32_MAX) \
 
224
 || !defined(INT64_MAX) \
 
225
 || !defined(UINT8_MAX) \
 
226
 || !defined(UINT16_MAX) \
 
227
 || !defined(UINT32_MAX) \
 
228
 || !defined(UINT64_MAX)
 
229
# define INT8_MIN           (INT8_C(-0x7f)                - 1)
 
230
# define INT16_MIN          (INT16_C(-0x7fff)             - 1)
 
231
# define INT32_MIN          (INT32_C(-0x7fffffff)         - 1)
 
232
# define INT64_MIN          (INT64_C(-0x7fffffffffffffff) - 1)
 
233
# define INT8_MAX           INT8_C(0x7f)
 
234
# define INT16_MAX          INT16_C(0x7fff)
 
235
# define INT32_MAX          INT32_C(0x7fffffff)
 
236
# define INT64_MAX          INT64_C(0x7fffffffffffffff)
 
237
# define UINT8_MAX          UINT8_C(0xff)
 
238
# define UINT16_MAX         UINT16_C(0xffff)
 
239
# define UINT32_MAX         UINT32_C(0xffffffff)
 
240
# define UINT64_MAX         UINT64_C(0xffffffffffffffff)
 
241
 
 
242
# define INTMAX_MIN         INT64_MIN
 
243
# define INTMAX_MAX         INT64_MAX
 
244
# define UINTMAX_MAX        UINT64_MAX
 
245
#endif
202
246
 
203
247
#endif
204
248