4 * COPYRIGHT: See COPYING in the top level directory
5 * PROJECT: ReactOS kernel
7 * PURPOSE: Memory functions
8 * PROGRAMMER: David Welch (welch@mcmail.com)
13 /* INCLUDES *****************************************************************/
15 #include <ddk/ntddk.h>
24 /* FUNCTIONS *****************************************************************/
26 /******************************************************************************
27 * RtlCompareMemory [NTDLL.@]
29 * Compare one block of memory with another
32 * Source1 [I] Source block
33 * Source2 [I] Block to compare to Source1
34 * Length [I] Number of bytes to fill
37 * The length of the first byte at which Source1 and Source2 differ, or Length
38 * if they are the same.
43 RtlCompareMemory(IN
const VOID
*Source1
,
44 IN
const VOID
*Source2
,
48 for(i
=0; (i
<Length
) && (((PUCHAR
)Source1
)[i
]==((PUCHAR
)Source2
)[i
]); i
++)
59 RtlCompareMemoryUlong (
65 * FUNCTION: Compares a block of ULONGs with an ULONG and returns the number of equal bytes
67 * Source = Block to compare
68 * Length = Number of bytes to compare
69 * Value = Value to compare
70 * RETURNS: Number of equal bytes
73 PULONG ptr
= (PULONG
)Source
;
74 ULONG len
= Length
/ sizeof(ULONG
);
77 for (i
= 0; i
< len
; i
++)
84 return (ULONG
)((PCHAR
)ptr
- (PCHAR
)Source
);
99 memset(Destination
, Fill
, Length
);
115 PULONG Dest
= Destination
;
116 ULONG Count
= Length
/ sizeof(ULONG
);
151 RtlPrefetchMemoryNonTemporal(
177 /*************************************************************************
180 * Swap the bytes of an unsigned short value.
183 * Based on the inline versions in Wine winternl.h
188 RtlUshortByteSwap (IN USHORT Source
)
190 return (Source
>> 8) | (Source
<< 8);
195 /*************************************************************************
196 * RtlUlongByteSwap [NTDLL.@]
198 * Swap the bytes of an unsigned int value.
201 * Based on the inline versions in Wine winternl.h
211 #if defined(__i386__) && defined(__GNUC__)
213 __asm__("bswap %0" : "=r" (ret
) : "0" (Source
) );
217 return ((ULONG
)RtlUshortByteSwap((USHORT
)Source
) << 16) | RtlUshortByteSwap((USHORT
)(Source
>> 16));
222 /*************************************************************************
223 * RtlUlonglongByteSwap
225 * Swap the bytes of an unsigned long long value.
228 * i [I] Value to swap bytes of
231 * The value with its bytes swapped.
236 RtlUlonglongByteSwap (IN ULONGLONG Source
)
238 return ((ULONGLONG
) RtlUlongByteSwap (Source
) << 32) | RtlUlongByteSwap (Source
>>32);