VirtualBox

Changeset 19178 in vbox for trunk/include/VBox


Ignore:
Timestamp:
Apr 24, 2009 6:30:49 PM (16 years ago)
Author:
vboxsync
Message:

VBox/vm.h: VMCPU_IS/ASSERT variants, added VM[CPU]_ASSERT_VALID_EXT_RETURN.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vm.h

    r19141 r19178  
    436436#endif
    437437
     438/** @def VMCPU_IS_EMT
     439 * Checks if the current thread is the emulation thread (EMT) for the specified
     440 * virtual CPU.
     441 */
     442#ifdef IN_RC
     443# define VMCPU_IS_EMT(pVCpu)                true
     444#elif defined(IN_RING0)
     445# define VMCPU_IS_EMT(pVCpu)                fixme - need to call HWACCM I think... /** @todo SMP */
     446#else
     447/** @todo need to rework this macro for the case of multiple emulation threads for SMP */
     448# define VMCPU_IS_EMT(pVCpu)                ((pVCpu)->hNativeThread == RTThreadNativeSelf())
     449#endif
     450
    438451/** @def VM_ASSERT_EMT
    439452 * Asserts that the current thread IS the emulation thread (EMT).
     
    449462#endif
    450463
     464/** @def VMCPU_ASSERT_EMT
     465 * Asserts that the current thread IS the emulation thread (EMT) of the
     466 * specified virtual CPU.
     467 */
     468#ifdef IN_RC
     469# define VMCPU_ASSERT_EMT(pVCpu)            Assert(VMCPU_IS_EMT(pVCpu))
     470#elif defined(IN_RING0)
     471# define VMCPU_ASSERT_EMT(pVCpu)            Assert(VMCPU_IS_EMT(pVCpu))
     472#else
     473# define VMCPU_ASSERT_EMT(pVCpu) \
     474    AssertMsg(VMCPU_IS_EMT(pVCpu), \
     475              ("Not emulation thread! Thread=%RTnthrd ThreadEMT=%RTnthrd idCpu=%#x\n", \
     476              RTThreadNativeSelf(), (pVCpu)->hNativeThread, (pVCpu)->idCpu))
     477#endif
     478
    451479/** @def VM_ASSERT_EMT_RETURN
    452480 * Asserts that the current thread IS the emulation thread (EMT) and returns if it isn't.
     
    463491#endif
    464492
     493/** @def VMCPU_ASSERT_EMT_RETURN
     494 * Asserts that the current thread IS the emulation thread (EMT) and returns if it isn't.
     495 */
     496#ifdef IN_RC
     497# define VMCPU_ASSERT_EMT_RETURN(pVCpu, rc) AssertReturn(VMCPU_IS_EMT(pVCpu), (rc))
     498#elif defined(IN_RING0)
     499# define VMCPU_ASSERT_EMT_RETURN(pVCpu, rc) AssertReturn(VMCPU_IS_EMT(pVCpu), (rc))
     500#else
     501# define VMCPU_ASSERT_EMT_RETURN(pVCpu, rc) \
     502    AssertMsg(VMCPU_IS_EMT(pVCpu), \
     503              ("Not emulation thread! Thread=%RTnthrd ThreadEMT=%RTnthrd idCpu=%#x\n", \
     504               RTThreadNativeSelf(), (pVCpu)->hNativeThread, (pVCpu)->idCpu), \
     505              (rc))
     506#endif
     507
    465508
    466509/**
     
    486529                        (rc))
    487530
    488 
     531/** @def VM_ASSERT_VALID_EXT_RETURN
     532 * Asserts a the VM handle is valid for external access, i.e. not being
     533 * destroy or terminated.
     534 */
     535#define VM_ASSERT_VALID_EXT_RETURN(pVM, rc) \
     536        AssertMsgReturn(    RT_VALID_ALIGNED_PTR(pVM, PAGE_SIZE) \
     537                        &&  (unsigned)(pVM)->enmVMState < (unsigned)VMSTATE_DESTROYING, \
     538                        ("pVM=%p state %s\n", (pVM), RT_VALID_ALIGNED_PTR(pVM, PAGE_SIZE) \
     539                         ? VMGetStateName(pVM->enmVMState) : ""), \
     540                        (rc))
     541
     542/** @def VMCPU_ASSERT_VALID_EXT_RETURN
     543 * Asserts a the VMCPU handle is valid for external access, i.e. not being
     544 * destroy or terminated.
     545 */
     546#define VMCPU_ASSERT_VALID_EXT_RETURN(pVCpu, rc) \
     547        AssertMsgReturn(    RT_VALID_ALIGNED_PTR(pVCpu, 64) \
     548                        &&  RT_VALID_ALIGNED_PTR((pVCpu)->CTX_SUFF(pVM), PAGE_SIZE) \
     549                        &&  (unsigned)(pVCpu)->CTX_SUFF(pVM)->enmVMState < (unsigned)VMSTATE_DESTROYING, \
     550                        ("pVCpu=%p pVM=%p state %s\n", (pVCpu), RT_VALID_ALIGNED_PTR(pVCpu, 64) ? (pVCpu)->CTX_SUFF(pVM) : NULL, \
     551                         RT_VALID_ALIGNED_PTR(pVCpu, 64) && RT_VALID_ALIGNED_PTR((pVCpu)->CTX_SUFF(pVM), PAGE_SIZE) \
     552                         ? VMGetStateName((pVCpu)->pVMR3->enmVMState) : ""), \
     553                        (rc))
    489554
    490555
Note: See TracChangeset for help on using the changeset viewer.

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