VirtualBox

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

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

reversed top & bottom

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