VirtualBox

source: vbox/trunk/include/iprt/types.h@ 5704

Last change on this file since 5704 was 5704, checked in by vboxsync, 17 years ago

Runtime: extended the types.h linux hack to include uintptr_t, which is typedefed in the Linux 2.6.24 headers

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 28.9 KB
Line 
1/** @file
2 * innotek Portable Runtime - Types.
3 */
4
5/*
6 * Copyright (C) 2006-2007 innotek GmbH
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 as published by the Free Software Foundation,
12 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
13 * distribution. VirtualBox OSE is distributed in the hope that it will
14 * be useful, but WITHOUT ANY WARRANTY of any kind.
15 */
16
17#ifndef ___iprt_types_h
18#define ___iprt_types_h
19
20#include <iprt/cdefs.h>
21#include <iprt/stdint.h>
22
23/*
24 * Include standard C types.
25 */
26#ifndef IPRT_NO_CRT
27
28# if defined(RT_OS_DARWIN) && defined(KERNEL)
29 /*
30 * Kludge for the darwin kernel:
31 * stddef.h is missing IIRC.
32 */
33# ifndef _PTRDIFF_T
34# define _PTRDIFF_T
35 typedef __darwin_ptrdiff_t ptrdiff_t;
36# endif
37# include <sys/types.h>
38
39# elif defined(RT_OS_FREEBSD) && defined(_KERNEL)
40 /*
41 * Kludge for the FreeBSD kernel:
42 * stddef.h and sys/types.h has sligtly different offsetof definitions
43 * when compiling in kernel mode. This is just to make GCC keep shut.
44 */
45# ifndef _STDDEF_H_
46# undef offsetof
47# endif
48# include <stddef.h>
49# ifndef _SYS_TYPES_H_
50# undef offsetof
51# endif
52# include <sys/types.h>
53# ifndef offsetof
54# error "offsetof is not defined..."
55# endif
56
57# elif defined(RT_OS_LINUX) && defined(__KERNEL__)
58 /*
59 * Kludge for the linux kernel:
60 * 1. sys/types.h doesn't mix with the kernel.
61 * 2. Starting with 2.6.19, linux/types.h typedefs bool and linux/stddef.h
62 * declares false and true as enum values.
63 * 3. Starting with 2.6.24, linux/types.h typedefs uintptr_t.
64 * We work around these issues here and nowhere else.
65 */
66# include <stddef.h>
67# if defined(__cplusplus)
68 typedef bool _Bool;
69# endif
70# define bool linux_bool
71# define true linux_true
72# define false linux_false
73# define uintptr_t linux_uintptr_t
74# include <linux/types.h>
75# include <linux/stddef.h>
76# undef uintptr_t
77# undef false
78# undef true
79# undef bool
80
81# else
82# include <stddef.h>
83# include <sys/types.h>
84# endif
85
86/* Define any types missing from sys/types.h on windows. */
87# ifdef _MSC_VER
88# undef ssize_t
89 typedef intptr_t ssize_t;
90# endif
91
92#else /* no crt */
93# include <iprt/nocrt/compiler/gcc.h>
94#endif /* no crt */
95
96
97
98/** @defgroup grp_rt_types innotek Portable Runtime Base Types
99 * @{
100 */
101
102/* define wchar_t, we don't wanna include all the wcsstuff to get this. */
103#ifdef _MSC_VER
104# ifndef _WCHAR_T_DEFINED
105 typedef unsigned short wchar_t;
106# define _WCHAR_T_DEFINED
107# endif
108#endif
109#ifdef __GNUC__
110/** @todo wchar_t on GNUC */
111#endif
112
113/*
114 * C doesn't have bool.
115 */
116#ifndef __cplusplus
117# if defined(__GNUC__)
118# if defined(RT_OS_LINUX) && __GNUC__ < 3
119typedef uint8_t bool;
120# else
121# if defined(RT_OS_DARWIN) && defined(_STDBOOL_H)
122# undef bool
123# endif
124typedef _Bool bool;
125# endif
126# else
127typedef unsigned char bool;
128# endif
129# ifndef true
130# define true (1)
131# endif
132# ifndef false
133# define false (0)
134# endif
135#endif
136
137/**
138 * 128-bit unsigned integer.
139 */
140#if defined(__GNUC__) && defined(RT_ARCH_AMD64)
141typedef __uint128_t uint128_t;
142#else
143typedef struct uint128_s
144{
145 uint64_t Lo;
146 uint64_t Hi;
147} uint128_t;
148#endif
149
150
151/**
152 * 128-bit signed integer.
153 */
154#if defined(__GNUC__) && defined(RT_ARCH_AMD64)
155typedef __int128_t int128_t;
156#else
157typedef struct int128_s
158{
159 uint64_t lo;
160 int64_t hi;
161} int128_t;
162#endif
163
164
165/**
166 * 16-bit unsigned interger union.
167 */
168typedef union RTUINT16U
169{
170 /** natural view. */
171 uint16_t u;
172
173 /** 16-bit view. */
174 uint16_t au16[1];
175 /** 8-bit view. */
176 uint8_t au8[4];
177 /** 16-bit hi/lo view. */
178 struct
179 {
180 uint16_t Lo;
181 uint16_t Hi;
182 } s;
183} RTUINT16U;
184/** Pointer to a 16-bit unsigned interger union. */
185typedef RTUINT16U *PRTUINT16U;
186/** Pointer to a const 32-bit unsigned interger union. */
187typedef const RTUINT16U *PCRTUINT16U;
188
189
190/**
191 * 32-bit unsigned interger union.
192 */
193typedef union RTUINT32U
194{
195 /** natural view. */
196 uint32_t u;
197 /** Hi/Low view. */
198 struct
199 {
200 uint16_t Lo;
201 uint16_t Hi;
202 } s;
203 /** Word view. */
204 struct
205 {
206 uint16_t w0;
207 uint16_t w1;
208 } Words;
209
210 /** 32-bit view. */
211 uint32_t au32[1];
212 /** 16-bit view. */
213 uint16_t au16[2];
214 /** 8-bit view. */
215 uint8_t au8[4];
216} RTUINT32U;
217/** Pointer to a 32-bit unsigned interger union. */
218typedef RTUINT32U *PRTUINT32U;
219/** Pointer to a const 32-bit unsigned interger union. */
220typedef const RTUINT32U *PCRTUINT32U;
221
222
223/**
224 * 64-bit unsigned interger union.
225 */
226typedef union RTUINT64U
227{
228 /** Natural view. */
229 uint64_t u;
230 /** Hi/Low view. */
231 struct
232 {
233 uint32_t Lo;
234 uint32_t Hi;
235 } s;
236 /** Double-Word view. */
237 struct
238 {
239 uint32_t dw0;
240 uint32_t dw1;
241 } DWords;
242 /** Word view. */
243 struct
244 {
245 uint16_t w0;
246 uint16_t w1;
247 uint16_t w2;
248 uint16_t w3;
249 } Words;
250
251 /** 64-bit view. */
252 uint64_t au64[1];
253 /** 32-bit view. */
254 uint32_t au32[2];
255 /** 16-bit view. */
256 uint16_t au16[4];
257 /** 8-bit view. */
258 uint8_t au8[8];
259} RTUINT64U;
260/** Pointer to a 64-bit unsigned interger union. */
261typedef RTUINT64U *PRTUINT64U;
262/** Pointer to a const 64-bit unsigned interger union. */
263typedef const RTUINT64U *PCRTUINT64U;
264
265
266/**
267 * 128-bit unsigned interger union.
268 */
269typedef union RTUINT128U
270{
271 /** Natural view.
272 * WARNING! This member depends on compiler supporing 128-bit stuff. */
273 uint128_t u;
274 /** Hi/Low view. */
275 struct
276 {
277 uint64_t Lo;
278 uint64_t Hi;
279 } s;
280 /** Quad-Word view. */
281 struct
282 {
283 uint64_t qw0;
284 uint64_t qw1;
285 } QWords;
286 /** Double-Word view. */
287 struct
288 {
289 uint32_t dw0;
290 uint32_t dw1;
291 uint32_t dw2;
292 uint32_t dw3;
293 } DWords;
294 /** Word view. */
295 struct
296 {
297 uint16_t w0;
298 uint16_t w1;
299 uint16_t w2;
300 uint16_t w3;
301 uint16_t w4;
302 uint16_t w5;
303 uint16_t w6;
304 uint16_t w7;
305 } Words;
306
307 /** 64-bit view. */
308 uint64_t au64[2];
309 /** 32-bit view. */
310 uint32_t au32[4];
311 /** 16-bit view. */
312 uint16_t au16[8];
313 /** 8-bit view. */
314 uint8_t au8[16];
315} RTUINT128U;
316/** Pointer to a 64-bit unsigned interger union. */
317typedef RTUINT128U *PRTUINT128U;
318/** Pointer to a const 64-bit unsigned interger union. */
319typedef const RTUINT128U *PCRTUINT128U;
320
321
322/** Generic function type.
323 * @see PFNRT
324 */
325typedef DECLCALLBACK(void) FNRT(void);
326
327/** Generic function pointer.
328 * With -pedantic, gcc-4 complains when casting a function to a data object, for example
329 *
330 * @code
331 * void foo(void)
332 * {
333 * }
334 *
335 * void *bar = (void *)foo;
336 * @endcode
337 *
338 * The compiler would warn with "ISO C++ forbids casting between pointer-to-function and
339 * pointer-to-object". The purpose of this warning is not to bother the programmer but to
340 * point out that he is probably doing something dangerous, assigning a pointer to executable
341 * code to a data object.
342 */
343typedef FNRT *PFNRT;
344
345
346/** @defgroup grp_rt_types_both Common Guest and Host Context Basic Types
347 * @ingroup grp_rt_types
348 * @{
349 */
350
351/** Signed integer which can contain both GC and HC pointers. */
352#if (HC_ARCH_BITS == 32 && GC_ARCH_BITS == 32)
353typedef int32_t RTINTPTR;
354#elif (HC_ARCH_BITS == 64 || GC_ARCH_BITS == 64)
355typedef int64_t RTINTPTR;
356#else
357# error Unsupported HC_ARCH_BITS and/or GC_ARCH_BITS values.
358#endif
359/** Pointer to signed integer which can contain both GC and HC pointers. */
360typedef RTINTPTR *PRTINTPTR;
361/** Pointer const to signed integer which can contain both GC and HC pointers. */
362typedef const RTINTPTR *PCRTINTPTR;
363
364/** Unsigned integer which can contain both GC and HC pointers. */
365#if (HC_ARCH_BITS == 32 && GC_ARCH_BITS == 32)
366typedef uint32_t RTUINTPTR;
367#elif (HC_ARCH_BITS == 64 || GC_ARCH_BITS == 64)
368typedef uint64_t RTUINTPTR;
369#else
370# error Unsupported HC_ARCH_BITS and/or GC_ARCH_BITS values.
371#endif
372/** Pointer to unsigned integer which can contain both GC and HC pointers. */
373typedef RTUINTPTR *PRTUINTPTR;
374/** Pointer const to unsigned integer which can contain both GC and HC pointers. */
375typedef const RTUINTPTR *PCRTUINTPTR;
376
377/** Signed integer. */
378typedef int32_t RTINT;
379/** Pointer to signed integer. */
380typedef RTINT *PRTINT;
381/** Pointer to const signed integer. */
382typedef const RTINT *PCRTINT;
383
384/** Unsigned integer. */
385typedef uint32_t RTUINT;
386/** Pointer to unsigned integer. */
387typedef RTUINT *PRTUINT;
388/** Pointer to const unsigned integer. */
389typedef const RTUINT *PCRTUINT;
390
391/** A file offset / size (off_t). */
392typedef int64_t RTFOFF;
393/** Pointer to a file offset / size. */
394typedef RTFOFF *PRTFOFF;
395
396/** File mode (see iprt/fs.h). */
397typedef uint32_t RTFMODE;
398/** Pointer to file mode. */
399typedef RTFMODE *PRTFMODE;
400
401/** Device unix number. */
402typedef uint32_t RTDEV;
403/** Pointer to a device unix number. */
404typedef RTDEV *PRTDEV;
405
406/** i-node number. */
407typedef uint64_t RTINODE;
408/** Pointer to a i-node number. */
409typedef RTINODE *PRTINODE;
410
411/** User id. */
412typedef uint32_t RTUID;
413/** Pointer to a user id. */
414typedef RTUID *PRTUID;
415/** NIL user id.
416 * @todo check this for portability! */
417#define NIL_RTUID (~(RTUID)0);
418
419/** Group id. */
420typedef uint32_t RTGID;
421/** Pointer to a group id. */
422typedef RTGID *PRTGID;
423/** NIL group id.
424 * @todo check this for portability! */
425#define NIL_RTGID (~(RTGID)0);
426
427/** I/O Port. */
428typedef uint16_t RTIOPORT;
429/** Pointer to I/O Port. */
430typedef RTIOPORT *PRTIOPORT;
431/** Pointer to const I/O Port. */
432typedef const RTIOPORT *PCRTIOPORT;
433
434/** Selector. */
435typedef uint16_t RTSEL;
436/** Pointer to selector. */
437typedef RTSEL *PRTSEL;
438/** Pointer to const selector. */
439typedef const RTSEL *PCRTSEL;
440
441/** Far 16-bit pointer. */
442#pragma pack(1)
443typedef struct RTFAR16
444{
445 uint16_t off;
446 RTSEL sel;
447} RTFAR16;
448#pragma pack()
449/** Pointer to Far 16-bit pointer. */
450typedef RTFAR16 *PRTFAR16;
451/** Pointer to const Far 16-bit pointer. */
452typedef const RTFAR16 *PCRTFAR16;
453
454/** Far 32-bit pointer. */
455#pragma pack(1)
456typedef struct RTFAR32
457{
458 uint32_t off;
459 RTSEL sel;
460} RTFAR32;
461#pragma pack()
462/** Pointer to Far 32-bit pointer. */
463typedef RTFAR32 *PRTFAR32;
464/** Pointer to const Far 32-bit pointer. */
465typedef const RTFAR32 *PCRTFAR32;
466
467/** Far 64-bit pointer. */
468#pragma pack(1)
469typedef struct RTFAR64
470{
471 uint64_t off;
472 RTSEL sel;
473} RTFAR64;
474#pragma pack()
475/** Pointer to Far 64-bit pointer. */
476typedef RTFAR64 *PRTFAR64;
477/** Pointer to const Far 64-bit pointer. */
478typedef const RTFAR64 *PCRTFAR64;
479
480/** @} */
481
482
483/** @defgroup grp_rt_types_hc Host Context Basic Types
484 * @ingroup grp_rt_types
485 * @{
486 */
487
488/** HC Natural signed integer. */
489typedef int32_t RTHCINT;
490/** Pointer to HC Natural signed integer. */
491typedef RTHCINT *PRTHCINT;
492/** Pointer to const HC Natural signed integer. */
493typedef const RTHCINT *PCRTHCINT;
494
495/** HC Natural unsigned integer. */
496typedef uint32_t RTHCUINT;
497/** Pointer to HC Natural unsigned integer. */
498typedef RTHCUINT *PRTHCUINT;
499/** Pointer to const HC Natural unsigned integer. */
500typedef const RTHCUINT *PCRTHCUINT;
501
502
503/** Signed integer which can contain a HC pointer. */
504#if HC_ARCH_BITS == 32
505typedef int32_t RTHCINTPTR;
506#elif HC_ARCH_BITS == 64
507typedef int64_t RTHCINTPTR;
508#else
509# error Unsupported HC_ARCH_BITS value.
510#endif
511/** Pointer to signed interger which can contain a HC pointer. */
512typedef RTHCINTPTR *PRTHCINTPTR;
513/** Pointer to const signed interger which can contain a HC pointer. */
514typedef const RTHCINTPTR *PCRTHCINTPTR;
515
516/** Signed integer which can contain a HC ring-3 pointer. */
517#if R3_ARCH_BITS == 32
518typedef int32_t RTR3INTPTR;
519#elif R3_ARCH_BITS == 64
520typedef int64_t RTR3INTPTR;
521#else
522# error Unsupported R3_ARCH_BITS value.
523#endif
524/** Pointer to signed interger which can contain a HC ring-3 pointer. */
525typedef RTR3INTPTR *PRTR3INTPTR;
526/** Pointer to const signed interger which can contain a HC ring-3 pointer. */
527typedef const RTR3INTPTR *PCRTR3INTPTR;
528
529/** Signed integer which can contain a HC ring-0 pointer. */
530#if R0_ARCH_BITS == 32
531typedef int32_t RTR0INTPTR;
532#elif R0_ARCH_BITS == 64
533typedef int64_t RTR0INTPTR;
534#else
535# error Unsupported R0_ARCH_BITS value.
536#endif
537/** Pointer to signed interger which can contain a HC ring-0 pointer. */
538typedef RTR0INTPTR *PRTR0INTPTR;
539/** Pointer to const signed interger which can contain a HC ring-0 pointer. */
540typedef const RTR0INTPTR *PCRTR0INTPTR;
541
542
543/** Unsigned integer which can contain a HC pointer. */
544#if HC_ARCH_BITS == 32
545typedef uint32_t RTHCUINTPTR;
546#elif HC_ARCH_BITS == 64
547typedef uint64_t RTHCUINTPTR;
548#else
549# error Unsupported HC_ARCH_BITS value.
550#endif
551/** Pointer to unsigned interger which can contain a HC pointer. */
552typedef RTHCUINTPTR *PRTHCUINTPTR;
553/** Pointer to unsigned interger which can contain a HC pointer. */
554typedef const RTHCUINTPTR *PCRTHCUINTPTR;
555
556/** Unsigned integer which can contain a HC ring-3 pointer. */
557#if R3_ARCH_BITS == 32
558typedef uint32_t RTR3UINTPTR;
559#elif R3_ARCH_BITS == 64
560typedef uint64_t RTR3UINTPTR;
561#else
562# error Unsupported R3_ARCH_BITS value.
563#endif
564/** Pointer to unsigned interger which can contain a HC ring-3 pointer. */
565typedef RTR3UINTPTR *PRTR3UINTPTR;
566/** Pointer to unsigned interger which can contain a HC ring-3 pointer. */
567typedef const RTR3UINTPTR *PCRTR3UINTPTR;
568
569/** Unsigned integer which can contain a HC ring-0 pointer. */
570#if R0_ARCH_BITS == 32
571typedef uint32_t RTR0UINTPTR;
572#elif R0_ARCH_BITS == 64
573typedef uint64_t RTR0UINTPTR;
574#else
575# error Unsupported R0_ARCH_BITS value.
576#endif
577/** Pointer to unsigned interger which can contain a HC ring-0 pointer. */
578typedef RTR0UINTPTR *PRTR0UINTPTR;
579/** Pointer to unsigned interger which can contain a HC ring-0 pointer. */
580typedef const RTR0UINTPTR *PCRTR0UINTPTR;
581
582
583/** Host Physical Memory Address.
584 * @todo This should be configurable at compile time too...
585 */
586typedef uint64_t RTHCPHYS;
587/** Pointer to Host Physical Memory Address. */
588typedef RTHCPHYS *PRTHCPHYS;
589/** Pointer to const Host Physical Memory Address. */
590typedef const RTHCPHYS *PCRTHCPHYS;
591/** @def NIL_RTHCPHYS
592 * NIL HC Physical Address.
593 * NIL_RTHCPHYS is used to signal an invalid physical address, similar
594 * to the NULL pointer.
595 */
596#define NIL_RTHCPHYS ((RTHCPHYS)~0U) /** @todo change this to (~(VBOXHCPHYS)0) */
597
598
599/** HC pointer. */
600#ifndef IN_GC
601typedef void * RTHCPTR;
602#else
603typedef RTHCUINTPTR RTHCPTR;
604#endif
605/** Pointer to HC pointer. */
606typedef RTHCPTR *PRTHCPTR;
607/** Pointer to const HC pointer. */
608typedef const RTHCPTR *PCRTHCPTR;
609/** @def NIL_RTHCPTR
610 * NIL HC pointer.
611 */
612#define NIL_RTHCPTR ((RTHCPTR)0)
613
614/** HC ring-3 pointer. */
615#ifdef IN_RING3
616typedef void * RTR3PTR;
617#else
618typedef RTR3UINTPTR RTR3PTR;
619#endif
620/** Pointer to HC ring-3 pointer. */
621typedef RTR3PTR *PRTR3PTR;
622/** Pointer to const HC ring-3 pointer. */
623typedef const RTR3PTR *PCRTR3PTR;
624/** @def NIL_RTR3PTR
625 * NIL HC ring-3 pointer.
626 */
627#define NIL_RTR3PTR ((RTR3PTR)0)
628
629/** HC ring-0 pointer. */
630#ifdef IN_RING0
631typedef void * RTR0PTR;
632#else
633typedef RTR0UINTPTR RTR0PTR;
634#endif
635/** Pointer to HC ring-0 pointer. */
636typedef RTR0PTR *PRTR0PTR;
637/** Pointer to const HC ring-0 pointer. */
638typedef const RTR0PTR *PCRTR0PTR;
639/** @def NIL_RTR0PTR
640 * NIL HC ring-0 pointer.
641 */
642#define NIL_RTR0PTR ((RTR0PTR)0)
643
644
645/** Unsigned integer register in the host context. */
646#if HC_ARCH_BITS == 32
647typedef uint32_t RTHCUINTREG;
648#elif HC_ARCH_BITS == 64
649typedef uint64_t RTHCUINTREG;
650#else
651# error "Unsupported HC_ARCH_BITS!"
652#endif
653/** Pointer to an unsigned integer register in the host context. */
654typedef RTHCUINTREG *PRTHCUINTREG;
655/** Pointer to a const unsigned integer register in the host context. */
656typedef const RTHCUINTREG *PCRTHCUINTREG;
657
658/** Unsigned integer register in the host ring-3 context. */
659#if R3_ARCH_BITS == 32
660typedef uint32_t RTR3UINTREG;
661#elif R3_ARCH_BITS == 64
662typedef uint64_t RTR3UINTREG;
663#else
664# error "Unsupported R3_ARCH_BITS!"
665#endif
666/** Pointer to an unsigned integer register in the host ring-3 context. */
667typedef RTR3UINTREG *PRTR3UINTREG;
668/** Pointer to a const unsigned integer register in the host ring-3 context. */
669typedef const RTR3UINTREG *PCRTR3UINTREG;
670
671/** Unsigned integer register in the host ring-3 context. */
672#if R0_ARCH_BITS == 32
673typedef uint32_t RTR0UINTREG;
674#elif R0_ARCH_BITS == 64
675typedef uint64_t RTR0UINTREG;
676#else
677# error "Unsupported R3_ARCH_BITS!"
678#endif
679/** Pointer to an unsigned integer register in the host ring-3 context. */
680typedef RTR0UINTREG *PRTR0UINTREG;
681/** Pointer to a const unsigned integer register in the host ring-3 context. */
682typedef const RTR0UINTREG *PCRTR0UINTREG;
683
684/** @} */
685
686
687/** @defgroup grp_rt_types_gc Guest Context Basic Types
688 * @ingroup grp_rt_types
689 * @{
690 */
691
692/** Natural signed integer in the GC. */
693typedef int32_t RTGCINT;
694/** Pointer to natural signed interger in GC. */
695typedef RTGCINT *PRTGCINT;
696/** Pointer to const natural signed interger in GC. */
697typedef const RTGCINT *PCRTGCINT;
698
699/** Natural signed uninteger in the GC. */
700typedef uint32_t RTGCUINT;
701/** Pointer to natural unsigned interger in GC. */
702typedef RTGCUINT *PRTGCUINT;
703/** Pointer to const natural unsigned interger in GC. */
704typedef const RTGCUINT *PCRTGCUINT;
705
706/** Signed integer which can contain a GC pointer. */
707#if GC_ARCH_BITS == 32
708typedef int32_t RTGCINTPTR;
709#elif GC_ARCH_BITS == 64
710typedef int64_t RTGCINTPTR;
711#else
712# error Unsupported GC_ARCH_BITS value.
713#endif
714/** Pointer to signed interger which can contain a GC pointer. */
715typedef RTGCINTPTR *PRTGCINTPTR;
716/** Pointer to const signed interger which can contain a GC pointer. */
717typedef const RTGCINTPTR *PCRTGCINTPTR;
718
719/** Unsigned integer which can contain a GC pointer. */
720#if GC_ARCH_BITS == 32
721typedef uint32_t RTGCUINTPTR;
722#elif GC_ARCH_BITS == 64
723typedef uint64_t RTGCUINTPTR;
724#else
725# error Unsupported GC_ARCH_BITS value.
726#endif
727/** Pointer to unsigned interger which can contain a GC pointer. */
728typedef RTGCUINTPTR *PRTGCUINTPTR;
729/** Pointer to unsigned interger which can contain a GC pointer. */
730typedef const RTGCUINTPTR *PCRTGCUINTPTR;
731
732/** Guest Physical Memory Address.*/
733typedef RTGCUINTPTR RTGCPHYS;
734/** Pointer to Guest Physical Memory Address. */
735typedef RTGCPHYS *PRTGCPHYS;
736/** Pointer to const Guest Physical Memory Address. */
737typedef const RTGCPHYS *PCRTGCPHYS;
738/** @def NIL_RTGCPHYS
739 * NIL GC Physical Address.
740 * NIL_RTGCPHYS is used to signal an invalid physical address, similar
741 * to the NULL pointer.
742 */
743#define NIL_RTGCPHYS ((RTGCPHYS)~0U) /** @todo change this to (~(RTGCPHYS)0) */
744
745
746/** Guest context pointer.
747 * Keep in mind that this type is an unsigned integer in
748 * HC and void pointer in GC.
749 */
750#ifdef IN_GC
751typedef void *RTGCPTR;
752#else
753typedef RTGCUINTPTR RTGCPTR;
754#endif
755/** Pointer to a guest context pointer. */
756typedef RTGCPTR *PRTGCPTR;
757/** Pointer to a const guest context pointer. */
758typedef const RTGCPTR *PCRTGCPTR;
759/** @def NIL_RTGCPTR
760 * NIL GC pointer.
761 */
762#define NIL_RTGCPTR ((RTGCPTR)0)
763
764
765/** Unsigned integer register in the guest context. */
766#if GC_ARCH_BITS == 32
767typedef uint32_t RTGCUINTREG;
768#elif GC_ARCH_BITS == 64
769typedef uint64_t RTGCUINTREG;
770#else
771# error "Unsupported GC_ARCH_BITS!"
772#endif
773/** Pointer to an unsigned integer register in the guest context. */
774typedef RTGCUINTREG *PRTGCUINTREG;
775/** Pointer to a const unsigned integer register in the guest context. */
776typedef const RTGCUINTREG *PCRTGCUINTREG;
777
778/** @} */
779
780
781/** @defgroup grp_rt_types_cc Current Context Basic Types
782 * @ingroup grp_rt_types
783 * @{
784 */
785
786/** Current Context Physical Memory Address.*/
787#ifdef IN_GC
788typedef RTGCPHYS RTCCPHYS;
789#else
790typedef RTHCPHYS RTCCPHYS;
791#endif
792/** Pointer to Current Context Physical Memory Address. */
793typedef RTCCPHYS *PRTCCPHYS;
794/** Pointer to const Current Context Physical Memory Address. */
795typedef const RTCCPHYS *PCRTCCPHYS;
796/** @def NIL_RTCCPHYS
797 * NIL CC Physical Address.
798 * NIL_RTCCPHYS is used to signal an invalid physical address, similar
799 * to the NULL pointer.
800 */
801#ifdef IN_GC
802# define NIL_RTCCPHYS NIL_RTGCPHYS
803#else
804# define NIL_RTCCPHYS NIL_RTHCPHYS
805#endif
806
807/** Unsigned integer register in the current context. */
808#if ARCH_BITS == 32
809typedef uint32_t RTCCUINTREG;
810#elif ARCH_BITS == 64
811typedef uint64_t RTCCUINTREG;
812#else
813# error "Unsupported ARCH_BITS!"
814#endif
815/** Pointer to an unsigned integer register in the current context. */
816typedef RTCCUINTREG *PRTCCUINTREG;
817/** Pointer to a const unsigned integer register in the current context. */
818typedef const RTCCUINTREG *PCRTCCUINTREG;
819
820/** @deprecated */
821typedef RTCCUINTREG RTUINTREG;
822/** @deprecated */
823typedef RTCCUINTREG *PRTUINTREG;
824/** @deprecated */
825typedef const RTCCUINTREG *PCRTUINTREG;
826
827/** @} */
828
829
830/** File handle. */
831typedef RTUINT RTFILE;
832/** Pointer to file handle. */
833typedef RTFILE *PRTFILE;
834/** Nil file handle. */
835#define NIL_RTFILE (~(RTFILE)0)
836
837/** Loader module handle. */
838typedef R3PTRTYPE(struct RTLDRMODINTERNAL *) RTLDRMOD;
839/** Pointer to a loader module handle. */
840typedef RTLDRMOD *PRTLDRMOD;
841/** Nil loader module handle. */
842#define NIL_RTLDRMOD 0
843
844/** Ring-0 memory object handle. */
845typedef R0PTRTYPE(struct RTR0MEMOBJINTERNAL *) RTR0MEMOBJ;
846/** Pointer to a Ring-0 memory object handle. */
847typedef RTR0MEMOBJ *PRTR0MEMOBJ;
848/** Nil ring-0 memory object handle. */
849#define NIL_RTR0MEMOBJ 0
850
851/** Native thread handle. */
852typedef RTHCUINTPTR RTNATIVETHREAD;
853/** Pointer to an native thread handle. */
854typedef RTNATIVETHREAD *PRTNATIVETHREAD;
855/** Nil native thread handle. */
856#define NIL_RTNATIVETHREAD (~(RTNATIVETHREAD)0)
857
858/** Process identifier. */
859typedef uint32_t RTPROCESS;
860/** Pointer to a process identifier. */
861typedef RTPROCESS *PRTPROCESS;
862/** Nil process identifier. */
863#define NIL_RTPROCESS (~(RTPROCESS)0)
864
865/** Process ring-0 handle. */
866typedef RTR0UINTPTR RTR0PROCESS;
867/** Pointer to a ring-0 process handle. */
868typedef RTR0PROCESS *PRTR0PROCESS;
869/** Nil ring-0 process handle. */
870#define NIL_RTR0PROCESS (~(RTR0PROCESS)0)
871
872/** @typedef RTSEMEVENT
873 * Event Semaphore handle. */
874typedef R3R0PTRTYPE(struct RTSEMEVENTINTERNAL *) RTSEMEVENT;
875/** Pointer to an event semaphore handle. */
876typedef RTSEMEVENT *PRTSEMEVENT;
877/** Nil event semaphore handle. */
878#define NIL_RTSEMEVENT 0
879
880/** @typedef RTSEMEVENTMULTI
881 * Event Multiple Release Semaphore handle. */
882typedef R3R0PTRTYPE(struct RTSEMEVENTMULTIINTERNAL *) RTSEMEVENTMULTI;
883/** Pointer to an event multiple release semaphore handle. */
884typedef RTSEMEVENTMULTI *PRTSEMEVENTMULTI;
885/** Nil multiple release event semaphore handle. */
886#define NIL_RTSEMEVENTMULTI 0
887
888/** @typedef RTSEMFASTMUTEX
889 * Fast mutex Semaphore handle. */
890typedef R3R0PTRTYPE(struct RTSEMFASTMUTEXINTERNAL *) RTSEMFASTMUTEX;
891/** Pointer to a mutex semaphore handle. */
892typedef RTSEMFASTMUTEX *PRTSEMFASTMUTEX;
893/** Nil fast mutex semaphore handle. */
894#define NIL_RTSEMFASTMUTEX 0
895
896/** @typedef RTSEMMUTEX
897 * Mutex Semaphore handle. */
898typedef R3R0PTRTYPE(struct RTSEMMUTEXINTERNAL *) RTSEMMUTEX;
899/** Pointer to a mutex semaphore handle. */
900typedef RTSEMMUTEX *PRTSEMMUTEX;
901/** Nil mutex semaphore handle. */
902#define NIL_RTSEMMUTEX 0
903
904/** @typedef RTSEMRW
905 * Read/Write Semaphore handle. */
906typedef R3R0PTRTYPE(struct RTSEMRWINTERNAL *) RTSEMRW;
907/** Pointer to a read/write semaphore handle. */
908typedef RTSEMRW *PRTSEMRW;
909/** Nil read/write semaphore handle. */
910#define NIL_RTSEMRW 0
911
912/** Spinlock handle. */
913typedef R3R0PTRTYPE(struct RTSPINLOCKINTERNAL *) RTSPINLOCK;
914/** Pointer to a spinlock handle. */
915typedef RTSPINLOCK *PRTSPINLOCK;
916/** Nil spinlock handle. */
917#define NIL_RTSPINLOCK 0
918
919/** Socket handle. */
920typedef int RTSOCKET;
921/** Pointer to socket handle. */
922typedef RTSOCKET *PRTSOCKET;
923/** Nil socket handle. */
924#define NIL_RTSOCKET (~(RTSOCKET)0)
925
926/** Thread handle.*/
927typedef R3R0PTRTYPE(struct RTTHREADINT *) RTTHREAD;
928/** Pointer to thread handle. */
929typedef RTTHREAD *PRTTHREAD;
930/** Nil thread handle. */
931#define NIL_RTTHREAD 0
932
933/** Handle to a simple heap. */
934typedef R3R0PTRTYPE(struct RTHEAPSIMPLEINTERNAL *) RTHEAPSIMPLE;
935/** Pointer to a handle to a simple heap. */
936typedef RTHEAPSIMPLE *PRTHEAPSIMPLE;
937/** NIL simple heap handle. */
938#define NIL_RTHEAPSIMPLE ((RTHEAPSIMPLE)0)
939
940/** Handle to an environment block. */
941typedef R3PTRTYPE(struct RTENVINTERNAL *) RTENV;
942/** Pointer to a handle to an environment block. */
943typedef RTENV *PRTENV;
944/** NIL simple heap handle. */
945#define NIL_RTENV ((RTENV)0)
946
947
948/**
949 * UUID data type.
950 */
951typedef union RTUUID
952{
953 /** 8-bit view. */
954 uint8_t au8[16];
955 /** 16-bit view. */
956 uint16_t au16[8];
957 /** 32-bit view. */
958 uint32_t au32[4];
959 /** 64-bit view. */
960 uint64_t au64[2];
961 /** The way the UUID is declared by the ext2 guys. */
962 struct
963 {
964 uint32_t u32TimeLow;
965 uint16_t u16TimeMid;
966 uint16_t u16TimeHiAndVersion;
967 uint16_t u16ClockSeq;
968 uint8_t au8Node[6];
969 } Gen;
970 /** @deprecated */
971 unsigned char aUuid[16];
972} RTUUID;
973/** Pointer to UUID data. */
974typedef RTUUID *PRTUUID;
975/** Pointer to readonly UUID data. */
976typedef const RTUUID *PCRTUUID;
977
978/**
979 * UUID string maximum length.
980 */
981#define RTUUID_STR_LENGTH 37
982
983
984/** Compression handle. */
985typedef struct RTZIPCOMP *PRTZIPCOMP;
986
987/** Decompressor handle. */
988typedef struct RTZIPDECOMP *PRTZIPDECOMP;
989
990
991/**
992 * Unicode Code Point.
993 */
994typedef uint32_t RTUNICP;
995/** Pointer to an Unicode Code Point. */
996typedef RTUNICP *PRTUNICP;
997/** Pointer to an Unicode Code Point. */
998typedef const RTUNICP *PCRTUNICP;
999
1000
1001/**
1002 * UTF-16 character.
1003 * @remark wchar_t is not usable since it's compiler defined.
1004 * @remark When we use the term character we're not talking about unicode code point, but
1005 * the basic unit of the string encoding. Thus cuc - count of unicode chars - means
1006 * count of RTUTF16. And cch means count of the typedef 'char', which is assumed
1007 * to be an octet.
1008 */
1009typedef uint16_t RTUTF16;
1010/** Pointer to a UTF-16 character. */
1011typedef RTUTF16 *PRTUTF16;
1012/** Pointer to a const UTF-16 character. */
1013typedef const RTUTF16 *PCRTUTF16;
1014
1015/**
1016 * UCS-2 character.
1017 * @remark wchar_t is not usable since it's compiler defined.
1018 * @deprecated Use RTUTF16!
1019 */
1020typedef RTUTF16 RTUCS2;
1021/** Pointer to UCS-2 character.
1022 * @deprecated Use PRTUTF16!
1023 */
1024typedef PRTUTF16 PRTUCS2;
1025/** Pointer to const UCS-2 character.
1026 * @deprecated Use PCRTUTF16!
1027 */
1028typedef PCRTUTF16 PCRTUCS2;
1029
1030
1031
1032/**
1033 * Wait for ever if we have to.
1034 */
1035#define RT_INDEFINITE_WAIT (~0U)
1036
1037
1038/**
1039 * Generic process callback.
1040 *
1041 * @returns VBox status code. Failure will cancel the operation.
1042 * @param uPercentage The percentage of the operation which has been completed.
1043 * @param pvUser The user specified argument.
1044 */
1045typedef DECLCALLBACK(int) FNRTPROGRESS(unsigned uPrecentage, void *pvUser);
1046/** Pointer to a generic progress callback function, FNRTPROCESS(). */
1047typedef FNRTPROGRESS *PFNRTPROGRESS;
1048
1049
1050/**
1051 * Rectangle data type.
1052 */
1053typedef struct RTRECT
1054{
1055 /** left X coordinate. */
1056 int32_t xLeft;
1057 /** top Y coordinate. */
1058 int32_t yTop;
1059 /** right X coordinate. (exclusive) */
1060 int32_t xRight;
1061 /** bottom Y coordinate. (exclusive) */
1062 int32_t yBottom;
1063} RTRECT;
1064/** Pointer to a rectangle. */
1065typedef RTRECT *PRTRECT;
1066/** Pointer to a const rectangle. */
1067typedef const RTRECT *PCRTRECT;
1068
1069/** @} */
1070
1071#endif
1072
Note: See TracBrowser for help on using the repository browser.

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