VirtualBox

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

Last change on this file since 39798 was 39138, checked in by vboxsync, 13 years ago

iprt/types.h,IEM: Moved the pointer union types to iprt/types.h, adding volatile versions of it.

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