VirtualBox

source: vbox/trunk/src/VBox/Runtime/include/internal/iprt.h@ 22150

最後變更 在這個檔案從22150是 22150,由 vboxsync 提交於 16 年 前

IPRT,SUPDrv: Changed RTTHREADPREEMPTSTATE breaking binary compatibility - increased the major SUPDrv version.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 6.6 KB
 
1/* $Id: iprt.h 22150 2009-08-11 09:41:58Z vboxsync $ */
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.alldomusa.eu.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# include <linux/module.h>
48# undef bool
49# define RT_EXPORT_SYMBOL(Name) EXPORT_SYMBOL(Name)
50#else
51# define RT_EXPORT_SYMBOL(Name) extern int g_rtExportSymbolDummyVariable
52#endif
53
54
55/** @def RT_MORE_STRICT
56 * Enables more assertions in IPRT. */
57#if !defined(RT_MORE_STRICT) && (defined(DEBUG) || defined(RT_STRICT) || defined(DOXYGEN_RUNNING)) && !defined(RT_OS_WINDOWS) /** @todo enable on windows after testing */
58# define RT_MORE_STRICT
59#endif
60
61/** @def RT_ASSERT_PREEMPT_CPUID_VAR
62 * Partner to RT_ASSERT_PREEMPT_CPUID_VAR. Declares and initializes a variable
63 * idAssertCpu to NIL_RTCPUID if preemption is enabled and to RTMpCpuId if
64 * disabled. When RT_MORE_STRICT isn't defined it declares an uninitialized
65 * dummy variable.
66 *
67 * Requires iprt/mp.h and iprt/asm.h.
68 */
69/** @def RT_ASSERT_PREEMPT_CPUID
70 * Asserts that we didn't change CPU since RT_ASSERT_PREEMPT_CPUID_VAR if
71 * preemption is disabled. Will also detect changes in preemption
72 * disable/enable status. This is a noop when RT_MORE_STRICT isn't defined. */
73#ifdef RT_MORE_STRICT
74# define RT_ASSERT_PREEMPT_CPUID_VAR() \
75 RTCPUID const idAssertCpu = RTThreadPreemptIsEnabled(NIL_RTTHREAD) ? NIL_RTCPUID : RTMpCpuId()
76# define RT_ASSERT_PREEMPT_CPUID() \
77 do \
78 { \
79 RTCPUID const idAssertCpuNow = RTThreadPreemptIsEnabled(NIL_RTTHREAD) ? NIL_RTCPUID : RTMpCpuId(); \
80 AssertMsg(idAssertCpu == idAssertCpuNow, ("%#x, %#x\n", idAssertCpu, idAssertCpuNow)); \
81 } while (0)
82
83#else
84# define RT_ASSERT_PREEMPT_CPUID_VAR() RTCPUID idAssertCpuDummy
85# define RT_ASSERT_PREEMPT_CPUID() NOREF(idAssertCpuDummy)
86#endif
87
88/** @def RT_ASSERT_PREEMPT_CPUID_SPIN_ACQUIRED
89 * Extended version of RT_ASSERT_PREEMPT_CPUID for use before
90 * RTSpinlockAcquired* returns. This macro works the idCpuOwner and idAssertCpu
91 * members of the spinlock instance data. */
92#ifdef RT_MORE_STRICT
93# define RT_ASSERT_PREEMPT_CPUID_SPIN_ACQUIRED(pThis) \
94 do \
95 { \
96 RTCPUID const idAssertCpuNow = RTMpCpuId(); \
97 AssertMsg(idAssertCpu == idAssertCpuNow || idAssertCpu == NIL_RTCPUID, ("%#x, %#x\n", idAssertCpu, idAssertCpuNow)); \
98 (pThis)->idAssertCpu = idAssertCpu; \
99 (pThis)->idCpuOwner = idAssertCpuNow; \
100 } while (0)
101#else
102# define RT_ASSERT_PREEMPT_CPUID_SPIN_ACQUIRED(pThis) NOREF(idAssertCpuDummy)
103#endif
104
105/** @def RT_ASSERT_PREEMPT_CPUID_SPIN_RELEASE_VARS
106 * Extended version of RT_ASSERT_PREEMPT_CPUID_VAR for use with
107 * RTSpinlockRelease* returns. */
108#ifdef RT_MORE_STRICT
109# define RT_ASSERT_PREEMPT_CPUID_SPIN_RELEASE_VARS() RTCPUID idAssertCpu
110#else
111# define RT_ASSERT_PREEMPT_CPUID_SPIN_RELEASE_VARS() RTCPUID idAssertCpuDummy
112#endif
113
114/** @def RT_ASSERT_PREEMPT_CPUID_SPIN_RELEASE
115 * Extended version of RT_ASSERT_PREEMPT_CPUID for use in RTSpinlockRelease*
116 * before calling the native API for releasing the spinlock. It must be
117 * teamed up with RT_ASSERT_PREEMPT_CPUID_SPIN_ACQUIRED. */
118#ifdef RT_MORE_STRICT
119# define RT_ASSERT_PREEMPT_CPUID_SPIN_RELEASE(pThis) \
120 do \
121 { \
122 RTCPUID const idCpuOwner = (pThis)->idCpuOwner; \
123 RTCPUID const idAssertCpuNow = RTMpCpuId(); \
124 AssertMsg(idCpuOwner == idAssertCpuNow, ("%#x, %#x\n", idCpuOwner, idAssertCpuNow)); \
125 (pThis)->idCpuOwner = NIL_RTCPUID; \
126 idAssertCpu = (pThis)->idAssertCpu; \
127 (pThis)->idAssertCpu = NIL_RTCPUID; \
128 } while (0)
129#else
130# define RT_ASSERT_PREEMPT_CPUID_SPIN_RELEASE(pThis) NOREF(idAssertCpuDummy)
131#endif
132
133/** @def RT_ASSERT_PREEMPT_CPUID_DISABLE
134 * For use in RTThreadPreemptDisable implementations after having disabled
135 * preemption. Requires iprt/mp.h. */
136#ifdef RT_MORE_STRICT
137# define RT_ASSERT_PREEMPT_CPUID_DISABLE(pStat) \
138 do \
139 { \
140 Assert((pStat)->idCpu == NIL_RTCPUID); \
141 (pStat)->idCpu = RTMpCpuId(); \
142 } while (0)
143#else
144# define RT_ASSERT_PREEMPT_CPUID_DISABLE(pStat) \
145 Assert((pStat)->idCpu == NIL_RTCPUID)
146#endif
147
148/** @def RT_ASSERT_PREEMPT_CPUID_RESTORE
149 * For use in RTThreadPreemptRestore implementations before restoring
150 * preemption. Requires iprt/mp.h. */
151#ifdef RT_MORE_STRICT
152# define RT_ASSERT_PREEMPT_CPUID_RESTORE(pStat) \
153 do \
154 { \
155 RTCPUID const idAssertCpuNow = RTMpCpuId(); \
156 AssertMsg((pStat)->idCpu == idAssertCpuNow, ("%#x, %#x\n", (pStat)->idCpu, idAssertCpuNow)); \
157 (pStat)->idCpu = NIL_RTCPUID; \
158 } while (0)
159#else
160# define RT_ASSERT_PREEMPT_CPUID_RESTORE(pStat) do { } while (0)
161#endif
162
163
164/** @def RT_ASSERT_INTS_ON
165 * Asserts that interrupts are disabled when RT_MORE_STRICT is defined. */
166#ifdef RT_MORE_STRICT
167# define RT_ASSERT_INTS_ON() Assert(ASMIntAreEnabled())
168#else
169# define RT_ASSERT_INTS_ON() do { } while (0)
170#endif
171
172/** @def RT_ASSERT_PREEMPTIBLE
173 * Asserts that preemption hasn't been disabled (using
174 * RTThreadPreemptDisable) when RT_MORE_STRICT is defined. */
175#ifdef RT_MORE_STRICT
176# define RT_ASSERT_PREEMPTIBLE() Assert(RTThreadPreemptIsEnabled(NIL_RTTHREAD))
177#else
178# define RT_ASSERT_PREEMPTIBLE() do { } while (0)
179#endif
180
181#endif
182
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette