VirtualBox

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

Last change on this file since 40986 was 40946, checked in by vboxsync, 13 years ago

iprt: build fix.

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