VirtualBox

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

Last change on this file since 46385 was 46270, checked in by vboxsync, 12 years ago

iprt/types.h: Extended the pointer unions (RTPTRUNION, RTCPTRUNION, RTVPTRUNION, and RTCVPTRUNION) with some classing C types.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 72.7 KB
Line 
1/** @file
2 * IPRT - Types.
3 */
4
5/*
6 * Copyright (C) 2006-2012 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef ___iprt_types_h
27#define ___iprt_types_h
28
29#include <iprt/cdefs.h>
30#include <iprt/stdint.h>
31
32/*
33 * Include standard C types.
34 */
35#ifndef IPRT_NO_CRT
36
37# if defined(IN_XF86_MODULE) && !defined(NO_ANSIC)
38 /*
39 * Kludge for xfree86 modules: size_t and other types are redefined.
40 */
41RT_C_DECLS_BEGIN
42# include "xf86_ansic.h"
43# undef NULL
44RT_C_DECLS_END
45
46# elif defined(RT_OS_DARWIN) && defined(KERNEL)
47 /*
48 * Kludge for the darwin kernel:
49 * stddef.h is missing IIRC.
50 */
51# ifndef _PTRDIFF_T
52# define _PTRDIFF_T
53 typedef __darwin_ptrdiff_t ptrdiff_t;
54# endif
55# include <sys/types.h>
56
57# elif defined(RT_OS_FREEBSD) && defined(_KERNEL)
58 /*
59 * Kludge for the FreeBSD kernel:
60 * stddef.h and sys/types.h have slightly different offsetof definitions
61 * when compiling in kernel mode. This is just to make GCC shut up.
62 */
63# ifndef _STDDEF_H_
64# undef offsetof
65# endif
66# include <sys/stddef.h>
67# ifndef _SYS_TYPES_H_
68# undef offsetof
69# endif
70# include <sys/types.h>
71# ifndef offsetof
72# error "offsetof is not defined..."
73# endif
74
75# elif defined(RT_OS_FREEBSD) && HC_ARCH_BITS == 64 && defined(RT_ARCH_X86)
76 /*
77 * Kludge for compiling 32-bit code on a 64-bit FreeBSD:
78 * FreeBSD declares uint64_t and int64_t wrong (long unsigned and long int
79 * though they need to be long long unsigned and long long int). These
80 * defines conflict with our decleration in stdint.h. Adding the defines
81 * below omits the definitions in the system header.
82 */
83# include <stddef.h>
84# define _UINT64_T_DECLARED
85# define _INT64_T_DECLARED
86# define _UINTPTR_T_DECLARED
87# define _INTPTR_T_DECLARED
88# include <sys/types.h>
89
90# elif defined(RT_OS_LINUX) && defined(__KERNEL__)
91 /*
92 * Kludge for the linux kernel:
93 * 1. sys/types.h doesn't mix with the kernel.
94 * 2. Starting with 2.6.19, linux/types.h typedefs bool and linux/stddef.h
95 * declares false and true as enum values.
96 * 3. Starting with 2.6.24, linux/types.h typedefs uintptr_t.
97 * We work around these issues here and nowhere else.
98 */
99# include <stddef.h>
100# if defined(__cplusplus)
101 typedef bool _Bool;
102# endif
103# define bool linux_bool
104# define true linux_true
105# define false linux_false
106# define uintptr_t linux_uintptr_t
107# include <linux/version.h>
108# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
109# include <generated/autoconf.h>
110# else
111# ifndef AUTOCONF_INCLUDED
112# include <linux/autoconf.h>
113# endif
114# endif
115# include <linux/compiler.h>
116# if defined(__cplusplus)
117 /*
118 * Starting with 3.3, <linux/compiler-gcc.h> appends 'notrace' (which
119 * expands to __attribute__((no_instrument_function))) to inline,
120 * __inline and __inline__. Revert that.
121 */
122# undef inline
123# define inline inline
124# undef __inline__
125# define __inline__ __inline__
126# undef __inline
127# define __inline __inline
128# endif
129# include <linux/types.h>
130# include <linux/stddef.h>
131 /*
132 * Starting with 3.4, <linux/stddef.h> defines NULL as '((void*)0)' which
133 * does not work for C++ code.
134 */
135# undef NULL
136# undef uintptr_t
137# ifdef __GNUC__
138# if (__GNUC__ * 100 + __GNUC_MINOR__) <= 400
139 /*
140 * <linux/compiler-gcc{3,4}.h> does
141 * #define __inline__ __inline__ __attribute__((always_inline))
142 * in some older Linux kernels. Forcing inlining will fail for some RTStrA*
143 * functions with gcc <= 4.0 due to passing variable argument lists.
144 */
145# undef __inline__
146# define __inline__ __inline__
147# endif
148# endif
149# undef false
150# undef true
151# undef bool
152# else
153# include <stddef.h>
154# include <sys/types.h>
155# endif
156
157
158/* Define any types missing from sys/types.h on windows. */
159# ifdef _MSC_VER
160# undef ssize_t
161 typedef intptr_t ssize_t;
162# endif
163
164#else /* no crt */
165# include <iprt/nocrt/compiler/compiler.h>
166#endif /* no crt */
167
168/** @def NULL
169 * NULL pointer.
170 */
171#ifndef NULL
172# ifdef __cplusplus
173# define NULL 0
174# else
175# define NULL ((void*)0)
176# endif
177#endif
178
179
180
181/** @defgroup grp_rt_types IPRT Base Types
182 * @{
183 */
184
185/* define wchar_t, we don't wanna include all the wcsstuff to get this. */
186#ifdef _MSC_VER
187# ifndef _WCHAR_T_DEFINED
188 typedef unsigned short wchar_t;
189# define _WCHAR_T_DEFINED
190# endif
191#endif
192#ifdef __GNUC__
193/** @todo wchar_t on GNUC */
194#endif
195
196/*
197 * C doesn't have bool.
198 */
199#ifndef __cplusplus
200# if defined(__GNUC__)
201# if defined(RT_OS_LINUX) && __GNUC__ < 3
202typedef uint8_t bool;
203# elif defined(RT_OS_FREEBSD)
204# ifndef __bool_true_false_are_defined
205typedef _Bool bool;
206# endif
207# else
208# if (defined(RT_OS_DARWIN) || defined(RT_OS_HAIKU)) && defined(_STDBOOL_H)
209# undef bool
210# endif
211typedef _Bool bool;
212# endif
213# else
214typedef unsigned char bool;
215# endif
216# ifndef true
217# define true (1)
218# endif
219# ifndef false
220# define false (0)
221# endif
222#endif
223
224/**
225 * 128-bit unsigned integer.
226 */
227#if defined(__GNUC__) && defined(RT_ARCH_AMD64)
228typedef __uint128_t uint128_t;
229#else
230typedef struct uint128_s
231{
232# ifdef RT_BIG_ENDIAN
233 uint64_t Hi;
234 uint64_t Lo;
235# else
236 uint64_t Lo;
237 uint64_t Hi;
238# endif
239} uint128_t;
240#endif
241
242
243/**
244 * 128-bit signed integer.
245 */
246#if defined(__GNUC__) && defined(RT_ARCH_AMD64)
247typedef __int128_t int128_t;
248#else
249typedef struct int128_s
250{
251# ifdef RT_BIG_ENDIAN
252 int64_t Hi;
253 uint64_t Lo;
254# else
255 uint64_t Lo;
256 int64_t Hi;
257# endif
258} int128_t;
259#endif
260
261
262/**
263 * 16-bit unsigned integer union.
264 */
265typedef union RTUINT16U
266{
267 /** natural view. */
268 uint16_t u;
269
270 /** 16-bit view. */
271 uint16_t au16[1];
272 /** 8-bit view. */
273 uint8_t au8[2];
274 /** 16-bit hi/lo view. */
275 struct
276 {
277#ifdef RT_BIG_ENDIAN
278 uint8_t Hi;
279 uint8_t Lo;
280#else
281 uint8_t Lo;
282 uint8_t Hi;
283#endif
284 } s;
285} RTUINT16U;
286/** Pointer to a 16-bit unsigned integer union. */
287typedef RTUINT16U *PRTUINT16U;
288/** Pointer to a const 32-bit unsigned integer union. */
289typedef const RTUINT16U *PCRTUINT16U;
290
291
292/**
293 * 32-bit unsigned integer union.
294 */
295typedef union RTUINT32U
296{
297 /** natural view. */
298 uint32_t u;
299 /** Hi/Low view. */
300 struct
301 {
302#ifdef RT_BIG_ENDIAN
303 uint16_t Hi;
304 uint16_t Lo;
305#else
306 uint16_t Lo;
307 uint16_t Hi;
308#endif
309 } s;
310 /** Word view. */
311 struct
312 {
313#ifdef RT_BIG_ENDIAN
314 uint16_t w1;
315 uint16_t w0;
316#else
317 uint16_t w0;
318 uint16_t w1;
319#endif
320 } Words;
321
322 /** 32-bit view. */
323 uint32_t au32[1];
324 /** 16-bit view. */
325 uint16_t au16[2];
326 /** 8-bit view. */
327 uint8_t au8[4];
328} RTUINT32U;
329/** Pointer to a 32-bit unsigned integer union. */
330typedef RTUINT32U *PRTUINT32U;
331/** Pointer to a const 32-bit unsigned integer union. */
332typedef const RTUINT32U *PCRTUINT32U;
333
334
335/**
336 * 64-bit unsigned integer union.
337 */
338typedef union RTUINT64U
339{
340 /** Natural view. */
341 uint64_t u;
342 /** Hi/Low view. */
343 struct
344 {
345#ifdef RT_BIG_ENDIAN
346 uint32_t Hi;
347 uint32_t Lo;
348#else
349 uint32_t Lo;
350 uint32_t Hi;
351#endif
352 } s;
353 /** Double-Word view. */
354 struct
355 {
356#ifdef RT_BIG_ENDIAN
357 uint32_t dw1;
358 uint32_t dw0;
359#else
360 uint32_t dw0;
361 uint32_t dw1;
362#endif
363 } DWords;
364 /** Word view. */
365 struct
366 {
367#ifdef RT_BIG_ENDIAN
368 uint16_t w3;
369 uint16_t w2;
370 uint16_t w1;
371 uint16_t w0;
372#else
373 uint16_t w0;
374 uint16_t w1;
375 uint16_t w2;
376 uint16_t w3;
377#endif
378 } Words;
379
380 /** 64-bit view. */
381 uint64_t au64[1];
382 /** 32-bit view. */
383 uint32_t au32[2];
384 /** 16-bit view. */
385 uint16_t au16[4];
386 /** 8-bit view. */
387 uint8_t au8[8];
388} RTUINT64U;
389/** Pointer to a 64-bit unsigned integer union. */
390typedef RTUINT64U *PRTUINT64U;
391/** Pointer to a const 64-bit unsigned integer union. */
392typedef const RTUINT64U *PCRTUINT64U;
393
394
395/**
396 * 128-bit unsigned integer union.
397 */
398#pragma pack(1)
399typedef union RTUINT128U
400{
401 /** Natural view.
402 * WARNING! This member depends on the compiler supporting 128-bit stuff. */
403 uint128_t u;
404 /** Hi/Low view. */
405 struct
406 {
407#ifdef RT_BIG_ENDIAN
408 uint64_t Hi;
409 uint64_t Lo;
410#else
411 uint64_t Lo;
412 uint64_t Hi;
413#endif
414 } s;
415 /** Quad-Word view. */
416 struct
417 {
418#ifdef RT_BIG_ENDIAN
419 uint64_t qw1;
420 uint64_t qw0;
421#else
422 uint64_t qw0;
423 uint64_t qw1;
424#endif
425 } QWords;
426 /** Double-Word view. */
427 struct
428 {
429#ifdef RT_BIG_ENDIAN
430 uint32_t dw3;
431 uint32_t dw2;
432 uint32_t dw1;
433 uint32_t dw0;
434#else
435 uint32_t dw0;
436 uint32_t dw1;
437 uint32_t dw2;
438 uint32_t dw3;
439#endif
440 } DWords;
441 /** Word view. */
442 struct
443 {
444#ifdef RT_BIG_ENDIAN
445 uint16_t w7;
446 uint16_t w6;
447 uint16_t w5;
448 uint16_t w4;
449 uint16_t w3;
450 uint16_t w2;
451 uint16_t w1;
452 uint16_t w0;
453#else
454 uint16_t w0;
455 uint16_t w1;
456 uint16_t w2;
457 uint16_t w3;
458 uint16_t w4;
459 uint16_t w5;
460 uint16_t w6;
461 uint16_t w7;
462#endif
463 } Words;
464
465 /** 64-bit view. */
466 uint64_t au64[2];
467 /** 32-bit view. */
468 uint32_t au32[4];
469 /** 16-bit view. */
470 uint16_t au16[8];
471 /** 8-bit view. */
472 uint8_t au8[16];
473} RTUINT128U;
474#pragma pack()
475/** Pointer to a 64-bit unsigned integer union. */
476typedef RTUINT128U *PRTUINT128U;
477/** Pointer to a const 64-bit unsigned integer union. */
478typedef const RTUINT128U *PCRTUINT128U;
479
480
481/**
482 * Double precision floating point format (64-bit).
483 */
484typedef union RTFLOAT64U
485{
486#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
487 /** Double view. */
488 double rd;
489#endif
490 /** Format using regular bitfields. */
491 struct
492 {
493# ifdef RT_BIG_ENDIAN
494 /** The sign indicator. */
495 uint32_t fSign : 1;
496 /** The exponent (offseted by 1023). */
497 uint32_t uExponent : 11;
498 /** The fraction, bits 32 thru 51. */
499 uint32_t u20FractionHigh : 20;
500 /** The fraction, bits 0 thru 31. */
501 uint32_t u32FractionLow;
502# else
503 /** The fraction, bits 0 thru 31. */
504 uint32_t u32FractionLow;
505 /** The fraction, bits 32 thru 51. */
506 uint32_t u20FractionHigh : 20;
507 /** The exponent (offseted by 1023). */
508 uint32_t uExponent : 11;
509 /** The sign indicator. */
510 uint32_t fSign : 1;
511# endif
512 } s;
513
514#ifdef RT_COMPILER_GROKS_64BIT_BITFIELDS
515 /** Format using 64-bit bitfields. */
516 RT_GCC_EXTENSION struct
517 {
518# ifdef RT_BIG_ENDIAN
519 /** The sign indicator. */
520 RT_GCC_EXTENSION uint64_t fSign : 1;
521 /** The exponent (offseted by 1023). */
522 RT_GCC_EXTENSION uint64_t uExponent : 11;
523 /** The fraction. */
524 RT_GCC_EXTENSION uint64_t uFraction : 52;
525# else
526 /** The fraction. */
527 RT_GCC_EXTENSION uint64_t uFraction : 52;
528 /** The exponent (offseted by 1023). */
529 RT_GCC_EXTENSION uint64_t uExponent : 11;
530 /** The sign indicator. */
531 RT_GCC_EXTENSION uint64_t fSign : 1;
532# endif
533 } s64;
534#endif
535
536 /** 64-bit view. */
537 uint64_t au64[1];
538 /** 32-bit view. */
539 uint32_t au32[2];
540 /** 16-bit view. */
541 uint16_t au16[4];
542 /** 8-bit view. */
543 uint8_t au8[8];
544} RTFLOAT64U;
545/** Pointer to a double precision floating point format union. */
546typedef RTFLOAT64U *PRTFLOAT64U;
547/** Pointer to a const double precision floating point format union. */
548typedef const RTFLOAT64U *PCRTFLOAT64U;
549
550
551/**
552 * Extended Double precision floating point format (80-bit).
553 */
554#pragma pack(1)
555typedef union RTFLOAT80U
556{
557 /** Format using bitfields. */
558 RT_GCC_EXTENSION struct
559 {
560# ifdef RT_BIG_ENDIAN
561 /** The sign indicator. */
562 RT_GCC_EXTENSION uint16_t fSign : 1;
563 /** The exponent (offseted by 16383). */
564 RT_GCC_EXTENSION uint16_t uExponent : 15;
565 /** The mantissa. */
566 uint64_t u64Mantissa;
567# else
568 /** The mantissa. */
569 uint64_t u64Mantissa;
570 /** The exponent (offseted by 16383). */
571 RT_GCC_EXTENSION uint16_t uExponent : 15;
572 /** The sign indicator. */
573 RT_GCC_EXTENSION uint16_t fSign : 1;
574# endif
575 } s;
576
577 /** 64-bit view. */
578 uint64_t au64[1];
579 /** 32-bit view. */
580 uint32_t au32[2];
581 /** 16-bit view. */
582 uint16_t au16[5];
583 /** 8-bit view. */
584 uint8_t au8[10];
585} RTFLOAT80U;
586#pragma pack()
587/** Pointer to a extended precision floating point format union. */
588typedef RTFLOAT80U *PRTFLOAT80U;
589/** Pointer to a const extended precision floating point format union. */
590typedef const RTFLOAT80U *PCRTFLOAT80U;
591
592
593/**
594 * A variant of RTFLOAT80U that may be larger than 80-bits depending on how the
595 * compiler implements long double.
596 */
597#pragma pack(1)
598typedef union RTFLOAT80U2
599{
600#ifdef RT_COMPILER_WITH_80BIT_LONG_DOUBLE
601 /** Long double view. */
602 long double lrd;
603#endif
604 /** Format using bitfields. */
605 RT_GCC_EXTENSION struct
606 {
607#ifdef RT_BIG_ENDIAN
608 /** The sign indicator. */
609 RT_GCC_EXTENSION uint16_t fSign : 1;
610 /** The exponent (offseted by 16383). */
611 RT_GCC_EXTENSION uint16_t uExponent : 15;
612 /** The mantissa. */
613 uint64_t u64Mantissa;
614#else
615 /** The mantissa. */
616 uint64_t u64Mantissa;
617 /** The exponent (offseted by 16383). */
618 RT_GCC_EXTENSION uint16_t uExponent : 15;
619 /** The sign indicator. */
620 RT_GCC_EXTENSION uint16_t fSign : 1;
621#endif
622 } s;
623
624 /** Bitfield exposing the J bit and the fraction. */
625 RT_GCC_EXTENSION struct
626 {
627#ifdef RT_BIG_ENDIAN
628 /** The sign indicator. */
629 RT_GCC_EXTENSION uint16_t fSign : 1;
630 /** The exponent (offseted by 16383). */
631 RT_GCC_EXTENSION uint16_t uExponent : 15;
632 /** The J bit, aka the integer bit. */
633 uint32_t fInteger;
634 /** The fraction, bits 32 thru 62. */
635 uint32_t u31FractionHigh : 31;
636 /** The fraction, bits 0 thru 31. */
637 uint32_t u32FractionLow : 32;
638#else
639 /** The fraction, bits 0 thru 31. */
640 uint32_t u32FractionLow : 32;
641 /** The fraction, bits 32 thru 62. */
642 uint32_t u31FractionHigh : 31;
643 /** The J bit, aka the integer bit. */
644 uint32_t fInteger;
645 /** The exponent (offseted by 16383). */
646 RT_GCC_EXTENSION uint16_t uExponent : 15;
647 /** The sign indicator. */
648 RT_GCC_EXTENSION uint16_t fSign : 1;
649#endif
650 } sj;
651
652#ifdef RT_COMPILER_GROKS_64BIT_BITFIELDS
653 /** 64-bit bitfields exposing the J bit and the fraction. */
654 RT_GCC_EXTENSION struct
655 {
656# ifdef RT_BIG_ENDIAN
657 /** The sign indicator. */
658 RT_GCC_EXTENSION uint16_t fSign : 1;
659 /** The exponent (offseted by 16383). */
660 RT_GCC_EXTENSION uint16_t uExponent : 15;
661 /** The J bit, aka the integer bit. */
662 RT_GCC_EXTENSION uint64_t fInteger : 1;
663 /** The fraction. */
664 RT_GCC_EXTENSION uint64_t u63Fraction : 63;
665# else
666 /** The fraction. */
667 RT_GCC_EXTENSION uint64_t u63Fraction : 63;
668 /** The J bit, aka the integer bit. */
669 RT_GCC_EXTENSION uint64_t fInteger : 1;
670 /** The exponent (offseted by 16383). */
671 RT_GCC_EXTENSION uint16_t uExponent : 15;
672 /** The sign indicator. */
673 RT_GCC_EXTENSION uint16_t fSign : 1;
674# endif
675 } sj64;
676#endif
677
678 /** 64-bit view. */
679 uint64_t au64[1];
680 /** 32-bit view. */
681 uint32_t au32[2];
682 /** 16-bit view. */
683 uint16_t au16[5];
684 /** 8-bit view. */
685 uint8_t au8[10];
686} RTFLOAT80U2;
687#pragma pack()
688/** Pointer to a extended precision floating point format union, 2nd
689 * variant. */
690typedef RTFLOAT80U2 *PRTFLOAT80U2;
691/** Pointer to a const extended precision floating point format union, 2nd
692 * variant. */
693typedef const RTFLOAT80U2 *PCRTFLOAT80U2;
694
695
696/** Generic function type.
697 * @see PFNRT
698 */
699typedef DECLCALLBACK(void) FNRT(void);
700
701/** Generic function pointer.
702 * With -pedantic, gcc-4 complains when casting a function to a data object, for
703 * example:
704 *
705 * @code
706 * void foo(void)
707 * {
708 * }
709 *
710 * void *bar = (void *)foo;
711 * @endcode
712 *
713 * The compiler would warn with "ISO C++ forbids casting between
714 * pointer-to-function and pointer-to-object". The purpose of this warning is
715 * not to bother the programmer but to point out that he is probably doing
716 * something dangerous, assigning a pointer to executable code to a data object.
717 */
718typedef FNRT *PFNRT;
719
720/** Millisecond interval. */
721typedef uint32_t RTMSINTERVAL;
722/** Pointer to a millisecond interval. */
723typedef RTMSINTERVAL *PRTMSINTERVAL;
724/** Pointer to a const millisecond interval. */
725typedef const RTMSINTERVAL *PCRTMSINTERVAL;
726
727/** Pointer to a time spec structure. */
728typedef struct RTTIMESPEC *PRTTIMESPEC;
729/** Pointer to a const time spec structure. */
730typedef const struct RTTIMESPEC *PCRTTIMESPEC;
731
732/**
733 * Generic pointer union.
734 */
735typedef union RTPTRUNION
736{
737 /** Pointer into the void... */
738 void *pv;
739 /** Pointer to char value. */
740 char *pch;
741 /** Pointer to char value. */
742 unsigned char *puch;
743 /** Pointer to a int value. */
744 int *pi;
745 /** Pointer to a unsigned int value. */
746 unsigned int *pu;
747 /** Pointer to a long value. */
748 long *pl;
749 /** Pointer to a long value. */
750 unsigned long *pul;
751 /** Pointer to a 8-bit unsigned value. */
752 uint8_t *pu8;
753 /** Pointer to a 16-bit unsigned value. */
754 uint16_t *pu16;
755 /** Pointer to a 32-bit unsigned value. */
756 uint32_t *pu32;
757 /** Pointer to a 64-bit unsigned value. */
758 uint64_t *pu64;
759} RTPTRUNION;
760/** Pointer to a pointer union. */
761typedef RTPTRUNION *PRTPTRUNION;
762
763/**
764 * Generic const pointer union.
765 */
766typedef union RTCPTRUNION
767{
768 /** Pointer into the void... */
769 void const *pv;
770 /** Pointer to char value. */
771 char const *pch;
772 /** Pointer to char value. */
773 unsigned char const *puch;
774 /** Pointer to a int value. */
775 int const *pi;
776 /** Pointer to a unsigned int value. */
777 unsigned int const *pu;
778 /** Pointer to a long value. */
779 long const *pl;
780 /** Pointer to a long value. */
781 unsigned long const *pul;
782 /** Pointer to a 8-bit unsigned value. */
783 uint8_t const *pu8;
784 /** Pointer to a 16-bit unsigned value. */
785 uint16_t const *pu16;
786 /** Pointer to a 32-bit unsigned value. */
787 uint32_t const *pu32;
788 /** Pointer to a 64-bit unsigned value. */
789 uint64_t const *pu64;
790} RTCPTRUNION;
791/** Pointer to a const pointer union. */
792typedef RTCPTRUNION *PRTCPTRUNION;
793
794/**
795 * Generic volatile pointer union.
796 */
797typedef union RTVPTRUNION
798{
799 /** Pointer into the void... */
800 void volatile *pv;
801 /** Pointer to char value. */
802 char volatile *pch;
803 /** Pointer to char value. */
804 unsigned char volatile *puch;
805 /** Pointer to a int value. */
806 int volatile *pi;
807 /** Pointer to a unsigned int value. */
808 unsigned int volatile *pu;
809 /** Pointer to a long value. */
810 long volatile *pl;
811 /** Pointer to a long value. */
812 unsigned long volatile *pul;
813 /** Pointer to a 8-bit unsigned value. */
814 uint8_t volatile *pu8;
815 /** Pointer to a 16-bit unsigned value. */
816 uint16_t volatile *pu16;
817 /** Pointer to a 32-bit unsigned value. */
818 uint32_t volatile *pu32;
819 /** Pointer to a 64-bit unsigned value. */
820 uint64_t volatile *pu64;
821} RTVPTRUNION;
822/** Pointer to a const pointer union. */
823typedef RTVPTRUNION *PRTVPTRUNION;
824
825/**
826 * Generic const volatile pointer union.
827 */
828typedef union RTCVPTRUNION
829{
830 /** Pointer into the void... */
831 void const volatile *pv;
832 /** Pointer to char value. */
833 char const volatile *pch;
834 /** Pointer to char value. */
835 unsigned char const volatile *puch;
836 /** Pointer to a int value. */
837 int const volatile *pi;
838 /** Pointer to a unsigned int value. */
839 unsigned int const volatile *pu;
840 /** Pointer to a long value. */
841 long const volatile *pl;
842 /** Pointer to a long value. */
843 unsigned long const volatile *pul;
844 /** Pointer to a 8-bit unsigned value. */
845 uint8_t const volatile *pu8;
846 /** Pointer to a 16-bit unsigned value. */
847 uint16_t const volatile *pu16;
848 /** Pointer to a 32-bit unsigned value. */
849 uint32_t const volatile *pu32;
850 /** Pointer to a 64-bit unsigned value. */
851 uint64_t const volatile *pu64;
852} RTCVPTRUNION;
853/** Pointer to a const pointer union. */
854typedef RTCVPTRUNION *PRTCVPTRUNION;
855
856
857/** @defgroup grp_rt_types_both Common Guest and Host Context Basic Types
858 * @ingroup grp_rt_types
859 * @{
860 */
861
862/** Signed integer which can contain both GC and HC pointers. */
863#if (HC_ARCH_BITS == 32 && GC_ARCH_BITS == 32)
864typedef int32_t RTINTPTR;
865#elif (HC_ARCH_BITS == 64 || GC_ARCH_BITS == 64)
866typedef int64_t RTINTPTR;
867#else
868# error Unsupported HC_ARCH_BITS and/or GC_ARCH_BITS values.
869#endif
870/** Pointer to signed integer which can contain both GC and HC pointers. */
871typedef RTINTPTR *PRTINTPTR;
872/** Pointer const to signed integer which can contain both GC and HC pointers. */
873typedef const RTINTPTR *PCRTINTPTR;
874/** The maximum value the RTINTPTR type can hold. */
875#if (HC_ARCH_BITS == 32 && GC_ARCH_BITS == 32)
876# define RTINTPTR_MAX INT32_MAX
877#elif (HC_ARCH_BITS == 64 || GC_ARCH_BITS == 64)
878# define RTINTPTR_MAX INT64_MAX
879#else
880# error Unsupported HC_ARCH_BITS and/or GC_ARCH_BITS values.
881#endif
882/** The minimum value the RTINTPTR type can hold. */
883#if (HC_ARCH_BITS == 32 && GC_ARCH_BITS == 32)
884# define RTINTPTR_MIN INT32_MIN
885#elif (HC_ARCH_BITS == 64 || GC_ARCH_BITS == 64)
886# define RTINTPTR_MIN INT64_MIN
887#else
888# error Unsupported HC_ARCH_BITS and/or GC_ARCH_BITS values.
889#endif
890
891/** Unsigned integer which can contain both GC and HC pointers. */
892#if (HC_ARCH_BITS == 32 && GC_ARCH_BITS == 32)
893typedef uint32_t RTUINTPTR;
894#elif (HC_ARCH_BITS == 64 || GC_ARCH_BITS == 64)
895typedef uint64_t RTUINTPTR;
896#else
897# error Unsupported HC_ARCH_BITS and/or GC_ARCH_BITS values.
898#endif
899/** Pointer to unsigned integer which can contain both GC and HC pointers. */
900typedef RTUINTPTR *PRTUINTPTR;
901/** Pointer const to unsigned integer which can contain both GC and HC pointers. */
902typedef const RTUINTPTR *PCRTUINTPTR;
903/** The maximum value the RTUINTPTR type can hold. */
904#if (HC_ARCH_BITS == 32 && GC_ARCH_BITS == 32)
905# define RTUINTPTR_MAX UINT32_MAX
906#elif (HC_ARCH_BITS == 64 || GC_ARCH_BITS == 64)
907# define RTUINTPTR_MAX UINT64_MAX
908#else
909# error Unsupported HC_ARCH_BITS and/or GC_ARCH_BITS values.
910#endif
911
912/** Signed integer. */
913typedef int32_t RTINT;
914/** Pointer to signed integer. */
915typedef RTINT *PRTINT;
916/** Pointer to const signed integer. */
917typedef const RTINT *PCRTINT;
918
919/** Unsigned integer. */
920typedef uint32_t RTUINT;
921/** Pointer to unsigned integer. */
922typedef RTUINT *PRTUINT;
923/** Pointer to const unsigned integer. */
924typedef const RTUINT *PCRTUINT;
925
926/** A file offset / size (off_t). */
927typedef int64_t RTFOFF;
928/** Pointer to a file offset / size. */
929typedef RTFOFF *PRTFOFF;
930/** The max value for RTFOFF. */
931#define RTFOFF_MAX INT64_MAX
932/** The min value for RTFOFF. */
933#define RTFOFF_MIN INT64_MIN
934
935/** File mode (see iprt/fs.h). */
936typedef uint32_t RTFMODE;
937/** Pointer to file mode. */
938typedef RTFMODE *PRTFMODE;
939
940/** Device unix number. */
941typedef uint32_t RTDEV;
942/** Pointer to a device unix number. */
943typedef RTDEV *PRTDEV;
944
945/** @name RTDEV Macros
946 * @{ */
947/**
948 * Our makedev macro.
949 * @returns RTDEV
950 * @param uMajor The major device number.
951 * @param uMinor The minor device number.
952 */
953#define RTDEV_MAKE(uMajor, uMinor) ((RTDEV)( ((RTDEV)(uMajor) << 24) | (uMinor & UINT32_C(0x00ffffff)) ))
954/**
955 * Get the major device node number from an RTDEV type.
956 * @returns The major device number of @a uDev
957 * @param uDev The device number.
958 */
959#define RTDEV_MAJOR(uDev) ((uDev) >> 24)
960/**
961 * Get the minor device node number from an RTDEV type.
962 * @returns The minor device number of @a uDev
963 * @param uDev The device number.
964 */
965#define RTDEV_MINOR(uDev) ((uDev) & UINT32_C(0x00ffffff))
966/** @} */
967
968/** i-node number. */
969typedef uint64_t RTINODE;
970/** Pointer to a i-node number. */
971typedef RTINODE *PRTINODE;
972
973/** User id. */
974typedef uint32_t RTUID;
975/** Pointer to a user id. */
976typedef RTUID *PRTUID;
977/** NIL user id.
978 * @todo check this for portability! */
979#define NIL_RTUID (~(RTUID)0)
980
981/** Group id. */
982typedef uint32_t RTGID;
983/** Pointer to a group id. */
984typedef RTGID *PRTGID;
985/** NIL group id.
986 * @todo check this for portability! */
987#define NIL_RTGID (~(RTGID)0)
988
989/** I/O Port. */
990typedef uint16_t RTIOPORT;
991/** Pointer to I/O Port. */
992typedef RTIOPORT *PRTIOPORT;
993/** Pointer to const I/O Port. */
994typedef const RTIOPORT *PCRTIOPORT;
995
996/** Selector. */
997typedef uint16_t RTSEL;
998/** Pointer to selector. */
999typedef RTSEL *PRTSEL;
1000/** Pointer to const selector. */
1001typedef const RTSEL *PCRTSEL;
1002/** Max selector value. */
1003#define RTSEL_MAX UINT16_MAX
1004
1005/** Far 16-bit pointer. */
1006#pragma pack(1)
1007typedef struct RTFAR16
1008{
1009 uint16_t off;
1010 RTSEL sel;
1011} RTFAR16;
1012#pragma pack()
1013/** Pointer to Far 16-bit pointer. */
1014typedef RTFAR16 *PRTFAR16;
1015/** Pointer to const Far 16-bit pointer. */
1016typedef const RTFAR16 *PCRTFAR16;
1017
1018/** Far 32-bit pointer. */
1019#pragma pack(1)
1020typedef struct RTFAR32
1021{
1022 uint32_t off;
1023 RTSEL sel;
1024} RTFAR32;
1025#pragma pack()
1026/** Pointer to Far 32-bit pointer. */
1027typedef RTFAR32 *PRTFAR32;
1028/** Pointer to const Far 32-bit pointer. */
1029typedef const RTFAR32 *PCRTFAR32;
1030
1031/** Far 64-bit pointer. */
1032#pragma pack(1)
1033typedef struct RTFAR64
1034{
1035 uint64_t off;
1036 RTSEL sel;
1037} RTFAR64;
1038#pragma pack()
1039/** Pointer to Far 64-bit pointer. */
1040typedef RTFAR64 *PRTFAR64;
1041/** Pointer to const Far 64-bit pointer. */
1042typedef const RTFAR64 *PCRTFAR64;
1043
1044/** @} */
1045
1046
1047/** @defgroup grp_rt_types_hc Host Context Basic Types
1048 * @ingroup grp_rt_types
1049 * @{
1050 */
1051
1052/** HC Natural signed integer.
1053 * @deprecated silly type. */
1054typedef int32_t RTHCINT;
1055/** Pointer to HC Natural signed integer.
1056 * @deprecated silly type. */
1057typedef RTHCINT *PRTHCINT;
1058/** Pointer to const HC Natural signed integer.
1059 * @deprecated silly type. */
1060typedef const RTHCINT *PCRTHCINT;
1061
1062/** HC Natural unsigned integer.
1063 * @deprecated silly type. */
1064typedef uint32_t RTHCUINT;
1065/** Pointer to HC Natural unsigned integer.
1066 * @deprecated silly type. */
1067typedef RTHCUINT *PRTHCUINT;
1068/** Pointer to const HC Natural unsigned integer.
1069 * @deprecated silly type. */
1070typedef const RTHCUINT *PCRTHCUINT;
1071
1072
1073/** Signed integer which can contain a HC pointer. */
1074#if HC_ARCH_BITS == 32
1075typedef int32_t RTHCINTPTR;
1076#elif HC_ARCH_BITS == 64
1077typedef int64_t RTHCINTPTR;
1078#else
1079# error Unsupported HC_ARCH_BITS value.
1080#endif
1081/** Pointer to signed integer which can contain a HC pointer. */
1082typedef RTHCINTPTR *PRTHCINTPTR;
1083/** Pointer to const signed integer which can contain a HC pointer. */
1084typedef const RTHCINTPTR *PCRTHCINTPTR;
1085/** Max RTHCINTPTR value. */
1086#if HC_ARCH_BITS == 32
1087# define RTHCINTPTR_MAX INT32_MAX
1088#else
1089# define RTHCINTPTR_MAX INT64_MAX
1090#endif
1091/** Min RTHCINTPTR value. */
1092#if HC_ARCH_BITS == 32
1093# define RTHCINTPTR_MIN INT32_MIN
1094#else
1095# define RTHCINTPTR_MIN INT64_MIN
1096#endif
1097
1098/** Signed integer which can contain a HC ring-3 pointer. */
1099#if R3_ARCH_BITS == 32
1100typedef int32_t RTR3INTPTR;
1101#elif R3_ARCH_BITS == 64
1102typedef int64_t RTR3INTPTR;
1103#else
1104# error Unsupported R3_ARCH_BITS value.
1105#endif
1106/** Pointer to signed integer which can contain a HC ring-3 pointer. */
1107typedef RTR3INTPTR *PRTR3INTPTR;
1108/** Pointer to const signed integer which can contain a HC ring-3 pointer. */
1109typedef const RTR3INTPTR *PCRTR3INTPTR;
1110/** Max RTR3INTPTR value. */
1111#if R3_ARCH_BITS == 32
1112# define RTR3INTPTR_MAX INT32_MAX
1113#else
1114# define RTR3INTPTR_MAX INT64_MAX
1115#endif
1116/** Min RTR3INTPTR value. */
1117#if R3_ARCH_BITS == 32
1118# define RTR3INTPTR_MIN INT32_MIN
1119#else
1120# define RTR3INTPTR_MIN INT64_MIN
1121#endif
1122
1123/** Signed integer which can contain a HC ring-0 pointer. */
1124#if R0_ARCH_BITS == 32
1125typedef int32_t RTR0INTPTR;
1126#elif R0_ARCH_BITS == 64
1127typedef int64_t RTR0INTPTR;
1128#else
1129# error Unsupported R0_ARCH_BITS value.
1130#endif
1131/** Pointer to signed integer which can contain a HC ring-0 pointer. */
1132typedef RTR0INTPTR *PRTR0INTPTR;
1133/** Pointer to const signed integer which can contain a HC ring-0 pointer. */
1134typedef const RTR0INTPTR *PCRTR0INTPTR;
1135/** Max RTR0INTPTR value. */
1136#if R0_ARCH_BITS == 32
1137# define RTR0INTPTR_MAX INT32_MAX
1138#else
1139# define RTR0INTPTR_MAX INT64_MAX
1140#endif
1141/** Min RTHCINTPTR value. */
1142#if R0_ARCH_BITS == 32
1143# define RTR0INTPTR_MIN INT32_MIN
1144#else
1145# define RTR0INTPTR_MIN INT64_MIN
1146#endif
1147
1148
1149/** Unsigned integer which can contain a HC pointer. */
1150#if HC_ARCH_BITS == 32
1151typedef uint32_t RTHCUINTPTR;
1152#elif HC_ARCH_BITS == 64
1153typedef uint64_t RTHCUINTPTR;
1154#else
1155# error Unsupported HC_ARCH_BITS value.
1156#endif
1157/** Pointer to unsigned integer which can contain a HC pointer. */
1158typedef RTHCUINTPTR *PRTHCUINTPTR;
1159/** Pointer to unsigned integer which can contain a HC pointer. */
1160typedef const RTHCUINTPTR *PCRTHCUINTPTR;
1161/** Max RTHCUINTTPR value. */
1162#if HC_ARCH_BITS == 32
1163# define RTHCUINTPTR_MAX UINT32_MAX
1164#else
1165# define RTHCUINTPTR_MAX UINT64_MAX
1166#endif
1167
1168/** Unsigned integer which can contain a HC ring-3 pointer. */
1169#if R3_ARCH_BITS == 32
1170typedef uint32_t RTR3UINTPTR;
1171#elif R3_ARCH_BITS == 64
1172typedef uint64_t RTR3UINTPTR;
1173#else
1174# error Unsupported R3_ARCH_BITS value.
1175#endif
1176/** Pointer to unsigned integer which can contain a HC ring-3 pointer. */
1177typedef RTR3UINTPTR *PRTR3UINTPTR;
1178/** Pointer to unsigned integer which can contain a HC ring-3 pointer. */
1179typedef const RTR3UINTPTR *PCRTR3UINTPTR;
1180/** Max RTHCUINTTPR value. */
1181#if R3_ARCH_BITS == 32
1182# define RTR3UINTPTR_MAX UINT32_MAX
1183#else
1184# define RTR3UINTPTR_MAX UINT64_MAX
1185#endif
1186
1187/** Unsigned integer which can contain a HC ring-0 pointer. */
1188#if R0_ARCH_BITS == 32
1189typedef uint32_t RTR0UINTPTR;
1190#elif R0_ARCH_BITS == 64
1191typedef uint64_t RTR0UINTPTR;
1192#else
1193# error Unsupported R0_ARCH_BITS value.
1194#endif
1195/** Pointer to unsigned integer which can contain a HC ring-0 pointer. */
1196typedef RTR0UINTPTR *PRTR0UINTPTR;
1197/** Pointer to unsigned integer which can contain a HC ring-0 pointer. */
1198typedef const RTR0UINTPTR *PCRTR0UINTPTR;
1199/** Max RTR0UINTTPR value. */
1200#if HC_ARCH_BITS == 32
1201# define RTR0UINTPTR_MAX UINT32_MAX
1202#else
1203# define RTR0UINTPTR_MAX UINT64_MAX
1204#endif
1205
1206
1207/** Host Physical Memory Address. */
1208typedef uint64_t RTHCPHYS;
1209/** Pointer to Host Physical Memory Address. */
1210typedef RTHCPHYS *PRTHCPHYS;
1211/** Pointer to const Host Physical Memory Address. */
1212typedef const RTHCPHYS *PCRTHCPHYS;
1213/** @def NIL_RTHCPHYS
1214 * NIL HC Physical Address.
1215 * NIL_RTHCPHYS is used to signal an invalid physical address, similar
1216 * to the NULL pointer.
1217 */
1218#define NIL_RTHCPHYS (~(RTHCPHYS)0)
1219/** Max RTHCPHYS value. */
1220#define RTHCPHYS_MAX UINT64_MAX
1221
1222
1223/** HC pointer. */
1224#ifndef IN_RC
1225typedef void * RTHCPTR;
1226#else
1227typedef RTHCUINTPTR RTHCPTR;
1228#endif
1229/** Pointer to HC pointer. */
1230typedef RTHCPTR *PRTHCPTR;
1231/** Pointer to const HC pointer. */
1232typedef const RTHCPTR *PCRTHCPTR;
1233/** @def NIL_RTHCPTR
1234 * NIL HC pointer.
1235 */
1236#define NIL_RTHCPTR ((RTHCPTR)0)
1237/** Max RTHCPTR value. */
1238#define RTHCPTR_MAX ((RTHCPTR)RTHCUINTPTR_MAX)
1239
1240
1241/** HC ring-3 pointer. */
1242#ifdef IN_RING3
1243typedef void * RTR3PTR;
1244#else
1245typedef RTR3UINTPTR RTR3PTR;
1246#endif
1247/** Pointer to HC ring-3 pointer. */
1248typedef RTR3PTR *PRTR3PTR;
1249/** Pointer to const HC ring-3 pointer. */
1250typedef const RTR3PTR *PCRTR3PTR;
1251/** @def NIL_RTR3PTR
1252 * NIL HC ring-3 pointer.
1253 */
1254#ifndef IN_RING3
1255# define NIL_RTR3PTR ((RTR3PTR)0)
1256#else
1257# define NIL_RTR3PTR (NULL)
1258#endif
1259/** Max RTR3PTR value. */
1260#define RTR3PTR_MAX ((RTR3PTR)RTR3UINTPTR_MAX)
1261
1262/** HC ring-0 pointer. */
1263#ifdef IN_RING0
1264typedef void * RTR0PTR;
1265#else
1266typedef RTR0UINTPTR RTR0PTR;
1267#endif
1268/** Pointer to HC ring-0 pointer. */
1269typedef RTR0PTR *PRTR0PTR;
1270/** Pointer to const HC ring-0 pointer. */
1271typedef const RTR0PTR *PCRTR0PTR;
1272/** @def NIL_RTR0PTR
1273 * NIL HC ring-0 pointer.
1274 */
1275#ifndef IN_RING0
1276# define NIL_RTR0PTR ((RTR0PTR)0)
1277#else
1278# define NIL_RTR0PTR (NULL)
1279#endif
1280/** Max RTR3PTR value. */
1281#define RTR0PTR_MAX ((RTR0PTR)RTR0UINTPTR_MAX)
1282
1283
1284/** Unsigned integer register in the host context. */
1285#if HC_ARCH_BITS == 32
1286typedef uint32_t RTHCUINTREG;
1287#elif HC_ARCH_BITS == 64
1288typedef uint64_t RTHCUINTREG;
1289#else
1290# error "Unsupported HC_ARCH_BITS!"
1291#endif
1292/** Pointer to an unsigned integer register in the host context. */
1293typedef RTHCUINTREG *PRTHCUINTREG;
1294/** Pointer to a const unsigned integer register in the host context. */
1295typedef const RTHCUINTREG *PCRTHCUINTREG;
1296
1297/** Unsigned integer register in the host ring-3 context. */
1298#if R3_ARCH_BITS == 32
1299typedef uint32_t RTR3UINTREG;
1300#elif R3_ARCH_BITS == 64
1301typedef uint64_t RTR3UINTREG;
1302#else
1303# error "Unsupported R3_ARCH_BITS!"
1304#endif
1305/** Pointer to an unsigned integer register in the host ring-3 context. */
1306typedef RTR3UINTREG *PRTR3UINTREG;
1307/** Pointer to a const unsigned integer register in the host ring-3 context. */
1308typedef const RTR3UINTREG *PCRTR3UINTREG;
1309
1310/** Unsigned integer register in the host ring-3 context. */
1311#if R0_ARCH_BITS == 32
1312typedef uint32_t RTR0UINTREG;
1313#elif R0_ARCH_BITS == 64
1314typedef uint64_t RTR0UINTREG;
1315#else
1316# error "Unsupported R3_ARCH_BITS!"
1317#endif
1318/** Pointer to an unsigned integer register in the host ring-3 context. */
1319typedef RTR0UINTREG *PRTR0UINTREG;
1320/** Pointer to a const unsigned integer register in the host ring-3 context. */
1321typedef const RTR0UINTREG *PCRTR0UINTREG;
1322
1323/** @} */
1324
1325
1326/** @defgroup grp_rt_types_gc Guest Context Basic Types
1327 * @ingroup grp_rt_types
1328 * @{
1329 */
1330
1331/** Natural signed integer in the GC.
1332 * @deprecated silly type. */
1333#if GC_ARCH_BITS == 32
1334typedef int32_t RTGCINT;
1335#elif GC_ARCH_BITS == 64 /** @todo this isn't right, natural int is 32-bit, see RTHCINT. */
1336typedef int64_t RTGCINT;
1337#endif
1338/** Pointer to natural signed integer in GC.
1339 * @deprecated silly type. */
1340typedef RTGCINT *PRTGCINT;
1341/** Pointer to const natural signed integer in GC.
1342 * @deprecated silly type. */
1343typedef const RTGCINT *PCRTGCINT;
1344
1345/** Natural unsigned integer in the GC.
1346 * @deprecated silly type. */
1347#if GC_ARCH_BITS == 32
1348typedef uint32_t RTGCUINT;
1349#elif GC_ARCH_BITS == 64 /** @todo this isn't right, natural int is 32-bit, see RTHCUINT. */
1350typedef uint64_t RTGCUINT;
1351#endif
1352/** Pointer to natural unsigned integer in GC.
1353 * @deprecated silly type. */
1354typedef RTGCUINT *PRTGCUINT;
1355/** Pointer to const natural unsigned integer in GC.
1356 * @deprecated silly type. */
1357typedef const RTGCUINT *PCRTGCUINT;
1358
1359/** Signed integer which can contain a GC pointer. */
1360#if GC_ARCH_BITS == 32
1361typedef int32_t RTGCINTPTR;
1362#elif GC_ARCH_BITS == 64
1363typedef int64_t RTGCINTPTR;
1364#endif
1365/** Pointer to signed integer which can contain a GC pointer. */
1366typedef RTGCINTPTR *PRTGCINTPTR;
1367/** Pointer to const signed integer which can contain a GC pointer. */
1368typedef const RTGCINTPTR *PCRTGCINTPTR;
1369
1370/** Unsigned integer which can contain a GC pointer. */
1371#if GC_ARCH_BITS == 32
1372typedef uint32_t RTGCUINTPTR;
1373#elif GC_ARCH_BITS == 64
1374typedef uint64_t RTGCUINTPTR;
1375#else
1376# error Unsupported GC_ARCH_BITS value.
1377#endif
1378/** Pointer to unsigned integer which can contain a GC pointer. */
1379typedef RTGCUINTPTR *PRTGCUINTPTR;
1380/** Pointer to unsigned integer which can contain a GC pointer. */
1381typedef const RTGCUINTPTR *PCRTGCUINTPTR;
1382
1383/** Unsigned integer which can contain a 32 bits GC pointer. */
1384typedef uint32_t RTGCUINTPTR32;
1385/** Pointer to unsigned integer which can contain a 32 bits GC pointer. */
1386typedef RTGCUINTPTR32 *PRTGCUINTPTR32;
1387/** Pointer to unsigned integer which can contain a 32 bits GC pointer. */
1388typedef const RTGCUINTPTR32 *PCRTGCUINTPTR32;
1389
1390/** Unsigned integer which can contain a 64 bits GC pointer. */
1391typedef uint64_t RTGCUINTPTR64;
1392/** Pointer to unsigned integer which can contain a 32 bits GC pointer. */
1393typedef RTGCUINTPTR64 *PRTGCUINTPTR64;
1394/** Pointer to unsigned integer which can contain a 32 bits GC pointer. */
1395typedef const RTGCUINTPTR64 *PCRTGCUINTPTR64;
1396
1397/** Guest Physical Memory Address.*/
1398typedef uint64_t RTGCPHYS;
1399/** Pointer to Guest Physical Memory Address. */
1400typedef RTGCPHYS *PRTGCPHYS;
1401/** Pointer to const Guest Physical Memory Address. */
1402typedef const RTGCPHYS *PCRTGCPHYS;
1403/** @def NIL_RTGCPHYS
1404 * NIL GC Physical Address.
1405 * NIL_RTGCPHYS is used to signal an invalid physical address, similar
1406 * to the NULL pointer. Note that this value may actually be valid in
1407 * some contexts.
1408 */
1409#define NIL_RTGCPHYS (~(RTGCPHYS)0U)
1410/** Max guest physical memory address value. */
1411#define RTGCPHYS_MAX UINT64_MAX
1412
1413
1414/** Guest Physical Memory Address; limited to 32 bits.*/
1415typedef uint32_t RTGCPHYS32;
1416/** Pointer to Guest Physical Memory Address. */
1417typedef RTGCPHYS32 *PRTGCPHYS32;
1418/** Pointer to const Guest Physical Memory Address. */
1419typedef const RTGCPHYS32 *PCRTGCPHYS32;
1420/** @def NIL_RTGCPHYS32
1421 * NIL GC Physical Address.
1422 * NIL_RTGCPHYS32 is used to signal an invalid physical address, similar
1423 * to the NULL pointer. Note that this value may actually be valid in
1424 * some contexts.
1425 */
1426#define NIL_RTGCPHYS32 (~(RTGCPHYS32)0)
1427
1428
1429/** Guest Physical Memory Address; limited to 64 bits.*/
1430typedef uint64_t RTGCPHYS64;
1431/** Pointer to Guest Physical Memory Address. */
1432typedef RTGCPHYS64 *PRTGCPHYS64;
1433/** Pointer to const Guest Physical Memory Address. */
1434typedef const RTGCPHYS64 *PCRTGCPHYS64;
1435/** @def NIL_RTGCPHYS64
1436 * NIL GC Physical Address.
1437 * NIL_RTGCPHYS64 is used to signal an invalid physical address, similar
1438 * to the NULL pointer. Note that this value may actually be valid in
1439 * some contexts.
1440 */
1441#define NIL_RTGCPHYS64 (~(RTGCPHYS64)0)
1442
1443/** Guest context pointer, 32 bits.
1444 * Keep in mind that this type is an unsigned integer in
1445 * HC and void pointer in GC.
1446 */
1447typedef RTGCUINTPTR32 RTGCPTR32;
1448/** Pointer to a guest context pointer. */
1449typedef RTGCPTR32 *PRTGCPTR32;
1450/** Pointer to a const guest context pointer. */
1451typedef const RTGCPTR32 *PCRTGCPTR32;
1452/** @def NIL_RTGCPTR32
1453 * NIL GC pointer.
1454 */
1455#define NIL_RTGCPTR32 ((RTGCPTR32)0)
1456
1457/** Guest context pointer, 64 bits.
1458 */
1459typedef RTGCUINTPTR64 RTGCPTR64;
1460/** Pointer to a guest context pointer. */
1461typedef RTGCPTR64 *PRTGCPTR64;
1462/** Pointer to a const guest context pointer. */
1463typedef const RTGCPTR64 *PCRTGCPTR64;
1464/** @def NIL_RTGCPTR64
1465 * NIL GC pointer.
1466 */
1467#define NIL_RTGCPTR64 ((RTGCPTR64)0)
1468
1469/** Guest context pointer.
1470 * Keep in mind that this type is an unsigned integer in
1471 * HC and void pointer in GC.
1472 */
1473#if GC_ARCH_BITS == 64
1474typedef RTGCPTR64 RTGCPTR;
1475/** Pointer to a guest context pointer. */
1476typedef PRTGCPTR64 PRTGCPTR;
1477/** Pointer to a const guest context pointer. */
1478typedef PCRTGCPTR64 PCRTGCPTR;
1479/** @def NIL_RTGCPTR
1480 * NIL GC pointer.
1481 */
1482# define NIL_RTGCPTR NIL_RTGCPTR64
1483/** Max RTGCPTR value. */
1484# define RTGCPTR_MAX UINT64_MAX
1485#elif GC_ARCH_BITS == 32
1486typedef RTGCPTR32 RTGCPTR;
1487/** Pointer to a guest context pointer. */
1488typedef PRTGCPTR32 PRTGCPTR;
1489/** Pointer to a const guest context pointer. */
1490typedef PCRTGCPTR32 PCRTGCPTR;
1491/** @def NIL_RTGCPTR
1492 * NIL GC pointer.
1493 */
1494# define NIL_RTGCPTR NIL_RTGCPTR32
1495/** Max RTGCPTR value. */
1496# define RTGCPTR_MAX UINT32_MAX
1497#else
1498# error "Unsupported GC_ARCH_BITS!"
1499#endif
1500
1501/** Unsigned integer register in the guest context. */
1502typedef uint32_t RTGCUINTREG32;
1503/** Pointer to an unsigned integer register in the guest context. */
1504typedef RTGCUINTREG32 *PRTGCUINTREG32;
1505/** Pointer to a const unsigned integer register in the guest context. */
1506typedef const RTGCUINTREG32 *PCRTGCUINTREG32;
1507
1508typedef uint64_t RTGCUINTREG64;
1509/** Pointer to an unsigned integer register in the guest context. */
1510typedef RTGCUINTREG64 *PRTGCUINTREG64;
1511/** Pointer to a const unsigned integer register in the guest context. */
1512typedef const RTGCUINTREG64 *PCRTGCUINTREG64;
1513
1514#if GC_ARCH_BITS == 64
1515typedef RTGCUINTREG64 RTGCUINTREG;
1516#elif GC_ARCH_BITS == 32
1517typedef RTGCUINTREG32 RTGCUINTREG;
1518#else
1519# error "Unsupported GC_ARCH_BITS!"
1520#endif
1521/** Pointer to an unsigned integer register in the guest context. */
1522typedef RTGCUINTREG *PRTGCUINTREG;
1523/** Pointer to a const unsigned integer register in the guest context. */
1524typedef const RTGCUINTREG *PCRTGCUINTREG;
1525
1526/** @} */
1527
1528/** @defgroup grp_rt_types_rc Raw mode Context Basic Types
1529 * @ingroup grp_rt_types
1530 * @{
1531 */
1532
1533/** Raw mode context pointer; a 32 bits guest context pointer.
1534 * Keep in mind that this type is an unsigned integer in
1535 * HC and void pointer in RC.
1536 */
1537#ifdef IN_RC
1538typedef void * RTRCPTR;
1539#else
1540typedef uint32_t RTRCPTR;
1541#endif
1542/** Pointer to a raw mode context pointer. */
1543typedef RTRCPTR *PRTRCPTR;
1544/** Pointer to a const raw mode context pointer. */
1545typedef const RTRCPTR *PCRTRCPTR;
1546/** @def NIL_RTGCPTR
1547 * NIL RC pointer.
1548 */
1549#ifndef IN_RC
1550# define NIL_RTRCPTR ((RTRCPTR)0)
1551#else
1552# define NIL_RTRCPTR (NULL)
1553#endif
1554/** @def RTRCPTR_MAX
1555 * The maximum value a RTRCPTR can have. Mostly used as INVALID value.
1556 */
1557#define RTRCPTR_MAX ((RTRCPTR)UINT32_MAX)
1558
1559/** Raw mode context pointer, unsigned integer variant. */
1560typedef int32_t RTRCINTPTR;
1561/** @def RTRCUINTPTR_MAX
1562 * The maximum value a RTRCUINPTR can have.
1563 */
1564#define RTRCUINTPTR_MAX ((RTRCUINTPTR)UINT32_MAX)
1565
1566/** Raw mode context pointer, signed integer variant. */
1567typedef uint32_t RTRCUINTPTR;
1568/** @def RTRCINTPTR_MIN
1569 * The minimum value a RTRCINPTR can have.
1570 */
1571#define RTRCINTPTR_MIN ((RTRCINTPTR)INT32_MIN)
1572/** @def RTRCINTPTR_MAX
1573 * The maximum value a RTRCINPTR can have.
1574 */
1575#define RTRCINTPTR_MAX ((RTRCINTPTR)INT32_MAX)
1576
1577/** @} */
1578
1579
1580/** @defgroup grp_rt_types_cc Current Context Basic Types
1581 * @ingroup grp_rt_types
1582 * @{
1583 */
1584
1585/** Current Context Physical Memory Address.*/
1586#ifdef IN_RC
1587typedef RTGCPHYS RTCCPHYS;
1588#else
1589typedef RTHCPHYS RTCCPHYS;
1590#endif
1591/** Pointer to Current Context Physical Memory Address. */
1592typedef RTCCPHYS *PRTCCPHYS;
1593/** Pointer to const Current Context Physical Memory Address. */
1594typedef const RTCCPHYS *PCRTCCPHYS;
1595/** @def NIL_RTCCPHYS
1596 * NIL CC Physical Address.
1597 * NIL_RTCCPHYS is used to signal an invalid physical address, similar
1598 * to the NULL pointer.
1599 */
1600#ifdef IN_RC
1601# define NIL_RTCCPHYS NIL_RTGCPHYS
1602#else
1603# define NIL_RTCCPHYS NIL_RTHCPHYS
1604#endif
1605
1606/** Unsigned integer register in the current context. */
1607#if ARCH_BITS == 32
1608typedef uint32_t RTCCUINTREG;
1609#elif ARCH_BITS == 64
1610typedef uint64_t RTCCUINTREG;
1611#else
1612# error "Unsupported ARCH_BITS!"
1613#endif
1614/** Pointer to an unsigned integer register in the current context. */
1615typedef RTCCUINTREG *PRTCCUINTREG;
1616/** Pointer to a const unsigned integer register in the current context. */
1617typedef RTCCUINTREG const *PCRTCCUINTREG;
1618
1619/** Signed integer register in the current context. */
1620#if ARCH_BITS == 32
1621typedef int32_t RTCCINTREG;
1622#elif ARCH_BITS == 64
1623typedef int64_t RTCCINTREG;
1624#endif
1625/** Pointer to a signed integer register in the current context. */
1626typedef RTCCINTREG *PRTCCINTREG;
1627/** Pointer to a const signed integer register in the current context. */
1628typedef RTCCINTREG const *PCRTCCINTREG;
1629
1630/** @} */
1631
1632
1633/** Pointer to a critical section. */
1634typedef struct RTCRITSECT *PRTCRITSECT;
1635/** Pointer to a const critical section. */
1636typedef const struct RTCRITSECT *PCRTCRITSECT;
1637
1638/** Pointer to a read/write critical section. */
1639typedef struct RTCRITSECTRW *PRTCRITSECTRW;
1640/** Pointer to a const read/write critical section. */
1641typedef const struct RTCRITSECTRW *PCRTCRITSECTRW;
1642
1643
1644/** Condition variable handle. */
1645typedef R3PTRTYPE(struct RTCONDVARINTERNAL *) RTCONDVAR;
1646/** Pointer to a condition variable handle. */
1647typedef RTCONDVAR *PRTCONDVAR;
1648/** Nil condition variable handle. */
1649#define NIL_RTCONDVAR 0
1650
1651/** File handle. */
1652typedef R3R0PTRTYPE(struct RTFILEINT *) RTFILE;
1653/** Pointer to file handle. */
1654typedef RTFILE *PRTFILE;
1655/** Nil file handle. */
1656#define NIL_RTFILE ((RTFILE)~(RTHCINTPTR)0)
1657
1658/** Async I/O request handle. */
1659typedef R3PTRTYPE(struct RTFILEAIOREQINTERNAL *) RTFILEAIOREQ;
1660/** Pointer to an async I/O request handle. */
1661typedef RTFILEAIOREQ *PRTFILEAIOREQ;
1662/** Nil request handle. */
1663#define NIL_RTFILEAIOREQ 0
1664
1665/** Async I/O completion context handle. */
1666typedef R3PTRTYPE(struct RTFILEAIOCTXINTERNAL *) RTFILEAIOCTX;
1667/** Pointer to an async I/O completion context handle. */
1668typedef RTFILEAIOCTX *PRTFILEAIOCTX;
1669/** Nil context handle. */
1670#define NIL_RTFILEAIOCTX 0
1671
1672/** Loader module handle. */
1673typedef R3PTRTYPE(struct RTLDRMODINTERNAL *) RTLDRMOD;
1674/** Pointer to a loader module handle. */
1675typedef RTLDRMOD *PRTLDRMOD;
1676/** Nil loader module handle. */
1677#define NIL_RTLDRMOD 0
1678
1679/** Lock validator class handle. */
1680typedef R3R0PTRTYPE(struct RTLOCKVALCLASSINT *) RTLOCKVALCLASS;
1681/** Pointer to a lock validator class handle. */
1682typedef RTLOCKVALCLASS *PRTLOCKVALCLASS;
1683/** Nil lock validator class handle. */
1684#define NIL_RTLOCKVALCLASS ((RTLOCKVALCLASS)0)
1685
1686/** Ring-0 memory object handle. */
1687typedef R0PTRTYPE(struct RTR0MEMOBJINTERNAL *) RTR0MEMOBJ;
1688/** Pointer to a Ring-0 memory object handle. */
1689typedef RTR0MEMOBJ *PRTR0MEMOBJ;
1690/** Nil ring-0 memory object handle. */
1691#define NIL_RTR0MEMOBJ 0
1692
1693/** Native thread handle. */
1694typedef RTHCUINTPTR RTNATIVETHREAD;
1695/** Pointer to an native thread handle. */
1696typedef RTNATIVETHREAD *PRTNATIVETHREAD;
1697/** Nil native thread handle. */
1698#define NIL_RTNATIVETHREAD (~(RTNATIVETHREAD)0)
1699
1700/** Pipe handle. */
1701typedef R3R0PTRTYPE(struct RTPIPEINTERNAL *) RTPIPE;
1702/** Pointer to a pipe handle. */
1703typedef RTPIPE *PRTPIPE;
1704/** Nil pipe handle.
1705 * @remarks This is not 0 because of UNIX and OS/2 handle values. Take care! */
1706#define NIL_RTPIPE ((RTPIPE)RTHCUINTPTR_MAX)
1707
1708/** @typedef RTPOLLSET
1709 * Poll set handle. */
1710typedef R3R0PTRTYPE(struct RTPOLLSETINTERNAL *) RTPOLLSET;
1711/** Pointer to a poll set handle. */
1712typedef RTPOLLSET *PRTPOLLSET;
1713/** Nil poll set handle handle. */
1714#define NIL_RTPOLLSET ((RTPOLLSET)0)
1715
1716/** Process identifier. */
1717typedef uint32_t RTPROCESS;
1718/** Pointer to a process identifier. */
1719typedef RTPROCESS *PRTPROCESS;
1720/** Nil process identifier. */
1721#define NIL_RTPROCESS (~(RTPROCESS)0)
1722
1723/** Process ring-0 handle. */
1724typedef RTR0UINTPTR RTR0PROCESS;
1725/** Pointer to a ring-0 process handle. */
1726typedef RTR0PROCESS *PRTR0PROCESS;
1727/** Nil ring-0 process handle. */
1728#define NIL_RTR0PROCESS (~(RTR0PROCESS)0)
1729
1730/** @typedef RTSEMEVENT
1731 * Event Semaphore handle. */
1732typedef R3R0PTRTYPE(struct RTSEMEVENTINTERNAL *) RTSEMEVENT;
1733/** Pointer to an event semaphore handle. */
1734typedef RTSEMEVENT *PRTSEMEVENT;
1735/** Nil event semaphore handle. */
1736#define NIL_RTSEMEVENT 0
1737
1738/** @typedef RTSEMEVENTMULTI
1739 * Event Multiple Release Semaphore handle. */
1740typedef R3R0PTRTYPE(struct RTSEMEVENTMULTIINTERNAL *) RTSEMEVENTMULTI;
1741/** Pointer to an event multiple release semaphore handle. */
1742typedef RTSEMEVENTMULTI *PRTSEMEVENTMULTI;
1743/** Nil multiple release event semaphore handle. */
1744#define NIL_RTSEMEVENTMULTI 0
1745
1746/** @typedef RTSEMFASTMUTEX
1747 * Fast mutex Semaphore handle. */
1748typedef R3R0PTRTYPE(struct RTSEMFASTMUTEXINTERNAL *) RTSEMFASTMUTEX;
1749/** Pointer to a fast mutex semaphore handle. */
1750typedef RTSEMFASTMUTEX *PRTSEMFASTMUTEX;
1751/** Nil fast mutex semaphore handle. */
1752#define NIL_RTSEMFASTMUTEX 0
1753
1754/** @typedef RTSEMMUTEX
1755 * Mutex Semaphore handle. */
1756typedef R3R0PTRTYPE(struct RTSEMMUTEXINTERNAL *) RTSEMMUTEX;
1757/** Pointer to a mutex semaphore handle. */
1758typedef RTSEMMUTEX *PRTSEMMUTEX;
1759/** Nil mutex semaphore handle. */
1760#define NIL_RTSEMMUTEX 0
1761
1762/** @typedef RTSEMSPINMUTEX
1763 * Spinning mutex Semaphore handle. */
1764typedef R3R0PTRTYPE(struct RTSEMSPINMUTEXINTERNAL *) RTSEMSPINMUTEX;
1765/** Pointer to a spinning mutex semaphore handle. */
1766typedef RTSEMSPINMUTEX *PRTSEMSPINMUTEX;
1767/** Nil spinning mutex semaphore handle. */
1768#define NIL_RTSEMSPINMUTEX 0
1769
1770/** @typedef RTSEMRW
1771 * Read/Write Semaphore handle. */
1772typedef R3R0PTRTYPE(struct RTSEMRWINTERNAL *) RTSEMRW;
1773/** Pointer to a read/write semaphore handle. */
1774typedef RTSEMRW *PRTSEMRW;
1775/** Nil read/write semaphore handle. */
1776#define NIL_RTSEMRW 0
1777
1778/** @typedef RTSEMXROADS
1779 * Crossroads semaphore handle. */
1780typedef R3R0PTRTYPE(struct RTSEMXROADSINTERNAL *) RTSEMXROADS;
1781/** Pointer to a crossroads semaphore handle. */
1782typedef RTSEMXROADS *PRTSEMXROADS;
1783/** Nil crossroads semaphore handle. */
1784#define NIL_RTSEMXROADS ((RTSEMXROADS)0)
1785
1786/** Spinlock handle. */
1787typedef R3R0PTRTYPE(struct RTSPINLOCKINTERNAL *) RTSPINLOCK;
1788/** Pointer to a spinlock handle. */
1789typedef RTSPINLOCK *PRTSPINLOCK;
1790/** Nil spinlock handle. */
1791#define NIL_RTSPINLOCK 0
1792
1793/** Socket handle. */
1794typedef R3R0PTRTYPE(struct RTSOCKETINT *) RTSOCKET;
1795/** Pointer to socket handle. */
1796typedef RTSOCKET *PRTSOCKET;
1797/** Nil socket handle. */
1798#define NIL_RTSOCKET ((RTSOCKET)0)
1799
1800/** Pointer to a RTTCPSERVER handle. */
1801typedef struct RTTCPSERVER *PRTTCPSERVER;
1802/** Pointer to a RTTCPSERVER handle. */
1803typedef PRTTCPSERVER *PPRTTCPSERVER;
1804/** Nil RTTCPSERVER handle. */
1805#define NIL_RTTCPSERVER ((PRTTCPSERVER)0)
1806
1807/** Pointer to a RTUDPSERVER handle. */
1808typedef struct RTUDPSERVER *PRTUDPSERVER;
1809/** Pointer to a RTUDPSERVER handle. */
1810typedef PRTUDPSERVER *PPRTUDPSERVER;
1811/** Nil RTUDPSERVER handle. */
1812#define NIL_RTUDPSERVER ((PRTUDPSERVER)0)
1813
1814/** Thread handle.*/
1815typedef R3R0PTRTYPE(struct RTTHREADINT *) RTTHREAD;
1816/** Pointer to thread handle. */
1817typedef RTTHREAD *PRTTHREAD;
1818/** Nil thread handle. */
1819#define NIL_RTTHREAD 0
1820
1821/** A TLS index. */
1822typedef RTHCINTPTR RTTLS;
1823/** Pointer to a TLS index. */
1824typedef RTTLS *PRTTLS;
1825/** Pointer to a const TLS index. */
1826typedef RTTLS const *PCRTTLS;
1827/** NIL TLS index value. */
1828#define NIL_RTTLS ((RTTLS)-1)
1829
1830/** Trace buffer handle.
1831 * @remarks This is not a R3/R0 type like most other handles!
1832 */
1833typedef struct RTTRACEBUFINT *RTTRACEBUF;
1834/** Poiner to a trace buffer handle. */
1835typedef RTTRACEBUF *PRTTRACEBUF;
1836/** Nil trace buffer handle. */
1837#define NIL_RTTRACEBUF ((RTTRACEBUF)0)
1838/** The handle of the default trace buffer.
1839 * This can be used with any of the RTTraceBufAdd APIs. */
1840#define RTTRACEBUF_DEFAULT ((RTTRACEBUF)-2)
1841
1842/** Handle to a simple heap. */
1843typedef R3R0PTRTYPE(struct RTHEAPSIMPLEINTERNAL *) RTHEAPSIMPLE;
1844/** Pointer to a handle to a simple heap. */
1845typedef RTHEAPSIMPLE *PRTHEAPSIMPLE;
1846/** NIL simple heap handle. */
1847#define NIL_RTHEAPSIMPLE ((RTHEAPSIMPLE)0)
1848
1849/** Handle to an offset based heap. */
1850typedef R3R0PTRTYPE(struct RTHEAPOFFSETINTERNAL *) RTHEAPOFFSET;
1851/** Pointer to a handle to an offset based heap. */
1852typedef RTHEAPOFFSET *PRTHEAPOFFSET;
1853/** NIL offset based heap handle. */
1854#define NIL_RTHEAPOFFSET ((RTHEAPOFFSET)0)
1855
1856/** Handle to an environment block. */
1857typedef R3PTRTYPE(struct RTENVINTERNAL *) RTENV;
1858/** Pointer to a handle to an environment block. */
1859typedef RTENV *PRTENV;
1860/** NIL simple heap handle. */
1861#define NIL_RTENV ((RTENV)0)
1862
1863/** A CPU identifier.
1864 * @remarks This doesn't have to correspond to the APIC ID (intel/amd). Nor
1865 * does it have to correspond to the bits in the affinity mask, at
1866 * least not until we've sorted out Windows NT. */
1867typedef uint32_t RTCPUID;
1868/** Pointer to a CPU identifier. */
1869typedef RTCPUID *PRTCPUID;
1870/** Pointer to a const CPU identifier. */
1871typedef RTCPUID const *PCRTCPUID;
1872/** Nil CPU Id. */
1873#define NIL_RTCPUID ((RTCPUID)~0)
1874
1875/** The maximum number of CPUs a set can contain and IPRT is able
1876 * to reference. (Should be max of support arch/platforms.)
1877 * @remarks Must be a multiple of 64 (see RTCPUSET). */
1878#if defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)
1879# define RTCPUSET_MAX_CPUS 256
1880#elif defined(RT_ARCH_SPARC) || defined(RT_ARCH_SPARC64)
1881# define RTCPUSET_MAX_CPUS 1024
1882#else
1883# define RTCPUSET_MAX_CPUS 64
1884#endif
1885/** A CPU set.
1886 * @note Treat this as an opaque type and always use RTCpuSet* for
1887 * manupulating it. */
1888typedef struct RTCPUSET
1889{
1890 /** The bitmap. */
1891 uint64_t bmSet[RTCPUSET_MAX_CPUS / 64];
1892} RTCPUSET;
1893/** Pointer to a CPU set. */
1894typedef RTCPUSET *PRTCPUSET;
1895/** Pointer to a const CPU set. */
1896typedef RTCPUSET const *PCRTCPUSET;
1897
1898/** A handle table handle. */
1899typedef R3R0PTRTYPE(struct RTHANDLETABLEINT *) RTHANDLETABLE;
1900/** A pointer to a handle table handle. */
1901typedef RTHANDLETABLE *PRTHANDLETABLE;
1902/** @def NIL_RTHANDLETABLE
1903 * NIL handle table handle. */
1904#define NIL_RTHANDLETABLE ((RTHANDLETABLE)0)
1905
1906/** A handle to a low resolution timer. */
1907typedef R3R0PTRTYPE(struct RTTIMERLRINT *) RTTIMERLR;
1908/** A pointer to a low resolution timer handle. */
1909typedef RTTIMERLR *PRTTIMERLR;
1910/** @def NIL_RTTIMERLR
1911 * NIL low resolution timer handle value. */
1912#define NIL_RTTIMERLR ((RTTIMERLR)0)
1913
1914/** Handle to a random number generator. */
1915typedef R3R0PTRTYPE(struct RTRANDINT *) RTRAND;
1916/** Pointer to a random number generator handle. */
1917typedef RTRAND *PRTRAND;
1918/** NIL random number genrator handle value. */
1919#define NIL_RTRAND ((RTRAND)0)
1920
1921/** Debug address space handle. */
1922typedef R3R0PTRTYPE(struct RTDBGASINT *) RTDBGAS;
1923/** Pointer to a debug address space handle. */
1924typedef RTDBGAS *PRTDBGAS;
1925/** NIL debug address space handle. */
1926#define NIL_RTDBGAS ((RTDBGAS)0)
1927
1928/** Debug module handle. */
1929typedef R3R0PTRTYPE(struct RTDBGMODINT *) RTDBGMOD;
1930/** Pointer to a debug module handle. */
1931typedef RTDBGMOD *PRTDBGMOD;
1932/** NIL debug module handle. */
1933#define NIL_RTDBGMOD ((RTDBGMOD)0)
1934
1935/** Manifest handle. */
1936typedef struct RTMANIFESTINT *RTMANIFEST;
1937/** Pointer to a manifest handle. */
1938typedef RTMANIFEST *PRTMANIFEST;
1939/** NIL manifest handle. */
1940#define NIL_RTMANIFEST ((RTMANIFEST)~(uintptr_t)0)
1941
1942/** Memory pool handle. */
1943typedef R3R0PTRTYPE(struct RTMEMPOOLINT *) RTMEMPOOL;
1944/** Pointer to a memory pool handle. */
1945typedef RTMEMPOOL *PRTMEMPOOL;
1946/** NIL memory pool handle. */
1947#define NIL_RTMEMPOOL ((RTMEMPOOL)0)
1948/** The default memory pool handle. */
1949#define RTMEMPOOL_DEFAULT ((RTMEMPOOL)-2)
1950
1951/** String cache handle. */
1952typedef R3R0PTRTYPE(struct RTSTRCACHEINT *) RTSTRCACHE;
1953/** Pointer to a string cache handle. */
1954typedef RTSTRCACHE *PRTSTRCACHE;
1955/** NIL string cache handle. */
1956#define NIL_RTSTRCACHE ((RTSTRCACHE)0)
1957/** The default string cache handle. */
1958#define RTSTRCACHE_DEFAULT ((RTSTRCACHE)-2)
1959
1960
1961/** Virtual Filesystem handle. */
1962typedef struct RTVFSINTERNAL *RTVFS;
1963/** Pointer to a VFS handle. */
1964typedef RTVFS *PRTVFS;
1965/** A NIL VFS handle. */
1966#define NIL_RTVFS ((RTVFS)~(uintptr_t)0)
1967
1968/** Virtual Filesystem base object handle. */
1969typedef struct RTVFSOBJINTERNAL *RTVFSOBJ;
1970/** Pointer to a VFS base object handle. */
1971typedef RTVFSOBJ *PRTVFSOBJ;
1972/** A NIL VFS base object handle. */
1973#define NIL_RTVFSOBJ ((RTVFSOBJ)~(uintptr_t)0)
1974
1975/** Virtual Filesystem directory handle. */
1976typedef struct RTVFSDIRINTERNAL *RTVFSDIR;
1977/** Pointer to a VFS directory handle. */
1978typedef RTVFSDIR *PRTVFSDIR;
1979/** A NIL VFS directory handle. */
1980#define NIL_RTVFSDIR ((RTVFSDIR)~(uintptr_t)0)
1981
1982/** Virtual Filesystem filesystem stream handle. */
1983typedef struct RTVFSFSSTREAMINTERNAL *RTVFSFSSTREAM;
1984/** Pointer to a VFS filesystem stream handle. */
1985typedef RTVFSFSSTREAM *PRTVFSFSSTREAM;
1986/** A NIL VFS filesystem stream handle. */
1987#define NIL_RTVFSFSSTREAM ((RTVFSFSSTREAM)~(uintptr_t)0)
1988
1989/** Virtual Filesystem I/O stream handle. */
1990typedef struct RTVFSIOSTREAMINTERNAL *RTVFSIOSTREAM;
1991/** Pointer to a VFS I/O stream handle. */
1992typedef RTVFSIOSTREAM *PRTVFSIOSTREAM;
1993/** A NIL VFS I/O stream handle. */
1994#define NIL_RTVFSIOSTREAM ((RTVFSIOSTREAM)~(uintptr_t)0)
1995
1996/** Virtual Filesystem file handle. */
1997typedef struct RTVFSFILEINTERNAL *RTVFSFILE;
1998/** Pointer to a VFS file handle. */
1999typedef RTVFSFILE *PRTVFSFILE;
2000/** A NIL VFS file handle. */
2001#define NIL_RTVFSFILE ((RTVFSFILE)~(uintptr_t)0)
2002
2003/** Virtual Filesystem symbolic link handle. */
2004typedef struct RTVFSSYMLINKINTERNAL *RTVFSSYMLINK;
2005/** Pointer to a VFS symbolic link handle. */
2006typedef RTVFSSYMLINK *PRTVFSSYMLINK;
2007/** A NIL VFS symbolic link handle. */
2008#define NIL_RTVFSSYMLINK ((RTVFSSYMLINK)~(uintptr_t)0)
2009
2010/** Async I/O manager handle. */
2011typedef struct RTAIOMGRINT *RTAIOMGR;
2012/** Pointer to a async I/O manager handle. */
2013typedef RTAIOMGR *PRTAIOMGR;
2014/** A NIL async I/O manager handle. */
2015#define NIL_RTAIOMGR ((RTAIOMGR)~(uintptr_t)0)
2016
2017/** Async I/O manager file handle. */
2018typedef struct RTAIOMGRFILEINT *RTAIOMGRFILE;
2019/** Pointer to a async I/O manager file handle. */
2020typedef RTAIOMGRFILE *PRTAIOMGRFILE;
2021/** A NIL async I/O manager file handle. */
2022#define NIL_RTAIOMGRFILE ((RTAIOMGRFILE)~(uintptr_t)0)
2023
2024/**
2025 * Handle type.
2026 *
2027 * This is usually used together with RTHANDLEUNION.
2028 */
2029typedef enum RTHANDLETYPE
2030{
2031 /** The invalid zero value. */
2032 RTHANDLETYPE_INVALID = 0,
2033 /** File handle. */
2034 RTHANDLETYPE_FILE,
2035 /** Pipe handle */
2036 RTHANDLETYPE_PIPE,
2037 /** Socket handle. */
2038 RTHANDLETYPE_SOCKET,
2039 /** Thread handle. */
2040 RTHANDLETYPE_THREAD,
2041 /** The end of the valid values. */
2042 RTHANDLETYPE_END,
2043 /** The 32-bit type blow up. */
2044 RTHANDLETYPE_32BIT_HACK = 0x7fffffff
2045} RTHANDLETYPE;
2046/** Pointer to a handle type. */
2047typedef RTHANDLETYPE *PRTHANDLETYPE;
2048
2049/**
2050 * Handle union.
2051 *
2052 * This is usually used together with RTHANDLETYPE or as RTHANDLE.
2053 */
2054typedef union RTHANDLEUNION
2055{
2056 RTFILE hFile; /**< File handle. */
2057 RTPIPE hPipe; /**< Pipe handle. */
2058 RTSOCKET hSocket; /**< Socket handle. */
2059 RTTHREAD hThread; /**< Thread handle. */
2060 /** Generic integer handle value.
2061 * Note that RTFILE is not yet pointer sized, so accessing it via this member
2062 * isn't necessarily safe or fully portable. */
2063 RTHCUINTPTR uInt;
2064} RTHANDLEUNION;
2065/** Pointer to a handle union. */
2066typedef RTHANDLEUNION *PRTHANDLEUNION;
2067/** Pointer to a const handle union. */
2068typedef RTHANDLEUNION const *PCRTHANDLEUNION;
2069
2070/**
2071 * Generic handle.
2072 */
2073typedef struct RTHANDLE
2074{
2075 /** The handle type. */
2076 RTHANDLETYPE enmType;
2077 /** The handle value. */
2078 RTHANDLEUNION u;
2079} RTHANDLE;
2080/** Pointer to a generic handle. */
2081typedef RTHANDLE *PRTHANDLE;
2082/** Pointer to a const generic handle. */
2083typedef RTHANDLE const *PCRTHANDLE;
2084
2085
2086/**
2087 * Standard handles.
2088 *
2089 * @remarks These have the correct file descriptor values for unixy systems and
2090 * can be used directly in code specific to those platforms.
2091 */
2092typedef enum RTHANDLESTD
2093{
2094 /** Invalid standard handle. */
2095 RTHANDLESTD_INVALID = -1,
2096 /** The standard input handle. */
2097 RTHANDLESTD_INPUT = 0,
2098 /** The standard output handle. */
2099 RTHANDLESTD_OUTPUT,
2100 /** The standard error handle. */
2101 RTHANDLESTD_ERROR,
2102 /** The typical 32-bit type hack. */
2103 RTHANDLESTD_32BIT_HACK = 0x7fffffff
2104} RTHANDLESTD;
2105
2106
2107/**
2108 * Error info.
2109 *
2110 * See RTErrInfo*.
2111 */
2112typedef struct RTERRINFO
2113{
2114 /** Flags, see RTERRINFO_FLAGS_XXX. */
2115 uint32_t fFlags;
2116 /** The status code. */
2117 int32_t rc;
2118 /** The size of the message */
2119 size_t cbMsg;
2120 /** The error buffer. */
2121 char *pszMsg;
2122 /** Reserved for future use. */
2123 void *apvReserved[2];
2124} RTERRINFO;
2125/** Pointer to an error info structure. */
2126typedef RTERRINFO *PRTERRINFO;
2127/** Pointer to a const error info structure. */
2128typedef RTERRINFO const *PCRTERRINFO;
2129
2130/**
2131 * Static error info structure, see RTErrInfoInitStatic.
2132 */
2133typedef struct RTERRINFOSTATIC
2134{
2135 /** The core error info. */
2136 RTERRINFO Core;
2137 /** The static message buffer. */
2138 char szMsg[3072];
2139} RTERRINFOSTATIC;
2140/** Pointer to a error info buffer. */
2141typedef RTERRINFOSTATIC *PRTERRINFOSTATIC;
2142/** Pointer to a const static error info buffer. */
2143typedef RTERRINFOSTATIC const *PCRTERRINFOSTATIC;
2144
2145
2146/**
2147 * UUID data type.
2148 *
2149 * See RTUuid*.
2150 *
2151 * @remarks IPRT defines that the first three integers in the @c Gen struct
2152 * interpretation are in little endian representation. This is
2153 * different to many other UUID implementation, and requires
2154 * conversion if you need to achieve consistent results.
2155 */
2156typedef union RTUUID
2157{
2158 /** 8-bit view. */
2159 uint8_t au8[16];
2160 /** 16-bit view. */
2161 uint16_t au16[8];
2162 /** 32-bit view. */
2163 uint32_t au32[4];
2164 /** 64-bit view. */
2165 uint64_t au64[2];
2166 /** The way the UUID is declared by the DCE specification. */
2167 struct
2168 {
2169 uint32_t u32TimeLow;
2170 uint16_t u16TimeMid;
2171 uint16_t u16TimeHiAndVersion;
2172 uint8_t u8ClockSeqHiAndReserved;
2173 uint8_t u8ClockSeqLow;
2174 uint8_t au8Node[6];
2175 } Gen;
2176} RTUUID;
2177/** Pointer to UUID data. */
2178typedef RTUUID *PRTUUID;
2179/** Pointer to readonly UUID data. */
2180typedef const RTUUID *PCRTUUID;
2181
2182/** UUID string maximum length. */
2183#define RTUUID_STR_LENGTH 37
2184
2185
2186/** Compression handle. */
2187typedef struct RTZIPCOMP *PRTZIPCOMP;
2188/** Decompressor handle. */
2189typedef struct RTZIPDECOMP *PRTZIPDECOMP;
2190
2191
2192/**
2193 * Unicode Code Point.
2194 */
2195typedef uint32_t RTUNICP;
2196/** Pointer to an Unicode Code Point. */
2197typedef RTUNICP *PRTUNICP;
2198/** Pointer to an Unicode Code Point. */
2199typedef const RTUNICP *PCRTUNICP;
2200/** Max value a RTUNICP type can hold. */
2201#define RTUNICP_MAX ( ~(RTUNICP)0 )
2202/** Invalid code point.
2203 * This is returned when encountered invalid encodings or invalid
2204 * unicode code points. */
2205#define RTUNICP_INVALID ( UINT32_C(0xfffffffe) )
2206
2207
2208/**
2209 * UTF-16 character.
2210 * @remark wchar_t is not usable since it's compiler defined.
2211 * @remark When we use the term character we're not talking about unicode code point, but
2212 * the basic unit of the string encoding. Thus cwc - count of wide chars - means
2213 * count of RTUTF16; cuc - count of unicode chars - means count of RTUNICP;
2214 * and cch means count of the typedef 'char', which is assumed to be an octet.
2215 */
2216typedef uint16_t RTUTF16;
2217/** Pointer to a UTF-16 character. */
2218typedef RTUTF16 *PRTUTF16;
2219/** Pointer to a const UTF-16 character. */
2220typedef const RTUTF16 *PCRTUTF16;
2221
2222
2223/**
2224 * Wait for ever if we have to.
2225 */
2226#define RT_INDEFINITE_WAIT (~0U)
2227
2228
2229/**
2230 * Generic process callback.
2231 *
2232 * @returns VBox status code. Failure will cancel the operation.
2233 * @param uPercentage The percentage of the operation which has been completed.
2234 * @param pvUser The user specified argument.
2235 */
2236typedef DECLCALLBACK(int) FNRTPROGRESS(unsigned uPrecentage, void *pvUser);
2237/** Pointer to a generic progress callback function, FNRTPROCESS(). */
2238typedef FNRTPROGRESS *PFNRTPROGRESS;
2239
2240
2241/**
2242 * A point in a two dimentional coordinate system.
2243 */
2244typedef struct RTPOINT
2245{
2246 /** X coordinate. */
2247 int32_t x;
2248 /** Y coordinate. */
2249 int32_t y;
2250} RTPOINT;
2251/** Pointer to a point. */
2252typedef RTPOINT *PRTPOINT;
2253/** Pointer to a const point. */
2254typedef const RTPOINT *PCRTPOINT;
2255
2256
2257/**
2258 * Rectangle data type, double point.
2259 */
2260typedef struct RTRECT
2261{
2262 /** left X coordinate. */
2263 int32_t xLeft;
2264 /** top Y coordinate. */
2265 int32_t yTop;
2266 /** right X coordinate. (exclusive) */
2267 int32_t xRight;
2268 /** bottom Y coordinate. (exclusive) */
2269 int32_t yBottom;
2270} RTRECT;
2271/** Pointer to a double point rectangle. */
2272typedef RTRECT *PRTRECT;
2273/** Pointer to a const double point rectangle. */
2274typedef const RTRECT *PCRTRECT;
2275
2276
2277/**
2278 * Rectangle data type, point + size.
2279 */
2280typedef struct RTRECT2
2281{
2282 /** X coordinate.
2283 * Unless stated otherwise, this is the top left corner. */
2284 int32_t x;
2285 /** Y coordinate.
2286 * Unless stated otherwise, this is the top left corner. */
2287 int32_t y;
2288 /** The width.
2289 * Unless stated otherwise, this is to the right of (x,y) and will not
2290 * be a negative number. */
2291 int32_t cx;
2292 /** The height.
2293 * Unless stated otherwise, this is down from (x,y) and will not be a
2294 * negative number. */
2295 int32_t cy;
2296} RTRECT2;
2297/** Pointer to a point + size rectangle. */
2298typedef RTRECT2 *PRTRECT2;
2299/** Pointer to a const point + size rectangle. */
2300typedef const RTRECT2 *PCRTRECT2;
2301
2302
2303/**
2304 * The size of a rectangle.
2305 */
2306typedef struct RTRECTSIZE
2307{
2308 /** The width (along the x-axis). */
2309 uint32_t cx;
2310 /** The height (along the y-axis). */
2311 uint32_t cy;
2312} RTRECTSIZE;
2313/** Pointer to a rectangle size. */
2314typedef RTRECTSIZE *PRTRECTSIZE;
2315/** Pointer to a const rectangle size. */
2316typedef const RTRECTSIZE *PCRTRECTSIZE;
2317
2318
2319/**
2320 * Ethernet MAC address.
2321 *
2322 * The first 24 bits make up the Organisationally Unique Identifier (OUI),
2323 * where the first bit (little endian) indicates multicast (set) / unicast,
2324 * and the second bit indicates locally (set) / global administered. If all
2325 * bits are set, it's a broadcast.
2326 */
2327typedef union RTMAC
2328{
2329 /** @todo add a bitfield view of this stuff. */
2330 /** 8-bit view. */
2331 uint8_t au8[6];
2332 /** 16-bit view. */
2333 uint16_t au16[3];
2334} RTMAC;
2335/** Pointer to a MAC address. */
2336typedef RTMAC *PRTMAC;
2337/** Pointer to a readonly MAC address. */
2338typedef const RTMAC *PCRTMAC;
2339
2340
2341/** Pointer to a lock validator record.
2342 * The structure definition is found in iprt/lockvalidator.h. */
2343typedef struct RTLOCKVALRECEXCL *PRTLOCKVALRECEXCL;
2344/** Pointer to a record of one ownership share.
2345 * The structure definition is found in iprt/lockvalidator.h. */
2346typedef struct RTLOCKVALRECSHRD *PRTLOCKVALRECSHRD;
2347/** Pointer to a lock validator source poisition.
2348 * The structure definition is found in iprt/lockvalidator.h. */
2349typedef struct RTLOCKVALSRCPOS *PRTLOCKVALSRCPOS;
2350/** Pointer to a const lock validator source poisition.
2351 * The structure definition is found in iprt/lockvalidator.h. */
2352typedef struct RTLOCKVALSRCPOS const *PCRTLOCKVALSRCPOS;
2353
2354/** @name Special sub-class values.
2355 * The range 16..UINT32_MAX is available to the user, the range 0..15 is
2356 * reserved for the lock validator. In the user range the locks can only be
2357 * taking in ascending order.
2358 * @{ */
2359/** Invalid value. */
2360#define RTLOCKVAL_SUB_CLASS_INVALID UINT32_C(0)
2361/** Not allowed to be taken with any other locks in the same class.
2362 * This is the recommended value. */
2363#define RTLOCKVAL_SUB_CLASS_NONE UINT32_C(1)
2364/** Any order is allowed within the class. */
2365#define RTLOCKVAL_SUB_CLASS_ANY UINT32_C(2)
2366/** The first user value. */
2367#define RTLOCKVAL_SUB_CLASS_USER UINT32_C(16)
2368/** @} */
2369
2370
2371/**
2372 * Process exit codes.
2373 */
2374typedef enum RTEXITCODE
2375{
2376 /** Success. */
2377 RTEXITCODE_SUCCESS = 0,
2378 /** General failure. */
2379 RTEXITCODE_FAILURE = 1,
2380 /** Invalid arguments. */
2381 RTEXITCODE_SYNTAX = 2,
2382 /** Initialization failure (usually IPRT, but could be used for other
2383 * components as well). */
2384 RTEXITCODE_INIT = 3,
2385 /** Test skipped. */
2386 RTEXITCODE_SKIPPED = 4,
2387 /** The end of valid exit codes. */
2388 RTEXITCODE_END,
2389 /** The usual 32-bit type hack. */
2390 RTEXITCODE_32BIT_HACK = 0x7fffffff
2391} RTEXITCODE;
2392
2393/**
2394 * Range descriptor.
2395 */
2396typedef struct RTRANGE
2397{
2398 /** Start offset. */
2399 uint64_t offStart;
2400 /** Range size. */
2401 size_t cbRange;
2402} RTRANGE;
2403/** Pointer to a range descriptor. */
2404typedef RTRANGE *PRTRANGE;
2405/** Pointer to a readonly range descriptor. */
2406typedef const RTRANGE *PCRTRANGE;
2407
2408#ifdef __cplusplus
2409/**
2410 * Strict type validation helper class.
2411 *
2412 * See RTErrStrictType and RT_SUCCESS_NP.
2413 */
2414class RTErrStrictType2
2415{
2416protected:
2417 /** The status code. */
2418 int32_t m_rc;
2419
2420public:
2421 /**
2422 * Constructor.
2423 * @param rc IPRT style status code.
2424 */
2425 RTErrStrictType2(int32_t rc) : m_rc(rc)
2426 {
2427 }
2428
2429 /**
2430 * Get the status code.
2431 * @returns IPRT style status code.
2432 */
2433 int32_t getValue() const
2434 {
2435 return m_rc;
2436 }
2437};
2438#endif /* __cplusplus */
2439/** @} */
2440
2441#endif
2442
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