VirtualBox

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

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

vfs: the gunzip stream works, except for some double frees somewhere.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 54.7 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/** i-node number. */
550typedef uint64_t RTINODE;
551/** Pointer to a i-node number. */
552typedef RTINODE *PRTINODE;
553
554/** User id. */
555typedef uint32_t RTUID;
556/** Pointer to a user id. */
557typedef RTUID *PRTUID;
558/** NIL user id.
559 * @todo check this for portability! */
560#define NIL_RTUID (~(RTUID)0);
561
562/** Group id. */
563typedef uint32_t RTGID;
564/** Pointer to a group id. */
565typedef RTGID *PRTGID;
566/** NIL group id.
567 * @todo check this for portability! */
568#define NIL_RTGID (~(RTGID)0);
569
570/** I/O Port. */
571typedef uint16_t RTIOPORT;
572/** Pointer to I/O Port. */
573typedef RTIOPORT *PRTIOPORT;
574/** Pointer to const I/O Port. */
575typedef const RTIOPORT *PCRTIOPORT;
576
577/** Selector. */
578typedef uint16_t RTSEL;
579/** Pointer to selector. */
580typedef RTSEL *PRTSEL;
581/** Pointer to const selector. */
582typedef const RTSEL *PCRTSEL;
583/** Max selector value. */
584#define RTSEL_MAX UINT16_MAX
585
586/** Far 16-bit pointer. */
587#pragma pack(1)
588typedef struct RTFAR16
589{
590 uint16_t off;
591 RTSEL sel;
592} RTFAR16;
593#pragma pack()
594/** Pointer to Far 16-bit pointer. */
595typedef RTFAR16 *PRTFAR16;
596/** Pointer to const Far 16-bit pointer. */
597typedef const RTFAR16 *PCRTFAR16;
598
599/** Far 32-bit pointer. */
600#pragma pack(1)
601typedef struct RTFAR32
602{
603 uint32_t off;
604 RTSEL sel;
605} RTFAR32;
606#pragma pack()
607/** Pointer to Far 32-bit pointer. */
608typedef RTFAR32 *PRTFAR32;
609/** Pointer to const Far 32-bit pointer. */
610typedef const RTFAR32 *PCRTFAR32;
611
612/** Far 64-bit pointer. */
613#pragma pack(1)
614typedef struct RTFAR64
615{
616 uint64_t off;
617 RTSEL sel;
618} RTFAR64;
619#pragma pack()
620/** Pointer to Far 64-bit pointer. */
621typedef RTFAR64 *PRTFAR64;
622/** Pointer to const Far 64-bit pointer. */
623typedef const RTFAR64 *PCRTFAR64;
624
625/** @} */
626
627
628/** @defgroup grp_rt_types_hc Host Context Basic Types
629 * @ingroup grp_rt_types
630 * @{
631 */
632
633/** HC Natural signed integer.
634 * @deprecated silly type. */
635typedef int32_t RTHCINT;
636/** Pointer to HC Natural signed integer.
637 * @deprecated silly type. */
638typedef RTHCINT *PRTHCINT;
639/** Pointer to const HC Natural signed integer.
640 * @deprecated silly type. */
641typedef const RTHCINT *PCRTHCINT;
642
643/** HC Natural unsigned integer.
644 * @deprecated silly type. */
645typedef uint32_t RTHCUINT;
646/** Pointer to HC Natural unsigned integer.
647 * @deprecated silly type. */
648typedef RTHCUINT *PRTHCUINT;
649/** Pointer to const HC Natural unsigned integer.
650 * @deprecated silly type. */
651typedef const RTHCUINT *PCRTHCUINT;
652
653
654/** Signed integer which can contain a HC pointer. */
655#if HC_ARCH_BITS == 32
656typedef int32_t RTHCINTPTR;
657#elif HC_ARCH_BITS == 64
658typedef int64_t RTHCINTPTR;
659#else
660# error Unsupported HC_ARCH_BITS value.
661#endif
662/** Pointer to signed integer which can contain a HC pointer. */
663typedef RTHCINTPTR *PRTHCINTPTR;
664/** Pointer to const signed integer which can contain a HC pointer. */
665typedef const RTHCINTPTR *PCRTHCINTPTR;
666/** Max RTHCINTPTR value. */
667#if HC_ARCH_BITS == 32
668# define RTHCINTPTR_MAX INT32_MAX
669#else
670# define RTHCINTPTR_MAX INT64_MAX
671#endif
672/** Min RTHCINTPTR value. */
673#if HC_ARCH_BITS == 32
674# define RTHCINTPTR_MIN INT32_MIN
675#else
676# define RTHCINTPTR_MIN INT64_MIN
677#endif
678
679/** Signed integer which can contain a HC ring-3 pointer. */
680#if R3_ARCH_BITS == 32
681typedef int32_t RTR3INTPTR;
682#elif R3_ARCH_BITS == 64
683typedef int64_t RTR3INTPTR;
684#else
685# error Unsupported R3_ARCH_BITS value.
686#endif
687/** Pointer to signed integer which can contain a HC ring-3 pointer. */
688typedef RTR3INTPTR *PRTR3INTPTR;
689/** Pointer to const signed integer which can contain a HC ring-3 pointer. */
690typedef const RTR3INTPTR *PCRTR3INTPTR;
691/** Max RTR3INTPTR value. */
692#if R3_ARCH_BITS == 32
693# define RTR3INTPTR_MAX INT32_MAX
694#else
695# define RTR3INTPTR_MAX INT64_MAX
696#endif
697/** Min RTR3INTPTR value. */
698#if R3_ARCH_BITS == 32
699# define RTR3INTPTR_MIN INT32_MIN
700#else
701# define RTR3INTPTR_MIN INT64_MIN
702#endif
703
704/** Signed integer which can contain a HC ring-0 pointer. */
705#if R0_ARCH_BITS == 32
706typedef int32_t RTR0INTPTR;
707#elif R0_ARCH_BITS == 64
708typedef int64_t RTR0INTPTR;
709#else
710# error Unsupported R0_ARCH_BITS value.
711#endif
712/** Pointer to signed integer which can contain a HC ring-0 pointer. */
713typedef RTR0INTPTR *PRTR0INTPTR;
714/** Pointer to const signed integer which can contain a HC ring-0 pointer. */
715typedef const RTR0INTPTR *PCRTR0INTPTR;
716/** Max RTR0INTPTR value. */
717#if R0_ARCH_BITS == 32
718# define RTR0INTPTR_MAX INT32_MAX
719#else
720# define RTR0INTPTR_MAX INT64_MAX
721#endif
722/** Min RTHCINTPTR value. */
723#if R0_ARCH_BITS == 32
724# define RTR0INTPTR_MIN INT32_MIN
725#else
726# define RTR0INTPTR_MIN INT64_MIN
727#endif
728
729
730/** Unsigned integer which can contain a HC pointer. */
731#if HC_ARCH_BITS == 32
732typedef uint32_t RTHCUINTPTR;
733#elif HC_ARCH_BITS == 64
734typedef uint64_t RTHCUINTPTR;
735#else
736# error Unsupported HC_ARCH_BITS value.
737#endif
738/** Pointer to unsigned integer which can contain a HC pointer. */
739typedef RTHCUINTPTR *PRTHCUINTPTR;
740/** Pointer to unsigned integer which can contain a HC pointer. */
741typedef const RTHCUINTPTR *PCRTHCUINTPTR;
742/** Max RTHCUINTTPR value. */
743#if HC_ARCH_BITS == 32
744# define RTHCUINTPTR_MAX UINT32_MAX
745#else
746# define RTHCUINTPTR_MAX UINT64_MAX
747#endif
748
749/** Unsigned integer which can contain a HC ring-3 pointer. */
750#if R3_ARCH_BITS == 32
751typedef uint32_t RTR3UINTPTR;
752#elif R3_ARCH_BITS == 64
753typedef uint64_t RTR3UINTPTR;
754#else
755# error Unsupported R3_ARCH_BITS value.
756#endif
757/** Pointer to unsigned integer which can contain a HC ring-3 pointer. */
758typedef RTR3UINTPTR *PRTR3UINTPTR;
759/** Pointer to unsigned integer which can contain a HC ring-3 pointer. */
760typedef const RTR3UINTPTR *PCRTR3UINTPTR;
761/** Max RTHCUINTTPR value. */
762#if R3_ARCH_BITS == 32
763# define RTR3UINTPTR_MAX UINT32_MAX
764#else
765# define RTR3UINTPTR_MAX UINT64_MAX
766#endif
767
768/** Unsigned integer which can contain a HC ring-0 pointer. */
769#if R0_ARCH_BITS == 32
770typedef uint32_t RTR0UINTPTR;
771#elif R0_ARCH_BITS == 64
772typedef uint64_t RTR0UINTPTR;
773#else
774# error Unsupported R0_ARCH_BITS value.
775#endif
776/** Pointer to unsigned integer which can contain a HC ring-0 pointer. */
777typedef RTR0UINTPTR *PRTR0UINTPTR;
778/** Pointer to unsigned integer which can contain a HC ring-0 pointer. */
779typedef const RTR0UINTPTR *PCRTR0UINTPTR;
780/** Max RTR0UINTTPR value. */
781#if HC_ARCH_BITS == 32
782# define RTR0UINTPTR_MAX UINT32_MAX
783#else
784# define RTR0UINTPTR_MAX UINT64_MAX
785#endif
786
787
788/** Host Physical Memory Address. */
789typedef uint64_t RTHCPHYS;
790/** Pointer to Host Physical Memory Address. */
791typedef RTHCPHYS *PRTHCPHYS;
792/** Pointer to const Host Physical Memory Address. */
793typedef const RTHCPHYS *PCRTHCPHYS;
794/** @def NIL_RTHCPHYS
795 * NIL HC Physical Address.
796 * NIL_RTHCPHYS is used to signal an invalid physical address, similar
797 * to the NULL pointer.
798 */
799#define NIL_RTHCPHYS (~(RTHCPHYS)0)
800/** Max RTHCPHYS value. */
801#define RTHCPHYS_MAX UINT64_MAX
802
803
804/** HC pointer. */
805#ifndef IN_RC
806typedef void * RTHCPTR;
807#else
808typedef RTHCUINTPTR RTHCPTR;
809#endif
810/** Pointer to HC pointer. */
811typedef RTHCPTR *PRTHCPTR;
812/** Pointer to const HC pointer. */
813typedef const RTHCPTR *PCRTHCPTR;
814/** @def NIL_RTHCPTR
815 * NIL HC pointer.
816 */
817#define NIL_RTHCPTR ((RTHCPTR)0)
818/** Max RTHCPTR value. */
819#define RTHCPTR_MAX ((RTHCPTR)RTHCUINTPTR_MAX)
820
821
822/** HC ring-3 pointer. */
823#ifdef IN_RING3
824typedef void * RTR3PTR;
825#else
826typedef RTR3UINTPTR RTR3PTR;
827#endif
828/** Pointer to HC ring-3 pointer. */
829typedef RTR3PTR *PRTR3PTR;
830/** Pointer to const HC ring-3 pointer. */
831typedef const RTR3PTR *PCRTR3PTR;
832/** @def NIL_RTR3PTR
833 * NIL HC ring-3 pointer.
834 */
835#define NIL_RTR3PTR ((RTR3PTR)0)
836/** Max RTR3PTR value. */
837#define RTR3PTR_MAX ((RTR3PTR)RTR3UINTPTR_MAX)
838
839/** HC ring-0 pointer. */
840#ifdef IN_RING0
841typedef void * RTR0PTR;
842#else
843typedef RTR0UINTPTR RTR0PTR;
844#endif
845/** Pointer to HC ring-0 pointer. */
846typedef RTR0PTR *PRTR0PTR;
847/** Pointer to const HC ring-0 pointer. */
848typedef const RTR0PTR *PCRTR0PTR;
849/** @def NIL_RTR0PTR
850 * NIL HC ring-0 pointer.
851 */
852#define NIL_RTR0PTR ((RTR0PTR)0)
853/** Max RTR3PTR value. */
854#define RTR0PTR_MAX ((RTR0PTR)RTR0UINTPTR_MAX)
855
856
857/** Unsigned integer register in the host context. */
858#if HC_ARCH_BITS == 32
859typedef uint32_t RTHCUINTREG;
860#elif HC_ARCH_BITS == 64
861typedef uint64_t RTHCUINTREG;
862#else
863# error "Unsupported HC_ARCH_BITS!"
864#endif
865/** Pointer to an unsigned integer register in the host context. */
866typedef RTHCUINTREG *PRTHCUINTREG;
867/** Pointer to a const unsigned integer register in the host context. */
868typedef const RTHCUINTREG *PCRTHCUINTREG;
869
870/** Unsigned integer register in the host ring-3 context. */
871#if R3_ARCH_BITS == 32
872typedef uint32_t RTR3UINTREG;
873#elif R3_ARCH_BITS == 64
874typedef uint64_t RTR3UINTREG;
875#else
876# error "Unsupported R3_ARCH_BITS!"
877#endif
878/** Pointer to an unsigned integer register in the host ring-3 context. */
879typedef RTR3UINTREG *PRTR3UINTREG;
880/** Pointer to a const unsigned integer register in the host ring-3 context. */
881typedef const RTR3UINTREG *PCRTR3UINTREG;
882
883/** Unsigned integer register in the host ring-3 context. */
884#if R0_ARCH_BITS == 32
885typedef uint32_t RTR0UINTREG;
886#elif R0_ARCH_BITS == 64
887typedef uint64_t RTR0UINTREG;
888#else
889# error "Unsupported R3_ARCH_BITS!"
890#endif
891/** Pointer to an unsigned integer register in the host ring-3 context. */
892typedef RTR0UINTREG *PRTR0UINTREG;
893/** Pointer to a const unsigned integer register in the host ring-3 context. */
894typedef const RTR0UINTREG *PCRTR0UINTREG;
895
896/** @} */
897
898
899/** @defgroup grp_rt_types_gc Guest Context Basic Types
900 * @ingroup grp_rt_types
901 * @{
902 */
903
904/** Natural signed integer in the GC.
905 * @deprecated silly type. */
906#if GC_ARCH_BITS == 32
907typedef int32_t RTGCINT;
908#elif GC_ARCH_BITS == 64 /** @todo this isn't right, natural int is 32-bit, see RTHCINT. */
909typedef int64_t RTGCINT;
910#endif
911/** Pointer to natural signed integer in GC.
912 * @deprecated silly type. */
913typedef RTGCINT *PRTGCINT;
914/** Pointer to const natural signed integer in GC.
915 * @deprecated silly type. */
916typedef const RTGCINT *PCRTGCINT;
917
918/** Natural unsigned integer in the GC.
919 * @deprecated silly type. */
920#if GC_ARCH_BITS == 32
921typedef uint32_t RTGCUINT;
922#elif GC_ARCH_BITS == 64 /** @todo this isn't right, natural int is 32-bit, see RTHCUINT. */
923typedef uint64_t RTGCUINT;
924#endif
925/** Pointer to natural unsigned integer in GC.
926 * @deprecated silly type. */
927typedef RTGCUINT *PRTGCUINT;
928/** Pointer to const natural unsigned integer in GC.
929 * @deprecated silly type. */
930typedef const RTGCUINT *PCRTGCUINT;
931
932/** Signed integer which can contain a GC pointer. */
933#if GC_ARCH_BITS == 32
934typedef int32_t RTGCINTPTR;
935#elif GC_ARCH_BITS == 64
936typedef int64_t RTGCINTPTR;
937#endif
938/** Pointer to signed integer which can contain a GC pointer. */
939typedef RTGCINTPTR *PRTGCINTPTR;
940/** Pointer to const signed integer which can contain a GC pointer. */
941typedef const RTGCINTPTR *PCRTGCINTPTR;
942
943/** Unsigned integer which can contain a GC pointer. */
944#if GC_ARCH_BITS == 32
945typedef uint32_t RTGCUINTPTR;
946#elif GC_ARCH_BITS == 64
947typedef uint64_t RTGCUINTPTR;
948#else
949# error Unsupported GC_ARCH_BITS value.
950#endif
951/** Pointer to unsigned integer which can contain a GC pointer. */
952typedef RTGCUINTPTR *PRTGCUINTPTR;
953/** Pointer to unsigned integer which can contain a GC pointer. */
954typedef const RTGCUINTPTR *PCRTGCUINTPTR;
955
956/** Unsigned integer which can contain a 32 bits GC pointer. */
957typedef uint32_t RTGCUINTPTR32;
958/** Pointer to unsigned integer which can contain a 32 bits GC pointer. */
959typedef RTGCUINTPTR32 *PRTGCUINTPTR32;
960/** Pointer to unsigned integer which can contain a 32 bits GC pointer. */
961typedef const RTGCUINTPTR32 *PCRTGCUINTPTR32;
962
963/** Unsigned integer which can contain a 64 bits GC pointer. */
964typedef uint64_t RTGCUINTPTR64;
965/** Pointer to unsigned integer which can contain a 32 bits GC pointer. */
966typedef RTGCUINTPTR64 *PRTGCUINTPTR64;
967/** Pointer to unsigned integer which can contain a 32 bits GC pointer. */
968typedef const RTGCUINTPTR64 *PCRTGCUINTPTR64;
969
970/** Guest Physical Memory Address.*/
971typedef uint64_t RTGCPHYS;
972/** Pointer to Guest Physical Memory Address. */
973typedef RTGCPHYS *PRTGCPHYS;
974/** Pointer to const Guest Physical Memory Address. */
975typedef const RTGCPHYS *PCRTGCPHYS;
976/** @def NIL_RTGCPHYS
977 * NIL GC Physical Address.
978 * NIL_RTGCPHYS is used to signal an invalid physical address, similar
979 * to the NULL pointer. Note that this value may actually be valid in
980 * some contexts.
981 */
982#define NIL_RTGCPHYS (~(RTGCPHYS)0U)
983/** Max guest physical memory address value. */
984#define RTGCPHYS_MAX UINT64_MAX
985
986
987/** Guest Physical Memory Address; limited to 32 bits.*/
988typedef uint32_t RTGCPHYS32;
989/** Pointer to Guest Physical Memory Address. */
990typedef RTGCPHYS32 *PRTGCPHYS32;
991/** Pointer to const Guest Physical Memory Address. */
992typedef const RTGCPHYS32 *PCRTGCPHYS32;
993/** @def NIL_RTGCPHYS32
994 * NIL GC Physical Address.
995 * NIL_RTGCPHYS32 is used to signal an invalid physical address, similar
996 * to the NULL pointer. Note that this value may actually be valid in
997 * some contexts.
998 */
999#define NIL_RTGCPHYS32 (~(RTGCPHYS32)0)
1000
1001
1002/** Guest Physical Memory Address; limited to 64 bits.*/
1003typedef uint64_t RTGCPHYS64;
1004/** Pointer to Guest Physical Memory Address. */
1005typedef RTGCPHYS64 *PRTGCPHYS64;
1006/** Pointer to const Guest Physical Memory Address. */
1007typedef const RTGCPHYS64 *PCRTGCPHYS64;
1008/** @def NIL_RTGCPHYS64
1009 * NIL GC Physical Address.
1010 * NIL_RTGCPHYS64 is used to signal an invalid physical address, similar
1011 * to the NULL pointer. Note that this value may actually be valid in
1012 * some contexts.
1013 */
1014#define NIL_RTGCPHYS64 (~(RTGCPHYS64)0)
1015
1016/** Guest context pointer, 32 bits.
1017 * Keep in mind that this type is an unsigned integer in
1018 * HC and void pointer in GC.
1019 */
1020typedef RTGCUINTPTR32 RTGCPTR32;
1021/** Pointer to a guest context pointer. */
1022typedef RTGCPTR32 *PRTGCPTR32;
1023/** Pointer to a const guest context pointer. */
1024typedef const RTGCPTR32 *PCRTGCPTR32;
1025/** @def NIL_RTGCPTR32
1026 * NIL GC pointer.
1027 */
1028#define NIL_RTGCPTR32 ((RTGCPTR32)0)
1029
1030/** Guest context pointer, 64 bits.
1031 */
1032typedef RTGCUINTPTR64 RTGCPTR64;
1033/** Pointer to a guest context pointer. */
1034typedef RTGCPTR64 *PRTGCPTR64;
1035/** Pointer to a const guest context pointer. */
1036typedef const RTGCPTR64 *PCRTGCPTR64;
1037/** @def NIL_RTGCPTR64
1038 * NIL GC pointer.
1039 */
1040#define NIL_RTGCPTR64 ((RTGCPTR64)0)
1041
1042/** Guest context pointer.
1043 * Keep in mind that this type is an unsigned integer in
1044 * HC and void pointer in GC.
1045 */
1046#if GC_ARCH_BITS == 64
1047typedef RTGCPTR64 RTGCPTR;
1048/** Pointer to a guest context pointer. */
1049typedef PRTGCPTR64 PRTGCPTR;
1050/** Pointer to a const guest context pointer. */
1051typedef PCRTGCPTR64 PCRTGCPTR;
1052/** @def NIL_RTGCPTR
1053 * NIL GC pointer.
1054 */
1055# define NIL_RTGCPTR NIL_RTGCPTR64
1056/** Max RTGCPTR value. */
1057# define RTGCPTR_MAX UINT64_MAX
1058#elif GC_ARCH_BITS == 32
1059typedef RTGCPTR32 RTGCPTR;
1060/** Pointer to a guest context pointer. */
1061typedef PRTGCPTR32 PRTGCPTR;
1062/** Pointer to a const guest context pointer. */
1063typedef PCRTGCPTR32 PCRTGCPTR;
1064/** @def NIL_RTGCPTR
1065 * NIL GC pointer.
1066 */
1067# define NIL_RTGCPTR NIL_RTGCPTR32
1068/** Max RTGCPTR value. */
1069# define RTGCPTR_MAX UINT32_MAX
1070#else
1071# error "Unsupported GC_ARCH_BITS!"
1072#endif
1073
1074/** Unsigned integer register in the guest context. */
1075typedef uint32_t RTGCUINTREG32;
1076/** Pointer to an unsigned integer register in the guest context. */
1077typedef RTGCUINTREG32 *PRTGCUINTREG32;
1078/** Pointer to a const unsigned integer register in the guest context. */
1079typedef const RTGCUINTREG32 *PCRTGCUINTREG32;
1080
1081typedef uint64_t RTGCUINTREG64;
1082/** Pointer to an unsigned integer register in the guest context. */
1083typedef RTGCUINTREG64 *PRTGCUINTREG64;
1084/** Pointer to a const unsigned integer register in the guest context. */
1085typedef const RTGCUINTREG64 *PCRTGCUINTREG64;
1086
1087#if GC_ARCH_BITS == 64
1088typedef RTGCUINTREG64 RTGCUINTREG;
1089#elif GC_ARCH_BITS == 32
1090typedef RTGCUINTREG32 RTGCUINTREG;
1091#else
1092# error "Unsupported GC_ARCH_BITS!"
1093#endif
1094/** Pointer to an unsigned integer register in the guest context. */
1095typedef RTGCUINTREG *PRTGCUINTREG;
1096/** Pointer to a const unsigned integer register in the guest context. */
1097typedef const RTGCUINTREG *PCRTGCUINTREG;
1098
1099/** @} */
1100
1101/** @defgroup grp_rt_types_rc Raw mode Context Basic Types
1102 * @ingroup grp_rt_types
1103 * @{
1104 */
1105
1106/** Raw mode context pointer; a 32 bits guest context pointer.
1107 * Keep in mind that this type is an unsigned integer in
1108 * HC and void pointer in RC.
1109 */
1110#ifdef IN_RC
1111typedef void * RTRCPTR;
1112#else
1113typedef uint32_t RTRCPTR;
1114#endif
1115/** Pointer to a raw mode context pointer. */
1116typedef RTRCPTR *PRTRCPTR;
1117/** Pointer to a const raw mode context pointer. */
1118typedef const RTRCPTR *PCRTRCPTR;
1119/** @def NIL_RTGCPTR
1120 * NIL RC pointer.
1121 */
1122#define NIL_RTRCPTR ((RTRCPTR)0)
1123/** @def RTRCPTR_MAX
1124 * The maximum value a RTRCPTR can have. Mostly used as INVALID value.
1125 */
1126#define RTRCPTR_MAX ((RTRCPTR)UINT32_MAX)
1127
1128/** Raw mode context pointer, unsigned integer variant. */
1129typedef int32_t RTRCINTPTR;
1130/** @def RTRCUINTPTR_MAX
1131 * The maximum value a RTRCUINPTR can have.
1132 */
1133#define RTRCUINTPTR_MAX ((RTRCUINTPTR)UINT32_MAX)
1134
1135/** Raw mode context pointer, signed integer variant. */
1136typedef uint32_t RTRCUINTPTR;
1137/** @def RTRCINTPTR_MIN
1138 * The minimum value a RTRCINPTR can have.
1139 */
1140#define RTRCINTPTR_MIN ((RTRCINTPTR)INT32_MIN)
1141/** @def RTRCINTPTR_MAX
1142 * The maximum value a RTRCINPTR can have.
1143 */
1144#define RTRCINTPTR_MAX ((RTRCINTPTR)INT32_MAX)
1145
1146/** @} */
1147
1148
1149/** @defgroup grp_rt_types_cc Current Context Basic Types
1150 * @ingroup grp_rt_types
1151 * @{
1152 */
1153
1154/** Current Context Physical Memory Address.*/
1155#ifdef IN_RC
1156typedef RTGCPHYS RTCCPHYS;
1157#else
1158typedef RTHCPHYS RTCCPHYS;
1159#endif
1160/** Pointer to Current Context Physical Memory Address. */
1161typedef RTCCPHYS *PRTCCPHYS;
1162/** Pointer to const Current Context Physical Memory Address. */
1163typedef const RTCCPHYS *PCRTCCPHYS;
1164/** @def NIL_RTCCPHYS
1165 * NIL CC Physical Address.
1166 * NIL_RTCCPHYS is used to signal an invalid physical address, similar
1167 * to the NULL pointer.
1168 */
1169#ifdef IN_RC
1170# define NIL_RTCCPHYS NIL_RTGCPHYS
1171#else
1172# define NIL_RTCCPHYS NIL_RTHCPHYS
1173#endif
1174
1175/** Unsigned integer register in the current context. */
1176#if ARCH_BITS == 32
1177typedef uint32_t RTCCUINTREG;
1178#elif ARCH_BITS == 64
1179typedef uint64_t RTCCUINTREG;
1180#else
1181# error "Unsupported ARCH_BITS!"
1182#endif
1183/** Pointer to an unsigned integer register in the current context. */
1184typedef RTCCUINTREG *PRTCCUINTREG;
1185/** Pointer to a const unsigned integer register in the current context. */
1186typedef RTCCUINTREG const *PCRTCCUINTREG;
1187
1188/** Signed integer register in the current context. */
1189#if ARCH_BITS == 32
1190typedef int32_t RTCCINTREG;
1191#elif ARCH_BITS == 64
1192typedef int64_t RTCCINTREG;
1193#endif
1194/** Pointer to a signed integer register in the current context. */
1195typedef RTCCINTREG *PRTCCINTREG;
1196/** Pointer to a const signed integer register in the current context. */
1197typedef RTCCINTREG const *PCRTCCINTREG;
1198
1199/** @} */
1200
1201
1202/** Pointer to a critical section. */
1203typedef struct RTCRITSECT *PRTCRITSECT;
1204/** Pointer to a const critical section. */
1205typedef const struct RTCRITSECT *PCRTCRITSECT;
1206
1207
1208/** Condition variable handle. */
1209typedef R3PTRTYPE(struct RTCONDVARINTERNAL *) RTCONDVAR;
1210/** Pointer to a condition variable handle. */
1211typedef RTCONDVAR *PRTCONDVAR;
1212/** Nil condition variable handle. */
1213#define NIL_RTCONDVAR 0
1214
1215/** File handle. */
1216typedef RTUINT RTFILE;
1217/** Pointer to file handle. */
1218typedef RTFILE *PRTFILE;
1219/** Nil file handle. */
1220#define NIL_RTFILE (~(RTFILE)0)
1221
1222/** Async I/O request handle. */
1223typedef R3PTRTYPE(struct RTFILEAIOREQINTERNAL *) RTFILEAIOREQ;
1224/** Pointer to a async I/O request handle. */
1225typedef RTFILEAIOREQ *PRTFILEAIOREQ;
1226/** Nil request handle. */
1227#define NIL_RTFILEAIOREQ 0
1228
1229/** Async I/O completion context handle. */
1230typedef R3PTRTYPE(struct RTFILEAIOCTXINTERNAL *) RTFILEAIOCTX;
1231/** Pointer to a async I/O completion context handle. */
1232typedef RTFILEAIOCTX *PRTFILEAIOCTX;
1233/** Nil context handle. */
1234#define NIL_RTFILEAIOCTX 0
1235
1236/** Loader module handle. */
1237typedef R3PTRTYPE(struct RTLDRMODINTERNAL *) RTLDRMOD;
1238/** Pointer to a loader module handle. */
1239typedef RTLDRMOD *PRTLDRMOD;
1240/** Nil loader module handle. */
1241#define NIL_RTLDRMOD 0
1242
1243/** Lock validator class handle. */
1244typedef R3R0PTRTYPE(struct RTLOCKVALCLASSINT *) RTLOCKVALCLASS;
1245/** Pointer to a lock validator class handle. */
1246typedef RTLOCKVALCLASS *PRTLOCKVALCLASS;
1247/** Nil lock validator class handle. */
1248#define NIL_RTLOCKVALCLASS ((RTLOCKVALCLASS)0)
1249
1250/** Ring-0 memory object handle. */
1251typedef R0PTRTYPE(struct RTR0MEMOBJINTERNAL *) RTR0MEMOBJ;
1252/** Pointer to a Ring-0 memory object handle. */
1253typedef RTR0MEMOBJ *PRTR0MEMOBJ;
1254/** Nil ring-0 memory object handle. */
1255#define NIL_RTR0MEMOBJ 0
1256
1257/** Native thread handle. */
1258typedef RTHCUINTPTR RTNATIVETHREAD;
1259/** Pointer to an native thread handle. */
1260typedef RTNATIVETHREAD *PRTNATIVETHREAD;
1261/** Nil native thread handle. */
1262#define NIL_RTNATIVETHREAD (~(RTNATIVETHREAD)0)
1263
1264/** Pipe handle. */
1265typedef R3R0PTRTYPE(struct RTPIPEINTERNAL *) RTPIPE;
1266/** Pointer to a pipe handle. */
1267typedef RTPIPE *PRTPIPE;
1268/** Nil pipe handle.
1269 * @remarks This is not 0 because of UNIX and OS/2 handle values. Take care! */
1270#define NIL_RTPIPE ((RTPIPE)RTHCUINTPTR_MAX)
1271
1272/** @typedef RTPOLLSET
1273 * Poll set handle. */
1274typedef R3R0PTRTYPE(struct RTPOLLSETINTERNAL *) RTPOLLSET;
1275/** Pointer to a poll set handle. */
1276typedef RTPOLLSET *PRTPOLLSET;
1277/** Nil poll set handle handle. */
1278#define NIL_RTPOLLSET ((RTPOLLSET)0)
1279
1280/** Process identifier. */
1281typedef uint32_t RTPROCESS;
1282/** Pointer to a process identifier. */
1283typedef RTPROCESS *PRTPROCESS;
1284/** Nil process identifier. */
1285#define NIL_RTPROCESS (~(RTPROCESS)0)
1286
1287/** Process ring-0 handle. */
1288typedef RTR0UINTPTR RTR0PROCESS;
1289/** Pointer to a ring-0 process handle. */
1290typedef RTR0PROCESS *PRTR0PROCESS;
1291/** Nil ring-0 process handle. */
1292#define NIL_RTR0PROCESS (~(RTR0PROCESS)0)
1293
1294/** @typedef RTSEMEVENT
1295 * Event Semaphore handle. */
1296typedef R3R0PTRTYPE(struct RTSEMEVENTINTERNAL *) RTSEMEVENT;
1297/** Pointer to an event semaphore handle. */
1298typedef RTSEMEVENT *PRTSEMEVENT;
1299/** Nil event semaphore handle. */
1300#define NIL_RTSEMEVENT 0
1301
1302/** @typedef RTSEMEVENTMULTI
1303 * Event Multiple Release Semaphore handle. */
1304typedef R3R0PTRTYPE(struct RTSEMEVENTMULTIINTERNAL *) RTSEMEVENTMULTI;
1305/** Pointer to an event multiple release semaphore handle. */
1306typedef RTSEMEVENTMULTI *PRTSEMEVENTMULTI;
1307/** Nil multiple release event semaphore handle. */
1308#define NIL_RTSEMEVENTMULTI 0
1309
1310/** @typedef RTSEMFASTMUTEX
1311 * Fast mutex Semaphore handle. */
1312typedef R3R0PTRTYPE(struct RTSEMFASTMUTEXINTERNAL *) RTSEMFASTMUTEX;
1313/** Pointer to a fast mutex semaphore handle. */
1314typedef RTSEMFASTMUTEX *PRTSEMFASTMUTEX;
1315/** Nil fast mutex semaphore handle. */
1316#define NIL_RTSEMFASTMUTEX 0
1317
1318/** @typedef RTSEMMUTEX
1319 * Mutex Semaphore handle. */
1320typedef R3R0PTRTYPE(struct RTSEMMUTEXINTERNAL *) RTSEMMUTEX;
1321/** Pointer to a mutex semaphore handle. */
1322typedef RTSEMMUTEX *PRTSEMMUTEX;
1323/** Nil mutex semaphore handle. */
1324#define NIL_RTSEMMUTEX 0
1325
1326/** @typedef RTSEMSPINMUTEX
1327 * Spinning mutex Semaphore handle. */
1328typedef R3R0PTRTYPE(struct RTSEMSPINMUTEXINTERNAL *) RTSEMSPINMUTEX;
1329/** Pointer to a spinning mutex semaphore handle. */
1330typedef RTSEMSPINMUTEX *PRTSEMSPINMUTEX;
1331/** Nil spinning mutex semaphore handle. */
1332#define NIL_RTSEMSPINMUTEX 0
1333
1334/** @typedef RTSEMRW
1335 * Read/Write Semaphore handle. */
1336typedef R3R0PTRTYPE(struct RTSEMRWINTERNAL *) RTSEMRW;
1337/** Pointer to a read/write semaphore handle. */
1338typedef RTSEMRW *PRTSEMRW;
1339/** Nil read/write semaphore handle. */
1340#define NIL_RTSEMRW 0
1341
1342/** @typedef RTSEMXROADS
1343 * Crossroads semaphore handle. */
1344typedef R3R0PTRTYPE(struct RTSEMXROADSINTERNAL *) RTSEMXROADS;
1345/** Pointer to a crossroads semaphore handle. */
1346typedef RTSEMXROADS *PRTSEMXROADS;
1347/** Nil crossroads semaphore handle. */
1348#define NIL_RTSEMXROADS ((RTSEMXROADS)0)
1349
1350/** Spinlock handle. */
1351typedef R3R0PTRTYPE(struct RTSPINLOCKINTERNAL *) RTSPINLOCK;
1352/** Pointer to a spinlock handle. */
1353typedef RTSPINLOCK *PRTSPINLOCK;
1354/** Nil spinlock handle. */
1355#define NIL_RTSPINLOCK 0
1356
1357/** Socket handle. */
1358typedef R3R0PTRTYPE(struct RTSOCKETINT *) RTSOCKET;
1359/** Pointer to socket handle. */
1360typedef RTSOCKET *PRTSOCKET;
1361/** Nil socket handle. */
1362#define NIL_RTSOCKET ((RTSOCKET)0)
1363
1364/** Pointer to a RTTCPSERVER handle. */
1365typedef struct RTTCPSERVER *PRTTCPSERVER;
1366/** Pointer to a RTTCPSERVER handle. */
1367typedef PRTTCPSERVER *PPRTTCPSERVER;
1368/** Nil RTTCPSERVER handle. */
1369#define NIL_RTTCPSERVER ((PRTTCPSERVER)0)
1370
1371/** Thread handle.*/
1372typedef R3R0PTRTYPE(struct RTTHREADINT *) RTTHREAD;
1373/** Pointer to thread handle. */
1374typedef RTTHREAD *PRTTHREAD;
1375/** Nil thread handle. */
1376#define NIL_RTTHREAD 0
1377
1378/** A TLS index. */
1379typedef RTHCINTPTR RTTLS;
1380/** Pointer to a TLS index. */
1381typedef RTTLS *PRTTLS;
1382/** Pointer to a const TLS index. */
1383typedef RTTLS const *PCRTTLS;
1384/** NIL TLS index value. */
1385#define NIL_RTTLS ((RTTLS)-1)
1386
1387/** Handle to a simple heap. */
1388typedef R3R0PTRTYPE(struct RTHEAPSIMPLEINTERNAL *) RTHEAPSIMPLE;
1389/** Pointer to a handle to a simple heap. */
1390typedef RTHEAPSIMPLE *PRTHEAPSIMPLE;
1391/** NIL simple heap handle. */
1392#define NIL_RTHEAPSIMPLE ((RTHEAPSIMPLE)0)
1393
1394/** Handle to a offset based heap. */
1395typedef R3R0PTRTYPE(struct RTHEAPOFFSETINTERNAL *) RTHEAPOFFSET;
1396/** Pointer to a handle to a offset based heap. */
1397typedef RTHEAPOFFSET *PRTHEAPOFFSET;
1398/** NIL offset based heap handle. */
1399#define NIL_RTHEAPOFFSET ((RTHEAPOFFSET)0)
1400
1401/** Handle to an environment block. */
1402typedef R3PTRTYPE(struct RTENVINTERNAL *) RTENV;
1403/** Pointer to a handle to an environment block. */
1404typedef RTENV *PRTENV;
1405/** NIL simple heap handle. */
1406#define NIL_RTENV ((RTENV)0)
1407
1408/** A CPU identifier.
1409 * @remarks This doesn't have to correspond to the APIC ID (intel/amd). Nor
1410 * does it have to correspond to the bits in the affinity mask, at
1411 * least not until we've sorted out Windows NT. */
1412typedef uint32_t RTCPUID;
1413/** Pointer to a CPU identifier. */
1414typedef RTCPUID *PRTCPUID;
1415/** Pointer to a const CPU identifier. */
1416typedef RTCPUID const *PCRTCPUID;
1417/** Nil CPU Id. */
1418#define NIL_RTCPUID ((RTCPUID)~0)
1419
1420/** A CPU set.
1421 * Treat this as an opaque type and always use RTCpuSet* for manupulating it.
1422 * @remarks Subject to change. */
1423typedef uint64_t RTCPUSET;
1424/** Pointer to a CPU set. */
1425typedef RTCPUSET *PRTCPUSET;
1426/** Pointer to a const CPU set. */
1427typedef RTCPUSET const *PCRTCPUSET;
1428
1429/** A handle table handle. */
1430typedef R3R0PTRTYPE(struct RTHANDLETABLEINT *) RTHANDLETABLE;
1431/** A pointer to a handle table handle. */
1432typedef RTHANDLETABLE *PRTHANDLETABLE;
1433/** @def NIL_RTHANDLETABLE
1434 * NIL handle table handle. */
1435#define NIL_RTHANDLETABLE ((RTHANDLETABLE)0)
1436
1437/** A handle to a low resolution timer. */
1438typedef R3R0PTRTYPE(struct RTTIMERLRINT *) RTTIMERLR;
1439/** A pointer to a low resolution timer handle. */
1440typedef RTTIMERLR *PRTTIMERLR;
1441/** @def NIL_RTTIMERLR
1442 * NIL low resolution timer handle value. */
1443#define NIL_RTTIMERLR ((RTTIMERLR)0)
1444
1445/** Handle to a random number generator. */
1446typedef R3R0PTRTYPE(struct RTRANDINT *) RTRAND;
1447/** Pointer to a random number generator handle. */
1448typedef RTRAND *PRTRAND;
1449/** NIL random number genrator handle value. */
1450#define NIL_RTRAND ((RTRAND)0)
1451
1452/** Debug address space handle. */
1453typedef R3R0PTRTYPE(struct RTDBGASINT *) RTDBGAS;
1454/** Pointer to a debug address space handle. */
1455typedef RTDBGAS *PRTDBGAS;
1456/** NIL debug address space handle. */
1457#define NIL_RTDBGAS ((RTDBGAS)0)
1458
1459/** Debug module handle. */
1460typedef R3R0PTRTYPE(struct RTDBGMODINT *) RTDBGMOD;
1461/** Pointer to a debug module handle. */
1462typedef RTDBGMOD *PRTDBGMOD;
1463/** NIL debug module handle. */
1464#define NIL_RTDBGMOD ((RTDBGMOD)0)
1465
1466/** Memory pool handle. */
1467typedef R3R0PTRTYPE(struct RTMEMPOOLINT *) RTMEMPOOL;
1468/** Pointer to a memory pool handle. */
1469typedef RTMEMPOOL *PRTMEMPOOL;
1470/** NIL memory pool handle. */
1471#define NIL_RTMEMPOOL ((RTMEMPOOL)0)
1472/** The default memory pool handle. */
1473#define RTMEMPOOL_DEFAULT ((RTMEMPOOL)-2)
1474
1475/** String cache handle. */
1476typedef R3R0PTRTYPE(struct RTSTRCACHEINT *) RTSTRCACHE;
1477/** Pointer to a string cache handle. */
1478typedef RTSTRCACHE *PRTSTRCACHE;
1479/** NIL string cache handle. */
1480#define NIL_RTSTRCACHE ((RTSTRCACHE)0)
1481/** The default string cache handle. */
1482#define RTSTRCACHE_DEFAULT ((RTSTRCACHE)-2)
1483
1484
1485/** Virtual Filesystem handle. */
1486typedef struct RTVFSINTERNAL *RTVFS;
1487/** Pointer to a VFS handle. */
1488typedef RTVFS *PRTVFS;
1489/** A NIL VFS handle. */
1490#define NIL_RTVFS ((RTVFS)~(uintptr_t)0)
1491
1492/** Virtual Filesystem base object handle. */
1493typedef struct RTVFSOBJINTERNAL *RTVFSOBJ;
1494/** Pointer to a VFS base object handle. */
1495typedef RTVFSOBJ *PRTVFSOBJ;
1496/** A NIL VFS base object handle. */
1497#define NIL_RTVFSOBJ ((RTVFSOBJ)~(uintptr_t)0)
1498
1499/** Virtual Filesystem directory handle. */
1500typedef struct RTVFSDIRINTERNAL *RTVFSDIR;
1501/** Pointer to a VFS directory handle. */
1502typedef RTVFSDIR *PRTVFSDIR;
1503/** A NIL VFS directory handle. */
1504#define NIL_RTVFSDIR ((RTVFSDIR)~(uintptr_t)0)
1505
1506/** Virtual Filesystem filesystem stream handle. */
1507typedef struct RTVFSFSSTREAMINTERNAL *RTVFSFSSTREAM;
1508/** Pointer to a VFS filesystem stream handle. */
1509typedef RTVFSFSSTREAM *PRTVFSFSSTREAM;
1510/** A NIL VFS filesystem stream handle. */
1511#define NIL_RTVFSFSSTREAM ((RTVFSFSSTREAM)~(uintptr_t)0)
1512
1513/** Virtual Filesystem I/O stream handle. */
1514typedef struct RTVFSIOSTREAMINTERNAL *RTVFSIOSTREAM;
1515/** Pointer to a VFS I/O stream handle. */
1516typedef RTVFSIOSTREAM *PRTVFSIOSTREAM;
1517/** A NIL VFS I/O stream handle. */
1518#define NIL_RTVFSIOSTREAM ((RTVFSIOSTREAM)~(uintptr_t)0)
1519
1520/** Virtual Filesystem file handle. */
1521typedef struct RTVFSFILEINTERNAL *RTVFSFILE;
1522/** Pointer to a VFS file handle. */
1523typedef RTVFSFILE *PRTVFSFILE;
1524/** A NIL VFS file handle. */
1525#define NIL_RTVFSFILE ((RTVFSFILE)~(uintptr_t)0)
1526
1527/** Virtual Filesystem symbolic link handle. */
1528typedef struct RTVFSSYMLINKINTERNAL *RTVFSSYMLINK;
1529/** Pointer to a VFS symbolic link handle. */
1530typedef RTVFSSYMLINK *PRTVFSSYMLINK;
1531/** A NIL VFS symbolic link handle. */
1532#define NIL_RTVFSSYMLINK ((RTVFSSYMLINK)~(uintptr_t)0)
1533
1534
1535/**
1536 * Handle type.
1537 *
1538 * This is usually used together with RTHANDLEUNION.
1539 */
1540typedef enum RTHANDLETYPE
1541{
1542 /** The invalid zero value. */
1543 RTHANDLETYPE_INVALID = 0,
1544 /** File handle. */
1545 RTHANDLETYPE_FILE,
1546 /** Pipe handle */
1547 RTHANDLETYPE_PIPE,
1548 /** Socket handle. */
1549 RTHANDLETYPE_SOCKET,
1550 /** Thread handle. */
1551 RTHANDLETYPE_THREAD,
1552 /** The end of the valid values. */
1553 RTHANDLETYPE_END,
1554 /** The 32-bit type blow up. */
1555 RTHANDLETYPE_32BIT_HACK = 0x7fffffff
1556} RTHANDLETYPE;
1557/** Pointer to a handle type. */
1558typedef RTHANDLETYPE *PRTHANDLETYPE;
1559
1560/**
1561 * Handle union.
1562 *
1563 * This is usually used together with RTHANDLETYPE or as RTHANDLE.
1564 */
1565typedef union RTHANDLEUNION
1566{
1567 RTFILE hFile; /**< File handle. */
1568 RTPIPE hPipe; /**< Pipe handle. */
1569 RTSOCKET hSocket; /**< Socket handle. */
1570 RTTHREAD hThread; /**< Thread handle. */
1571 /** Generic integer handle value.
1572 * Note that RTFILE is not yet pointer sized, so accessing it via this member
1573 * isn't necessarily safe or fully portable. */
1574 RTHCUINTPTR uInt;
1575} RTHANDLEUNION;
1576/** Pointer to a handle union. */
1577typedef RTHANDLEUNION *PRTHANDLEUNION;
1578/** Pointer to a const handle union. */
1579typedef RTHANDLEUNION const *PCRTHANDLEUNION;
1580
1581/**
1582 * Generic handle.
1583 */
1584typedef struct RTHANDLE
1585{
1586 /** The handle type. */
1587 RTHANDLETYPE enmType;
1588 /** The handle value. */
1589 RTHANDLEUNION u;
1590} RTHANDLE;
1591/** Pointer to a generic handle. */
1592typedef RTHANDLE *PRTHANDLE;
1593/** Pointer to a const generic handle. */
1594typedef RTHANDLE const *PCRTHANDLE;
1595
1596
1597/**
1598 * Standard handles.
1599 *
1600 * @remarks These have the correct file descriptor values for unixy systems and
1601 * can be used directly in code specific to those platforms.
1602 */
1603typedef enum RTHANDLESTD
1604{
1605 /** Invalid standard handle. */
1606 RTHANDLESTD_INVALID = -1,
1607 /** The standard input handle. */
1608 RTHANDLESTD_INPUT = 0,
1609 /** The standard output handle. */
1610 RTHANDLESTD_OUTPUT,
1611 /** The standard error handle. */
1612 RTHANDLESTD_ERROR,
1613 /** The typical 32-bit type hack. */
1614 RTHANDLESTD_32BIT_HACK = 0x7fffffff
1615} RTHANDLESTD;
1616
1617
1618/**
1619 * UUID data type.
1620 *
1621 * @note IPRT defines that the first three integers in the @c Gen struct
1622 * interpretation are in little endian representation. This is different to
1623 * many other UUID implementation, and requires conversion if you need to
1624 * achieve consistent results.
1625 */
1626typedef union RTUUID
1627{
1628 /** 8-bit view. */
1629 uint8_t au8[16];
1630 /** 16-bit view. */
1631 uint16_t au16[8];
1632 /** 32-bit view. */
1633 uint32_t au32[4];
1634 /** 64-bit view. */
1635 uint64_t au64[2];
1636 /** The way the UUID is declared by the DCE specification. */
1637 struct
1638 {
1639 uint32_t u32TimeLow;
1640 uint16_t u16TimeMid;
1641 uint16_t u16TimeHiAndVersion;
1642 uint8_t u8ClockSeqHiAndReserved;
1643 uint8_t u8ClockSeqLow;
1644 uint8_t au8Node[6];
1645 } Gen;
1646} RTUUID;
1647/** Pointer to UUID data. */
1648typedef RTUUID *PRTUUID;
1649/** Pointer to readonly UUID data. */
1650typedef const RTUUID *PCRTUUID;
1651
1652/**
1653 * UUID string maximum length.
1654 */
1655#define RTUUID_STR_LENGTH 37
1656
1657
1658/** Compression handle. */
1659typedef struct RTZIPCOMP *PRTZIPCOMP;
1660
1661/** Decompressor handle. */
1662typedef struct RTZIPDECOMP *PRTZIPDECOMP;
1663
1664
1665/**
1666 * Unicode Code Point.
1667 */
1668typedef uint32_t RTUNICP;
1669/** Pointer to an Unicode Code Point. */
1670typedef RTUNICP *PRTUNICP;
1671/** Pointer to an Unicode Code Point. */
1672typedef const RTUNICP *PCRTUNICP;
1673/** Max value a RTUNICP type can hold. */
1674#define RTUNICP_MAX ( ~(RTUNICP)0 )
1675/** Invalid code point.
1676 * This is returned when encountered invalid encodings or invalid
1677 * unicode code points. */
1678#define RTUNICP_INVALID ( UINT32_C(0xfffffffe) )
1679
1680
1681/**
1682 * UTF-16 character.
1683 * @remark wchar_t is not usable since it's compiler defined.
1684 * @remark When we use the term character we're not talking about unicode code point, but
1685 * the basic unit of the string encoding. Thus cwc - count of wide chars - means
1686 * count of RTUTF16; cuc - count of unicode chars - means count of RTUNICP;
1687 * and cch means count of the typedef 'char', which is assumed to be an octet.
1688 */
1689typedef uint16_t RTUTF16;
1690/** Pointer to a UTF-16 character. */
1691typedef RTUTF16 *PRTUTF16;
1692/** Pointer to a const UTF-16 character. */
1693typedef const RTUTF16 *PCRTUTF16;
1694
1695
1696/**
1697 * Wait for ever if we have to.
1698 */
1699#define RT_INDEFINITE_WAIT (~0U)
1700
1701
1702/**
1703 * Generic process callback.
1704 *
1705 * @returns VBox status code. Failure will cancel the operation.
1706 * @param uPercentage The percentage of the operation which has been completed.
1707 * @param pvUser The user specified argument.
1708 */
1709typedef DECLCALLBACK(int) FNRTPROGRESS(unsigned uPrecentage, void *pvUser);
1710/** Pointer to a generic progress callback function, FNRTPROCESS(). */
1711typedef FNRTPROGRESS *PFNRTPROGRESS;
1712
1713
1714/**
1715 * Rectangle data type.
1716 */
1717typedef struct RTRECT
1718{
1719 /** left X coordinate. */
1720 int32_t xLeft;
1721 /** top Y coordinate. */
1722 int32_t yTop;
1723 /** right X coordinate. (exclusive) */
1724 int32_t xRight;
1725 /** bottom Y coordinate. (exclusive) */
1726 int32_t yBottom;
1727} RTRECT;
1728/** Pointer to a rectangle. */
1729typedef RTRECT *PRTRECT;
1730/** Pointer to a const rectangle. */
1731typedef const RTRECT *PCRTRECT;
1732
1733
1734/**
1735 * Ethernet MAC address.
1736 *
1737 * The first 24 bits make up the Organisationally Unique Identifier (OUI),
1738 * where the first bit (little endian) indicates multicast (set) / unicast,
1739 * and the second bit indicates locally (set) / global administered. If all
1740 * bits are set, it's a broadcast.
1741 */
1742typedef union RTMAC
1743{
1744 /** @todo add a bitfield view of this stuff. */
1745 /** 8-bit view. */
1746 uint8_t au8[6];
1747 /** 16-bit view. */
1748 uint16_t au16[3];
1749} RTMAC;
1750/** Pointer to a MAC address. */
1751typedef RTMAC *PRTMAC;
1752/** Pointer to a readonly MAC address. */
1753typedef const RTMAC *PCRTMAC;
1754
1755
1756/** Pointer to a lock validator record.
1757 * The structure definition is found in iprt/lockvalidator.h. */
1758typedef struct RTLOCKVALRECEXCL *PRTLOCKVALRECEXCL;
1759/** Pointer to a lock validator source poisition.
1760 * The structure definition is found in iprt/lockvalidator.h. */
1761typedef struct RTLOCKVALSRCPOS *PRTLOCKVALSRCPOS;
1762/** Pointer to a const lock validator source poisition.
1763 * The structure definition is found in iprt/lockvalidator.h. */
1764typedef struct RTLOCKVALSRCPOS const *PCRTLOCKVALSRCPOS;
1765
1766/** @name Special sub-class values.
1767 * The range 16..UINT32_MAX is available to the user, the range 0..15 is
1768 * reserved for the lock validator. In the user range the locks can only be
1769 * taking in ascending order.
1770 * @{ */
1771/** Invalid value. */
1772#define RTLOCKVAL_SUB_CLASS_INVALID UINT32_C(0)
1773/** Not allowed to be taken with any other locks in the same class.
1774 * This is the recommended value. */
1775#define RTLOCKVAL_SUB_CLASS_NONE UINT32_C(1)
1776/** Any order is allowed within the class. */
1777#define RTLOCKVAL_SUB_CLASS_ANY UINT32_C(2)
1778/** The first user value. */
1779#define RTLOCKVAL_SUB_CLASS_USER UINT32_C(16)
1780/** @} */
1781
1782
1783/**
1784 * Process exit codes.
1785 */
1786typedef enum RTEXITCODE
1787{
1788 /** Success. */
1789 RTEXITCODE_SUCCESS = 0,
1790 /** General failure. */
1791 RTEXITCODE_FAILURE = 1,
1792 /** Invalid arguments. */
1793 RTEXITCODE_SYNTAX = 2,
1794 /** Initialization failure (usually IPRT, but could be used for other
1795 * components as well). */
1796 RTEXITCODE_INIT = 3,
1797 /** Test skipped. */
1798 RTEXITCODE_SKIPPED = 4,
1799 /** The end of valid exit codes. */
1800 RTEXITCODE_END,
1801 /** The usual 32-bit type hack. */
1802 RTEXITCODE_32BIT_HACK = 0x7fffffff
1803} RTEXITCODE;
1804
1805
1806#ifdef __cplusplus
1807/**
1808 * Strict type validation helper class.
1809 *
1810 * See RTErrStrictType and RT_SUCCESS_NP.
1811 */
1812class RTErrStrictType2
1813{
1814protected:
1815 /** The status code. */
1816 int32_t m_rc;
1817
1818public:
1819 /**
1820 * Constructor.
1821 * @param rc IPRT style status code.
1822 */
1823 RTErrStrictType2(int32_t rc) : m_rc(rc)
1824 {
1825 }
1826
1827 /**
1828 * Get the status code.
1829 * @returns IPRT style status code.
1830 */
1831 int32_t getValue() const
1832 {
1833 return m_rc;
1834 }
1835};
1836#endif /* __cplusplus */
1837/** @} */
1838
1839#endif
1840
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