VirtualBox

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

Last change on this file since 87359 was 85614, checked in by vboxsync, 4 years ago

IPRT: Adding SHA-3. bugref:9734

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

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