VirtualBox

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

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

InnoTek -> innotek: all the headers and comments.

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