VirtualBox

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

Last change on this file was 106338, checked in by vboxsync, 6 weeks ago

Runtime: Add ACPI table builder API to dynamically generate a DSDT/SSDT, bugref:10733 [missing file]

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 134.5 KB
Line 
1/** @file
2 * IPRT - Types.
3 */
4
5/*
6 * Copyright (C) 2006-2024 Oracle and/or its affiliates.
7 *
8 * This file is part of VirtualBox base platform packages, as
9 * available from https://www.virtualbox.org.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation, in version 3 of the
14 * License.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see <https://www.gnu.org/licenses>.
23 *
24 * The contents of this file may alternatively be used under the terms
25 * of the Common Development and Distribution License Version 1.0
26 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
27 * in the VirtualBox distribution, in which case the provisions of the
28 * CDDL are applicable instead of those of the GPL.
29 *
30 * You may elect to license modified versions of this file under the
31 * terms and conditions of either the GPL or the CDDL or both.
32 *
33 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
34 */
35
36#ifndef IPRT_INCLUDED_types_h
37#define IPRT_INCLUDED_types_h
38#ifndef RT_WITHOUT_PRAGMA_ONCE
39# pragma once
40#endif
41
42#include <iprt/cdefs.h>
43#include <iprt/stdint.h>
44#include <iprt/stdarg.h>
45
46/*
47 * Include standard C types.
48 */
49#if !defined(IPRT_NO_CRT) && !defined(DOXYGEN_RUNNING)
50
51# if defined(IN_XF86_MODULE) && !defined(NO_ANSIC)
52 /*
53 * Kludge for xfree86 modules: size_t and other types are redefined.
54 */
55RT_C_DECLS_BEGIN
56# include "xf86_ansic.h"
57# undef NULL
58RT_C_DECLS_END
59
60# elif defined(RT_OS_DARWIN) && defined(KERNEL)
61 /*
62 * Kludge for the darwin kernel:
63 * stddef.h is missing IIRC.
64 */
65# ifndef _PTRDIFF_T
66# define _PTRDIFF_T
67 typedef __darwin_ptrdiff_t ptrdiff_t;
68# endif
69# include <sys/types.h>
70
71# elif defined(RT_OS_FREEBSD) && defined(_KERNEL)
72# include <sys/param.h>
73# undef PVM
74# if __FreeBSD_version < 1200000
75 /*
76 * Kludge for the FreeBSD kernel:
77 * stddef.h and sys/types.h have slightly different offsetof definitions
78 * when compiling in kernel mode. This is just to make GCC shut up.
79 */
80# ifndef _STDDEF_H_
81# undef offsetof
82# endif
83# include <sys/stddef.h>
84# ifndef _SYS_TYPES_H_
85# undef offsetof
86# endif
87# include <sys/types.h>
88# ifndef offsetof
89# error "offsetof is not defined!"
90# endif
91# else
92# include <sys/stddef.h>
93# include <sys/types.h>
94# endif
95
96# elif defined(RT_OS_FREEBSD) && HC_ARCH_BITS == 64 && defined(RT_ARCH_X86)
97 /*
98 * Kludge for compiling 32-bit code on a 64-bit FreeBSD:
99 * FreeBSD declares uint64_t and int64_t wrong (long unsigned and long int
100 * though they need to be long long unsigned and long long int). These
101 * defines conflict with our declaration in stdint.h. Adding the defines
102 * below omits the definitions in the system header.
103 */
104# include <stddef.h>
105# define _UINT64_T_DECLARED
106# define _INT64_T_DECLARED
107# define _UINTPTR_T_DECLARED
108# define _INTPTR_T_DECLARED
109# include <sys/types.h>
110
111# elif defined(RT_OS_NETBSD) && defined(_KERNEL)
112
113# include <sys/types.h>
114
115 /*
116 * Kludge for NetBSD-6.x where the definition of bool in
117 * <sys/types.h> does not check for C++.
118 */
119# if defined(__cplusplus) && defined(bool)
120# undef bool
121# undef true
122# undef false
123# endif
124
125 /*
126 * Kludge for NetBSD-6.x where <sys/types.h> does not define
127 * ptrdiff_t for the kernel code. Note that we don't worry about
128 * redefinition in <stddef.h> since that header doesn't exist for
129 * _KERNEL code.
130 */
131# ifdef _BSD_PTRDIFF_T_
132 typedef _BSD_PTRDIFF_T_ ptrdiff_t;
133# endif
134
135# elif defined(RT_OS_LINUX) && defined(__KERNEL__)
136 /*
137 * Kludge for the linux kernel:
138 * 1. sys/types.h doesn't mix with the kernel.
139 * 2. Starting with 2.6.19, linux/types.h typedefs bool and linux/stddef.h
140 * declares false and true as enum values.
141 * 3. Starting with 2.6.24, linux/types.h typedefs uintptr_t.
142 * We work around these issues here and nowhere else.
143 */
144# if defined(__cplusplus)
145 typedef bool _Bool;
146# endif
147# define bool linux_bool
148# define true linux_true
149# define false linux_false
150# define uintptr_t linux_uintptr_t
151# include <linux/version.h>
152# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
153# include <generated/autoconf.h>
154# else
155# ifndef AUTOCONF_INCLUDED
156# include <linux/autoconf.h>
157# endif
158# endif
159# include <linux/compiler.h>
160# if defined(__cplusplus)
161 /*
162 * Starting with 3.3, <linux/compiler-gcc.h> appends 'notrace' (which
163 * expands to __attribute__((no_instrument_function))) to inline,
164 * __inline and __inline__. Revert that.
165 */
166# undef inline
167# define inline inline
168# undef __inline__
169# define __inline__ __inline__
170# undef __inline
171# define __inline __inline
172# endif
173# include <linux/types.h>
174# include <linux/stddef.h>
175 /*
176 * Starting with 3.4, <linux/stddef.h> defines NULL as '((void*)0)' which
177 * does not work for C++ code.
178 */
179# undef NULL
180# undef uintptr_t
181# ifdef __GNUC__
182# if !RT_GNUC_PREREQ(4, 1)
183 /*
184 * <linux/compiler-gcc{3,4}.h> does
185 * #define __inline__ __inline__ __attribute__((always_inline))
186 * in some older Linux kernels. Forcing inlining will fail for some RTStrA*
187 * functions with gcc <= 4.0 due to passing variable argument lists.
188 */
189# undef __inline__
190# define __inline__ __inline__
191# endif
192# endif
193# undef false
194# undef true
195# undef bool
196
197# elif !defined(DOXYGEN_RUNNING) && RT_MSC_PREREQ(RT_MSC_VER_VC140) && defined(RT_OS_AGNOSTIC)
198 /* Try avoid needing the UCRT just for stddef.h and sys/types.h. */
199 /** @todo refine the RT_OS_AGNOSTIC test? */
200# include <vcruntime.h>
201
202# else
203# include <stddef.h>
204# 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/** ACPI table handle. */
3207typedef struct RTACPITBLINT RT_FAR *RTACPITBL;
3208/** Pointer to an ACPI table handle. */
3209typedef RTACPITBL RT_FAR *PRTACPITBL;
3210/** A NIL ACPI table handle. */
3211#define NIL_RTACPITBL ((RTACPITBL)~(uintptr_t)0)
3212
3213/** ACPI resource handle. */
3214typedef struct RTACPIRESINT RT_FAR *RTACPIRES;
3215/** Pointer to an ACPI resource handle. */
3216typedef RTACPIRES RT_FAR *PRTACPIRES;
3217/** A NIL ACPI resource handle. */
3218#define NIL_RTACPIRES ((RTACPIRES)~(uintptr_t)0)
3219
3220
3221/**
3222 * Handle type.
3223 *
3224 * This is usually used together with RTHANDLEUNION.
3225 */
3226typedef enum RTHANDLETYPE
3227{
3228 /** The invalid zero value. */
3229 RTHANDLETYPE_INVALID = 0,
3230 /** File handle. */
3231 RTHANDLETYPE_FILE,
3232 /** Pipe handle */
3233 RTHANDLETYPE_PIPE,
3234 /** Socket handle. */
3235 RTHANDLETYPE_SOCKET,
3236 /** Thread handle. */
3237 RTHANDLETYPE_THREAD,
3238 /** The end of the valid values. */
3239 RTHANDLETYPE_END,
3240 /** The 32-bit type blow up. */
3241 RTHANDLETYPE_32BIT_HACK = 0x7fffffff
3242} RTHANDLETYPE;
3243/** Pointer to a handle type. */
3244typedef RTHANDLETYPE RT_FAR *PRTHANDLETYPE;
3245
3246/**
3247 * Handle union.
3248 *
3249 * This is usually used together with RTHANDLETYPE or as RTHANDLE.
3250 */
3251typedef union RTHANDLEUNION
3252{
3253 RTFILE hFile; /**< File handle. */
3254 RTPIPE hPipe; /**< Pipe handle. */
3255 RTSOCKET hSocket; /**< Socket handle. */
3256 RTTHREAD hThread; /**< Thread handle. */
3257 /** Generic integer handle value.
3258 * Note that RTFILE is not yet pointer sized, so accessing it via this member
3259 * isn't necessarily safe or fully portable. */
3260 RTHCUINTPTR uInt;
3261} RTHANDLEUNION;
3262/** Pointer to a handle union. */
3263typedef RTHANDLEUNION RT_FAR *PRTHANDLEUNION;
3264/** Pointer to a const handle union. */
3265typedef RTHANDLEUNION const RT_FAR *PCRTHANDLEUNION;
3266
3267/**
3268 * Generic handle.
3269 */
3270typedef struct RTHANDLE
3271{
3272 /** The handle type. */
3273 RTHANDLETYPE enmType;
3274 /** The handle value. */
3275 RTHANDLEUNION u;
3276} RTHANDLE;
3277/** Pointer to a generic handle. */
3278typedef RTHANDLE RT_FAR *PRTHANDLE;
3279/** Pointer to a const generic handle. */
3280typedef RTHANDLE const RT_FAR *PCRTHANDLE;
3281
3282
3283/**
3284 * Standard handles.
3285 *
3286 * @remarks These have the correct file descriptor values for unixy systems and
3287 * can be used directly in code specific to those platforms.
3288 */
3289typedef enum RTHANDLESTD
3290{
3291 /** Invalid standard handle. */
3292 RTHANDLESTD_INVALID = -1,
3293 /** The standard input handle. */
3294 RTHANDLESTD_INPUT = 0,
3295 /** The standard output handle. */
3296 RTHANDLESTD_OUTPUT,
3297 /** The standard error handle. */
3298 RTHANDLESTD_ERROR,
3299 /** The typical 32-bit type hack. */
3300 RTHANDLESTD_32BIT_HACK = 0x7fffffff
3301} RTHANDLESTD;
3302
3303
3304/**
3305 * Error info.
3306 *
3307 * See RTErrInfo*.
3308 */
3309typedef struct RTERRINFO
3310{
3311 /** Flags, see RTERRINFO_FLAGS_XXX. */
3312 uint32_t fFlags;
3313 /** The status code. */
3314 int32_t rc;
3315 /** The size of the message buffer pointed to by pszMsg. */
3316 size_t cbMsg;
3317 /** The error buffer. */
3318 char *pszMsg;
3319 /** Reserved for future use. */
3320 void *apvReserved[2];
3321} RTERRINFO;
3322/** Pointer to an error info structure. */
3323typedef RTERRINFO RT_FAR *PRTERRINFO;
3324/** Pointer to a const error info structure. */
3325typedef RTERRINFO const RT_FAR *PCRTERRINFO;
3326
3327/**
3328 * Static error info structure, see RTErrInfoInitStatic.
3329 */
3330typedef struct RTERRINFOSTATIC
3331{
3332 /** The core error info. */
3333 RTERRINFO Core;
3334 /** The static message buffer. */
3335 char szMsg[3072];
3336} RTERRINFOSTATIC;
3337/** Pointer to a error info buffer. */
3338typedef RTERRINFOSTATIC RT_FAR *PRTERRINFOSTATIC;
3339/** Pointer to a const static error info buffer. */
3340typedef RTERRINFOSTATIC const RT_FAR *PCRTERRINFOSTATIC;
3341
3342
3343/**
3344 * UUID data type.
3345 *
3346 * See RTUuid*.
3347 *
3348 * @remarks IPRT defines that the first three integers in the @c Gen struct
3349 * interpretation are in little endian representation. This is
3350 * different to many other UUID implementation, and requires
3351 * conversion if you need to achieve consistent results.
3352 */
3353typedef union RTUUID
3354{
3355 /** 8-bit view. */
3356 uint8_t au8[16];
3357 /** 16-bit view. */
3358 uint16_t au16[8];
3359 /** 32-bit view. */
3360 uint32_t au32[4];
3361 /** 64-bit view. */
3362 uint64_t au64[2];
3363 /** The way the UUID is declared by the DCE specification. */
3364 struct
3365 {
3366 uint32_t u32TimeLow;
3367 uint16_t u16TimeMid;
3368 uint16_t u16TimeHiAndVersion;
3369 uint8_t u8ClockSeqHiAndReserved;
3370 uint8_t u8ClockSeqLow;
3371 uint8_t au8Node[6];
3372 } Gen;
3373} RTUUID;
3374/** Pointer to UUID data. */
3375typedef RTUUID RT_FAR *PRTUUID;
3376/** Pointer to readonly UUID data. */
3377typedef const RTUUID RT_FAR *PCRTUUID;
3378
3379/** Initializes a RTUUID structure with all zeros (RTUuidIsNull() true). */
3380#define RTUUID_INITIALIZE_NULL { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
3381
3382/** UUID string maximum length. */
3383#define RTUUID_STR_LENGTH 37
3384
3385
3386/** Compression handle. */
3387typedef struct RTZIPCOMP RT_FAR *PRTZIPCOMP;
3388/** Decompressor handle. */
3389typedef struct RTZIPDECOMP RT_FAR *PRTZIPDECOMP;
3390
3391
3392/**
3393 * Unicode Code Point.
3394 */
3395typedef uint32_t RTUNICP;
3396/** Pointer to an Unicode Code Point. */
3397typedef RTUNICP RT_FAR *PRTUNICP;
3398/** Pointer to an Unicode Code Point. */
3399typedef const RTUNICP RT_FAR *PCRTUNICP;
3400/** Max value a RTUNICP type can hold. */
3401#define RTUNICP_MAX ( ~(RTUNICP)0 )
3402/** Invalid code point.
3403 * This is returned when encountered invalid encodings or invalid
3404 * unicode code points. */
3405#define RTUNICP_INVALID ( UINT32_C(0xfffffffe) )
3406
3407
3408/**
3409 * UTF-16 character.
3410 *
3411 * @remark wchar_t is not usable since it's compiler defined and can be 8 thru
3412 * 64 bit wide. On Windows it is 16-bit, though, and for various
3413 * reasons of convenience we need to use the native compiler type when
3414 * compling without the /Zc:wchar_t- option (only relevant for C++ and
3415 * _NATIVE_WCHAR_T_DEFINED indicates the absense of /Zc:wchar_t-).
3416 *
3417 * @remark When we use the term character we're not talking about unicode code point, but
3418 * the basic unit of the string encoding. Thus cwc - count of wide chars - means
3419 * count of RTUTF16; cuc - count of unicode chars - means count of RTUNICP;
3420 * and cch means count of the typedef 'char', which is assumed to be an octet.
3421 */
3422#if defined(_MSC_VER) && defined(__cplusplus) && defined(_NATIVE_WCHAR_T_DEFINED)
3423typedef __wchar_t RTUTF16;
3424#else
3425typedef uint16_t RTUTF16;
3426#endif
3427/** Pointer to a UTF-16 character. */
3428typedef RTUTF16 RT_FAR *PRTUTF16;
3429/** Pointer to a const UTF-16 character. */
3430typedef const RTUTF16 RT_FAR *PCRTUTF16;
3431
3432
3433/**
3434 * String tuple to go with the RT_STR_TUPLE macro.
3435 */
3436typedef struct RTSTRTUPLE
3437{
3438 /** The string. */
3439 const char *psz;
3440 /** The string length. */
3441 size_t cch;
3442} RTSTRTUPLE;
3443/** Pointer to a string tuple. */
3444typedef RTSTRTUPLE RT_FAR *PRTSTRTUPLE;
3445/** Pointer to a const string tuple. */
3446typedef RTSTRTUPLE const RT_FAR *PCRTSTRTUPLE;
3447
3448/**
3449 * Wait for ever if we have to.
3450 */
3451#define RT_INDEFINITE_WAIT (~0U)
3452
3453
3454/**
3455 * Generic process callback.
3456 *
3457 * @returns VBox status code. Failure will cancel the operation.
3458 * @param uPercentage The percentage of the operation which has been completed.
3459 * @param pvUser The user specified argument.
3460 */
3461typedef DECLCALLBACKTYPE(int, FNRTPROGRESS,(unsigned uPercentage, void *pvUser));
3462/** Pointer to a generic progress callback function, FNRTPROCESS(). */
3463typedef FNRTPROGRESS *PFNRTPROGRESS;
3464
3465/**
3466 * Generic vprintf-like callback function for dumpers.
3467 *
3468 * @param pvUser User argument.
3469 * @param pszFormat The format string.
3470 * @param va Arguments for the format string.
3471 */
3472typedef DECLCALLBACKTYPE(void, FNRTDUMPPRINTFV,(void *pvUser, const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(2, 0));
3473/** Pointer to a generic printf-like function for dumping. */
3474typedef FNRTDUMPPRINTFV *PFNRTDUMPPRINTFV;
3475
3476
3477/**
3478 * A point in a two dimentional coordinate system.
3479 */
3480typedef struct RTPOINT
3481{
3482 /** X coordinate. */
3483 int32_t x;
3484 /** Y coordinate. */
3485 int32_t y;
3486} RTPOINT;
3487/** Pointer to a point. */
3488typedef RTPOINT RT_FAR *PRTPOINT;
3489/** Pointer to a const point. */
3490typedef const RTPOINT RT_FAR *PCRTPOINT;
3491
3492
3493/**
3494 * Rectangle data type, double point.
3495 */
3496typedef struct RTRECT
3497{
3498 /** left X coordinate. */
3499 int32_t xLeft;
3500 /** top Y coordinate. */
3501 int32_t yTop;
3502 /** right X coordinate. (exclusive) */
3503 int32_t xRight;
3504 /** bottom Y coordinate. (exclusive) */
3505 int32_t yBottom;
3506} RTRECT;
3507/** Pointer to a double point rectangle. */
3508typedef RTRECT RT_FAR *PRTRECT;
3509/** Pointer to a const double point rectangle. */
3510typedef const RTRECT RT_FAR *PCRTRECT;
3511
3512
3513/**
3514 * Rectangle data type, point + size.
3515 */
3516typedef struct RTRECT2
3517{
3518 /** X coordinate.
3519 * Unless stated otherwise, this is the top left corner. */
3520 int32_t x;
3521 /** Y coordinate.
3522 * Unless stated otherwise, this is the top left corner. */
3523 int32_t y;
3524 /** The width.
3525 * Unless stated otherwise, this is to the right of (x,y) and will not
3526 * be a negative number. */
3527 int32_t cx;
3528 /** The height.
3529 * Unless stated otherwise, this is down from (x,y) and will not be a
3530 * negative number. */
3531 int32_t cy;
3532} RTRECT2;
3533/** Pointer to a point + size rectangle. */
3534typedef RTRECT2 RT_FAR *PRTRECT2;
3535/** Pointer to a const point + size rectangle. */
3536typedef const RTRECT2 RT_FAR *PCRTRECT2;
3537
3538
3539/**
3540 * The size of a rectangle.
3541 */
3542typedef struct RTRECTSIZE
3543{
3544 /** The width (along the x-axis). */
3545 uint32_t cx;
3546 /** The height (along the y-axis). */
3547 uint32_t cy;
3548} RTRECTSIZE;
3549/** Pointer to a rectangle size. */
3550typedef RTRECTSIZE RT_FAR *PRTRECTSIZE;
3551/** Pointer to a const rectangle size. */
3552typedef const RTRECTSIZE RT_FAR *PCRTRECTSIZE;
3553
3554
3555/**
3556 * Ethernet MAC address.
3557 *
3558 * The first 24 bits make up the Organisationally Unique Identifier (OUI),
3559 * where the first bit (little endian) indicates multicast (set) / unicast,
3560 * and the second bit indicates locally (set) / global administered. If all
3561 * bits are set, it's a broadcast.
3562 */
3563typedef union RTMAC
3564{
3565 /** @todo add a bitfield view of this stuff. */
3566 /** 8-bit view. */
3567 uint8_t au8[6];
3568 /** 16-bit view. */
3569 uint16_t au16[3];
3570} RTMAC;
3571/** Pointer to a MAC address. */
3572typedef RTMAC RT_FAR *PRTMAC;
3573/** Pointer to a readonly MAC address. */
3574typedef const RTMAC RT_FAR *PCRTMAC;
3575
3576
3577/** Pointer to a lock validator record.
3578 * The structure definition is found in iprt/lockvalidator.h. */
3579typedef struct RTLOCKVALRECEXCL RT_FAR *PRTLOCKVALRECEXCL;
3580/** Pointer to a record of one ownership share.
3581 * The structure definition is found in iprt/lockvalidator.h. */
3582typedef struct RTLOCKVALRECSHRD RT_FAR *PRTLOCKVALRECSHRD;
3583/** Pointer to a lock validator source position.
3584 * The structure definition is found in iprt/lockvalidator.h. */
3585typedef struct RTLOCKVALSRCPOS RT_FAR *PRTLOCKVALSRCPOS;
3586/** Pointer to a const lock validator source position.
3587 * The structure definition is found in iprt/lockvalidator.h. */
3588typedef struct RTLOCKVALSRCPOS const RT_FAR *PCRTLOCKVALSRCPOS;
3589
3590/** @name Special sub-class values.
3591 * The range 16..UINT32_MAX is available to the user, the range 0..15 is
3592 * reserved for the lock validator. In the user range the locks can only be
3593 * taking in ascending order.
3594 * @{ */
3595/** Invalid value. */
3596#define RTLOCKVAL_SUB_CLASS_INVALID UINT32_C(0)
3597/** Not allowed to be taken with any other locks in the same class.
3598 * This is the recommended value. */
3599#define RTLOCKVAL_SUB_CLASS_NONE UINT32_C(1)
3600/** Any order is allowed within the class. */
3601#define RTLOCKVAL_SUB_CLASS_ANY UINT32_C(2)
3602/** The first user value. */
3603#define RTLOCKVAL_SUB_CLASS_USER UINT32_C(16)
3604/** @} */
3605
3606
3607/**
3608 * Digest types.
3609 */
3610typedef enum RTDIGESTTYPE
3611{
3612 /** Invalid digest value. */
3613 RTDIGESTTYPE_INVALID = 0,
3614 /** Unknown digest type. */
3615 RTDIGESTTYPE_UNKNOWN,
3616 /** CRC32 checksum. */
3617 RTDIGESTTYPE_CRC32,
3618 /** CRC64 checksum. */
3619 RTDIGESTTYPE_CRC64,
3620 /** MD2 checksum (unsafe!). */
3621 RTDIGESTTYPE_MD2,
3622 /** MD4 checksum (unsafe!!). */
3623 RTDIGESTTYPE_MD4,
3624 /** MD5 checksum (unsafe!). */
3625 RTDIGESTTYPE_MD5,
3626 /** SHA-1 checksum (unsafe!). */
3627 RTDIGESTTYPE_SHA1,
3628 /** SHA-224 checksum. */
3629 RTDIGESTTYPE_SHA224,
3630 /** SHA-256 checksum. */
3631 RTDIGESTTYPE_SHA256,
3632 /** SHA-384 checksum. */
3633 RTDIGESTTYPE_SHA384,
3634 /** SHA-512 checksum. */
3635 RTDIGESTTYPE_SHA512,
3636 /** SHA-512/224 checksum. */
3637 RTDIGESTTYPE_SHA512T224,
3638 /** SHA-512/256 checksum. */
3639 RTDIGESTTYPE_SHA512T256,
3640 /** SHA3-224 checksum. */
3641 RTDIGESTTYPE_SHA3_224,
3642 /** SHA3-256 checksum. */
3643 RTDIGESTTYPE_SHA3_256,
3644 /** SHA3-384 checksum. */
3645 RTDIGESTTYPE_SHA3_384,
3646 /** SHA3-512 checksum. */
3647 RTDIGESTTYPE_SHA3_512,
3648#if 0
3649 /** SHAKE128 checksum. */
3650 RTDIGESTTYPE_SHAKE128,
3651 /** SHAKE256 checksum. */
3652 RTDIGESTTYPE_SHAKE256,
3653#endif
3654 /** End of valid types. */
3655 RTDIGESTTYPE_END,
3656 /** Usual 32-bit type blowup. */
3657 RTDIGESTTYPE_32BIT_HACK = 0x7fffffff
3658} RTDIGESTTYPE;
3659
3660/**
3661 * Process exit codes.
3662 */
3663typedef enum RTEXITCODE
3664{
3665 /** Success. */
3666 RTEXITCODE_SUCCESS = 0,
3667 /** General failure. */
3668 RTEXITCODE_FAILURE = 1,
3669 /** Invalid arguments. */
3670 RTEXITCODE_SYNTAX = 2,
3671 /** Initialization failure (usually IPRT, but could be used for other
3672 * components as well). */
3673 RTEXITCODE_INIT = 3,
3674 /** Test skipped. */
3675 RTEXITCODE_SKIPPED = 4,
3676 /** The end of valid exit codes. */
3677 RTEXITCODE_END,
3678 /** The usual 32-bit type hack. */
3679 RTEXITCODE_32BIT_HACK = 0x7fffffff
3680} RTEXITCODE;
3681
3682/**
3683 * Range descriptor.
3684 */
3685typedef struct RTRANGE
3686{
3687 /** Start offset. */
3688 uint64_t offStart;
3689 /** Range size. */
3690 size_t cbRange;
3691} RTRANGE;
3692/** Pointer to a range descriptor. */
3693typedef RTRANGE RT_FAR *PRTRANGE;
3694/** Pointer to a readonly range descriptor. */
3695typedef const RTRANGE RT_FAR *PCRTRANGE;
3696
3697
3698/**
3699 * Generic pointer union.
3700 */
3701typedef union RTPTRUNION
3702{
3703 /** Pointer into the void. */
3704 void RT_FAR *pv;
3705 /** As a signed integer. */
3706 intptr_t i;
3707 /** As an unsigned integer. */
3708 uintptr_t u;
3709 /** Pointer to char value. */
3710 char RT_FAR *pch;
3711 /** Pointer to char value. */
3712 unsigned char RT_FAR *puch;
3713 /** Pointer to a int value. */
3714 int RT_FAR *pi;
3715 /** Pointer to a unsigned int value. */
3716 unsigned int RT_FAR *pu;
3717 /** Pointer to a long value. */
3718 long RT_FAR *pl;
3719 /** Pointer to a long value. */
3720 unsigned long RT_FAR *pul;
3721 /** Pointer to a byte value. */
3722 uint8_t RT_FAR *pb;
3723 /** Pointer to a 8-bit unsigned value. */
3724 uint8_t RT_FAR *pu8;
3725 /** Pointer to a 16-bit unsigned value. */
3726 uint16_t RT_FAR *pu16;
3727 /** Pointer to a 32-bit unsigned value. */
3728 uint32_t RT_FAR *pu32;
3729 /** Pointer to a 64-bit unsigned value. */
3730 uint64_t RT_FAR *pu64;
3731 /** Pointer to a 8-bit signed value. */
3732 int8_t RT_FAR *pi8;
3733 /** Pointer to a 16-bit signed value. */
3734 int16_t RT_FAR *pi16;
3735 /** Pointer to a 32-bit signed value. */
3736 int32_t RT_FAR *pi32;
3737 /** Pointer to a 64-bit signed value. */
3738 int64_t RT_FAR *pi64;
3739 /** Pointer to a UTF-16 character. */
3740 PRTUTF16 pwc;
3741 /** Pointer to a UUID character. */
3742 PRTUUID pUuid;
3743} RTPTRUNION;
3744/** Pointer to a pointer union. */
3745typedef RTPTRUNION RT_FAR *PRTPTRUNION;
3746
3747/**
3748 * Generic const pointer union.
3749 */
3750typedef union RTCPTRUNION
3751{
3752 /** Pointer into the void. */
3753 void const RT_FAR *pv;
3754 /** As a signed integer. */
3755 intptr_t i;
3756 /** As an unsigned integer. */
3757 uintptr_t u;
3758 /** Pointer to char value. */
3759 char const RT_FAR *pch;
3760 /** Pointer to char value. */
3761 unsigned char const RT_FAR *puch;
3762 /** Pointer to a int value. */
3763 int const RT_FAR *pi;
3764 /** Pointer to a unsigned int value. */
3765 unsigned int const RT_FAR *pu;
3766 /** Pointer to a long value. */
3767 long const RT_FAR *pl;
3768 /** Pointer to a long value. */
3769 unsigned long const RT_FAR *pul;
3770 /** Pointer to a byte value. */
3771 uint8_t const RT_FAR *pb;
3772 /** Pointer to a 8-bit unsigned value. */
3773 uint8_t const RT_FAR *pu8;
3774 /** Pointer to a 16-bit unsigned value. */
3775 uint16_t const RT_FAR *pu16;
3776 /** Pointer to a 32-bit unsigned value. */
3777 uint32_t const RT_FAR *pu32;
3778 /** Pointer to a 64-bit unsigned value. */
3779 uint64_t const RT_FAR *pu64;
3780 /** Pointer to a 8-bit signed value. */
3781 int8_t const RT_FAR *pi8;
3782 /** Pointer to a 16-bit signed value. */
3783 int16_t const RT_FAR *pi16;
3784 /** Pointer to a 32-bit signed value. */
3785 int32_t const RT_FAR *pi32;
3786 /** Pointer to a 64-bit signed value. */
3787 int64_t const RT_FAR *pi64;
3788 /** Pointer to a UTF-16 character. */
3789 PCRTUTF16 pwc;
3790 /** Pointer to a UUID character. */
3791 PCRTUUID pUuid;
3792} RTCPTRUNION;
3793/** Pointer to a const pointer union. */
3794typedef RTCPTRUNION RT_FAR *PRTCPTRUNION;
3795
3796/**
3797 * Generic volatile pointer union.
3798 */
3799typedef union RTVPTRUNION
3800{
3801 /** Pointer into the void. */
3802 void volatile RT_FAR *pv;
3803 /** As a signed integer. */
3804 intptr_t i;
3805 /** As an unsigned integer. */
3806 uintptr_t u;
3807 /** Pointer to char value. */
3808 char volatile RT_FAR *pch;
3809 /** Pointer to char value. */
3810 unsigned char volatile RT_FAR *puch;
3811 /** Pointer to a int value. */
3812 int volatile RT_FAR *pi;
3813 /** Pointer to a unsigned int value. */
3814 unsigned int volatile RT_FAR *pu;
3815 /** Pointer to a long value. */
3816 long volatile RT_FAR *pl;
3817 /** Pointer to a long value. */
3818 unsigned long volatile RT_FAR *pul;
3819 /** Pointer to a byte value. */
3820 uint8_t volatile RT_FAR *pb;
3821 /** Pointer to a 8-bit unsigned value. */
3822 uint8_t volatile RT_FAR *pu8;
3823 /** Pointer to a 16-bit unsigned value. */
3824 uint16_t volatile RT_FAR *pu16;
3825 /** Pointer to a 32-bit unsigned value. */
3826 uint32_t volatile RT_FAR *pu32;
3827 /** Pointer to a 64-bit unsigned value. */
3828 uint64_t volatile RT_FAR *pu64;
3829 /** Pointer to a 8-bit signed value. */
3830 int8_t volatile RT_FAR *pi8;
3831 /** Pointer to a 16-bit signed value. */
3832 int16_t volatile RT_FAR *pi16;
3833 /** Pointer to a 32-bit signed value. */
3834 int32_t volatile RT_FAR *pi32;
3835 /** Pointer to a 64-bit signed value. */
3836 int64_t volatile RT_FAR *pi64;
3837 /** Pointer to a UTF-16 character. */
3838 RTUTF16 volatile RT_FAR *pwc;
3839 /** Pointer to a UUID character. */
3840 RTUUID volatile RT_FAR *pUuid;
3841} RTVPTRUNION;
3842/** Pointer to a const pointer union. */
3843typedef RTVPTRUNION RT_FAR *PRTVPTRUNION;
3844
3845/**
3846 * Generic const volatile pointer union.
3847 */
3848typedef union RTCVPTRUNION
3849{
3850 /** Pointer into the void. */
3851 void const volatile RT_FAR *pv;
3852 /** As a signed integer. */
3853 intptr_t i;
3854 /** As an unsigned integer. */
3855 uintptr_t u;
3856 /** Pointer to char value. */
3857 char const volatile RT_FAR *pch;
3858 /** Pointer to char value. */
3859 unsigned char const volatile RT_FAR *puch;
3860 /** Pointer to a int value. */
3861 int const volatile RT_FAR *pi;
3862 /** Pointer to a unsigned int value. */
3863 unsigned int const volatile RT_FAR *pu;
3864 /** Pointer to a long value. */
3865 long const volatile RT_FAR *pl;
3866 /** Pointer to a long value. */
3867 unsigned long const volatile RT_FAR *pul;
3868 /** Pointer to a byte value. */
3869 uint8_t const volatile RT_FAR *pb;
3870 /** Pointer to a 8-bit unsigned value. */
3871 uint8_t const volatile RT_FAR *pu8;
3872 /** Pointer to a 16-bit unsigned value. */
3873 uint16_t const volatile RT_FAR *pu16;
3874 /** Pointer to a 32-bit unsigned value. */
3875 uint32_t const volatile RT_FAR *pu32;
3876 /** Pointer to a 64-bit unsigned value. */
3877 uint64_t const volatile RT_FAR *pu64;
3878 /** Pointer to a 8-bit signed value. */
3879 int8_t const volatile RT_FAR *pi8;
3880 /** Pointer to a 16-bit signed value. */
3881 int16_t const volatile RT_FAR *pi16;
3882 /** Pointer to a 32-bit signed value. */
3883 int32_t const volatile RT_FAR *pi32;
3884 /** Pointer to a 64-bit signed value. */
3885 int64_t const volatile RT_FAR *pi64;
3886 /** Pointer to a UTF-16 character. */
3887 RTUTF16 const volatile RT_FAR *pwc;
3888 /** Pointer to a UUID character. */
3889 RTUUID const volatile RT_FAR *pUuid;
3890} RTCVPTRUNION;
3891/** Pointer to a const pointer union. */
3892typedef RTCVPTRUNION RT_FAR *PRTCVPTRUNION;
3893
3894
3895
3896#ifdef __cplusplus
3897/**
3898 * Strict type validation helper class.
3899 *
3900 * See RTErrStrictType and RT_SUCCESS_NP.
3901 */
3902class RTErrStrictType2
3903{
3904protected:
3905 /** The status code. */
3906 int32_t m_rc;
3907
3908public:
3909 /**
3910 * Constructor.
3911 * @param rc IPRT style status code.
3912 */
3913 RTErrStrictType2(int32_t rc) : m_rc(rc)
3914 {
3915 }
3916
3917 /**
3918 * Get the status code.
3919 * @returns IPRT style status code.
3920 */
3921 int32_t getValue() const
3922 {
3923 return m_rc;
3924 }
3925};
3926#endif /* __cplusplus */
3927/** @} */
3928
3929#define IPRT_COMPLETED_types_h /* hack for watcom and nocrt headers depending on this one. */
3930#endif /* !IPRT_INCLUDED_types_h */
3931
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