~ubuntu-branches/ubuntu/precise/virtualbox/precise-updates

« back to all changes in this revision

Viewing changes to src/VBox/Runtime/r0drv/darwin/threadpreempt-r0drv-darwin.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-07-04 13:02:31 UTC
  • mfrom: (3.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20110704130231-l843es6wqhx614n7
Tags: 4.0.10-dfsg-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Add Apport hook.
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Drop *-source packages.
* Add the Modaliases control field manually for maximum backportability.

Show diffs side-by-side

added added

removed removed

Lines of Context:
104
104
 
105
105
RTDECL(bool) RTThreadPreemptIsPending(RTTHREAD hThread)
106
106
{
107
 
    Assert(hThread == NIL_RTTHREAD);
 
107
    if (!g_pfnR0DarwinAstPending)
 
108
        return false;
 
109
    uint32_t volatile *pfAstPending = g_pfnR0DarwinAstPending(); AssertPtr(pfAstPending);
 
110
    uint32_t  const    fAstPending = *pfAstPending;
108
111
 
109
 
    /* HACK ALERT! This ASSUMES that the cpu_pending_ast member of cpu_data_t doesn't move. */
110
 
    uint32_t ast_pending;
111
 
#if defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)
112
 
    __asm__ volatile("movl %%gs:%P1,%0\n\t"
113
 
                     : "=r" (ast_pending)
114
 
                     : "i"  (__builtin_offsetof(struct my_cpu_data_x86, cpu_pending_ast)) );
115
 
#else
116
 
# error "Port me"
117
 
#endif
118
 
    AssertMsg(!(ast_pending & UINT32_C(0xfffff000)),("%#x\n", ast_pending));
119
 
    return (ast_pending & (AST_PREEMPT | AST_URGENT)) != 0;
 
112
    AssertMsg(!(fAstPending & UINT32_C(0xfffff000)), ("%#x\n", fAstPending));
 
113
    return (fAstPending & (AST_PREEMPT | AST_URGENT)) != 0;
120
114
}
121
115
 
122
116
 
123
117
RTDECL(bool) RTThreadPreemptIsPendingTrusty(void)
124
118
{
125
119
    /* yes, we think that RTThreadPreemptIsPending is reliable... */
126
 
    return true;
 
120
    return g_pfnR0DarwinAstPending != NULL;
127
121
}
128
122
 
129
123