VirtualBox

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

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

iprt/types.h: Some RTFLOAT* additions for simplifying writing RTStrToLongDoubleEx and friends. bugref:10261

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

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