VirtualBox

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

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

iprt: dance with NULL.

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