Revert 45697:
[reactos.git] / lib / rtl / memgen.c
1 /* COPYRIGHT: See COPYING in the top level directory
2 * PROJECT: ReactOS system libraries
3 * FILE: lib/rtl/mem.c
4 * PURPOSE: Memory functions
5 * PROGRAMMER: David Welch (welch@mcmail.com)
6 */
7
8 /* INCLUDES *****************************************************************/
9
10 #include <rtl.h>
11
12 #define NDEBUG
13 #include <debug.h>
14
15 #undef RtlUlonglongByteSwap
16 #undef RtlUlongByteSwap
17 #undef RtlUshortByteSwap
18
19 /*************************************************************************
20 * RtlUshortByteSwap
21 *
22 * Swap the bytes of an unsigned short value.
23 *
24 * NOTES
25 * Based on the inline versions in Wine winternl.h
26 *
27 * @implemented
28 */
29 USHORT FASTCALL
30 RtlUshortByteSwap (IN USHORT Source)
31 {
32 return (Source >> 8) | (Source << 8);
33 }
34
35
36
37 /*************************************************************************
38 * RtlUlongByteSwap [NTDLL.@]
39 *
40 * Swap the bytes of an unsigned int value.
41 *
42 * NOTES
43 * Based on the inline versions in Wine winternl.h
44 *
45 * @implemented
46 */
47 ULONG
48 FASTCALL
49 RtlUlongByteSwap(
50 IN ULONG Source
51 )
52 {
53 return ((ULONG)RtlUshortByteSwap((USHORT)Source) << 16) | RtlUshortByteSwap((USHORT)(Source >> 16));
54 }
55
56
57 /*************************************************************************
58 * RtlUlonglongByteSwap
59 *
60 * Swap the bytes of an unsigned long long value.
61 *
62 * PARAMS
63 * i [I] Value to swap bytes of
64 *
65 * RETURNS
66 * The value with its bytes swapped.
67 *
68 * @implemented
69 */
70 ULONGLONG FASTCALL
71 RtlUlonglongByteSwap (IN ULONGLONG Source)
72 {
73 return ((ULONGLONG) RtlUlongByteSwap (Source) << 32) | RtlUlongByteSwap (Source>>32);
74 }
75
76
77 /* EOF */