VirtualBox

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

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

FreeBSD: Fix build on 10-CURRENT (Thanks to Daichi Goto and Bernhard Froehlich)

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