VirtualBox

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

Last change on this file since 25817 was 25704, checked in by vboxsync, 15 years ago

iprt,pdmcritsect: More flexible lock naming, added RTCritSectSetSubClass and made some RTCritSectInitEx.

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