-/* $Id: rtl.h,v 1.28 2000/03/03 00:38:15 ekohl Exp $
+/* $Id: rtl.h,v 1.29 2000/03/08 01:52:52 ekohl Exp $
*
*/
PWSTR Source
);
+BOOLEAN
+STDCALL
+RtlAreBitsClear (
+ PRTL_BITMAP BitMapHeader,
+ ULONG StartingIndex,
+ ULONG Length
+ );
+
+BOOLEAN
+STDCALL
+RtlAreBitsSet (
+ PRTL_BITMAP BitMapHeader,
+ ULONG StartingIndex,
+ ULONG Length
+ );
+
NTSTATUS
STDCALL
RtlCharToInteger (
ULONG Fill
);
+ULONG
+STDCALL
+RtlFindClearBits (
+ PRTL_BITMAP BitMapHeader,
+ ULONG NumberToFind,
+ ULONG HintIndex
+ );
+
+ULONG
+STDCALL
+RtlFindClearBitsAndSet (
+ PRTL_BITMAP BitMapHeader,
+ ULONG NumberToFind,
+ ULONG HintIndex
+ );
+
+ULONG
+STDCALL
+RtlFindFirstRunClear (
+ PRTL_BITMAP BitMapHeader,
+ PULONG StartingIndex
+ );
+
+ULONG
+STDCALL
+RtlFindFirstRunSet (
+ PRTL_BITMAP BitMapHeader,
+ PULONG StartingIndex
+ );
+
+ULONG
+STDCALL
+RtlFindLongestRunClear (
+ PRTL_BITMAP BitMapHeader,
+ PULONG StartingIndex
+ );
+
+ULONG
+STDCALL
+RtlFindLongestRunSet (
+ PRTL_BITMAP BitMapHeader,
+ PULONG StartingIndex
+ );
+
+ULONG
+STDCALL
+RtlFindSetBits (
+ PRTL_BITMAP BitMapHeader,
+ ULONG NumberToFind,
+ ULONG HintIndex
+ );
+
+ULONG
+STDCALL
+RtlFindSetBitsAndClear (
+ PRTL_BITMAP BitMapHeader,
+ ULONG NumberToFind,
+ ULONG HintIndex
+ );
+
VOID
STDCALL
RtlFreeAnsiString (
NTSTATUS StatusCode
);
+ULONG
+STDCALL
+RtlNumberOfClearBits (
+ PRTL_BITMAP BitMapHeader
+ );
+
+ULONG
+STDCALL
+RtlNumberOfSetBits (
+ PRTL_BITMAP BitMapHeader
+ );
+
ULONG
STDCALL
RtlOemStringToUnicodeSize (
IN PRTL_BITMAP BitMapHeader
);
+VOID
+STDCALL
+RtlSetBits (
+ PRTL_BITMAP BitMapHeader,
+ ULONG StartingIndex,
+ ULONG NumberToSet
+ );
+
NTSTATUS
STDCALL
RtlSetDaclSecurityDescriptor (
PVOID pmem
);
-#if 0
-PWSTR
-RtlStrtok (
- PUNICODE_STRING _string,
- PWSTR _sep,
- PWSTR * temp
- );
-#endif
-
VOID
RtlStoreLong (
PULONG Address,
-; $Id: ntoskrnl.edf,v 1.40 2000/03/06 01:02:30 ea Exp $
+; $Id: ntoskrnl.edf,v 1.41 2000/03/08 01:55:34 ekohl Exp $
;
; reactos/ntoskrnl/ntoskrnl.def
;
KdDebuggerEnabled DATA
KdDebuggerNotPresent DATA
KdPollBreakIn=KdPollBreakIn@0
-KeAddSystemServiceTable
+KeAddSystemServiceTable=KeAddSystemServiceTable@20
KeBugCheck
KeBugCheckEx
KeClearEvent
KeQuerySystemTime
KeReadStateEvent
KeResetEvent
+KeServiceDescriptorTable DATA
KeSetEvent
KeSetTimer
KeSynchronizeExecution
KeWaitForSingleObject
MmGetSystemAddressForMdl
MmMapIoSpace
-NlsAnsiCodePage DATA
-NlsLeadByteInfo DATA
-NlsMbCodePageTag DATA
-NlsMbOemCodePageTag DATA
-NlsOemLeadByteInfo DATA
+NlsAnsiCodePage DATA
+NlsLeadByteInfo DATA
+NlsMbCodePageTag DATA
+NlsMbOemCodePageTag DATA
+NlsOemLeadByteInfo DATA
NtAddAtom=NtAddAtom@8
NtAdjustPrivilegesToken=NtAdjustPrivilegesToken@24
NtAllocateLocallyUniqueId=NtAllocateLocallyUniqueId@4
RtlAppendStringToString=RtlAppendStringToString@8
RtlAppendUnicodeStringToString=RtlAppendUnicodeStringToString@8
RtlAppendUnicodeToString=RtlAppendUnicodeToString@8
+RtlAreBitsClear=RtlAreBitsClear@12
+RtlAreBitsSet=RtlAreBitsSet@12
RtlCharToInteger=RtlCharToInteger@12
RtlClearAllBits=RtlClearAllBits@4
RtlClearBits=RtlClearBits@12
RtlExtendedMagicDivide=RtlExtendedMagicDivide@20
RtlFillMemory=RtlFillMemory@12
RtlFillMemoryUlong=RtlFillMemoryUlong@12
+RtlFindClearBits=RtlFindClearBits@12
+RtlFindClearBitsAndSet=RtlFindClearBitsAndSet@12
+RtlFindFirstRunClear=RtlFindFirstRunClear@8
+RtlFindFirstRunSet=RtlFindFirstRunSet@8
+RtlFindLongestRunClear=RtlFindLongestRunClear@8
+RtlFindLongestRunSet=RtlFindLongestRunSet@8
+RtlFindSetBits=RtlFindSetBits@12
+RtlFindSetBitsAndClear=RtlFindSetBitsAndClear@12
RtlFreeAnsiString=RtlFreeAnsiString@4
RtlFreeOemString=RtlFreeOemString@4
RtlFreeUnicodeString=RtlFreeUnicodeString@4
RtlMoveMemory=RtlMoveMemory@12
RtlMultiByteToUnicodeN=RtlMultiByteToUnicodeN@20
RtlMultiByteToUnicodeSize=RtlMultiByteToUnicodeSize@12
+RtlNumberOfClearBits=RtlNumberOfClearBits@4
+RtlNumberOfSetBits=RtlNumberOfSetBits@4
RtlOemStringToCountedUnicodeString=RtlOemStringToCountedUnicodeString@12
RtlOemStringToUnicodeSize=RtlOemStringToUnicodeSize@4
RtlOemStringToUnicodeString=RtlOemStringToUnicodeString@12
-/* $Id: bitmap.c,v 1.1 2000/03/03 00:48:50 ekohl Exp $
+/* $Id: bitmap.c,v 1.2 2000/03/08 01:54:34 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
}
+BOOLEAN
+STDCALL
+RtlAreBitsClear (
+ PRTL_BITMAP BitMapHeader,
+ ULONG StartingIndex,
+ ULONG Length
+ )
+{
+ ULONG Size = BitMapHeader->SizeOfBitMap;
+ ULONG Shift;
+ ULONG Count;
+ PCHAR Ptr;
+
+ if (StartingIndex >= Size ||
+ !Length ||
+ (StartingIndex + Length > Size))
+ return FALSE;
+
+ Ptr = (PCHAR)BitMapHeader->Buffer + (StartingIndex / 8);
+ while (Length)
+ {
+ /* get bit shift in current byte */
+ Shift = StartingIndex & 7;
+
+ /* get number of bits to check in current byte */
+ Count = (Length > 8 - Shift) ? 8 - Shift : Length;
+
+ /* check byte */
+ if (*Ptr++ & (~(0xFF << Count) << Shift))
+ return FALSE;
+
+ Length -= Count;
+ StartingIndex += Count;
+ }
+
+ return TRUE;
+}
+
+
+BOOLEAN
+STDCALL
+RtlAreBitsSet (
+ PRTL_BITMAP BitMapHeader,
+ ULONG StartingIndex,
+ ULONG Length
+ )
+{
+ ULONG Size = BitMapHeader->SizeOfBitMap;
+ ULONG Shift;
+ ULONG Count;
+ PCHAR Ptr;
+
+ if (StartingIndex >= Size ||
+ !Length ||
+ (StartingIndex + Length > Size))
+ return FALSE;
+
+ Ptr = (PCHAR)BitMapHeader->Buffer + (StartingIndex / 8);
+ while (Length)
+ {
+ /* get bit shift in current byte */
+ Shift = StartingIndex & 7;
+
+ /* get number of bits to check in current byte */
+ Count = (Length > 8 - Shift) ? 8 - Shift : Length;
+
+ /* check byte */
+ if (~*Ptr++ & (~(0xFF << Count) << Shift))
+ return FALSE;
+
+ Length -= Count;
+ StartingIndex += Count;
+ }
+
+ return TRUE;
+}
+
+
VOID
STDCALL
RtlClearAllBits (
)
{
ULONG Size = BitMapHeader->SizeOfBitMap;
- ULONG n;
- ULONG shift;
- PCHAR p;
+ ULONG Count;
+ ULONG Shift;
+ PCHAR Ptr;
if (StartingIndex >= Size || NumberToClear == 0)
return;
if (StartingIndex + NumberToClear > Size)
NumberToClear = Size - StartingIndex;
- p = (PCHAR)(BitMapHeader->Buffer + (StartingIndex / 8));
+ Ptr = (PCHAR)(BitMapHeader->Buffer + (StartingIndex / 8));
while (NumberToClear)
{
/* bit shift in current byte */
- shift = StartingIndex & 7;
+ Shift = StartingIndex & 7;
/* number of bits to change in current byte */
- n = (NumberToClear > 8 - shift ) ? 8 - shift : NumberToClear;
+ Count = (NumberToClear > 8 - Shift ) ? 8 - Shift : NumberToClear;
/* adjust byte */
- *p++ &= ~(~(0xFF << n) << shift);
- NumberToClear -= n;
- StartingIndex += n;
+ *Ptr++ &= ~(~(0xFF << Count) << Shift);
+ NumberToClear -= Count;
+ StartingIndex += Count;
+ }
+}
+
+
+ULONG
+STDCALL
+RtlFindClearBits (
+ PRTL_BITMAP BitMapHeader,
+ ULONG NumberToFind,
+ ULONG HintIndex
+ )
+{
+ ULONG Size = BitMapHeader->SizeOfBitMap;
+ ULONG Index;
+ ULONG Count;
+ PCHAR Ptr;
+ CHAR Mask;
+
+ if (NumberToFind > Size || NumberToFind == 0)
+ return -1;
+
+ if (HintIndex >= Size)
+ HintIndex = 0;
+
+ Index = HintIndex;
+ Ptr = (PCHAR)BitMapHeader->Buffer + (Index / 8);
+ Mask = 1 << (Index & 7);
+
+ while (HintIndex < Size)
+ {
+ /* count clear bits */
+ for (Count = 0; Index < Size && ~*Ptr & Mask; Index++)
+ {
+ if (++Count >= NumberToFind)
+ return HintIndex;
+ Mask <<= 1;
+ if (Mask == 0)
+ {
+ Mask = 1;
+ Ptr++;
+ }
+ }
+
+ /* skip set bits */
+ for (; Index < Size && *Ptr & Mask; Index++)
+ {
+ Mask <<= 1;
+ if (Mask == 0)
+ {
+ Mask = 1;
+ Ptr++;
+ }
+ }
+ HintIndex = Index;
+ }
+
+ return -1;
+}
+
+
+ULONG
+STDCALL
+RtlFindClearBitsAndSet (
+ PRTL_BITMAP BitMapHeader,
+ ULONG NumberToFind,
+ ULONG HintIndex
+ )
+{
+ ULONG Index;
+
+ Index = RtlFindClearBits (BitMapHeader,
+ NumberToFind,
+ HintIndex);
+ if (Index != (ULONG)-1)
+ RtlSetBits (BitMapHeader,
+ Index,
+ NumberToFind);
+
+ return Index;
+}
+
+
+ULONG
+STDCALL
+RtlFindFirstRunClear (
+ PRTL_BITMAP BitMapHeader,
+ PULONG StartingIndex
+ )
+{
+ ULONG Size = BitMapHeader->SizeOfBitMap;
+ ULONG Index;
+ ULONG Count;
+ PCHAR Ptr;
+ CHAR Mask;
+
+ if (*StartingIndex > Size)
+ {
+ *StartingIndex = (ULONG)-1;
+ return 0;
+ }
+
+ Index = *StartingIndex;
+ Ptr = (PCHAR)BitMapHeader->Buffer + (Index / 8);
+ Mask = 1 << (Index & 7);
+
+ /* skip set bits */
+ for (; Index < Size && *Ptr & Mask; Index++)
+ {
+ Mask <<= 1;
+ if (Mask == 0)
+ {
+ Mask = 1;
+ Ptr++;
+ }
+ }
+
+ /* return index of first clear bit */
+ if (Index >= Size)
+ {
+ *StartingIndex = (ULONG)-1;
+ return 0;
+ }
+ else
+ *StartingIndex = Index;
+
+ /* count clear bits */
+ for (Count = 0; Index < Size && ~*Ptr & Mask; Index++)
+ {
+ Count++;
+ Mask <<= 1;
+ if (Mask == 0)
+ {
+ Mask = 1;
+ Ptr++;
+ }
+ }
+
+ return Count;
+}
+
+
+ULONG
+STDCALL
+RtlFindFirstRunSet (
+ PRTL_BITMAP BitMapHeader,
+ PULONG StartingIndex
+ )
+{
+ ULONG Size = BitMapHeader->SizeOfBitMap;
+ ULONG Index;
+ ULONG Count;
+ PCHAR Ptr;
+ CHAR Mask;
+
+ if (*StartingIndex > Size)
+ {
+ *StartingIndex = (ULONG)-1;
+ return 0;
+ }
+
+ Index = *StartingIndex;
+ Ptr = (PCHAR)BitMapHeader->Buffer + (Index / 8);
+ Mask = 1 << (Index & 7);
+
+ /* skip clear bits */
+ for (; Index < Size && ~*Ptr & Mask; Index++)
+ {
+ Mask <<= 1;
+ if (Mask == 0)
+ {
+ Mask = 1;
+ Ptr++;
+ }
+ }
+
+ /* return index of first set bit */
+ if (Index >= Size)
+ {
+ *StartingIndex = (ULONG)-1;
+ return 0;
}
+ else
+ *StartingIndex = Index;
+
+ /* count set bits */
+ for (Count = 0; Index < Size && *Ptr & Mask; Index++)
+ {
+ Count++;
+ Mask <<= 1;
+ if (Mask == 0)
+ {
+ Mask = 1;
+ Ptr++;
+ }
+ }
+
+ return Count;
+}
+
+
+ULONG
+STDCALL
+RtlFindLongestRunClear (
+ PRTL_BITMAP BitMapHeader,
+ PULONG StartingIndex
+ )
+{
+ ULONG Size = BitMapHeader->SizeOfBitMap;
+ PCHAR Ptr = (PCHAR)BitMapHeader->Buffer;
+ ULONG Index = 0;
+ ULONG Count;
+ ULONG Max = 0;
+ ULONG Start;
+ ULONG Maxstart = 0;
+ CHAR Mask = 1;
+
+ while (Index < Size)
+ {
+ Start = Index;
+
+ /* count clear bits */
+ for (Count = 0; Index < Size && ~*Ptr & Mask; Index++)
+ {
+ Count++;
+ Mask <<= 1;
+ if (Mask == 0)
+ {
+ Mask = 1;
+ Ptr++;
+ }
+ }
+
+ /* skip set bits */
+ for (; Index < Size && *Ptr & Mask; Index++)
+ {
+ Mask <<= 1;
+ if (Mask == 0)
+ {
+ Mask = 1;
+ Ptr++;
+ }
+ }
+
+ if (Count > Max)
+ {
+ Max = Count;
+ Maxstart = Start;
+ }
+ }
+
+ if (StartingIndex)
+ *StartingIndex = Maxstart;
+
+ return Max;
+}
+
+
+ULONG
+STDCALL
+RtlFindLongestRunSet (
+ PRTL_BITMAP BitMapHeader,
+ PULONG StartingIndex
+ )
+{
+ ULONG Size = BitMapHeader->SizeOfBitMap;
+ PCHAR Ptr = (PCHAR)BitMapHeader->Buffer;
+ ULONG Index = 0;
+ ULONG Count;
+ ULONG Max = 0;
+ ULONG Start;
+ ULONG Maxstart = 0;
+ CHAR Mask = 1;
+
+ while (Index < Size)
+ {
+ Start = Index;
+
+ /* count set bits */
+ for (Count = 0; Index < Size && *Ptr & Mask; Index++)
+ {
+ Count++;
+ Mask <<= 1;
+ if (Mask == 0)
+ {
+ Mask = 1;
+ Ptr++;
+ }
+ }
+
+ /* skip clear bits */
+ for (; Index < Size && ~*Ptr & Mask; Index++)
+ {
+ Mask <<= 1;
+ if (Mask == 0)
+ {
+ Mask = 1;
+ Ptr++;
+ }
+ }
+
+ if (Count > Max)
+ {
+ Max = Count;
+ Maxstart = Start;
+ }
+ }
+
+ if (StartingIndex)
+ *StartingIndex = Maxstart;
+
+ return Max;
+}
+
+
+ULONG
+STDCALL
+RtlFindSetBits (
+ PRTL_BITMAP BitMapHeader,
+ ULONG NumberToFind,
+ ULONG HintIndex
+ )
+{
+ ULONG Size = BitMapHeader->SizeOfBitMap;
+ ULONG Index;
+ ULONG Count;
+ PCHAR Ptr;
+ CHAR Mask;
+
+ if (NumberToFind > Size || NumberToFind == 0)
+ return (ULONG)-1;
+
+ if (HintIndex >= Size)
+ HintIndex = 0;
+
+ Index = HintIndex;
+ Ptr = (PCHAR)BitMapHeader->Buffer + (Index / 8);
+ Mask = 1 << (Index & 7);
+
+ while (HintIndex < Size)
+ {
+ /* count set bits */
+ for (Count = 0; Index < Size && *Ptr & Mask; Index++)
+ {
+ if (++Count >= NumberToFind)
+ return HintIndex;
+ Mask <<= 1;
+ if (Mask == 0)
+ {
+ Mask = 1;
+ Ptr++;
+ }
+ }
+
+ /* skip clear bits */
+ for (; Index < Size && ~*Ptr & Mask; Index++)
+ {
+ Mask <<= 1;
+ if (Mask == 0)
+ {
+ Mask = 1;
+ Ptr++;
+ }
+ }
+ HintIndex = Index;
+ }
+
+ return (ULONG)-1;
+}
+
+
+ULONG
+STDCALL
+RtlFindSetBitsAndClear (
+ PRTL_BITMAP BitMapHeader,
+ ULONG NumberToFind,
+ ULONG HintIndex
+ )
+{
+ ULONG Index;
+
+ Index = RtlFindSetBits (BitMapHeader,
+ NumberToFind,
+ HintIndex);
+ if (Index != (ULONG)-1)
+ RtlClearBits (BitMapHeader,
+ Index,
+ NumberToFind);
+
+ return Index;
+}
+
+
+ULONG
+STDCALL
+RtlNumberOfClearBits (
+ PRTL_BITMAP BitMapHeader
+ )
+{
+ PCHAR Ptr = (PCHAR)BitMapHeader->Buffer;
+ ULONG Size = BitMapHeader->SizeOfBitMap;
+ ULONG Index;
+ ULONG Count;
+ CHAR Mask;
+
+ for (Mask = 1, Index = 0, Count = 0; Index < Size; Index++)
+ {
+ if (~*Ptr & Mask)
+ Count++;
+
+ Mask <<= 1;
+ if (Mask == 0)
+ {
+ Mask = 1;
+ Ptr++;
+ }
+ }
+
+ return Count;
+}
+
+
+ULONG
+STDCALL
+RtlNumberOfSetBits (
+ PRTL_BITMAP BitMapHeader
+ )
+{
+ PCHAR Ptr = (PCHAR)BitMapHeader->Buffer;
+ ULONG Size = BitMapHeader->SizeOfBitMap;
+ ULONG Index;
+ ULONG Count;
+ CHAR Mask;
+
+ for (Mask = 1, Index = 0, Count = 0; Index < Size; Index++)
+ {
+ if (*Ptr & Mask)
+ Count++;
+
+ Mask <<= 1;
+ if (Mask == 0)
+ {
+ Mask = 1;
+ Ptr++;
+ }
+ }
+
+ return Count;
}
ALIGN(BitMapHeader->SizeOfBitMap, 8));
}
+
VOID
STDCALL
RtlSetBits (
)
{
ULONG Size = BitMapHeader->SizeOfBitMap;
- ULONG n;
- ULONG shift;
- PCHAR p;
+ ULONG Count;
+ ULONG Shift;
+ PCHAR Ptr;
if (StartingIndex >= Size || NumberToSet == 0)
return;
if (StartingIndex + NumberToSet > Size)
NumberToSet = Size - StartingIndex;
- p = (PCHAR)BitMapHeader->Buffer + (StartingIndex / 8);
+ Ptr = (PCHAR)BitMapHeader->Buffer + (StartingIndex / 8);
while (NumberToSet)
{
/* bit shift in current byte */
- shift = StartingIndex & 7;
+ Shift = StartingIndex & 7;
/* number of bits to change in current byte */
- n = (NumberToSet > 8 - shift) ? 8 - shift : NumberToSet;
+ Count = (NumberToSet > 8 - Shift) ? 8 - Shift : NumberToSet;
/* adjust byte */
- *p++ |= ~( 0xFF << n ) << shift;
- NumberToSet -= n;
- StartingIndex += n;
+ *Ptr++ |= ~(0xFF << Count) << Shift;
+ NumberToSet -= Count;
+ StartingIndex += Count;
}
}
-
/* EOF */