VirtualBox

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

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

Second try

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