VirtualBox

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

Last change on this file since 29567 was 28800, checked in by vboxsync, 15 years ago

Automated rebranding to Oracle copyright/license strings via filemuncher

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