儲存庫 vbox 的更動 18368
- 時間撮記:
- 2009-3-27 上午03:19:41 (16 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/include/iprt/asm.h
r15216 r18368 5760 5760 DECLINLINE(int) ASMBitNextClear(const volatile void *pvBitmap, uint32_t cBits, uint32_t iBitPrev) 5761 5761 { 5762 int iBit = ++iBitPrev & 31; 5763 pvBitmap = (const volatile char *)pvBitmap + ((iBitPrev >> 5) << 2); 5764 cBits -= iBitPrev & ~31; 5762 const volatile uint32_t *pau32Bitmap = (const volatile uint32_t *)pvBitmap; 5763 int iBit = ++iBitPrev & 31; 5765 5764 if (iBit) 5766 5765 { 5767 /* inspect the first dword. */ 5768 uint32_t u32 = (~*(const volatile uint32_t *)pvBitmap) >> iBit; 5766 /* 5767 * Inspect the 32-bit word containing the unaligned bit. 5768 */ 5769 uint32_t u32 = ~pau32Bitmap[iBitPrev / 32] >> iBit; 5770 5769 5771 # if RT_INLINE_ASM_USES_INTRIN 5770 5772 unsigned long ulBit = 0; 5771 5773 if (_BitScanForward(&ulBit, u32)) 5772 5774 return ulBit + iBitPrev; 5773 iBit = -1;5774 5775 # else 5775 5776 # if RT_INLINE_ASM_GNU_STYLE … … 5794 5795 return iBit + iBitPrev; 5795 5796 # endif 5796 /* Search the rest of the bitmap, if there is anything. */ 5797 if (cBits > 32) 5798 { 5799 iBit = ASMBitFirstClear((const volatile char *)pvBitmap + sizeof(uint32_t), cBits - 32); 5800 if (iBit >= 0) 5801 return iBit + (iBitPrev & ~31) + 32; 5802 } 5803 } 5804 else 5805 { 5806 /* Search the rest of the bitmap. */ 5807 iBit = ASMBitFirstClear(pvBitmap, cBits); 5808 if (iBit >= 0) 5809 return iBit + (iBitPrev & ~31); 5810 } 5797 5798 /* 5799 * Skip ahead and see if there is anything left to search. 5800 */ 5801 iBitPrev |= 31; 5802 iBitPrev++; 5803 if (cBits <= (uint32_t)iBitPrev) 5804 return -1; 5805 } 5806 5807 /* 5808 * 32-bit aligned search, let ASMBitFirstClear do the dirty work. 5809 */ 5810 iBit = ASMBitFirstClear(&pau32Bitmap[iBitPrev / 32], cBits - iBitPrev); 5811 if (iBit >= 0) 5812 iBit += iBitPrev; 5811 5813 return iBit; 5812 5814 } … … 5912 5914 DECLINLINE(int) ASMBitNextSet(const volatile void *pvBitmap, uint32_t cBits, uint32_t iBitPrev) 5913 5915 { 5914 int iBit = ++iBitPrev & 31; 5915 pvBitmap = (const volatile char *)pvBitmap + ((iBitPrev >> 5) << 2); 5916 cBits -= iBitPrev & ~31; 5916 const volatile uint32_t *pau32Bitmap = (const volatile uint32_t *)pvBitmap; 5917 int iBit = ++iBitPrev & 31; 5917 5918 if (iBit) 5918 5919 { 5919 /* inspect the first dword. */ 5920 uint32_t u32 = *(const volatile uint32_t *)pvBitmap >> iBit; 5920 /* 5921 * Inspect the 32-bit word containing the unaligned bit. 5922 */ 5923 uint32_t u32 = pau32Bitmap[iBitPrev / 32] >> iBit; 5924 5921 5925 # if RT_INLINE_ASM_USES_INTRIN 5922 5926 unsigned long ulBit = 0; 5923 5927 if (_BitScanForward(&ulBit, u32)) 5924 5928 return ulBit + iBitPrev; 5925 iBit = -1;5926 5929 # else 5927 5930 # if RT_INLINE_ASM_GNU_STYLE … … 5935 5938 __asm 5936 5939 { 5937 mov edx, u325940 mov edx, [u32] 5938 5941 bsf eax, edx 5939 5942 jnz done … … 5946 5949 return iBit + iBitPrev; 5947 5950 # endif 5948 /* Search the rest of the bitmap, if there is anything. */ 5949 if (cBits > 32)5950 {5951 iBit = ASMBitFirstSet((const volatile char *)pvBitmap + sizeof(uint32_t), cBits - 32);5952 if (iBit >= 0)5953 return iBit + (iBitPrev & ~31) + 32;5954 }5955 5956 } 5957 else 5958 {5959 /* Search the rest of the bitmap. */5960 iBit = ASMBitFirstSet(pvBitmap, cBits);5961 if (iBit >= 0)5962 return iBit + (iBitPrev & ~31);5963 }5951 5952 /* 5953 * Skip ahead and see if there is anything left to search. 5954 */ 5955 iBitPrev |= 31; 5956 iBitPrev++; 5957 if (cBits <= (uint32_t)iBitPrev) 5958 return -1; 5959 } 5960 5961 /* 5962 * 32-bit aligned search, let ASMBitFirstClear do the dirty work. 5963 */ 5964 iBit = ASMBitFirstSet(&pau32Bitmap[iBitPrev / 32], cBits - iBitPrev); 5965 if (iBit >= 0) 5966 iBit += iBitPrev; 5964 5967 return iBit; 5965 5968 }
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器