1 /* COPYRIGHT: See COPYING in the top level directory
2 * PROJECT: ReactOS system libraries
4 * PURPOSE: Memory functions
5 * PROGRAMMER: David Welch (welch@mcmail.com)
8 /* INCLUDES *****************************************************************/
15 #undef RtlUlonglongByteSwap
16 #undef RtlUlongByteSwap
17 #undef RtlUshortByteSwap
19 /* FUNCTIONS *****************************************************************/
21 /******************************************************************************
22 * RtlCompareMemory [NTDLL.@]
24 * Compare one block of memory with another
27 * Source1 [I] Source block
28 * Source2 [I] Block to compare to Source1
29 * Length [I] Number of bytes to fill
32 * The length of the first byte at which Source1 and Source2 differ, or Length
33 * if they are the same.
38 RtlCompareMemory(IN
const VOID
*Source1
,
39 IN
const VOID
*Source2
,
43 for(i
=0; (i
<Length
) && (((PUCHAR
)Source1
)[i
]==((PUCHAR
)Source2
)[i
]); i
++)
54 RtlCompareMemoryUlong (
60 * FUNCTION: Compares a block of ULONGs with an ULONG and returns the number of equal bytes
62 * Source = Block to compare
63 * Length = Number of bytes to compare
64 * Value = Value to compare
65 * RETURNS: Number of equal bytes
68 PULONG ptr
= (PULONG
)Source
;
69 ULONG len
= Length
/ sizeof(ULONG
);
72 for (i
= 0; i
< len
; i
++)
79 return (ULONG
)((PCHAR
)ptr
- (PCHAR
)Source
);
95 memset(Destination
, Fill
, Length
);
111 PULONG Dest
= Destination
;
112 ULONG Count
= Length
/ sizeof(ULONG
);
147 RtlPrefetchMemoryNonTemporal(
152 /* By nature of prefetch, this is non-portable. */
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);