mirror of
https://github.com/reactos/reactos.git
synced 2026-07-03 05:34:27 +08:00
define BitScanReverse to _BitScanReverse, add BitScanForeward the same way, add 64 bit InterlockedBittest intrinsics
svn path=/trunk/; revision=39446
This commit is contained in:
@@ -181,30 +181,14 @@ InterlockedBitTestAndReset(IN LONG volatile *Base,
|
||||
#endif
|
||||
}
|
||||
|
||||
static __inline__ BOOLEAN
|
||||
BitScanReverse(OUT ULONG *Index,
|
||||
IN ULONG Mask)
|
||||
{
|
||||
BOOLEAN BitPosition = 0;
|
||||
#if defined(_M_IX86)
|
||||
__asm__ __volatile__("bsrl %2,%0\n\t"
|
||||
"setnz %1\n\t"
|
||||
:"=&r" (*Index), "=q" (BitPosition)
|
||||
:"rm" (Mask)
|
||||
:"memory");
|
||||
return BitPosition;
|
||||
#else
|
||||
/* Slow implementation for now */
|
||||
for( *Index = 31; *Index; (*Index)-- ) {
|
||||
if( (1<<*Index) & Mask ) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
#define BitScanForward _BitScanForward
|
||||
#define BitScanReverse _BitScanReverse
|
||||
|
||||
#ifdef _M_AMD64
|
||||
#define InterlockedBitTestAndSet64 _interlockedbittestandset64
|
||||
#define InterlockedBitTestAndReset64 _interlockedbittestandreset64
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user