VirtualBox

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

Last change on this file since 22075 was 22075, checked in by vboxsync, 16 years ago

internal/iprt.h: don't enable RT_MORE_STRICT on windows yet, it's likely to blow up in memobj.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 KB
Line 
1/* $Id: iprt.h 22075 2009-08-07 15:37:07Z 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.215389.xyz. 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_INTS_ON
89 * Asserts that interrupts are disabled when RT_MORE_STRICT is defined. */
90#ifdef RT_MORE_STRICT
91# define RT_ASSERT_INTS_ON() Assert(ASMIntAreEnabled())
92#else
93# define RT_ASSERT_INTS_ON() do { } while (0)
94#endif
95
96/** @def RT_ASSERT_PREEMPTIBLE
97 * Asserts that preemption hasn't been disabled (using
98 * RTThreadPreemptDisable) when RT_MORE_STRICT is defined. */
99#ifdef RT_MORE_STRICT
100# define RT_ASSERT_PREEMPTIBLE() Assert(RTThreadPreemptIsEnabled(NIL_RTTHREAD))
101#else
102# define RT_ASSERT_PREEMPTIBLE() do { } while (0)
103#endif
104
105#endif
106
Note: See TracBrowser for help on using the repository browser.

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