VirtualBox

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

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

VMMDev,IGuest,IAdditionsFacility,VBoxGuest,iprt/types.h: VMMDev must track the guest facility reports so they can be saved and restored correctly. Also fixed a reset bug related to guestInfo2. Restrict who can report the status of which facilities. Recalc the runlevel based on which facilities are active. Restrict the number of facilities main tracks.

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