VirtualBox

Changeset 20785 in vbox for trunk/include/iprt/asm.h


Ignore:
Timestamp:
Jun 22, 2009 2:43:29 PM (15 years ago)
Author:
vboxsync
Message:

IPRT: the ASMAtomicBit* functions must work on 32-bit aligned addresses to be atomic. The ASMBit* functions should work on 32-bit aligned addresses for performance reasons.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/asm.h

    r20624 r20785  
    54475447/**
    54485448 * Sets a bit in a bitmap.
     5449 * @note    Address should be 32-bit aligned for performance reasons.
    54495450 *
    54505451 * @param   pvBitmap    Pointer to the bitmap.
     
    54855486/**
    54865487 * Atomically sets a bit in a bitmap, ordered.
     5488 * @note    Address must be 32-bit aligned, otherwise the memory access isn't atomic!
    54875489 *
    54885490 * @param   pvBitmap    Pointer to the bitmap.
     
    54945496DECLINLINE(void) ASMAtomicBitSet(volatile void *pvBitmap, int32_t iBit)
    54955497{
     5498    AssertMsg(!((uintptr_t)pvBitmap & 3), ("address %p not 32-bit aligned", pvBitmap));
    54965499# if RT_INLINE_ASM_USES_INTRIN
    54975500    _interlockedbittestandset((long *)pvBitmap, iBit);
     
    55225525/**
    55235526 * Clears a bit in a bitmap.
     5527 * @note    Address should be 32-bit aligned for performance reasons.
    55245528 *
    55255529 * @param   pvBitmap    Pointer to the bitmap.
     
    55605564/**
    55615565 * Atomically clears a bit in a bitmap, ordered.
     5566 * @note    Address must be 32-bit aligned, otherwise the memory access isn't atomic!
    55625567 *
    55635568 * @param   pvBitmap    Pointer to the bitmap.
     
    55705575DECLINLINE(void) ASMAtomicBitClear(volatile void *pvBitmap, int32_t iBit)
    55715576{
     5577    AssertMsg(!((uintptr_t)pvBitmap & 3), ("address %p not 32-bit aligned", pvBitmap));
    55725578# if RT_INLINE_ASM_GNU_STYLE
    55735579    __asm__ __volatile__("lock; btrl %1, %0"
     
    55965602/**
    55975603 * Toggles a bit in a bitmap.
     5604 * @note    Address should be 32-bit aligned for performance reasons.
    55985605 *
    55995606 * @param   pvBitmap    Pointer to the bitmap.
     
    56335640/**
    56345641 * Atomically toggles a bit in a bitmap, ordered.
     5642 * @note    Address must be 32-bit aligned, otherwise the memory access isn't atomic!
    56355643 *
    56365644 * @param   pvBitmap    Pointer to the bitmap.
     
    56425650DECLINLINE(void) ASMAtomicBitToggle(volatile void *pvBitmap, int32_t iBit)
    56435651{
     5652    AssertMsg(!((uintptr_t)pvBitmap & 3), ("address %p not 32-bit aligned", pvBitmap));
    56445653# if RT_INLINE_ASM_GNU_STYLE
    56455654    __asm__ __volatile__("lock; btcl %1, %0"
     
    56685677/**
    56695678 * Tests and sets a bit in a bitmap.
     5679 * @note    Address should be 32-bit aligned for performance reasons.
    56705680 *
    56715681 * @returns true if the bit was set.
     
    57155725/**
    57165726 * Atomically tests and sets a bit in a bitmap, ordered.
     5727 * @note    Address must be 32-bit aligned, otherwise the memory access isn't atomic!
    57175728 *
    57185729 * @returns true if the bit was set.
     
    57275738{
    57285739    union { bool f; uint32_t u32; uint8_t u8; } rc;
     5740    AssertMsg(!((uintptr_t)pvBitmap & 3), ("address %p not 32-bit aligned", pvBitmap));
    57295741# if RT_INLINE_ASM_USES_INTRIN
    57305742    rc.u8 = _interlockedbittestandset((long *)pvBitmap, iBit);
     
    57615773/**
    57625774 * Tests and clears a bit in a bitmap.
     5775 * @note    Address should be 32-bit aligned for performance reasons.
    57635776 *
    57645777 * @returns true if the bit was set.
     
    58085821/**
    58095822 * Atomically tests and clears a bit in a bitmap, ordered.
     5823 * @note    Address must be 32-bit aligned, otherwise the memory access isn't atomic!
    58105824 *
    58115825 * @returns true if the bit was set.
     
    58215835{
    58225836    union { bool f; uint32_t u32; uint8_t u8; } rc;
     5837    AssertMsg(!((uintptr_t)pvBitmap & 3), ("address %p not 32-bit aligned", pvBitmap));
    58235838# if RT_INLINE_ASM_USES_INTRIN
    58245839    rc.u8 = _interlockedbittestandreset((long *)pvBitmap, iBit);
     
    58565871/**
    58575872 * Tests and toggles a bit in a bitmap.
     5873 * @note    Address should be 32-bit aligned for performance reasons.
    58585874 *
    58595875 * @returns true if the bit was set.
     
    59035919/**
    59045920 * Atomically tests and toggles a bit in a bitmap, ordered.
     5921 * @note    Address must be 32-bit aligned, otherwise the memory access isn't atomic!
    59055922 *
    59065923 * @returns true if the bit was set.
     
    59155932{
    59165933    union { bool f; uint32_t u32; uint8_t u8; } rc;
     5934    AssertMsg(!((uintptr_t)pvBitmap & 3), ("address %p not 32-bit aligned", pvBitmap));
    59175935# if RT_INLINE_ASM_GNU_STYLE
    59185936    __asm__ __volatile__("lock; btcl %2, %1\n\t"
     
    59475965/**
    59485966 * Tests if a bit in a bitmap is set.
     5967 * @note    Address should be 32-bit aligned for performance reasons.
    59495968 *
    59505969 * @returns true if the bit is set.
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