VirtualBox

Changeset 87194 in vbox for trunk/src/VBox/Runtime/common


Ignore:
Timestamp:
Jan 7, 2021 9:02:43 PM (4 years ago)
Author:
vboxsync
Message:

iprt/asm.h: Added generic C version of ASMBitNextSet. bugref:9898

Location:
trunk/src/VBox/Runtime/common/asm
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/asm/ASMBitNextClear-generic.cpp

    r87193 r87194  
    4646         * Inspect the 32-bit word containing the unaligned bit.
    4747         */
    48         uint32_t  u32 = ~RT_LE2H_U32(pau32Bitmap[iBitPrev / 32]) >> iBit;
     48        uint32_t u32 = ~RT_LE2H_U32(pau32Bitmap[iBitPrev / 32]) >> iBit;
    4949        if (u32)
    5050            return iBitPrev + ASMBitFirstSetU32(u32) - 1;
  • trunk/src/VBox/Runtime/common/asm/ASMBitNextSet-generic.cpp

    r87193 r87194  
    11/* $Id$ */
    22/** @file
    3  * IPRT - ASMBitNextClear - generic C implementation.
     3 * IPRT - ASMBitNextSet - generic C implementation.
    44 */
    55
     
    3535
    3636
    37 DECLASM(int) ASMBitNextClear(const volatile void RT_FAR *pvBitmap, uint32_t cBits, uint32_t iBitPrev) RT_NOTHROW_DEF
     37DECLASM(int) ASMBitNextSet(const volatile void RT_FAR *pvBitmap, uint32_t cBits, uint32_t iBitPrev) RT_NOTHROW_DEF
    3838{
    3939    const volatile uint32_t RT_FAR *pau32Bitmap = (const volatile uint32_t RT_FAR *)pvBitmap;
     
    4646         * Inspect the 32-bit word containing the unaligned bit.
    4747         */
    48         uint32_t  u32 = ~RT_LE2H_U32(pau32Bitmap[iBitPrev / 32]) >> iBit;
     48        uint32_t u32 = RT_LE2H_U32(pau32Bitmap[iBitPrev / 32]) >> iBit;
    4949        if (u32)
    5050            return iBitPrev + ASMBitFirstSetU32(u32) - 1;
     
    6060
    6161    /*
    62      * 32-bit aligned search, let ASMBitFirstClear do the dirty work.
     62     * 32-bit aligned search, let ASMBitFirstSet do the dirty work.
    6363     */
    64     iBit = ASMBitFirstClear(&pau32Bitmap[iBitPrev / 32], cBits - iBitPrev);
     64    iBit = ASMBitFirstSet(&pau32Bitmap[iBitPrev / 32], cBits - iBitPrev);
    6565    if (iBit >= 0)
    6666        iBit += iBitPrev;
  • trunk/src/VBox/Runtime/common/asm/asm-fake.cpp

    r87193 r87194  
    297297}
    298298
    299 RTDECL(int) ASMBitNextSet(const volatile void *pvBitmap, uint32_t cBits, uint32_t iBitPrev)
    300 {
    301     const volatile uint8_t *pau8Bitmap = (const volatile uint8_t *)pvBitmap;
    302     int                      iBit = ++iBitPrev & 7;
    303     if (iBit)
    304     {
    305         /*
    306          * Inspect the byte containing the unaligned bit.
    307          */
    308         uint8_t u8 = pau8Bitmap[iBitPrev / 8] >> iBit;
    309         if (u8)
    310         {
    311             iBit = 0;
    312             while (!(u8 & 1))
    313             {
    314                 u8 >>= 1;
    315                 iBit++;
    316             }
    317             return iBitPrev + iBit;
    318         }
    319 
    320         /*
    321          * Skip ahead and see if there is anything left to search.
    322          */
    323         iBitPrev |= 7;
    324         iBitPrev++;
    325         if (cBits <= iBitPrev)
    326             return -1;
    327     }
    328 
    329     /*
    330      * Byte search, let ASMBitFirstSet do the dirty work.
    331      */
    332     iBit = ASMBitFirstSet(&pau8Bitmap[iBitPrev / 8], cBits - iBitPrev);
    333     if (iBit >= 0)
    334         iBit += iBitPrev;
    335     return iBit;
    336 }
    337 
    338299RTDECL(unsigned) ASMBitFirstSetU32(uint32_t u32)
    339300{
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