VirtualBox

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

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

iprt/types.h: NetBSD support based on a patch from Arto Huusko.

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