VirtualBox

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

Last change on this file since 58625 was 58625, checked in by vboxsync, 9 years ago

iprt/types.h: Watcom & 16-bit adjustments.

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