VirtualBox

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

Last change on this file since 11303 was 10962, checked in by vboxsync, 16 years ago

iprt/types.h: Added RTMAC.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 36.8 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/** The max value for RTFOFF. */
410#define RTFOFF_MAX INT64_MAX
411/** The min value for RTFOFF. */
412#define RTFOFF_MIN INT64_MIN
413
414/** File mode (see iprt/fs.h). */
415typedef uint32_t RTFMODE;
416/** Pointer to file mode. */
417typedef RTFMODE *PRTFMODE;
418
419/** Device unix number. */
420typedef uint32_t RTDEV;
421/** Pointer to a device unix number. */
422typedef RTDEV *PRTDEV;
423
424/** i-node number. */
425typedef uint64_t RTINODE;
426/** Pointer to a i-node number. */
427typedef RTINODE *PRTINODE;
428
429/** User id. */
430typedef uint32_t RTUID;
431/** Pointer to a user id. */
432typedef RTUID *PRTUID;
433/** NIL user id.
434 * @todo check this for portability! */
435#define NIL_RTUID (~(RTUID)0);
436
437/** Group id. */
438typedef uint32_t RTGID;
439/** Pointer to a group id. */
440typedef RTGID *PRTGID;
441/** NIL group id.
442 * @todo check this for portability! */
443#define NIL_RTGID (~(RTGID)0);
444
445/** I/O Port. */
446typedef uint16_t RTIOPORT;
447/** Pointer to I/O Port. */
448typedef RTIOPORT *PRTIOPORT;
449/** Pointer to const I/O Port. */
450typedef const RTIOPORT *PCRTIOPORT;
451
452/** Selector. */
453typedef uint16_t RTSEL;
454/** Pointer to selector. */
455typedef RTSEL *PRTSEL;
456/** Pointer to const selector. */
457typedef const RTSEL *PCRTSEL;
458
459/** Far 16-bit pointer. */
460#pragma pack(1)
461typedef struct RTFAR16
462{
463 uint16_t off;
464 RTSEL sel;
465} RTFAR16;
466#pragma pack()
467/** Pointer to Far 16-bit pointer. */
468typedef RTFAR16 *PRTFAR16;
469/** Pointer to const Far 16-bit pointer. */
470typedef const RTFAR16 *PCRTFAR16;
471
472/** Far 32-bit pointer. */
473#pragma pack(1)
474typedef struct RTFAR32
475{
476 uint32_t off;
477 RTSEL sel;
478} RTFAR32;
479#pragma pack()
480/** Pointer to Far 32-bit pointer. */
481typedef RTFAR32 *PRTFAR32;
482/** Pointer to const Far 32-bit pointer. */
483typedef const RTFAR32 *PCRTFAR32;
484
485/** Far 64-bit pointer. */
486#pragma pack(1)
487typedef struct RTFAR64
488{
489 uint64_t off;
490 RTSEL sel;
491} RTFAR64;
492#pragma pack()
493/** Pointer to Far 64-bit pointer. */
494typedef RTFAR64 *PRTFAR64;
495/** Pointer to const Far 64-bit pointer. */
496typedef const RTFAR64 *PCRTFAR64;
497
498/** @} */
499
500
501/** @defgroup grp_rt_types_hc Host Context Basic Types
502 * @ingroup grp_rt_types
503 * @{
504 */
505
506/** HC Natural signed integer. */
507typedef int32_t RTHCINT;
508/** Pointer to HC Natural signed integer. */
509typedef RTHCINT *PRTHCINT;
510/** Pointer to const HC Natural signed integer. */
511typedef const RTHCINT *PCRTHCINT;
512
513/** HC Natural unsigned integer. */
514typedef uint32_t RTHCUINT;
515/** Pointer to HC Natural unsigned integer. */
516typedef RTHCUINT *PRTHCUINT;
517/** Pointer to const HC Natural unsigned integer. */
518typedef const RTHCUINT *PCRTHCUINT;
519
520
521/** Signed integer which can contain a HC pointer. */
522#if HC_ARCH_BITS == 32
523typedef int32_t RTHCINTPTR;
524#elif HC_ARCH_BITS == 64
525typedef int64_t RTHCINTPTR;
526#else
527# error Unsupported HC_ARCH_BITS value.
528#endif
529/** Pointer to signed interger which can contain a HC pointer. */
530typedef RTHCINTPTR *PRTHCINTPTR;
531/** Pointer to const signed interger which can contain a HC pointer. */
532typedef const RTHCINTPTR *PCRTHCINTPTR;
533
534/** Signed integer which can contain a HC ring-3 pointer. */
535#if R3_ARCH_BITS == 32
536typedef int32_t RTR3INTPTR;
537#elif R3_ARCH_BITS == 64
538typedef int64_t RTR3INTPTR;
539#else
540# error Unsupported R3_ARCH_BITS value.
541#endif
542/** Pointer to signed interger which can contain a HC ring-3 pointer. */
543typedef RTR3INTPTR *PRTR3INTPTR;
544/** Pointer to const signed interger which can contain a HC ring-3 pointer. */
545typedef const RTR3INTPTR *PCRTR3INTPTR;
546
547/** Signed integer which can contain a HC ring-0 pointer. */
548#if R0_ARCH_BITS == 32
549typedef int32_t RTR0INTPTR;
550#elif R0_ARCH_BITS == 64
551typedef int64_t RTR0INTPTR;
552#else
553# error Unsupported R0_ARCH_BITS value.
554#endif
555/** Pointer to signed interger which can contain a HC ring-0 pointer. */
556typedef RTR0INTPTR *PRTR0INTPTR;
557/** Pointer to const signed interger which can contain a HC ring-0 pointer. */
558typedef const RTR0INTPTR *PCRTR0INTPTR;
559
560
561/** Unsigned integer which can contain a HC pointer. */
562#if HC_ARCH_BITS == 32
563typedef uint32_t RTHCUINTPTR;
564#elif HC_ARCH_BITS == 64
565typedef uint64_t RTHCUINTPTR;
566#else
567# error Unsupported HC_ARCH_BITS value.
568#endif
569/** Pointer to unsigned interger which can contain a HC pointer. */
570typedef RTHCUINTPTR *PRTHCUINTPTR;
571/** Pointer to unsigned interger which can contain a HC pointer. */
572typedef const RTHCUINTPTR *PCRTHCUINTPTR;
573
574/** Unsigned integer which can contain a HC ring-3 pointer. */
575#if R3_ARCH_BITS == 32
576typedef uint32_t RTR3UINTPTR;
577#elif R3_ARCH_BITS == 64
578typedef uint64_t RTR3UINTPTR;
579#else
580# error Unsupported R3_ARCH_BITS value.
581#endif
582/** Pointer to unsigned interger which can contain a HC ring-3 pointer. */
583typedef RTR3UINTPTR *PRTR3UINTPTR;
584/** Pointer to unsigned interger which can contain a HC ring-3 pointer. */
585typedef const RTR3UINTPTR *PCRTR3UINTPTR;
586
587/** Unsigned integer which can contain a HC ring-0 pointer. */
588#if R0_ARCH_BITS == 32
589typedef uint32_t RTR0UINTPTR;
590#elif R0_ARCH_BITS == 64
591typedef uint64_t RTR0UINTPTR;
592#else
593# error Unsupported R0_ARCH_BITS value.
594#endif
595/** Pointer to unsigned interger which can contain a HC ring-0 pointer. */
596typedef RTR0UINTPTR *PRTR0UINTPTR;
597/** Pointer to unsigned interger which can contain a HC ring-0 pointer. */
598typedef const RTR0UINTPTR *PCRTR0UINTPTR;
599
600
601/** Host Physical Memory Address. */
602typedef uint64_t RTHCPHYS;
603/** Pointer to Host Physical Memory Address. */
604typedef RTHCPHYS *PRTHCPHYS;
605/** Pointer to const Host Physical Memory Address. */
606typedef const RTHCPHYS *PCRTHCPHYS;
607/** @def NIL_RTHCPHYS
608 * NIL HC Physical Address.
609 * NIL_RTHCPHYS is used to signal an invalid physical address, similar
610 * to the NULL pointer.
611 */
612#define NIL_RTHCPHYS ((RTHCPHYS)~0U) /** @todo change this to (~(VBOXHCPHYS)0) */
613
614
615/** HC pointer. */
616#ifndef IN_GC
617typedef void * RTHCPTR;
618#else
619typedef RTHCUINTPTR RTHCPTR;
620#endif
621/** Pointer to HC pointer. */
622typedef RTHCPTR *PRTHCPTR;
623/** Pointer to const HC pointer. */
624typedef const RTHCPTR *PCRTHCPTR;
625/** @def NIL_RTHCPTR
626 * NIL HC pointer.
627 */
628#define NIL_RTHCPTR ((RTHCPTR)0)
629
630/** HC ring-3 pointer. */
631#ifdef IN_RING3
632typedef void * RTR3PTR;
633#else
634typedef RTR3UINTPTR RTR3PTR;
635#endif
636/** Pointer to HC ring-3 pointer. */
637typedef RTR3PTR *PRTR3PTR;
638/** Pointer to const HC ring-3 pointer. */
639typedef const RTR3PTR *PCRTR3PTR;
640/** @def NIL_RTR3PTR
641 * NIL HC ring-3 pointer.
642 */
643#define NIL_RTR3PTR ((RTR3PTR)0)
644
645/** HC ring-0 pointer. */
646#ifdef IN_RING0
647typedef void * RTR0PTR;
648#else
649typedef RTR0UINTPTR RTR0PTR;
650#endif
651/** Pointer to HC ring-0 pointer. */
652typedef RTR0PTR *PRTR0PTR;
653/** Pointer to const HC ring-0 pointer. */
654typedef const RTR0PTR *PCRTR0PTR;
655/** @def NIL_RTR0PTR
656 * NIL HC ring-0 pointer.
657 */
658#define NIL_RTR0PTR ((RTR0PTR)0)
659
660
661/** Unsigned integer register in the host context. */
662#if HC_ARCH_BITS == 32
663typedef uint32_t RTHCUINTREG;
664#elif HC_ARCH_BITS == 64
665typedef uint64_t RTHCUINTREG;
666#else
667# error "Unsupported HC_ARCH_BITS!"
668#endif
669/** Pointer to an unsigned integer register in the host context. */
670typedef RTHCUINTREG *PRTHCUINTREG;
671/** Pointer to a const unsigned integer register in the host context. */
672typedef const RTHCUINTREG *PCRTHCUINTREG;
673
674/** Unsigned integer register in the host ring-3 context. */
675#if R3_ARCH_BITS == 32
676typedef uint32_t RTR3UINTREG;
677#elif R3_ARCH_BITS == 64
678typedef uint64_t RTR3UINTREG;
679#else
680# error "Unsupported R3_ARCH_BITS!"
681#endif
682/** Pointer to an unsigned integer register in the host ring-3 context. */
683typedef RTR3UINTREG *PRTR3UINTREG;
684/** Pointer to a const unsigned integer register in the host ring-3 context. */
685typedef const RTR3UINTREG *PCRTR3UINTREG;
686
687/** Unsigned integer register in the host ring-3 context. */
688#if R0_ARCH_BITS == 32
689typedef uint32_t RTR0UINTREG;
690#elif R0_ARCH_BITS == 64
691typedef uint64_t RTR0UINTREG;
692#else
693# error "Unsupported R3_ARCH_BITS!"
694#endif
695/** Pointer to an unsigned integer register in the host ring-3 context. */
696typedef RTR0UINTREG *PRTR0UINTREG;
697/** Pointer to a const unsigned integer register in the host ring-3 context. */
698typedef const RTR0UINTREG *PCRTR0UINTREG;
699
700/** @} */
701
702
703/** @defgroup grp_rt_types_gc Guest Context Basic Types
704 * @ingroup grp_rt_types
705 * @{
706 */
707
708/** Natural signed integer in the GC. */
709#if GC_ARCH_BITS == 32
710typedef int32_t RTGCINT;
711#elif GC_ARCH_BITS == 64
712typedef int64_t RTGCINT;
713#endif
714/** Pointer to natural signed interger in GC. */
715typedef RTGCINT *PRTGCINT;
716/** Pointer to const natural signed interger in GC. */
717typedef const RTGCINT *PCRTGCINT;
718
719/** Natural unsigned integer in the GC. */
720#if GC_ARCH_BITS == 32
721typedef uint32_t RTGCUINT;
722#elif GC_ARCH_BITS == 64
723typedef uint64_t RTGCUINT;
724#endif
725/** Pointer to natural unsigned integer in GC. */
726typedef RTGCUINT *PRTGCUINT;
727/** Pointer to const natural unsigned integer in GC. */
728typedef const RTGCUINT *PCRTGCUINT;
729
730/** Signed integer which can contain a GC pointer. */
731#if GC_ARCH_BITS == 32
732typedef int32_t RTGCINTPTR;
733#elif GC_ARCH_BITS == 64
734typedef int64_t RTGCINTPTR;
735#endif
736/** Pointer to signed interger which can contain a GC pointer. */
737typedef RTGCINTPTR *PRTGCINTPTR;
738/** Pointer to const signed interger which can contain a GC pointer. */
739typedef const RTGCINTPTR *PCRTGCINTPTR;
740
741/** Unsigned integer which can contain a GC pointer. */
742#if GC_ARCH_BITS == 32
743typedef uint32_t RTGCUINTPTR;
744#elif GC_ARCH_BITS == 64
745typedef uint64_t RTGCUINTPTR;
746#else
747# error Unsupported GC_ARCH_BITS value.
748#endif
749/** Pointer to unsigned interger which can contain a GC pointer. */
750typedef RTGCUINTPTR *PRTGCUINTPTR;
751/** Pointer to unsigned interger which can contain a GC pointer. */
752typedef const RTGCUINTPTR *PCRTGCUINTPTR;
753
754/** Unsigned integer which can contain a 32 bits GC pointer. */
755typedef uint32_t RTGCUINTPTR32;
756/** Pointer to unsigned interger which can contain a 32 bits GC pointer. */
757typedef RTGCUINTPTR32 *PRTGCUINTPTR32;
758/** Pointer to unsigned interger which can contain a 32 bits GC pointer. */
759typedef const RTGCUINTPTR32 *PCRTGCUINTPTR32;
760
761/** Unsigned integer which can contain a 64 bits GC pointer. */
762typedef uint64_t RTGCUINTPTR64;
763/** Pointer to unsigned interger which can contain a 32 bits GC pointer. */
764typedef RTGCUINTPTR64 *PRTGCUINTPTR64;
765/** Pointer to unsigned interger which can contain a 32 bits GC pointer. */
766typedef const RTGCUINTPTR64 *PCRTGCUINTPTR64;
767
768/** Guest Physical Memory Address.*/
769typedef uint64_t RTGCPHYS;
770/** Pointer to Guest Physical Memory Address. */
771typedef RTGCPHYS *PRTGCPHYS;
772/** Pointer to const Guest Physical Memory Address. */
773typedef const RTGCPHYS *PCRTGCPHYS;
774/** @def NIL_RTGCPHYS
775 * NIL GC Physical Address.
776 * NIL_RTGCPHYS is used to signal an invalid physical address, similar
777 * to the NULL pointer. Note that this value may actually be valid in
778 * some contexts.
779 */
780#define NIL_RTGCPHYS (~(RTGCPHYS)0U)
781
782
783/** Guest Physical Memory Address; limited to 32 bits.*/
784typedef uint32_t RTGCPHYS32;
785/** Pointer to Guest Physical Memory Address. */
786typedef RTGCPHYS32 *PRTGCPHYS32;
787/** Pointer to const Guest Physical Memory Address. */
788typedef const RTGCPHYS32 *PCRTGCPHYS32;
789/** @def NIL_RTGCPHYS32
790 * NIL GC Physical Address.
791 * NIL_RTGCPHYS32 is used to signal an invalid physical address, similar
792 * to the NULL pointer. Note that this value may actually be valid in
793 * some contexts.
794 */
795#define NIL_RTGCPHYS32 (~(RTGCPHYS32)0)
796
797
798/** Guest Physical Memory Address; limited to 64 bits.*/
799typedef uint64_t RTGCPHYS64;
800/** Pointer to Guest Physical Memory Address. */
801typedef RTGCPHYS64 *PRTGCPHYS64;
802/** Pointer to const Guest Physical Memory Address. */
803typedef const RTGCPHYS64 *PCRTGCPHYS64;
804/** @def NIL_RTGCPHYS64
805 * NIL GC Physical Address.
806 * NIL_RTGCPHYS64 is used to signal an invalid physical address, similar
807 * to the NULL pointer. Note that this value may actually be valid in
808 * some contexts.
809 */
810#define NIL_RTGCPHYS64 (~(RTGCPHYS64)0)
811
812/** Guest context pointer, 32 bits.
813 * Keep in mind that this type is an unsigned integer in
814 * HC and void pointer in GC.
815 */
816typedef RTGCUINTPTR32 RTGCPTR32;
817/** Pointer to a guest context pointer. */
818typedef RTGCPTR32 *PRTGCPTR32;
819/** Pointer to a const guest context pointer. */
820typedef const RTGCPTR32 *PCRTGCPTR32;
821/** @def NIL_RTGCPTR32
822 * NIL GC pointer.
823 */
824#define NIL_RTGCPTR32 ((RTGCPTR32)0)
825
826/** Guest context pointer, 64 bits.
827 */
828typedef RTGCUINTPTR64 RTGCPTR64;
829/** Pointer to a guest context pointer. */
830typedef RTGCPTR64 *PRTGCPTR64;
831/** Pointer to a const guest context pointer. */
832typedef const RTGCPTR64 *PCRTGCPTR64;
833/** @def NIL_RTGCPTR64
834 * NIL GC pointer.
835 */
836#define NIL_RTGCPTR64 ((RTGCPTR64)0)
837
838/** Guest context pointer.
839 * Keep in mind that this type is an unsigned integer in
840 * HC and void pointer in GC.
841 */
842#if GC_ARCH_BITS == 64
843typedef RTGCPTR64 RTGCPTR;
844/** Pointer to a guest context pointer. */
845typedef PRTGCPTR64 PRTGCPTR;
846/** Pointer to a const guest context pointer. */
847typedef PCRTGCPTR64 PCRTGCPTR;
848/** @def NIL_RTGCPTR
849 * NIL GC pointer.
850 */
851#define NIL_RTGCPTR NIL_RTGCPTR64
852#elif GC_ARCH_BITS == 32
853typedef RTGCPTR32 RTGCPTR;
854/** Pointer to a guest context pointer. */
855typedef PRTGCPTR32 PRTGCPTR;
856/** Pointer to a const guest context pointer. */
857typedef PCRTGCPTR32 PCRTGCPTR;
858/** @def NIL_RTGCPTR
859 * NIL GC pointer.
860 */
861#define NIL_RTGCPTR NIL_RTGCPTR32
862#else
863# error "Unsupported GC_ARCH_BITS!"
864#endif
865
866/** Unsigned integer register in the guest context. */
867typedef uint32_t RTGCUINTREG32;
868/** Pointer to an unsigned integer register in the guest context. */
869typedef RTGCUINTREG32 *PRTGCUINTREG32;
870/** Pointer to a const unsigned integer register in the guest context. */
871typedef const RTGCUINTREG32 *PCRTGCUINTREG32;
872
873typedef uint64_t RTGCUINTREG64;
874/** Pointer to an unsigned integer register in the guest context. */
875typedef RTGCUINTREG64 *PRTGCUINTREG64;
876/** Pointer to a const unsigned integer register in the guest context. */
877typedef const RTGCUINTREG64 *PCRTGCUINTREG64;
878
879#if GC_ARCH_BITS == 64
880typedef RTGCUINTREG64 RTGCUINTREG;
881#elif GC_ARCH_BITS == 32
882typedef RTGCUINTREG32 RTGCUINTREG;
883#else
884# error "Unsupported GC_ARCH_BITS!"
885#endif
886/** Pointer to an unsigned integer register in the guest context. */
887typedef RTGCUINTREG *PRTGCUINTREG;
888/** Pointer to a const unsigned integer register in the guest context. */
889typedef const RTGCUINTREG *PCRTGCUINTREG;
890
891/** @} */
892
893/** @defgroup grp_rt_types_rc Raw mode Context Basic Types
894 * @ingroup grp_rt_types
895 * @{
896 */
897
898/** Raw mode context pointer; a 32 bits guest context pointer
899 * Keep in mind that this type is an unsigned integer in
900 * HC and void pointer in GC.
901 */
902#ifdef IN_GC
903typedef void * RTRCPTR;
904#else
905typedef uint32_t RTRCPTR;
906#endif
907/** Pointer to a raw mode context pointer. */
908typedef RTRCPTR *PRTRCPTR;
909/** Pointer to a const raw mode context pointer. */
910typedef const RTRCPTR *PCRTRCPTR;
911/** @def NIL_RTGCPTR
912 * NIL RC pointer.
913 */
914#define NIL_RTRCPTR ((RTRCPTR)0)
915
916/** @def RTRCPTR_MAX
917 * The maximum value a RTRCPTR can have. Mostly used as INVALID value.
918 */
919#define RTRCPTR_MAX ((RTRCPTR)~0)
920
921typedef int32_t RTRCINTPTR;
922typedef uint32_t RTRCUINTPTR;
923
924/** @} */
925
926
927/** @defgroup grp_rt_types_cc Current Context Basic Types
928 * @ingroup grp_rt_types
929 * @{
930 */
931
932/** Current Context Physical Memory Address.*/
933#ifdef IN_GC
934typedef RTGCPHYS RTCCPHYS;
935#else
936typedef RTHCPHYS RTCCPHYS;
937#endif
938/** Pointer to Current Context Physical Memory Address. */
939typedef RTCCPHYS *PRTCCPHYS;
940/** Pointer to const Current Context Physical Memory Address. */
941typedef const RTCCPHYS *PCRTCCPHYS;
942/** @def NIL_RTCCPHYS
943 * NIL CC Physical Address.
944 * NIL_RTCCPHYS is used to signal an invalid physical address, similar
945 * to the NULL pointer.
946 */
947#ifdef IN_GC
948# define NIL_RTCCPHYS NIL_RTGCPHYS
949#else
950# define NIL_RTCCPHYS NIL_RTHCPHYS
951#endif
952
953/** Unsigned integer register in the current 32 bits context. */
954typedef uint32_t RTCCUINTREG32;
955/** Pointer to an unsigned integer register in the current context. */
956typedef RTCCUINTREG32 *PRTCCUINTREG32;
957/** Pointer to a const unsigned integer register in the current context. */
958typedef const RTCCUINTREG32 *PCRTCCUINTREG32;
959
960/** Unsigned integer register in the current 64 bits context. */
961typedef uint64_t RTCCUINTREG64;
962/** Pointer to an unsigned integer register in the current context. */
963typedef RTCCUINTREG64 *PRTCCUINTREG64;
964/** Pointer to a const unsigned integer register in the current context. */
965typedef const RTCCUINTREG64 *PCRTCCUINTREG64;
966
967/** Unsigned integer register in the current context. */
968#if ARCH_BITS == 32
969typedef RTCCUINTREG32 RTCCUINTREG;
970/** Pointer to an unsigned integer register in the current context. */
971typedef PRTCCUINTREG32 PRTCCUINTREG;
972/** Pointer to a const unsigned integer register in the current context. */
973typedef PCRTCCUINTREG32 PCRTCCUINTREG;
974#elif ARCH_BITS == 64
975typedef RTCCUINTREG64 RTCCUINTREG;
976/** Pointer to an unsigned integer register in the current context. */
977typedef PRTCCUINTREG64 PRTCCUINTREG;
978/** Pointer to a const unsigned integer register in the current context. */
979typedef PCRTCCUINTREG64 PCRTCCUINTREG;
980#else
981# error "Unsupported ARCH_BITS!"
982#endif
983
984/** @} */
985
986
987/** File handle. */
988typedef RTUINT RTFILE;
989/** Pointer to file handle. */
990typedef RTFILE *PRTFILE;
991/** Nil file handle. */
992#define NIL_RTFILE (~(RTFILE)0)
993
994/** Loader module handle. */
995typedef R3PTRTYPE(struct RTLDRMODINTERNAL *) RTLDRMOD;
996/** Pointer to a loader module handle. */
997typedef RTLDRMOD *PRTLDRMOD;
998/** Nil loader module handle. */
999#define NIL_RTLDRMOD 0
1000
1001/** Ring-0 memory object handle. */
1002typedef R0PTRTYPE(struct RTR0MEMOBJINTERNAL *) RTR0MEMOBJ;
1003/** Pointer to a Ring-0 memory object handle. */
1004typedef RTR0MEMOBJ *PRTR0MEMOBJ;
1005/** Nil ring-0 memory object handle. */
1006#define NIL_RTR0MEMOBJ 0
1007
1008/** Native thread handle. */
1009typedef RTHCUINTPTR RTNATIVETHREAD;
1010/** Pointer to an native thread handle. */
1011typedef RTNATIVETHREAD *PRTNATIVETHREAD;
1012/** Nil native thread handle. */
1013#define NIL_RTNATIVETHREAD (~(RTNATIVETHREAD)0)
1014
1015/** Process identifier. */
1016typedef uint32_t RTPROCESS;
1017/** Pointer to a process identifier. */
1018typedef RTPROCESS *PRTPROCESS;
1019/** Nil process identifier. */
1020#define NIL_RTPROCESS (~(RTPROCESS)0)
1021
1022/** Process ring-0 handle. */
1023typedef RTR0UINTPTR RTR0PROCESS;
1024/** Pointer to a ring-0 process handle. */
1025typedef RTR0PROCESS *PRTR0PROCESS;
1026/** Nil ring-0 process handle. */
1027#define NIL_RTR0PROCESS (~(RTR0PROCESS)0)
1028
1029/** @typedef RTSEMEVENT
1030 * Event Semaphore handle. */
1031typedef R3R0PTRTYPE(struct RTSEMEVENTINTERNAL *) RTSEMEVENT;
1032/** Pointer to an event semaphore handle. */
1033typedef RTSEMEVENT *PRTSEMEVENT;
1034/** Nil event semaphore handle. */
1035#define NIL_RTSEMEVENT 0
1036
1037/** @typedef RTSEMEVENTMULTI
1038 * Event Multiple Release Semaphore handle. */
1039typedef R3R0PTRTYPE(struct RTSEMEVENTMULTIINTERNAL *) RTSEMEVENTMULTI;
1040/** Pointer to an event multiple release semaphore handle. */
1041typedef RTSEMEVENTMULTI *PRTSEMEVENTMULTI;
1042/** Nil multiple release event semaphore handle. */
1043#define NIL_RTSEMEVENTMULTI 0
1044
1045/** @typedef RTSEMFASTMUTEX
1046 * Fast mutex Semaphore handle. */
1047typedef R3R0PTRTYPE(struct RTSEMFASTMUTEXINTERNAL *) RTSEMFASTMUTEX;
1048/** Pointer to a mutex semaphore handle. */
1049typedef RTSEMFASTMUTEX *PRTSEMFASTMUTEX;
1050/** Nil fast mutex semaphore handle. */
1051#define NIL_RTSEMFASTMUTEX 0
1052
1053/** @typedef RTSEMMUTEX
1054 * Mutex Semaphore handle. */
1055typedef R3R0PTRTYPE(struct RTSEMMUTEXINTERNAL *) RTSEMMUTEX;
1056/** Pointer to a mutex semaphore handle. */
1057typedef RTSEMMUTEX *PRTSEMMUTEX;
1058/** Nil mutex semaphore handle. */
1059#define NIL_RTSEMMUTEX 0
1060
1061/** @typedef RTSEMRW
1062 * Read/Write Semaphore handle. */
1063typedef R3R0PTRTYPE(struct RTSEMRWINTERNAL *) RTSEMRW;
1064/** Pointer to a read/write semaphore handle. */
1065typedef RTSEMRW *PRTSEMRW;
1066/** Nil read/write semaphore handle. */
1067#define NIL_RTSEMRW 0
1068
1069/** Spinlock handle. */
1070typedef R3R0PTRTYPE(struct RTSPINLOCKINTERNAL *) RTSPINLOCK;
1071/** Pointer to a spinlock handle. */
1072typedef RTSPINLOCK *PRTSPINLOCK;
1073/** Nil spinlock handle. */
1074#define NIL_RTSPINLOCK 0
1075
1076/** Socket handle. */
1077typedef int RTSOCKET;
1078/** Pointer to socket handle. */
1079typedef RTSOCKET *PRTSOCKET;
1080/** Nil socket handle. */
1081#define NIL_RTSOCKET (~(RTSOCKET)0)
1082
1083/** Thread handle.*/
1084typedef R3R0PTRTYPE(struct RTTHREADINT *) RTTHREAD;
1085/** Pointer to thread handle. */
1086typedef RTTHREAD *PRTTHREAD;
1087/** Nil thread handle. */
1088#define NIL_RTTHREAD 0
1089
1090/** A TLS index. */
1091typedef int RTTLS;
1092/** Pointer to a TLS index. */
1093typedef RTTLS *PRTTLS;
1094/** Pointer to a const TLS index. */
1095typedef RTTLS const *PCRTTLS;
1096/** NIL TLS index value. */
1097#define NIL_RTTLS (-1)
1098
1099/** Handle to a simple heap. */
1100typedef R3R0PTRTYPE(struct RTHEAPSIMPLEINTERNAL *) RTHEAPSIMPLE;
1101/** Pointer to a handle to a simple heap. */
1102typedef RTHEAPSIMPLE *PRTHEAPSIMPLE;
1103/** NIL simple heap handle. */
1104#define NIL_RTHEAPSIMPLE ((RTHEAPSIMPLE)0)
1105
1106/** Handle to an environment block. */
1107typedef R3PTRTYPE(struct RTENVINTERNAL *) RTENV;
1108/** Pointer to a handle to an environment block. */
1109typedef RTENV *PRTENV;
1110/** NIL simple heap handle. */
1111#define NIL_RTENV ((RTENV)0)
1112
1113/** A CPU identifier.
1114 * @remarks This doesn't have to correspond to the APIC ID (intel/amd). Nor
1115 * does it have to correspond to the bits in the affinity mask, at
1116 * least not until we've sorted out Windows NT. */
1117typedef RTHCUINTPTR RTCPUID;
1118/** Pointer to a CPU identifier. */
1119typedef RTCPUID *PRTCPUID;
1120/** Pointer to a const CPU identifier. */
1121typedef RTCPUID const *PCRTCPUID;
1122/** Nil CPU Id. */
1123#define NIL_RTCPUID ((RTCPUID)~0)
1124
1125/** A CPU set.
1126 * Treat this as an opaque type and always use RTCpuSet* for manupulating it. */
1127typedef uint64_t RTCPUSET;
1128/** Pointer to a CPU set. */
1129typedef RTCPUSET *PRTCPUSET;
1130/** Pointer to a const CPU set. */
1131typedef RTCPUSET const *PCRTCPUSET;
1132
1133/** A handle table handle. */
1134typedef struct RTHANDLETABLEINT *RTHANDLETABLE;
1135/** A pointer to a handle table handle. */
1136typedef RTHANDLETABLE *PRTHANDLETABLE;
1137/** @def NIL_RTHANDLETABLE
1138 * NIL handle table handle. */
1139#define NIL_RTHANDLETABLE ((RTHANDLETABLE)0)
1140
1141/** A handle to a low resolution timer. */
1142typedef struct RTTIMERLRINT *RTTIMERLR;
1143/** A pointer to a low resolution timer handle. */
1144typedef RTTIMERLR *PRTTIMERLR;
1145/** @def NIL_RTTIMERLR
1146 * NIL low resolution timer handle value. */
1147#define NIL_RTTIMERLR ((RTTIMERLR)0)
1148
1149
1150/**
1151 * UUID data type.
1152 */
1153typedef union RTUUID
1154{
1155 /** 8-bit view. */
1156 uint8_t au8[16];
1157 /** 16-bit view. */
1158 uint16_t au16[8];
1159 /** 32-bit view. */
1160 uint32_t au32[4];
1161 /** 64-bit view. */
1162 uint64_t au64[2];
1163 /** The way the UUID is declared by the ext2 guys. */
1164 struct
1165 {
1166 uint32_t u32TimeLow;
1167 uint16_t u16TimeMid;
1168 uint16_t u16TimeHiAndVersion;
1169 uint16_t u16ClockSeq;
1170 uint8_t au8Node[6];
1171 } Gen;
1172 /** @deprecated */
1173 unsigned char aUuid[16];
1174} RTUUID;
1175/** Pointer to UUID data. */
1176typedef RTUUID *PRTUUID;
1177/** Pointer to readonly UUID data. */
1178typedef const RTUUID *PCRTUUID;
1179
1180/**
1181 * UUID string maximum length.
1182 */
1183#define RTUUID_STR_LENGTH 37
1184
1185
1186/** Compression handle. */
1187typedef struct RTZIPCOMP *PRTZIPCOMP;
1188
1189/** Decompressor handle. */
1190typedef struct RTZIPDECOMP *PRTZIPDECOMP;
1191
1192
1193/**
1194 * Unicode Code Point.
1195 */
1196typedef uint32_t RTUNICP;
1197/** Pointer to an Unicode Code Point. */
1198typedef RTUNICP *PRTUNICP;
1199/** Pointer to an Unicode Code Point. */
1200typedef const RTUNICP *PCRTUNICP;
1201
1202
1203/**
1204 * UTF-16 character.
1205 * @remark wchar_t is not usable since it's compiler defined.
1206 * @remark When we use the term character we're not talking about unicode code point, but
1207 * the basic unit of the string encoding. Thus cwc - count of wide chars - means
1208 * count of RTUTF16; cuc - count of unicode chars - means count of RTUNICP;
1209 * and cch means count of the typedef 'char', which is assumed to be an octet.
1210 */
1211typedef uint16_t RTUTF16;
1212/** Pointer to a UTF-16 character. */
1213typedef RTUTF16 *PRTUTF16;
1214/** Pointer to a const UTF-16 character. */
1215typedef const RTUTF16 *PCRTUTF16;
1216
1217
1218/**
1219 * Wait for ever if we have to.
1220 */
1221#define RT_INDEFINITE_WAIT (~0U)
1222
1223
1224/**
1225 * Generic process callback.
1226 *
1227 * @returns VBox status code. Failure will cancel the operation.
1228 * @param uPercentage The percentage of the operation which has been completed.
1229 * @param pvUser The user specified argument.
1230 */
1231typedef DECLCALLBACK(int) FNRTPROGRESS(unsigned uPrecentage, void *pvUser);
1232/** Pointer to a generic progress callback function, FNRTPROCESS(). */
1233typedef FNRTPROGRESS *PFNRTPROGRESS;
1234
1235
1236/**
1237 * Rectangle data type.
1238 */
1239typedef struct RTRECT
1240{
1241 /** left X coordinate. */
1242 int32_t xLeft;
1243 /** top Y coordinate. */
1244 int32_t yTop;
1245 /** right X coordinate. (exclusive) */
1246 int32_t xRight;
1247 /** bottom Y coordinate. (exclusive) */
1248 int32_t yBottom;
1249} RTRECT;
1250/** Pointer to a rectangle. */
1251typedef RTRECT *PRTRECT;
1252/** Pointer to a const rectangle. */
1253typedef const RTRECT *PCRTRECT;
1254
1255
1256/**
1257 * Ethernet MAC address.
1258 *
1259 * The first 24 bits make up the Organisationally Unique Identifier (OUI),
1260 * where the first bit (little endian) indicates multicast (set) / unicast,
1261 * and the second bit indicates locally (set) / global administered. If all
1262 * bits are set, it's a broadcast.
1263 */
1264typedef union RTMAC
1265{
1266 /** @todo add a bitfield view of this stuff. */
1267 /** 8-bit view. */
1268 uint8_t au8[6];
1269 /** 16-bit view. */
1270 uint16_t au16[3];
1271} RTMAC;
1272/** Pointer to a MAC address. */
1273typedef RTMAC *PRTMAC;
1274/** Pointer to a readonly MAC address. */
1275typedef const RTMAC *PCRTMAC;
1276
1277/** @} */
1278
1279#endif
1280
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