~ubuntu-branches/ubuntu/trusty/virtualbox-ose/trusty

« back to all changes in this revision

Viewing changes to src/VBox/Runtime/include/internal/iprt.h

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2009-12-18 16:44:29 UTC
  • mfrom: (0.3.3 upstream) (0.4.6 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091218164429-jd34ccexpv5na11a
Tags: 3.1.2-dfsg-1ubuntu1
* Merge from Debian unstable (LP: #498219), remaining changes:
  - Disable update action
    - debian/patches/u01-disable-update-action.dpatch
  - VirtualBox should go in Accessories, not in System tools (LP: #288590)
    - debian/virtualbox-ose-qt.files/virtualbox-ose.desktop
  - Add Apport hook
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Add Launchpad integration
    - debian/control
    - debian/lpi-bug.xpm
    - debian/patches/u02-lp-integration.dpatch
* Fixes the following bugs:
  - Kernel module fails to build with Linux >= 2.6.32 (LP: #474625)
  - X.Org drivers need to be rebuilt against X-Server 1.7 (LP: #495935)
  - The *-source packages try to build the kernel modules even though the
    kernel headers aren't available (LP: #473334)
* Replace *-source packages with transitional packages for *-dkms.
* Adapt u01-disable-update-action.dpatch and u02-lp-integration.dpatch for
  new upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: iprt.h $ */
 
2
/** @file
 
3
 * IPRT - Internal header for miscellaneous global defs and types.
 
4
 */
 
5
 
 
6
/*
 
7
 * Copyright (C) 2009 Sun Microsystems, Inc.
 
8
 *
 
9
 * This file is part of VirtualBox Open Source Edition (OSE), as
 
10
 * available from http://www.virtualbox.org. This file is free software;
 
11
 * you can redistribute it and/or modify it under the terms of the GNU
 
12
 * General Public License (GPL) as published by the Free Software
 
13
 * Foundation, in version 2 as it comes in the "COPYING" file of the
 
14
 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 
15
 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 
16
 *
 
17
 * The contents of this file may alternatively be used under the terms
 
18
 * of the Common Development and Distribution License Version 1.0
 
19
 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
 
20
 * VirtualBox OSE distribution, in which case the provisions of the
 
21
 * CDDL are applicable instead of those of the GPL.
 
22
 *
 
23
 * You may elect to license modified versions of this file under the
 
24
 * terms and conditions of either the GPL or the CDDL or both.
 
25
 *
 
26
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
 
27
 * Clara, CA 95054 USA or visit http://www.sun.com if you need
 
28
 * additional information or have any questions.
 
29
 */
 
30
 
 
31
#ifndef ___internal_iprt_h
 
32
#define ___internal_iprt_h
 
33
 
 
34
#include <iprt/cdefs.h>
 
35
#include <iprt/types.h>
 
36
 
 
37
/** @def RT_EXPORT_SYMBOL
 
38
 * This define is really here just for the linux kernel.
 
39
 * @param   Name        The symbol name.
 
40
 */
 
41
#if defined(RT_OS_LINUX) \
 
42
 && defined(IN_RING0) \
 
43
 && defined(MODULE) \
 
44
 && !defined(RT_NO_EXPORT_SYMBOL)
 
45
# define bool linux_bool /* see r0drv/linux/the-linux-kernel.h */
 
46
# include <linux/autoconf.h>
 
47
# if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS)
 
48
#  include <linux/version.h>
 
49
#  define MODVERSIONS
 
50
#  if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 71)
 
51
#   include <linux/modversions.h>
 
52
#  endif
 
53
# endif
 
54
# include <linux/module.h>
 
55
# undef bool
 
56
# define RT_EXPORT_SYMBOL(Name) EXPORT_SYMBOL(Name)
 
57
#else
 
58
# define RT_EXPORT_SYMBOL(Name) extern int g_rtExportSymbolDummyVariable
 
59
#endif
 
60
 
 
61
 
 
62
/** @def RT_MORE_STRICT
 
63
 * Enables more assertions in IPRT.  */
 
64
#if !defined(RT_MORE_STRICT) && (defined(DEBUG) || defined(RT_STRICT) || defined(DOXYGEN_RUNNING)) && !defined(RT_OS_WINDOWS) /** @todo enable on windows after testing */
 
65
# define RT_MORE_STRICT
 
66
#endif
 
67
 
 
68
/** @def RT_ASSERT_PREEMPT_CPUID_VAR
 
69
 * Partner to RT_ASSERT_PREEMPT_CPUID_VAR. Declares and initializes a variable
 
70
 * idAssertCpu to NIL_RTCPUID if preemption is enabled and to RTMpCpuId if
 
71
 * disabled.  When RT_MORE_STRICT isn't defined it declares an uninitialized
 
72
 * dummy variable.
 
73
 *
 
74
 * Requires iprt/mp.h and iprt/asm.h.
 
75
 */
 
76
/** @def RT_ASSERT_PREEMPT_CPUID
 
77
 * Asserts that we didn't change CPU since RT_ASSERT_PREEMPT_CPUID_VAR if
 
78
 * preemption is disabled.  Will also detect changes in preemption
 
79
 * disable/enable status.  This is a noop when RT_MORE_STRICT isn't defined. */
 
80
#ifdef RT_MORE_STRICT
 
81
# define RT_ASSERT_PREEMPT_CPUID_VAR() \
 
82
    RTCPUID const idAssertCpu = RTThreadPreemptIsEnabled(NIL_RTTHREAD) ? NIL_RTCPUID : RTMpCpuId()
 
83
# define RT_ASSERT_PREEMPT_CPUID() \
 
84
   do \
 
85
   { \
 
86
        RTCPUID const idAssertCpuNow = RTThreadPreemptIsEnabled(NIL_RTTHREAD) ? NIL_RTCPUID : RTMpCpuId(); \
 
87
        AssertMsg(idAssertCpu == idAssertCpuNow,  ("%#x, %#x\n", idAssertCpu, idAssertCpuNow)); \
 
88
   } while (0)
 
89
 
 
90
#else
 
91
# define RT_ASSERT_PREEMPT_CPUID_VAR()  RTCPUID idAssertCpuDummy
 
92
# define RT_ASSERT_PREEMPT_CPUID()      NOREF(idAssertCpuDummy)
 
93
#endif
 
94
 
 
95
/** @def RT_ASSERT_PREEMPT_CPUID_SPIN_ACQUIRED
 
96
 * Extended version of RT_ASSERT_PREEMPT_CPUID for use before
 
97
 * RTSpinlockAcquired* returns.  This macro works the idCpuOwner and idAssertCpu
 
98
 * members of the spinlock instance data.  */
 
99
#ifdef RT_MORE_STRICT
 
100
# define RT_ASSERT_PREEMPT_CPUID_SPIN_ACQUIRED(pThis) \
 
101
    do \
 
102
    { \
 
103
        RTCPUID const idAssertCpuNow = RTMpCpuId(); \
 
104
        AssertMsg(idAssertCpu == idAssertCpuNow || idAssertCpu == NIL_RTCPUID,  ("%#x, %#x\n", idAssertCpu, idAssertCpuNow)); \
 
105
        (pThis)->idAssertCpu = idAssertCpu; \
 
106
        (pThis)->idCpuOwner  = idAssertCpuNow; \
 
107
    } while (0)
 
108
#else
 
109
# define RT_ASSERT_PREEMPT_CPUID_SPIN_ACQUIRED(pThis)   NOREF(idAssertCpuDummy)
 
110
#endif
 
111
 
 
112
/** @def RT_ASSERT_PREEMPT_CPUID_SPIN_RELEASE_VARS
 
113
 * Extended version of RT_ASSERT_PREEMPT_CPUID_VAR for use with
 
114
 * RTSpinlockRelease* returns. */
 
115
#ifdef RT_MORE_STRICT
 
116
# define RT_ASSERT_PREEMPT_CPUID_SPIN_RELEASE_VARS()    RTCPUID idAssertCpu
 
117
#else
 
118
# define RT_ASSERT_PREEMPT_CPUID_SPIN_RELEASE_VARS()    RTCPUID idAssertCpuDummy
 
119
#endif
 
120
 
 
121
/** @def RT_ASSERT_PREEMPT_CPUID_SPIN_RELEASE
 
122
 * Extended version of RT_ASSERT_PREEMPT_CPUID for use in RTSpinlockRelease*
 
123
 * before calling the native API for releasing the spinlock.  It must be
 
124
 * teamed up with RT_ASSERT_PREEMPT_CPUID_SPIN_ACQUIRED. */
 
125
#ifdef RT_MORE_STRICT
 
126
# define RT_ASSERT_PREEMPT_CPUID_SPIN_RELEASE(pThis) \
 
127
    do \
 
128
    { \
 
129
        RTCPUID const idCpuOwner     = (pThis)->idCpuOwner; \
 
130
        RTCPUID const idAssertCpuNow = RTMpCpuId(); \
 
131
        AssertMsg(idCpuOwner == idAssertCpuNow,  ("%#x, %#x\n", idCpuOwner, idAssertCpuNow)); \
 
132
        (pThis)->idCpuOwner  = NIL_RTCPUID; \
 
133
        idAssertCpu = (pThis)->idAssertCpu; \
 
134
        (pThis)->idAssertCpu = NIL_RTCPUID; \
 
135
    } while (0)
 
136
#else
 
137
# define RT_ASSERT_PREEMPT_CPUID_SPIN_RELEASE(pThis)    NOREF(idAssertCpuDummy)
 
138
#endif
 
139
 
 
140
/** @def RT_ASSERT_PREEMPT_CPUID_DISABLE
 
141
 * For use in RTThreadPreemptDisable implementations after having disabled
 
142
 * preemption.  Requires iprt/mp.h. */
 
143
#ifdef RT_MORE_STRICT
 
144
# define RT_ASSERT_PREEMPT_CPUID_DISABLE(pStat) \
 
145
    do \
 
146
    { \
 
147
        Assert((pStat)->idCpu == NIL_RTCPUID); \
 
148
        (pStat)->idCpu = RTMpCpuId(); \
 
149
    } while (0)
 
150
#else
 
151
# define RT_ASSERT_PREEMPT_CPUID_DISABLE(pStat) \
 
152
    Assert((pStat)->idCpu == NIL_RTCPUID)
 
153
#endif
 
154
 
 
155
/** @def RT_ASSERT_PREEMPT_CPUID_RESTORE
 
156
 * For use in RTThreadPreemptRestore implementations before restoring
 
157
 * preemption.  Requires iprt/mp.h. */
 
158
#ifdef RT_MORE_STRICT
 
159
# define RT_ASSERT_PREEMPT_CPUID_RESTORE(pStat) \
 
160
    do \
 
161
    { \
 
162
        RTCPUID const idAssertCpuNow = RTMpCpuId(); \
 
163
        AssertMsg((pStat)->idCpu == idAssertCpuNow,  ("%#x, %#x\n", (pStat)->idCpu, idAssertCpuNow)); \
 
164
        (pStat)->idCpu = NIL_RTCPUID; \
 
165
    } while (0)
 
166
#else
 
167
# define RT_ASSERT_PREEMPT_CPUID_RESTORE(pStat)         do { } while (0)
 
168
#endif
 
169
 
 
170
 
 
171
/** @def RT_ASSERT_INTS_ON
 
172
 * Asserts that interrupts are disabled when RT_MORE_STRICT is defined.   */
 
173
#ifdef RT_MORE_STRICT
 
174
# define RT_ASSERT_INTS_ON()            Assert(ASMIntAreEnabled())
 
175
#else
 
176
# define RT_ASSERT_INTS_ON()            do { } while (0)
 
177
#endif
 
178
 
 
179
/** @def RT_ASSERT_PREEMPTIBLE
 
180
 * Asserts that preemption hasn't been disabled (using
 
181
 * RTThreadPreemptDisable) when RT_MORE_STRICT is defined. */
 
182
#ifdef RT_MORE_STRICT
 
183
# define RT_ASSERT_PREEMPTIBLE()        Assert(RTThreadPreemptIsEnabled(NIL_RTTHREAD))
 
184
#else
 
185
# define RT_ASSERT_PREEMPTIBLE()        do { } while (0)
 
186
#endif
 
187
 
 
188
#endif
 
189