VirtualBox

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

Last change on this file since 6956 was 6956, checked in by vboxsync, 17 years ago

Moved RTTLS to iprt/types.h (from thread.h)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 29.7 KB
Line 
1/** @file
2 * innotek Portable Runtime - Types.
3 */
4
5/*
6 * Copyright (C) 2006-2007 innotek GmbH
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 has sligtly different offsetof definitions
52 * when compiling in kernel mode. This is just to make GCC keep shut.
53 */
54# ifndef _STDDEF_H_
55# undef offsetof
56# endif
57# include <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_LINUX) && defined(__KERNEL__)
67 /*
68 * Kludge for the linux kernel:
69 * 1. sys/types.h doesn't mix with the kernel.
70 * 2. Starting with 2.6.19, linux/types.h typedefs bool and linux/stddef.h
71 * declares false and true as enum values.
72 * 3. Starting with 2.6.24, linux/types.h typedefs uintptr_t.
73 * We work around these issues here and nowhere else.
74 */
75# include <stddef.h>
76# if defined(__cplusplus)
77 typedef bool _Bool;
78# endif
79# define bool linux_bool
80# define true linux_true
81# define false linux_false
82# define uintptr_t linux_uintptr_t
83# include <linux/autoconf.h>
84# include <linux/types.h>
85# include <linux/stddef.h>
86# undef uintptr_t
87# undef false
88# undef true
89# undef bool
90
91# else
92# include <stddef.h>
93# include <sys/types.h>
94# endif
95
96/* Define any types missing from sys/types.h on windows. */
97# ifdef _MSC_VER
98# undef ssize_t
99 typedef intptr_t ssize_t;
100# endif
101
102#else /* no crt */
103# include <iprt/nocrt/compiler/gcc.h>
104#endif /* no crt */
105
106
107
108/** @defgroup grp_rt_types innotek Portable Runtime Base Types
109 * @{
110 */
111
112/* define wchar_t, we don't wanna include all the wcsstuff to get this. */
113#ifdef _MSC_VER
114# ifndef _WCHAR_T_DEFINED
115 typedef unsigned short wchar_t;
116# define _WCHAR_T_DEFINED
117# endif
118#endif
119#ifdef __GNUC__
120/** @todo wchar_t on GNUC */
121#endif
122
123/*
124 * C doesn't have bool.
125 */
126#ifndef __cplusplus
127# if defined(__GNUC__)
128# if defined(RT_OS_LINUX) && __GNUC__ < 3
129typedef uint8_t bool;
130# else
131# if defined(RT_OS_DARWIN) && defined(_STDBOOL_H)
132# undef bool
133# endif
134typedef _Bool bool;
135# endif
136# else
137typedef unsigned char bool;
138# endif
139# ifndef true
140# define true (1)
141# endif
142# ifndef false
143# define false (0)
144# endif
145#endif
146
147/**
148 * 128-bit unsigned integer.
149 */
150#if defined(__GNUC__) && defined(RT_ARCH_AMD64)
151typedef __uint128_t uint128_t;
152#else
153typedef struct uint128_s
154{
155 uint64_t Lo;
156 uint64_t Hi;
157} uint128_t;
158#endif
159
160
161/**
162 * 128-bit signed integer.
163 */
164#if defined(__GNUC__) && defined(RT_ARCH_AMD64)
165typedef __int128_t int128_t;
166#else
167typedef struct int128_s
168{
169 uint64_t lo;
170 int64_t hi;
171} int128_t;
172#endif
173
174
175/**
176 * 16-bit unsigned interger union.
177 */
178typedef union RTUINT16U
179{
180 /** natural view. */
181 uint16_t u;
182
183 /** 16-bit view. */
184 uint16_t au16[1];
185 /** 8-bit view. */
186 uint8_t au8[4];
187 /** 16-bit hi/lo view. */
188 struct
189 {
190 uint16_t Lo;
191 uint16_t Hi;
192 } s;
193} RTUINT16U;
194/** Pointer to a 16-bit unsigned interger union. */
195typedef RTUINT16U *PRTUINT16U;
196/** Pointer to a const 32-bit unsigned interger union. */
197typedef const RTUINT16U *PCRTUINT16U;
198
199
200/**
201 * 32-bit unsigned interger union.
202 */
203typedef union RTUINT32U
204{
205 /** natural view. */
206 uint32_t u;
207 /** Hi/Low view. */
208 struct
209 {
210 uint16_t Lo;
211 uint16_t Hi;
212 } s;
213 /** Word view. */
214 struct
215 {
216 uint16_t w0;
217 uint16_t w1;
218 } Words;
219
220 /** 32-bit view. */
221 uint32_t au32[1];
222 /** 16-bit view. */
223 uint16_t au16[2];
224 /** 8-bit view. */
225 uint8_t au8[4];
226} RTUINT32U;
227/** Pointer to a 32-bit unsigned interger union. */
228typedef RTUINT32U *PRTUINT32U;
229/** Pointer to a const 32-bit unsigned interger union. */
230typedef const RTUINT32U *PCRTUINT32U;
231
232
233/**
234 * 64-bit unsigned interger union.
235 */
236typedef union RTUINT64U
237{
238 /** Natural view. */
239 uint64_t u;
240 /** Hi/Low view. */
241 struct
242 {
243 uint32_t Lo;
244 uint32_t Hi;
245 } s;
246 /** Double-Word view. */
247 struct
248 {
249 uint32_t dw0;
250 uint32_t dw1;
251 } DWords;
252 /** Word view. */
253 struct
254 {
255 uint16_t w0;
256 uint16_t w1;
257 uint16_t w2;
258 uint16_t w3;
259 } Words;
260
261 /** 64-bit view. */
262 uint64_t au64[1];
263 /** 32-bit view. */
264 uint32_t au32[2];
265 /** 16-bit view. */
266 uint16_t au16[4];
267 /** 8-bit view. */
268 uint8_t au8[8];
269} RTUINT64U;
270/** Pointer to a 64-bit unsigned interger union. */
271typedef RTUINT64U *PRTUINT64U;
272/** Pointer to a const 64-bit unsigned interger union. */
273typedef const RTUINT64U *PCRTUINT64U;
274
275
276/**
277 * 128-bit unsigned interger union.
278 */
279typedef union RTUINT128U
280{
281 /** Natural view.
282 * WARNING! This member depends on compiler supporing 128-bit stuff. */
283 uint128_t u;
284 /** Hi/Low view. */
285 struct
286 {
287 uint64_t Lo;
288 uint64_t Hi;
289 } s;
290 /** Quad-Word view. */
291 struct
292 {
293 uint64_t qw0;
294 uint64_t qw1;
295 } QWords;
296 /** Double-Word view. */
297 struct
298 {
299 uint32_t dw0;
300 uint32_t dw1;
301 uint32_t dw2;
302 uint32_t dw3;
303 } DWords;
304 /** Word view. */
305 struct
306 {
307 uint16_t w0;
308 uint16_t w1;
309 uint16_t w2;
310 uint16_t w3;
311 uint16_t w4;
312 uint16_t w5;
313 uint16_t w6;
314 uint16_t w7;
315 } Words;
316
317 /** 64-bit view. */
318 uint64_t au64[2];
319 /** 32-bit view. */
320 uint32_t au32[4];
321 /** 16-bit view. */
322 uint16_t au16[8];
323 /** 8-bit view. */
324 uint8_t au8[16];
325} RTUINT128U;
326/** Pointer to a 64-bit unsigned interger union. */
327typedef RTUINT128U *PRTUINT128U;
328/** Pointer to a const 64-bit unsigned interger union. */
329typedef const RTUINT128U *PCRTUINT128U;
330
331
332/** Generic function type.
333 * @see PFNRT
334 */
335typedef DECLCALLBACK(void) FNRT(void);
336
337/** Generic function pointer.
338 * With -pedantic, gcc-4 complains when casting a function to a data object, for example
339 *
340 * @code
341 * void foo(void)
342 * {
343 * }
344 *
345 * void *bar = (void *)foo;
346 * @endcode
347 *
348 * The compiler would warn with "ISO C++ forbids casting between pointer-to-function and
349 * pointer-to-object". The purpose of this warning is not to bother the programmer but to
350 * point out that he is probably doing something dangerous, assigning a pointer to executable
351 * code to a data object.
352 */
353typedef FNRT *PFNRT;
354
355
356/** @defgroup grp_rt_types_both Common Guest and Host Context Basic Types
357 * @ingroup grp_rt_types
358 * @{
359 */
360
361/** Signed integer which can contain both GC and HC pointers. */
362#if (HC_ARCH_BITS == 32 && GC_ARCH_BITS == 32)
363typedef int32_t RTINTPTR;
364#elif (HC_ARCH_BITS == 64 || GC_ARCH_BITS == 64)
365typedef int64_t RTINTPTR;
366#else
367# error Unsupported HC_ARCH_BITS and/or GC_ARCH_BITS values.
368#endif
369/** Pointer to signed integer which can contain both GC and HC pointers. */
370typedef RTINTPTR *PRTINTPTR;
371/** Pointer const to signed integer which can contain both GC and HC pointers. */
372typedef const RTINTPTR *PCRTINTPTR;
373
374/** Unsigned integer which can contain both GC and HC pointers. */
375#if (HC_ARCH_BITS == 32 && GC_ARCH_BITS == 32)
376typedef uint32_t RTUINTPTR;
377#elif (HC_ARCH_BITS == 64 || GC_ARCH_BITS == 64)
378typedef uint64_t RTUINTPTR;
379#else
380# error Unsupported HC_ARCH_BITS and/or GC_ARCH_BITS values.
381#endif
382/** Pointer to unsigned integer which can contain both GC and HC pointers. */
383typedef RTUINTPTR *PRTUINTPTR;
384/** Pointer const to unsigned integer which can contain both GC and HC pointers. */
385typedef const RTUINTPTR *PCRTUINTPTR;
386
387/** Signed integer. */
388typedef int32_t RTINT;
389/** Pointer to signed integer. */
390typedef RTINT *PRTINT;
391/** Pointer to const signed integer. */
392typedef const RTINT *PCRTINT;
393
394/** Unsigned integer. */
395typedef uint32_t RTUINT;
396/** Pointer to unsigned integer. */
397typedef RTUINT *PRTUINT;
398/** Pointer to const unsigned integer. */
399typedef const RTUINT *PCRTUINT;
400
401/** A file offset / size (off_t). */
402typedef int64_t RTFOFF;
403/** Pointer to a file offset / size. */
404typedef RTFOFF *PRTFOFF;
405
406/** File mode (see iprt/fs.h). */
407typedef uint32_t RTFMODE;
408/** Pointer to file mode. */
409typedef RTFMODE *PRTFMODE;
410
411/** Device unix number. */
412typedef uint32_t RTDEV;
413/** Pointer to a device unix number. */
414typedef RTDEV *PRTDEV;
415
416/** i-node number. */
417typedef uint64_t RTINODE;
418/** Pointer to a i-node number. */
419typedef RTINODE *PRTINODE;
420
421/** User id. */
422typedef uint32_t RTUID;
423/** Pointer to a user id. */
424typedef RTUID *PRTUID;
425/** NIL user id.
426 * @todo check this for portability! */
427#define NIL_RTUID (~(RTUID)0);
428
429/** Group id. */
430typedef uint32_t RTGID;
431/** Pointer to a group id. */
432typedef RTGID *PRTGID;
433/** NIL group id.
434 * @todo check this for portability! */
435#define NIL_RTGID (~(RTGID)0);
436
437/** I/O Port. */
438typedef uint16_t RTIOPORT;
439/** Pointer to I/O Port. */
440typedef RTIOPORT *PRTIOPORT;
441/** Pointer to const I/O Port. */
442typedef const RTIOPORT *PCRTIOPORT;
443
444/** Selector. */
445typedef uint16_t RTSEL;
446/** Pointer to selector. */
447typedef RTSEL *PRTSEL;
448/** Pointer to const selector. */
449typedef const RTSEL *PCRTSEL;
450
451/** Far 16-bit pointer. */
452#pragma pack(1)
453typedef struct RTFAR16
454{
455 uint16_t off;
456 RTSEL sel;
457} RTFAR16;
458#pragma pack()
459/** Pointer to Far 16-bit pointer. */
460typedef RTFAR16 *PRTFAR16;
461/** Pointer to const Far 16-bit pointer. */
462typedef const RTFAR16 *PCRTFAR16;
463
464/** Far 32-bit pointer. */
465#pragma pack(1)
466typedef struct RTFAR32
467{
468 uint32_t off;
469 RTSEL sel;
470} RTFAR32;
471#pragma pack()
472/** Pointer to Far 32-bit pointer. */
473typedef RTFAR32 *PRTFAR32;
474/** Pointer to const Far 32-bit pointer. */
475typedef const RTFAR32 *PCRTFAR32;
476
477/** Far 64-bit pointer. */
478#pragma pack(1)
479typedef struct RTFAR64
480{
481 uint64_t off;
482 RTSEL sel;
483} RTFAR64;
484#pragma pack()
485/** Pointer to Far 64-bit pointer. */
486typedef RTFAR64 *PRTFAR64;
487/** Pointer to const Far 64-bit pointer. */
488typedef const RTFAR64 *PCRTFAR64;
489
490/** @} */
491
492
493/** @defgroup grp_rt_types_hc Host Context Basic Types
494 * @ingroup grp_rt_types
495 * @{
496 */
497
498/** HC Natural signed integer. */
499typedef int32_t RTHCINT;
500/** Pointer to HC Natural signed integer. */
501typedef RTHCINT *PRTHCINT;
502/** Pointer to const HC Natural signed integer. */
503typedef const RTHCINT *PCRTHCINT;
504
505/** HC Natural unsigned integer. */
506typedef uint32_t RTHCUINT;
507/** Pointer to HC Natural unsigned integer. */
508typedef RTHCUINT *PRTHCUINT;
509/** Pointer to const HC Natural unsigned integer. */
510typedef const RTHCUINT *PCRTHCUINT;
511
512
513/** Signed integer which can contain a HC pointer. */
514#if HC_ARCH_BITS == 32
515typedef int32_t RTHCINTPTR;
516#elif HC_ARCH_BITS == 64
517typedef int64_t RTHCINTPTR;
518#else
519# error Unsupported HC_ARCH_BITS value.
520#endif
521/** Pointer to signed interger which can contain a HC pointer. */
522typedef RTHCINTPTR *PRTHCINTPTR;
523/** Pointer to const signed interger which can contain a HC pointer. */
524typedef const RTHCINTPTR *PCRTHCINTPTR;
525
526/** Signed integer which can contain a HC ring-3 pointer. */
527#if R3_ARCH_BITS == 32
528typedef int32_t RTR3INTPTR;
529#elif R3_ARCH_BITS == 64
530typedef int64_t RTR3INTPTR;
531#else
532# error Unsupported R3_ARCH_BITS value.
533#endif
534/** Pointer to signed interger which can contain a HC ring-3 pointer. */
535typedef RTR3INTPTR *PRTR3INTPTR;
536/** Pointer to const signed interger which can contain a HC ring-3 pointer. */
537typedef const RTR3INTPTR *PCRTR3INTPTR;
538
539/** Signed integer which can contain a HC ring-0 pointer. */
540#if R0_ARCH_BITS == 32
541typedef int32_t RTR0INTPTR;
542#elif R0_ARCH_BITS == 64
543typedef int64_t RTR0INTPTR;
544#else
545# error Unsupported R0_ARCH_BITS value.
546#endif
547/** Pointer to signed interger which can contain a HC ring-0 pointer. */
548typedef RTR0INTPTR *PRTR0INTPTR;
549/** Pointer to const signed interger which can contain a HC ring-0 pointer. */
550typedef const RTR0INTPTR *PCRTR0INTPTR;
551
552
553/** Unsigned integer which can contain a HC pointer. */
554#if HC_ARCH_BITS == 32
555typedef uint32_t RTHCUINTPTR;
556#elif HC_ARCH_BITS == 64
557typedef uint64_t RTHCUINTPTR;
558#else
559# error Unsupported HC_ARCH_BITS value.
560#endif
561/** Pointer to unsigned interger which can contain a HC pointer. */
562typedef RTHCUINTPTR *PRTHCUINTPTR;
563/** Pointer to unsigned interger which can contain a HC pointer. */
564typedef const RTHCUINTPTR *PCRTHCUINTPTR;
565
566/** Unsigned integer which can contain a HC ring-3 pointer. */
567#if R3_ARCH_BITS == 32
568typedef uint32_t RTR3UINTPTR;
569#elif R3_ARCH_BITS == 64
570typedef uint64_t RTR3UINTPTR;
571#else
572# error Unsupported R3_ARCH_BITS value.
573#endif
574/** Pointer to unsigned interger which can contain a HC ring-3 pointer. */
575typedef RTR3UINTPTR *PRTR3UINTPTR;
576/** Pointer to unsigned interger which can contain a HC ring-3 pointer. */
577typedef const RTR3UINTPTR *PCRTR3UINTPTR;
578
579/** Unsigned integer which can contain a HC ring-0 pointer. */
580#if R0_ARCH_BITS == 32
581typedef uint32_t RTR0UINTPTR;
582#elif R0_ARCH_BITS == 64
583typedef uint64_t RTR0UINTPTR;
584#else
585# error Unsupported R0_ARCH_BITS value.
586#endif
587/** Pointer to unsigned interger which can contain a HC ring-0 pointer. */
588typedef RTR0UINTPTR *PRTR0UINTPTR;
589/** Pointer to unsigned interger which can contain a HC ring-0 pointer. */
590typedef const RTR0UINTPTR *PCRTR0UINTPTR;
591
592
593/** Host Physical Memory Address.
594 * @todo This should be configurable at compile time too...
595 */
596typedef uint64_t RTHCPHYS;
597/** Pointer to Host Physical Memory Address. */
598typedef RTHCPHYS *PRTHCPHYS;
599/** Pointer to const Host Physical Memory Address. */
600typedef const RTHCPHYS *PCRTHCPHYS;
601/** @def NIL_RTHCPHYS
602 * NIL HC Physical Address.
603 * NIL_RTHCPHYS is used to signal an invalid physical address, similar
604 * to the NULL pointer.
605 */
606#define NIL_RTHCPHYS ((RTHCPHYS)~0U) /** @todo change this to (~(VBOXHCPHYS)0) */
607
608
609/** HC pointer. */
610#ifndef IN_GC
611typedef void * RTHCPTR;
612#else
613typedef RTHCUINTPTR RTHCPTR;
614#endif
615/** Pointer to HC pointer. */
616typedef RTHCPTR *PRTHCPTR;
617/** Pointer to const HC pointer. */
618typedef const RTHCPTR *PCRTHCPTR;
619/** @def NIL_RTHCPTR
620 * NIL HC pointer.
621 */
622#define NIL_RTHCPTR ((RTHCPTR)0)
623
624/** HC ring-3 pointer. */
625#ifdef IN_RING3
626typedef void * RTR3PTR;
627#else
628typedef RTR3UINTPTR RTR3PTR;
629#endif
630/** Pointer to HC ring-3 pointer. */
631typedef RTR3PTR *PRTR3PTR;
632/** Pointer to const HC ring-3 pointer. */
633typedef const RTR3PTR *PCRTR3PTR;
634/** @def NIL_RTR3PTR
635 * NIL HC ring-3 pointer.
636 */
637#define NIL_RTR3PTR ((RTR3PTR)0)
638
639/** HC ring-0 pointer. */
640#ifdef IN_RING0
641typedef void * RTR0PTR;
642#else
643typedef RTR0UINTPTR RTR0PTR;
644#endif
645/** Pointer to HC ring-0 pointer. */
646typedef RTR0PTR *PRTR0PTR;
647/** Pointer to const HC ring-0 pointer. */
648typedef const RTR0PTR *PCRTR0PTR;
649/** @def NIL_RTR0PTR
650 * NIL HC ring-0 pointer.
651 */
652#define NIL_RTR0PTR ((RTR0PTR)0)
653
654
655/** Unsigned integer register in the host context. */
656#if HC_ARCH_BITS == 32
657typedef uint32_t RTHCUINTREG;
658#elif HC_ARCH_BITS == 64
659typedef uint64_t RTHCUINTREG;
660#else
661# error "Unsupported HC_ARCH_BITS!"
662#endif
663/** Pointer to an unsigned integer register in the host context. */
664typedef RTHCUINTREG *PRTHCUINTREG;
665/** Pointer to a const unsigned integer register in the host context. */
666typedef const RTHCUINTREG *PCRTHCUINTREG;
667
668/** Unsigned integer register in the host ring-3 context. */
669#if R3_ARCH_BITS == 32
670typedef uint32_t RTR3UINTREG;
671#elif R3_ARCH_BITS == 64
672typedef uint64_t RTR3UINTREG;
673#else
674# error "Unsupported R3_ARCH_BITS!"
675#endif
676/** Pointer to an unsigned integer register in the host ring-3 context. */
677typedef RTR3UINTREG *PRTR3UINTREG;
678/** Pointer to a const unsigned integer register in the host ring-3 context. */
679typedef const RTR3UINTREG *PCRTR3UINTREG;
680
681/** Unsigned integer register in the host ring-3 context. */
682#if R0_ARCH_BITS == 32
683typedef uint32_t RTR0UINTREG;
684#elif R0_ARCH_BITS == 64
685typedef uint64_t RTR0UINTREG;
686#else
687# error "Unsupported R3_ARCH_BITS!"
688#endif
689/** Pointer to an unsigned integer register in the host ring-3 context. */
690typedef RTR0UINTREG *PRTR0UINTREG;
691/** Pointer to a const unsigned integer register in the host ring-3 context. */
692typedef const RTR0UINTREG *PCRTR0UINTREG;
693
694/** @} */
695
696
697/** @defgroup grp_rt_types_gc Guest Context Basic Types
698 * @ingroup grp_rt_types
699 * @{
700 */
701
702/** Natural signed integer in the GC. */
703typedef int32_t RTGCINT;
704/** Pointer to natural signed interger in GC. */
705typedef RTGCINT *PRTGCINT;
706/** Pointer to const natural signed interger in GC. */
707typedef const RTGCINT *PCRTGCINT;
708
709/** Natural signed uninteger in the GC. */
710typedef uint32_t RTGCUINT;
711/** Pointer to natural unsigned interger in GC. */
712typedef RTGCUINT *PRTGCUINT;
713/** Pointer to const natural unsigned interger in GC. */
714typedef const RTGCUINT *PCRTGCUINT;
715
716/** Signed integer which can contain a GC pointer. */
717#if GC_ARCH_BITS == 32
718typedef int32_t RTGCINTPTR;
719#elif GC_ARCH_BITS == 64
720typedef int64_t RTGCINTPTR;
721#else
722# error Unsupported GC_ARCH_BITS value.
723#endif
724/** Pointer to signed interger which can contain a GC pointer. */
725typedef RTGCINTPTR *PRTGCINTPTR;
726/** Pointer to const signed interger which can contain a GC pointer. */
727typedef const RTGCINTPTR *PCRTGCINTPTR;
728
729/** Unsigned integer which can contain a GC pointer. */
730#if GC_ARCH_BITS == 32
731typedef uint32_t RTGCUINTPTR;
732#elif GC_ARCH_BITS == 64
733typedef uint64_t RTGCUINTPTR;
734#else
735# error Unsupported GC_ARCH_BITS value.
736#endif
737/** Pointer to unsigned interger which can contain a GC pointer. */
738typedef RTGCUINTPTR *PRTGCUINTPTR;
739/** Pointer to unsigned interger which can contain a GC pointer. */
740typedef const RTGCUINTPTR *PCRTGCUINTPTR;
741
742/** Guest Physical Memory Address.*/
743typedef RTGCUINTPTR RTGCPHYS;
744/** Pointer to Guest Physical Memory Address. */
745typedef RTGCPHYS *PRTGCPHYS;
746/** Pointer to const Guest Physical Memory Address. */
747typedef const RTGCPHYS *PCRTGCPHYS;
748/** @def NIL_RTGCPHYS
749 * NIL GC Physical Address.
750 * NIL_RTGCPHYS is used to signal an invalid physical address, similar
751 * to the NULL pointer.
752 */
753#define NIL_RTGCPHYS ((RTGCPHYS)~0U) /** @todo change this to (~(RTGCPHYS)0) */
754
755
756/** Guest context pointer.
757 * Keep in mind that this type is an unsigned integer in
758 * HC and void pointer in GC.
759 */
760#ifdef IN_GC
761typedef void *RTGCPTR;
762#else
763typedef RTGCUINTPTR RTGCPTR;
764#endif
765/** Pointer to a guest context pointer. */
766typedef RTGCPTR *PRTGCPTR;
767/** Pointer to a const guest context pointer. */
768typedef const RTGCPTR *PCRTGCPTR;
769/** @def NIL_RTGCPTR
770 * NIL GC pointer.
771 */
772#define NIL_RTGCPTR ((RTGCPTR)0)
773
774
775/** Unsigned integer register in the guest context. */
776#if GC_ARCH_BITS == 32
777typedef uint32_t RTGCUINTREG;
778#elif GC_ARCH_BITS == 64
779typedef uint64_t RTGCUINTREG;
780#else
781# error "Unsupported GC_ARCH_BITS!"
782#endif
783/** Pointer to an unsigned integer register in the guest context. */
784typedef RTGCUINTREG *PRTGCUINTREG;
785/** Pointer to a const unsigned integer register in the guest context. */
786typedef const RTGCUINTREG *PCRTGCUINTREG;
787
788/** @} */
789
790
791/** @defgroup grp_rt_types_cc Current Context Basic Types
792 * @ingroup grp_rt_types
793 * @{
794 */
795
796/** Current Context Physical Memory Address.*/
797#ifdef IN_GC
798typedef RTGCPHYS RTCCPHYS;
799#else
800typedef RTHCPHYS RTCCPHYS;
801#endif
802/** Pointer to Current Context Physical Memory Address. */
803typedef RTCCPHYS *PRTCCPHYS;
804/** Pointer to const Current Context Physical Memory Address. */
805typedef const RTCCPHYS *PCRTCCPHYS;
806/** @def NIL_RTCCPHYS
807 * NIL CC Physical Address.
808 * NIL_RTCCPHYS is used to signal an invalid physical address, similar
809 * to the NULL pointer.
810 */
811#ifdef IN_GC
812# define NIL_RTCCPHYS NIL_RTGCPHYS
813#else
814# define NIL_RTCCPHYS NIL_RTHCPHYS
815#endif
816
817/** Unsigned integer register in the current context. */
818#if ARCH_BITS == 32
819typedef uint32_t RTCCUINTREG;
820#elif ARCH_BITS == 64
821typedef uint64_t RTCCUINTREG;
822#else
823# error "Unsupported ARCH_BITS!"
824#endif
825/** Pointer to an unsigned integer register in the current context. */
826typedef RTCCUINTREG *PRTCCUINTREG;
827/** Pointer to a const unsigned integer register in the current context. */
828typedef const RTCCUINTREG *PCRTCCUINTREG;
829
830/** @deprecated */
831typedef RTCCUINTREG RTUINTREG;
832/** @deprecated */
833typedef RTCCUINTREG *PRTUINTREG;
834/** @deprecated */
835typedef const RTCCUINTREG *PCRTUINTREG;
836
837/** @} */
838
839
840/** File handle. */
841typedef RTUINT RTFILE;
842/** Pointer to file handle. */
843typedef RTFILE *PRTFILE;
844/** Nil file handle. */
845#define NIL_RTFILE (~(RTFILE)0)
846
847/** Loader module handle. */
848typedef R3PTRTYPE(struct RTLDRMODINTERNAL *) RTLDRMOD;
849/** Pointer to a loader module handle. */
850typedef RTLDRMOD *PRTLDRMOD;
851/** Nil loader module handle. */
852#define NIL_RTLDRMOD 0
853
854/** Ring-0 memory object handle. */
855typedef R0PTRTYPE(struct RTR0MEMOBJINTERNAL *) RTR0MEMOBJ;
856/** Pointer to a Ring-0 memory object handle. */
857typedef RTR0MEMOBJ *PRTR0MEMOBJ;
858/** Nil ring-0 memory object handle. */
859#define NIL_RTR0MEMOBJ 0
860
861/** Native thread handle. */
862typedef RTHCUINTPTR RTNATIVETHREAD;
863/** Pointer to an native thread handle. */
864typedef RTNATIVETHREAD *PRTNATIVETHREAD;
865/** Nil native thread handle. */
866#define NIL_RTNATIVETHREAD (~(RTNATIVETHREAD)0)
867
868/** Process identifier. */
869typedef uint32_t RTPROCESS;
870/** Pointer to a process identifier. */
871typedef RTPROCESS *PRTPROCESS;
872/** Nil process identifier. */
873#define NIL_RTPROCESS (~(RTPROCESS)0)
874
875/** Process ring-0 handle. */
876typedef RTR0UINTPTR RTR0PROCESS;
877/** Pointer to a ring-0 process handle. */
878typedef RTR0PROCESS *PRTR0PROCESS;
879/** Nil ring-0 process handle. */
880#define NIL_RTR0PROCESS (~(RTR0PROCESS)0)
881
882/** @typedef RTSEMEVENT
883 * Event Semaphore handle. */
884typedef R3R0PTRTYPE(struct RTSEMEVENTINTERNAL *) RTSEMEVENT;
885/** Pointer to an event semaphore handle. */
886typedef RTSEMEVENT *PRTSEMEVENT;
887/** Nil event semaphore handle. */
888#define NIL_RTSEMEVENT 0
889
890/** @typedef RTSEMEVENTMULTI
891 * Event Multiple Release Semaphore handle. */
892typedef R3R0PTRTYPE(struct RTSEMEVENTMULTIINTERNAL *) RTSEMEVENTMULTI;
893/** Pointer to an event multiple release semaphore handle. */
894typedef RTSEMEVENTMULTI *PRTSEMEVENTMULTI;
895/** Nil multiple release event semaphore handle. */
896#define NIL_RTSEMEVENTMULTI 0
897
898/** @typedef RTSEMFASTMUTEX
899 * Fast mutex Semaphore handle. */
900typedef R3R0PTRTYPE(struct RTSEMFASTMUTEXINTERNAL *) RTSEMFASTMUTEX;
901/** Pointer to a mutex semaphore handle. */
902typedef RTSEMFASTMUTEX *PRTSEMFASTMUTEX;
903/** Nil fast mutex semaphore handle. */
904#define NIL_RTSEMFASTMUTEX 0
905
906/** @typedef RTSEMMUTEX
907 * Mutex Semaphore handle. */
908typedef R3R0PTRTYPE(struct RTSEMMUTEXINTERNAL *) RTSEMMUTEX;
909/** Pointer to a mutex semaphore handle. */
910typedef RTSEMMUTEX *PRTSEMMUTEX;
911/** Nil mutex semaphore handle. */
912#define NIL_RTSEMMUTEX 0
913
914/** @typedef RTSEMRW
915 * Read/Write Semaphore handle. */
916typedef R3R0PTRTYPE(struct RTSEMRWINTERNAL *) RTSEMRW;
917/** Pointer to a read/write semaphore handle. */
918typedef RTSEMRW *PRTSEMRW;
919/** Nil read/write semaphore handle. */
920#define NIL_RTSEMRW 0
921
922/** Spinlock handle. */
923typedef R3R0PTRTYPE(struct RTSPINLOCKINTERNAL *) RTSPINLOCK;
924/** Pointer to a spinlock handle. */
925typedef RTSPINLOCK *PRTSPINLOCK;
926/** Nil spinlock handle. */
927#define NIL_RTSPINLOCK 0
928
929/** Socket handle. */
930typedef int RTSOCKET;
931/** Pointer to socket handle. */
932typedef RTSOCKET *PRTSOCKET;
933/** Nil socket handle. */
934#define NIL_RTSOCKET (~(RTSOCKET)0)
935
936/** Thread handle.*/
937typedef R3R0PTRTYPE(struct RTTHREADINT *) RTTHREAD;
938/** Pointer to thread handle. */
939typedef RTTHREAD *PRTTHREAD;
940/** Nil thread handle. */
941#define NIL_RTTHREAD 0
942
943/** A TLS index. */
944typedef int RTTLS;
945/** Pointer to a TLS index. */
946typedef RTTLS *PRTTLS;
947/** Pointer to a const TLS index. */
948typedef RTTLS const *PCRTTLS;
949/** NIL TLS index value. */
950#define NIL_RTTLS (-1)
951
952/** Handle to a simple heap. */
953typedef R3R0PTRTYPE(struct RTHEAPSIMPLEINTERNAL *) RTHEAPSIMPLE;
954/** Pointer to a handle to a simple heap. */
955typedef RTHEAPSIMPLE *PRTHEAPSIMPLE;
956/** NIL simple heap handle. */
957#define NIL_RTHEAPSIMPLE ((RTHEAPSIMPLE)0)
958
959/** Handle to an environment block. */
960typedef R3PTRTYPE(struct RTENVINTERNAL *) RTENV;
961/** Pointer to a handle to an environment block. */
962typedef RTENV *PRTENV;
963/** NIL simple heap handle. */
964#define NIL_RTENV ((RTENV)0)
965
966
967/**
968 * UUID data type.
969 */
970typedef union RTUUID
971{
972 /** 8-bit view. */
973 uint8_t au8[16];
974 /** 16-bit view. */
975 uint16_t au16[8];
976 /** 32-bit view. */
977 uint32_t au32[4];
978 /** 64-bit view. */
979 uint64_t au64[2];
980 /** The way the UUID is declared by the ext2 guys. */
981 struct
982 {
983 uint32_t u32TimeLow;
984 uint16_t u16TimeMid;
985 uint16_t u16TimeHiAndVersion;
986 uint16_t u16ClockSeq;
987 uint8_t au8Node[6];
988 } Gen;
989 /** @deprecated */
990 unsigned char aUuid[16];
991} RTUUID;
992/** Pointer to UUID data. */
993typedef RTUUID *PRTUUID;
994/** Pointer to readonly UUID data. */
995typedef const RTUUID *PCRTUUID;
996
997/**
998 * UUID string maximum length.
999 */
1000#define RTUUID_STR_LENGTH 37
1001
1002
1003/** Compression handle. */
1004typedef struct RTZIPCOMP *PRTZIPCOMP;
1005
1006/** Decompressor handle. */
1007typedef struct RTZIPDECOMP *PRTZIPDECOMP;
1008
1009
1010/**
1011 * Unicode Code Point.
1012 */
1013typedef uint32_t RTUNICP;
1014/** Pointer to an Unicode Code Point. */
1015typedef RTUNICP *PRTUNICP;
1016/** Pointer to an Unicode Code Point. */
1017typedef const RTUNICP *PCRTUNICP;
1018
1019
1020/**
1021 * UTF-16 character.
1022 * @remark wchar_t is not usable since it's compiler defined.
1023 * @remark When we use the term character we're not talking about unicode code point, but
1024 * the basic unit of the string encoding. Thus cuc - count of unicode chars - means
1025 * count of RTUTF16. And cch means count of the typedef 'char', which is assumed
1026 * to be an octet.
1027 */
1028typedef uint16_t RTUTF16;
1029/** Pointer to a UTF-16 character. */
1030typedef RTUTF16 *PRTUTF16;
1031/** Pointer to a const UTF-16 character. */
1032typedef const RTUTF16 *PCRTUTF16;
1033
1034/**
1035 * UCS-2 character.
1036 * @remark wchar_t is not usable since it's compiler defined.
1037 * @deprecated Use RTUTF16!
1038 */
1039typedef RTUTF16 RTUCS2;
1040/** Pointer to UCS-2 character.
1041 * @deprecated Use PRTUTF16!
1042 */
1043typedef PRTUTF16 PRTUCS2;
1044/** Pointer to const UCS-2 character.
1045 * @deprecated Use PCRTUTF16!
1046 */
1047typedef PCRTUTF16 PCRTUCS2;
1048
1049
1050
1051/**
1052 * Wait for ever if we have to.
1053 */
1054#define RT_INDEFINITE_WAIT (~0U)
1055
1056
1057/**
1058 * Generic process callback.
1059 *
1060 * @returns VBox status code. Failure will cancel the operation.
1061 * @param uPercentage The percentage of the operation which has been completed.
1062 * @param pvUser The user specified argument.
1063 */
1064typedef DECLCALLBACK(int) FNRTPROGRESS(unsigned uPrecentage, void *pvUser);
1065/** Pointer to a generic progress callback function, FNRTPROCESS(). */
1066typedef FNRTPROGRESS *PFNRTPROGRESS;
1067
1068
1069/**
1070 * Rectangle data type.
1071 */
1072typedef struct RTRECT
1073{
1074 /** left X coordinate. */
1075 int32_t xLeft;
1076 /** top Y coordinate. */
1077 int32_t yTop;
1078 /** right X coordinate. (exclusive) */
1079 int32_t xRight;
1080 /** bottom Y coordinate. (exclusive) */
1081 int32_t yBottom;
1082} RTRECT;
1083/** Pointer to a rectangle. */
1084typedef RTRECT *PRTRECT;
1085/** Pointer to a const rectangle. */
1086typedef const RTRECT *PCRTRECT;
1087
1088/** @} */
1089
1090#endif
1091
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