VirtualBox

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

Last change on this file since 46050 was 45724, checked in by vboxsync, 12 years ago

Missing file

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