VirtualBox

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

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

RTUTF16 != uc or cuc. but wc or cwc.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 31.0 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/** Guest Physical Memory Address.*/
743typedef uint32_t RTGCPHYS;
744/** Pointer to Guest Physical Memory Address. */
745typedef RTGCPHYS *PRTGCPHYS;
746/** Pointer to const Guest Physical Memory Address. */
747typedef const RTGCPHYS *PCRTGCPHYS;
748/** @def NIL_RTGCPHYS
749 * NIL GC Physical Address.
750 * NIL_RTGCPHYS is used to signal an invalid physical address, similar
751 * to the NULL pointer. Note that this value may actually be valid in
752 * some contexts.
753 */
754#define NIL_RTGCPHYS ((RTGCPHYS)~0U) /** @todo change this to (~(RTGCPHYS)0) or maybe NIL_RTGCPHYS32? */
755
756
757/** Guest Physical Memory Address; limited to 32 bits.*/
758typedef uint32_t RTGCPHYS32;
759/** Pointer to Guest Physical Memory Address. */
760typedef RTGCPHYS32 *PRTGCPHYS32;
761/** Pointer to const Guest Physical Memory Address. */
762typedef const RTGCPHYS32 *PCRTGCPHYS32;
763/** @def NIL_RTGCPHYS32
764 * NIL GC Physical Address.
765 * NIL_RTGCPHYS32 is used to signal an invalid physical address, similar
766 * to the NULL pointer. Note that this value may actually be valid in
767 * some contexts.
768 */
769#define NIL_RTGCPHYS32 (~(RTGCPHYS32)0)
770
771/** Guest context pointer.
772 * Keep in mind that this type is an unsigned integer in
773 * HC and void pointer in GC.
774 */
775#ifdef IN_GC
776typedef void *RTGCPTR;
777#else
778typedef RTGCUINTPTR RTGCPTR;
779#endif
780/** Pointer to a guest context pointer. */
781typedef RTGCPTR *PRTGCPTR;
782/** Pointer to a const guest context pointer. */
783typedef const RTGCPTR *PCRTGCPTR;
784/** @def NIL_RTGCPTR
785 * NIL GC pointer.
786 */
787#define NIL_RTGCPTR ((RTGCPTR)0)
788
789
790/** Unsigned integer register in the guest context. */
791#if GC_ARCH_BITS == 32
792typedef uint32_t RTGCUINTREG;
793#elif GC_ARCH_BITS == 64
794typedef uint64_t RTGCUINTREG;
795#else
796# error "Unsupported GC_ARCH_BITS!"
797#endif
798/** Pointer to an unsigned integer register in the guest context. */
799typedef RTGCUINTREG *PRTGCUINTREG;
800/** Pointer to a const unsigned integer register in the guest context. */
801typedef const RTGCUINTREG *PCRTGCUINTREG;
802
803/** @} */
804
805
806/** @defgroup grp_rt_types_cc Current Context Basic Types
807 * @ingroup grp_rt_types
808 * @{
809 */
810
811/** Current Context Physical Memory Address.*/
812#ifdef IN_GC
813typedef RTGCPHYS RTCCPHYS;
814#else
815typedef RTHCPHYS RTCCPHYS;
816#endif
817/** Pointer to Current Context Physical Memory Address. */
818typedef RTCCPHYS *PRTCCPHYS;
819/** Pointer to const Current Context Physical Memory Address. */
820typedef const RTCCPHYS *PCRTCCPHYS;
821/** @def NIL_RTCCPHYS
822 * NIL CC Physical Address.
823 * NIL_RTCCPHYS is used to signal an invalid physical address, similar
824 * to the NULL pointer.
825 */
826#ifdef IN_GC
827# define NIL_RTCCPHYS NIL_RTGCPHYS
828#else
829# define NIL_RTCCPHYS NIL_RTHCPHYS
830#endif
831
832/** Unsigned integer register in the current context. */
833#if ARCH_BITS == 32
834typedef uint32_t RTCCUINTREG;
835#elif ARCH_BITS == 64
836typedef uint64_t RTCCUINTREG;
837#else
838# error "Unsupported ARCH_BITS!"
839#endif
840/** Pointer to an unsigned integer register in the current context. */
841typedef RTCCUINTREG *PRTCCUINTREG;
842/** Pointer to a const unsigned integer register in the current context. */
843typedef const RTCCUINTREG *PCRTCCUINTREG;
844
845/** @deprecated */
846typedef RTCCUINTREG RTUINTREG;
847/** @deprecated */
848typedef RTCCUINTREG *PRTUINTREG;
849/** @deprecated */
850typedef const RTCCUINTREG *PCRTUINTREG;
851
852/** @} */
853
854
855/** File handle. */
856typedef RTUINT RTFILE;
857/** Pointer to file handle. */
858typedef RTFILE *PRTFILE;
859/** Nil file handle. */
860#define NIL_RTFILE (~(RTFILE)0)
861
862/** Loader module handle. */
863typedef R3PTRTYPE(struct RTLDRMODINTERNAL *) RTLDRMOD;
864/** Pointer to a loader module handle. */
865typedef RTLDRMOD *PRTLDRMOD;
866/** Nil loader module handle. */
867#define NIL_RTLDRMOD 0
868
869/** Ring-0 memory object handle. */
870typedef R0PTRTYPE(struct RTR0MEMOBJINTERNAL *) RTR0MEMOBJ;
871/** Pointer to a Ring-0 memory object handle. */
872typedef RTR0MEMOBJ *PRTR0MEMOBJ;
873/** Nil ring-0 memory object handle. */
874#define NIL_RTR0MEMOBJ 0
875
876/** Native thread handle. */
877typedef RTHCUINTPTR RTNATIVETHREAD;
878/** Pointer to an native thread handle. */
879typedef RTNATIVETHREAD *PRTNATIVETHREAD;
880/** Nil native thread handle. */
881#define NIL_RTNATIVETHREAD (~(RTNATIVETHREAD)0)
882
883/** Process identifier. */
884typedef uint32_t RTPROCESS;
885/** Pointer to a process identifier. */
886typedef RTPROCESS *PRTPROCESS;
887/** Nil process identifier. */
888#define NIL_RTPROCESS (~(RTPROCESS)0)
889
890/** Process ring-0 handle. */
891typedef RTR0UINTPTR RTR0PROCESS;
892/** Pointer to a ring-0 process handle. */
893typedef RTR0PROCESS *PRTR0PROCESS;
894/** Nil ring-0 process handle. */
895#define NIL_RTR0PROCESS (~(RTR0PROCESS)0)
896
897/** @typedef RTSEMEVENT
898 * Event Semaphore handle. */
899typedef R3R0PTRTYPE(struct RTSEMEVENTINTERNAL *) RTSEMEVENT;
900/** Pointer to an event semaphore handle. */
901typedef RTSEMEVENT *PRTSEMEVENT;
902/** Nil event semaphore handle. */
903#define NIL_RTSEMEVENT 0
904
905/** @typedef RTSEMEVENTMULTI
906 * Event Multiple Release Semaphore handle. */
907typedef R3R0PTRTYPE(struct RTSEMEVENTMULTIINTERNAL *) RTSEMEVENTMULTI;
908/** Pointer to an event multiple release semaphore handle. */
909typedef RTSEMEVENTMULTI *PRTSEMEVENTMULTI;
910/** Nil multiple release event semaphore handle. */
911#define NIL_RTSEMEVENTMULTI 0
912
913/** @typedef RTSEMFASTMUTEX
914 * Fast mutex Semaphore handle. */
915typedef R3R0PTRTYPE(struct RTSEMFASTMUTEXINTERNAL *) RTSEMFASTMUTEX;
916/** Pointer to a mutex semaphore handle. */
917typedef RTSEMFASTMUTEX *PRTSEMFASTMUTEX;
918/** Nil fast mutex semaphore handle. */
919#define NIL_RTSEMFASTMUTEX 0
920
921/** @typedef RTSEMMUTEX
922 * Mutex Semaphore handle. */
923typedef R3R0PTRTYPE(struct RTSEMMUTEXINTERNAL *) RTSEMMUTEX;
924/** Pointer to a mutex semaphore handle. */
925typedef RTSEMMUTEX *PRTSEMMUTEX;
926/** Nil mutex semaphore handle. */
927#define NIL_RTSEMMUTEX 0
928
929/** @typedef RTSEMRW
930 * Read/Write Semaphore handle. */
931typedef R3R0PTRTYPE(struct RTSEMRWINTERNAL *) RTSEMRW;
932/** Pointer to a read/write semaphore handle. */
933typedef RTSEMRW *PRTSEMRW;
934/** Nil read/write semaphore handle. */
935#define NIL_RTSEMRW 0
936
937/** Spinlock handle. */
938typedef R3R0PTRTYPE(struct RTSPINLOCKINTERNAL *) RTSPINLOCK;
939/** Pointer to a spinlock handle. */
940typedef RTSPINLOCK *PRTSPINLOCK;
941/** Nil spinlock handle. */
942#define NIL_RTSPINLOCK 0
943
944/** Socket handle. */
945typedef int RTSOCKET;
946/** Pointer to socket handle. */
947typedef RTSOCKET *PRTSOCKET;
948/** Nil socket handle. */
949#define NIL_RTSOCKET (~(RTSOCKET)0)
950
951/** Thread handle.*/
952typedef R3R0PTRTYPE(struct RTTHREADINT *) RTTHREAD;
953/** Pointer to thread handle. */
954typedef RTTHREAD *PRTTHREAD;
955/** Nil thread handle. */
956#define NIL_RTTHREAD 0
957
958/** A TLS index. */
959typedef int RTTLS;
960/** Pointer to a TLS index. */
961typedef RTTLS *PRTTLS;
962/** Pointer to a const TLS index. */
963typedef RTTLS const *PCRTTLS;
964/** NIL TLS index value. */
965#define NIL_RTTLS (-1)
966
967/** Handle to a simple heap. */
968typedef R3R0PTRTYPE(struct RTHEAPSIMPLEINTERNAL *) RTHEAPSIMPLE;
969/** Pointer to a handle to a simple heap. */
970typedef RTHEAPSIMPLE *PRTHEAPSIMPLE;
971/** NIL simple heap handle. */
972#define NIL_RTHEAPSIMPLE ((RTHEAPSIMPLE)0)
973
974/** Handle to an environment block. */
975typedef R3PTRTYPE(struct RTENVINTERNAL *) RTENV;
976/** Pointer to a handle to an environment block. */
977typedef RTENV *PRTENV;
978/** NIL simple heap handle. */
979#define NIL_RTENV ((RTENV)0)
980
981/** A CPU identifier.
982 * @remarks This doesn't have to correspond to the APIC ID (intel/amd). Nor
983 * does it have to correspond to the bits in the affinity mask, at
984 * least not until we've sorted out Windows NT. */
985typedef RTHCUINTPTR RTCPUID;
986/** Pointer to a CPU identifier. */
987typedef RTCPUID *PRTCPUID;
988/** Pointer to a const CPU identifier. */
989typedef RTCPUID const *PCRTCPUID;
990/** Nil CPU Id. */
991#define NIL_RTCPUID ((RTCPUID)~0)
992
993/** A CPU set.
994 * Treat this as an opaque type and always use RTCpuSet* for manupulating it. */
995typedef uint64_t RTCPUSET;
996/** Pointer to a CPU set. */
997typedef RTCPUSET *PRTCPUSET;
998/** Pointer to a const CPU set. */
999typedef RTCPUSET const *PCRTCPUSET;
1000
1001
1002/**
1003 * UUID data type.
1004 */
1005typedef union RTUUID
1006{
1007 /** 8-bit view. */
1008 uint8_t au8[16];
1009 /** 16-bit view. */
1010 uint16_t au16[8];
1011 /** 32-bit view. */
1012 uint32_t au32[4];
1013 /** 64-bit view. */
1014 uint64_t au64[2];
1015 /** The way the UUID is declared by the ext2 guys. */
1016 struct
1017 {
1018 uint32_t u32TimeLow;
1019 uint16_t u16TimeMid;
1020 uint16_t u16TimeHiAndVersion;
1021 uint16_t u16ClockSeq;
1022 uint8_t au8Node[6];
1023 } Gen;
1024 /** @deprecated */
1025 unsigned char aUuid[16];
1026} RTUUID;
1027/** Pointer to UUID data. */
1028typedef RTUUID *PRTUUID;
1029/** Pointer to readonly UUID data. */
1030typedef const RTUUID *PCRTUUID;
1031
1032/**
1033 * UUID string maximum length.
1034 */
1035#define RTUUID_STR_LENGTH 37
1036
1037
1038/** Compression handle. */
1039typedef struct RTZIPCOMP *PRTZIPCOMP;
1040
1041/** Decompressor handle. */
1042typedef struct RTZIPDECOMP *PRTZIPDECOMP;
1043
1044
1045/**
1046 * Unicode Code Point.
1047 */
1048typedef uint32_t RTUNICP;
1049/** Pointer to an Unicode Code Point. */
1050typedef RTUNICP *PRTUNICP;
1051/** Pointer to an Unicode Code Point. */
1052typedef const RTUNICP *PCRTUNICP;
1053
1054
1055/**
1056 * UTF-16 character.
1057 * @remark wchar_t is not usable since it's compiler defined.
1058 * @remark When we use the term character we're not talking about unicode code point, but
1059 * the basic unit of the string encoding. Thus cwc - count of wide chars - means
1060 * count of RTUTF16; cuc - count of unicode chars - means count of RTUNICP;
1061 * and cch means count of the typedef 'char', which is assumed to be an octet.
1062 */
1063typedef uint16_t RTUTF16;
1064/** Pointer to a UTF-16 character. */
1065typedef RTUTF16 *PRTUTF16;
1066/** Pointer to a const UTF-16 character. */
1067typedef const RTUTF16 *PCRTUTF16;
1068
1069
1070/**
1071 * Wait for ever if we have to.
1072 */
1073#define RT_INDEFINITE_WAIT (~0U)
1074
1075
1076/**
1077 * Generic process callback.
1078 *
1079 * @returns VBox status code. Failure will cancel the operation.
1080 * @param uPercentage The percentage of the operation which has been completed.
1081 * @param pvUser The user specified argument.
1082 */
1083typedef DECLCALLBACK(int) FNRTPROGRESS(unsigned uPrecentage, void *pvUser);
1084/** Pointer to a generic progress callback function, FNRTPROCESS(). */
1085typedef FNRTPROGRESS *PFNRTPROGRESS;
1086
1087
1088/**
1089 * Rectangle data type.
1090 */
1091typedef struct RTRECT
1092{
1093 /** left X coordinate. */
1094 int32_t xLeft;
1095 /** top Y coordinate. */
1096 int32_t yTop;
1097 /** right X coordinate. (exclusive) */
1098 int32_t xRight;
1099 /** bottom Y coordinate. (exclusive) */
1100 int32_t yBottom;
1101} RTRECT;
1102/** Pointer to a rectangle. */
1103typedef RTRECT *PRTRECT;
1104/** Pointer to a const rectangle. */
1105typedef const RTRECT *PCRTRECT;
1106
1107/** @} */
1108
1109#endif
1110
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