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 *****************************************************************/
23 /* FUNCTIONS *****************************************************************/
25 /******************************************************************************
26 * RtlCompareMemory [NTDLL.@]
28 * Compare one block of memory with another
31 * Source1 [I] Source block
32 * Source2 [I] Block to compare to Source1
33 * Length [I] Number of bytes to fill
36 * The length of the first byte at which Source1 and Source2 differ, or Length
37 * if they are the same.
42 RtlCompareMemory(IN
const VOID
*Source1
,
43 IN
const VOID
*Source2
,
47 for(i
=0; (i
<Length
) && (((PUCHAR
)Source1
)[i
]==((PUCHAR
)Source2
)[i
]); i
++)
58 RtlCompareMemoryUlong (
64 * FUNCTION: Compares a block of ULONGs with an ULONG and returns the number of equal bytes
66 * Source = Block to compare
67 * Length = Number of bytes to compare
68 * Value = Value to compare
69 * RETURNS: Number of equal bytes
72 PULONG ptr
= (PULONG
)Source
;
73 ULONG len
= Length
/ sizeof(ULONG
);
76 for (i
= 0; i
< len
; i
++)
83 return (ULONG
)((PCHAR
)ptr
- (PCHAR
)Source
);
98 memset(Destination
, Fill
, Length
);
114 PULONG Dest
= Destination
;
115 ULONG Count
= Length
/ sizeof(ULONG
);
150 RtlPrefetchMemoryNonTemporal(
176 /*************************************************************************
179 * Swap the bytes of an unsigned short value.
182 * Based on the inline versions in Wine winternl.h
187 RtlUshortByteSwap (IN USHORT Source
)
189 return (Source
>> 8) | (Source
<< 8);
194 /*************************************************************************
195 * RtlUlongByteSwap [NTDLL.@]
197 * Swap the bytes of an unsigned int value.
200 * Based on the inline versions in Wine winternl.h
210 #if defined(__i386__) && defined(__GNUC__)
212 __asm__("bswap %0" : "=r" (ret
) : "0" (Source
) );
216 return ((ULONG
)RtlUshortByteSwap((USHORT
)Source
) << 16) | RtlUshortByteSwap((USHORT
)(Source
>> 16));
221 /*************************************************************************
222 * RtlUlonglongByteSwap
224 * Swap the bytes of an unsigned long long value.
227 * i [I] Value to swap bytes of
230 * The value with its bytes swapped.
235 RtlUlonglongByteSwap (IN ULONGLONG Source
)
237 return ((ULONGLONG
) RtlUlongByteSwap (Source
) << 32) | RtlUlongByteSwap (Source
>>32);