VirtualBox

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

Last change on this file since 62485 was 62473, checked in by vboxsync, 8 years ago

(C) 2016

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 84.9 KB
Line 
1/** @file
2 * IPRT - Types.
3 */
4
5/*
6 * Copyright (C) 2006-2016 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 !RT_GNUC_PREREQ(4, 1)
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) || (HC_ARCH_BITS == 16 || GC_ARCH_BITS == 16)
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) || (HC_ARCH_BITS == 16 || GC_ARCH_BITS == 16)
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) || (HC_ARCH_BITS == 16 || GC_ARCH_BITS == 16)
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) || (HC_ARCH_BITS == 16 || GC_ARCH_BITS == 16)
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) || (HC_ARCH_BITS == 16 || GC_ARCH_BITS == 16)
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/** Unsigned integer register in the current context.
1570 * @remarks This is for dealing with EAX in 16-bit mode. */
1571#if ARCH_BITS == 16 && defined(RT_ARCH_X86)
1572typedef uint32_t RTCCUINTXREG;
1573#else
1574typedef RTCCUINTREG RTCCUINTXREG;
1575#endif
1576/** Pointer to an unsigned integer register in the current context. */
1577typedef RTCCUINTREG *PRTCCUINTXREG;
1578/** Pointer to a const unsigned integer register in the current context. */
1579typedef RTCCUINTREG const *PCRTCCUINTXREG;
1580
1581/** Signed integer extended register in the current context.
1582 * @remarks This is for dealing with EAX in 16-bit mode. */
1583#if ARCH_BITS == 16 && defined(RT_ARCH_X86)
1584typedef int32_t RTCCINTXREG;
1585#else
1586typedef RTCCINTREG RTCCINTXREG;
1587#endif
1588/** Pointer to a signed integer extended register in the current context. */
1589typedef RTCCINTXREG *PRTCCINTXREG;
1590/** Pointer to a const signed integer extended register in the current
1591 * context. */
1592typedef RTCCINTXREG const *PCRTCCINTXREG;
1593
1594/** @def RTCCUINTREG_C
1595 * Defines a constant of RTCCUINTREG type.
1596 * @param a_Value Constant value */
1597/** @def RTCCUINTREG_MAX
1598 * Max value that RTCCUINTREG can hold. */
1599/** @def RTCCUINTREG_FMT
1600 * Generic IPRT format specifier for RTCCUINTREG. */
1601/** @def RTCCUINTREG_XFMT
1602 * Generic IPRT format specifier for RTCCUINTREG, hexadecimal. */
1603/** @def RTCCINTREG_C
1604 * Defines a constant of RTCCINTREG type.
1605 * @param a_Value Constant value */
1606/** @def RTCCINTREG_MAX
1607 * Max value that RTCCINTREG can hold. */
1608/** @def RTCCINTREG_MIN
1609 * Min value that RTCCINTREG can hold. */
1610/** @def RTCCINTREG_XFMT
1611 * Generic IPRT format specifier for RTCCINTREG, hexadecimal. */
1612#if ARCH_BITS == 32
1613# define RTCCUINTREG_C(a_Value) UINT32_C(a_Value)
1614# define RTCCUINTREG_MAX UINT32_MAX
1615# define RTCCUINTREG_FMT "RU32"
1616# define RTCCUINTREG_XFMT "RX32"
1617# define RTCCINTREG_C(a_Value) INT32_C(a_Value)
1618# define RTCCINTREG_MAX INT32_MAX
1619# define RTCCINTREG_MIN INT32_MIN
1620# define RTCCINTREG_FMT "RI32"
1621# define RTCCINTREG_XFMT "RX32"
1622#elif ARCH_BITS == 64
1623# define RTCCUINTREG_C(a_Value) UINT64_C(a_Value)
1624# define RTCCUINTREG_MAX UINT64_MAX
1625# define RTCCUINTREG_FMT "RU64"
1626# define RTCCUINTREG_XFMT "RX64"
1627# define RTCCINTREG_C(a_Value) INT64_C(a_Value)
1628# define RTCCINTREG_MAX INT64_MAX
1629# define RTCCINTREG_MIN INT64_MIN
1630# define RTCCINTREG_FMT "RI64"
1631# define RTCCINTREG_XFMT "RX64"
1632#elif ARCH_BITS == 16
1633# define RTCCUINTREG_C(a_Value) UINT16_C(a_Value)
1634# define RTCCUINTREG_MAX UINT16_MAX
1635# define RTCCUINTREG_FMT "RU16"
1636# define RTCCUINTREG_XFMT "RX16"
1637# define RTCCINTREG_C(a_Value) INT16_C(a_Value)
1638# define RTCCINTREG_MAX INT16_MAX
1639# define RTCCINTREG_MIN INT16_MIN
1640# define RTCCINTREG_FMT "RI16"
1641# define RTCCINTREG_XFMT "RX16"
1642#else
1643# error "Unsupported ARCH_BITS!"
1644#endif
1645/** @def RTCCUINTXREG_C
1646 * Defines a constant of RTCCUINTXREG type.
1647 * @param a_Value Constant value */
1648/** @def RTCCUINTXREG_MAX
1649 * Max value that RTCCUINTXREG can hold. */
1650/** @def RTCCUINTXREG_FMT
1651 * Generic IPRT format specifier for RTCCUINTXREG. */
1652/** @def RTCCUINTXREG_XFMT
1653 * Generic IPRT format specifier for RTCCUINTXREG, hexadecimal. */
1654/** @def RTCCINTXREG_C
1655 * Defines a constant of RTCCINTXREG type.
1656 * @param a_Value Constant value */
1657/** @def RTCCINTXREG_MAX
1658 * Max value that RTCCINTXREG can hold. */
1659/** @def RTCCINTXREG_MIN
1660 * Min value that RTCCINTXREG can hold. */
1661/** @def RTCCINTXREG_FMT
1662 * Generic IPRT format specifier for RTCCINTXREG. */
1663/** @def RTCCINTXREG_XFMT
1664 * Generic IPRT format specifier for RTCCINTXREG, hexadecimal. */
1665#if ARCH_BITS == 16 && defined(RT_ARCH_X86)
1666# define RTCCUINTXREG_C(a_Value) UINT32_C(a_Value)
1667# define RTCCUINTXREG_MAX UINT32_MAX
1668# define RTCCUINTXREG_FMT "RU32"
1669# define RTCCUINTXREG_XFMT "RX32"
1670# define RTCCINTXREG_C(a_Value) INT32_C(a_Value)
1671# define RTCCINTXREG_MAX INT32_MAX
1672# define RTCCINTXREG_MIN INT32_MIN
1673# define RTCCINTXREG_FMT "RI32"
1674# define RTCCINTXREG_XFMT "RX32"
1675#else
1676# define RTCCUINTXREG_C(a_Value) RTCCUINTREG_C(a_Value)
1677# define RTCCUINTXREG_MAX RTCCUINTREG_MAX
1678# define RTCCUINTXREG_FMT RTCCUINTREG_FMT
1679# define RTCCUINTXREG_XFMT RTCCUINTREG_XFMT
1680# define RTCCINTXREG_C(a_Value) RTCCINTREG_C(a_Value)
1681# define RTCCINTXREG_MAX RTCCINTREG_MAX
1682# define RTCCINTXREG_MIN RTCCINTREG_MIN
1683# define RTCCINTXREG_FMT RTCCINTREG_FMT
1684# define RTCCINTXREG_XFMT RTCCINTREG_XFMT
1685#endif
1686/** @} */
1687
1688
1689
1690/** Pointer to a big integer number. */
1691typedef struct RTBIGNUM *PRTBIGNUM;
1692/** Pointer to a const big integer number. */
1693typedef struct RTBIGNUM const *PCRTBIGNUM;
1694
1695
1696/** Pointer to a critical section. */
1697typedef struct RTCRITSECT *PRTCRITSECT;
1698/** Pointer to a const critical section. */
1699typedef const struct RTCRITSECT *PCRTCRITSECT;
1700
1701/** Pointer to a read/write critical section. */
1702typedef struct RTCRITSECTRW *PRTCRITSECTRW;
1703/** Pointer to a const read/write critical section. */
1704typedef const struct RTCRITSECTRW *PCRTCRITSECTRW;
1705
1706
1707/** Condition variable handle. */
1708typedef R3PTRTYPE(struct RTCONDVARINTERNAL *) RTCONDVAR;
1709/** Pointer to a condition variable handle. */
1710typedef RTCONDVAR *PRTCONDVAR;
1711/** Nil condition variable handle. */
1712#define NIL_RTCONDVAR 0
1713
1714/** Cryptographic (certificate) store handle. */
1715typedef R3R0PTRTYPE(struct RTCRSTOREINT *) RTCRSTORE;
1716/** Pointer to a Cryptographic (certificate) store handle. */
1717typedef RTCRSTORE *PRTCRSTORE;
1718/** Nil Cryptographic (certificate) store handle. */
1719#define NIL_RTCRSTORE 0
1720
1721/** Pointer to a const (store) certificate context. */
1722typedef struct RTCRCERTCTX const *PCRTCRCERTCTX;
1723
1724/** Cryptographic message digest handle. */
1725typedef R3R0PTRTYPE(struct RTCRDIGESTINT *) RTCRDIGEST;
1726/** Pointer to a cryptographic message digest handle. */
1727typedef RTCRDIGEST *PRTCRDIGEST;
1728/** NIL cryptographic message digest handle. */
1729#define NIL_RTCRDIGEST (0)
1730
1731/** Public key encryption schema handle. */
1732typedef R3R0PTRTYPE(struct RTCRPKIXENCRYPTIONINT *) RTCRPKIXENCRYPTION;
1733/** Pointer to a public key encryption schema handle. */
1734typedef RTCRPKIXENCRYPTION *PRTCRPKIXENCRYPTION;
1735/** NIL public key encryption schema handle */
1736#define NIL_RTCRPKIXENCRYPTION (0)
1737
1738/** Public key signature schema handle. */
1739typedef R3R0PTRTYPE(struct RTCRPKIXSIGNATUREINT *) RTCRPKIXSIGNATURE;
1740/** Pointer to a public key signature schema handle. */
1741typedef RTCRPKIXSIGNATURE *PRTCRPKIXSIGNATURE;
1742/** NIL public key signature schema handle */
1743#define NIL_RTCRPKIXSIGNATURE (0)
1744
1745/** X.509 certificate paths builder & validator handle. */
1746typedef R3R0PTRTYPE(struct RTCRX509CERTPATHSINT *) RTCRX509CERTPATHS;
1747/** Pointer to a certificate paths builder & validator handle. */
1748typedef RTCRX509CERTPATHS *PRTCRX509CERTPATHS;
1749/** Nil certificate paths builder & validator handle. */
1750#define NIL_RTCRX509CERTPATHS 0
1751
1752/** File handle. */
1753typedef R3R0PTRTYPE(struct RTFILEINT *) RTFILE;
1754/** Pointer to file handle. */
1755typedef RTFILE *PRTFILE;
1756/** Nil file handle. */
1757#define NIL_RTFILE ((RTFILE)~(RTHCINTPTR)0)
1758
1759/** Async I/O request handle. */
1760typedef R3PTRTYPE(struct RTFILEAIOREQINTERNAL *) RTFILEAIOREQ;
1761/** Pointer to an async I/O request handle. */
1762typedef RTFILEAIOREQ *PRTFILEAIOREQ;
1763/** Nil request handle. */
1764#define NIL_RTFILEAIOREQ 0
1765
1766/** Async I/O completion context handle. */
1767typedef R3PTRTYPE(struct RTFILEAIOCTXINTERNAL *) RTFILEAIOCTX;
1768/** Pointer to an async I/O completion context handle. */
1769typedef RTFILEAIOCTX *PRTFILEAIOCTX;
1770/** Nil context handle. */
1771#define NIL_RTFILEAIOCTX 0
1772
1773/** Loader module handle. */
1774typedef R3R0PTRTYPE(struct RTLDRMODINTERNAL *) RTLDRMOD;
1775/** Pointer to a loader module handle. */
1776typedef RTLDRMOD *PRTLDRMOD;
1777/** Nil loader module handle. */
1778#define NIL_RTLDRMOD 0
1779
1780/** Lock validator class handle. */
1781typedef R3R0PTRTYPE(struct RTLOCKVALCLASSINT *) RTLOCKVALCLASS;
1782/** Pointer to a lock validator class handle. */
1783typedef RTLOCKVALCLASS *PRTLOCKVALCLASS;
1784/** Nil lock validator class handle. */
1785#define NIL_RTLOCKVALCLASS ((RTLOCKVALCLASS)0)
1786
1787/** Ring-0 memory object handle. */
1788typedef R0PTRTYPE(struct RTR0MEMOBJINTERNAL *) RTR0MEMOBJ;
1789/** Pointer to a Ring-0 memory object handle. */
1790typedef RTR0MEMOBJ *PRTR0MEMOBJ;
1791/** Nil ring-0 memory object handle. */
1792#define NIL_RTR0MEMOBJ 0
1793
1794/** Native thread handle. */
1795typedef RTHCUINTPTR RTNATIVETHREAD;
1796/** Pointer to an native thread handle. */
1797typedef RTNATIVETHREAD *PRTNATIVETHREAD;
1798/** Nil native thread handle. */
1799#define NIL_RTNATIVETHREAD (~(RTNATIVETHREAD)0)
1800
1801/** Pipe handle. */
1802typedef R3R0PTRTYPE(struct RTPIPEINTERNAL *) RTPIPE;
1803/** Pointer to a pipe handle. */
1804typedef RTPIPE *PRTPIPE;
1805/** Nil pipe handle.
1806 * @remarks This is not 0 because of UNIX and OS/2 handle values. Take care! */
1807#define NIL_RTPIPE ((RTPIPE)RTHCUINTPTR_MAX)
1808
1809/** @typedef RTPOLLSET
1810 * Poll set handle. */
1811typedef R3R0PTRTYPE(struct RTPOLLSETINTERNAL *) RTPOLLSET;
1812/** Pointer to a poll set handle. */
1813typedef RTPOLLSET *PRTPOLLSET;
1814/** Nil poll set handle handle. */
1815#define NIL_RTPOLLSET ((RTPOLLSET)0)
1816
1817/** Process identifier. */
1818typedef uint32_t RTPROCESS;
1819/** Pointer to a process identifier. */
1820typedef RTPROCESS *PRTPROCESS;
1821/** Nil process identifier. */
1822#define NIL_RTPROCESS (~(RTPROCESS)0)
1823
1824/** Process ring-0 handle. */
1825typedef RTR0UINTPTR RTR0PROCESS;
1826/** Pointer to a ring-0 process handle. */
1827typedef RTR0PROCESS *PRTR0PROCESS;
1828/** Nil ring-0 process handle. */
1829#define NIL_RTR0PROCESS (~(RTR0PROCESS)0)
1830
1831/** @typedef RTSEMEVENT
1832 * Event Semaphore handle. */
1833typedef R3R0PTRTYPE(struct RTSEMEVENTINTERNAL *) RTSEMEVENT;
1834/** Pointer to an event semaphore handle. */
1835typedef RTSEMEVENT *PRTSEMEVENT;
1836/** Nil event semaphore handle. */
1837#define NIL_RTSEMEVENT 0
1838
1839/** @typedef RTSEMEVENTMULTI
1840 * Event Multiple Release Semaphore handle. */
1841typedef R3R0PTRTYPE(struct RTSEMEVENTMULTIINTERNAL *) RTSEMEVENTMULTI;
1842/** Pointer to an event multiple release semaphore handle. */
1843typedef RTSEMEVENTMULTI *PRTSEMEVENTMULTI;
1844/** Nil multiple release event semaphore handle. */
1845#define NIL_RTSEMEVENTMULTI 0
1846
1847/** @typedef RTSEMFASTMUTEX
1848 * Fast mutex Semaphore handle. */
1849typedef R3R0PTRTYPE(struct RTSEMFASTMUTEXINTERNAL *) RTSEMFASTMUTEX;
1850/** Pointer to a fast mutex semaphore handle. */
1851typedef RTSEMFASTMUTEX *PRTSEMFASTMUTEX;
1852/** Nil fast mutex semaphore handle. */
1853#define NIL_RTSEMFASTMUTEX 0
1854
1855/** @typedef RTSEMMUTEX
1856 * Mutex Semaphore handle. */
1857typedef R3R0PTRTYPE(struct RTSEMMUTEXINTERNAL *) RTSEMMUTEX;
1858/** Pointer to a mutex semaphore handle. */
1859typedef RTSEMMUTEX *PRTSEMMUTEX;
1860/** Nil mutex semaphore handle. */
1861#define NIL_RTSEMMUTEX 0
1862
1863/** @typedef RTSEMSPINMUTEX
1864 * Spinning mutex Semaphore handle. */
1865typedef R3R0PTRTYPE(struct RTSEMSPINMUTEXINTERNAL *) RTSEMSPINMUTEX;
1866/** Pointer to a spinning mutex semaphore handle. */
1867typedef RTSEMSPINMUTEX *PRTSEMSPINMUTEX;
1868/** Nil spinning mutex semaphore handle. */
1869#define NIL_RTSEMSPINMUTEX 0
1870
1871/** @typedef RTSEMRW
1872 * Read/Write Semaphore handle. */
1873typedef R3R0PTRTYPE(struct RTSEMRWINTERNAL *) RTSEMRW;
1874/** Pointer to a read/write semaphore handle. */
1875typedef RTSEMRW *PRTSEMRW;
1876/** Nil read/write semaphore handle. */
1877#define NIL_RTSEMRW 0
1878
1879/** @typedef RTSEMXROADS
1880 * Crossroads semaphore handle. */
1881typedef R3R0PTRTYPE(struct RTSEMXROADSINTERNAL *) RTSEMXROADS;
1882/** Pointer to a crossroads semaphore handle. */
1883typedef RTSEMXROADS *PRTSEMXROADS;
1884/** Nil crossroads semaphore handle. */
1885#define NIL_RTSEMXROADS ((RTSEMXROADS)0)
1886
1887/** Spinlock handle. */
1888typedef R3R0PTRTYPE(struct RTSPINLOCKINTERNAL *) RTSPINLOCK;
1889/** Pointer to a spinlock handle. */
1890typedef RTSPINLOCK *PRTSPINLOCK;
1891/** Nil spinlock handle. */
1892#define NIL_RTSPINLOCK 0
1893
1894/** Socket handle. */
1895typedef R3R0PTRTYPE(struct RTSOCKETINT *) RTSOCKET;
1896/** Pointer to socket handle. */
1897typedef RTSOCKET *PRTSOCKET;
1898/** Nil socket handle. */
1899#define NIL_RTSOCKET ((RTSOCKET)0)
1900
1901/** Pointer to a RTTCPSERVER handle. */
1902typedef struct RTTCPSERVER *PRTTCPSERVER;
1903/** Pointer to a RTTCPSERVER handle. */
1904typedef PRTTCPSERVER *PPRTTCPSERVER;
1905/** Nil RTTCPSERVER handle. */
1906#define NIL_RTTCPSERVER ((PRTTCPSERVER)0)
1907
1908/** Pointer to a RTUDPSERVER handle. */
1909typedef struct RTUDPSERVER *PRTUDPSERVER;
1910/** Pointer to a RTUDPSERVER handle. */
1911typedef PRTUDPSERVER *PPRTUDPSERVER;
1912/** Nil RTUDPSERVER handle. */
1913#define NIL_RTUDPSERVER ((PRTUDPSERVER)0)
1914
1915/** Thread handle.*/
1916typedef R3R0PTRTYPE(struct RTTHREADINT *) RTTHREAD;
1917/** Pointer to thread handle. */
1918typedef RTTHREAD *PRTTHREAD;
1919/** Nil thread handle. */
1920#define NIL_RTTHREAD 0
1921
1922/** Thread context switching hook handle. */
1923typedef R0PTRTYPE(struct RTTHREADCTXHOOKINT *) RTTHREADCTXHOOK;
1924/** Pointer to Thread context switching hook handle. */
1925typedef RTTHREADCTXHOOK *PRTTHREADCTXHOOK;
1926/** Nil Thread context switching hook handle. */
1927#define NIL_RTTHREADCTXHOOK ((RTTHREADCTXHOOK)0)
1928
1929/** A TLS index. */
1930typedef RTHCINTPTR RTTLS;
1931/** Pointer to a TLS index. */
1932typedef RTTLS *PRTTLS;
1933/** Pointer to a const TLS index. */
1934typedef RTTLS const *PCRTTLS;
1935/** NIL TLS index value. */
1936#define NIL_RTTLS ((RTTLS)-1)
1937
1938/** Trace buffer handle.
1939 * @remarks This is not a R3/R0 type like most other handles!
1940 */
1941typedef struct RTTRACEBUFINT *RTTRACEBUF;
1942/** Pointer to a trace buffer handle. */
1943typedef RTTRACEBUF *PRTTRACEBUF;
1944/** Nil trace buffer handle. */
1945#define NIL_RTTRACEBUF ((RTTRACEBUF)0)
1946/** The handle of the default trace buffer.
1947 * This can be used with any of the RTTraceBufAdd APIs. */
1948#define RTTRACEBUF_DEFAULT ((RTTRACEBUF)-2)
1949
1950/** Handle to a simple heap. */
1951typedef R3R0PTRTYPE(struct RTHEAPSIMPLEINTERNAL *) RTHEAPSIMPLE;
1952/** Pointer to a handle to a simple heap. */
1953typedef RTHEAPSIMPLE *PRTHEAPSIMPLE;
1954/** NIL simple heap handle. */
1955#define NIL_RTHEAPSIMPLE ((RTHEAPSIMPLE)0)
1956
1957/** Handle to an offset based heap. */
1958typedef R3R0PTRTYPE(struct RTHEAPOFFSETINTERNAL *) RTHEAPOFFSET;
1959/** Pointer to a handle to an offset based heap. */
1960typedef RTHEAPOFFSET *PRTHEAPOFFSET;
1961/** NIL offset based heap handle. */
1962#define NIL_RTHEAPOFFSET ((RTHEAPOFFSET)0)
1963
1964/** Handle to an environment block. */
1965typedef R3PTRTYPE(struct RTENVINTERNAL *) RTENV;
1966/** Pointer to a handle to an environment block. */
1967typedef RTENV *PRTENV;
1968/** NIL simple heap handle. */
1969#define NIL_RTENV ((RTENV)0)
1970
1971/** A CPU identifier.
1972 * @remarks This doesn't have to correspond to the APIC ID (intel/amd). Nor
1973 * does it have to correspond to the bits in the affinity mask, at
1974 * least not until we've sorted out Windows NT. */
1975typedef uint32_t RTCPUID;
1976/** Pointer to a CPU identifier. */
1977typedef RTCPUID *PRTCPUID;
1978/** Pointer to a const CPU identifier. */
1979typedef RTCPUID const *PCRTCPUID;
1980/** Nil CPU Id. */
1981#define NIL_RTCPUID ((RTCPUID)~0)
1982
1983/** The maximum number of CPUs a set can contain and IPRT is able
1984 * to reference. (Should be max of support arch/platforms.)
1985 * @remarks Must be a multiple of 64 (see RTCPUSET). */
1986#if defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)
1987# define RTCPUSET_MAX_CPUS 256
1988#elif defined(RT_ARCH_SPARC) || defined(RT_ARCH_SPARC64)
1989# define RTCPUSET_MAX_CPUS 1024
1990#else
1991# define RTCPUSET_MAX_CPUS 64
1992#endif
1993/** A CPU set.
1994 * @note Treat this as an opaque type and always use RTCpuSet* for
1995 * manipulating it. */
1996typedef struct RTCPUSET
1997{
1998 /** The bitmap. */
1999 uint64_t bmSet[RTCPUSET_MAX_CPUS / 64];
2000} RTCPUSET;
2001/** Pointer to a CPU set. */
2002typedef RTCPUSET *PRTCPUSET;
2003/** Pointer to a const CPU set. */
2004typedef RTCPUSET const *PCRTCPUSET;
2005
2006/** A handle table handle. */
2007typedef R3R0PTRTYPE(struct RTHANDLETABLEINT *) RTHANDLETABLE;
2008/** A pointer to a handle table handle. */
2009typedef RTHANDLETABLE *PRTHANDLETABLE;
2010/** @def NIL_RTHANDLETABLE
2011 * NIL handle table handle. */
2012#define NIL_RTHANDLETABLE ((RTHANDLETABLE)0)
2013
2014/** A handle to a low resolution timer. */
2015typedef R3R0PTRTYPE(struct RTTIMERLRINT *) RTTIMERLR;
2016/** A pointer to a low resolution timer handle. */
2017typedef RTTIMERLR *PRTTIMERLR;
2018/** @def NIL_RTTIMERLR
2019 * NIL low resolution timer handle value. */
2020#define NIL_RTTIMERLR ((RTTIMERLR)0)
2021
2022/** Handle to a random number generator. */
2023typedef R3R0PTRTYPE(struct RTRANDINT *) RTRAND;
2024/** Pointer to a random number generator handle. */
2025typedef RTRAND *PRTRAND;
2026/** NIL random number generator handle value. */
2027#define NIL_RTRAND ((RTRAND)0)
2028
2029/** Debug address space handle. */
2030typedef R3R0PTRTYPE(struct RTDBGASINT *) RTDBGAS;
2031/** Pointer to a debug address space handle. */
2032typedef RTDBGAS *PRTDBGAS;
2033/** NIL debug address space handle. */
2034#define NIL_RTDBGAS ((RTDBGAS)0)
2035
2036/** Debug module handle. */
2037typedef R3R0PTRTYPE(struct RTDBGMODINT *) RTDBGMOD;
2038/** Pointer to a debug module handle. */
2039typedef RTDBGMOD *PRTDBGMOD;
2040/** NIL debug module handle. */
2041#define NIL_RTDBGMOD ((RTDBGMOD)0)
2042
2043/** Manifest handle. */
2044typedef struct RTMANIFESTINT *RTMANIFEST;
2045/** Pointer to a manifest handle. */
2046typedef RTMANIFEST *PRTMANIFEST;
2047/** NIL manifest handle. */
2048#define NIL_RTMANIFEST ((RTMANIFEST)~(uintptr_t)0)
2049
2050/** Memory pool handle. */
2051typedef R3R0PTRTYPE(struct RTMEMPOOLINT *) RTMEMPOOL;
2052/** Pointer to a memory pool handle. */
2053typedef RTMEMPOOL *PRTMEMPOOL;
2054/** NIL memory pool handle. */
2055#define NIL_RTMEMPOOL ((RTMEMPOOL)0)
2056/** The default memory pool handle. */
2057#define RTMEMPOOL_DEFAULT ((RTMEMPOOL)-2)
2058
2059/** String cache handle. */
2060typedef R3R0PTRTYPE(struct RTSTRCACHEINT *) RTSTRCACHE;
2061/** Pointer to a string cache handle. */
2062typedef RTSTRCACHE *PRTSTRCACHE;
2063/** NIL string cache handle. */
2064#define NIL_RTSTRCACHE ((RTSTRCACHE)0)
2065/** The default string cache handle. */
2066#define RTSTRCACHE_DEFAULT ((RTSTRCACHE)-2)
2067
2068
2069/** Virtual Filesystem handle. */
2070typedef struct RTVFSINTERNAL *RTVFS;
2071/** Pointer to a VFS handle. */
2072typedef RTVFS *PRTVFS;
2073/** A NIL VFS handle. */
2074#define NIL_RTVFS ((RTVFS)~(uintptr_t)0)
2075
2076/** Virtual Filesystem base object handle. */
2077typedef struct RTVFSOBJINTERNAL *RTVFSOBJ;
2078/** Pointer to a VFS base object handle. */
2079typedef RTVFSOBJ *PRTVFSOBJ;
2080/** A NIL VFS base object handle. */
2081#define NIL_RTVFSOBJ ((RTVFSOBJ)~(uintptr_t)0)
2082
2083/** Virtual Filesystem directory handle. */
2084typedef struct RTVFSDIRINTERNAL *RTVFSDIR;
2085/** Pointer to a VFS directory handle. */
2086typedef RTVFSDIR *PRTVFSDIR;
2087/** A NIL VFS directory handle. */
2088#define NIL_RTVFSDIR ((RTVFSDIR)~(uintptr_t)0)
2089
2090/** Virtual Filesystem filesystem stream handle. */
2091typedef struct RTVFSFSSTREAMINTERNAL *RTVFSFSSTREAM;
2092/** Pointer to a VFS filesystem stream handle. */
2093typedef RTVFSFSSTREAM *PRTVFSFSSTREAM;
2094/** A NIL VFS filesystem stream handle. */
2095#define NIL_RTVFSFSSTREAM ((RTVFSFSSTREAM)~(uintptr_t)0)
2096
2097/** Virtual Filesystem I/O stream handle. */
2098typedef struct RTVFSIOSTREAMINTERNAL *RTVFSIOSTREAM;
2099/** Pointer to a VFS I/O stream handle. */
2100typedef RTVFSIOSTREAM *PRTVFSIOSTREAM;
2101/** A NIL VFS I/O stream handle. */
2102#define NIL_RTVFSIOSTREAM ((RTVFSIOSTREAM)~(uintptr_t)0)
2103
2104/** Virtual Filesystem file handle. */
2105typedef struct RTVFSFILEINTERNAL *RTVFSFILE;
2106/** Pointer to a VFS file handle. */
2107typedef RTVFSFILE *PRTVFSFILE;
2108/** A NIL VFS file handle. */
2109#define NIL_RTVFSFILE ((RTVFSFILE)~(uintptr_t)0)
2110
2111/** Virtual Filesystem symbolic link handle. */
2112typedef struct RTVFSSYMLINKINTERNAL *RTVFSSYMLINK;
2113/** Pointer to a VFS symbolic link handle. */
2114typedef RTVFSSYMLINK *PRTVFSSYMLINK;
2115/** A NIL VFS symbolic link handle. */
2116#define NIL_RTVFSSYMLINK ((RTVFSSYMLINK)~(uintptr_t)0)
2117
2118/** Async I/O manager handle. */
2119typedef struct RTAIOMGRINT *RTAIOMGR;
2120/** Pointer to a async I/O manager handle. */
2121typedef RTAIOMGR *PRTAIOMGR;
2122/** A NIL async I/O manager handle. */
2123#define NIL_RTAIOMGR ((RTAIOMGR)~(uintptr_t)0)
2124
2125/** Async I/O manager file handle. */
2126typedef struct RTAIOMGRFILEINT *RTAIOMGRFILE;
2127/** Pointer to a async I/O manager file handle. */
2128typedef RTAIOMGRFILE *PRTAIOMGRFILE;
2129/** A NIL async I/O manager file handle. */
2130#define NIL_RTAIOMGRFILE ((RTAIOMGRFILE)~(uintptr_t)0)
2131
2132/**
2133 * Handle type.
2134 *
2135 * This is usually used together with RTHANDLEUNION.
2136 */
2137typedef enum RTHANDLETYPE
2138{
2139 /** The invalid zero value. */
2140 RTHANDLETYPE_INVALID = 0,
2141 /** File handle. */
2142 RTHANDLETYPE_FILE,
2143 /** Pipe handle */
2144 RTHANDLETYPE_PIPE,
2145 /** Socket handle. */
2146 RTHANDLETYPE_SOCKET,
2147 /** Thread handle. */
2148 RTHANDLETYPE_THREAD,
2149 /** The end of the valid values. */
2150 RTHANDLETYPE_END,
2151 /** The 32-bit type blow up. */
2152 RTHANDLETYPE_32BIT_HACK = 0x7fffffff
2153} RTHANDLETYPE;
2154/** Pointer to a handle type. */
2155typedef RTHANDLETYPE *PRTHANDLETYPE;
2156
2157/**
2158 * Handle union.
2159 *
2160 * This is usually used together with RTHANDLETYPE or as RTHANDLE.
2161 */
2162typedef union RTHANDLEUNION
2163{
2164 RTFILE hFile; /**< File handle. */
2165 RTPIPE hPipe; /**< Pipe handle. */
2166 RTSOCKET hSocket; /**< Socket handle. */
2167 RTTHREAD hThread; /**< Thread handle. */
2168 /** Generic integer handle value.
2169 * Note that RTFILE is not yet pointer sized, so accessing it via this member
2170 * isn't necessarily safe or fully portable. */
2171 RTHCUINTPTR uInt;
2172} RTHANDLEUNION;
2173/** Pointer to a handle union. */
2174typedef RTHANDLEUNION *PRTHANDLEUNION;
2175/** Pointer to a const handle union. */
2176typedef RTHANDLEUNION const *PCRTHANDLEUNION;
2177
2178/**
2179 * Generic handle.
2180 */
2181typedef struct RTHANDLE
2182{
2183 /** The handle type. */
2184 RTHANDLETYPE enmType;
2185 /** The handle value. */
2186 RTHANDLEUNION u;
2187} RTHANDLE;
2188/** Pointer to a generic handle. */
2189typedef RTHANDLE *PRTHANDLE;
2190/** Pointer to a const generic handle. */
2191typedef RTHANDLE const *PCRTHANDLE;
2192
2193
2194/**
2195 * Standard handles.
2196 *
2197 * @remarks These have the correct file descriptor values for unixy systems and
2198 * can be used directly in code specific to those platforms.
2199 */
2200typedef enum RTHANDLESTD
2201{
2202 /** Invalid standard handle. */
2203 RTHANDLESTD_INVALID = -1,
2204 /** The standard input handle. */
2205 RTHANDLESTD_INPUT = 0,
2206 /** The standard output handle. */
2207 RTHANDLESTD_OUTPUT,
2208 /** The standard error handle. */
2209 RTHANDLESTD_ERROR,
2210 /** The typical 32-bit type hack. */
2211 RTHANDLESTD_32BIT_HACK = 0x7fffffff
2212} RTHANDLESTD;
2213
2214
2215/**
2216 * Error info.
2217 *
2218 * See RTErrInfo*.
2219 */
2220typedef struct RTERRINFO
2221{
2222 /** Flags, see RTERRINFO_FLAGS_XXX. */
2223 uint32_t fFlags;
2224 /** The status code. */
2225 int32_t rc;
2226 /** The size of the message */
2227 size_t cbMsg;
2228 /** The error buffer. */
2229 char *pszMsg;
2230 /** Reserved for future use. */
2231 void *apvReserved[2];
2232} RTERRINFO;
2233/** Pointer to an error info structure. */
2234typedef RTERRINFO *PRTERRINFO;
2235/** Pointer to a const error info structure. */
2236typedef RTERRINFO const *PCRTERRINFO;
2237
2238/**
2239 * Static error info structure, see RTErrInfoInitStatic.
2240 */
2241typedef struct RTERRINFOSTATIC
2242{
2243 /** The core error info. */
2244 RTERRINFO Core;
2245 /** The static message buffer. */
2246 char szMsg[3072];
2247} RTERRINFOSTATIC;
2248/** Pointer to a error info buffer. */
2249typedef RTERRINFOSTATIC *PRTERRINFOSTATIC;
2250/** Pointer to a const static error info buffer. */
2251typedef RTERRINFOSTATIC const *PCRTERRINFOSTATIC;
2252
2253
2254/**
2255 * UUID data type.
2256 *
2257 * See RTUuid*.
2258 *
2259 * @remarks IPRT defines that the first three integers in the @c Gen struct
2260 * interpretation are in little endian representation. This is
2261 * different to many other UUID implementation, and requires
2262 * conversion if you need to achieve consistent results.
2263 */
2264typedef union RTUUID
2265{
2266 /** 8-bit view. */
2267 uint8_t au8[16];
2268 /** 16-bit view. */
2269 uint16_t au16[8];
2270 /** 32-bit view. */
2271 uint32_t au32[4];
2272 /** 64-bit view. */
2273 uint64_t au64[2];
2274 /** The way the UUID is declared by the DCE specification. */
2275 struct
2276 {
2277 uint32_t u32TimeLow;
2278 uint16_t u16TimeMid;
2279 uint16_t u16TimeHiAndVersion;
2280 uint8_t u8ClockSeqHiAndReserved;
2281 uint8_t u8ClockSeqLow;
2282 uint8_t au8Node[6];
2283 } Gen;
2284} RTUUID;
2285/** Pointer to UUID data. */
2286typedef RTUUID *PRTUUID;
2287/** Pointer to readonly UUID data. */
2288typedef const RTUUID *PCRTUUID;
2289
2290/** Initializes a RTUUID structure with all zeros (RTUuidIsNull() true). */
2291#define RTUUID_INITIALIZE_NULL { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
2292
2293/** UUID string maximum length. */
2294#define RTUUID_STR_LENGTH 37
2295
2296
2297/** Compression handle. */
2298typedef struct RTZIPCOMP *PRTZIPCOMP;
2299/** Decompressor handle. */
2300typedef struct RTZIPDECOMP *PRTZIPDECOMP;
2301
2302
2303/**
2304 * Unicode Code Point.
2305 */
2306typedef uint32_t RTUNICP;
2307/** Pointer to an Unicode Code Point. */
2308typedef RTUNICP *PRTUNICP;
2309/** Pointer to an Unicode Code Point. */
2310typedef const RTUNICP *PCRTUNICP;
2311/** Max value a RTUNICP type can hold. */
2312#define RTUNICP_MAX ( ~(RTUNICP)0 )
2313/** Invalid code point.
2314 * This is returned when encountered invalid encodings or invalid
2315 * unicode code points. */
2316#define RTUNICP_INVALID ( UINT32_C(0xfffffffe) )
2317
2318
2319/**
2320 * UTF-16 character.
2321 * @remark wchar_t is not usable since it's compiler defined.
2322 * @remark When we use the term character we're not talking about unicode code point, but
2323 * the basic unit of the string encoding. Thus cwc - count of wide chars - means
2324 * count of RTUTF16; cuc - count of unicode chars - means count of RTUNICP;
2325 * and cch means count of the typedef 'char', which is assumed to be an octet.
2326 */
2327typedef uint16_t RTUTF16;
2328/** Pointer to a UTF-16 character. */
2329typedef RTUTF16 *PRTUTF16;
2330/** Pointer to a const UTF-16 character. */
2331typedef const RTUTF16 *PCRTUTF16;
2332
2333
2334/**
2335 * String tuple to go with the RT_STR_TUPLE macro.
2336 */
2337typedef struct RTSTRTUPLE
2338{
2339 /** The string. */
2340 const char *psz;
2341 /** The string length. */
2342 size_t cch;
2343} RTSTRTUPLE;
2344/** Pointer to a string tuple. */
2345typedef RTSTRTUPLE *PRTSTRTUPLE;
2346/** Pointer to a const string tuple. */
2347typedef RTSTRTUPLE const *PCRTSTRTUPLE;
2348
2349/**
2350 * Wait for ever if we have to.
2351 */
2352#define RT_INDEFINITE_WAIT (~0U)
2353
2354
2355/**
2356 * Generic process callback.
2357 *
2358 * @returns VBox status code. Failure will cancel the operation.
2359 * @param uPercentage The percentage of the operation which has been completed.
2360 * @param pvUser The user specified argument.
2361 */
2362typedef DECLCALLBACK(int) FNRTPROGRESS(unsigned uPrecentage, void *pvUser);
2363/** Pointer to a generic progress callback function, FNRTPROCESS(). */
2364typedef FNRTPROGRESS *PFNRTPROGRESS;
2365
2366/**
2367 * Generic vprintf-like callback function for dumpers.
2368 *
2369 * @param pvUser User argument.
2370 * @param pszFormat The format string.
2371 * @param va Arguments for the format string.
2372 */
2373typedef DECLCALLBACK(void) FNRTDUMPPRINTFV(void *pvUser, const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(2, 0);
2374/** Pointer to a generic printf-like function for dumping. */
2375typedef FNRTDUMPPRINTFV *PFNRTDUMPPRINTFV;
2376
2377
2378/**
2379 * A point in a two dimentional coordinate system.
2380 */
2381typedef struct RTPOINT
2382{
2383 /** X coordinate. */
2384 int32_t x;
2385 /** Y coordinate. */
2386 int32_t y;
2387} RTPOINT;
2388/** Pointer to a point. */
2389typedef RTPOINT *PRTPOINT;
2390/** Pointer to a const point. */
2391typedef const RTPOINT *PCRTPOINT;
2392
2393
2394/**
2395 * Rectangle data type, double point.
2396 */
2397typedef struct RTRECT
2398{
2399 /** left X coordinate. */
2400 int32_t xLeft;
2401 /** top Y coordinate. */
2402 int32_t yTop;
2403 /** right X coordinate. (exclusive) */
2404 int32_t xRight;
2405 /** bottom Y coordinate. (exclusive) */
2406 int32_t yBottom;
2407} RTRECT;
2408/** Pointer to a double point rectangle. */
2409typedef RTRECT *PRTRECT;
2410/** Pointer to a const double point rectangle. */
2411typedef const RTRECT *PCRTRECT;
2412
2413
2414/**
2415 * Rectangle data type, point + size.
2416 */
2417typedef struct RTRECT2
2418{
2419 /** X coordinate.
2420 * Unless stated otherwise, this is the top left corner. */
2421 int32_t x;
2422 /** Y coordinate.
2423 * Unless stated otherwise, this is the top left corner. */
2424 int32_t y;
2425 /** The width.
2426 * Unless stated otherwise, this is to the right of (x,y) and will not
2427 * be a negative number. */
2428 int32_t cx;
2429 /** The height.
2430 * Unless stated otherwise, this is down from (x,y) and will not be a
2431 * negative number. */
2432 int32_t cy;
2433} RTRECT2;
2434/** Pointer to a point + size rectangle. */
2435typedef RTRECT2 *PRTRECT2;
2436/** Pointer to a const point + size rectangle. */
2437typedef const RTRECT2 *PCRTRECT2;
2438
2439
2440/**
2441 * The size of a rectangle.
2442 */
2443typedef struct RTRECTSIZE
2444{
2445 /** The width (along the x-axis). */
2446 uint32_t cx;
2447 /** The height (along the y-axis). */
2448 uint32_t cy;
2449} RTRECTSIZE;
2450/** Pointer to a rectangle size. */
2451typedef RTRECTSIZE *PRTRECTSIZE;
2452/** Pointer to a const rectangle size. */
2453typedef const RTRECTSIZE *PCRTRECTSIZE;
2454
2455
2456/**
2457 * Ethernet MAC address.
2458 *
2459 * The first 24 bits make up the Organisationally Unique Identifier (OUI),
2460 * where the first bit (little endian) indicates multicast (set) / unicast,
2461 * and the second bit indicates locally (set) / global administered. If all
2462 * bits are set, it's a broadcast.
2463 */
2464typedef union RTMAC
2465{
2466 /** @todo add a bitfield view of this stuff. */
2467 /** 8-bit view. */
2468 uint8_t au8[6];
2469 /** 16-bit view. */
2470 uint16_t au16[3];
2471} RTMAC;
2472/** Pointer to a MAC address. */
2473typedef RTMAC *PRTMAC;
2474/** Pointer to a readonly MAC address. */
2475typedef const RTMAC *PCRTMAC;
2476
2477
2478/** Pointer to a lock validator record.
2479 * The structure definition is found in iprt/lockvalidator.h. */
2480typedef struct RTLOCKVALRECEXCL *PRTLOCKVALRECEXCL;
2481/** Pointer to a record of one ownership share.
2482 * The structure definition is found in iprt/lockvalidator.h. */
2483typedef struct RTLOCKVALRECSHRD *PRTLOCKVALRECSHRD;
2484/** Pointer to a lock validator source position.
2485 * The structure definition is found in iprt/lockvalidator.h. */
2486typedef struct RTLOCKVALSRCPOS *PRTLOCKVALSRCPOS;
2487/** Pointer to a const lock validator source position.
2488 * The structure definition is found in iprt/lockvalidator.h. */
2489typedef struct RTLOCKVALSRCPOS const *PCRTLOCKVALSRCPOS;
2490
2491/** @name Special sub-class values.
2492 * The range 16..UINT32_MAX is available to the user, the range 0..15 is
2493 * reserved for the lock validator. In the user range the locks can only be
2494 * taking in ascending order.
2495 * @{ */
2496/** Invalid value. */
2497#define RTLOCKVAL_SUB_CLASS_INVALID UINT32_C(0)
2498/** Not allowed to be taken with any other locks in the same class.
2499 * This is the recommended value. */
2500#define RTLOCKVAL_SUB_CLASS_NONE UINT32_C(1)
2501/** Any order is allowed within the class. */
2502#define RTLOCKVAL_SUB_CLASS_ANY UINT32_C(2)
2503/** The first user value. */
2504#define RTLOCKVAL_SUB_CLASS_USER UINT32_C(16)
2505/** @} */
2506
2507
2508/**
2509 * Digest types.
2510 */
2511typedef enum RTDIGESTTYPE
2512{
2513 /** Invalid digest value. */
2514 RTDIGESTTYPE_INVALID = 0,
2515 /** Unknown digest type. */
2516 RTDIGESTTYPE_UNKNOWN,
2517 /** CRC32 checksum. */
2518 RTDIGESTTYPE_CRC32,
2519 /** CRC64 checksum. */
2520 RTDIGESTTYPE_CRC64,
2521 /** MD2 checksum (unsafe!). */
2522 RTDIGESTTYPE_MD2,
2523 /** MD4 checksum (unsafe!!). */
2524 RTDIGESTTYPE_MD4,
2525 /** MD5 checksum (unsafe!). */
2526 RTDIGESTTYPE_MD5,
2527 /** SHA-1 checksum (unsafe!). */
2528 RTDIGESTTYPE_SHA1,
2529 /** SHA-224 checksum. */
2530 RTDIGESTTYPE_SHA224,
2531 /** SHA-256 checksum. */
2532 RTDIGESTTYPE_SHA256,
2533 /** SHA-384 checksum. */
2534 RTDIGESTTYPE_SHA384,
2535 /** SHA-512 checksum. */
2536 RTDIGESTTYPE_SHA512,
2537 /** SHA-512/224 checksum. */
2538 RTDIGESTTYPE_SHA512T224,
2539 /** SHA-512/256 checksum. */
2540 RTDIGESTTYPE_SHA512T256,
2541 /** End of valid types. */
2542 RTDIGESTTYPE_END,
2543 /** Usual 32-bit type blowup. */
2544 RTDIGESTTYPE_32BIT_HACK = 0x7fffffff
2545} RTDIGESTTYPE;
2546
2547/**
2548 * Process exit codes.
2549 */
2550typedef enum RTEXITCODE
2551{
2552 /** Success. */
2553 RTEXITCODE_SUCCESS = 0,
2554 /** General failure. */
2555 RTEXITCODE_FAILURE = 1,
2556 /** Invalid arguments. */
2557 RTEXITCODE_SYNTAX = 2,
2558 /** Initialization failure (usually IPRT, but could be used for other
2559 * components as well). */
2560 RTEXITCODE_INIT = 3,
2561 /** Test skipped. */
2562 RTEXITCODE_SKIPPED = 4,
2563 /** The end of valid exit codes. */
2564 RTEXITCODE_END,
2565 /** The usual 32-bit type hack. */
2566 RTEXITCODE_32BIT_HACK = 0x7fffffff
2567} RTEXITCODE;
2568
2569/**
2570 * Range descriptor.
2571 */
2572typedef struct RTRANGE
2573{
2574 /** Start offset. */
2575 uint64_t offStart;
2576 /** Range size. */
2577 size_t cbRange;
2578} RTRANGE;
2579/** Pointer to a range descriptor. */
2580typedef RTRANGE *PRTRANGE;
2581/** Pointer to a readonly range descriptor. */
2582typedef const RTRANGE *PCRTRANGE;
2583
2584
2585/**
2586 * Generic pointer union.
2587 */
2588typedef union RTPTRUNION
2589{
2590 /** Pointer into the void. */
2591 void *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 *pch;
2598 /** Pointer to char value. */
2599 unsigned char *puch;
2600 /** Pointer to a int value. */
2601 int *pi;
2602 /** Pointer to a unsigned int value. */
2603 unsigned int *pu;
2604 /** Pointer to a long value. */
2605 long *pl;
2606 /** Pointer to a long value. */
2607 unsigned long *pul;
2608 /** Pointer to a 8-bit unsigned value. */
2609 uint8_t *pu8;
2610 /** Pointer to a 16-bit unsigned value. */
2611 uint16_t *pu16;
2612 /** Pointer to a 32-bit unsigned value. */
2613 uint32_t *pu32;
2614 /** Pointer to a 64-bit unsigned value. */
2615 uint64_t *pu64;
2616 /** Pointer to a UTF-16 character. */
2617 PRTUTF16 pwc;
2618 /** Pointer to a UUID character. */
2619 PRTUUID pUuid;
2620} RTPTRUNION;
2621/** Pointer to a pointer union. */
2622typedef RTPTRUNION *PRTPTRUNION;
2623
2624/**
2625 * Generic const pointer union.
2626 */
2627typedef union RTCPTRUNION
2628{
2629 /** Pointer into the void. */
2630 void const *pv;
2631 /** As a signed integer. */
2632 intptr_t i;
2633 /** As an unsigned integer. */
2634 intptr_t u;
2635 /** Pointer to char value. */
2636 char const *pch;
2637 /** Pointer to char value. */
2638 unsigned char const *puch;
2639 /** Pointer to a int value. */
2640 int const *pi;
2641 /** Pointer to a unsigned int value. */
2642 unsigned int const *pu;
2643 /** Pointer to a long value. */
2644 long const *pl;
2645 /** Pointer to a long value. */
2646 unsigned long const *pul;
2647 /** Pointer to a 8-bit unsigned value. */
2648 uint8_t const *pu8;
2649 /** Pointer to a 16-bit unsigned value. */
2650 uint16_t const *pu16;
2651 /** Pointer to a 32-bit unsigned value. */
2652 uint32_t const *pu32;
2653 /** Pointer to a 64-bit unsigned value. */
2654 uint64_t const *pu64;
2655 /** Pointer to a UTF-16 character. */
2656 PCRTUTF16 pwc;
2657 /** Pointer to a UUID character. */
2658 PCRTUUID pUuid;
2659} RTCPTRUNION;
2660/** Pointer to a const pointer union. */
2661typedef RTCPTRUNION *PRTCPTRUNION;
2662
2663/**
2664 * Generic volatile pointer union.
2665 */
2666typedef union RTVPTRUNION
2667{
2668 /** Pointer into the void. */
2669 void volatile *pv;
2670 /** As a signed integer. */
2671 intptr_t i;
2672 /** As an unsigned integer. */
2673 intptr_t u;
2674 /** Pointer to char value. */
2675 char volatile *pch;
2676 /** Pointer to char value. */
2677 unsigned char volatile *puch;
2678 /** Pointer to a int value. */
2679 int volatile *pi;
2680 /** Pointer to a unsigned int value. */
2681 unsigned int volatile *pu;
2682 /** Pointer to a long value. */
2683 long volatile *pl;
2684 /** Pointer to a long value. */
2685 unsigned long volatile *pul;
2686 /** Pointer to a 8-bit unsigned value. */
2687 uint8_t volatile *pu8;
2688 /** Pointer to a 16-bit unsigned value. */
2689 uint16_t volatile *pu16;
2690 /** Pointer to a 32-bit unsigned value. */
2691 uint32_t volatile *pu32;
2692 /** Pointer to a 64-bit unsigned value. */
2693 uint64_t volatile *pu64;
2694 /** Pointer to a UTF-16 character. */
2695 RTUTF16 volatile *pwc;
2696 /** Pointer to a UUID character. */
2697 RTUUID volatile *pUuid;
2698} RTVPTRUNION;
2699/** Pointer to a const pointer union. */
2700typedef RTVPTRUNION *PRTVPTRUNION;
2701
2702/**
2703 * Generic const volatile pointer union.
2704 */
2705typedef union RTCVPTRUNION
2706{
2707 /** Pointer into the void. */
2708 void const volatile *pv;
2709 /** As a signed integer. */
2710 intptr_t i;
2711 /** As an unsigned integer. */
2712 intptr_t u;
2713 /** Pointer to char value. */
2714 char const volatile *pch;
2715 /** Pointer to char value. */
2716 unsigned char const volatile *puch;
2717 /** Pointer to a int value. */
2718 int const volatile *pi;
2719 /** Pointer to a unsigned int value. */
2720 unsigned int const volatile *pu;
2721 /** Pointer to a long value. */
2722 long const volatile *pl;
2723 /** Pointer to a long value. */
2724 unsigned long const volatile *pul;
2725 /** Pointer to a 8-bit unsigned value. */
2726 uint8_t const volatile *pu8;
2727 /** Pointer to a 16-bit unsigned value. */
2728 uint16_t const volatile *pu16;
2729 /** Pointer to a 32-bit unsigned value. */
2730 uint32_t const volatile *pu32;
2731 /** Pointer to a 64-bit unsigned value. */
2732 uint64_t const volatile *pu64;
2733 /** Pointer to a UTF-16 character. */
2734 RTUTF16 const volatile *pwc;
2735 /** Pointer to a UUID character. */
2736 RTUUID const volatile *pUuid;
2737} RTCVPTRUNION;
2738/** Pointer to a const pointer union. */
2739typedef RTCVPTRUNION *PRTCVPTRUNION;
2740
2741
2742
2743#ifdef __cplusplus
2744/**
2745 * Strict type validation helper class.
2746 *
2747 * See RTErrStrictType and RT_SUCCESS_NP.
2748 */
2749class RTErrStrictType2
2750{
2751protected:
2752 /** The status code. */
2753 int32_t m_rc;
2754
2755public:
2756 /**
2757 * Constructor.
2758 * @param rc IPRT style status code.
2759 */
2760 RTErrStrictType2(int32_t rc) : m_rc(rc)
2761 {
2762 }
2763
2764 /**
2765 * Get the status code.
2766 * @returns IPRT style status code.
2767 */
2768 int32_t getValue() const
2769 {
2770 return m_rc;
2771 }
2772};
2773#endif /* __cplusplus */
2774/** @} */
2775
2776#endif
2777
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