Rewrite the rtl bitmap implementation.
The old one was a little .... suboptimal. The new one should outperform the old one by several orders of magnitude, especially RtlFindClearBits that was literally searching bit by bit.

svn path=/trunk/; revision=44464
This commit is contained in:
Timo Kreuzer 2009-12-08 01:02:36 +00:00
parent e7ff40f1e3
commit 66fe9a0793
3 changed files with 682 additions and 871 deletions

File diff suppressed because it is too large Load diff

View file

@ -47,6 +47,10 @@
#define STATUS_INVALID_PARAMETER_2 ((NTSTATUS)0xC00000F0)
#define STATUS_BUFFER_OVERFLOW ((NTSTATUS)0x80000005)
unsigned char BitScanForward(ULONG * Index, const unsigned long Mask);
unsigned char BitScanReverse(ULONG * const Index, const unsigned long Mask);
#define RtlFillMemoryUlong(dst, len, val) memset(dst, val, len)
NTSTATUS NTAPI
RtlAnsiStringToUnicodeString(
IN OUT PUNICODE_STRING UniDest,

View file

@ -185,3 +185,25 @@ RtlAssert(PVOID FailedAssertion,
//DbgBreakPoint();
}
unsigned char BitScanForward(ULONG * Index, unsigned long Mask)
{
*Index = 0;
while (Mask && ((Mask & 1) == 0))
{
Mask >>= 1;
++(*Index);
}
return Mask ? 1 : 0;
}
unsigned char BitScanReverse(ULONG * const Index, unsigned long Mask)
{
*Index = 0;
while (Mask && ((Mask & (1 << 31)) == 0))
{
Mask <<= 1;
++(*Index);
}
return Mask ? 1 : 0;
}