VirtualBox

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

Last change on this file since 94646 was 94612, checked in by vboxsync, 3 years ago

VMM/IEM,libs/softfloat,iprt/types.h: The bias adjust value is applied to both unmasked underflows as as well as overflow, reworked the softfloat_roundPackToExtF80 function to do it correct so the new fmul_r80_by_r80 works right. bugref:9898

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 123.7 KB
Line 
1/** @file
2 * IPRT - Types.
3 */
4
5/*
6 * Copyright (C) 2006-2022 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_INCLUDED_types_h
27#define IPRT_INCLUDED_types_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <iprt/cdefs.h>
33#include <iprt/stdint.h>
34#include <iprt/stdarg.h>
35
36/*
37 * Include standard C types.
38 */
39#if !defined(IPRT_NO_CRT) && !defined(DOXYGEN_RUNNING)
40
41# if defined(IN_XF86_MODULE) && !defined(NO_ANSIC)
42 /*
43 * Kludge for xfree86 modules: size_t and other types are redefined.
44 */
45RT_C_DECLS_BEGIN
46# include "xf86_ansic.h"
47# undef NULL
48RT_C_DECLS_END
49
50# elif defined(RT_OS_DARWIN) && defined(KERNEL)
51 /*
52 * Kludge for the darwin kernel:
53 * stddef.h is missing IIRC.
54 */
55# ifndef _PTRDIFF_T
56# define _PTRDIFF_T
57 typedef __darwin_ptrdiff_t ptrdiff_t;
58# endif
59# include <sys/types.h>
60
61# elif defined(RT_OS_FREEBSD) && defined(_KERNEL)
62# include <sys/param.h>
63# undef PVM
64# if __FreeBSD_version < 1200000
65 /*
66 * Kludge for the FreeBSD kernel:
67 * stddef.h and sys/types.h have slightly different offsetof definitions
68 * when compiling in kernel mode. This is just to make GCC shut up.
69 */
70# ifndef _STDDEF_H_
71# undef offsetof
72# endif
73# include <sys/stddef.h>
74# ifndef _SYS_TYPES_H_
75# undef offsetof
76# endif
77# include <sys/types.h>
78# ifndef offsetof
79# error "offsetof is not defined!"
80# endif
81# else
82# include <sys/stddef.h>
83# include <sys/types.h>
84# endif
85
86# elif defined(RT_OS_FREEBSD) && HC_ARCH_BITS == 64 && defined(RT_ARCH_X86)
87 /*
88 * Kludge for compiling 32-bit code on a 64-bit FreeBSD:
89 * FreeBSD declares uint64_t and int64_t wrong (long unsigned and long int
90 * though they need to be long long unsigned and long long int). These
91 * defines conflict with our declaration in stdint.h. Adding the defines
92 * below omits the definitions in the system header.
93 */
94# include <stddef.h>
95# define _UINT64_T_DECLARED
96# define _INT64_T_DECLARED
97# define _UINTPTR_T_DECLARED
98# define _INTPTR_T_DECLARED
99# include <sys/types.h>
100
101# elif defined(RT_OS_NETBSD) && defined(_KERNEL)
102
103# include <sys/types.h>
104
105 /*
106 * Kludge for NetBSD-6.x where the definition of bool in
107 * <sys/types.h> does not check for C++.
108 */
109# if defined(__cplusplus) && defined(bool)
110# undef bool
111# undef true
112# undef false
113# endif
114
115 /*
116 * Kludge for NetBSD-6.x where <sys/types.h> does not define
117 * ptrdiff_t for the kernel code. Note that we don't worry about
118 * redefinition in <stddef.h> since that header doesn't exist for
119 * _KERNEL code.
120 */
121# ifdef _BSD_PTRDIFF_T_
122 typedef _BSD_PTRDIFF_T_ ptrdiff_t;
123# endif
124
125# elif defined(RT_OS_LINUX) && defined(__KERNEL__)
126 /*
127 * Kludge for the linux kernel:
128 * 1. sys/types.h doesn't mix with the kernel.
129 * 2. Starting with 2.6.19, linux/types.h typedefs bool and linux/stddef.h
130 * declares false and true as enum values.
131 * 3. Starting with 2.6.24, linux/types.h typedefs uintptr_t.
132 * We work around these issues here and nowhere else.
133 */
134# if defined(__cplusplus)
135 typedef bool _Bool;
136# endif
137# define bool linux_bool
138# define true linux_true
139# define false linux_false
140# define uintptr_t linux_uintptr_t
141# include <linux/version.h>
142# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
143# include <generated/autoconf.h>
144# else
145# ifndef AUTOCONF_INCLUDED
146# include <linux/autoconf.h>
147# endif
148# endif
149# include <linux/compiler.h>
150# if defined(__cplusplus)
151 /*
152 * Starting with 3.3, <linux/compiler-gcc.h> appends 'notrace' (which
153 * expands to __attribute__((no_instrument_function))) to inline,
154 * __inline and __inline__. Revert that.
155 */
156# undef inline
157# define inline inline
158# undef __inline__
159# define __inline__ __inline__
160# undef __inline
161# define __inline __inline
162# endif
163# include <linux/types.h>
164# include <linux/stddef.h>
165 /*
166 * Starting with 3.4, <linux/stddef.h> defines NULL as '((void*)0)' which
167 * does not work for C++ code.
168 */
169# undef NULL
170# undef uintptr_t
171# ifdef __GNUC__
172# if !RT_GNUC_PREREQ(4, 1)
173 /*
174 * <linux/compiler-gcc{3,4}.h> does
175 * #define __inline__ __inline__ __attribute__((always_inline))
176 * in some older Linux kernels. Forcing inlining will fail for some RTStrA*
177 * functions with gcc <= 4.0 due to passing variable argument lists.
178 */
179# undef __inline__
180# define __inline__ __inline__
181# endif
182# endif
183# undef false
184# undef true
185# undef bool
186
187# elif !defined(DOXYGEN_RUNNING) && RT_MSC_PREREQ(RT_MSC_VER_VC140) && defined(RT_OS_AGNOSTIC)
188 /* Try avoid needing the UCRT just for stddef.h and sys/types.h. */
189 /** @todo refine the RT_OS_AGNOSTIC test? */
190# include <vcruntime.h>
191
192# else
193# include <stddef.h>
194# include <sys/types.h>
195# endif
196
197
198/* Define any types missing from sys/types.h on Windows and OS/2. */
199# ifdef _MSC_VER
200# undef ssize_t
201typedef intptr_t ssize_t;
202# endif
203# if defined(RT_OS_OS2) && (defined(__IBMC__) || defined(__IBMCPP__))
204typedef signed long ssize_t;
205# endif
206
207#else /* no crt */
208# include <iprt/nocrt/compiler/compiler.h>
209#endif /* no crt */
210
211
212
213/** @def NULL
214 * NULL pointer.
215 */
216#ifndef NULL
217# ifdef __cplusplus
218# define NULL 0
219# else
220# define NULL ((void*)0)
221# endif
222#endif
223
224
225
226/** @defgroup grp_rt_types IPRT Base Types
227 * @{
228 */
229
230/* define wchar_t, we don't wanna include all the wcsstuff to get this. */
231#ifdef _MSC_VER
232# ifndef _WCHAR_T_DEFINED
233 typedef unsigned short wchar_t;
234# define _WCHAR_T_DEFINED
235# endif
236#endif
237#ifdef __GNUC__
238/** @todo wchar_t on GNUC */
239#endif
240
241/*
242 * C doesn't have bool, nor does VisualAge for C++ v3.08.
243 */
244#if !defined(__cplusplus) || (defined(__IBMCPP__) && defined(RT_OS_OS2))
245# if defined(__GNUC__)
246# if defined(RT_OS_LINUX) && __GNUC__ < 3
247typedef uint8_t bool;
248# elif defined(RT_OS_FREEBSD)
249# ifndef __bool_true_false_are_defined
250typedef _Bool bool;
251# endif
252# elif defined(RT_OS_NETBSD)
253# if !defined(_KERNEL)
254 /*
255 * For the kernel code <stdbool.h> is not available, but bool is
256 * provided by <sys/types.h> included above.
257 */
258# include <stdbool.h>
259
260 /*
261 * ... but the story doesn't end here. The C standard says that
262 * <stdbool.h> defines preprocessor macro "bool" that expands to
263 * "_Bool", but adds that a program may undefine/redefine it
264 * (this is 7.16 in C99 and 7.18 in C11). We have to play this
265 * game here because X11 code uses "bool" as a struct member name
266 * - so undefine "bool" and provide it as a typedef instead. We
267 * still keep #include <stdbool.h> so that any code that might
268 * include it later doesn't mess things up.
269 */
270# undef bool
271 typedef _Bool bool;
272# endif
273# else
274# undef bool /* see above netbsd explanation */
275typedef _Bool bool;
276# endif
277# else
278# if RT_MSC_PREREQ(RT_MSC_VER_VC120)
279# include <stdbool.h>
280# else
281typedef unsigned char bool;
282# endif
283# endif
284# ifndef true
285# define true (1)
286# endif
287# ifndef false
288# define false (0)
289# endif
290#endif
291
292
293/**
294 * 128-bit unsigned integer.
295 */
296#ifdef RT_COMPILER_WITH_128BIT_INT_TYPES
297typedef __uint128_t uint128_t;
298#else
299typedef struct uint128_s
300{
301# ifdef RT_BIG_ENDIAN
302 uint64_t Hi;
303 uint64_t Lo;
304# else
305 uint64_t Lo;
306 uint64_t Hi;
307# endif
308} uint128_t;
309#endif
310
311
312/**
313 * 128-bit signed integer.
314 */
315#ifdef RT_COMPILER_WITH_128BIT_INT_TYPES
316typedef __int128_t int128_t;
317#else
318typedef struct int128_s
319{
320# ifdef RT_BIG_ENDIAN
321 int64_t Hi;
322 uint64_t Lo;
323# else
324 uint64_t Lo;
325 int64_t Hi;
326# endif
327} int128_t;
328#endif
329
330
331/**
332 * 16-bit unsigned integer union.
333 */
334typedef union RTUINT16U
335{
336 /** natural view. */
337 uint16_t u;
338
339 /** 16-bit view. */
340 uint16_t au16[1];
341 /** 8-bit view. */
342 uint8_t au8[2];
343 /** 16-bit hi/lo view. */
344 struct
345 {
346#ifdef RT_BIG_ENDIAN
347 uint8_t Hi;
348 uint8_t Lo;
349#else
350 uint8_t Lo;
351 uint8_t Hi;
352#endif
353 } s;
354} RTUINT16U;
355/** Pointer to a 16-bit unsigned integer union. */
356typedef RTUINT16U RT_FAR *PRTUINT16U;
357/** Pointer to a const 32-bit unsigned integer union. */
358typedef const RTUINT16U RT_FAR *PCRTUINT16U;
359
360
361/**
362 * 32-bit unsigned integer union.
363 */
364typedef union RTUINT32U
365{
366 /** natural view. */
367 uint32_t u;
368 /** Hi/Low view. */
369 struct
370 {
371#ifdef RT_BIG_ENDIAN
372 uint16_t Hi;
373 uint16_t Lo;
374#else
375 uint16_t Lo;
376 uint16_t Hi;
377#endif
378 } s;
379 /** Word view. */
380 struct
381 {
382#ifdef RT_BIG_ENDIAN
383 uint16_t w1;
384 uint16_t w0;
385#else
386 uint16_t w0;
387 uint16_t w1;
388#endif
389 } Words;
390
391 /** 32-bit view. */
392 uint32_t au32[1];
393 /** 16-bit view. */
394 uint16_t au16[2];
395 /** 8-bit view. */
396 uint8_t au8[4];
397} RTUINT32U;
398/** Pointer to a 32-bit unsigned integer union. */
399typedef RTUINT32U RT_FAR *PRTUINT32U;
400/** Pointer to a const 32-bit unsigned integer union. */
401typedef const RTUINT32U RT_FAR *PCRTUINT32U;
402
403
404/**
405 * 64-bit unsigned integer union.
406 */
407typedef union RTUINT64U
408{
409 /** Natural view. */
410 uint64_t u;
411 /** Hi/Low view. */
412 struct
413 {
414#ifdef RT_BIG_ENDIAN
415 uint32_t Hi;
416 uint32_t Lo;
417#else
418 uint32_t Lo;
419 uint32_t Hi;
420#endif
421 } s;
422 /** Double-Word view. */
423 struct
424 {
425#ifdef RT_BIG_ENDIAN
426 uint32_t dw1;
427 uint32_t dw0;
428#else
429 uint32_t dw0;
430 uint32_t dw1;
431#endif
432 } DWords;
433 /** Word view. */
434 struct
435 {
436#ifdef RT_BIG_ENDIAN
437 uint16_t w3;
438 uint16_t w2;
439 uint16_t w1;
440 uint16_t w0;
441#else
442 uint16_t w0;
443 uint16_t w1;
444 uint16_t w2;
445 uint16_t w3;
446#endif
447 } Words;
448
449 /** 64-bit view. */
450 uint64_t au64[1];
451 /** 32-bit view. */
452 uint32_t au32[2];
453 /** 16-bit view. */
454 uint16_t au16[4];
455 /** 8-bit view. */
456 uint8_t au8[8];
457} RTUINT64U;
458/** Pointer to a 64-bit unsigned integer union. */
459typedef RTUINT64U RT_FAR *PRTUINT64U;
460/** Pointer to a const 64-bit unsigned integer union. */
461typedef const RTUINT64U RT_FAR *PCRTUINT64U;
462
463
464/**
465 * 128-bit unsigned integer union.
466 */
467#pragma pack(1)
468typedef union RTUINT128U
469{
470 /** Hi/Low view.
471 * @remarks We put this first so we can have portable initializers
472 * (RTUINT128_INIT) */
473 struct
474 {
475#ifdef RT_BIG_ENDIAN
476 uint64_t Hi;
477 uint64_t Lo;
478#else
479 uint64_t Lo;
480 uint64_t Hi;
481#endif
482 } s;
483
484 /** Natural view.
485 * WARNING! This member depends on the compiler supporting 128-bit stuff. */
486 uint128_t u;
487
488 /** Quad-Word view. */
489 struct
490 {
491#ifdef RT_BIG_ENDIAN
492 uint64_t qw1;
493 uint64_t qw0;
494#else
495 uint64_t qw0;
496 uint64_t qw1;
497#endif
498 } QWords;
499 /** Double-Word view. */
500 struct
501 {
502#ifdef RT_BIG_ENDIAN
503 uint32_t dw3;
504 uint32_t dw2;
505 uint32_t dw1;
506 uint32_t dw0;
507#else
508 uint32_t dw0;
509 uint32_t dw1;
510 uint32_t dw2;
511 uint32_t dw3;
512#endif
513 } DWords;
514 /** Word view. */
515 struct
516 {
517#ifdef RT_BIG_ENDIAN
518 uint16_t w7;
519 uint16_t w6;
520 uint16_t w5;
521 uint16_t w4;
522 uint16_t w3;
523 uint16_t w2;
524 uint16_t w1;
525 uint16_t w0;
526#else
527 uint16_t w0;
528 uint16_t w1;
529 uint16_t w2;
530 uint16_t w3;
531 uint16_t w4;
532 uint16_t w5;
533 uint16_t w6;
534 uint16_t w7;
535#endif
536 } Words;
537
538 /** 64-bit view. */
539 uint64_t au64[2];
540 /** 32-bit view. */
541 uint32_t au32[4];
542 /** 16-bit view. */
543 uint16_t au16[8];
544 /** 8-bit view. */
545 uint8_t au8[16];
546} RTUINT128U;
547#pragma pack()
548/** Pointer to a 128-bit unsigned integer union. */
549typedef RTUINT128U RT_FAR *PRTUINT128U;
550/** Pointer to a const 128-bit unsigned integer union. */
551typedef const RTUINT128U RT_FAR *PCRTUINT128U;
552
553/** @def RTUINT128_INIT
554 * Portable RTUINT128U initializer. */
555#ifdef RT_BIG_ENDIAN
556# define RTUINT128_INIT(a_Hi, a_Lo) { { a_Hi, a_Lo } }
557#else
558# define RTUINT128_INIT(a_Hi, a_Lo) { { a_Lo, a_Hi } }
559#endif
560
561/** @def RTUINT128_INIT_C
562 * Portable RTUINT128U initializer for 64-bit constants. */
563#ifdef RT_BIG_ENDIAN
564# define RTUINT128_INIT_C(a_Hi, a_Lo) { { UINT64_C(a_Hi), UINT64_C(a_Lo) } }
565#else
566# define RTUINT128_INIT_C(a_Hi, a_Lo) { { UINT64_C(a_Lo), UINT64_C(a_Hi) } }
567#endif
568
569
570/**
571 * 256-bit unsigned integer union.
572 */
573#pragma pack(1)
574typedef union RTUINT256U
575{
576 /** Quad-Word view (first as it's used by RTUINT256_INIT). */
577 struct
578 {
579#ifdef RT_BIG_ENDIAN
580 uint64_t qw3;
581 uint64_t qw2;
582 uint64_t qw1;
583 uint64_t qw0;
584#else
585 uint64_t qw0;
586 uint64_t qw1;
587 uint64_t qw2;
588 uint64_t qw3;
589#endif
590 } QWords;
591 /** Double-Word view. */
592 struct
593 {
594#ifdef RT_BIG_ENDIAN
595 uint32_t dw7;
596 uint32_t dw6;
597 uint32_t dw5;
598 uint32_t dw4;
599 uint32_t dw3;
600 uint32_t dw2;
601 uint32_t dw1;
602 uint32_t dw0;
603#else
604 uint32_t dw0;
605 uint32_t dw1;
606 uint32_t dw2;
607 uint32_t dw3;
608 uint32_t dw4;
609 uint32_t dw5;
610 uint32_t dw6;
611 uint32_t dw7;
612#endif
613 } DWords;
614 /** Word view. */
615 struct
616 {
617#ifdef RT_BIG_ENDIAN
618 uint16_t w15;
619 uint16_t w14;
620 uint16_t w13;
621 uint16_t w12;
622 uint16_t w11;
623 uint16_t w10;
624 uint16_t w9;
625 uint16_t w8;
626 uint16_t w7;
627 uint16_t w6;
628 uint16_t w5;
629 uint16_t w4;
630 uint16_t w3;
631 uint16_t w2;
632 uint16_t w1;
633 uint16_t w0;
634#else
635 uint16_t w0;
636 uint16_t w1;
637 uint16_t w2;
638 uint16_t w3;
639 uint16_t w4;
640 uint16_t w5;
641 uint16_t w6;
642 uint16_t w7;
643 uint16_t w8;
644 uint16_t w9;
645 uint16_t w10;
646 uint16_t w11;
647 uint16_t w12;
648 uint16_t w13;
649 uint16_t w14;
650 uint16_t w15;
651#endif
652 } Words;
653
654 /** Double-Quad-Word view. */
655 struct
656 {
657#ifdef RT_BIG_ENDIAN
658 RTUINT128U dqw1;
659 RTUINT128U dqw0;
660#else
661 RTUINT128U dqw0;
662 RTUINT128U dqw1;
663#endif
664 } DQWords;
665
666 /** 128-bit view. */
667 RTUINT128U au128[2];
668 /** 64-bit view. */
669 uint64_t au64[4];
670 /** 32-bit view. */
671 uint32_t au32[8];
672 /** 16-bit view. */
673 uint16_t au16[16];
674 /** 8-bit view. */
675 uint8_t au8[32];
676} RTUINT256U;
677#pragma pack()
678/** Pointer to a 256-bit unsigned integer union. */
679typedef RTUINT256U RT_FAR *PRTUINT256U;
680/** Pointer to a const 256-bit unsigned integer union. */
681typedef const RTUINT256U RT_FAR *PCRTUINT256U;
682
683/** @def RTUINT256_INIT
684 * Portable RTUINT256U initializer. */
685#ifdef RT_BIG_ENDIAN
686# define RTUINT256_INIT(a_Qw3, a_Qw2, a_Qw1, a_Qw0) { { a_Qw3, a_Qw2, a_Qw1, a_Qw0 } }
687#else
688# define RTUINT256_INIT(a_Qw3, a_Qw2, a_Qw1, a_Qw0) { { a_Qw0, a_Qw1, a_Qw2, a_Qw3 } }
689#endif
690
691/** @def RTUINT256_INIT_C
692 * Portable RTUINT256U initializer for 64-bit constants. */
693#define RTUINT256_INIT_C(a_Qw3, a_Qw2, a_Qw1, a_Qw0) \
694 RTUINT256_INIT(UINT64_C(a_Qw3), UINT64_C(a_Qw2), UINT64_C(a_Qw1), UINT64_C(a_Qw0))
695
696
697/**
698 * 512-bit unsigned integer union.
699 */
700#pragma pack(1)
701typedef union RTUINT512U
702{
703 /** Quad-Word view (first as it's used by RTUINT512_INIT). */
704 struct
705 {
706#ifdef RT_BIG_ENDIAN
707 uint64_t qw7;
708 uint64_t qw6;
709 uint64_t qw5;
710 uint64_t qw4;
711 uint64_t qw3;
712 uint64_t qw2;
713 uint64_t qw1;
714 uint64_t qw0;
715#else
716 uint64_t qw0;
717 uint64_t qw1;
718 uint64_t qw2;
719 uint64_t qw3;
720 uint64_t qw4;
721 uint64_t qw5;
722 uint64_t qw6;
723 uint64_t qw7;
724#endif
725 } QWords;
726 /** Double-Word view. */
727 struct
728 {
729#ifdef RT_BIG_ENDIAN
730 uint32_t dw15;
731 uint32_t dw14;
732 uint32_t dw13;
733 uint32_t dw12;
734 uint32_t dw11;
735 uint32_t dw10;
736 uint32_t dw9;
737 uint32_t dw8;
738 uint32_t dw7;
739 uint32_t dw6;
740 uint32_t dw5;
741 uint32_t dw4;
742 uint32_t dw3;
743 uint32_t dw2;
744 uint32_t dw1;
745 uint32_t dw0;
746#else
747 uint32_t dw0;
748 uint32_t dw1;
749 uint32_t dw2;
750 uint32_t dw3;
751 uint32_t dw4;
752 uint32_t dw5;
753 uint32_t dw6;
754 uint32_t dw7;
755 uint32_t dw8;
756 uint32_t dw9;
757 uint32_t dw10;
758 uint32_t dw11;
759 uint32_t dw12;
760 uint32_t dw13;
761 uint32_t dw14;
762 uint32_t dw15;
763#endif
764 } DWords;
765 /** Word view. */
766 struct
767 {
768#ifdef RT_BIG_ENDIAN
769 uint16_t w31;
770 uint16_t w30;
771 uint16_t w29;
772 uint16_t w28;
773 uint16_t w27;
774 uint16_t w26;
775 uint16_t w25;
776 uint16_t w24;
777 uint16_t w23;
778 uint16_t w22;
779 uint16_t w21;
780 uint16_t w20;
781 uint16_t w19;
782 uint16_t w18;
783 uint16_t w17;
784 uint16_t w16;
785 uint16_t w15;
786 uint16_t w14;
787 uint16_t w13;
788 uint16_t w12;
789 uint16_t w11;
790 uint16_t w10;
791 uint16_t w9;
792 uint16_t w8;
793 uint16_t w7;
794 uint16_t w6;
795 uint16_t w5;
796 uint16_t w4;
797 uint16_t w3;
798 uint16_t w2;
799 uint16_t w1;
800 uint16_t w0;
801#else
802 uint16_t w0;
803 uint16_t w1;
804 uint16_t w2;
805 uint16_t w3;
806 uint16_t w4;
807 uint16_t w5;
808 uint16_t w6;
809 uint16_t w7;
810 uint16_t w8;
811 uint16_t w9;
812 uint16_t w10;
813 uint16_t w11;
814 uint16_t w12;
815 uint16_t w13;
816 uint16_t w14;
817 uint16_t w15;
818 uint16_t w16;
819 uint16_t w17;
820 uint16_t w18;
821 uint16_t w19;
822 uint16_t w20;
823 uint16_t w21;
824 uint16_t w22;
825 uint16_t w23;
826 uint16_t w24;
827 uint16_t w25;
828 uint16_t w26;
829 uint16_t w27;
830 uint16_t w28;
831 uint16_t w29;
832 uint16_t w30;
833 uint16_t w31;
834#endif
835 } Words;
836
837 /** Double-Quad-Word view. */
838 struct
839 {
840#ifdef RT_BIG_ENDIAN
841 RTUINT128U dqw3;
842 RTUINT128U dqw2;
843 RTUINT128U dqw1;
844 RTUINT128U dqw0;
845#else
846 RTUINT128U dqw0;
847 RTUINT128U dqw1;
848 RTUINT128U dqw2;
849 RTUINT128U dqw3;
850#endif
851 } DQWords;
852
853 /** Octo-Word view. */
854 struct
855 {
856#ifdef RT_BIG_ENDIAN
857 RTUINT256U ow3;
858 RTUINT256U ow2;
859 RTUINT256U ow1;
860 RTUINT256U ow0;
861#else
862 RTUINT256U ow0;
863 RTUINT256U ow1;
864 RTUINT256U ow2;
865 RTUINT256U ow3;
866#endif
867 } OWords;
868
869 /** 256-bit view. */
870 RTUINT256U au256[2];
871 /** 128-bit view. */
872 RTUINT128U au128[4];
873 /** 64-bit view. */
874 uint64_t au64[8];
875 /** 32-bit view. */
876 uint32_t au32[16];
877 /** 16-bit view. */
878 uint16_t au16[32];
879 /** 8-bit view. */
880 uint8_t au8[64];
881} RTUINT512U;
882#pragma pack()
883/** Pointer to a 512-bit unsigned integer union. */
884typedef RTUINT512U RT_FAR *PRTUINT512U;
885/** Pointer to a const 512-bit unsigned integer union. */
886typedef const RTUINT512U RT_FAR *PCRTUINT512U;
887
888/** @def RTUINT512_INIT
889 * Portable RTUINT512U initializer. */
890#ifdef RT_BIG_ENDIAN
891# define RTUINT512_INIT(a_Qw7, a_Qw6, a_Qw5, a_Qw4, a_Qw3, a_Qw2, a_Qw1, a_Qw0) \
892 { { a_Qw7, a_Qw6, a_Qw5, a_Qw4, a_Qw3, a_Qw2, a_Qw1, a_Qw0 } }
893#else
894# define RTUINT512_INIT(a_Qw7, a_Qw6, a_Qw5, a_Qw4, a_Qw3, a_Qw2, a_Qw1, a_Qw0) \
895 { { a_Qw0, a_Qw1, a_Qw2, a_Qw3, a_Qw4, a_Qw5, a_Qw6, a_Qw7 } }
896#endif
897
898/** @def RTUINT512_INIT_C
899 * Portable RTUINT512U initializer for 64-bit constants. */
900#define RTUINT512_INIT_C(a_Qw7, a_Qw6, a_Qw5, a_Qw4, a_Qw3, a_Qw2, a_Qw1, a_Qw0) \
901 RTUINT512_INIT(UINT64_C(a_Qw7), UINT64_C(a_Qw6), UINT64_C(a_Qw5), UINT64_C(a_Qw4), \
902 UINT64_C(a_Qw3), UINT64_C(a_Qw2), UINT64_C(a_Qw1), UINT64_C(a_Qw0))
903
904
905/**
906 * Single precision floating point format (32-bit).
907 */
908typedef union RTFLOAT32U
909{
910 /** Format using regular bitfields. */
911 struct
912 {
913# ifdef RT_BIG_ENDIAN
914 /** The sign indicator. */
915 uint32_t fSign : 1;
916 /** The exponent (offseted by 127). */
917 uint32_t uExponent : 8;
918 /** The fraction. */
919 uint32_t uFraction : 23;
920# else
921 /** The fraction. */
922 uint32_t uFraction : 23;
923 /** The exponent (offseted by 127). */
924 uint32_t uExponent : 8;
925 /** The sign indicator. */
926 uint32_t fSign : 1;
927# endif
928 } s;
929
930#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
931 /** Double view. */
932 float r;
933#endif
934 /** Unsigned integer view. */
935 uint32_t u;
936 /** 32-bit view. */
937 uint32_t au32[1];
938 /** 16-bit view. */
939 uint16_t au16[2];
940 /** 8-bit view. */
941 uint8_t au8[4];
942} RTFLOAT32U;
943/** Pointer to a single precision floating point format union. */
944typedef RTFLOAT32U RT_FAR *PRTFLOAT32U;
945/** Pointer to a const single precision floating point format union. */
946typedef const RTFLOAT32U RT_FAR *PCRTFLOAT32U;
947/** RTFLOAT32U initializer. */
948#ifdef RT_BIG_ENDIAN
949# define RTFLOAT32U_INIT(a_fSign, a_uFraction, a_uExponent) { { (a_fSign), (a_uExponent), (a_uFraction) } }
950#else
951# define RTFLOAT32U_INIT(a_fSign, a_uFraction, a_uExponent) { { (a_uFraction), (a_uExponent), (a_fSign) } }
952#endif
953#define RTFLOAT32U_INIT_C(a_fSign, a_uFraction, a_uExponent) RTFLOAT32U_INIT((a_fSign), UINT32_C(a_uFraction), (a_uExponent))
954/** The exponent bias for the RTFLOAT32U format. */
955#define RTFLOAT32U_EXP_BIAS (127)
956/** The max exponent value for the RTFLOAT32U format. */
957#define RTFLOAT32U_EXP_MAX (255)
958/** The exponent bias overflow/underflow adjust for the RTFLOAT32U format.
959 * @note 754-1985 sec 7.3 & 7.4, not mentioned in later standard versions. */
960#define RTFLOAT32U_EXP_BIAS_ADJUST (192)
961/** Fraction width (in bits) for the RTFLOAT32U format. */
962#define RTFLOAT32U_FRACTION_BITS (23)
963/** Check if two 32-bit floating values are identical (memcmp, not
964 * numerically). */
965#define RTFLOAT32U_ARE_IDENTICAL(a_pLeft, a_pRight) ((a_pLeft)->u == (a_pRight)->u)
966/** @name RTFLOAT32U classification macros
967 * @{ */
968#define RTFLOAT32U_IS_ZERO(a_pr32) (((a_pr32)->u & (RT_BIT_32(31) - 1)) == 0)
969#define RTFLOAT32U_IS_SUBNORMAL(a_pr32) ((a_pr32)->s.uExponent == 0 && (a_pr32)->s.uFraction != 0)
970#define RTFLOAT32U_IS_INF(a_pr32) ((a_pr32)->s.uExponent == 0xff && (a_pr32)->s.uFraction == 0)
971#define RTFLOAT32U_IS_SIGNALLING_NAN(a_pr32) ((a_pr32)->s.uExponent == 0xff && !((a_pr32)->s.uFraction & RT_BIT_32(22)) \
972 && (a_pr32)->s.uFraction != 0)
973#define RTFLOAT32U_IS_QUIET_NAN(a_pr32) ((a_pr32)->s.uExponent == 0xff && ((a_pr32)->s.uFraction & RT_BIT_32(22)))
974#define RTFLOAT32U_IS_NAN(a_pr32) ((a_pr32)->s.uExponent == 0xff && (a_pr32)->s.uFraction != 0)
975#define RTFLOAT32U_IS_NORMAL(a_pr32) ((a_pr32)->s.uExponent > 0 && (a_pr32)->s.uExponent < 0xff)
976/** @} */
977
978
979/**
980 * Double precision floating point format (64-bit).
981 */
982typedef union RTFLOAT64U
983{
984 /** Format using regular bitfields. */
985 struct
986 {
987# ifdef RT_BIG_ENDIAN
988 /** The sign indicator. */
989 uint32_t fSign : 1;
990 /** The exponent (offseted by 1023). */
991 uint32_t uExponent : 11;
992 /** The fraction, bits 32 thru 51. */
993 uint32_t uFractionHigh : 20;
994 /** The fraction, bits 0 thru 31. */
995 uint32_t uFractionLow;
996# else
997 /** The fraction, bits 0 thru 31. */
998 uint32_t uFractionLow;
999 /** The fraction, bits 32 thru 51. */
1000 uint32_t uFractionHigh : 20;
1001 /** The exponent (offseted by 1023). */
1002 uint32_t uExponent : 11;
1003 /** The sign indicator. */
1004 uint32_t fSign : 1;
1005# endif
1006 } s;
1007
1008#ifdef RT_COMPILER_GROKS_64BIT_BITFIELDS
1009 /** Format using 64-bit bitfields. */
1010 RT_GCC_EXTENSION struct
1011 {
1012# ifdef RT_BIG_ENDIAN
1013 /** The sign indicator. */
1014 RT_GCC_EXTENSION uint64_t fSign : 1;
1015 /** The exponent (offseted by 1023). */
1016 RT_GCC_EXTENSION uint64_t uExponent : 11;
1017 /** The fraction. */
1018 RT_GCC_EXTENSION uint64_t uFraction : 52;
1019# else
1020 /** The fraction. */
1021 RT_GCC_EXTENSION uint64_t uFraction : 52;
1022 /** The exponent (offseted by 1023). */
1023 RT_GCC_EXTENSION uint64_t uExponent : 11;
1024 /** The sign indicator. */
1025 RT_GCC_EXTENSION uint64_t fSign : 1;
1026# endif
1027 } s64;
1028#endif
1029
1030#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
1031 /** Double view. */
1032 double rd;
1033#endif
1034 /** Unsigned integer view. */
1035 uint64_t u;
1036 /** 64-bit view. */
1037 uint64_t au64[1];
1038 /** 32-bit view. */
1039 uint32_t au32[2];
1040 /** 16-bit view. */
1041 uint16_t au16[4];
1042 /** 8-bit view. */
1043 uint8_t au8[8];
1044} RTFLOAT64U;
1045/** Pointer to a double precision floating point format union. */
1046typedef RTFLOAT64U RT_FAR *PRTFLOAT64U;
1047/** Pointer to a const double precision floating point format union. */
1048typedef const RTFLOAT64U RT_FAR *PCRTFLOAT64U;
1049/** RTFLOAT64U initializer. */
1050#ifdef RT_BIG_ENDIAN
1051# define RTFLOAT64U_INIT(a_fSign, a_uFraction, a_uExponent) \
1052 { { (a_fSign), (a_uExponent), (uint32_t)((a_uFraction) >> 32), (uint32_t)((a_uFraction) & UINT32_MAX) } }
1053#else
1054# define RTFLOAT64U_INIT(a_fSign, a_uFraction, a_uExponent) \
1055 { { (uint32_t)((a_uFraction) & UINT32_MAX), (uint32_t)((a_uFraction) >> 32), (a_uExponent), (a_fSign) } }
1056#endif
1057#define RTFLOAT64U_INIT_C(a_fSign, a_uFraction, a_uExponent) RTFLOAT64U_INIT((a_fSign), UINT64_C(a_uFraction), (a_uExponent))
1058/** The exponent bias for the RTFLOAT64U format. */
1059#define RTFLOAT64U_EXP_BIAS (1023)
1060/** The max exponent value for the RTFLOAT64U format. */
1061#define RTFLOAT64U_EXP_MAX (2047)
1062/** The exponent bias overflow/underflow adjust for the RTFLOAT64U format.
1063 * @note 754-1985 sec 7.3 & 7.4, not mentioned in later standard versions. */
1064#define RTFLOAT64U_EXP_BIAS_ADJUST (1536)
1065/** Fraction width (in bits) for the RTFLOAT64U format. */
1066#define RTFLOAT64U_FRACTION_BITS (52)
1067/** Check if two 64-bit floating values are identical (memcmp, not
1068 * numerically). */
1069#define RTFLOAT64U_ARE_IDENTICAL(a_pLeft, a_pRight) ((a_pLeft)->u == (a_pRight)->u)
1070/** @name RTFLOAT64U classification macros
1071 * @{ */
1072#define RTFLOAT64U_IS_ZERO(a_pr64) (((a_pr64)->u & (RT_BIT_64(63) - 1)) == 0)
1073#define RTFLOAT64U_IS_SUBNORMAL(a_pr64) ( (a_pr64)->s.uExponent == 0 \
1074 && ((a_pr64)->s.uFractionLow != 0 || (a_pr64)->s.uFractionHigh != 0) )
1075#define RTFLOAT64U_IS_INF(a_pr64) ( (a_pr64)->s.uExponent == 0x7ff \
1076 && (a_pr64)->s.uFractionLow == 0 && (a_pr64)->s.uFractionHigh == 0)
1077#define RTFLOAT64U_IS_SIGNALLING_NAN(a_pr64) ( (a_pr64)->s.uExponent == 0x7ff \
1078 && !((a_pr64)->s.uFractionHigh & RT_BIT_32(19)) \
1079 && ((a_pr64)->s.uFractionHigh != 0 || (a_pr64)->s.uFractionLow != 0) )
1080#define RTFLOAT64U_IS_QUIET_NAN(a_pr64) ((a_pr64)->s.uExponent == 0x7ff && ((a_pr64)->s.uFractionHigh & RT_BIT_32(19)))
1081#define RTFLOAT64U_IS_NAN(a_pr64) ( (a_pr64)->s.uExponent == 0x7ff \
1082 && ((a_pr64)->s.uFractionHigh != 0 || (a_pr64)->s.uFractionLow != 0) )
1083#define RTFLOAT64U_IS_NORMAL(a_pr64) ((a_pr64)->s.uExponent > 0 && (a_pr64)->s.uExponent < 0x7ff)
1084/** @} */
1085
1086
1087
1088#if !defined(__IBMCPP__) && !defined(__IBMC__)
1089
1090/**
1091 * Extended Double precision floating point format (80-bit).
1092 */
1093# pragma pack(1)
1094typedef union RTFLOAT80U
1095{
1096 /** Format using bitfields. */
1097 RT_GCC_EXTENSION struct
1098 {
1099# ifdef RT_BIG_ENDIAN /** @todo big endian mapping is wrong. */
1100 /** The sign indicator. */
1101 RT_GCC_EXTENSION uint16_t fSign : 1;
1102 /** The exponent (offseted by 16383). */
1103 RT_GCC_EXTENSION uint16_t uExponent : 15;
1104 /** The mantissa. */
1105 uint64_t uMantissa;
1106# else
1107 /** The mantissa. */
1108 uint64_t uMantissa;
1109 /** The exponent (offseted by 16383). */
1110 RT_GCC_EXTENSION uint16_t uExponent : 15;
1111 /** The sign indicator. */
1112 RT_GCC_EXTENSION uint16_t fSign : 1;
1113# endif
1114 } s;
1115
1116 /** Format for accessing it as two separate components. */
1117 RT_GCC_EXTENSION struct
1118 {
1119# ifdef RT_BIG_ENDIAN /** @todo big endian mapping is wrong. */
1120 /** The sign bit and exponent. */
1121 uint16_t uSignAndExponent;
1122 /** The mantissa. */
1123 uint64_t uMantissa;
1124# else
1125 /** The mantissa. */
1126 uint64_t uMantissa;
1127 /** The sign bit and exponent. */
1128 uint16_t uSignAndExponent;
1129# endif
1130 } s2;
1131
1132# ifdef RT_COMPILER_GROKS_64BIT_BITFIELDS
1133 /** 64-bit bitfields exposing the J bit and the fraction. */
1134 RT_GCC_EXTENSION struct
1135 {
1136# ifdef RT_BIG_ENDIAN /** @todo big endian mapping is wrong. */
1137 /** The sign indicator. */
1138 RT_GCC_EXTENSION uint16_t fSign : 1;
1139 /** The exponent (offseted by 16383). */
1140 RT_GCC_EXTENSION uint16_t uExponent : 15;
1141 /** The J bit, aka the integer bit. */
1142 RT_GCC_EXTENSION uint64_t fInteger : 1;
1143 /** The fraction. */
1144 RT_GCC_EXTENSION uint64_t uFraction : 63;
1145# else
1146 /** The fraction. */
1147 RT_GCC_EXTENSION uint64_t uFraction : 63;
1148 /** The J bit, aka the integer bit. */
1149 RT_GCC_EXTENSION uint64_t fInteger : 1;
1150 /** The exponent (offseted by 16383). */
1151 RT_GCC_EXTENSION uint16_t uExponent : 15;
1152 /** The sign indicator. */
1153 RT_GCC_EXTENSION uint16_t fSign : 1;
1154# endif
1155 } sj64;
1156# endif
1157
1158 /** 64-bit view. */
1159 uint64_t au64[1];
1160 /** 32-bit view. */
1161 uint32_t au32[2];
1162 /** 16-bit view. */
1163 uint16_t au16[5];
1164 /** 8-bit view. */
1165 uint8_t au8[10];
1166} RTFLOAT80U;
1167# pragma pack()
1168/** Pointer to a extended precision floating point format union. */
1169typedef RTFLOAT80U RT_FAR *PRTFLOAT80U;
1170/** Pointer to a const extended precision floating point format union. */
1171typedef const RTFLOAT80U RT_FAR *PCRTFLOAT80U;
1172/** RTFLOAT80U initializer. */
1173# ifdef RT_BIG_ENDIAN
1174# define RTFLOAT80U_INIT(a_fSign, a_uMantissa, a_uExponent) { { (a_fSign), (a_uExponent), (a_uMantissa) } }
1175# else
1176# define RTFLOAT80U_INIT(a_fSign, a_uMantissa, a_uExponent) { { (a_uMantissa), (a_uExponent), (a_fSign) } }
1177# endif
1178# define RTFLOAT80U_INIT_C(a_fSign, a_uMantissa, a_uExponent) RTFLOAT80U_INIT((a_fSign), UINT64_C(a_uMantissa), (a_uExponent))
1179# define RTFLOAT80U_INIT_ZERO(a_fSign) RTFLOAT80U_INIT((a_fSign), 0, 0)
1180# define RTFLOAT80U_INIT_INF(a_fSign) RTFLOAT80U_INIT((a_fSign), RT_BIT_64(63), 0x7fff)
1181# define RTFLOAT80U_INIT_SIGNALLING_NAN(a_fSign) RTFLOAT80U_INIT((a_fSign), RT_BIT_64(63) | 1, 0x7fff)
1182# define RTFLOAT80U_INIT_SNAN(a_fSign) RTFLOAT80U_INIT_SIGNALLING_NAN(a_fSign)
1183# define RTFLOAT80U_INIT_QUIET_NAN(a_fSign) RTFLOAT80U_INIT((a_fSign), RT_BIT_64(63) | RT_BIT_64(62) | 1, 0x7fff)
1184# define RTFLOAT80U_INIT_QNAN(a_fSign) RTFLOAT80U_INIT_QUIET_NAN(a_fSign)
1185# define RTFLOAT80U_INIT_INDEFINITE(a_fSign) RTFLOAT80U_INIT((a_fSign), RT_BIT_64(63) | RT_BIT_64(62), 0x7fff)
1186# define RTFLOAT80U_INIT_IND(a_fSign) RTFLOAT80U_INIT_INDEFINITE(a_fSign)
1187/** The exponent bias for the RTFLOAT80U format. */
1188# define RTFLOAT80U_EXP_BIAS (16383)
1189/** The max exponent value for the RTFLOAT80U format. */
1190# define RTFLOAT80U_EXP_MAX (32767)
1191/** The exponent bias overflow/underflow adjust for the RTFLOAT80U format.
1192 * @note 754-1985 sec 7.3 & 7.4, not mentioned in later standard versions. */
1193# define RTFLOAT80U_EXP_BIAS_ADJUST (24576)
1194/** Fraction width (in bits) for the RTFLOAT80U format. */
1195# define RTFLOAT80U_FRACTION_BITS (63)
1196/** Check if two 80-bit floating values are identical (memcmp, not
1197 * numberically). */
1198# define RTFLOAT80U_ARE_IDENTICAL(a_pLeft, a_pRight) \
1199 ( (a_pLeft)->au64[0] == (a_pRight)->au64[0] \
1200 && (a_pLeft)->au16[4] == (a_pRight)->au16[4] )
1201/** @name RTFLOAT80U classification macros
1202 * @{ */
1203# define RTFLOAT80U_IS_ZERO(a_pr80) \
1204 ((a_pr80)->s.uExponent == 0 && (a_pr80)->s.uMantissa == 0)
1205# define RTFLOAT80U_IS_DENORMAL(a_pr80) \
1206 ((a_pr80)->s.uExponent == 0 && (a_pr80)->s.uMantissa < RT_BIT_64(63) && (a_pr80)->s.uMantissa != 0)
1207# define RTFLOAT80U_IS_PSEUDO_DENORMAL(a_pr80) \
1208 ((a_pr80)->s.uExponent == 0 && (a_pr80)->s.uMantissa >= RT_BIT_64(63))
1209# define RTFLOAT80U_IS_DENORMAL_OR_PSEUDO_DENORMAL(a_pr80) \
1210 ((a_pr80)->s.uExponent == 0 && (a_pr80)->s.uMantissa != 0)
1211# define RTFLOAT80U_IS_PSEUDO_INF(a_pr80) \
1212 ((a_pr80)->s.uExponent == 0x7fff && (a_pr80)->s.uMantissa == 0)
1213# define RTFLOAT80U_IS_PSEUDO_NAN(a_pr80) \
1214 ((a_pr80)->s.uExponent == 0x7fff && !((a_pr80)->s.uMantissa & RT_BIT_64(63)))
1215# define RTFLOAT80U_IS_INF(a_pr80) \
1216 ((a_pr80)->s.uExponent == 0x7fff && (a_pr80)->s.uMantissa == RT_BIT_64(63))
1217# define RTFLOAT80U_IS_SIGNALLING_NAN(a_pr80) \
1218 ( (a_pr80)->s.uExponent == 0x7fff \
1219 && ((a_pr80)->s.uMantissa & (RT_BIT_64(63) | RT_BIT_64(62))) == RT_BIT_64(63) \
1220 && ((a_pr80)->s.uMantissa & (RT_BIT_64(62) - 1)) != 0)
1221# define RTFLOAT80U_IS_QUIET_NAN(a_pr80) \
1222 ( (a_pr80)->s.uExponent == 0x7fff \
1223 && ((a_pr80)->s.uMantissa & (RT_BIT_64(63) | RT_BIT_64(62))) == (RT_BIT_64(63) | RT_BIT_64(62)) \
1224 && ((a_pr80)->s.uMantissa & (RT_BIT_64(62) - 1)) != 0)
1225/** Signalling-, Quiet- or Pseudo-NaN. */
1226# define RTFLOAT80U_IS_NAN(a_pr80) \
1227 ((a_pr80)->s.uExponent == 0x7fff && ((a_pr80)->s.uMantissa & (RT_BIT_64(63) - 1)) != 0)
1228/** Signalling- or Quiet-Nan, but not Pseudo-NaN. */
1229# define RTFLOAT80U_IS_QUIET_OR_SIGNALLING_NAN(a_pr80) \
1230 ((a_pr80)->s.uExponent == 0x7fff && ((a_pr80)->s.uMantissa > RT_BIT_64(63)))
1231# define RTFLOAT80U_IS_INDEFINITE(a_pr80) \
1232 ((a_pr80)->s.uExponent == 0x7fff && (a_pr80)->s.uMantissa == (RT_BIT_64(63) | RT_BIT_64(62)))
1233# define RTFLOAT80U_IS_UNNORMAL(a_pr80) \
1234 (!((a_pr80)->s.uMantissa & RT_BIT_64(63)) && (a_pr80)->s.uExponent > 0 && (a_pr80)->s.uExponent < 0x7fff)
1235# define RTFLOAT80U_IS_NORMAL(a_pr80) \
1236 (((a_pr80)->s.uMantissa & RT_BIT_64(63)) && (a_pr80)->s.uExponent > 0 && (a_pr80)->s.uExponent < 0x7fff)
1237/** Invalid 387 (and later) operands: Pseudo-Infinity, Psuedo-NaN, Unnormals. */
1238#define RTFLOAT80U_IS_387_INVALID(a_pr80) \
1239 (!((a_pr80)->s.uMantissa & RT_BIT_64(63)) && (a_pr80)->s.uExponent > 0)
1240/** @} */
1241
1242
1243/**
1244 * A variant of RTFLOAT80U that may be larger than 80-bits depending on how the
1245 * compiler implements long double.
1246 *
1247 * @note On AMD64 systems implementing the System V ABI, this will be 16 bytes!
1248 * The last 6 bytes are unused padding taken up by the long double view.
1249 */
1250# pragma pack(1)
1251typedef union RTFLOAT80U2
1252{
1253 /** Format using bitfields. */
1254 RT_GCC_EXTENSION struct
1255 {
1256# ifdef RT_BIG_ENDIAN /** @todo big endian mapping is wrong. */
1257 /** The sign indicator. */
1258 RT_GCC_EXTENSION uint16_t fSign : 1;
1259 /** The exponent (offseted by 16383). */
1260 RT_GCC_EXTENSION uint16_t uExponent : 15;
1261 /** The mantissa. */
1262 uint64_t uMantissa;
1263# else
1264 /** The mantissa. */
1265 uint64_t uMantissa;
1266 /** The exponent (offseted by 16383). */
1267 RT_GCC_EXTENSION uint16_t uExponent : 15;
1268 /** The sign indicator. */
1269 RT_GCC_EXTENSION uint16_t fSign : 1;
1270# endif
1271 } s;
1272
1273 /** Format for accessing it as two separate components. */
1274 RT_GCC_EXTENSION struct
1275 {
1276# ifdef RT_BIG_ENDIAN /** @todo big endian mapping is wrong. */
1277 /** The sign bit and exponent. */
1278 uint16_t uSignAndExponent;
1279 /** The mantissa. */
1280 uint64_t uMantissa;
1281# else
1282 /** The mantissa. */
1283 uint64_t uMantissa;
1284 /** The sign bit and exponent. */
1285 uint16_t uSignAndExponent;
1286# endif
1287 } s2;
1288
1289 /** Bitfield exposing the J bit and the fraction. */
1290 RT_GCC_EXTENSION struct
1291 {
1292# ifdef RT_BIG_ENDIAN /** @todo big endian mapping is wrong. */
1293 /** The sign indicator. */
1294 RT_GCC_EXTENSION uint16_t fSign : 1;
1295 /** The exponent (offseted by 16383). */
1296 RT_GCC_EXTENSION uint16_t uExponent : 15;
1297 /** The J bit, aka the integer bit. */
1298 uint32_t fInteger : 1;
1299 /** The fraction, bits 32 thru 62. */
1300 uint32_t uFractionHigh : 31;
1301 /** The fraction, bits 0 thru 31. */
1302 uint32_t uFractionLow : 32;
1303# else
1304 /** The fraction, bits 0 thru 31. */
1305 uint32_t uFractionLow : 32;
1306 /** The fraction, bits 32 thru 62. */
1307 uint32_t uFractionHigh : 31;
1308 /** The J bit, aka the integer bit. */
1309 uint32_t fInteger : 1;
1310 /** The exponent (offseted by 16383). */
1311 RT_GCC_EXTENSION uint16_t uExponent : 15;
1312 /** The sign indicator. */
1313 RT_GCC_EXTENSION uint16_t fSign : 1;
1314# endif
1315 } sj;
1316
1317# ifdef RT_COMPILER_GROKS_64BIT_BITFIELDS
1318 /** 64-bit bitfields exposing the J bit and the fraction. */
1319 RT_GCC_EXTENSION struct
1320 {
1321# ifdef RT_BIG_ENDIAN /** @todo big endian mapping is wrong. */
1322 /** The sign indicator. */
1323 RT_GCC_EXTENSION uint16_t fSign : 1;
1324 /** The exponent (offseted by 16383). */
1325 RT_GCC_EXTENSION uint16_t uExponent : 15;
1326 /** The J bit, aka the integer bit. */
1327 RT_GCC_EXTENSION uint64_t fInteger : 1;
1328 /** The fraction. */
1329 RT_GCC_EXTENSION uint64_t uFraction : 63;
1330# else
1331 /** The fraction. */
1332 RT_GCC_EXTENSION uint64_t uFraction : 63;
1333 /** The J bit, aka the integer bit. */
1334 RT_GCC_EXTENSION uint64_t fInteger : 1;
1335 /** The exponent (offseted by 16383). */
1336 RT_GCC_EXTENSION uint16_t uExponent : 15;
1337 /** The sign indicator. */
1338 RT_GCC_EXTENSION uint16_t fSign : 1;
1339# endif
1340 } sj64;
1341# endif
1342
1343# ifdef RT_COMPILER_WITH_80BIT_LONG_DOUBLE
1344 /** Long double view. */
1345 long double lrd;
1346# endif
1347 /** 64-bit view. */
1348 uint64_t au64[1];
1349 /** 32-bit view. */
1350 uint32_t au32[2];
1351 /** 16-bit view. */
1352 uint16_t au16[5];
1353 /** 8-bit view. */
1354 uint8_t au8[10];
1355} RTFLOAT80U2;
1356# pragma pack()
1357/** Pointer to a extended precision floating point format union, 2nd
1358 * variant. */
1359typedef RTFLOAT80U2 RT_FAR *PRTFLOAT80U2;
1360/** Pointer to a const extended precision floating point format union, 2nd
1361 * variant. */
1362typedef const RTFLOAT80U2 RT_FAR *PCRTFLOAT80U2;
1363
1364#endif /* uint16_t bitfields doesn't work */
1365
1366
1367/**
1368 * Quadruple precision floating point format (128-bit).
1369 */
1370typedef union RTFLOAT128U
1371{
1372 /** Format using regular bitfields. */
1373 struct
1374 {
1375# ifdef RT_BIG_ENDIAN
1376 /** The sign indicator. */
1377 uint32_t fSign : 1;
1378 /** The exponent (offseted by 16383). */
1379 uint32_t uExponent : 15;
1380 /** The fraction, bits 96 thru 111. */
1381 uint32_t uFractionHigh : 16;
1382 /** The fraction, bits 64 thru 95. */
1383 uint32_t uFractionMid;
1384 /** The fraction, bits 0 thru 63. */
1385 uint64_t uFractionLow;
1386# else
1387 /** The fraction, bits 0 thru 63. */
1388 uint64_t uFractionLow;
1389 /** The fraction, bits 64 thru 95. */
1390 uint32_t uFractionMid;
1391 /** The fraction, bits 96 thru 111. */
1392 uint32_t uFractionHigh : 16;
1393 /** The exponent (offseted by 16383). */
1394 uint32_t uExponent : 15;
1395 /** The sign indicator. */
1396 uint32_t fSign : 1;
1397# endif
1398 } s;
1399
1400 /** Format for accessing it as two separate components. */
1401 struct
1402 {
1403# ifdef RT_BIG_ENDIAN
1404 /** The sign bit and exponent. */
1405 uint16_t uSignAndExponent;
1406 /** The fraction, bits 96 thru 111. */
1407 uint16_t uFractionHigh;
1408 /** The fraction, bits 64 thru 95. */
1409 uint32_t uFractionMid;
1410 /** The fraction, bits 0 thru 63. */
1411 uint64_t uFractionLow;
1412# else
1413 /** The fraction, bits 0 thru 63. */
1414 uint64_t uFractionLow;
1415 /** The fraction, bits 64 thru 95. */
1416 uint32_t uFractionMid;
1417 /** The fraction, bits 96 thru 111. */
1418 uint16_t uFractionHigh;
1419 /** The sign bit and exponent. */
1420 uint16_t uSignAndExponent;
1421# endif
1422 } s2;
1423
1424#ifdef RT_COMPILER_GROKS_64BIT_BITFIELDS
1425 /** Format using 64-bit bitfields. */
1426 RT_GCC_EXTENSION struct
1427 {
1428# ifdef RT_BIG_ENDIAN
1429 /** The sign indicator. */
1430 RT_GCC_EXTENSION uint64_t fSign : 1;
1431 /** The exponent (offseted by 16383). */
1432 RT_GCC_EXTENSION uint64_t uExponent : 15;
1433 /** The fraction, bits 64 thru 111. */
1434 RT_GCC_EXTENSION uint64_t uFractionHi : 48;
1435 /** The fraction, bits 0 thru 63. */
1436 uint64_t uFractionLo;
1437# else
1438 /** The fraction, bits 0 thru 63. */
1439 uint64_t uFractionLo;
1440 /** The fraction, bits 64 thru 111. */
1441 RT_GCC_EXTENSION uint64_t uFractionHi : 48;
1442 /** The exponent (offseted by 16383). */
1443 RT_GCC_EXTENSION uint64_t uExponent : 15;
1444 /** The sign indicator. */
1445 RT_GCC_EXTENSION uint64_t fSign : 1;
1446# endif
1447 } s64;
1448#endif
1449
1450#ifdef RT_COMPILER_WITH_128BIT_LONG_DOUBLE
1451 /** Long double view. */
1452 long double lrd;
1453#endif
1454 /** 128-bit view. */
1455 RTUINT128U u128;
1456 /** 64-bit view. */
1457 uint64_t au64[2];
1458 /** 32-bit view. */
1459 uint32_t au32[4];
1460 /** 16-bit view. */
1461 uint16_t au16[8];
1462 /** 8-bit view. */
1463 uint8_t au8[16];
1464} RTFLOAT128U;
1465/** Pointer to a quadruple precision floating point format union. */
1466typedef RTFLOAT128U RT_FAR *PRTFLOAT128U;
1467/** Pointer to a const quadruple precision floating point format union. */
1468typedef const RTFLOAT128U RT_FAR *PCRTFLOAT128U;
1469/** RTFLOAT128U initializer. */
1470#ifdef RT_BIG_ENDIAN
1471# define RTFLOAT128U_INIT(a_fSign, a_uFractionHi, a_uFractionLo, a_uExponent) \
1472 { { (a_fSign), (a_uExponent), (uint32_t)((a_uFractionHi) >> 32), (uint32_t)((a_uFractionHi) & UINT32_MAX), (a_uFractionLo) } }
1473#else
1474# define RTFLOAT128U_INIT(a_fSign, a_uFractionHi, a_uFractionLo, a_uExponent) \
1475 { { (a_uFractionLo), (uint32_t)((a_uFractionHi) & UINT32_MAX), (uint32_t)((a_uFractionHi) >> 32), (a_uExponent), (a_fSign) } }
1476#endif
1477#define RTFLOAT128U_INIT_C(a_fSign, a_uFractionHi, a_uFractionLo, a_uExponent) \
1478 RTFLOAT128U_INIT((a_fSign), UINT64_C(a_uFractionHi), UINT64_C(a_uFractionLo), (a_uExponent))
1479/** The exponent bias for the RTFLOAT128U format. */
1480#define RTFLOAT128U_EXP_BIAS (16383)
1481/** The max exponent value for the RTFLOAT128U format. */
1482#define RTFLOAT128U_EXP_MAX (32767)
1483/** The exponent bias overflow/underflow adjust for the RTFLOAT128U format.
1484 * @note This is stipulated based on RTFLOAT80U, it doesn't appear in any
1485 * standard text as far as we know. */
1486#define RTFLOAT128U_EXP_BIAS_ADJUST (24576)
1487/** Fraction width (in bits) for the RTFLOAT128U format. */
1488#define RTFLOAT128U_FRACTION_BITS (112)
1489/** Check if two 128-bit floating values are identical (memcmp, not
1490 * numerically). */
1491#define RTFLOAT128U_ARE_IDENTICAL(a_pLeft, a_pRight) \
1492 ( (a_pLeft)->au64[0] == (a_pRight)->au64[0] && (a_pLeft)->au64[1] == (a_pRight)->au64[1] )
1493/** @name RTFLOAT128U classification macros
1494 * @{ */
1495#define RTFLOAT128U_IS_ZERO(a_pr128) ( (a_pr128)->u128.s.Lo == 0 \
1496 && ((a_pr128)->u128.s.Hi & (RT_BIT_64(63) - 1)) == 0)
1497#define RTFLOAT128U_IS_SUBNORMAL(a_pr128) ( (a_pr128)->s.uExponent == 0 \
1498 && ( (a_pr128)->s.uFractionLow != 0 \
1499 || (a_pr128)->s.uFractionMid != 0 \
1500 || (a_pr128)->s.uFractionHigh != 0 ) )
1501#define RTFLOAT128U_IS_INF(a_pr128) ( (a_pr128)->s.uExponent == RTFLOAT128U_EXP_MAX \
1502 && (a_pr128)->s.uFractionHigh == 0 \
1503 && (a_pr128)->s.uFractionMid == 0 \
1504 && (a_pr128)->s.uFractionLow == 0 )
1505#define RTFLOAT128U_IS_SIGNALLING_NAN(a_pr128) ( (a_pr128)->s.uExponent == RTFLOAT128U_EXP_MAX \
1506 && !((a_pr128)->s.uFractionHigh & RT_BIT_32(15)) \
1507 && ( (a_pr128)->s.uFractionHigh != 0 \
1508 || (a_pr128)->s.uFractionMid != 0 \
1509 || (a_pr128)->s.uFractionLow != 0) )
1510#define RTFLOAT128U_IS_QUIET_NAN(a_pr128) ( (a_pr128)->s.uExponent == RTFLOAT128U_EXP_MAX \
1511 && ((a_pr128)->s.uFractionHigh & RT_BIT_32(15)))
1512#define RTFLOAT128U_IS_NAN(a_pr128) ( (a_pr128)->s.uExponent == RTFLOAT128U_EXP_MAX \
1513 && ( (a_pr128)->s.uFractionLow != 0 \
1514 || (a_pr128)->s.uFractionMid != 0 \
1515 || (a_pr128)->s.uFractionHigh != 0) )
1516#define RTFLOAT128U_IS_NORMAL(a_pr128) ((a_pr128)->s.uExponent > 0 && (a_pr128)->s.uExponent < RTFLOAT128U_EXP_MAX)
1517/** @} */
1518
1519
1520/**
1521 * Packed BCD 18-digit signed integer format (80-bit).
1522 */
1523#pragma pack(1)
1524typedef union RTPBCD80U
1525{
1526 /** Format using bitfields. */
1527 RT_GCC_EXTENSION struct
1528 {
1529 /** 18 packed BCD digits, two to a byte. */
1530 uint8_t abPairs[9];
1531 /** Padding, non-zero if indefinite. */
1532 RT_GCC_EXTENSION uint8_t uPad : 7;
1533 /** The sign indicator. */
1534 RT_GCC_EXTENSION uint8_t fSign : 1;
1535 } s;
1536
1537 /** 64-bit view. */
1538 uint64_t au64[1];
1539 /** 32-bit view. */
1540 uint32_t au32[2];
1541 /** 16-bit view. */
1542 uint16_t au16[5];
1543 /** 8-bit view. */
1544 uint8_t au8[10];
1545} RTPBCD80U;
1546#pragma pack()
1547/** Pointer to a packed BCD integer format union. */
1548typedef RTPBCD80U RT_FAR *PRTPBCD80U;
1549/** Pointer to a const packed BCD integer format union. */
1550typedef const RTPBCD80U RT_FAR *PCRTPBCD80U;
1551/** RTPBCD80U initializer. */
1552#define RTPBCD80U_INIT_C(a_fSign, a_D17, a_D16, a_D15, a_D14, a_D13, a_D12, a_D11, a_D10, \
1553 a_D9, a_D8, a_D7, a_D6, a_D5, a_D4, a_D3, a_D2, a_D1, a_D0) \
1554 RTPBCD80U_INIT_EX_C(0, a_fSign, a_D17, a_D16, a_D15, a_D14, a_D13, a_D12, a_D11, a_D10, \
1555 a_D9, a_D8, a_D7, a_D6, a_D5, a_D4, a_D3, a_D2, a_D1, a_D0)
1556/** Extended RTPBCD80U initializer. */
1557#define RTPBCD80U_INIT_EX_C(a_uPad, a_fSign, a_D17, a_D16, a_D15, a_D14, a_D13, a_D12, a_D11, a_D10, \
1558 a_D9, a_D8, a_D7, a_D6, a_D5, a_D4, a_D3, a_D2, a_D1, a_D0) \
1559 { { { RTPBCD80U_MAKE_PAIR(a_D1, a_D0), \
1560 RTPBCD80U_MAKE_PAIR(a_D3, a_D2), \
1561 RTPBCD80U_MAKE_PAIR(a_D5, a_D4), \
1562 RTPBCD80U_MAKE_PAIR(a_D7, a_D6), \
1563 RTPBCD80U_MAKE_PAIR(a_D9, a_D8), \
1564 RTPBCD80U_MAKE_PAIR(a_D11, a_D10), \
1565 RTPBCD80U_MAKE_PAIR(a_D13, a_D12), \
1566 RTPBCD80U_MAKE_PAIR(a_D15, a_D14), \
1567 RTPBCD80U_MAKE_PAIR(a_D17, a_D16), }, (a_uPad), (a_fSign) } }
1568/** RTPBCD80U initializer for the zero value. */
1569#define RTPBCD80U_INIT_ZERO(a_fSign) RTPBCD80U_INIT_C(a_fSign, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0)
1570/** RTPBCD80U initializer for the indefinite value. */
1571#define RTPBCD80U_INIT_INDEFINITE() RTPBCD80U_INIT_EX_C(0x7f,1, 0xf,0xf, 0xc,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0)
1572/** RTPBCD80U initializer for the minimum value. */
1573#define RTPBCD80U_INIT_MIN() RTPBCD80U_INIT_C(1, 9,9, 9,9, 9,9, 9,9, 9,9, 9,9, 9,9, 9,9, 9,9)
1574/** RTPBCD80U initializer for the maximum value. */
1575#define RTPBCD80U_INIT_MAX() RTPBCD80U_INIT_C(0, 9,9, 9,9, 9,9, 9,9, 9,9, 9,9, 9,9, 9,9, 9,9)
1576/** RTPBCD80U minimum value. */
1577#define RTPBCD80U_MIN INT64_C(-999999999999999999)
1578/** RTPBCD80U maximum value. */
1579#define RTPBCD80U_MAX INT64_C(999999999999999999)
1580/** Makes a packs a pair of BCD digits. */
1581#define RTPBCD80U_MAKE_PAIR(a_D1, a_D0) ((a_D0) | ((a_D1) << 4))
1582/** Retrieves the lower digit of a BCD digit pair. */
1583#define RTPBCD80U_LO_DIGIT(a_bPair) ((a_bPair) & 0xf)
1584/** Retrieves the higher digit of a BCD digit pair. */
1585#define RTPBCD80U_HI_DIGIT(a_bPair) ((a_bPair) >> 4)
1586/** Checks if the packaged BCD number is representing indefinite. */
1587#define RTPBCD80U_IS_INDEFINITE(a_pd80) \
1588 ( (a_pd80)->s.uPad == 0x7f \
1589 && (a_pd80)->s.fSign == 1 \
1590 && (a_pd80)->s.abPairs[8] == 0xff \
1591 && (a_pd80)->s.abPairs[7] == RTPBCD80U_MAKE_PAIR(0xc, 0) \
1592 && (a_pd80)->s.abPairs[6] == 0 \
1593 && (a_pd80)->s.abPairs[5] == 0 \
1594 && (a_pd80)->s.abPairs[4] == 0 \
1595 && (a_pd80)->s.abPairs[3] == 0 \
1596 && (a_pd80)->s.abPairs[2] == 0 \
1597 && (a_pd80)->s.abPairs[1] == 0 \
1598 && (a_pd80)->s.abPairs[0] == 0)
1599/** Check if @a a_pd80Left and @a a_pd80Right are exactly the same. */
1600#define RTPBCD80U_ARE_IDENTICAL(a_pd80Left, a_pd80Right) \
1601 ( (a_pd80Left)->au64[0] == (a_pd80Right)->au64[0] && (a_pd80Left)->au16[4] == (a_pd80Right)->au16[4] )
1602
1603
1604/** Generic function type.
1605 * @see PFNRT
1606 */
1607typedef DECLCALLBACKTYPE(void, FNRT,(void));
1608
1609/** Generic function pointer.
1610 * With -pedantic, gcc-4 complains when casting a function to a data object, for
1611 * example:
1612 *
1613 * @code
1614 * void foo(void)
1615 * {
1616 * }
1617 *
1618 * void *bar = (void *)foo;
1619 * @endcode
1620 *
1621 * The compiler would warn with "ISO C++ forbids casting between
1622 * pointer-to-function and pointer-to-object". The purpose of this warning is
1623 * not to bother the programmer but to point out that he is probably doing
1624 * something dangerous, assigning a pointer to executable code to a data object.
1625 */
1626typedef FNRT *PFNRT;
1627
1628/** Variant on PFNRT that takes one pointer argument. */
1629typedef DECLCALLBACKTYPE(void, FNRT1,(void *pvArg));
1630/** Pointer to FNRT1. */
1631typedef FNRT1 *PFNRT1;
1632
1633/** Millisecond interval. */
1634typedef uint32_t RTMSINTERVAL;
1635/** Pointer to a millisecond interval. */
1636typedef RTMSINTERVAL RT_FAR *PRTMSINTERVAL;
1637/** Pointer to a const millisecond interval. */
1638typedef const RTMSINTERVAL RT_FAR *PCRTMSINTERVAL;
1639
1640/** Pointer to a time spec structure. */
1641typedef struct RTTIMESPEC RT_FAR *PRTTIMESPEC;
1642/** Pointer to a const time spec structure. */
1643typedef const struct RTTIMESPEC RT_FAR *PCRTTIMESPEC;
1644
1645
1646
1647/** @defgroup grp_rt_types_both Common Guest and Host Context Basic Types
1648 * @{
1649 */
1650
1651/** Signed integer which can contain both GC and HC pointers. */
1652#if (HC_ARCH_BITS == 32 && GC_ARCH_BITS == 32) || (HC_ARCH_BITS == 16 || GC_ARCH_BITS == 16)
1653typedef int32_t RTINTPTR;
1654#elif (HC_ARCH_BITS == 64 || GC_ARCH_BITS == 64)
1655typedef int64_t RTINTPTR;
1656#else
1657# error Unsupported HC_ARCH_BITS and/or GC_ARCH_BITS values.
1658#endif
1659/** Pointer to signed integer which can contain both GC and HC pointers. */
1660typedef RTINTPTR RT_FAR *PRTINTPTR;
1661/** Pointer const to signed integer which can contain both GC and HC pointers. */
1662typedef const RTINTPTR RT_FAR *PCRTINTPTR;
1663/** The maximum value the RTINTPTR type can hold. */
1664#if (HC_ARCH_BITS == 32 && GC_ARCH_BITS == 32) || (HC_ARCH_BITS == 16 || GC_ARCH_BITS == 16)
1665# define RTINTPTR_MAX INT32_MAX
1666#elif (HC_ARCH_BITS == 64 || GC_ARCH_BITS == 64)
1667# define RTINTPTR_MAX INT64_MAX
1668#else
1669# error Unsupported HC_ARCH_BITS and/or GC_ARCH_BITS values.
1670#endif
1671/** The minimum value the RTINTPTR type can hold. */
1672#if (HC_ARCH_BITS == 32 && GC_ARCH_BITS == 32) || (HC_ARCH_BITS == 16 || GC_ARCH_BITS == 16)
1673# define RTINTPTR_MIN INT32_MIN
1674#elif (HC_ARCH_BITS == 64 || GC_ARCH_BITS == 64)
1675# define RTINTPTR_MIN INT64_MIN
1676#else
1677# error Unsupported HC_ARCH_BITS and/or GC_ARCH_BITS values.
1678#endif
1679
1680/** Unsigned integer which can contain both GC and HC pointers. */
1681#if (HC_ARCH_BITS == 32 && GC_ARCH_BITS == 32) || (HC_ARCH_BITS == 16 || GC_ARCH_BITS == 16)
1682typedef uint32_t RTUINTPTR;
1683#elif (HC_ARCH_BITS == 64 || GC_ARCH_BITS == 64)
1684typedef uint64_t RTUINTPTR;
1685#else
1686# error Unsupported HC_ARCH_BITS and/or GC_ARCH_BITS values.
1687#endif
1688/** Pointer to unsigned integer which can contain both GC and HC pointers. */
1689typedef RTUINTPTR RT_FAR *PRTUINTPTR;
1690/** Pointer const to unsigned integer which can contain both GC and HC pointers. */
1691typedef const RTUINTPTR RT_FAR *PCRTUINTPTR;
1692/** The maximum value the RTUINTPTR type can hold. */
1693#if (HC_ARCH_BITS == 32 && GC_ARCH_BITS == 32) || (HC_ARCH_BITS == 16 || GC_ARCH_BITS == 16)
1694# define RTUINTPTR_MAX UINT32_MAX
1695#elif (HC_ARCH_BITS == 64 || GC_ARCH_BITS == 64)
1696# define RTUINTPTR_MAX UINT64_MAX
1697#else
1698# error Unsupported HC_ARCH_BITS and/or GC_ARCH_BITS values.
1699#endif
1700
1701/** Signed integer. */
1702typedef int32_t RTINT;
1703/** Pointer to signed integer. */
1704typedef RTINT RT_FAR *PRTINT;
1705/** Pointer to const signed integer. */
1706typedef const RTINT RT_FAR *PCRTINT;
1707
1708/** Unsigned integer. */
1709typedef uint32_t RTUINT;
1710/** Pointer to unsigned integer. */
1711typedef RTUINT RT_FAR *PRTUINT;
1712/** Pointer to const unsigned integer. */
1713typedef const RTUINT RT_FAR *PCRTUINT;
1714
1715/** A file offset / size (off_t). */
1716typedef int64_t RTFOFF;
1717/** Pointer to a file offset / size. */
1718typedef RTFOFF RT_FAR *PRTFOFF;
1719/** The max value for RTFOFF. */
1720#define RTFOFF_MAX INT64_MAX
1721/** The min value for RTFOFF. */
1722#define RTFOFF_MIN INT64_MIN
1723
1724/** File mode (see iprt/fs.h). */
1725typedef uint32_t RTFMODE;
1726/** Pointer to file mode. */
1727typedef RTFMODE RT_FAR *PRTFMODE;
1728
1729/** Device unix number. */
1730typedef uint32_t RTDEV;
1731/** Pointer to a device unix number. */
1732typedef RTDEV RT_FAR *PRTDEV;
1733
1734/** @name RTDEV Macros
1735 * @{ */
1736/**
1737 * Our makedev macro.
1738 * @returns RTDEV
1739 * @param uMajor The major device number.
1740 * @param uMinor The minor device number.
1741 */
1742#define RTDEV_MAKE(uMajor, uMinor) ((RTDEV)( ((RTDEV)(uMajor) << 24) | (uMinor & UINT32_C(0x00ffffff)) ))
1743/**
1744 * Get the major device node number from an RTDEV type.
1745 * @returns The major device number of @a uDev
1746 * @param uDev The device number.
1747 */
1748#define RTDEV_MAJOR(uDev) ((uDev) >> 24)
1749/**
1750 * Get the minor device node number from an RTDEV type.
1751 * @returns The minor device number of @a uDev
1752 * @param uDev The device number.
1753 */
1754#define RTDEV_MINOR(uDev) ((uDev) & UINT32_C(0x00ffffff))
1755/** @} */
1756
1757/** i-node number. */
1758typedef uint64_t RTINODE;
1759/** Pointer to a i-node number. */
1760typedef RTINODE RT_FAR *PRTINODE;
1761
1762/** User id. */
1763typedef uint32_t RTUID;
1764/** Pointer to a user id. */
1765typedef RTUID RT_FAR *PRTUID;
1766/** NIL user id.
1767 * @todo check this for portability! */
1768#define NIL_RTUID (~(RTUID)0)
1769
1770/** Group id. */
1771typedef uint32_t RTGID;
1772/** Pointer to a group id. */
1773typedef RTGID RT_FAR *PRTGID;
1774/** NIL group id.
1775 * @todo check this for portability! */
1776#define NIL_RTGID (~(RTGID)0)
1777
1778/** I/O Port. */
1779typedef uint16_t RTIOPORT;
1780/** Pointer to I/O Port. */
1781typedef RTIOPORT RT_FAR *PRTIOPORT;
1782/** Pointer to const I/O Port. */
1783typedef const RTIOPORT RT_FAR *PCRTIOPORT;
1784
1785/** Selector. */
1786typedef uint16_t RTSEL;
1787/** Pointer to selector. */
1788typedef RTSEL RT_FAR *PRTSEL;
1789/** Pointer to const selector. */
1790typedef const RTSEL RT_FAR *PCRTSEL;
1791/** Max selector value. */
1792#define RTSEL_MAX UINT16_MAX
1793
1794/** Far 16-bit pointer. */
1795#pragma pack(1)
1796typedef struct RTFAR16
1797{
1798 uint16_t off;
1799 RTSEL sel;
1800} RTFAR16;
1801#pragma pack()
1802/** Pointer to Far 16-bit pointer. */
1803typedef RTFAR16 RT_FAR *PRTFAR16;
1804/** Pointer to const Far 16-bit pointer. */
1805typedef const RTFAR16 RT_FAR *PCRTFAR16;
1806
1807/** Far 32-bit pointer. */
1808#pragma pack(1)
1809typedef struct RTFAR32
1810{
1811 uint32_t off;
1812 RTSEL sel;
1813} RTFAR32;
1814#pragma pack()
1815/** Pointer to Far 32-bit pointer. */
1816typedef RTFAR32 RT_FAR *PRTFAR32;
1817/** Pointer to const Far 32-bit pointer. */
1818typedef const RTFAR32 RT_FAR *PCRTFAR32;
1819
1820/** Far 64-bit pointer. */
1821#pragma pack(1)
1822typedef struct RTFAR64
1823{
1824 uint64_t off;
1825 RTSEL sel;
1826} RTFAR64;
1827#pragma pack()
1828/** Pointer to Far 64-bit pointer. */
1829typedef RTFAR64 RT_FAR *PRTFAR64;
1830/** Pointer to const Far 64-bit pointer. */
1831typedef const RTFAR64 RT_FAR *PCRTFAR64;
1832
1833/** @} */
1834
1835
1836/** @defgroup grp_rt_types_hc Host Context Basic Types
1837 * @{
1838 */
1839
1840/** HC Natural signed integer.
1841 * @deprecated silly type. */
1842typedef int32_t RTHCINT;
1843/** Pointer to HC Natural signed integer.
1844 * @deprecated silly type. */
1845typedef RTHCINT RT_FAR *PRTHCINT;
1846/** Pointer to const HC Natural signed integer.
1847 * @deprecated silly type. */
1848typedef const RTHCINT RT_FAR *PCRTHCINT;
1849
1850/** HC Natural unsigned integer.
1851 * @deprecated silly type. */
1852typedef uint32_t RTHCUINT;
1853/** Pointer to HC Natural unsigned integer.
1854 * @deprecated silly type. */
1855typedef RTHCUINT RT_FAR *PRTHCUINT;
1856/** Pointer to const HC Natural unsigned integer.
1857 * @deprecated silly type. */
1858typedef const RTHCUINT RT_FAR *PCRTHCUINT;
1859
1860
1861/** Signed integer which can contain a HC pointer. */
1862#if HC_ARCH_BITS == 32 || HC_ARCH_BITS == 16
1863typedef int32_t RTHCINTPTR;
1864#elif HC_ARCH_BITS == 64
1865typedef int64_t RTHCINTPTR;
1866#else
1867# error Unsupported HC_ARCH_BITS value.
1868#endif
1869/** Pointer to signed integer which can contain a HC pointer. */
1870typedef RTHCINTPTR RT_FAR *PRTHCINTPTR;
1871/** Pointer to const signed integer which can contain a HC pointer. */
1872typedef const RTHCINTPTR RT_FAR *PCRTHCINTPTR;
1873/** Max RTHCINTPTR value. */
1874#if HC_ARCH_BITS == 32
1875# define RTHCINTPTR_MAX INT32_MAX
1876#elif HC_ARCH_BITS == 64
1877# define RTHCINTPTR_MAX INT64_MAX
1878#else
1879# define RTHCINTPTR_MAX INT16_MAX
1880#endif
1881/** Min RTHCINTPTR value. */
1882#if HC_ARCH_BITS == 32
1883# define RTHCINTPTR_MIN INT32_MIN
1884#elif HC_ARCH_BITS == 64
1885# define RTHCINTPTR_MIN INT64_MIN
1886#else
1887# define RTHCINTPTR_MIN INT16_MIN
1888#endif
1889
1890/** Signed integer which can contain a HC ring-3 pointer. */
1891#if R3_ARCH_BITS == 32 || R3_ARCH_BITS == 16
1892typedef int32_t RTR3INTPTR;
1893#elif R3_ARCH_BITS == 64
1894typedef int64_t RTR3INTPTR;
1895#else
1896# error Unsupported R3_ARCH_BITS value.
1897#endif
1898/** Pointer to signed integer which can contain a HC ring-3 pointer. */
1899typedef RTR3INTPTR RT_FAR *PRTR3INTPTR;
1900/** Pointer to const signed integer which can contain a HC ring-3 pointer. */
1901typedef const RTR3INTPTR RT_FAR *PCRTR3INTPTR;
1902/** Max RTR3INTPTR value. */
1903#if R3_ARCH_BITS == 32 || R3_ARCH_BITS == 16
1904# define RTR3INTPTR_MAX INT32_MAX
1905#else
1906# define RTR3INTPTR_MAX INT64_MAX
1907#endif
1908/** Min RTR3INTPTR value. */
1909#if R3_ARCH_BITS == 32 || R3_ARCH_BITS == 16
1910# define RTR3INTPTR_MIN INT32_MIN
1911#else
1912# define RTR3INTPTR_MIN INT64_MIN
1913#endif
1914
1915/** Signed integer which can contain a HC ring-0 pointer. */
1916#if R0_ARCH_BITS == 32 || R0_ARCH_BITS == 16
1917typedef int32_t RTR0INTPTR;
1918#elif R0_ARCH_BITS == 64
1919typedef int64_t RTR0INTPTR;
1920#else
1921# error Unsupported R0_ARCH_BITS value.
1922#endif
1923/** Pointer to signed integer which can contain a HC ring-0 pointer. */
1924typedef RTR0INTPTR RT_FAR *PRTR0INTPTR;
1925/** Pointer to const signed integer which can contain a HC ring-0 pointer. */
1926typedef const RTR0INTPTR RT_FAR *PCRTR0INTPTR;
1927/** Max RTR0INTPTR value. */
1928#if R0_ARCH_BITS == 32 || R0_ARCH_BITS == 16
1929# define RTR0INTPTR_MAX INT32_MAX
1930#else
1931# define RTR0INTPTR_MAX INT64_MAX
1932#endif
1933/** Min RTHCINTPTR value. */
1934#if R0_ARCH_BITS == 32 || R0_ARCH_BITS == 16
1935# define RTR0INTPTR_MIN INT32_MIN
1936#else
1937# define RTR0INTPTR_MIN INT64_MIN
1938#endif
1939
1940
1941/** Unsigned integer which can contain a HC pointer. */
1942#if HC_ARCH_BITS == 32 || HC_ARCH_BITS == 16
1943typedef uint32_t RTHCUINTPTR;
1944#elif HC_ARCH_BITS == 64
1945typedef uint64_t RTHCUINTPTR;
1946#else
1947# error Unsupported HC_ARCH_BITS value.
1948#endif
1949/** Pointer to unsigned integer which can contain a HC pointer. */
1950typedef RTHCUINTPTR RT_FAR *PRTHCUINTPTR;
1951/** Pointer to unsigned integer which can contain a HC pointer. */
1952typedef const RTHCUINTPTR RT_FAR *PCRTHCUINTPTR;
1953/** Max RTHCUINTTPR value. */
1954#if HC_ARCH_BITS == 32 || HC_ARCH_BITS == 16
1955# define RTHCUINTPTR_MAX UINT32_MAX
1956#else
1957# define RTHCUINTPTR_MAX UINT64_MAX
1958#endif
1959
1960/** Unsigned integer which can contain a HC ring-3 pointer. */
1961#if R3_ARCH_BITS == 32 || R3_ARCH_BITS == 16
1962typedef uint32_t RTR3UINTPTR;
1963#elif R3_ARCH_BITS == 64
1964typedef uint64_t RTR3UINTPTR;
1965#else
1966# error Unsupported R3_ARCH_BITS value.
1967#endif
1968/** Pointer to unsigned integer which can contain a HC ring-3 pointer. */
1969typedef RTR3UINTPTR RT_FAR *PRTR3UINTPTR;
1970/** Pointer to unsigned integer which can contain a HC ring-3 pointer. */
1971typedef const RTR3UINTPTR RT_FAR *PCRTR3UINTPTR;
1972/** Max RTHCUINTTPR value. */
1973#if R3_ARCH_BITS == 32 || R3_ARCH_BITS == 16
1974# define RTR3UINTPTR_MAX UINT32_MAX
1975#else
1976# define RTR3UINTPTR_MAX UINT64_MAX
1977#endif
1978
1979/** Unsigned integer which can contain a HC ring-0 pointer. */
1980#if R0_ARCH_BITS == 32 || R0_ARCH_BITS == 16
1981typedef uint32_t RTR0UINTPTR;
1982#elif R0_ARCH_BITS == 64
1983typedef uint64_t RTR0UINTPTR;
1984#else
1985# error Unsupported R0_ARCH_BITS value.
1986#endif
1987/** Pointer to unsigned integer which can contain a HC ring-0 pointer. */
1988typedef RTR0UINTPTR RT_FAR *PRTR0UINTPTR;
1989/** Pointer to unsigned integer which can contain a HC ring-0 pointer. */
1990typedef const RTR0UINTPTR RT_FAR *PCRTR0UINTPTR;
1991/** Max RTR0UINTTPR value. */
1992#if R0_ARCH_BITS == 32 || R0_ARCH_BITS == 16
1993# define RTR0UINTPTR_MAX UINT32_MAX
1994#else
1995# define RTR0UINTPTR_MAX UINT64_MAX
1996#endif
1997
1998
1999/** Host Physical Memory Address. */
2000typedef uint64_t RTHCPHYS;
2001/** Pointer to Host Physical Memory Address. */
2002typedef RTHCPHYS RT_FAR *PRTHCPHYS;
2003/** Pointer to const Host Physical Memory Address. */
2004typedef const RTHCPHYS RT_FAR *PCRTHCPHYS;
2005/** @def NIL_RTHCPHYS
2006 * NIL HC Physical Address.
2007 * NIL_RTHCPHYS is used to signal an invalid physical address, similar
2008 * to the NULL pointer.
2009 */
2010#define NIL_RTHCPHYS (~(RTHCPHYS)0)
2011/** Max RTHCPHYS value. */
2012#define RTHCPHYS_MAX UINT64_MAX
2013
2014
2015/** HC pointer. */
2016#if !defined(IN_RC) || defined(DOXYGEN_RUNNING)
2017typedef void RT_FAR *RTHCPTR;
2018#else
2019typedef RTHCUINTPTR RTHCPTR;
2020#endif
2021/** Pointer to HC pointer. */
2022typedef RTHCPTR RT_FAR *PRTHCPTR;
2023/** Pointer to const HC pointer. */
2024typedef const RTHCPTR *PCRTHCPTR;
2025/** @def NIL_RTHCPTR
2026 * NIL HC pointer.
2027 */
2028#define NIL_RTHCPTR ((RTHCPTR)0)
2029/** Max RTHCPTR value. */
2030#define RTHCPTR_MAX ((RTHCPTR)RTHCUINTPTR_MAX)
2031
2032
2033/** HC ring-3 pointer. */
2034#ifdef IN_RING3
2035typedef void RT_FAR *RTR3PTR;
2036#else
2037typedef RTR3UINTPTR RTR3PTR;
2038#endif
2039/** Pointer to HC ring-3 pointer. */
2040typedef RTR3PTR RT_FAR *PRTR3PTR;
2041/** Pointer to const HC ring-3 pointer. */
2042typedef const RTR3PTR *PCRTR3PTR;
2043/** @def NIL_RTR3PTR
2044 * NIL HC ring-3 pointer.
2045 */
2046#ifndef IN_RING3
2047# define NIL_RTR3PTR ((RTR3PTR)0)
2048#else
2049# define NIL_RTR3PTR (NULL)
2050#endif
2051/** Max RTR3PTR value. */
2052#define RTR3PTR_MAX ((RTR3PTR)RTR3UINTPTR_MAX)
2053
2054/** HC ring-0 pointer. */
2055#ifdef IN_RING0
2056typedef void RT_FAR *RTR0PTR;
2057#else
2058typedef RTR0UINTPTR RTR0PTR;
2059#endif
2060/** Pointer to HC ring-0 pointer. */
2061typedef RTR0PTR RT_FAR *PRTR0PTR;
2062/** Pointer to const HC ring-0 pointer. */
2063typedef const RTR0PTR *PCRTR0PTR;
2064/** @def NIL_RTR0PTR
2065 * NIL HC ring-0 pointer.
2066 */
2067#ifndef IN_RING0
2068# define NIL_RTR0PTR ((RTR0PTR)0)
2069#else
2070# define NIL_RTR0PTR (NULL)
2071#endif
2072/** Max RTR3PTR value. */
2073#define RTR0PTR_MAX ((RTR0PTR)RTR0UINTPTR_MAX)
2074
2075
2076/** Unsigned integer register in the host context. */
2077#if HC_ARCH_BITS == 32
2078typedef uint32_t RTHCUINTREG;
2079#elif HC_ARCH_BITS == 64
2080typedef uint64_t RTHCUINTREG;
2081#elif HC_ARCH_BITS == 16
2082typedef uint16_t RTHCUINTREG;
2083#else
2084# error "Unsupported HC_ARCH_BITS!"
2085#endif
2086/** Pointer to an unsigned integer register in the host context. */
2087typedef RTHCUINTREG RT_FAR *PRTHCUINTREG;
2088/** Pointer to a const unsigned integer register in the host context. */
2089typedef const RTHCUINTREG RT_FAR *PCRTHCUINTREG;
2090
2091/** Unsigned integer register in the host ring-3 context. */
2092#if R3_ARCH_BITS == 32
2093typedef uint32_t RTR3UINTREG;
2094#elif R3_ARCH_BITS == 64
2095typedef uint64_t RTR3UINTREG;
2096#elif R3_ARCH_BITS == 16
2097typedef uint16_t RTR3UINTREG;
2098#else
2099# error "Unsupported R3_ARCH_BITS!"
2100#endif
2101/** Pointer to an unsigned integer register in the host ring-3 context. */
2102typedef RTR3UINTREG RT_FAR *PRTR3UINTREG;
2103/** Pointer to a const unsigned integer register in the host ring-3 context. */
2104typedef const RTR3UINTREG RT_FAR *PCRTR3UINTREG;
2105
2106/** Unsigned integer register in the host ring-3 context. */
2107#if R0_ARCH_BITS == 32
2108typedef uint32_t RTR0UINTREG;
2109#elif R0_ARCH_BITS == 64
2110typedef uint64_t RTR0UINTREG;
2111#elif R0_ARCH_BITS == 16
2112typedef uint16_t RTR0UINTREG;
2113#else
2114# error "Unsupported R3_ARCH_BITS!"
2115#endif
2116/** Pointer to an unsigned integer register in the host ring-3 context. */
2117typedef RTR0UINTREG RT_FAR *PRTR0UINTREG;
2118/** Pointer to a const unsigned integer register in the host ring-3 context. */
2119typedef const RTR0UINTREG RT_FAR *PCRTR0UINTREG;
2120
2121/** @} */
2122
2123
2124/** @defgroup grp_rt_types_gc Guest Context Basic Types
2125 * @{
2126 */
2127
2128/** Natural signed integer in the GC.
2129 * @deprecated silly type. */
2130#if GC_ARCH_BITS == 32
2131typedef int32_t RTGCINT;
2132#elif GC_ARCH_BITS == 64 /** @todo this isn't right, natural int is 32-bit, see RTHCINT. */
2133typedef int64_t RTGCINT;
2134#endif
2135/** Pointer to natural signed integer in GC.
2136 * @deprecated silly type. */
2137typedef RTGCINT RT_FAR *PRTGCINT;
2138/** Pointer to const natural signed integer in GC.
2139 * @deprecated silly type. */
2140typedef const RTGCINT RT_FAR *PCRTGCINT;
2141
2142/** Natural unsigned integer in the GC.
2143 * @deprecated silly type. */
2144#if GC_ARCH_BITS == 32
2145typedef uint32_t RTGCUINT;
2146#elif GC_ARCH_BITS == 64 /** @todo this isn't right, natural int is 32-bit, see RTHCUINT. */
2147typedef uint64_t RTGCUINT;
2148#endif
2149/** Pointer to natural unsigned integer in GC.
2150 * @deprecated silly type. */
2151typedef RTGCUINT RT_FAR *PRTGCUINT;
2152/** Pointer to const natural unsigned integer in GC.
2153 * @deprecated silly type. */
2154typedef const RTGCUINT RT_FAR *PCRTGCUINT;
2155
2156/** Signed integer which can contain a GC pointer. */
2157#if GC_ARCH_BITS == 32
2158typedef int32_t RTGCINTPTR;
2159#elif GC_ARCH_BITS == 64
2160typedef int64_t RTGCINTPTR;
2161#endif
2162/** Pointer to signed integer which can contain a GC pointer. */
2163typedef RTGCINTPTR RT_FAR *PRTGCINTPTR;
2164/** Pointer to const signed integer which can contain a GC pointer. */
2165typedef const RTGCINTPTR RT_FAR *PCRTGCINTPTR;
2166
2167/** Unsigned integer which can contain a GC pointer. */
2168#if GC_ARCH_BITS == 32
2169typedef uint32_t RTGCUINTPTR;
2170#elif GC_ARCH_BITS == 64
2171typedef uint64_t RTGCUINTPTR;
2172#else
2173# error Unsupported GC_ARCH_BITS value.
2174#endif
2175/** Pointer to unsigned integer which can contain a GC pointer. */
2176typedef RTGCUINTPTR RT_FAR *PRTGCUINTPTR;
2177/** Pointer to unsigned integer which can contain a GC pointer. */
2178typedef const RTGCUINTPTR RT_FAR *PCRTGCUINTPTR;
2179
2180/** Unsigned integer which can contain a 32 bits GC pointer. */
2181typedef uint32_t RTGCUINTPTR32;
2182/** Pointer to unsigned integer which can contain a 32 bits GC pointer. */
2183typedef RTGCUINTPTR32 RT_FAR *PRTGCUINTPTR32;
2184/** Pointer to unsigned integer which can contain a 32 bits GC pointer. */
2185typedef const RTGCUINTPTR32 RT_FAR *PCRTGCUINTPTR32;
2186
2187/** Unsigned integer which can contain a 64 bits GC pointer. */
2188typedef uint64_t RTGCUINTPTR64;
2189/** Pointer to unsigned integer which can contain a 32 bits GC pointer. */
2190typedef RTGCUINTPTR64 RT_FAR *PRTGCUINTPTR64;
2191/** Pointer to unsigned integer which can contain a 32 bits GC pointer. */
2192typedef const RTGCUINTPTR64 RT_FAR *PCRTGCUINTPTR64;
2193
2194/** Guest Physical Memory Address.*/
2195typedef uint64_t RTGCPHYS;
2196/** Pointer to Guest Physical Memory Address. */
2197typedef RTGCPHYS RT_FAR *PRTGCPHYS;
2198/** Pointer to const Guest Physical Memory Address. */
2199typedef const RTGCPHYS RT_FAR *PCRTGCPHYS;
2200/** @def NIL_RTGCPHYS
2201 * NIL GC Physical Address.
2202 * NIL_RTGCPHYS is used to signal an invalid physical address, similar
2203 * to the NULL pointer. Note that this value may actually be valid in
2204 * some contexts.
2205 */
2206#define NIL_RTGCPHYS (~(RTGCPHYS)0U)
2207/** Max guest physical memory address value. */
2208#define RTGCPHYS_MAX UINT64_MAX
2209
2210
2211/** Guest Physical Memory Address; limited to 32 bits.*/
2212typedef uint32_t RTGCPHYS32;
2213/** Pointer to Guest Physical Memory Address. */
2214typedef RTGCPHYS32 RT_FAR *PRTGCPHYS32;
2215/** Pointer to const Guest Physical Memory Address. */
2216typedef const RTGCPHYS32 RT_FAR *PCRTGCPHYS32;
2217/** @def NIL_RTGCPHYS32
2218 * NIL GC Physical Address.
2219 * NIL_RTGCPHYS32 is used to signal an invalid physical address, similar
2220 * to the NULL pointer. Note that this value may actually be valid in
2221 * some contexts.
2222 */
2223#define NIL_RTGCPHYS32 (~(RTGCPHYS32)0)
2224
2225
2226/** Guest Physical Memory Address; limited to 64 bits.*/
2227typedef uint64_t RTGCPHYS64;
2228/** Pointer to Guest Physical Memory Address. */
2229typedef RTGCPHYS64 RT_FAR *PRTGCPHYS64;
2230/** Pointer to const Guest Physical Memory Address. */
2231typedef const RTGCPHYS64 RT_FAR *PCRTGCPHYS64;
2232/** @def NIL_RTGCPHYS64
2233 * NIL GC Physical Address.
2234 * NIL_RTGCPHYS64 is used to signal an invalid physical address, similar
2235 * to the NULL pointer. Note that this value may actually be valid in
2236 * some contexts.
2237 */
2238#define NIL_RTGCPHYS64 (~(RTGCPHYS64)0)
2239
2240/** Guest context pointer, 32 bits.
2241 * Keep in mind that this type is an unsigned integer in
2242 * HC and void pointer in GC.
2243 */
2244typedef RTGCUINTPTR32 RTGCPTR32;
2245/** Pointer to a guest context pointer. */
2246typedef RTGCPTR32 RT_FAR *PRTGCPTR32;
2247/** Pointer to a const guest context pointer. */
2248typedef const RTGCPTR32 RT_FAR *PCRTGCPTR32;
2249/** @def NIL_RTGCPTR32
2250 * NIL GC pointer.
2251 */
2252#define NIL_RTGCPTR32 ((RTGCPTR32)0)
2253
2254/** Guest context pointer, 64 bits.
2255 */
2256typedef RTGCUINTPTR64 RTGCPTR64;
2257/** Pointer to a guest context pointer. */
2258typedef RTGCPTR64 RT_FAR *PRTGCPTR64;
2259/** Pointer to a const guest context pointer. */
2260typedef const RTGCPTR64 RT_FAR *PCRTGCPTR64;
2261/** @def NIL_RTGCPTR64
2262 * NIL GC pointer.
2263 */
2264#define NIL_RTGCPTR64 ((RTGCPTR64)0)
2265
2266/** @typedef RTGCPTR
2267 * Guest context pointer.
2268 * Keep in mind that this type is an unsigned integer in HC and void pointer in GC. */
2269/** @typedef PRTGCPTR
2270 * Pointer to a guest context pointer. */
2271/** @typedef PCRTGCPTR
2272 * Pointer to a const guest context pointer. */
2273/** @def NIL_RTGCPTR
2274 * NIL GC pointer. */
2275/** @def RTGCPTR_MAX
2276 * Max RTGCPTR value. */
2277#if GC_ARCH_BITS == 64 || defined(DOXYGEN_RUNNING)
2278typedef RTGCPTR64 RTGCPTR;
2279typedef PRTGCPTR64 PRTGCPTR;
2280typedef PCRTGCPTR64 PCRTGCPTR;
2281# define NIL_RTGCPTR NIL_RTGCPTR64
2282# define RTGCPTR_MAX UINT64_MAX
2283#elif GC_ARCH_BITS == 32
2284typedef RTGCPTR32 RTGCPTR;
2285typedef PRTGCPTR32 PRTGCPTR;
2286typedef PCRTGCPTR32 PCRTGCPTR;
2287# define NIL_RTGCPTR NIL_RTGCPTR32
2288# define RTGCPTR_MAX UINT32_MAX
2289#else
2290# error "Unsupported GC_ARCH_BITS!"
2291#endif
2292
2293/** Unsigned integer register in the guest context. */
2294typedef uint32_t RTGCUINTREG32;
2295/** Pointer to an unsigned integer register in the guest context. */
2296typedef RTGCUINTREG32 RT_FAR *PRTGCUINTREG32;
2297/** Pointer to a const unsigned integer register in the guest context. */
2298typedef const RTGCUINTREG32 RT_FAR *PCRTGCUINTREG32;
2299
2300typedef uint64_t RTGCUINTREG64;
2301/** Pointer to an unsigned integer register in the guest context. */
2302typedef RTGCUINTREG64 RT_FAR *PRTGCUINTREG64;
2303/** Pointer to a const unsigned integer register in the guest context. */
2304typedef const RTGCUINTREG64 RT_FAR *PCRTGCUINTREG64;
2305
2306#if GC_ARCH_BITS == 64
2307typedef RTGCUINTREG64 RTGCUINTREG;
2308#elif GC_ARCH_BITS == 32
2309typedef RTGCUINTREG32 RTGCUINTREG;
2310#else
2311# error "Unsupported GC_ARCH_BITS!"
2312#endif
2313/** Pointer to an unsigned integer register in the guest context. */
2314typedef RTGCUINTREG RT_FAR *PRTGCUINTREG;
2315/** Pointer to a const unsigned integer register in the guest context. */
2316typedef const RTGCUINTREG RT_FAR *PCRTGCUINTREG;
2317
2318/** @} */
2319
2320/** @defgroup grp_rt_types_rc Raw mode Context Basic Types
2321 * @{
2322 */
2323
2324/** Raw mode context pointer; a 32 bits guest context pointer.
2325 * Keep in mind that this type is an unsigned integer in
2326 * HC and void pointer in RC.
2327 */
2328#ifdef IN_RC
2329typedef void RT_FAR *RTRCPTR;
2330#else
2331typedef uint32_t RTRCPTR;
2332#endif
2333/** Pointer to a raw mode context pointer. */
2334typedef RTRCPTR RT_FAR *PRTRCPTR;
2335/** Pointer to a const raw mode context pointer. */
2336typedef const RTRCPTR RT_FAR *PCRTRCPTR;
2337/** @def NIL_RTRCPTR
2338 * NIL RC pointer. */
2339#ifdef IN_RC
2340# define NIL_RTRCPTR (NULL)
2341#else
2342# define NIL_RTRCPTR ((RTRCPTR)0)
2343#endif
2344/** @def RTRCPTR_MAX
2345 * The maximum value a RTRCPTR can have. Mostly used as INVALID value.
2346 */
2347#define RTRCPTR_MAX ((RTRCPTR)UINT32_MAX)
2348
2349/** Raw mode context pointer, unsigned integer variant. */
2350typedef int32_t RTRCINTPTR;
2351/** @def RTRCUINTPTR_MAX
2352 * The maximum value a RTRCUINPTR can have.
2353 */
2354#define RTRCUINTPTR_MAX ((RTRCUINTPTR)UINT32_MAX)
2355
2356/** Raw mode context pointer, signed integer variant. */
2357typedef uint32_t RTRCUINTPTR;
2358/** @def RTRCINTPTR_MIN
2359 * The minimum value a RTRCINPTR can have.
2360 */
2361#define RTRCINTPTR_MIN ((RTRCINTPTR)INT32_MIN)
2362/** @def RTRCINTPTR_MAX
2363 * The maximum value a RTRCINPTR can have.
2364 */
2365#define RTRCINTPTR_MAX ((RTRCINTPTR)INT32_MAX)
2366
2367/* The following are only temporarily while we clean up RTRCPTR usage: */
2368#ifdef IN_RC
2369typedef void RT_FAR *RTRGPTR;
2370#else
2371typedef uint64_t RTRGPTR;
2372#endif
2373typedef RTRGPTR RT_FAR *PRTRGPTR;
2374typedef const RTRGPTR RT_FAR *PCRTRGPTR;
2375#ifdef IN_RC
2376# define NIL_RTRGPTR (NULL)
2377#else
2378# define NIL_RTRGPTR ((RTRGPTR)0)
2379#endif
2380
2381/** @} */
2382
2383
2384/** @defgroup grp_rt_types_cc Current Context Basic Types
2385 * @{
2386 */
2387
2388/** Current Context Physical Memory Address.*/
2389#ifdef IN_RC
2390typedef RTGCPHYS RTCCPHYS;
2391#else
2392typedef RTHCPHYS RTCCPHYS;
2393#endif
2394/** Pointer to Current Context Physical Memory Address. */
2395typedef RTCCPHYS RT_FAR *PRTCCPHYS;
2396/** Pointer to const Current Context Physical Memory Address. */
2397typedef const RTCCPHYS RT_FAR *PCRTCCPHYS;
2398/** @def NIL_RTCCPHYS
2399 * NIL CC Physical Address.
2400 * NIL_RTCCPHYS is used to signal an invalid physical address, similar
2401 * to the NULL pointer.
2402 */
2403#ifdef IN_RC
2404# define NIL_RTCCPHYS NIL_RTGCPHYS
2405#else
2406# define NIL_RTCCPHYS NIL_RTHCPHYS
2407#endif
2408
2409/** Unsigned integer register in the current context. */
2410#if ARCH_BITS == 32
2411typedef uint32_t RTCCUINTREG;
2412#elif ARCH_BITS == 64
2413typedef uint64_t RTCCUINTREG;
2414#elif ARCH_BITS == 16
2415typedef uint16_t RTCCUINTREG;
2416#else
2417# error "Unsupported ARCH_BITS!"
2418#endif
2419/** Pointer to an unsigned integer register in the current context. */
2420typedef RTCCUINTREG RT_FAR *PRTCCUINTREG;
2421/** Pointer to a const unsigned integer register in the current context. */
2422typedef RTCCUINTREG const RT_FAR *PCRTCCUINTREG;
2423
2424/** Signed integer register in the current context. */
2425#if ARCH_BITS == 32
2426typedef int32_t RTCCINTREG;
2427#elif ARCH_BITS == 64
2428typedef int64_t RTCCINTREG;
2429#elif ARCH_BITS == 16
2430typedef int16_t RTCCINTREG;
2431#endif
2432/** Pointer to a signed integer register in the current context. */
2433typedef RTCCINTREG RT_FAR *PRTCCINTREG;
2434/** Pointer to a const signed integer register in the current context. */
2435typedef RTCCINTREG const RT_FAR *PCRTCCINTREG;
2436
2437/** Unsigned integer register in the current context.
2438 * @remarks This is for dealing with EAX in 16-bit mode. */
2439#if ARCH_BITS == 16 && defined(RT_ARCH_X86)
2440typedef uint32_t RTCCUINTXREG;
2441#else
2442typedef RTCCUINTREG RTCCUINTXREG;
2443#endif
2444/** Pointer to an unsigned integer register in the current context. */
2445typedef RTCCUINTREG RT_FAR *PRTCCUINTXREG;
2446/** Pointer to a const unsigned integer register in the current context. */
2447typedef RTCCUINTREG const RT_FAR *PCRTCCUINTXREG;
2448
2449/** Signed integer extended register in the current context.
2450 * @remarks This is for dealing with EAX in 16-bit mode. */
2451#if ARCH_BITS == 16 && defined(RT_ARCH_X86)
2452typedef int32_t RTCCINTXREG;
2453#else
2454typedef RTCCINTREG RTCCINTXREG;
2455#endif
2456/** Pointer to a signed integer extended register in the current context. */
2457typedef RTCCINTXREG RT_FAR *PRTCCINTXREG;
2458/** Pointer to a const signed integer extended register in the current
2459 * context. */
2460typedef RTCCINTXREG const RT_FAR *PCRTCCINTXREG;
2461
2462/** @def RTCCUINTREG_C
2463 * Defines a constant of RTCCUINTREG type.
2464 * @param a_Value Constant value */
2465/** @def RTCCUINTREG_MAX
2466 * Max value that RTCCUINTREG can hold. */
2467/** @def RTCCUINTREG_FMT
2468 * Generic IPRT format specifier for RTCCUINTREG. */
2469/** @def RTCCUINTREG_XFMT
2470 * Generic IPRT format specifier for RTCCUINTREG, hexadecimal. */
2471/** @def RTCCINTREG_C
2472 * Defines a constant of RTCCINTREG type.
2473 * @param a_Value Constant value */
2474/** @def RTCCINTREG_MAX
2475 * Max value that RTCCINTREG can hold. */
2476/** @def RTCCINTREG_MIN
2477 * Min value that RTCCINTREG can hold. */
2478/** @def RTCCINTREG_XFMT
2479 * Generic IPRT format specifier for RTCCINTREG, hexadecimal. */
2480#if ARCH_BITS == 32
2481# define RTCCUINTREG_C(a_Value) UINT32_C(a_Value)
2482# define RTCCUINTREG_MAX UINT32_MAX
2483# define RTCCUINTREG_FMT "RU32"
2484# define RTCCUINTREG_XFMT "RX32"
2485# define RTCCINTREG_C(a_Value) INT32_C(a_Value)
2486# define RTCCINTREG_MAX INT32_MAX
2487# define RTCCINTREG_MIN INT32_MIN
2488# define RTCCINTREG_FMT "RI32"
2489# define RTCCINTREG_XFMT "RX32"
2490#elif ARCH_BITS == 64
2491# define RTCCUINTREG_C(a_Value) UINT64_C(a_Value)
2492# define RTCCUINTREG_MAX UINT64_MAX
2493# define RTCCUINTREG_FMT "RU64"
2494# define RTCCUINTREG_XFMT "RX64"
2495# define RTCCINTREG_C(a_Value) INT64_C(a_Value)
2496# define RTCCINTREG_MAX INT64_MAX
2497# define RTCCINTREG_MIN INT64_MIN
2498# define RTCCINTREG_FMT "RI64"
2499# define RTCCINTREG_XFMT "RX64"
2500#elif ARCH_BITS == 16
2501# define RTCCUINTREG_C(a_Value) UINT16_C(a_Value)
2502# define RTCCUINTREG_MAX UINT16_MAX
2503# define RTCCUINTREG_FMT "RU16"
2504# define RTCCUINTREG_XFMT "RX16"
2505# define RTCCINTREG_C(a_Value) INT16_C(a_Value)
2506# define RTCCINTREG_MAX INT16_MAX
2507# define RTCCINTREG_MIN INT16_MIN
2508# define RTCCINTREG_FMT "RI16"
2509# define RTCCINTREG_XFMT "RX16"
2510#else
2511# error "Unsupported ARCH_BITS!"
2512#endif
2513/** @def RTCCUINTXREG_C
2514 * Defines a constant of RTCCUINTXREG type.
2515 * @param a_Value Constant value */
2516/** @def RTCCUINTXREG_MAX
2517 * Max value that RTCCUINTXREG can hold. */
2518/** @def RTCCUINTXREG_FMT
2519 * Generic IPRT format specifier for RTCCUINTXREG. */
2520/** @def RTCCUINTXREG_XFMT
2521 * Generic IPRT format specifier for RTCCUINTXREG, hexadecimal. */
2522/** @def RTCCINTXREG_C
2523 * Defines a constant of RTCCINTXREG type.
2524 * @param a_Value Constant value */
2525/** @def RTCCINTXREG_MAX
2526 * Max value that RTCCINTXREG can hold. */
2527/** @def RTCCINTXREG_MIN
2528 * Min value that RTCCINTXREG can hold. */
2529/** @def RTCCINTXREG_FMT
2530 * Generic IPRT format specifier for RTCCINTXREG. */
2531/** @def RTCCINTXREG_XFMT
2532 * Generic IPRT format specifier for RTCCINTXREG, hexadecimal. */
2533#if ARCH_BITS == 16 && defined(RT_ARCH_X86)
2534# define RTCCUINTXREG_C(a_Value) UINT32_C(a_Value)
2535# define RTCCUINTXREG_MAX UINT32_MAX
2536# define RTCCUINTXREG_FMT "RU32"
2537# define RTCCUINTXREG_XFMT "RX32"
2538# define RTCCINTXREG_C(a_Value) INT32_C(a_Value)
2539# define RTCCINTXREG_MAX INT32_MAX
2540# define RTCCINTXREG_MIN INT32_MIN
2541# define RTCCINTXREG_FMT "RI32"
2542# define RTCCINTXREG_XFMT "RX32"
2543#else
2544# define RTCCUINTXREG_C(a_Value) RTCCUINTREG_C(a_Value)
2545# define RTCCUINTXREG_MAX RTCCUINTREG_MAX
2546# define RTCCUINTXREG_FMT RTCCUINTREG_FMT
2547# define RTCCUINTXREG_XFMT RTCCUINTREG_XFMT
2548# define RTCCINTXREG_C(a_Value) RTCCINTREG_C(a_Value)
2549# define RTCCINTXREG_MAX RTCCINTREG_MAX
2550# define RTCCINTXREG_MIN RTCCINTREG_MIN
2551# define RTCCINTXREG_FMT RTCCINTREG_FMT
2552# define RTCCINTXREG_XFMT RTCCINTREG_XFMT
2553#endif
2554/** @} */
2555
2556
2557
2558/** Pointer to a big integer number. */
2559typedef struct RTBIGNUM RT_FAR *PRTBIGNUM;
2560/** Pointer to a const big integer number. */
2561typedef struct RTBIGNUM const RT_FAR *PCRTBIGNUM;
2562
2563
2564/** Pointer to a critical section. */
2565typedef struct RTCRITSECT RT_FAR *PRTCRITSECT;
2566/** Pointer to a const critical section. */
2567typedef const struct RTCRITSECT RT_FAR *PCRTCRITSECT;
2568
2569/** Pointer to a read/write critical section. */
2570typedef struct RTCRITSECTRW RT_FAR *PRTCRITSECTRW;
2571/** Pointer to a const read/write critical section. */
2572typedef const struct RTCRITSECTRW RT_FAR *PCRTCRITSECTRW;
2573
2574
2575/** Condition variable handle. */
2576typedef R3PTRTYPE(struct RTCONDVARINTERNAL RT_FAR *) RTCONDVAR;
2577/** Pointer to a condition variable handle. */
2578typedef RTCONDVAR RT_FAR *PRTCONDVAR;
2579/** Nil condition variable handle. */
2580#define NIL_RTCONDVAR 0
2581
2582/** Cryptographic (certificate) store handle. */
2583typedef R3R0PTRTYPE(struct RTCRSTOREINT RT_FAR *) RTCRSTORE;
2584/** Pointer to a Cryptographic (certificate) store handle. */
2585typedef RTCRSTORE RT_FAR *PRTCRSTORE;
2586/** Nil Cryptographic (certificate) store handle. */
2587#define NIL_RTCRSTORE 0
2588
2589/** Pointer to a const (store) certificate context. */
2590typedef struct RTCRCERTCTX const RT_FAR *PCRTCRCERTCTX;
2591
2592/** Cryptographic message digest handle. */
2593typedef R3R0PTRTYPE(struct RTCRDIGESTINT RT_FAR *) RTCRDIGEST;
2594/** Pointer to a cryptographic message digest handle. */
2595typedef RTCRDIGEST RT_FAR *PRTCRDIGEST;
2596/** NIL cryptographic message digest handle. */
2597#define NIL_RTCRDIGEST (0)
2598
2599/** Cryptographic key handle. */
2600typedef R3R0PTRTYPE(struct RTCRKEYINT RT_FAR *) RTCRKEY;
2601/** Pointer to a cryptographic key handle. */
2602typedef RTCRKEY RT_FAR *PRTCRKEY;
2603/** Cryptographic key handle nil value. */
2604#define NIL_RTCRKEY (0)
2605
2606/** Public key encryption schema handle. */
2607typedef R3R0PTRTYPE(struct RTCRPKIXENCRYPTIONINT RT_FAR *) RTCRPKIXENCRYPTION;
2608/** Pointer to a public key encryption schema handle. */
2609typedef RTCRPKIXENCRYPTION RT_FAR *PRTCRPKIXENCRYPTION;
2610/** NIL public key encryption schema handle */
2611#define NIL_RTCRPKIXENCRYPTION (0)
2612
2613/** Public key signature schema handle. */
2614typedef R3R0PTRTYPE(struct RTCRPKIXSIGNATUREINT RT_FAR *) RTCRPKIXSIGNATURE;
2615/** Pointer to a public key signature schema handle. */
2616typedef RTCRPKIXSIGNATURE RT_FAR *PRTCRPKIXSIGNATURE;
2617/** NIL public key signature schema handle */
2618#define NIL_RTCRPKIXSIGNATURE (0)
2619
2620/** X.509 certificate paths builder & validator handle. */
2621typedef R3R0PTRTYPE(struct RTCRX509CERTPATHSINT RT_FAR *) RTCRX509CERTPATHS;
2622/** Pointer to a certificate paths builder & validator handle. */
2623typedef RTCRX509CERTPATHS RT_FAR *PRTCRX509CERTPATHS;
2624/** Nil certificate paths builder & validator handle. */
2625#define NIL_RTCRX509CERTPATHS 0
2626
2627/** Directory handle. */
2628typedef struct RTDIRINTERNAL *RTDIR;
2629/** Pointer to directory handle. */
2630typedef RTDIR *PRTDIR;
2631/** NIL directory handle. */
2632#define NIL_RTDIR ((RTDIR)0)
2633
2634/** File handle. */
2635typedef R3R0PTRTYPE(struct RTFILEINT RT_FAR *) RTFILE;
2636/** Pointer to file handle. */
2637typedef RTFILE RT_FAR *PRTFILE;
2638/** Nil file handle. */
2639#define NIL_RTFILE ((RTFILE)~(RTHCINTPTR)0)
2640
2641/** Async I/O request handle. */
2642typedef R3PTRTYPE(struct RTFILEAIOREQINTERNAL RT_FAR *) RTFILEAIOREQ;
2643/** Pointer to an async I/O request handle. */
2644typedef RTFILEAIOREQ RT_FAR *PRTFILEAIOREQ;
2645/** Nil request handle. */
2646#define NIL_RTFILEAIOREQ 0
2647
2648/** Async I/O completion context handle. */
2649typedef R3PTRTYPE(struct RTFILEAIOCTXINTERNAL RT_FAR *) RTFILEAIOCTX;
2650/** Pointer to an async I/O completion context handle. */
2651typedef RTFILEAIOCTX RT_FAR *PRTFILEAIOCTX;
2652/** Nil context handle. */
2653#define NIL_RTFILEAIOCTX 0
2654
2655/** ISO image maker handle. */
2656typedef struct RTFSISOMAKERINT RT_FAR *RTFSISOMAKER;
2657/** Pointer to an ISO image maker handle. */
2658typedef RTFSISOMAKER RT_FAR *PRTFSISOMAKER;
2659/** NIL ISO maker handle. */
2660#define NIL_RTFSISOMAKER ((RTFSISOMAKER)0)
2661
2662/** INI-file handle. */
2663typedef struct RTINIFILEINT RT_FAR *RTINIFILE;
2664/** Pointer to an INI-file handle. */
2665typedef RTINIFILE RT_FAR *PRTINIFILE;
2666/** NIL INI-file handle. */
2667#define NIL_RTINIFILE ((RTINIFILE)0)
2668
2669/** Loader module handle. */
2670typedef R3R0PTRTYPE(struct RTLDRMODINTERNAL RT_FAR *) RTLDRMOD;
2671/** Pointer to a loader module handle. */
2672typedef RTLDRMOD RT_FAR *PRTLDRMOD;
2673/** Nil loader module handle. */
2674#define NIL_RTLDRMOD 0
2675
2676/** Lock validator class handle. */
2677typedef R3R0PTRTYPE(struct RTLOCKVALCLASSINT RT_FAR *) RTLOCKVALCLASS;
2678/** Pointer to a lock validator class handle. */
2679typedef RTLOCKVALCLASS RT_FAR *PRTLOCKVALCLASS;
2680/** Nil lock validator class handle. */
2681#define NIL_RTLOCKVALCLASS ((RTLOCKVALCLASS)0)
2682
2683/** Ring-0 memory object handle. */
2684typedef R0PTRTYPE(struct RTR0MEMOBJINTERNAL RT_FAR *) RTR0MEMOBJ;
2685/** Pointer to a Ring-0 memory object handle. */
2686typedef RTR0MEMOBJ RT_FAR *PRTR0MEMOBJ;
2687/** Nil ring-0 memory object handle. */
2688#define NIL_RTR0MEMOBJ 0
2689
2690/** Native thread handle. */
2691typedef RTHCUINTPTR RTNATIVETHREAD;
2692/** Pointer to an native thread handle. */
2693typedef RTNATIVETHREAD RT_FAR *PRTNATIVETHREAD;
2694/** Nil native thread handle. */
2695#define NIL_RTNATIVETHREAD (~(RTNATIVETHREAD)0)
2696
2697/** Pipe handle. */
2698typedef R3R0PTRTYPE(struct RTPIPEINTERNAL RT_FAR *) RTPIPE;
2699/** Pointer to a pipe handle. */
2700typedef RTPIPE RT_FAR *PRTPIPE;
2701/** Nil pipe handle.
2702 * @remarks This is not 0 because of UNIX and OS/2 handle values. Take care! */
2703#define NIL_RTPIPE ((RTPIPE)RTHCUINTPTR_MAX)
2704
2705/** @typedef RTPOLLSET
2706 * Poll set handle. */
2707typedef R3R0PTRTYPE(struct RTPOLLSETINTERNAL RT_FAR *) RTPOLLSET;
2708/** Pointer to a poll set handle. */
2709typedef RTPOLLSET RT_FAR *PRTPOLLSET;
2710/** Nil poll set handle handle. */
2711#define NIL_RTPOLLSET ((RTPOLLSET)0)
2712
2713/** Process identifier. */
2714typedef uint32_t RTPROCESS;
2715/** Pointer to a process identifier. */
2716typedef RTPROCESS RT_FAR *PRTPROCESS;
2717/** Nil process identifier. */
2718#define NIL_RTPROCESS (~(RTPROCESS)0)
2719
2720/** Process ring-0 handle. */
2721typedef RTR0UINTPTR RTR0PROCESS;
2722/** Pointer to a ring-0 process handle. */
2723typedef RTR0PROCESS RT_FAR *PRTR0PROCESS;
2724/** Nil ring-0 process handle. */
2725#define NIL_RTR0PROCESS (~(RTR0PROCESS)0)
2726
2727/** @typedef RTSEMEVENT
2728 * Event Semaphore handle. */
2729typedef R3R0PTRTYPE(struct RTSEMEVENTINTERNAL RT_FAR *) RTSEMEVENT;
2730/** Pointer to an event semaphore handle. */
2731typedef RTSEMEVENT RT_FAR *PRTSEMEVENT;
2732/** Nil event semaphore handle. */
2733#define NIL_RTSEMEVENT 0
2734
2735/** @typedef RTSEMEVENTMULTI
2736 * Event Multiple Release Semaphore handle. */
2737typedef R3R0PTRTYPE(struct RTSEMEVENTMULTIINTERNAL RT_FAR *) RTSEMEVENTMULTI;
2738/** Pointer to an event multiple release semaphore handle. */
2739typedef RTSEMEVENTMULTI RT_FAR *PRTSEMEVENTMULTI;
2740/** Nil multiple release event semaphore handle. */
2741#define NIL_RTSEMEVENTMULTI 0
2742
2743/** @typedef RTSEMFASTMUTEX
2744 * Fast mutex Semaphore handle. */
2745typedef R3R0PTRTYPE(struct RTSEMFASTMUTEXINTERNAL RT_FAR *) RTSEMFASTMUTEX;
2746/** Pointer to a fast mutex semaphore handle. */
2747typedef RTSEMFASTMUTEX RT_FAR *PRTSEMFASTMUTEX;
2748/** Nil fast mutex semaphore handle. */
2749#define NIL_RTSEMFASTMUTEX 0
2750
2751/** @typedef RTSEMMUTEX
2752 * Mutex Semaphore handle. */
2753typedef R3R0PTRTYPE(struct RTSEMMUTEXINTERNAL RT_FAR *) RTSEMMUTEX;
2754/** Pointer to a mutex semaphore handle. */
2755typedef RTSEMMUTEX RT_FAR *PRTSEMMUTEX;
2756/** Nil mutex semaphore handle. */
2757#define NIL_RTSEMMUTEX 0
2758
2759/** @typedef RTSEMSPINMUTEX
2760 * Spinning mutex Semaphore handle. */
2761typedef R3R0PTRTYPE(struct RTSEMSPINMUTEXINTERNAL RT_FAR *) RTSEMSPINMUTEX;
2762/** Pointer to a spinning mutex semaphore handle. */
2763typedef RTSEMSPINMUTEX RT_FAR *PRTSEMSPINMUTEX;
2764/** Nil spinning mutex semaphore handle. */
2765#define NIL_RTSEMSPINMUTEX 0
2766
2767/** @typedef RTSEMRW
2768 * Read/Write Semaphore handle. */
2769typedef R3R0PTRTYPE(struct RTSEMRWINTERNAL RT_FAR *) RTSEMRW;
2770/** Pointer to a read/write semaphore handle. */
2771typedef RTSEMRW RT_FAR *PRTSEMRW;
2772/** Nil read/write semaphore handle. */
2773#define NIL_RTSEMRW 0
2774
2775/** @typedef RTSEMXROADS
2776 * Crossroads semaphore handle. */
2777typedef R3R0PTRTYPE(struct RTSEMXROADSINTERNAL RT_FAR *) RTSEMXROADS;
2778/** Pointer to a crossroads semaphore handle. */
2779typedef RTSEMXROADS RT_FAR *PRTSEMXROADS;
2780/** Nil crossroads semaphore handle. */
2781#define NIL_RTSEMXROADS ((RTSEMXROADS)0)
2782
2783/** Spinlock handle. */
2784typedef R3R0PTRTYPE(struct RTSPINLOCKINTERNAL RT_FAR *) RTSPINLOCK;
2785/** Pointer to a spinlock handle. */
2786typedef RTSPINLOCK RT_FAR *PRTSPINLOCK;
2787/** Nil spinlock handle. */
2788#define NIL_RTSPINLOCK 0
2789
2790/** Socket handle. */
2791typedef R3R0PTRTYPE(struct RTSOCKETINT RT_FAR *) RTSOCKET;
2792/** Pointer to socket handle. */
2793typedef RTSOCKET RT_FAR *PRTSOCKET;
2794/** Nil socket handle. */
2795#define NIL_RTSOCKET ((RTSOCKET)0)
2796
2797/** Pointer to a RTTCPSERVER handle. */
2798typedef struct RTTCPSERVER RT_FAR *PRTTCPSERVER;
2799/** Pointer to a RTTCPSERVER handle. */
2800typedef PRTTCPSERVER RT_FAR *PPRTTCPSERVER;
2801/** Nil RTTCPSERVER handle. */
2802#define NIL_RTTCPSERVER ((PRTTCPSERVER)0)
2803
2804/** Pointer to a RTUDPSERVER handle. */
2805typedef struct RTUDPSERVER RT_FAR *PRTUDPSERVER;
2806/** Pointer to a RTUDPSERVER handle. */
2807typedef PRTUDPSERVER RT_FAR *PPRTUDPSERVER;
2808/** Nil RTUDPSERVER handle. */
2809#define NIL_RTUDPSERVER ((PRTUDPSERVER)0)
2810
2811/** Thread handle.*/
2812typedef R3R0PTRTYPE(struct RTTHREADINT RT_FAR *) RTTHREAD;
2813/** Pointer to thread handle. */
2814typedef RTTHREAD RT_FAR *PRTTHREAD;
2815/** Nil thread handle. */
2816#define NIL_RTTHREAD 0
2817
2818/** Thread context switching hook handle. */
2819typedef R0PTRTYPE(struct RTTHREADCTXHOOKINT RT_FAR *) RTTHREADCTXHOOK;
2820/** Pointer to Thread context switching hook handle. */
2821typedef RTTHREADCTXHOOK RT_FAR *PRTTHREADCTXHOOK;
2822/** Nil Thread context switching hook handle. */
2823#define NIL_RTTHREADCTXHOOK ((RTTHREADCTXHOOK)0)
2824
2825/** A TLS index. */
2826typedef RTHCINTPTR RTTLS;
2827/** Pointer to a TLS index. */
2828typedef RTTLS RT_FAR *PRTTLS;
2829/** Pointer to a const TLS index. */
2830typedef RTTLS const RT_FAR *PCRTTLS;
2831/** NIL TLS index value. */
2832#define NIL_RTTLS ((RTTLS)-1)
2833
2834/** Trace buffer handle.
2835 * @remarks This is not a R3/R0 type like most other handles!
2836 */
2837typedef struct RTTRACEBUFINT RT_FAR *RTTRACEBUF;
2838/** Pointer to a trace buffer handle. */
2839typedef RTTRACEBUF RT_FAR *PRTTRACEBUF;
2840/** Nil trace buffer handle. */
2841#define NIL_RTTRACEBUF ((RTTRACEBUF)0)
2842/** The handle of the default trace buffer.
2843 * This can be used with any of the RTTraceBufAdd APIs. */
2844#define RTTRACEBUF_DEFAULT ((RTTRACEBUF)-2)
2845
2846/** Handle to a simple heap. */
2847typedef R3R0PTRTYPE(struct RTHEAPSIMPLEINTERNAL RT_FAR *) RTHEAPSIMPLE;
2848/** Pointer to a handle to a simple heap. */
2849typedef RTHEAPSIMPLE RT_FAR *PRTHEAPSIMPLE;
2850/** NIL simple heap handle. */
2851#define NIL_RTHEAPSIMPLE ((RTHEAPSIMPLE)0)
2852
2853/** Handle to an offset based heap. */
2854typedef R3R0PTRTYPE(struct RTHEAPOFFSETINTERNAL RT_FAR *) RTHEAPOFFSET;
2855/** Pointer to a handle to an offset based heap. */
2856typedef RTHEAPOFFSET RT_FAR *PRTHEAPOFFSET;
2857/** NIL offset based heap handle. */
2858#define NIL_RTHEAPOFFSET ((RTHEAPOFFSET)0)
2859
2860/** Handle to an environment block. */
2861typedef R3PTRTYPE(struct RTENVINTERNAL RT_FAR *) RTENV;
2862/** Pointer to a handle to an environment block. */
2863typedef RTENV RT_FAR *PRTENV;
2864/** NIL simple heap handle. */
2865#define NIL_RTENV ((RTENV)0)
2866
2867/** A CPU identifier.
2868 * @remarks This doesn't have to correspond to the APIC ID (intel/amd). Nor
2869 * does it have to correspond to the bits in the affinity mask, at
2870 * least not until we've sorted out Windows NT. */
2871typedef uint32_t RTCPUID;
2872/** Pointer to a CPU identifier. */
2873typedef RTCPUID RT_FAR *PRTCPUID;
2874/** Pointer to a const CPU identifier. */
2875typedef RTCPUID const RT_FAR *PCRTCPUID;
2876/** Nil CPU Id. */
2877#define NIL_RTCPUID ((RTCPUID)~0)
2878
2879/** The maximum number of CPUs a set can contain and IPRT is able
2880 * to reference. (Should be max of support arch/platforms.)
2881 * @remarks Must be a power of two and multiple of 64 (see RTCPUSET). */
2882#if defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)
2883# if defined(RT_OS_OS2)
2884# define RTCPUSET_MAX_CPUS 64
2885# elif defined(RT_OS_DARWIN) || defined(RT_ARCH_X86)
2886# define RTCPUSET_MAX_CPUS 256
2887# else
2888# define RTCPUSET_MAX_CPUS 1024
2889# endif
2890#elif defined(RT_ARCH_SPARC) || defined(RT_ARCH_SPARC64)
2891# define RTCPUSET_MAX_CPUS 1024
2892#else
2893# define RTCPUSET_MAX_CPUS 64
2894#endif
2895/** A CPU set.
2896 * @note Treat this as an opaque type and always use RTCpuSet* for
2897 * manipulating it. */
2898typedef struct RTCPUSET
2899{
2900 /** The bitmap. */
2901 uint64_t bmSet[RTCPUSET_MAX_CPUS / 64];
2902} RTCPUSET;
2903/** Pointer to a CPU set. */
2904typedef RTCPUSET RT_FAR *PRTCPUSET;
2905/** Pointer to a const CPU set. */
2906typedef RTCPUSET const RT_FAR *PCRTCPUSET;
2907
2908/** A handle table handle. */
2909typedef R3R0PTRTYPE(struct RTHANDLETABLEINT RT_FAR *) RTHANDLETABLE;
2910/** A pointer to a handle table handle. */
2911typedef RTHANDLETABLE RT_FAR *PRTHANDLETABLE;
2912/** @def NIL_RTHANDLETABLE
2913 * NIL handle table handle. */
2914#define NIL_RTHANDLETABLE ((RTHANDLETABLE)0)
2915
2916/** A handle to a low resolution timer. */
2917typedef R3R0PTRTYPE(struct RTTIMERLRINT RT_FAR *) RTTIMERLR;
2918/** A pointer to a low resolution timer handle. */
2919typedef RTTIMERLR RT_FAR *PRTTIMERLR;
2920/** @def NIL_RTTIMERLR
2921 * NIL low resolution timer handle value. */
2922#define NIL_RTTIMERLR ((RTTIMERLR)0)
2923
2924/** Handle to a random number generator. */
2925typedef R3R0PTRTYPE(struct RTRANDINT RT_FAR *) RTRAND;
2926/** Pointer to a random number generator handle. */
2927typedef RTRAND RT_FAR *PRTRAND;
2928/** NIL random number generator handle value. */
2929#define NIL_RTRAND ((RTRAND)0)
2930
2931/** Debug address space handle. */
2932typedef R3R0PTRTYPE(struct RTDBGASINT RT_FAR *) RTDBGAS;
2933/** Pointer to a debug address space handle. */
2934typedef RTDBGAS RT_FAR *PRTDBGAS;
2935/** NIL debug address space handle. */
2936#define NIL_RTDBGAS ((RTDBGAS)0)
2937
2938/** Debug module handle. */
2939typedef R3R0PTRTYPE(struct RTDBGMODINT RT_FAR *) RTDBGMOD;
2940/** Pointer to a debug module handle. */
2941typedef RTDBGMOD RT_FAR *PRTDBGMOD;
2942/** NIL debug module handle. */
2943#define NIL_RTDBGMOD ((RTDBGMOD)0)
2944
2945/** Pointer to an unwind machine state. */
2946typedef struct RTDBGUNWINDSTATE RT_FAR *PRTDBGUNWINDSTATE;
2947/** Pointer to a const unwind machine state. */
2948typedef struct RTDBGUNWINDSTATE const RT_FAR *PCRTDBGUNWINDSTATE;
2949
2950/** Manifest handle. */
2951typedef struct RTMANIFESTINT RT_FAR *RTMANIFEST;
2952/** Pointer to a manifest handle. */
2953typedef RTMANIFEST RT_FAR *PRTMANIFEST;
2954/** NIL manifest handle. */
2955#define NIL_RTMANIFEST ((RTMANIFEST)~(uintptr_t)0)
2956
2957/** Memory pool handle. */
2958typedef R3R0PTRTYPE(struct RTMEMPOOLINT RT_FAR *) RTMEMPOOL;
2959/** Pointer to a memory pool handle. */
2960typedef RTMEMPOOL RT_FAR *PRTMEMPOOL;
2961/** NIL memory pool handle. */
2962#define NIL_RTMEMPOOL ((RTMEMPOOL)0)
2963/** The default memory pool handle. */
2964#define RTMEMPOOL_DEFAULT ((RTMEMPOOL)-2)
2965
2966/** String cache handle. */
2967typedef R3R0PTRTYPE(struct RTSTRCACHEINT RT_FAR *) RTSTRCACHE;
2968/** Pointer to a string cache handle. */
2969typedef RTSTRCACHE RT_FAR *PRTSTRCACHE;
2970/** NIL string cache handle. */
2971#define NIL_RTSTRCACHE ((RTSTRCACHE)0)
2972/** The default string cache handle. */
2973#define RTSTRCACHE_DEFAULT ((RTSTRCACHE)-2)
2974
2975
2976/** Virtual Filesystem handle. */
2977typedef struct RTVFSINTERNAL RT_FAR *RTVFS;
2978/** Pointer to a VFS handle. */
2979typedef RTVFS RT_FAR *PRTVFS;
2980/** A NIL VFS handle. */
2981#define NIL_RTVFS ((RTVFS)~(uintptr_t)0)
2982
2983/** Virtual Filesystem base object handle. */
2984typedef struct RTVFSOBJINTERNAL RT_FAR *RTVFSOBJ;
2985/** Pointer to a VFS base object handle. */
2986typedef RTVFSOBJ RT_FAR *PRTVFSOBJ;
2987/** A NIL VFS base object handle. */
2988#define NIL_RTVFSOBJ ((RTVFSOBJ)~(uintptr_t)0)
2989
2990/** Virtual Filesystem directory handle. */
2991typedef struct RTVFSDIRINTERNAL RT_FAR *RTVFSDIR;
2992/** Pointer to a VFS directory handle. */
2993typedef RTVFSDIR RT_FAR *PRTVFSDIR;
2994/** A NIL VFS directory handle. */
2995#define NIL_RTVFSDIR ((RTVFSDIR)~(uintptr_t)0)
2996
2997/** Virtual Filesystem filesystem stream handle. */
2998typedef struct RTVFSFSSTREAMINTERNAL RT_FAR *RTVFSFSSTREAM;
2999/** Pointer to a VFS filesystem stream handle. */
3000typedef RTVFSFSSTREAM RT_FAR *PRTVFSFSSTREAM;
3001/** A NIL VFS filesystem stream handle. */
3002#define NIL_RTVFSFSSTREAM ((RTVFSFSSTREAM)~(uintptr_t)0)
3003
3004/** Virtual Filesystem I/O stream handle. */
3005typedef struct RTVFSIOSTREAMINTERNAL RT_FAR *RTVFSIOSTREAM;
3006/** Pointer to a VFS I/O stream handle. */
3007typedef RTVFSIOSTREAM RT_FAR *PRTVFSIOSTREAM;
3008/** A NIL VFS I/O stream handle. */
3009#define NIL_RTVFSIOSTREAM ((RTVFSIOSTREAM)~(uintptr_t)0)
3010
3011/** Virtual Filesystem file handle. */
3012typedef struct RTVFSFILEINTERNAL RT_FAR *RTVFSFILE;
3013/** Pointer to a VFS file handle. */
3014typedef RTVFSFILE RT_FAR *PRTVFSFILE;
3015/** A NIL VFS file handle. */
3016#define NIL_RTVFSFILE ((RTVFSFILE)~(uintptr_t)0)
3017
3018/** Virtual Filesystem symbolic link handle. */
3019typedef struct RTVFSSYMLINKINTERNAL RT_FAR *RTVFSSYMLINK;
3020/** Pointer to a VFS symbolic link handle. */
3021typedef RTVFSSYMLINK RT_FAR *PRTVFSSYMLINK;
3022/** A NIL VFS symbolic link handle. */
3023#define NIL_RTVFSSYMLINK ((RTVFSSYMLINK)~(uintptr_t)0)
3024
3025/** Async I/O manager handle. */
3026typedef struct RTAIOMGRINT RT_FAR *RTAIOMGR;
3027/** Pointer to a async I/O manager handle. */
3028typedef RTAIOMGR RT_FAR *PRTAIOMGR;
3029/** A NIL async I/O manager handle. */
3030#define NIL_RTAIOMGR ((RTAIOMGR)~(uintptr_t)0)
3031
3032/** Async I/O manager file handle. */
3033typedef struct RTAIOMGRFILEINT RT_FAR *RTAIOMGRFILE;
3034/** Pointer to a async I/O manager file handle. */
3035typedef RTAIOMGRFILE RT_FAR *PRTAIOMGRFILE;
3036/** A NIL async I/O manager file handle. */
3037#define NIL_RTAIOMGRFILE ((RTAIOMGRFILE)~(uintptr_t)0)
3038
3039/** Kernel module information record handle. */
3040typedef struct RTKRNLMODINFOINT RT_FAR *RTKRNLMODINFO;
3041/** Pointer to a kernel information record handle. */
3042typedef RTKRNLMODINFO RT_FAR *PRTKRNLMODINFO;
3043/** A NIL kernel module information record handle. */
3044#define NIL_RTKRNLMODINFO ((RTKRNLMODINFO)~(uintptr_t)0);
3045
3046/** Shared memory object handle. */
3047typedef struct RTSHMEMINT RT_FAR *RTSHMEM;
3048/** Pointer to a shared memory object handle. */
3049typedef RTSHMEM RT_FAR *PRTSHMEM;
3050/** A NIL shared memory object handle. */
3051#define NIL_RTSHMEM ((RTSHMEM)~(uintptr_t)0)
3052
3053/** EFI signature database handle. */
3054typedef struct RTEFISIGDBINT RT_FAR *RTEFISIGDB;
3055/** Pointer to a EFI signature database handle. */
3056typedef RTEFISIGDB RT_FAR *PRTEFISIGDB;
3057/** A NIL EFI signature database handle. */
3058#define NIL_RTEFISIGDB ((RTEFISIGDB)~(uintptr_t)0)
3059
3060
3061/**
3062 * Handle type.
3063 *
3064 * This is usually used together with RTHANDLEUNION.
3065 */
3066typedef enum RTHANDLETYPE
3067{
3068 /** The invalid zero value. */
3069 RTHANDLETYPE_INVALID = 0,
3070 /** File handle. */
3071 RTHANDLETYPE_FILE,
3072 /** Pipe handle */
3073 RTHANDLETYPE_PIPE,
3074 /** Socket handle. */
3075 RTHANDLETYPE_SOCKET,
3076 /** Thread handle. */
3077 RTHANDLETYPE_THREAD,
3078 /** The end of the valid values. */
3079 RTHANDLETYPE_END,
3080 /** The 32-bit type blow up. */
3081 RTHANDLETYPE_32BIT_HACK = 0x7fffffff
3082} RTHANDLETYPE;
3083/** Pointer to a handle type. */
3084typedef RTHANDLETYPE RT_FAR *PRTHANDLETYPE;
3085
3086/**
3087 * Handle union.
3088 *
3089 * This is usually used together with RTHANDLETYPE or as RTHANDLE.
3090 */
3091typedef union RTHANDLEUNION
3092{
3093 RTFILE hFile; /**< File handle. */
3094 RTPIPE hPipe; /**< Pipe handle. */
3095 RTSOCKET hSocket; /**< Socket handle. */
3096 RTTHREAD hThread; /**< Thread handle. */
3097 /** Generic integer handle value.
3098 * Note that RTFILE is not yet pointer sized, so accessing it via this member
3099 * isn't necessarily safe or fully portable. */
3100 RTHCUINTPTR uInt;
3101} RTHANDLEUNION;
3102/** Pointer to a handle union. */
3103typedef RTHANDLEUNION RT_FAR *PRTHANDLEUNION;
3104/** Pointer to a const handle union. */
3105typedef RTHANDLEUNION const RT_FAR *PCRTHANDLEUNION;
3106
3107/**
3108 * Generic handle.
3109 */
3110typedef struct RTHANDLE
3111{
3112 /** The handle type. */
3113 RTHANDLETYPE enmType;
3114 /** The handle value. */
3115 RTHANDLEUNION u;
3116} RTHANDLE;
3117/** Pointer to a generic handle. */
3118typedef RTHANDLE RT_FAR *PRTHANDLE;
3119/** Pointer to a const generic handle. */
3120typedef RTHANDLE const RT_FAR *PCRTHANDLE;
3121
3122
3123/**
3124 * Standard handles.
3125 *
3126 * @remarks These have the correct file descriptor values for unixy systems and
3127 * can be used directly in code specific to those platforms.
3128 */
3129typedef enum RTHANDLESTD
3130{
3131 /** Invalid standard handle. */
3132 RTHANDLESTD_INVALID = -1,
3133 /** The standard input handle. */
3134 RTHANDLESTD_INPUT = 0,
3135 /** The standard output handle. */
3136 RTHANDLESTD_OUTPUT,
3137 /** The standard error handle. */
3138 RTHANDLESTD_ERROR,
3139 /** The typical 32-bit type hack. */
3140 RTHANDLESTD_32BIT_HACK = 0x7fffffff
3141} RTHANDLESTD;
3142
3143
3144/**
3145 * Error info.
3146 *
3147 * See RTErrInfo*.
3148 */
3149typedef struct RTERRINFO
3150{
3151 /** Flags, see RTERRINFO_FLAGS_XXX. */
3152 uint32_t fFlags;
3153 /** The status code. */
3154 int32_t rc;
3155 /** The size of the message */
3156 size_t cbMsg;
3157 /** The error buffer. */
3158 char *pszMsg;
3159 /** Reserved for future use. */
3160 void *apvReserved[2];
3161} RTERRINFO;
3162/** Pointer to an error info structure. */
3163typedef RTERRINFO RT_FAR *PRTERRINFO;
3164/** Pointer to a const error info structure. */
3165typedef RTERRINFO const RT_FAR *PCRTERRINFO;
3166
3167/**
3168 * Static error info structure, see RTErrInfoInitStatic.
3169 */
3170typedef struct RTERRINFOSTATIC
3171{
3172 /** The core error info. */
3173 RTERRINFO Core;
3174 /** The static message buffer. */
3175 char szMsg[3072];
3176} RTERRINFOSTATIC;
3177/** Pointer to a error info buffer. */
3178typedef RTERRINFOSTATIC RT_FAR *PRTERRINFOSTATIC;
3179/** Pointer to a const static error info buffer. */
3180typedef RTERRINFOSTATIC const RT_FAR *PCRTERRINFOSTATIC;
3181
3182
3183/**
3184 * UUID data type.
3185 *
3186 * See RTUuid*.
3187 *
3188 * @remarks IPRT defines that the first three integers in the @c Gen struct
3189 * interpretation are in little endian representation. This is
3190 * different to many other UUID implementation, and requires
3191 * conversion if you need to achieve consistent results.
3192 */
3193typedef union RTUUID
3194{
3195 /** 8-bit view. */
3196 uint8_t au8[16];
3197 /** 16-bit view. */
3198 uint16_t au16[8];
3199 /** 32-bit view. */
3200 uint32_t au32[4];
3201 /** 64-bit view. */
3202 uint64_t au64[2];
3203 /** The way the UUID is declared by the DCE specification. */
3204 struct
3205 {
3206 uint32_t u32TimeLow;
3207 uint16_t u16TimeMid;
3208 uint16_t u16TimeHiAndVersion;
3209 uint8_t u8ClockSeqHiAndReserved;
3210 uint8_t u8ClockSeqLow;
3211 uint8_t au8Node[6];
3212 } Gen;
3213} RTUUID;
3214/** Pointer to UUID data. */
3215typedef RTUUID RT_FAR *PRTUUID;
3216/** Pointer to readonly UUID data. */
3217typedef const RTUUID RT_FAR *PCRTUUID;
3218
3219/** Initializes a RTUUID structure with all zeros (RTUuidIsNull() true). */
3220#define RTUUID_INITIALIZE_NULL { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
3221
3222/** UUID string maximum length. */
3223#define RTUUID_STR_LENGTH 37
3224
3225
3226/** Compression handle. */
3227typedef struct RTZIPCOMP RT_FAR *PRTZIPCOMP;
3228/** Decompressor handle. */
3229typedef struct RTZIPDECOMP RT_FAR *PRTZIPDECOMP;
3230
3231
3232/**
3233 * Unicode Code Point.
3234 */
3235typedef uint32_t RTUNICP;
3236/** Pointer to an Unicode Code Point. */
3237typedef RTUNICP RT_FAR *PRTUNICP;
3238/** Pointer to an Unicode Code Point. */
3239typedef const RTUNICP RT_FAR *PCRTUNICP;
3240/** Max value a RTUNICP type can hold. */
3241#define RTUNICP_MAX ( ~(RTUNICP)0 )
3242/** Invalid code point.
3243 * This is returned when encountered invalid encodings or invalid
3244 * unicode code points. */
3245#define RTUNICP_INVALID ( UINT32_C(0xfffffffe) )
3246
3247
3248/**
3249 * UTF-16 character.
3250 * @remark wchar_t is not usable since it's compiler defined.
3251 * @remark When we use the term character we're not talking about unicode code point, but
3252 * the basic unit of the string encoding. Thus cwc - count of wide chars - means
3253 * count of RTUTF16; cuc - count of unicode chars - means count of RTUNICP;
3254 * and cch means count of the typedef 'char', which is assumed to be an octet.
3255 */
3256typedef uint16_t RTUTF16;
3257/** Pointer to a UTF-16 character. */
3258typedef RTUTF16 RT_FAR *PRTUTF16;
3259/** Pointer to a const UTF-16 character. */
3260typedef const RTUTF16 RT_FAR *PCRTUTF16;
3261
3262
3263/**
3264 * String tuple to go with the RT_STR_TUPLE macro.
3265 */
3266typedef struct RTSTRTUPLE
3267{
3268 /** The string. */
3269 const char *psz;
3270 /** The string length. */
3271 size_t cch;
3272} RTSTRTUPLE;
3273/** Pointer to a string tuple. */
3274typedef RTSTRTUPLE RT_FAR *PRTSTRTUPLE;
3275/** Pointer to a const string tuple. */
3276typedef RTSTRTUPLE const RT_FAR *PCRTSTRTUPLE;
3277
3278/**
3279 * Wait for ever if we have to.
3280 */
3281#define RT_INDEFINITE_WAIT (~0U)
3282
3283
3284/**
3285 * Generic process callback.
3286 *
3287 * @returns VBox status code. Failure will cancel the operation.
3288 * @param uPercentage The percentage of the operation which has been completed.
3289 * @param pvUser The user specified argument.
3290 */
3291typedef DECLCALLBACKTYPE(int, FNRTPROGRESS,(unsigned uPercentage, void *pvUser));
3292/** Pointer to a generic progress callback function, FNRTPROCESS(). */
3293typedef FNRTPROGRESS *PFNRTPROGRESS;
3294
3295/**
3296 * Generic vprintf-like callback function for dumpers.
3297 *
3298 * @param pvUser User argument.
3299 * @param pszFormat The format string.
3300 * @param va Arguments for the format string.
3301 */
3302typedef DECLCALLBACKTYPE(void, FNRTDUMPPRINTFV,(void *pvUser, const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(2, 0));
3303/** Pointer to a generic printf-like function for dumping. */
3304typedef FNRTDUMPPRINTFV *PFNRTDUMPPRINTFV;
3305
3306
3307/**
3308 * A point in a two dimentional coordinate system.
3309 */
3310typedef struct RTPOINT
3311{
3312 /** X coordinate. */
3313 int32_t x;
3314 /** Y coordinate. */
3315 int32_t y;
3316} RTPOINT;
3317/** Pointer to a point. */
3318typedef RTPOINT RT_FAR *PRTPOINT;
3319/** Pointer to a const point. */
3320typedef const RTPOINT RT_FAR *PCRTPOINT;
3321
3322
3323/**
3324 * Rectangle data type, double point.
3325 */
3326typedef struct RTRECT
3327{
3328 /** left X coordinate. */
3329 int32_t xLeft;
3330 /** top Y coordinate. */
3331 int32_t yTop;
3332 /** right X coordinate. (exclusive) */
3333 int32_t xRight;
3334 /** bottom Y coordinate. (exclusive) */
3335 int32_t yBottom;
3336} RTRECT;
3337/** Pointer to a double point rectangle. */
3338typedef RTRECT RT_FAR *PRTRECT;
3339/** Pointer to a const double point rectangle. */
3340typedef const RTRECT RT_FAR *PCRTRECT;
3341
3342
3343/**
3344 * Rectangle data type, point + size.
3345 */
3346typedef struct RTRECT2
3347{
3348 /** X coordinate.
3349 * Unless stated otherwise, this is the top left corner. */
3350 int32_t x;
3351 /** Y coordinate.
3352 * Unless stated otherwise, this is the top left corner. */
3353 int32_t y;
3354 /** The width.
3355 * Unless stated otherwise, this is to the right of (x,y) and will not
3356 * be a negative number. */
3357 int32_t cx;
3358 /** The height.
3359 * Unless stated otherwise, this is down from (x,y) and will not be a
3360 * negative number. */
3361 int32_t cy;
3362} RTRECT2;
3363/** Pointer to a point + size rectangle. */
3364typedef RTRECT2 RT_FAR *PRTRECT2;
3365/** Pointer to a const point + size rectangle. */
3366typedef const RTRECT2 RT_FAR *PCRTRECT2;
3367
3368
3369/**
3370 * The size of a rectangle.
3371 */
3372typedef struct RTRECTSIZE
3373{
3374 /** The width (along the x-axis). */
3375 uint32_t cx;
3376 /** The height (along the y-axis). */
3377 uint32_t cy;
3378} RTRECTSIZE;
3379/** Pointer to a rectangle size. */
3380typedef RTRECTSIZE RT_FAR *PRTRECTSIZE;
3381/** Pointer to a const rectangle size. */
3382typedef const RTRECTSIZE RT_FAR *PCRTRECTSIZE;
3383
3384
3385/**
3386 * Ethernet MAC address.
3387 *
3388 * The first 24 bits make up the Organisationally Unique Identifier (OUI),
3389 * where the first bit (little endian) indicates multicast (set) / unicast,
3390 * and the second bit indicates locally (set) / global administered. If all
3391 * bits are set, it's a broadcast.
3392 */
3393typedef union RTMAC
3394{
3395 /** @todo add a bitfield view of this stuff. */
3396 /** 8-bit view. */
3397 uint8_t au8[6];
3398 /** 16-bit view. */
3399 uint16_t au16[3];
3400} RTMAC;
3401/** Pointer to a MAC address. */
3402typedef RTMAC RT_FAR *PRTMAC;
3403/** Pointer to a readonly MAC address. */
3404typedef const RTMAC RT_FAR *PCRTMAC;
3405
3406
3407/** Pointer to a lock validator record.
3408 * The structure definition is found in iprt/lockvalidator.h. */
3409typedef struct RTLOCKVALRECEXCL RT_FAR *PRTLOCKVALRECEXCL;
3410/** Pointer to a record of one ownership share.
3411 * The structure definition is found in iprt/lockvalidator.h. */
3412typedef struct RTLOCKVALRECSHRD RT_FAR *PRTLOCKVALRECSHRD;
3413/** Pointer to a lock validator source position.
3414 * The structure definition is found in iprt/lockvalidator.h. */
3415typedef struct RTLOCKVALSRCPOS RT_FAR *PRTLOCKVALSRCPOS;
3416/** Pointer to a const lock validator source position.
3417 * The structure definition is found in iprt/lockvalidator.h. */
3418typedef struct RTLOCKVALSRCPOS const RT_FAR *PCRTLOCKVALSRCPOS;
3419
3420/** @name Special sub-class values.
3421 * The range 16..UINT32_MAX is available to the user, the range 0..15 is
3422 * reserved for the lock validator. In the user range the locks can only be
3423 * taking in ascending order.
3424 * @{ */
3425/** Invalid value. */
3426#define RTLOCKVAL_SUB_CLASS_INVALID UINT32_C(0)
3427/** Not allowed to be taken with any other locks in the same class.
3428 * This is the recommended value. */
3429#define RTLOCKVAL_SUB_CLASS_NONE UINT32_C(1)
3430/** Any order is allowed within the class. */
3431#define RTLOCKVAL_SUB_CLASS_ANY UINT32_C(2)
3432/** The first user value. */
3433#define RTLOCKVAL_SUB_CLASS_USER UINT32_C(16)
3434/** @} */
3435
3436
3437/**
3438 * Digest types.
3439 */
3440typedef enum RTDIGESTTYPE
3441{
3442 /** Invalid digest value. */
3443 RTDIGESTTYPE_INVALID = 0,
3444 /** Unknown digest type. */
3445 RTDIGESTTYPE_UNKNOWN,
3446 /** CRC32 checksum. */
3447 RTDIGESTTYPE_CRC32,
3448 /** CRC64 checksum. */
3449 RTDIGESTTYPE_CRC64,
3450 /** MD2 checksum (unsafe!). */
3451 RTDIGESTTYPE_MD2,
3452 /** MD4 checksum (unsafe!!). */
3453 RTDIGESTTYPE_MD4,
3454 /** MD5 checksum (unsafe!). */
3455 RTDIGESTTYPE_MD5,
3456 /** SHA-1 checksum (unsafe!). */
3457 RTDIGESTTYPE_SHA1,
3458 /** SHA-224 checksum. */
3459 RTDIGESTTYPE_SHA224,
3460 /** SHA-256 checksum. */
3461 RTDIGESTTYPE_SHA256,
3462 /** SHA-384 checksum. */
3463 RTDIGESTTYPE_SHA384,
3464 /** SHA-512 checksum. */
3465 RTDIGESTTYPE_SHA512,
3466 /** SHA-512/224 checksum. */
3467 RTDIGESTTYPE_SHA512T224,
3468 /** SHA-512/256 checksum. */
3469 RTDIGESTTYPE_SHA512T256,
3470 /** SHA3-224 checksum. */
3471 RTDIGESTTYPE_SHA3_224,
3472 /** SHA3-256 checksum. */
3473 RTDIGESTTYPE_SHA3_256,
3474 /** SHA3-384 checksum. */
3475 RTDIGESTTYPE_SHA3_384,
3476 /** SHA3-512 checksum. */
3477 RTDIGESTTYPE_SHA3_512,
3478#if 0
3479 /** SHAKE128 checksum. */
3480 RTDIGESTTYPE_SHAKE128,
3481 /** SHAKE256 checksum. */
3482 RTDIGESTTYPE_SHAKE256,
3483#endif
3484 /** End of valid types. */
3485 RTDIGESTTYPE_END,
3486 /** Usual 32-bit type blowup. */
3487 RTDIGESTTYPE_32BIT_HACK = 0x7fffffff
3488} RTDIGESTTYPE;
3489
3490/**
3491 * Process exit codes.
3492 */
3493typedef enum RTEXITCODE
3494{
3495 /** Success. */
3496 RTEXITCODE_SUCCESS = 0,
3497 /** General failure. */
3498 RTEXITCODE_FAILURE = 1,
3499 /** Invalid arguments. */
3500 RTEXITCODE_SYNTAX = 2,
3501 /** Initialization failure (usually IPRT, but could be used for other
3502 * components as well). */
3503 RTEXITCODE_INIT = 3,
3504 /** Test skipped. */
3505 RTEXITCODE_SKIPPED = 4,
3506 /** The end of valid exit codes. */
3507 RTEXITCODE_END,
3508 /** The usual 32-bit type hack. */
3509 RTEXITCODE_32BIT_HACK = 0x7fffffff
3510} RTEXITCODE;
3511
3512/**
3513 * Range descriptor.
3514 */
3515typedef struct RTRANGE
3516{
3517 /** Start offset. */
3518 uint64_t offStart;
3519 /** Range size. */
3520 size_t cbRange;
3521} RTRANGE;
3522/** Pointer to a range descriptor. */
3523typedef RTRANGE RT_FAR *PRTRANGE;
3524/** Pointer to a readonly range descriptor. */
3525typedef const RTRANGE RT_FAR *PCRTRANGE;
3526
3527
3528/**
3529 * Generic pointer union.
3530 */
3531typedef union RTPTRUNION
3532{
3533 /** Pointer into the void. */
3534 void RT_FAR *pv;
3535 /** As a signed integer. */
3536 intptr_t i;
3537 /** As an unsigned integer. */
3538 uintptr_t u;
3539 /** Pointer to char value. */
3540 char RT_FAR *pch;
3541 /** Pointer to char value. */
3542 unsigned char RT_FAR *puch;
3543 /** Pointer to a int value. */
3544 int RT_FAR *pi;
3545 /** Pointer to a unsigned int value. */
3546 unsigned int RT_FAR *pu;
3547 /** Pointer to a long value. */
3548 long RT_FAR *pl;
3549 /** Pointer to a long value. */
3550 unsigned long RT_FAR *pul;
3551 /** Pointer to a 8-bit unsigned value. */
3552 uint8_t RT_FAR *pu8;
3553 /** Pointer to a 16-bit unsigned value. */
3554 uint16_t RT_FAR *pu16;
3555 /** Pointer to a 32-bit unsigned value. */
3556 uint32_t RT_FAR *pu32;
3557 /** Pointer to a 64-bit unsigned value. */
3558 uint64_t RT_FAR *pu64;
3559 /** Pointer to a 8-bit signed value. */
3560 int8_t RT_FAR *pi8;
3561 /** Pointer to a 16-bit signed value. */
3562 int16_t RT_FAR *pi16;
3563 /** Pointer to a 32-bit signed value. */
3564 int32_t RT_FAR *pi32;
3565 /** Pointer to a 64-bit signed value. */
3566 int64_t RT_FAR *pi64;
3567 /** Pointer to a UTF-16 character. */
3568 PRTUTF16 pwc;
3569 /** Pointer to a UUID character. */
3570 PRTUUID pUuid;
3571} RTPTRUNION;
3572/** Pointer to a pointer union. */
3573typedef RTPTRUNION RT_FAR *PRTPTRUNION;
3574
3575/**
3576 * Generic const pointer union.
3577 */
3578typedef union RTCPTRUNION
3579{
3580 /** Pointer into the void. */
3581 void const RT_FAR *pv;
3582 /** As a signed integer. */
3583 intptr_t i;
3584 /** As an unsigned integer. */
3585 uintptr_t u;
3586 /** Pointer to char value. */
3587 char const RT_FAR *pch;
3588 /** Pointer to char value. */
3589 unsigned char const RT_FAR *puch;
3590 /** Pointer to a int value. */
3591 int const RT_FAR *pi;
3592 /** Pointer to a unsigned int value. */
3593 unsigned int const RT_FAR *pu;
3594 /** Pointer to a long value. */
3595 long const RT_FAR *pl;
3596 /** Pointer to a long value. */
3597 unsigned long const RT_FAR *pul;
3598 /** Pointer to a 8-bit unsigned value. */
3599 uint8_t const RT_FAR *pu8;
3600 /** Pointer to a 16-bit unsigned value. */
3601 uint16_t const RT_FAR *pu16;
3602 /** Pointer to a 32-bit unsigned value. */
3603 uint32_t const RT_FAR *pu32;
3604 /** Pointer to a 64-bit unsigned value. */
3605 uint64_t const RT_FAR *pu64;
3606 /** Pointer to a 8-bit signed value. */
3607 int8_t const RT_FAR *pi8;
3608 /** Pointer to a 16-bit signed value. */
3609 int16_t const RT_FAR *pi16;
3610 /** Pointer to a 32-bit signed value. */
3611 int32_t const RT_FAR *pi32;
3612 /** Pointer to a 64-bit signed value. */
3613 int64_t const RT_FAR *pi64;
3614 /** Pointer to a UTF-16 character. */
3615 PCRTUTF16 pwc;
3616 /** Pointer to a UUID character. */
3617 PCRTUUID pUuid;
3618} RTCPTRUNION;
3619/** Pointer to a const pointer union. */
3620typedef RTCPTRUNION RT_FAR *PRTCPTRUNION;
3621
3622/**
3623 * Generic volatile pointer union.
3624 */
3625typedef union RTVPTRUNION
3626{
3627 /** Pointer into the void. */
3628 void volatile RT_FAR *pv;
3629 /** As a signed integer. */
3630 intptr_t i;
3631 /** As an unsigned integer. */
3632 uintptr_t u;
3633 /** Pointer to char value. */
3634 char volatile RT_FAR *pch;
3635 /** Pointer to char value. */
3636 unsigned char volatile RT_FAR *puch;
3637 /** Pointer to a int value. */
3638 int volatile RT_FAR *pi;
3639 /** Pointer to a unsigned int value. */
3640 unsigned int volatile RT_FAR *pu;
3641 /** Pointer to a long value. */
3642 long volatile RT_FAR *pl;
3643 /** Pointer to a long value. */
3644 unsigned long volatile RT_FAR *pul;
3645 /** Pointer to a 8-bit unsigned value. */
3646 uint8_t volatile RT_FAR *pu8;
3647 /** Pointer to a 16-bit unsigned value. */
3648 uint16_t volatile RT_FAR *pu16;
3649 /** Pointer to a 32-bit unsigned value. */
3650 uint32_t volatile RT_FAR *pu32;
3651 /** Pointer to a 64-bit unsigned value. */
3652 uint64_t volatile RT_FAR *pu64;
3653 /** Pointer to a 8-bit signed value. */
3654 int8_t volatile RT_FAR *pi8;
3655 /** Pointer to a 16-bit signed value. */
3656 int16_t volatile RT_FAR *pi16;
3657 /** Pointer to a 32-bit signed value. */
3658 int32_t volatile RT_FAR *pi32;
3659 /** Pointer to a 64-bit signed value. */
3660 int64_t volatile RT_FAR *pi64;
3661 /** Pointer to a UTF-16 character. */
3662 RTUTF16 volatile RT_FAR *pwc;
3663 /** Pointer to a UUID character. */
3664 RTUUID volatile RT_FAR *pUuid;
3665} RTVPTRUNION;
3666/** Pointer to a const pointer union. */
3667typedef RTVPTRUNION RT_FAR *PRTVPTRUNION;
3668
3669/**
3670 * Generic const volatile pointer union.
3671 */
3672typedef union RTCVPTRUNION
3673{
3674 /** Pointer into the void. */
3675 void const volatile RT_FAR *pv;
3676 /** As a signed integer. */
3677 intptr_t i;
3678 /** As an unsigned integer. */
3679 uintptr_t u;
3680 /** Pointer to char value. */
3681 char const volatile RT_FAR *pch;
3682 /** Pointer to char value. */
3683 unsigned char const volatile RT_FAR *puch;
3684 /** Pointer to a int value. */
3685 int const volatile RT_FAR *pi;
3686 /** Pointer to a unsigned int value. */
3687 unsigned int const volatile RT_FAR *pu;
3688 /** Pointer to a long value. */
3689 long const volatile RT_FAR *pl;
3690 /** Pointer to a long value. */
3691 unsigned long const volatile RT_FAR *pul;
3692 /** Pointer to a 8-bit unsigned value. */
3693 uint8_t const volatile RT_FAR *pu8;
3694 /** Pointer to a 16-bit unsigned value. */
3695 uint16_t const volatile RT_FAR *pu16;
3696 /** Pointer to a 32-bit unsigned value. */
3697 uint32_t const volatile RT_FAR *pu32;
3698 /** Pointer to a 64-bit unsigned value. */
3699 uint64_t const volatile RT_FAR *pu64;
3700 /** Pointer to a 8-bit signed value. */
3701 int8_t const volatile RT_FAR *pi8;
3702 /** Pointer to a 16-bit signed value. */
3703 int16_t const volatile RT_FAR *pi16;
3704 /** Pointer to a 32-bit signed value. */
3705 int32_t const volatile RT_FAR *pi32;
3706 /** Pointer to a 64-bit signed value. */
3707 int64_t const volatile RT_FAR *pi64;
3708 /** Pointer to a UTF-16 character. */
3709 RTUTF16 const volatile RT_FAR *pwc;
3710 /** Pointer to a UUID character. */
3711 RTUUID const volatile RT_FAR *pUuid;
3712} RTCVPTRUNION;
3713/** Pointer to a const pointer union. */
3714typedef RTCVPTRUNION RT_FAR *PRTCVPTRUNION;
3715
3716
3717
3718#ifdef __cplusplus
3719/**
3720 * Strict type validation helper class.
3721 *
3722 * See RTErrStrictType and RT_SUCCESS_NP.
3723 */
3724class RTErrStrictType2
3725{
3726protected:
3727 /** The status code. */
3728 int32_t m_rc;
3729
3730public:
3731 /**
3732 * Constructor.
3733 * @param rc IPRT style status code.
3734 */
3735 RTErrStrictType2(int32_t rc) : m_rc(rc)
3736 {
3737 }
3738
3739 /**
3740 * Get the status code.
3741 * @returns IPRT style status code.
3742 */
3743 int32_t getValue() const
3744 {
3745 return m_rc;
3746 }
3747};
3748#endif /* __cplusplus */
3749/** @} */
3750
3751#endif /* !IPRT_INCLUDED_types_h */
3752
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette