VirtualBox

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

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

scm cleanups

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