VirtualBox

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

Last change on this file since 34066 was 34049, checked in by vboxsync, 14 years ago

iprt/tarvfs: Working on validating and parsing the tar headers.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 55.4 KB
Line 
1/** @file
2 * IPRT - Types.
3 */
4
5/*
6 * Copyright (C) 2006-2010 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_types_h
27#define ___iprt_types_h
28
29#include <iprt/cdefs.h>
30#include <iprt/stdint.h>
31
32/*
33 * Include standard C types.
34 */
35#ifndef IPRT_NO_CRT
36
37# if defined(RT_OS_DARWIN) && defined(KERNEL)
38 /*
39 * Kludge for the darwin kernel:
40 * stddef.h is missing IIRC.
41 */
42# ifndef _PTRDIFF_T
43# define _PTRDIFF_T
44 typedef __darwin_ptrdiff_t ptrdiff_t;
45# endif
46# include <sys/types.h>
47
48# elif defined(RT_OS_FREEBSD) && defined(_KERNEL)
49 /*
50 * Kludge for the FreeBSD kernel:
51 * stddef.h and sys/types.h have slightly different offsetof definitions
52 * when compiling in kernel mode. This is just to make GCC shut up.
53 */
54# ifndef _STDDEF_H_
55# undef offsetof
56# endif
57# include <sys/stddef.h>
58# ifndef _SYS_TYPES_H_
59# undef offsetof
60# endif
61# include <sys/types.h>
62# ifndef offsetof
63# error "offsetof is not defined..."
64# endif
65
66# elif defined(RT_OS_FREEBSD) && HC_ARCH_BITS == 64 && defined(RT_ARCH_X86)
67 /*
68 * Kludge for compiling 32-bit code on a 64-bit FreeBSD:
69 * FreeBSD declares uint64_t and int64_t wrong (long unsigned and long int
70 * though they need to be long long unsigned and long long int). These
71 * defines conflict with our decleration in stdint.h. Adding the defines
72 * below omits the definitions in the system header.
73 */
74# include <stddef.h>
75# define _UINT64_T_DECLARED
76# define _INT64_T_DECLARED
77# include <sys/types.h>
78
79# elif defined(RT_OS_LINUX) && defined(__KERNEL__)
80 /*
81 * Kludge for the linux kernel:
82 * 1. sys/types.h doesn't mix with the kernel.
83 * 2. Starting with 2.6.19, linux/types.h typedefs bool and linux/stddef.h
84 * declares false and true as enum values.
85 * 3. Starting with 2.6.24, linux/types.h typedefs uintptr_t.
86 * We work around these issues here and nowhere else.
87 */
88# include <stddef.h>
89# if defined(__cplusplus)
90 typedef bool _Bool;
91# endif
92# define bool linux_bool
93# define true linux_true
94# define false linux_false
95# define uintptr_t linux_uintptr_t
96# ifndef AUTOCONF_INCLUDED
97# include <linux/autoconf.h>
98# endif
99# include <linux/types.h>
100# include <linux/stddef.h>
101# undef uintptr_t
102# ifdef __GNUC__
103# if (__GNUC__ * 100 + __GNUC_MINOR__) <= 400
104 /*
105 * <linux/compiler-gcc{3,4}.h> does
106 * #define __inline__ __inline__ __attribute__((always_inline))
107 * in some older Linux kernels. Forcing inlining will fail for some RTStrA*
108 * functions with gcc <= 4.0 due to passing variable argument lists.
109 */
110# undef __inline__
111# define __inline__ __inline__
112# endif
113# endif
114# undef false
115# undef true
116# undef bool
117
118# else
119# include <stddef.h>
120# include <sys/types.h>
121# endif
122
123/* Define any types missing from sys/types.h on windows. */
124# ifdef _MSC_VER
125# undef ssize_t
126 typedef intptr_t ssize_t;
127# endif
128
129#else /* no crt */
130# include <iprt/nocrt/compiler/compiler.h>
131#endif /* no crt */
132
133
134
135/** @defgroup grp_rt_types IPRT Base Types
136 * @{
137 */
138
139/* define wchar_t, we don't wanna include all the wcsstuff to get this. */
140#ifdef _MSC_VER
141# ifndef _WCHAR_T_DEFINED
142 typedef unsigned short wchar_t;
143# define _WCHAR_T_DEFINED
144# endif
145#endif
146#ifdef __GNUC__
147/** @todo wchar_t on GNUC */
148#endif
149
150/*
151 * C doesn't have bool.
152 */
153#ifndef __cplusplus
154# if defined(__GNUC__)
155# if defined(RT_OS_LINUX) && __GNUC__ < 3
156typedef uint8_t bool;
157# else
158# if defined(RT_OS_DARWIN) && defined(_STDBOOL_H)
159# undef bool
160# endif
161typedef _Bool bool;
162# endif
163# else
164typedef unsigned char bool;
165# endif
166# ifndef true
167# define true (1)
168# endif
169# ifndef false
170# define false (0)
171# endif
172#endif
173
174/**
175 * 128-bit unsigned integer.
176 */
177#if defined(__GNUC__) && defined(RT_ARCH_AMD64)
178typedef __uint128_t uint128_t;
179#else
180typedef struct uint128_s
181{
182# ifdef RT_BIG_ENDIAN
183 uint64_t Hi;
184 uint64_t Lo;
185# else
186 uint64_t Lo;
187 uint64_t Hi;
188# endif
189} uint128_t;
190#endif
191
192
193/**
194 * 128-bit signed integer.
195 */
196#if defined(__GNUC__) && defined(RT_ARCH_AMD64)
197typedef __int128_t int128_t;
198#else
199typedef struct int128_s
200{
201# ifdef RT_BIG_ENDIAN
202 int64_t Hi;
203 uint64_t Lo;
204# else
205 uint64_t Lo;
206 int64_t Hi;
207# endif
208} int128_t;
209#endif
210
211
212/**
213 * 16-bit unsigned integer union.
214 */
215typedef union RTUINT16U
216{
217 /** natural view. */
218 uint16_t u;
219
220 /** 16-bit view. */
221 uint16_t au16[1];
222 /** 8-bit view. */
223 uint8_t au8[2];
224 /** 16-bit hi/lo view. */
225 struct
226 {
227#ifdef RT_BIG_ENDIAN
228 uint8_t Hi;
229 uint8_t Lo;
230#else
231 uint8_t Lo;
232 uint8_t Hi;
233#endif
234 } s;
235} RTUINT16U;
236/** Pointer to a 16-bit unsigned integer union. */
237typedef RTUINT16U *PRTUINT16U;
238/** Pointer to a const 32-bit unsigned integer union. */
239typedef const RTUINT16U *PCRTUINT16U;
240
241
242/**
243 * 32-bit unsigned integer union.
244 */
245typedef union RTUINT32U
246{
247 /** natural view. */
248 uint32_t u;
249 /** Hi/Low view. */
250 struct
251 {
252#ifdef RT_BIG_ENDIAN
253 uint16_t Hi;
254 uint16_t Lo;
255#else
256 uint16_t Lo;
257 uint16_t Hi;
258#endif
259 } s;
260 /** Word view. */
261 struct
262 {
263#ifdef RT_BIG_ENDIAN
264 uint16_t w1;
265 uint16_t w0;
266#else
267 uint16_t w0;
268 uint16_t w1;
269#endif
270 } Words;
271
272 /** 32-bit view. */
273 uint32_t au32[1];
274 /** 16-bit view. */
275 uint16_t au16[2];
276 /** 8-bit view. */
277 uint8_t au8[4];
278} RTUINT32U;
279/** Pointer to a 32-bit unsigned integer union. */
280typedef RTUINT32U *PRTUINT32U;
281/** Pointer to a const 32-bit unsigned integer union. */
282typedef const RTUINT32U *PCRTUINT32U;
283
284
285/**
286 * 64-bit unsigned integer union.
287 */
288typedef union RTUINT64U
289{
290 /** Natural view. */
291 uint64_t u;
292 /** Hi/Low view. */
293 struct
294 {
295#ifdef RT_BIG_ENDIAN
296 uint32_t Hi;
297 uint32_t Lo;
298#else
299 uint32_t Lo;
300 uint32_t Hi;
301#endif
302 } s;
303 /** Double-Word view. */
304 struct
305 {
306#ifdef RT_BIG_ENDIAN
307 uint32_t dw1;
308 uint32_t dw0;
309#else
310 uint32_t dw0;
311 uint32_t dw1;
312#endif
313 } DWords;
314 /** Word view. */
315 struct
316 {
317#ifdef RT_BIG_ENDIAN
318 uint16_t w3;
319 uint16_t w2;
320 uint16_t w1;
321 uint16_t w0;
322#else
323 uint16_t w0;
324 uint16_t w1;
325 uint16_t w2;
326 uint16_t w3;
327#endif
328 } Words;
329
330 /** 64-bit view. */
331 uint64_t au64[1];
332 /** 32-bit view. */
333 uint32_t au32[2];
334 /** 16-bit view. */
335 uint16_t au16[4];
336 /** 8-bit view. */
337 uint8_t au8[8];
338} RTUINT64U;
339/** Pointer to a 64-bit unsigned integer union. */
340typedef RTUINT64U *PRTUINT64U;
341/** Pointer to a const 64-bit unsigned integer union. */
342typedef const RTUINT64U *PCRTUINT64U;
343
344
345/**
346 * 128-bit unsigned integer union.
347 */
348typedef union RTUINT128U
349{
350 /** Natural view.
351 * WARNING! This member depends on the compiler supporting 128-bit stuff. */
352 uint128_t u;
353 /** Hi/Low view. */
354 struct
355 {
356#ifdef RT_BIG_ENDIAN
357 uint64_t Hi;
358 uint64_t Lo;
359#else
360 uint64_t Lo;
361 uint64_t Hi;
362#endif
363 } s;
364 /** Quad-Word view. */
365 struct
366 {
367#ifdef RT_BIG_ENDIAN
368 uint64_t qw1;
369 uint64_t qw0;
370#else
371 uint64_t qw0;
372 uint64_t qw1;
373#endif
374 } QWords;
375 /** Double-Word view. */
376 struct
377 {
378#ifdef RT_BIG_ENDIAN
379 uint32_t dw3;
380 uint32_t dw2;
381 uint32_t dw1;
382 uint32_t dw0;
383#else
384 uint32_t dw0;
385 uint32_t dw1;
386 uint32_t dw2;
387 uint32_t dw3;
388#endif
389 } DWords;
390 /** Word view. */
391 struct
392 {
393#ifdef RT_BIG_ENDIAN
394 uint16_t w7;
395 uint16_t w6;
396 uint16_t w5;
397 uint16_t w4;
398 uint16_t w3;
399 uint16_t w2;
400 uint16_t w1;
401 uint16_t w0;
402#else
403 uint16_t w0;
404 uint16_t w1;
405 uint16_t w2;
406 uint16_t w3;
407 uint16_t w4;
408 uint16_t w5;
409 uint16_t w6;
410 uint16_t w7;
411#endif
412 } Words;
413
414 /** 64-bit view. */
415 uint64_t au64[2];
416 /** 32-bit view. */
417 uint32_t au32[4];
418 /** 16-bit view. */
419 uint16_t au16[8];
420 /** 8-bit view. */
421 uint8_t au8[16];
422} RTUINT128U;
423/** Pointer to a 64-bit unsigned integer union. */
424typedef RTUINT128U *PRTUINT128U;
425/** Pointer to a const 64-bit unsigned integer union. */
426typedef const RTUINT128U *PCRTUINT128U;
427
428
429/** Generic function type.
430 * @see PFNRT
431 */
432typedef DECLCALLBACK(void) FNRT(void);
433
434/** Generic function pointer.
435 * With -pedantic, gcc-4 complains when casting a function to a data object, for
436 * example:
437 *
438 * @code
439 * void foo(void)
440 * {
441 * }
442 *
443 * void *bar = (void *)foo;
444 * @endcode
445 *
446 * The compiler would warn with "ISO C++ forbids casting between
447 * pointer-to-function and pointer-to-object". The purpose of this warning is
448 * not to bother the programmer but to point out that he is probably doing
449 * something dangerous, assigning a pointer to executable code to a data object.
450 */
451typedef FNRT *PFNRT;
452
453/** Millisecond interval. */
454typedef uint32_t RTMSINTERVAL;
455/** Pointer to a millisecond interval. */
456typedef RTMSINTERVAL *PRTMSINTERVAL;
457/** Pointer to a const millisecond interval. */
458typedef const RTMSINTERVAL *PCRTMSINTERVAL;
459
460
461/** @defgroup grp_rt_types_both Common Guest and Host Context Basic Types
462 * @ingroup grp_rt_types
463 * @{
464 */
465
466/** Signed integer which can contain both GC and HC pointers. */
467#if (HC_ARCH_BITS == 32 && GC_ARCH_BITS == 32)
468typedef int32_t RTINTPTR;
469#elif (HC_ARCH_BITS == 64 || GC_ARCH_BITS == 64)
470typedef int64_t RTINTPTR;
471#else
472# error Unsupported HC_ARCH_BITS and/or GC_ARCH_BITS values.
473#endif
474/** Pointer to signed integer which can contain both GC and HC pointers. */
475typedef RTINTPTR *PRTINTPTR;
476/** Pointer const to signed integer which can contain both GC and HC pointers. */
477typedef const RTINTPTR *PCRTINTPTR;
478/** The maximum value the RTINTPTR type can hold. */
479#if (HC_ARCH_BITS == 32 && GC_ARCH_BITS == 32)
480# define RTINTPTR_MAX INT32_MAX
481#elif (HC_ARCH_BITS == 64 || GC_ARCH_BITS == 64)
482# define RTINTPTR_MAX INT64_MAX
483#else
484# error Unsupported HC_ARCH_BITS and/or GC_ARCH_BITS values.
485#endif
486/** The minimum value the RTINTPTR type can hold. */
487#if (HC_ARCH_BITS == 32 && GC_ARCH_BITS == 32)
488# define RTINTPTR_MIN INT32_MIN
489#elif (HC_ARCH_BITS == 64 || GC_ARCH_BITS == 64)
490# define RTINTPTR_MIN INT64_MIN
491#else
492# error Unsupported HC_ARCH_BITS and/or GC_ARCH_BITS values.
493#endif
494
495/** Unsigned integer which can contain both GC and HC pointers. */
496#if (HC_ARCH_BITS == 32 && GC_ARCH_BITS == 32)
497typedef uint32_t RTUINTPTR;
498#elif (HC_ARCH_BITS == 64 || GC_ARCH_BITS == 64)
499typedef uint64_t RTUINTPTR;
500#else
501# error Unsupported HC_ARCH_BITS and/or GC_ARCH_BITS values.
502#endif
503/** Pointer to unsigned integer which can contain both GC and HC pointers. */
504typedef RTUINTPTR *PRTUINTPTR;
505/** Pointer const to unsigned integer which can contain both GC and HC pointers. */
506typedef const RTUINTPTR *PCRTUINTPTR;
507/** The maximum value the RTUINTPTR type can hold. */
508#if (HC_ARCH_BITS == 32 && GC_ARCH_BITS == 32)
509# define RTUINTPTR_MAX UINT32_MAX
510#elif (HC_ARCH_BITS == 64 || GC_ARCH_BITS == 64)
511# define RTUINTPTR_MAX UINT64_MAX
512#else
513# error Unsupported HC_ARCH_BITS and/or GC_ARCH_BITS values.
514#endif
515
516/** Signed integer. */
517typedef int32_t RTINT;
518/** Pointer to signed integer. */
519typedef RTINT *PRTINT;
520/** Pointer to const signed integer. */
521typedef const RTINT *PCRTINT;
522
523/** Unsigned integer. */
524typedef uint32_t RTUINT;
525/** Pointer to unsigned integer. */
526typedef RTUINT *PRTUINT;
527/** Pointer to const unsigned integer. */
528typedef const RTUINT *PCRTUINT;
529
530/** A file offset / size (off_t). */
531typedef int64_t RTFOFF;
532/** Pointer to a file offset / size. */
533typedef RTFOFF *PRTFOFF;
534/** The max value for RTFOFF. */
535#define RTFOFF_MAX INT64_MAX
536/** The min value for RTFOFF. */
537#define RTFOFF_MIN INT64_MIN
538
539/** File mode (see iprt/fs.h). */
540typedef uint32_t RTFMODE;
541/** Pointer to file mode. */
542typedef RTFMODE *PRTFMODE;
543
544/** Device unix number. */
545typedef uint32_t RTDEV;
546/** Pointer to a device unix number. */
547typedef RTDEV *PRTDEV;
548
549/** @name RTDEV Macros
550 * @{ */
551/**
552 * Our makedev macro.
553 * @returns RTDEV
554 * @param uMajor The major device number.
555 * @param uMinor The minor device number.
556 */
557#define RTDEV_MAKE(uMajor, uMinor) ((RTDEV)( ((RTDEV)(uMajor) << 24) | (uMinor & UINT32_C(0x00ffffff)) ))
558/**
559 * Get the major device node number from an RTDEV type.
560 * @returns The major device number of @a uDev
561 * @param uDev The device number.
562 */
563#define RTDEV_MAJOR(uDev) ((uDev) >> 24)
564/**
565 * Get the minor device node number from an RTDEV type.
566 * @returns The minor device number of @a uDev
567 * @param uDev The device number.
568 */
569#define RTDEV_MINOR(uDev) ((uDev) & UINT32_C(0x00ffffff))
570/** @} */
571
572/** i-node number. */
573typedef uint64_t RTINODE;
574/** Pointer to a i-node number. */
575typedef RTINODE *PRTINODE;
576
577/** User id. */
578typedef uint32_t RTUID;
579/** Pointer to a user id. */
580typedef RTUID *PRTUID;
581/** NIL user id.
582 * @todo check this for portability! */
583#define NIL_RTUID (~(RTUID)0);
584
585/** Group id. */
586typedef uint32_t RTGID;
587/** Pointer to a group id. */
588typedef RTGID *PRTGID;
589/** NIL group id.
590 * @todo check this for portability! */
591#define NIL_RTGID (~(RTGID)0);
592
593/** I/O Port. */
594typedef uint16_t RTIOPORT;
595/** Pointer to I/O Port. */
596typedef RTIOPORT *PRTIOPORT;
597/** Pointer to const I/O Port. */
598typedef const RTIOPORT *PCRTIOPORT;
599
600/** Selector. */
601typedef uint16_t RTSEL;
602/** Pointer to selector. */
603typedef RTSEL *PRTSEL;
604/** Pointer to const selector. */
605typedef const RTSEL *PCRTSEL;
606/** Max selector value. */
607#define RTSEL_MAX UINT16_MAX
608
609/** Far 16-bit pointer. */
610#pragma pack(1)
611typedef struct RTFAR16
612{
613 uint16_t off;
614 RTSEL sel;
615} RTFAR16;
616#pragma pack()
617/** Pointer to Far 16-bit pointer. */
618typedef RTFAR16 *PRTFAR16;
619/** Pointer to const Far 16-bit pointer. */
620typedef const RTFAR16 *PCRTFAR16;
621
622/** Far 32-bit pointer. */
623#pragma pack(1)
624typedef struct RTFAR32
625{
626 uint32_t off;
627 RTSEL sel;
628} RTFAR32;
629#pragma pack()
630/** Pointer to Far 32-bit pointer. */
631typedef RTFAR32 *PRTFAR32;
632/** Pointer to const Far 32-bit pointer. */
633typedef const RTFAR32 *PCRTFAR32;
634
635/** Far 64-bit pointer. */
636#pragma pack(1)
637typedef struct RTFAR64
638{
639 uint64_t off;
640 RTSEL sel;
641} RTFAR64;
642#pragma pack()
643/** Pointer to Far 64-bit pointer. */
644typedef RTFAR64 *PRTFAR64;
645/** Pointer to const Far 64-bit pointer. */
646typedef const RTFAR64 *PCRTFAR64;
647
648/** @} */
649
650
651/** @defgroup grp_rt_types_hc Host Context Basic Types
652 * @ingroup grp_rt_types
653 * @{
654 */
655
656/** HC Natural signed integer.
657 * @deprecated silly type. */
658typedef int32_t RTHCINT;
659/** Pointer to HC Natural signed integer.
660 * @deprecated silly type. */
661typedef RTHCINT *PRTHCINT;
662/** Pointer to const HC Natural signed integer.
663 * @deprecated silly type. */
664typedef const RTHCINT *PCRTHCINT;
665
666/** HC Natural unsigned integer.
667 * @deprecated silly type. */
668typedef uint32_t RTHCUINT;
669/** Pointer to HC Natural unsigned integer.
670 * @deprecated silly type. */
671typedef RTHCUINT *PRTHCUINT;
672/** Pointer to const HC Natural unsigned integer.
673 * @deprecated silly type. */
674typedef const RTHCUINT *PCRTHCUINT;
675
676
677/** Signed integer which can contain a HC pointer. */
678#if HC_ARCH_BITS == 32
679typedef int32_t RTHCINTPTR;
680#elif HC_ARCH_BITS == 64
681typedef int64_t RTHCINTPTR;
682#else
683# error Unsupported HC_ARCH_BITS value.
684#endif
685/** Pointer to signed integer which can contain a HC pointer. */
686typedef RTHCINTPTR *PRTHCINTPTR;
687/** Pointer to const signed integer which can contain a HC pointer. */
688typedef const RTHCINTPTR *PCRTHCINTPTR;
689/** Max RTHCINTPTR value. */
690#if HC_ARCH_BITS == 32
691# define RTHCINTPTR_MAX INT32_MAX
692#else
693# define RTHCINTPTR_MAX INT64_MAX
694#endif
695/** Min RTHCINTPTR value. */
696#if HC_ARCH_BITS == 32
697# define RTHCINTPTR_MIN INT32_MIN
698#else
699# define RTHCINTPTR_MIN INT64_MIN
700#endif
701
702/** Signed integer which can contain a HC ring-3 pointer. */
703#if R3_ARCH_BITS == 32
704typedef int32_t RTR3INTPTR;
705#elif R3_ARCH_BITS == 64
706typedef int64_t RTR3INTPTR;
707#else
708# error Unsupported R3_ARCH_BITS value.
709#endif
710/** Pointer to signed integer which can contain a HC ring-3 pointer. */
711typedef RTR3INTPTR *PRTR3INTPTR;
712/** Pointer to const signed integer which can contain a HC ring-3 pointer. */
713typedef const RTR3INTPTR *PCRTR3INTPTR;
714/** Max RTR3INTPTR value. */
715#if R3_ARCH_BITS == 32
716# define RTR3INTPTR_MAX INT32_MAX
717#else
718# define RTR3INTPTR_MAX INT64_MAX
719#endif
720/** Min RTR3INTPTR value. */
721#if R3_ARCH_BITS == 32
722# define RTR3INTPTR_MIN INT32_MIN
723#else
724# define RTR3INTPTR_MIN INT64_MIN
725#endif
726
727/** Signed integer which can contain a HC ring-0 pointer. */
728#if R0_ARCH_BITS == 32
729typedef int32_t RTR0INTPTR;
730#elif R0_ARCH_BITS == 64
731typedef int64_t RTR0INTPTR;
732#else
733# error Unsupported R0_ARCH_BITS value.
734#endif
735/** Pointer to signed integer which can contain a HC ring-0 pointer. */
736typedef RTR0INTPTR *PRTR0INTPTR;
737/** Pointer to const signed integer which can contain a HC ring-0 pointer. */
738typedef const RTR0INTPTR *PCRTR0INTPTR;
739/** Max RTR0INTPTR value. */
740#if R0_ARCH_BITS == 32
741# define RTR0INTPTR_MAX INT32_MAX
742#else
743# define RTR0INTPTR_MAX INT64_MAX
744#endif
745/** Min RTHCINTPTR value. */
746#if R0_ARCH_BITS == 32
747# define RTR0INTPTR_MIN INT32_MIN
748#else
749# define RTR0INTPTR_MIN INT64_MIN
750#endif
751
752
753/** Unsigned integer which can contain a HC pointer. */
754#if HC_ARCH_BITS == 32
755typedef uint32_t RTHCUINTPTR;
756#elif HC_ARCH_BITS == 64
757typedef uint64_t RTHCUINTPTR;
758#else
759# error Unsupported HC_ARCH_BITS value.
760#endif
761/** Pointer to unsigned integer which can contain a HC pointer. */
762typedef RTHCUINTPTR *PRTHCUINTPTR;
763/** Pointer to unsigned integer which can contain a HC pointer. */
764typedef const RTHCUINTPTR *PCRTHCUINTPTR;
765/** Max RTHCUINTTPR value. */
766#if HC_ARCH_BITS == 32
767# define RTHCUINTPTR_MAX UINT32_MAX
768#else
769# define RTHCUINTPTR_MAX UINT64_MAX
770#endif
771
772/** Unsigned integer which can contain a HC ring-3 pointer. */
773#if R3_ARCH_BITS == 32
774typedef uint32_t RTR3UINTPTR;
775#elif R3_ARCH_BITS == 64
776typedef uint64_t RTR3UINTPTR;
777#else
778# error Unsupported R3_ARCH_BITS value.
779#endif
780/** Pointer to unsigned integer which can contain a HC ring-3 pointer. */
781typedef RTR3UINTPTR *PRTR3UINTPTR;
782/** Pointer to unsigned integer which can contain a HC ring-3 pointer. */
783typedef const RTR3UINTPTR *PCRTR3UINTPTR;
784/** Max RTHCUINTTPR value. */
785#if R3_ARCH_BITS == 32
786# define RTR3UINTPTR_MAX UINT32_MAX
787#else
788# define RTR3UINTPTR_MAX UINT64_MAX
789#endif
790
791/** Unsigned integer which can contain a HC ring-0 pointer. */
792#if R0_ARCH_BITS == 32
793typedef uint32_t RTR0UINTPTR;
794#elif R0_ARCH_BITS == 64
795typedef uint64_t RTR0UINTPTR;
796#else
797# error Unsupported R0_ARCH_BITS value.
798#endif
799/** Pointer to unsigned integer which can contain a HC ring-0 pointer. */
800typedef RTR0UINTPTR *PRTR0UINTPTR;
801/** Pointer to unsigned integer which can contain a HC ring-0 pointer. */
802typedef const RTR0UINTPTR *PCRTR0UINTPTR;
803/** Max RTR0UINTTPR value. */
804#if HC_ARCH_BITS == 32
805# define RTR0UINTPTR_MAX UINT32_MAX
806#else
807# define RTR0UINTPTR_MAX UINT64_MAX
808#endif
809
810
811/** Host Physical Memory Address. */
812typedef uint64_t RTHCPHYS;
813/** Pointer to Host Physical Memory Address. */
814typedef RTHCPHYS *PRTHCPHYS;
815/** Pointer to const Host Physical Memory Address. */
816typedef const RTHCPHYS *PCRTHCPHYS;
817/** @def NIL_RTHCPHYS
818 * NIL HC Physical Address.
819 * NIL_RTHCPHYS is used to signal an invalid physical address, similar
820 * to the NULL pointer.
821 */
822#define NIL_RTHCPHYS (~(RTHCPHYS)0)
823/** Max RTHCPHYS value. */
824#define RTHCPHYS_MAX UINT64_MAX
825
826
827/** HC pointer. */
828#ifndef IN_RC
829typedef void * RTHCPTR;
830#else
831typedef RTHCUINTPTR RTHCPTR;
832#endif
833/** Pointer to HC pointer. */
834typedef RTHCPTR *PRTHCPTR;
835/** Pointer to const HC pointer. */
836typedef const RTHCPTR *PCRTHCPTR;
837/** @def NIL_RTHCPTR
838 * NIL HC pointer.
839 */
840#define NIL_RTHCPTR ((RTHCPTR)0)
841/** Max RTHCPTR value. */
842#define RTHCPTR_MAX ((RTHCPTR)RTHCUINTPTR_MAX)
843
844
845/** HC ring-3 pointer. */
846#ifdef IN_RING3
847typedef void * RTR3PTR;
848#else
849typedef RTR3UINTPTR RTR3PTR;
850#endif
851/** Pointer to HC ring-3 pointer. */
852typedef RTR3PTR *PRTR3PTR;
853/** Pointer to const HC ring-3 pointer. */
854typedef const RTR3PTR *PCRTR3PTR;
855/** @def NIL_RTR3PTR
856 * NIL HC ring-3 pointer.
857 */
858#define NIL_RTR3PTR ((RTR3PTR)0)
859/** Max RTR3PTR value. */
860#define RTR3PTR_MAX ((RTR3PTR)RTR3UINTPTR_MAX)
861
862/** HC ring-0 pointer. */
863#ifdef IN_RING0
864typedef void * RTR0PTR;
865#else
866typedef RTR0UINTPTR RTR0PTR;
867#endif
868/** Pointer to HC ring-0 pointer. */
869typedef RTR0PTR *PRTR0PTR;
870/** Pointer to const HC ring-0 pointer. */
871typedef const RTR0PTR *PCRTR0PTR;
872/** @def NIL_RTR0PTR
873 * NIL HC ring-0 pointer.
874 */
875#define NIL_RTR0PTR ((RTR0PTR)0)
876/** Max RTR3PTR value. */
877#define RTR0PTR_MAX ((RTR0PTR)RTR0UINTPTR_MAX)
878
879
880/** Unsigned integer register in the host context. */
881#if HC_ARCH_BITS == 32
882typedef uint32_t RTHCUINTREG;
883#elif HC_ARCH_BITS == 64
884typedef uint64_t RTHCUINTREG;
885#else
886# error "Unsupported HC_ARCH_BITS!"
887#endif
888/** Pointer to an unsigned integer register in the host context. */
889typedef RTHCUINTREG *PRTHCUINTREG;
890/** Pointer to a const unsigned integer register in the host context. */
891typedef const RTHCUINTREG *PCRTHCUINTREG;
892
893/** Unsigned integer register in the host ring-3 context. */
894#if R3_ARCH_BITS == 32
895typedef uint32_t RTR3UINTREG;
896#elif R3_ARCH_BITS == 64
897typedef uint64_t RTR3UINTREG;
898#else
899# error "Unsupported R3_ARCH_BITS!"
900#endif
901/** Pointer to an unsigned integer register in the host ring-3 context. */
902typedef RTR3UINTREG *PRTR3UINTREG;
903/** Pointer to a const unsigned integer register in the host ring-3 context. */
904typedef const RTR3UINTREG *PCRTR3UINTREG;
905
906/** Unsigned integer register in the host ring-3 context. */
907#if R0_ARCH_BITS == 32
908typedef uint32_t RTR0UINTREG;
909#elif R0_ARCH_BITS == 64
910typedef uint64_t RTR0UINTREG;
911#else
912# error "Unsupported R3_ARCH_BITS!"
913#endif
914/** Pointer to an unsigned integer register in the host ring-3 context. */
915typedef RTR0UINTREG *PRTR0UINTREG;
916/** Pointer to a const unsigned integer register in the host ring-3 context. */
917typedef const RTR0UINTREG *PCRTR0UINTREG;
918
919/** @} */
920
921
922/** @defgroup grp_rt_types_gc Guest Context Basic Types
923 * @ingroup grp_rt_types
924 * @{
925 */
926
927/** Natural signed integer in the GC.
928 * @deprecated silly type. */
929#if GC_ARCH_BITS == 32
930typedef int32_t RTGCINT;
931#elif GC_ARCH_BITS == 64 /** @todo this isn't right, natural int is 32-bit, see RTHCINT. */
932typedef int64_t RTGCINT;
933#endif
934/** Pointer to natural signed integer in GC.
935 * @deprecated silly type. */
936typedef RTGCINT *PRTGCINT;
937/** Pointer to const natural signed integer in GC.
938 * @deprecated silly type. */
939typedef const RTGCINT *PCRTGCINT;
940
941/** Natural unsigned integer in the GC.
942 * @deprecated silly type. */
943#if GC_ARCH_BITS == 32
944typedef uint32_t RTGCUINT;
945#elif GC_ARCH_BITS == 64 /** @todo this isn't right, natural int is 32-bit, see RTHCUINT. */
946typedef uint64_t RTGCUINT;
947#endif
948/** Pointer to natural unsigned integer in GC.
949 * @deprecated silly type. */
950typedef RTGCUINT *PRTGCUINT;
951/** Pointer to const natural unsigned integer in GC.
952 * @deprecated silly type. */
953typedef const RTGCUINT *PCRTGCUINT;
954
955/** Signed integer which can contain a GC pointer. */
956#if GC_ARCH_BITS == 32
957typedef int32_t RTGCINTPTR;
958#elif GC_ARCH_BITS == 64
959typedef int64_t RTGCINTPTR;
960#endif
961/** Pointer to signed integer which can contain a GC pointer. */
962typedef RTGCINTPTR *PRTGCINTPTR;
963/** Pointer to const signed integer which can contain a GC pointer. */
964typedef const RTGCINTPTR *PCRTGCINTPTR;
965
966/** Unsigned integer which can contain a GC pointer. */
967#if GC_ARCH_BITS == 32
968typedef uint32_t RTGCUINTPTR;
969#elif GC_ARCH_BITS == 64
970typedef uint64_t RTGCUINTPTR;
971#else
972# error Unsupported GC_ARCH_BITS value.
973#endif
974/** Pointer to unsigned integer which can contain a GC pointer. */
975typedef RTGCUINTPTR *PRTGCUINTPTR;
976/** Pointer to unsigned integer which can contain a GC pointer. */
977typedef const RTGCUINTPTR *PCRTGCUINTPTR;
978
979/** Unsigned integer which can contain a 32 bits GC pointer. */
980typedef uint32_t RTGCUINTPTR32;
981/** Pointer to unsigned integer which can contain a 32 bits GC pointer. */
982typedef RTGCUINTPTR32 *PRTGCUINTPTR32;
983/** Pointer to unsigned integer which can contain a 32 bits GC pointer. */
984typedef const RTGCUINTPTR32 *PCRTGCUINTPTR32;
985
986/** Unsigned integer which can contain a 64 bits GC pointer. */
987typedef uint64_t RTGCUINTPTR64;
988/** Pointer to unsigned integer which can contain a 32 bits GC pointer. */
989typedef RTGCUINTPTR64 *PRTGCUINTPTR64;
990/** Pointer to unsigned integer which can contain a 32 bits GC pointer. */
991typedef const RTGCUINTPTR64 *PCRTGCUINTPTR64;
992
993/** Guest Physical Memory Address.*/
994typedef uint64_t RTGCPHYS;
995/** Pointer to Guest Physical Memory Address. */
996typedef RTGCPHYS *PRTGCPHYS;
997/** Pointer to const Guest Physical Memory Address. */
998typedef const RTGCPHYS *PCRTGCPHYS;
999/** @def NIL_RTGCPHYS
1000 * NIL GC Physical Address.
1001 * NIL_RTGCPHYS is used to signal an invalid physical address, similar
1002 * to the NULL pointer. Note that this value may actually be valid in
1003 * some contexts.
1004 */
1005#define NIL_RTGCPHYS (~(RTGCPHYS)0U)
1006/** Max guest physical memory address value. */
1007#define RTGCPHYS_MAX UINT64_MAX
1008
1009
1010/** Guest Physical Memory Address; limited to 32 bits.*/
1011typedef uint32_t RTGCPHYS32;
1012/** Pointer to Guest Physical Memory Address. */
1013typedef RTGCPHYS32 *PRTGCPHYS32;
1014/** Pointer to const Guest Physical Memory Address. */
1015typedef const RTGCPHYS32 *PCRTGCPHYS32;
1016/** @def NIL_RTGCPHYS32
1017 * NIL GC Physical Address.
1018 * NIL_RTGCPHYS32 is used to signal an invalid physical address, similar
1019 * to the NULL pointer. Note that this value may actually be valid in
1020 * some contexts.
1021 */
1022#define NIL_RTGCPHYS32 (~(RTGCPHYS32)0)
1023
1024
1025/** Guest Physical Memory Address; limited to 64 bits.*/
1026typedef uint64_t RTGCPHYS64;
1027/** Pointer to Guest Physical Memory Address. */
1028typedef RTGCPHYS64 *PRTGCPHYS64;
1029/** Pointer to const Guest Physical Memory Address. */
1030typedef const RTGCPHYS64 *PCRTGCPHYS64;
1031/** @def NIL_RTGCPHYS64
1032 * NIL GC Physical Address.
1033 * NIL_RTGCPHYS64 is used to signal an invalid physical address, similar
1034 * to the NULL pointer. Note that this value may actually be valid in
1035 * some contexts.
1036 */
1037#define NIL_RTGCPHYS64 (~(RTGCPHYS64)0)
1038
1039/** Guest context pointer, 32 bits.
1040 * Keep in mind that this type is an unsigned integer in
1041 * HC and void pointer in GC.
1042 */
1043typedef RTGCUINTPTR32 RTGCPTR32;
1044/** Pointer to a guest context pointer. */
1045typedef RTGCPTR32 *PRTGCPTR32;
1046/** Pointer to a const guest context pointer. */
1047typedef const RTGCPTR32 *PCRTGCPTR32;
1048/** @def NIL_RTGCPTR32
1049 * NIL GC pointer.
1050 */
1051#define NIL_RTGCPTR32 ((RTGCPTR32)0)
1052
1053/** Guest context pointer, 64 bits.
1054 */
1055typedef RTGCUINTPTR64 RTGCPTR64;
1056/** Pointer to a guest context pointer. */
1057typedef RTGCPTR64 *PRTGCPTR64;
1058/** Pointer to a const guest context pointer. */
1059typedef const RTGCPTR64 *PCRTGCPTR64;
1060/** @def NIL_RTGCPTR64
1061 * NIL GC pointer.
1062 */
1063#define NIL_RTGCPTR64 ((RTGCPTR64)0)
1064
1065/** Guest context pointer.
1066 * Keep in mind that this type is an unsigned integer in
1067 * HC and void pointer in GC.
1068 */
1069#if GC_ARCH_BITS == 64
1070typedef RTGCPTR64 RTGCPTR;
1071/** Pointer to a guest context pointer. */
1072typedef PRTGCPTR64 PRTGCPTR;
1073/** Pointer to a const guest context pointer. */
1074typedef PCRTGCPTR64 PCRTGCPTR;
1075/** @def NIL_RTGCPTR
1076 * NIL GC pointer.
1077 */
1078# define NIL_RTGCPTR NIL_RTGCPTR64
1079/** Max RTGCPTR value. */
1080# define RTGCPTR_MAX UINT64_MAX
1081#elif GC_ARCH_BITS == 32
1082typedef RTGCPTR32 RTGCPTR;
1083/** Pointer to a guest context pointer. */
1084typedef PRTGCPTR32 PRTGCPTR;
1085/** Pointer to a const guest context pointer. */
1086typedef PCRTGCPTR32 PCRTGCPTR;
1087/** @def NIL_RTGCPTR
1088 * NIL GC pointer.
1089 */
1090# define NIL_RTGCPTR NIL_RTGCPTR32
1091/** Max RTGCPTR value. */
1092# define RTGCPTR_MAX UINT32_MAX
1093#else
1094# error "Unsupported GC_ARCH_BITS!"
1095#endif
1096
1097/** Unsigned integer register in the guest context. */
1098typedef uint32_t RTGCUINTREG32;
1099/** Pointer to an unsigned integer register in the guest context. */
1100typedef RTGCUINTREG32 *PRTGCUINTREG32;
1101/** Pointer to a const unsigned integer register in the guest context. */
1102typedef const RTGCUINTREG32 *PCRTGCUINTREG32;
1103
1104typedef uint64_t RTGCUINTREG64;
1105/** Pointer to an unsigned integer register in the guest context. */
1106typedef RTGCUINTREG64 *PRTGCUINTREG64;
1107/** Pointer to a const unsigned integer register in the guest context. */
1108typedef const RTGCUINTREG64 *PCRTGCUINTREG64;
1109
1110#if GC_ARCH_BITS == 64
1111typedef RTGCUINTREG64 RTGCUINTREG;
1112#elif GC_ARCH_BITS == 32
1113typedef RTGCUINTREG32 RTGCUINTREG;
1114#else
1115# error "Unsupported GC_ARCH_BITS!"
1116#endif
1117/** Pointer to an unsigned integer register in the guest context. */
1118typedef RTGCUINTREG *PRTGCUINTREG;
1119/** Pointer to a const unsigned integer register in the guest context. */
1120typedef const RTGCUINTREG *PCRTGCUINTREG;
1121
1122/** @} */
1123
1124/** @defgroup grp_rt_types_rc Raw mode Context Basic Types
1125 * @ingroup grp_rt_types
1126 * @{
1127 */
1128
1129/** Raw mode context pointer; a 32 bits guest context pointer.
1130 * Keep in mind that this type is an unsigned integer in
1131 * HC and void pointer in RC.
1132 */
1133#ifdef IN_RC
1134typedef void * RTRCPTR;
1135#else
1136typedef uint32_t RTRCPTR;
1137#endif
1138/** Pointer to a raw mode context pointer. */
1139typedef RTRCPTR *PRTRCPTR;
1140/** Pointer to a const raw mode context pointer. */
1141typedef const RTRCPTR *PCRTRCPTR;
1142/** @def NIL_RTGCPTR
1143 * NIL RC pointer.
1144 */
1145#define NIL_RTRCPTR ((RTRCPTR)0)
1146/** @def RTRCPTR_MAX
1147 * The maximum value a RTRCPTR can have. Mostly used as INVALID value.
1148 */
1149#define RTRCPTR_MAX ((RTRCPTR)UINT32_MAX)
1150
1151/** Raw mode context pointer, unsigned integer variant. */
1152typedef int32_t RTRCINTPTR;
1153/** @def RTRCUINTPTR_MAX
1154 * The maximum value a RTRCUINPTR can have.
1155 */
1156#define RTRCUINTPTR_MAX ((RTRCUINTPTR)UINT32_MAX)
1157
1158/** Raw mode context pointer, signed integer variant. */
1159typedef uint32_t RTRCUINTPTR;
1160/** @def RTRCINTPTR_MIN
1161 * The minimum value a RTRCINPTR can have.
1162 */
1163#define RTRCINTPTR_MIN ((RTRCINTPTR)INT32_MIN)
1164/** @def RTRCINTPTR_MAX
1165 * The maximum value a RTRCINPTR can have.
1166 */
1167#define RTRCINTPTR_MAX ((RTRCINTPTR)INT32_MAX)
1168
1169/** @} */
1170
1171
1172/** @defgroup grp_rt_types_cc Current Context Basic Types
1173 * @ingroup grp_rt_types
1174 * @{
1175 */
1176
1177/** Current Context Physical Memory Address.*/
1178#ifdef IN_RC
1179typedef RTGCPHYS RTCCPHYS;
1180#else
1181typedef RTHCPHYS RTCCPHYS;
1182#endif
1183/** Pointer to Current Context Physical Memory Address. */
1184typedef RTCCPHYS *PRTCCPHYS;
1185/** Pointer to const Current Context Physical Memory Address. */
1186typedef const RTCCPHYS *PCRTCCPHYS;
1187/** @def NIL_RTCCPHYS
1188 * NIL CC Physical Address.
1189 * NIL_RTCCPHYS is used to signal an invalid physical address, similar
1190 * to the NULL pointer.
1191 */
1192#ifdef IN_RC
1193# define NIL_RTCCPHYS NIL_RTGCPHYS
1194#else
1195# define NIL_RTCCPHYS NIL_RTHCPHYS
1196#endif
1197
1198/** Unsigned integer register in the current context. */
1199#if ARCH_BITS == 32
1200typedef uint32_t RTCCUINTREG;
1201#elif ARCH_BITS == 64
1202typedef uint64_t RTCCUINTREG;
1203#else
1204# error "Unsupported ARCH_BITS!"
1205#endif
1206/** Pointer to an unsigned integer register in the current context. */
1207typedef RTCCUINTREG *PRTCCUINTREG;
1208/** Pointer to a const unsigned integer register in the current context. */
1209typedef RTCCUINTREG const *PCRTCCUINTREG;
1210
1211/** Signed integer register in the current context. */
1212#if ARCH_BITS == 32
1213typedef int32_t RTCCINTREG;
1214#elif ARCH_BITS == 64
1215typedef int64_t RTCCINTREG;
1216#endif
1217/** Pointer to a signed integer register in the current context. */
1218typedef RTCCINTREG *PRTCCINTREG;
1219/** Pointer to a const signed integer register in the current context. */
1220typedef RTCCINTREG const *PCRTCCINTREG;
1221
1222/** @} */
1223
1224
1225/** Pointer to a critical section. */
1226typedef struct RTCRITSECT *PRTCRITSECT;
1227/** Pointer to a const critical section. */
1228typedef const struct RTCRITSECT *PCRTCRITSECT;
1229
1230
1231/** Condition variable handle. */
1232typedef R3PTRTYPE(struct RTCONDVARINTERNAL *) RTCONDVAR;
1233/** Pointer to a condition variable handle. */
1234typedef RTCONDVAR *PRTCONDVAR;
1235/** Nil condition variable handle. */
1236#define NIL_RTCONDVAR 0
1237
1238/** File handle. */
1239typedef RTUINT RTFILE;
1240/** Pointer to file handle. */
1241typedef RTFILE *PRTFILE;
1242/** Nil file handle. */
1243#define NIL_RTFILE (~(RTFILE)0)
1244
1245/** Async I/O request handle. */
1246typedef R3PTRTYPE(struct RTFILEAIOREQINTERNAL *) RTFILEAIOREQ;
1247/** Pointer to a async I/O request handle. */
1248typedef RTFILEAIOREQ *PRTFILEAIOREQ;
1249/** Nil request handle. */
1250#define NIL_RTFILEAIOREQ 0
1251
1252/** Async I/O completion context handle. */
1253typedef R3PTRTYPE(struct RTFILEAIOCTXINTERNAL *) RTFILEAIOCTX;
1254/** Pointer to a async I/O completion context handle. */
1255typedef RTFILEAIOCTX *PRTFILEAIOCTX;
1256/** Nil context handle. */
1257#define NIL_RTFILEAIOCTX 0
1258
1259/** Loader module handle. */
1260typedef R3PTRTYPE(struct RTLDRMODINTERNAL *) RTLDRMOD;
1261/** Pointer to a loader module handle. */
1262typedef RTLDRMOD *PRTLDRMOD;
1263/** Nil loader module handle. */
1264#define NIL_RTLDRMOD 0
1265
1266/** Lock validator class handle. */
1267typedef R3R0PTRTYPE(struct RTLOCKVALCLASSINT *) RTLOCKVALCLASS;
1268/** Pointer to a lock validator class handle. */
1269typedef RTLOCKVALCLASS *PRTLOCKVALCLASS;
1270/** Nil lock validator class handle. */
1271#define NIL_RTLOCKVALCLASS ((RTLOCKVALCLASS)0)
1272
1273/** Ring-0 memory object handle. */
1274typedef R0PTRTYPE(struct RTR0MEMOBJINTERNAL *) RTR0MEMOBJ;
1275/** Pointer to a Ring-0 memory object handle. */
1276typedef RTR0MEMOBJ *PRTR0MEMOBJ;
1277/** Nil ring-0 memory object handle. */
1278#define NIL_RTR0MEMOBJ 0
1279
1280/** Native thread handle. */
1281typedef RTHCUINTPTR RTNATIVETHREAD;
1282/** Pointer to an native thread handle. */
1283typedef RTNATIVETHREAD *PRTNATIVETHREAD;
1284/** Nil native thread handle. */
1285#define NIL_RTNATIVETHREAD (~(RTNATIVETHREAD)0)
1286
1287/** Pipe handle. */
1288typedef R3R0PTRTYPE(struct RTPIPEINTERNAL *) RTPIPE;
1289/** Pointer to a pipe handle. */
1290typedef RTPIPE *PRTPIPE;
1291/** Nil pipe handle.
1292 * @remarks This is not 0 because of UNIX and OS/2 handle values. Take care! */
1293#define NIL_RTPIPE ((RTPIPE)RTHCUINTPTR_MAX)
1294
1295/** @typedef RTPOLLSET
1296 * Poll set handle. */
1297typedef R3R0PTRTYPE(struct RTPOLLSETINTERNAL *) RTPOLLSET;
1298/** Pointer to a poll set handle. */
1299typedef RTPOLLSET *PRTPOLLSET;
1300/** Nil poll set handle handle. */
1301#define NIL_RTPOLLSET ((RTPOLLSET)0)
1302
1303/** Process identifier. */
1304typedef uint32_t RTPROCESS;
1305/** Pointer to a process identifier. */
1306typedef RTPROCESS *PRTPROCESS;
1307/** Nil process identifier. */
1308#define NIL_RTPROCESS (~(RTPROCESS)0)
1309
1310/** Process ring-0 handle. */
1311typedef RTR0UINTPTR RTR0PROCESS;
1312/** Pointer to a ring-0 process handle. */
1313typedef RTR0PROCESS *PRTR0PROCESS;
1314/** Nil ring-0 process handle. */
1315#define NIL_RTR0PROCESS (~(RTR0PROCESS)0)
1316
1317/** @typedef RTSEMEVENT
1318 * Event Semaphore handle. */
1319typedef R3R0PTRTYPE(struct RTSEMEVENTINTERNAL *) RTSEMEVENT;
1320/** Pointer to an event semaphore handle. */
1321typedef RTSEMEVENT *PRTSEMEVENT;
1322/** Nil event semaphore handle. */
1323#define NIL_RTSEMEVENT 0
1324
1325/** @typedef RTSEMEVENTMULTI
1326 * Event Multiple Release Semaphore handle. */
1327typedef R3R0PTRTYPE(struct RTSEMEVENTMULTIINTERNAL *) RTSEMEVENTMULTI;
1328/** Pointer to an event multiple release semaphore handle. */
1329typedef RTSEMEVENTMULTI *PRTSEMEVENTMULTI;
1330/** Nil multiple release event semaphore handle. */
1331#define NIL_RTSEMEVENTMULTI 0
1332
1333/** @typedef RTSEMFASTMUTEX
1334 * Fast mutex Semaphore handle. */
1335typedef R3R0PTRTYPE(struct RTSEMFASTMUTEXINTERNAL *) RTSEMFASTMUTEX;
1336/** Pointer to a fast mutex semaphore handle. */
1337typedef RTSEMFASTMUTEX *PRTSEMFASTMUTEX;
1338/** Nil fast mutex semaphore handle. */
1339#define NIL_RTSEMFASTMUTEX 0
1340
1341/** @typedef RTSEMMUTEX
1342 * Mutex Semaphore handle. */
1343typedef R3R0PTRTYPE(struct RTSEMMUTEXINTERNAL *) RTSEMMUTEX;
1344/** Pointer to a mutex semaphore handle. */
1345typedef RTSEMMUTEX *PRTSEMMUTEX;
1346/** Nil mutex semaphore handle. */
1347#define NIL_RTSEMMUTEX 0
1348
1349/** @typedef RTSEMSPINMUTEX
1350 * Spinning mutex Semaphore handle. */
1351typedef R3R0PTRTYPE(struct RTSEMSPINMUTEXINTERNAL *) RTSEMSPINMUTEX;
1352/** Pointer to a spinning mutex semaphore handle. */
1353typedef RTSEMSPINMUTEX *PRTSEMSPINMUTEX;
1354/** Nil spinning mutex semaphore handle. */
1355#define NIL_RTSEMSPINMUTEX 0
1356
1357/** @typedef RTSEMRW
1358 * Read/Write Semaphore handle. */
1359typedef R3R0PTRTYPE(struct RTSEMRWINTERNAL *) RTSEMRW;
1360/** Pointer to a read/write semaphore handle. */
1361typedef RTSEMRW *PRTSEMRW;
1362/** Nil read/write semaphore handle. */
1363#define NIL_RTSEMRW 0
1364
1365/** @typedef RTSEMXROADS
1366 * Crossroads semaphore handle. */
1367typedef R3R0PTRTYPE(struct RTSEMXROADSINTERNAL *) RTSEMXROADS;
1368/** Pointer to a crossroads semaphore handle. */
1369typedef RTSEMXROADS *PRTSEMXROADS;
1370/** Nil crossroads semaphore handle. */
1371#define NIL_RTSEMXROADS ((RTSEMXROADS)0)
1372
1373/** Spinlock handle. */
1374typedef R3R0PTRTYPE(struct RTSPINLOCKINTERNAL *) RTSPINLOCK;
1375/** Pointer to a spinlock handle. */
1376typedef RTSPINLOCK *PRTSPINLOCK;
1377/** Nil spinlock handle. */
1378#define NIL_RTSPINLOCK 0
1379
1380/** Socket handle. */
1381typedef R3R0PTRTYPE(struct RTSOCKETINT *) RTSOCKET;
1382/** Pointer to socket handle. */
1383typedef RTSOCKET *PRTSOCKET;
1384/** Nil socket handle. */
1385#define NIL_RTSOCKET ((RTSOCKET)0)
1386
1387/** Pointer to a RTTCPSERVER handle. */
1388typedef struct RTTCPSERVER *PRTTCPSERVER;
1389/** Pointer to a RTTCPSERVER handle. */
1390typedef PRTTCPSERVER *PPRTTCPSERVER;
1391/** Nil RTTCPSERVER handle. */
1392#define NIL_RTTCPSERVER ((PRTTCPSERVER)0)
1393
1394/** Thread handle.*/
1395typedef R3R0PTRTYPE(struct RTTHREADINT *) RTTHREAD;
1396/** Pointer to thread handle. */
1397typedef RTTHREAD *PRTTHREAD;
1398/** Nil thread handle. */
1399#define NIL_RTTHREAD 0
1400
1401/** A TLS index. */
1402typedef RTHCINTPTR RTTLS;
1403/** Pointer to a TLS index. */
1404typedef RTTLS *PRTTLS;
1405/** Pointer to a const TLS index. */
1406typedef RTTLS const *PCRTTLS;
1407/** NIL TLS index value. */
1408#define NIL_RTTLS ((RTTLS)-1)
1409
1410/** Handle to a simple heap. */
1411typedef R3R0PTRTYPE(struct RTHEAPSIMPLEINTERNAL *) RTHEAPSIMPLE;
1412/** Pointer to a handle to a simple heap. */
1413typedef RTHEAPSIMPLE *PRTHEAPSIMPLE;
1414/** NIL simple heap handle. */
1415#define NIL_RTHEAPSIMPLE ((RTHEAPSIMPLE)0)
1416
1417/** Handle to a offset based heap. */
1418typedef R3R0PTRTYPE(struct RTHEAPOFFSETINTERNAL *) RTHEAPOFFSET;
1419/** Pointer to a handle to a offset based heap. */
1420typedef RTHEAPOFFSET *PRTHEAPOFFSET;
1421/** NIL offset based heap handle. */
1422#define NIL_RTHEAPOFFSET ((RTHEAPOFFSET)0)
1423
1424/** Handle to an environment block. */
1425typedef R3PTRTYPE(struct RTENVINTERNAL *) RTENV;
1426/** Pointer to a handle to an environment block. */
1427typedef RTENV *PRTENV;
1428/** NIL simple heap handle. */
1429#define NIL_RTENV ((RTENV)0)
1430
1431/** A CPU identifier.
1432 * @remarks This doesn't have to correspond to the APIC ID (intel/amd). Nor
1433 * does it have to correspond to the bits in the affinity mask, at
1434 * least not until we've sorted out Windows NT. */
1435typedef uint32_t RTCPUID;
1436/** Pointer to a CPU identifier. */
1437typedef RTCPUID *PRTCPUID;
1438/** Pointer to a const CPU identifier. */
1439typedef RTCPUID const *PCRTCPUID;
1440/** Nil CPU Id. */
1441#define NIL_RTCPUID ((RTCPUID)~0)
1442
1443/** A CPU set.
1444 * Treat this as an opaque type and always use RTCpuSet* for manupulating it.
1445 * @remarks Subject to change. */
1446typedef uint64_t RTCPUSET;
1447/** Pointer to a CPU set. */
1448typedef RTCPUSET *PRTCPUSET;
1449/** Pointer to a const CPU set. */
1450typedef RTCPUSET const *PCRTCPUSET;
1451
1452/** A handle table handle. */
1453typedef R3R0PTRTYPE(struct RTHANDLETABLEINT *) RTHANDLETABLE;
1454/** A pointer to a handle table handle. */
1455typedef RTHANDLETABLE *PRTHANDLETABLE;
1456/** @def NIL_RTHANDLETABLE
1457 * NIL handle table handle. */
1458#define NIL_RTHANDLETABLE ((RTHANDLETABLE)0)
1459
1460/** A handle to a low resolution timer. */
1461typedef R3R0PTRTYPE(struct RTTIMERLRINT *) RTTIMERLR;
1462/** A pointer to a low resolution timer handle. */
1463typedef RTTIMERLR *PRTTIMERLR;
1464/** @def NIL_RTTIMERLR
1465 * NIL low resolution timer handle value. */
1466#define NIL_RTTIMERLR ((RTTIMERLR)0)
1467
1468/** Handle to a random number generator. */
1469typedef R3R0PTRTYPE(struct RTRANDINT *) RTRAND;
1470/** Pointer to a random number generator handle. */
1471typedef RTRAND *PRTRAND;
1472/** NIL random number genrator handle value. */
1473#define NIL_RTRAND ((RTRAND)0)
1474
1475/** Debug address space handle. */
1476typedef R3R0PTRTYPE(struct RTDBGASINT *) RTDBGAS;
1477/** Pointer to a debug address space handle. */
1478typedef RTDBGAS *PRTDBGAS;
1479/** NIL debug address space handle. */
1480#define NIL_RTDBGAS ((RTDBGAS)0)
1481
1482/** Debug module handle. */
1483typedef R3R0PTRTYPE(struct RTDBGMODINT *) RTDBGMOD;
1484/** Pointer to a debug module handle. */
1485typedef RTDBGMOD *PRTDBGMOD;
1486/** NIL debug module handle. */
1487#define NIL_RTDBGMOD ((RTDBGMOD)0)
1488
1489/** Memory pool handle. */
1490typedef R3R0PTRTYPE(struct RTMEMPOOLINT *) RTMEMPOOL;
1491/** Pointer to a memory pool handle. */
1492typedef RTMEMPOOL *PRTMEMPOOL;
1493/** NIL memory pool handle. */
1494#define NIL_RTMEMPOOL ((RTMEMPOOL)0)
1495/** The default memory pool handle. */
1496#define RTMEMPOOL_DEFAULT ((RTMEMPOOL)-2)
1497
1498/** String cache handle. */
1499typedef R3R0PTRTYPE(struct RTSTRCACHEINT *) RTSTRCACHE;
1500/** Pointer to a string cache handle. */
1501typedef RTSTRCACHE *PRTSTRCACHE;
1502/** NIL string cache handle. */
1503#define NIL_RTSTRCACHE ((RTSTRCACHE)0)
1504/** The default string cache handle. */
1505#define RTSTRCACHE_DEFAULT ((RTSTRCACHE)-2)
1506
1507
1508/** Virtual Filesystem handle. */
1509typedef struct RTVFSINTERNAL *RTVFS;
1510/** Pointer to a VFS handle. */
1511typedef RTVFS *PRTVFS;
1512/** A NIL VFS handle. */
1513#define NIL_RTVFS ((RTVFS)~(uintptr_t)0)
1514
1515/** Virtual Filesystem base object handle. */
1516typedef struct RTVFSOBJINTERNAL *RTVFSOBJ;
1517/** Pointer to a VFS base object handle. */
1518typedef RTVFSOBJ *PRTVFSOBJ;
1519/** A NIL VFS base object handle. */
1520#define NIL_RTVFSOBJ ((RTVFSOBJ)~(uintptr_t)0)
1521
1522/** Virtual Filesystem directory handle. */
1523typedef struct RTVFSDIRINTERNAL *RTVFSDIR;
1524/** Pointer to a VFS directory handle. */
1525typedef RTVFSDIR *PRTVFSDIR;
1526/** A NIL VFS directory handle. */
1527#define NIL_RTVFSDIR ((RTVFSDIR)~(uintptr_t)0)
1528
1529/** Virtual Filesystem filesystem stream handle. */
1530typedef struct RTVFSFSSTREAMINTERNAL *RTVFSFSSTREAM;
1531/** Pointer to a VFS filesystem stream handle. */
1532typedef RTVFSFSSTREAM *PRTVFSFSSTREAM;
1533/** A NIL VFS filesystem stream handle. */
1534#define NIL_RTVFSFSSTREAM ((RTVFSFSSTREAM)~(uintptr_t)0)
1535
1536/** Virtual Filesystem I/O stream handle. */
1537typedef struct RTVFSIOSTREAMINTERNAL *RTVFSIOSTREAM;
1538/** Pointer to a VFS I/O stream handle. */
1539typedef RTVFSIOSTREAM *PRTVFSIOSTREAM;
1540/** A NIL VFS I/O stream handle. */
1541#define NIL_RTVFSIOSTREAM ((RTVFSIOSTREAM)~(uintptr_t)0)
1542
1543/** Virtual Filesystem file handle. */
1544typedef struct RTVFSFILEINTERNAL *RTVFSFILE;
1545/** Pointer to a VFS file handle. */
1546typedef RTVFSFILE *PRTVFSFILE;
1547/** A NIL VFS file handle. */
1548#define NIL_RTVFSFILE ((RTVFSFILE)~(uintptr_t)0)
1549
1550/** Virtual Filesystem symbolic link handle. */
1551typedef struct RTVFSSYMLINKINTERNAL *RTVFSSYMLINK;
1552/** Pointer to a VFS symbolic link handle. */
1553typedef RTVFSSYMLINK *PRTVFSSYMLINK;
1554/** A NIL VFS symbolic link handle. */
1555#define NIL_RTVFSSYMLINK ((RTVFSSYMLINK)~(uintptr_t)0)
1556
1557
1558/**
1559 * Handle type.
1560 *
1561 * This is usually used together with RTHANDLEUNION.
1562 */
1563typedef enum RTHANDLETYPE
1564{
1565 /** The invalid zero value. */
1566 RTHANDLETYPE_INVALID = 0,
1567 /** File handle. */
1568 RTHANDLETYPE_FILE,
1569 /** Pipe handle */
1570 RTHANDLETYPE_PIPE,
1571 /** Socket handle. */
1572 RTHANDLETYPE_SOCKET,
1573 /** Thread handle. */
1574 RTHANDLETYPE_THREAD,
1575 /** The end of the valid values. */
1576 RTHANDLETYPE_END,
1577 /** The 32-bit type blow up. */
1578 RTHANDLETYPE_32BIT_HACK = 0x7fffffff
1579} RTHANDLETYPE;
1580/** Pointer to a handle type. */
1581typedef RTHANDLETYPE *PRTHANDLETYPE;
1582
1583/**
1584 * Handle union.
1585 *
1586 * This is usually used together with RTHANDLETYPE or as RTHANDLE.
1587 */
1588typedef union RTHANDLEUNION
1589{
1590 RTFILE hFile; /**< File handle. */
1591 RTPIPE hPipe; /**< Pipe handle. */
1592 RTSOCKET hSocket; /**< Socket handle. */
1593 RTTHREAD hThread; /**< Thread handle. */
1594 /** Generic integer handle value.
1595 * Note that RTFILE is not yet pointer sized, so accessing it via this member
1596 * isn't necessarily safe or fully portable. */
1597 RTHCUINTPTR uInt;
1598} RTHANDLEUNION;
1599/** Pointer to a handle union. */
1600typedef RTHANDLEUNION *PRTHANDLEUNION;
1601/** Pointer to a const handle union. */
1602typedef RTHANDLEUNION const *PCRTHANDLEUNION;
1603
1604/**
1605 * Generic handle.
1606 */
1607typedef struct RTHANDLE
1608{
1609 /** The handle type. */
1610 RTHANDLETYPE enmType;
1611 /** The handle value. */
1612 RTHANDLEUNION u;
1613} RTHANDLE;
1614/** Pointer to a generic handle. */
1615typedef RTHANDLE *PRTHANDLE;
1616/** Pointer to a const generic handle. */
1617typedef RTHANDLE const *PCRTHANDLE;
1618
1619
1620/**
1621 * Standard handles.
1622 *
1623 * @remarks These have the correct file descriptor values for unixy systems and
1624 * can be used directly in code specific to those platforms.
1625 */
1626typedef enum RTHANDLESTD
1627{
1628 /** Invalid standard handle. */
1629 RTHANDLESTD_INVALID = -1,
1630 /** The standard input handle. */
1631 RTHANDLESTD_INPUT = 0,
1632 /** The standard output handle. */
1633 RTHANDLESTD_OUTPUT,
1634 /** The standard error handle. */
1635 RTHANDLESTD_ERROR,
1636 /** The typical 32-bit type hack. */
1637 RTHANDLESTD_32BIT_HACK = 0x7fffffff
1638} RTHANDLESTD;
1639
1640
1641/**
1642 * UUID data type.
1643 *
1644 * @note IPRT defines that the first three integers in the @c Gen struct
1645 * interpretation are in little endian representation. This is different to
1646 * many other UUID implementation, and requires conversion if you need to
1647 * achieve consistent results.
1648 */
1649typedef union RTUUID
1650{
1651 /** 8-bit view. */
1652 uint8_t au8[16];
1653 /** 16-bit view. */
1654 uint16_t au16[8];
1655 /** 32-bit view. */
1656 uint32_t au32[4];
1657 /** 64-bit view. */
1658 uint64_t au64[2];
1659 /** The way the UUID is declared by the DCE specification. */
1660 struct
1661 {
1662 uint32_t u32TimeLow;
1663 uint16_t u16TimeMid;
1664 uint16_t u16TimeHiAndVersion;
1665 uint8_t u8ClockSeqHiAndReserved;
1666 uint8_t u8ClockSeqLow;
1667 uint8_t au8Node[6];
1668 } Gen;
1669} RTUUID;
1670/** Pointer to UUID data. */
1671typedef RTUUID *PRTUUID;
1672/** Pointer to readonly UUID data. */
1673typedef const RTUUID *PCRTUUID;
1674
1675/**
1676 * UUID string maximum length.
1677 */
1678#define RTUUID_STR_LENGTH 37
1679
1680
1681/** Compression handle. */
1682typedef struct RTZIPCOMP *PRTZIPCOMP;
1683
1684/** Decompressor handle. */
1685typedef struct RTZIPDECOMP *PRTZIPDECOMP;
1686
1687
1688/**
1689 * Unicode Code Point.
1690 */
1691typedef uint32_t RTUNICP;
1692/** Pointer to an Unicode Code Point. */
1693typedef RTUNICP *PRTUNICP;
1694/** Pointer to an Unicode Code Point. */
1695typedef const RTUNICP *PCRTUNICP;
1696/** Max value a RTUNICP type can hold. */
1697#define RTUNICP_MAX ( ~(RTUNICP)0 )
1698/** Invalid code point.
1699 * This is returned when encountered invalid encodings or invalid
1700 * unicode code points. */
1701#define RTUNICP_INVALID ( UINT32_C(0xfffffffe) )
1702
1703
1704/**
1705 * UTF-16 character.
1706 * @remark wchar_t is not usable since it's compiler defined.
1707 * @remark When we use the term character we're not talking about unicode code point, but
1708 * the basic unit of the string encoding. Thus cwc - count of wide chars - means
1709 * count of RTUTF16; cuc - count of unicode chars - means count of RTUNICP;
1710 * and cch means count of the typedef 'char', which is assumed to be an octet.
1711 */
1712typedef uint16_t RTUTF16;
1713/** Pointer to a UTF-16 character. */
1714typedef RTUTF16 *PRTUTF16;
1715/** Pointer to a const UTF-16 character. */
1716typedef const RTUTF16 *PCRTUTF16;
1717
1718
1719/**
1720 * Wait for ever if we have to.
1721 */
1722#define RT_INDEFINITE_WAIT (~0U)
1723
1724
1725/**
1726 * Generic process callback.
1727 *
1728 * @returns VBox status code. Failure will cancel the operation.
1729 * @param uPercentage The percentage of the operation which has been completed.
1730 * @param pvUser The user specified argument.
1731 */
1732typedef DECLCALLBACK(int) FNRTPROGRESS(unsigned uPrecentage, void *pvUser);
1733/** Pointer to a generic progress callback function, FNRTPROCESS(). */
1734typedef FNRTPROGRESS *PFNRTPROGRESS;
1735
1736
1737/**
1738 * Rectangle data type.
1739 */
1740typedef struct RTRECT
1741{
1742 /** left X coordinate. */
1743 int32_t xLeft;
1744 /** top Y coordinate. */
1745 int32_t yTop;
1746 /** right X coordinate. (exclusive) */
1747 int32_t xRight;
1748 /** bottom Y coordinate. (exclusive) */
1749 int32_t yBottom;
1750} RTRECT;
1751/** Pointer to a rectangle. */
1752typedef RTRECT *PRTRECT;
1753/** Pointer to a const rectangle. */
1754typedef const RTRECT *PCRTRECT;
1755
1756
1757/**
1758 * Ethernet MAC address.
1759 *
1760 * The first 24 bits make up the Organisationally Unique Identifier (OUI),
1761 * where the first bit (little endian) indicates multicast (set) / unicast,
1762 * and the second bit indicates locally (set) / global administered. If all
1763 * bits are set, it's a broadcast.
1764 */
1765typedef union RTMAC
1766{
1767 /** @todo add a bitfield view of this stuff. */
1768 /** 8-bit view. */
1769 uint8_t au8[6];
1770 /** 16-bit view. */
1771 uint16_t au16[3];
1772} RTMAC;
1773/** Pointer to a MAC address. */
1774typedef RTMAC *PRTMAC;
1775/** Pointer to a readonly MAC address. */
1776typedef const RTMAC *PCRTMAC;
1777
1778
1779/** Pointer to a lock validator record.
1780 * The structure definition is found in iprt/lockvalidator.h. */
1781typedef struct RTLOCKVALRECEXCL *PRTLOCKVALRECEXCL;
1782/** Pointer to a lock validator source poisition.
1783 * The structure definition is found in iprt/lockvalidator.h. */
1784typedef struct RTLOCKVALSRCPOS *PRTLOCKVALSRCPOS;
1785/** Pointer to a const lock validator source poisition.
1786 * The structure definition is found in iprt/lockvalidator.h. */
1787typedef struct RTLOCKVALSRCPOS const *PCRTLOCKVALSRCPOS;
1788
1789/** @name Special sub-class values.
1790 * The range 16..UINT32_MAX is available to the user, the range 0..15 is
1791 * reserved for the lock validator. In the user range the locks can only be
1792 * taking in ascending order.
1793 * @{ */
1794/** Invalid value. */
1795#define RTLOCKVAL_SUB_CLASS_INVALID UINT32_C(0)
1796/** Not allowed to be taken with any other locks in the same class.
1797 * This is the recommended value. */
1798#define RTLOCKVAL_SUB_CLASS_NONE UINT32_C(1)
1799/** Any order is allowed within the class. */
1800#define RTLOCKVAL_SUB_CLASS_ANY UINT32_C(2)
1801/** The first user value. */
1802#define RTLOCKVAL_SUB_CLASS_USER UINT32_C(16)
1803/** @} */
1804
1805
1806/**
1807 * Process exit codes.
1808 */
1809typedef enum RTEXITCODE
1810{
1811 /** Success. */
1812 RTEXITCODE_SUCCESS = 0,
1813 /** General failure. */
1814 RTEXITCODE_FAILURE = 1,
1815 /** Invalid arguments. */
1816 RTEXITCODE_SYNTAX = 2,
1817 /** Initialization failure (usually IPRT, but could be used for other
1818 * components as well). */
1819 RTEXITCODE_INIT = 3,
1820 /** Test skipped. */
1821 RTEXITCODE_SKIPPED = 4,
1822 /** The end of valid exit codes. */
1823 RTEXITCODE_END,
1824 /** The usual 32-bit type hack. */
1825 RTEXITCODE_32BIT_HACK = 0x7fffffff
1826} RTEXITCODE;
1827
1828
1829#ifdef __cplusplus
1830/**
1831 * Strict type validation helper class.
1832 *
1833 * See RTErrStrictType and RT_SUCCESS_NP.
1834 */
1835class RTErrStrictType2
1836{
1837protected:
1838 /** The status code. */
1839 int32_t m_rc;
1840
1841public:
1842 /**
1843 * Constructor.
1844 * @param rc IPRT style status code.
1845 */
1846 RTErrStrictType2(int32_t rc) : m_rc(rc)
1847 {
1848 }
1849
1850 /**
1851 * Get the status code.
1852 * @returns IPRT style status code.
1853 */
1854 int32_t getValue() const
1855 {
1856 return m_rc;
1857 }
1858};
1859#endif /* __cplusplus */
1860/** @} */
1861
1862#endif
1863
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