Logo Search packages:      
Sourcecode: virtualbox-ose version File versions  Download package

static void kPrfAtomicAdd64 ( volatile KU64 *  pu64,
const KU64  u64 
) [inline, static]

Atomically add a 64-bit integer to another. Atomically isn't quite required, just a non-corruptive manner, assuming all updates are adds.

Definition at line 462 of file kProfileR3.cpp.

{
#if defined(HAVE_INTRIN) && KPRF_BITS == 64
    _InterlockedExchangeAdd64((volatile KI64 *)pu64, (const KI64)u64);

#elif defined(__GNUC__) && KPRF_BITS == 64
    __asm__ __volatile__("lock; addq %0, %1\n\t"
                         : "=m" (*pu64)
                         : "r" (u64));

#elif defined(__GNUC__) && KPRF_BITS == 32
    __asm__ __volatile__("lock; addl %0, %2\n\t"
                         "lock; adcl %1, %3\n\t"
                         : "=m" (*(volatile KU32 *)pu64),
                           "=m" (*((volatile KU32 *)pu64 + 1))
                         : "r" ((KU32)u64),
                           "r" ((KU32)(u64 >> 32)));

#elif _MSC_VER
    __asm
    {
        mov     edx, [pu64]
        mov     eax, dword ptr [u64]
        mov     ecx, dword ptr [u64 + 4]
        lock add [edx], eax
        lock adc [edx + 4], ecx
    }

#else
    *pu64 += u64;
#endif
}


Generated by  Doxygen 1.6.0   Back to index