VirtualBox

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

Last change on this file since 107807 was 107244, checked in by vboxsync, 2 months ago

iprt/types.h: solaris/pairfait workaround attempt.

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

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