VirtualBox

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

Last change on this file was 104795, checked in by vboxsync, 4 months ago

iprt/asm.h: Added ASMAtomic[Uo]WriteU128[U|v2] and ASMAtomic[Uo]ReadU128[U]. bugref:10687

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

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