VirtualBox

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

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

iprt: comment fix.

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