VirtualBox

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

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

iprt/types.h: Kludge for NetBSD-6.x where <sys/types.h> does not
define ptrdiff_t for the kernel code. Note that we don't worry about
redefinition in <stddef.h> since that header doesn't exist for _KERNEL
code.

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