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(
175 /*************************************************************************
178 * Swap the bytes of an unsigned short value.
181 * Based on the inline versions in Wine winternl.h
186 RtlUshortByteSwap (IN USHORT Source
)
188 return (Source
>> 8) | (Source
<< 8);
193 /*************************************************************************
194 * RtlUlongByteSwap [NTDLL.@]
196 * Swap the bytes of an unsigned int value.
199 * Based on the inline versions in Wine winternl.h
209 #if defined(__i386__) && defined(__GNUC__)
211 __asm__("bswap %0" : "=r" (ret
) : "0" (Source
) );
215 return ((ULONG
)RtlUshortByteSwap((USHORT
)Source
) << 16) | RtlUshortByteSwap((USHORT
)(Source
>> 16));
220 /*************************************************************************
221 * RtlUlonglongByteSwap
223 * Swap the bytes of an unsigned long long value.
226 * i [I] Value to swap bytes of
229 * The value with its bytes swapped.
234 RtlUlonglongByteSwap (IN ULONGLONG Source
)
236 return ((ULONGLONG
) RtlUlongByteSwap (Source
) << 32) | RtlUlongByteSwap (Source
>>32);