VirtualBox

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

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

Biggest check-in ever. New source code headers for all (C) innotek files.

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