VirtualBox

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

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

iprt/types.h: NetBSD-6 <sys/types.h> doesn't check for C++ when
defining bool, work around that. Also fix the cpp guard on
<stdbool.h> inclusion so that NetBSD R0 code doesn't fall through to
the #else that always redefines bool.

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