VirtualBox

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

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

rebranding: IPRT files again.

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