VirtualBox

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

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

IPRT/strttofloat.cpp: Some fixes and blind attempt at making it build on sparc. bugref:10261

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

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