VirtualBox

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

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

obsolete todo.

  • 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. */
598typedef uint64_t RTHCPHYS;
599/** Pointer to Host Physical Memory Address. */
600typedef RTHCPHYS *PRTHCPHYS;
601/** Pointer to const Host Physical Memory Address. */
602typedef const RTHCPHYS *PCRTHCPHYS;
603/** @def NIL_RTHCPHYS
604 * NIL HC Physical Address.
605 * NIL_RTHCPHYS is used to signal an invalid physical address, similar
606 * to the NULL pointer.
607 */
608#define NIL_RTHCPHYS ((RTHCPHYS)~0U) /** @todo change this to (~(VBOXHCPHYS)0) */
609
610
611/** HC pointer. */
612#ifndef IN_GC
613typedef void * RTHCPTR;
614#else
615typedef RTHCUINTPTR RTHCPTR;
616#endif
617/** Pointer to HC pointer. */
618typedef RTHCPTR *PRTHCPTR;
619/** Pointer to const HC pointer. */
620typedef const RTHCPTR *PCRTHCPTR;
621/** @def NIL_RTHCPTR
622 * NIL HC pointer.
623 */
624#define NIL_RTHCPTR ((RTHCPTR)0)
625
626/** HC ring-3 pointer. */
627#ifdef IN_RING3
628typedef void * RTR3PTR;
629#else
630typedef RTR3UINTPTR RTR3PTR;
631#endif
632/** Pointer to HC ring-3 pointer. */
633typedef RTR3PTR *PRTR3PTR;
634/** Pointer to const HC ring-3 pointer. */
635typedef const RTR3PTR *PCRTR3PTR;
636/** @def NIL_RTR3PTR
637 * NIL HC ring-3 pointer.
638 */
639#define NIL_RTR3PTR ((RTR3PTR)0)
640
641/** HC ring-0 pointer. */
642#ifdef IN_RING0
643typedef void * RTR0PTR;
644#else
645typedef RTR0UINTPTR RTR0PTR;
646#endif
647/** Pointer to HC ring-0 pointer. */
648typedef RTR0PTR *PRTR0PTR;
649/** Pointer to const HC ring-0 pointer. */
650typedef const RTR0PTR *PCRTR0PTR;
651/** @def NIL_RTR0PTR
652 * NIL HC ring-0 pointer.
653 */
654#define NIL_RTR0PTR ((RTR0PTR)0)
655
656
657/** Unsigned integer register in the host context. */
658#if HC_ARCH_BITS == 32
659typedef uint32_t RTHCUINTREG;
660#elif HC_ARCH_BITS == 64
661typedef uint64_t RTHCUINTREG;
662#else
663# error "Unsupported HC_ARCH_BITS!"
664#endif
665/** Pointer to an unsigned integer register in the host context. */
666typedef RTHCUINTREG *PRTHCUINTREG;
667/** Pointer to a const unsigned integer register in the host context. */
668typedef const RTHCUINTREG *PCRTHCUINTREG;
669
670/** Unsigned integer register in the host ring-3 context. */
671#if R3_ARCH_BITS == 32
672typedef uint32_t RTR3UINTREG;
673#elif R3_ARCH_BITS == 64
674typedef uint64_t RTR3UINTREG;
675#else
676# error "Unsupported R3_ARCH_BITS!"
677#endif
678/** Pointer to an unsigned integer register in the host ring-3 context. */
679typedef RTR3UINTREG *PRTR3UINTREG;
680/** Pointer to a const unsigned integer register in the host ring-3 context. */
681typedef const RTR3UINTREG *PCRTR3UINTREG;
682
683/** Unsigned integer register in the host ring-3 context. */
684#if R0_ARCH_BITS == 32
685typedef uint32_t RTR0UINTREG;
686#elif R0_ARCH_BITS == 64
687typedef uint64_t RTR0UINTREG;
688#else
689# error "Unsupported R3_ARCH_BITS!"
690#endif
691/** Pointer to an unsigned integer register in the host ring-3 context. */
692typedef RTR0UINTREG *PRTR0UINTREG;
693/** Pointer to a const unsigned integer register in the host ring-3 context. */
694typedef const RTR0UINTREG *PCRTR0UINTREG;
695
696/** @} */
697
698
699/** @defgroup grp_rt_types_gc Guest Context Basic Types
700 * @ingroup grp_rt_types
701 * @{
702 */
703
704/** Natural signed integer in the GC. */
705typedef int32_t RTGCINT;
706/** Pointer to natural signed interger in GC. */
707typedef RTGCINT *PRTGCINT;
708/** Pointer to const natural signed interger in GC. */
709typedef const RTGCINT *PCRTGCINT;
710
711/** Natural signed uninteger in the GC. */
712typedef uint32_t RTGCUINT;
713/** Pointer to natural unsigned interger in GC. */
714typedef RTGCUINT *PRTGCUINT;
715/** Pointer to const natural unsigned interger in GC. */
716typedef const RTGCUINT *PCRTGCUINT;
717
718/** Signed integer which can contain a GC pointer. */
719#if GC_ARCH_BITS == 32
720typedef int32_t RTGCINTPTR;
721#elif GC_ARCH_BITS == 64
722typedef int64_t RTGCINTPTR;
723#else
724# error Unsupported GC_ARCH_BITS value.
725#endif
726/** Pointer to signed interger which can contain a GC pointer. */
727typedef RTGCINTPTR *PRTGCINTPTR;
728/** Pointer to const signed interger which can contain a GC pointer. */
729typedef const RTGCINTPTR *PCRTGCINTPTR;
730
731/** Unsigned integer which can contain a GC pointer. */
732#if GC_ARCH_BITS == 32
733typedef uint32_t RTGCUINTPTR;
734#elif GC_ARCH_BITS == 64
735typedef uint64_t RTGCUINTPTR;
736#else
737# error Unsupported GC_ARCH_BITS value.
738#endif
739/** Pointer to unsigned interger which can contain a GC pointer. */
740typedef RTGCUINTPTR *PRTGCUINTPTR;
741/** Pointer to unsigned interger which can contain a GC pointer. */
742typedef const RTGCUINTPTR *PCRTGCUINTPTR;
743
744/** Unsigned integer which can contain a 32 bits GC pointer. */
745typedef uint32_t RTGCUINTPTR32;
746/** Pointer to unsigned interger which can contain a 32 bits GC pointer. */
747typedef RTGCUINTPTR32 *PRTGCUINTPTR32;
748/** Pointer to unsigned interger which can contain a 32 bits GC pointer. */
749typedef const RTGCUINTPTR32 *PCRTGCUINTPTR32;
750
751/** Unsigned integer which can contain a 64 bits GC pointer. */
752typedef uint64_t RTGCUINTPTR64;
753/** Pointer to unsigned interger which can contain a 32 bits GC pointer. */
754typedef RTGCUINTPTR64 *PRTGCUINTPTR64;
755/** Pointer to unsigned interger which can contain a 32 bits GC pointer. */
756typedef const RTGCUINTPTR64 *PCRTGCUINTPTR64;
757
758/** Guest Physical Memory Address.*/
759typedef uint64_t RTGCPHYS;
760/** Pointer to Guest Physical Memory Address. */
761typedef RTGCPHYS *PRTGCPHYS;
762/** Pointer to const Guest Physical Memory Address. */
763typedef const RTGCPHYS *PCRTGCPHYS;
764/** @def NIL_RTGCPHYS
765 * NIL GC Physical Address.
766 * NIL_RTGCPHYS is used to signal an invalid physical address, similar
767 * to the NULL pointer. Note that this value may actually be valid in
768 * some contexts.
769 */
770#define NIL_RTGCPHYS (~(RTGCPHYS)0U)
771
772
773/** Guest Physical Memory Address; limited to 32 bits.*/
774typedef uint32_t RTGCPHYS32;
775/** Pointer to Guest Physical Memory Address. */
776typedef RTGCPHYS32 *PRTGCPHYS32;
777/** Pointer to const Guest Physical Memory Address. */
778typedef const RTGCPHYS32 *PCRTGCPHYS32;
779/** @def NIL_RTGCPHYS32
780 * NIL GC Physical Address.
781 * NIL_RTGCPHYS32 is used to signal an invalid physical address, similar
782 * to the NULL pointer. Note that this value may actually be valid in
783 * some contexts.
784 */
785#define NIL_RTGCPHYS32 (~(RTGCPHYS32)0)
786
787
788/** Guest Physical Memory Address; limited to 64 bits.*/
789typedef uint64_t RTGCPHYS64;
790/** Pointer to Guest Physical Memory Address. */
791typedef RTGCPHYS64 *PRTGCPHYS64;
792/** Pointer to const Guest Physical Memory Address. */
793typedef const RTGCPHYS64 *PCRTGCPHYS64;
794/** @def NIL_RTGCPHYS64
795 * NIL GC Physical Address.
796 * NIL_RTGCPHYS64 is used to signal an invalid physical address, similar
797 * to the NULL pointer. Note that this value may actually be valid in
798 * some contexts.
799 */
800#define NIL_RTGCPHYS64 (~(RTGCPHYS64)0)
801
802/** Guest context pointer.
803 * Keep in mind that this type is an unsigned integer in
804 * HC and void pointer in GC.
805 */
806#ifdef IN_GC
807typedef void *RTGCPTR;
808#else
809typedef RTGCUINTPTR RTGCPTR;
810#endif
811/** Pointer to a guest context pointer. */
812typedef RTGCPTR *PRTGCPTR;
813/** Pointer to a const guest context pointer. */
814typedef const RTGCPTR *PCRTGCPTR;
815/** @def NIL_RTGCPTR
816 * NIL GC pointer.
817 */
818#define NIL_RTGCPTR ((RTGCPTR)0)
819
820/** Guest context pointer, 32 bits.
821 * Keep in mind that this type is an unsigned integer in
822 * HC and void pointer in GC.
823 */
824#ifdef IN_GC
825typedef void *RTGCPTR32;
826#else
827typedef RTGCUINTPTR32 RTGCPTR32;
828#endif
829/** Pointer to a guest context pointer. */
830typedef RTGCPTR32 *PRTGCPTR32;
831/** Pointer to a const guest context pointer. */
832typedef const RTGCPTR32 *PCRTGCPTR32;
833/** @def NIL_RTGCPTR32
834 * NIL GC pointer.
835 */
836#define NIL_RTGCPTR32 ((RTGCPTR32)0)
837
838/** Guest context pointer, 64 bits.
839 */
840typedef RTGCUINTPTR64 RTGCPTR64;
841/** Pointer to a guest context pointer. */
842typedef RTGCPTR64 *PRTGCPTR64;
843/** Pointer to a const guest context pointer. */
844typedef const RTGCPTR64 *PCRTGCPTR64;
845/** @def NIL_RTGCPTR64
846 * NIL GC pointer.
847 */
848#define NIL_RTGCPTR64 ((RTGCPTR64)0)
849
850/** Unsigned integer register in the guest context. */
851#if GC_ARCH_BITS == 32
852typedef uint32_t RTGCUINTREG;
853#elif GC_ARCH_BITS == 64
854typedef uint64_t RTGCUINTREG;
855#else
856# error "Unsupported GC_ARCH_BITS!"
857#endif
858/** Pointer to an unsigned integer register in the guest context. */
859typedef RTGCUINTREG *PRTGCUINTREG;
860/** Pointer to a const unsigned integer register in the guest context. */
861typedef const RTGCUINTREG *PCRTGCUINTREG;
862
863/** @} */
864
865
866/** @defgroup grp_rt_types_cc Current Context Basic Types
867 * @ingroup grp_rt_types
868 * @{
869 */
870
871/** Current Context Physical Memory Address.*/
872#ifdef IN_GC
873typedef RTGCPHYS RTCCPHYS;
874#else
875typedef RTHCPHYS RTCCPHYS;
876#endif
877/** Pointer to Current Context Physical Memory Address. */
878typedef RTCCPHYS *PRTCCPHYS;
879/** Pointer to const Current Context Physical Memory Address. */
880typedef const RTCCPHYS *PCRTCCPHYS;
881/** @def NIL_RTCCPHYS
882 * NIL CC Physical Address.
883 * NIL_RTCCPHYS is used to signal an invalid physical address, similar
884 * to the NULL pointer.
885 */
886#ifdef IN_GC
887# define NIL_RTCCPHYS NIL_RTGCPHYS
888#else
889# define NIL_RTCCPHYS NIL_RTHCPHYS
890#endif
891
892/** Unsigned integer register in the current context. */
893#if ARCH_BITS == 32
894typedef uint32_t RTCCUINTREG;
895#elif ARCH_BITS == 64
896typedef uint64_t RTCCUINTREG;
897#else
898# error "Unsupported ARCH_BITS!"
899#endif
900/** Pointer to an unsigned integer register in the current context. */
901typedef RTCCUINTREG *PRTCCUINTREG;
902/** Pointer to a const unsigned integer register in the current context. */
903typedef const RTCCUINTREG *PCRTCCUINTREG;
904
905/** @deprecated */
906typedef RTCCUINTREG RTUINTREG;
907/** @deprecated */
908typedef RTCCUINTREG *PRTUINTREG;
909/** @deprecated */
910typedef const RTCCUINTREG *PCRTUINTREG;
911
912/** @} */
913
914
915/** File handle. */
916typedef RTUINT RTFILE;
917/** Pointer to file handle. */
918typedef RTFILE *PRTFILE;
919/** Nil file handle. */
920#define NIL_RTFILE (~(RTFILE)0)
921
922/** Loader module handle. */
923typedef R3PTRTYPE(struct RTLDRMODINTERNAL *) RTLDRMOD;
924/** Pointer to a loader module handle. */
925typedef RTLDRMOD *PRTLDRMOD;
926/** Nil loader module handle. */
927#define NIL_RTLDRMOD 0
928
929/** Ring-0 memory object handle. */
930typedef R0PTRTYPE(struct RTR0MEMOBJINTERNAL *) RTR0MEMOBJ;
931/** Pointer to a Ring-0 memory object handle. */
932typedef RTR0MEMOBJ *PRTR0MEMOBJ;
933/** Nil ring-0 memory object handle. */
934#define NIL_RTR0MEMOBJ 0
935
936/** Native thread handle. */
937typedef RTHCUINTPTR RTNATIVETHREAD;
938/** Pointer to an native thread handle. */
939typedef RTNATIVETHREAD *PRTNATIVETHREAD;
940/** Nil native thread handle. */
941#define NIL_RTNATIVETHREAD (~(RTNATIVETHREAD)0)
942
943/** Process identifier. */
944typedef uint32_t RTPROCESS;
945/** Pointer to a process identifier. */
946typedef RTPROCESS *PRTPROCESS;
947/** Nil process identifier. */
948#define NIL_RTPROCESS (~(RTPROCESS)0)
949
950/** Process ring-0 handle. */
951typedef RTR0UINTPTR RTR0PROCESS;
952/** Pointer to a ring-0 process handle. */
953typedef RTR0PROCESS *PRTR0PROCESS;
954/** Nil ring-0 process handle. */
955#define NIL_RTR0PROCESS (~(RTR0PROCESS)0)
956
957/** @typedef RTSEMEVENT
958 * Event Semaphore handle. */
959typedef R3R0PTRTYPE(struct RTSEMEVENTINTERNAL *) RTSEMEVENT;
960/** Pointer to an event semaphore handle. */
961typedef RTSEMEVENT *PRTSEMEVENT;
962/** Nil event semaphore handle. */
963#define NIL_RTSEMEVENT 0
964
965/** @typedef RTSEMEVENTMULTI
966 * Event Multiple Release Semaphore handle. */
967typedef R3R0PTRTYPE(struct RTSEMEVENTMULTIINTERNAL *) RTSEMEVENTMULTI;
968/** Pointer to an event multiple release semaphore handle. */
969typedef RTSEMEVENTMULTI *PRTSEMEVENTMULTI;
970/** Nil multiple release event semaphore handle. */
971#define NIL_RTSEMEVENTMULTI 0
972
973/** @typedef RTSEMFASTMUTEX
974 * Fast mutex Semaphore handle. */
975typedef R3R0PTRTYPE(struct RTSEMFASTMUTEXINTERNAL *) RTSEMFASTMUTEX;
976/** Pointer to a mutex semaphore handle. */
977typedef RTSEMFASTMUTEX *PRTSEMFASTMUTEX;
978/** Nil fast mutex semaphore handle. */
979#define NIL_RTSEMFASTMUTEX 0
980
981/** @typedef RTSEMMUTEX
982 * Mutex Semaphore handle. */
983typedef R3R0PTRTYPE(struct RTSEMMUTEXINTERNAL *) RTSEMMUTEX;
984/** Pointer to a mutex semaphore handle. */
985typedef RTSEMMUTEX *PRTSEMMUTEX;
986/** Nil mutex semaphore handle. */
987#define NIL_RTSEMMUTEX 0
988
989/** @typedef RTSEMRW
990 * Read/Write Semaphore handle. */
991typedef R3R0PTRTYPE(struct RTSEMRWINTERNAL *) RTSEMRW;
992/** Pointer to a read/write semaphore handle. */
993typedef RTSEMRW *PRTSEMRW;
994/** Nil read/write semaphore handle. */
995#define NIL_RTSEMRW 0
996
997/** Spinlock handle. */
998typedef R3R0PTRTYPE(struct RTSPINLOCKINTERNAL *) RTSPINLOCK;
999/** Pointer to a spinlock handle. */
1000typedef RTSPINLOCK *PRTSPINLOCK;
1001/** Nil spinlock handle. */
1002#define NIL_RTSPINLOCK 0
1003
1004/** Socket handle. */
1005typedef int RTSOCKET;
1006/** Pointer to socket handle. */
1007typedef RTSOCKET *PRTSOCKET;
1008/** Nil socket handle. */
1009#define NIL_RTSOCKET (~(RTSOCKET)0)
1010
1011/** Thread handle.*/
1012typedef R3R0PTRTYPE(struct RTTHREADINT *) RTTHREAD;
1013/** Pointer to thread handle. */
1014typedef RTTHREAD *PRTTHREAD;
1015/** Nil thread handle. */
1016#define NIL_RTTHREAD 0
1017
1018/** A TLS index. */
1019typedef int RTTLS;
1020/** Pointer to a TLS index. */
1021typedef RTTLS *PRTTLS;
1022/** Pointer to a const TLS index. */
1023typedef RTTLS const *PCRTTLS;
1024/** NIL TLS index value. */
1025#define NIL_RTTLS (-1)
1026
1027/** Handle to a simple heap. */
1028typedef R3R0PTRTYPE(struct RTHEAPSIMPLEINTERNAL *) RTHEAPSIMPLE;
1029/** Pointer to a handle to a simple heap. */
1030typedef RTHEAPSIMPLE *PRTHEAPSIMPLE;
1031/** NIL simple heap handle. */
1032#define NIL_RTHEAPSIMPLE ((RTHEAPSIMPLE)0)
1033
1034/** Handle to an environment block. */
1035typedef R3PTRTYPE(struct RTENVINTERNAL *) RTENV;
1036/** Pointer to a handle to an environment block. */
1037typedef RTENV *PRTENV;
1038/** NIL simple heap handle. */
1039#define NIL_RTENV ((RTENV)0)
1040
1041/** A CPU identifier.
1042 * @remarks This doesn't have to correspond to the APIC ID (intel/amd). Nor
1043 * does it have to correspond to the bits in the affinity mask, at
1044 * least not until we've sorted out Windows NT. */
1045typedef RTHCUINTPTR RTCPUID;
1046/** Pointer to a CPU identifier. */
1047typedef RTCPUID *PRTCPUID;
1048/** Pointer to a const CPU identifier. */
1049typedef RTCPUID const *PCRTCPUID;
1050/** Nil CPU Id. */
1051#define NIL_RTCPUID ((RTCPUID)~0)
1052
1053/** A CPU set.
1054 * Treat this as an opaque type and always use RTCpuSet* for manupulating it. */
1055typedef uint64_t RTCPUSET;
1056/** Pointer to a CPU set. */
1057typedef RTCPUSET *PRTCPUSET;
1058/** Pointer to a const CPU set. */
1059typedef RTCPUSET const *PCRTCPUSET;
1060
1061
1062/**
1063 * UUID data type.
1064 */
1065typedef union RTUUID
1066{
1067 /** 8-bit view. */
1068 uint8_t au8[16];
1069 /** 16-bit view. */
1070 uint16_t au16[8];
1071 /** 32-bit view. */
1072 uint32_t au32[4];
1073 /** 64-bit view. */
1074 uint64_t au64[2];
1075 /** The way the UUID is declared by the ext2 guys. */
1076 struct
1077 {
1078 uint32_t u32TimeLow;
1079 uint16_t u16TimeMid;
1080 uint16_t u16TimeHiAndVersion;
1081 uint16_t u16ClockSeq;
1082 uint8_t au8Node[6];
1083 } Gen;
1084 /** @deprecated */
1085 unsigned char aUuid[16];
1086} RTUUID;
1087/** Pointer to UUID data. */
1088typedef RTUUID *PRTUUID;
1089/** Pointer to readonly UUID data. */
1090typedef const RTUUID *PCRTUUID;
1091
1092/**
1093 * UUID string maximum length.
1094 */
1095#define RTUUID_STR_LENGTH 37
1096
1097
1098/** Compression handle. */
1099typedef struct RTZIPCOMP *PRTZIPCOMP;
1100
1101/** Decompressor handle. */
1102typedef struct RTZIPDECOMP *PRTZIPDECOMP;
1103
1104
1105/**
1106 * Unicode Code Point.
1107 */
1108typedef uint32_t RTUNICP;
1109/** Pointer to an Unicode Code Point. */
1110typedef RTUNICP *PRTUNICP;
1111/** Pointer to an Unicode Code Point. */
1112typedef const RTUNICP *PCRTUNICP;
1113
1114
1115/**
1116 * UTF-16 character.
1117 * @remark wchar_t is not usable since it's compiler defined.
1118 * @remark When we use the term character we're not talking about unicode code point, but
1119 * the basic unit of the string encoding. Thus cwc - count of wide chars - means
1120 * count of RTUTF16; cuc - count of unicode chars - means count of RTUNICP;
1121 * and cch means count of the typedef 'char', which is assumed to be an octet.
1122 */
1123typedef uint16_t RTUTF16;
1124/** Pointer to a UTF-16 character. */
1125typedef RTUTF16 *PRTUTF16;
1126/** Pointer to a const UTF-16 character. */
1127typedef const RTUTF16 *PCRTUTF16;
1128
1129
1130/**
1131 * Wait for ever if we have to.
1132 */
1133#define RT_INDEFINITE_WAIT (~0U)
1134
1135
1136/**
1137 * Generic process callback.
1138 *
1139 * @returns VBox status code. Failure will cancel the operation.
1140 * @param uPercentage The percentage of the operation which has been completed.
1141 * @param pvUser The user specified argument.
1142 */
1143typedef DECLCALLBACK(int) FNRTPROGRESS(unsigned uPrecentage, void *pvUser);
1144/** Pointer to a generic progress callback function, FNRTPROCESS(). */
1145typedef FNRTPROGRESS *PFNRTPROGRESS;
1146
1147
1148/**
1149 * Rectangle data type.
1150 */
1151typedef struct RTRECT
1152{
1153 /** left X coordinate. */
1154 int32_t xLeft;
1155 /** top Y coordinate. */
1156 int32_t yTop;
1157 /** right X coordinate. (exclusive) */
1158 int32_t xRight;
1159 /** bottom Y coordinate. (exclusive) */
1160 int32_t yBottom;
1161} RTRECT;
1162/** Pointer to a rectangle. */
1163typedef RTRECT *PRTRECT;
1164/** Pointer to a const rectangle. */
1165typedef const RTRECT *PCRTRECT;
1166
1167/** @} */
1168
1169#endif
1170
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