VirtualBox

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

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

Introducing 32 & 64 bits RTGCPTR types. (preparational work)

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