summaryrefslogtreecommitdiffstats
path: root/include/VBox/cdefs.h
blob: d06e51478904462930e8aa90fba7dd753d3346cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
/** @file
 * VirtualBox - Common C and C++ definition.
 */

/*
 * Copyright (C) 2006-2019 Oracle Corporation
 *
 * This file is part of VirtualBox Open Source Edition (OSE), as
 * available from http://www.virtualbox.org. This file is free software;
 * you can redistribute it and/or modify it under the terms of the GNU
 * General Public License (GPL) as published by the Free Software
 * Foundation, in version 2 as it comes in the "COPYING" file of the
 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 *
 * The contents of this file may alternatively be used under the terms
 * of the Common Development and Distribution License Version 1.0
 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
 * VirtualBox OSE distribution, in which case the provisions of the
 * CDDL are applicable instead of those of the GPL.
 *
 * You may elect to license modified versions of this file under the
 * terms and conditions of either the GPL or the CDDL or both.
 */

#ifndef VBOX_INCLUDED_cdefs_h
#define VBOX_INCLUDED_cdefs_h
#ifndef RT_WITHOUT_PRAGMA_ONCE
# pragma once
#endif

#include <iprt/cdefs.h>


/** @defgroup grp_vbox_cdefs    VBox Common Defintions and Macros
 * @{
 */

/** @def VBOX_WITH_STATISTICS
 * When defined all statistics will be included in the build.
 * This is enabled by default in all debug builds.
 */
#ifndef VBOX_WITH_STATISTICS
# ifdef DEBUG
#  define VBOX_WITH_STATISTICS
# endif
#endif

/** @def VBOX_STRICT
 * Alias for RT_STRICT.
 */
#ifdef RT_STRICT
# ifndef VBOX_STRICT
#  define VBOX_STRICT
# endif
#endif

/** @def VBOX_STRICT_GUEST
 * Be strict on guest input.  This can be overriden on the compiler command line
 * or per source file by defining VBOX_NO_STRICT_GUEST.
 *
 * @sa VBox/assert.h and its ASSERT_GUEST_XXXX macros.
 */
#ifndef VBOX_STRICT_GUEST
# ifdef VBOX_STRICT
#  define VBOX_STRICT_GUEST
# endif
#endif
/** @def VBOX_NO_STRICT_GUEST
 * Define to override VBOX_STRICT_GUEST, disabling asserting on guest input. */
#ifdef VBOX_NO_STRICT_GUEST
# undef VBOX_STRICT_GUEST
#endif


/*
 * Shut up DOXYGEN warnings and guide it properly thru the code.
 */
#ifdef DOXYGEN_RUNNING
#define VBOX_WITH_STATISTICS
#define VBOX_STRICT
#define VBOX_STRICT_GUEST
#define VBOX_NO_STRICT_GUEST
#define IN_DBG
#define IN_DIS
#define IN_INTNET_R0
#define IN_INTNET_R3
#define IN_PCIRAW_R0
#define IN_PCIRAW_R3
#define IN_REM_R3
#define IN_SUP_R0
#define IN_SUP_R3
#define IN_SUP_RC
#define IN_SUP_STATIC
#define IN_USBLIB
#define IN_VBOXDDU
#define IN_VMM_RC
#define IN_VMM_R0
#define IN_VMM_R3
#define IN_VMM_STATIC
#endif




/** @def VBOXCALL
 * The standard calling convention for VBOX interfaces.
 */
#define VBOXCALL   RTCALL



/** @def IN_DIS
 * Used to indicate whether we're inside the same link module as the
 * disassembler.
 */
/** @def DISDECL(type)
 * Disassembly export or import declaration.
 * @param   type    The return type of the function declaration.
 */
#if defined(IN_DIS)
# ifdef IN_DIS_STATIC
#  define DISDECL(type)     DECLHIDDEN(type) VBOXCALL
# else
#  define DISDECL(type)     DECLEXPORT(type) VBOXCALL
# endif
#else
# define DISDECL(type)      DECLIMPORT(type) VBOXCALL
#endif



/** @def IN_DBG
 * Used to indicate whether we're inside the same link module as the debugger
 * console, gui, and related things (ring-3).
 */
/** @def DBGDECL(type)
 * Debugger module export or import declaration.
 * Functions declared using this exists only in R3 since the
 * debugger modules is R3 only.
 * @param   type    The return type of the function declaration.
 */
#if defined(IN_DBG_R3) || defined(IN_DBG)
# define DBGDECL(type)      DECLEXPORT(type) VBOXCALL
#else
# define DBGDECL(type)      DECLIMPORT(type) VBOXCALL
#endif



/** @def IN_INTNET_R3
 * Used to indicate whether we're inside the same link module as the Ring-3
 * Internal Networking Service.
 */
/** @def INTNETR3DECL(type)
 * Internal Networking Service export or import declaration.
 * @param   type    The return type of the function declaration.
 */
#ifdef IN_INTNET_R3
# define INTNETR3DECL(type) DECLEXPORT(type) VBOXCALL
#else
# define INTNETR3DECL(type) DECLIMPORT(type) VBOXCALL
#endif

/** @def IN_INTNET_R0
 * Used to indicate whether we're inside the same link module as the R0
 * Internal Network Service.
 */
/** @def INTNETR0DECL(type)
 * Internal Networking Service export or import declaration.
 * @param   type    The return type of the function declaration.
 */
#ifdef IN_INTNET_R0
# define INTNETR0DECL(type) DECLEXPORT(type) VBOXCALL
#else
# define INTNETR0DECL(type) DECLIMPORT(type) VBOXCALL
#endif



/** @def IN_PCIRAW_R3
 * Used to indicate whether we're inside the same link module as the Ring-3
 * PCI passthrough support.
 */
/** @def PCIRAWR3DECL(type)
 * PCI passthrough export or import declaration.
 * @param   type    The return type of the function declaration.
 */
#ifdef IN_PCIRAW_R3
# define PCIRAWR3DECL(type) DECLEXPORT(type) VBOXCALL
#else
# define PCIRAWR3DECL(type) DECLIMPORT(type) VBOXCALL
#endif

/** @def IN_PCIRAW_R0
 * Used to indicate whether we're inside the same link module as the R0
 * PCI passthrough support.
 */
/** @def PCIRAWR0DECL(type)
 * PCI passthroug export or import declaration.
 * @param   type    The return type of the function declaration.
 */
#ifdef IN_PCIRAW_R0
# define PCIRAWR0DECL(type) DECLEXPORT(type) VBOXCALL
#else
# define PCIRAWR0DECL(type) DECLIMPORT(type) VBOXCALL
#endif



/** @def IN_REM_R3
 * Used to indicate whether we're inside the same link module as
 * the HC Ring-3 Recompiled Execution Manager.
 */
/** @def REMR3DECL(type)
 * Recompiled Execution Manager HC Ring-3 export or import declaration.
 * @param   type    The return type of the function declaration.
 */
#ifdef IN_REM_R3
# define REMR3DECL(type)    DECLEXPORT(type) VBOXCALL
#else
# define REMR3DECL(type)    DECLIMPORT(type) VBOXCALL
#endif



/** @def IN_SUP_R3
 * Used to indicate whether we're inside the same link module as the Ring-3
 * Support Library or not.
 */
/** @def SUPR3DECL(type)
 * Support library export or import declaration.
 * @param   type    The return type of the function declaration.
 */
#ifdef IN_SUP_R3
# ifdef IN_SUP_STATIC
#  define SUPR3DECL(type)   DECLHIDDEN(type) VBOXCALL
# else
#  define SUPR3DECL(type)   DECLEXPORT(type) VBOXCALL
# endif
#else
# ifdef IN_SUP_STATIC
#  define SUPR3DECL(type)   DECLHIDDEN(type) VBOXCALL
# else
#  define SUPR3DECL(type)   DECLIMPORT(type) VBOXCALL
# endif
#endif

/** @def IN_SUP_R0
 * Used to indicate whether we're inside the same link module as the Ring-0
 * Support Library or not.
 */
/** @def IN_SUP_STATIC
 * Used to indicate that the Support Library is built or used as a static
 * library.
 */
/** @def SUPR0DECL(type)
 * Support library export or import declaration.
 * @param   type    The return type of the function declaration.
 */
#ifdef IN_SUP_R0
# ifdef IN_SUP_STATIC
#  define SUPR0DECL(type)   DECLHIDDEN(type) VBOXCALL
# else
#  define SUPR0DECL(type)   DECLEXPORT(type) VBOXCALL
# endif
#else
# ifdef IN_SUP_STATIC
#  define SUPR0DECL(type)   DECLHIDDEN(type) VBOXCALL
# else
#  define SUPR0DECL(type)   DECLIMPORT(type) VBOXCALL
# endif
#endif

/** @def IN_SUP_RC
 * Used to indicate whether we're inside the same link module as the RC Support
 * Library or not.
 */
/** @def SUPRCDECL(type)
 * Support library export or import declaration.
 * @param   type    The return type of the function declaration.
 */
#ifdef IN_SUP_RC
# define SUPRCDECL(type)    DECLEXPORT(type) VBOXCALL
#else
# define SUPRCDECL(type)    DECLIMPORT(type) VBOXCALL
#endif

/** @def IN_SUP_R0
 * Used to indicate whether we're inside the same link module as the Ring-0
 * Support Library or not.
 */
/** @def SUPR0DECL(type)
 * Support library export or import declaration.
 * @param   type    The return type of the function declaration.
 */
#if defined(IN_SUP_R0) || defined(IN_SUP_R3) || defined(IN_SUP_RC)
# define SUPDECL(type)      DECLEXPORT(type) VBOXCALL
#else
# define SUPDECL(type)      DECLIMPORT(type) VBOXCALL
#endif



/** @def IN_USBLIB
 * Used to indicate whether we're inside the same link module as the USBLib.
 */
/** @def USBLIB_DECL
 * USBLIB export or import declaration.
 * @param   type    The return type of the function declaration.
 */
#ifdef IN_RING0
# define USBLIB_DECL(type)   type VBOXCALL
#elif defined(IN_USBLIB)
# define USBLIB_DECL(type)   DECLEXPORT(type) VBOXCALL
#else
# define USBLIB_DECL(type)   DECLIMPORT(type) VBOXCALL
#endif



/** @def IN_VMM_STATIC
 * Used to indicate that the virtual machine monitor is built or used as a
 * static library.
 */
/** @def IN_VMM_R3
 * Used to indicate whether we're inside the same link module as the ring 3 part of the
 * virtual machine monitor or not.
 */
/** @def VMMR3DECL
 * Ring-3 VMM export or import declaration.
 * @param   type    The return type of the function declaration.
 */
#ifdef IN_VMM_R3
# ifdef IN_VMM_STATIC
#  define VMMR3DECL(type)           DECLHIDDEN(type) VBOXCALL
# else
#  define VMMR3DECL(type)           DECLEXPORT(type) VBOXCALL
# endif
#elif defined(IN_RING3)
# ifdef IN_VMM_STATIC
#  define VMMR3DECL(type)           DECLHIDDEN(type) VBOXCALL
# else
#  define VMMR3DECL(type)           DECLIMPORT(type) VBOXCALL
# endif
#else
# define VMMR3DECL(type)            DECL_INVALID(type)
#endif

/** @def IN_VMM_R0
 * Used to indicate whether we're inside the same link module as the ring-0 part
 * of the virtual machine monitor or not.
 */
/** @def VMMR0DECL
 * Ring-0 VMM export or import declaration.
 * @param   type    The return type of the function declaration.
 */
#ifdef IN_VMM_R0
# define VMMR0DECL(type)            DECLEXPORT(type) VBOXCALL
#elif defined(IN_RING0)
# define VMMR0DECL(type)            DECLIMPORT(type) VBOXCALL
#else
# define VMMR0DECL(type)            DECL_INVALID(type)
#endif

/** @def IN_VMM_RC
 * Used to indicate whether we're inside the same link module as the raw-mode
 * context part of the virtual machine monitor or not.
 */
/** @def VMMRCDECL
 * Raw-mode context VMM export or import declaration.
 * @param   type    The return type of the function declaration.
 */
#ifdef IN_VMM_RC
# define VMMRCDECL(type)            DECLEXPORT(type) VBOXCALL
#elif defined(IN_RC)
# define VMMRCDECL(type)            DECLIMPORT(type) VBOXCALL
#else
# define VMMRCDECL(type)            DECL_INVALID(type)
#endif

/** @def VMMRZDECL
 * Ring-0 and Raw-mode context VMM export or import declaration.
 * @param   type    The return type of the function declaration.
 */
#if defined(IN_VMM_R0) || defined(IN_VMM_RC)
# define VMMRZDECL(type)            DECLEXPORT(type) VBOXCALL
#elif defined(IN_RING0) || defined(IN_RZ)
# define VMMRZDECL(type)            DECLIMPORT(type) VBOXCALL
#else
# define VMMRZDECL(type)            DECL_INVALID(type)
#endif

/** @def VMMDECL
 * VMM export or import declaration.
 * @param   type    The return type of the function declaration.
 */
#ifdef IN_VMM_STATIC
# define VMMDECL(type)              DECLHIDDEN(type) VBOXCALL
#elif defined(IN_VMM_R3) || defined(IN_VMM_R0) || defined(IN_VMM_RC)
# define VMMDECL(type)              DECLEXPORT(type) VBOXCALL
#else
# define VMMDECL(type)              DECLIMPORT(type) VBOXCALL
#endif

/** @def VMM_INT_DECL
 * VMM internal function.
 * @param   type    The return type of the function declaration.
 */
#if defined(IN_VMM_R3) || defined(IN_VMM_R0) || defined(IN_VMM_RC)
# define VMM_INT_DECL(type)         DECLHIDDEN(type) VBOXCALL
#else
# define VMM_INT_DECL(type)         DECL_INVALID(type)
#endif

/** @def VMMR3_INT_DECL
 * VMM internal function, ring-3.
 * @param   type    The return type of the function declaration.
 */
#ifdef IN_VMM_R3
# define VMMR3_INT_DECL(type)       DECLHIDDEN(type) VBOXCALL
#else
# define VMMR3_INT_DECL(type)       DECL_INVALID(type)
#endif

/** @def VMMR0_INT_DECL
 * VMM internal function, ring-0.
 * @param   type    The return type of the function declaration.
 */
#ifdef IN_VMM_R0
# define VMMR0_INT_DECL(type)       DECLHIDDEN(type) VBOXCALL
#else
# define VMMR0_INT_DECL(type)       DECL_INVALID(type)
#endif

/** @def VMMRC_INT_DECL
 * VMM internal function, raw-mode context.
 * @param   type    The return type of the function declaration.
 */
#ifdef IN_VMM_RC
# define VMMRC_INT_DECL(type)       DECLHIDDEN(type) VBOXCALL
#else
# define VMMRC_INT_DECL(type)       DECL_INVALID(type)
#endif

/** @def VMMRZ_INT_DECL
 * VMM internal function, ring-0 + raw-mode context.
 * @param   type    The return type of the function declaration.
 */
#if defined(IN_VMM_RC) || defined(IN_VMM_R0)
# define VMMRZ_INT_DECL(type)       DECLHIDDEN(type) VBOXCALL
#else
# define VMMRZ_INT_DECL(type)       DECL_INVALID(type)
#endif



/** @def IN_VBOXDDU
 * Used to indicate whether we're inside the VBoxDDU shared object.
 */
/** @def VBOXDDU_DECL(type)
 * VBoxDDU export or import (ring-3).
 * @param   type    The return type of the function declaration.
 */
#ifdef IN_VBOXDDU
# ifdef IN_VBOXDDU_STATIC
#  define VBOXDDU_DECL(type) type
# else
#  define VBOXDDU_DECL(type) DECLEXPORT(type) VBOXCALL
# endif
#else
# define VBOXDDU_DECL(type) DECLIMPORT(type) VBOXCALL
#endif

/** @} */


/** @defgroup grp_devdrv    Device Emulations and Drivers
 * @{ */
/** @} */

#endif /* !VBOX_INCLUDED_cdefs_h */