VirtualBox

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

Last change on this file since 45375 was 45111, checked in by vboxsync, 12 years ago

build fix

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