2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: lib/rtl/byteswap.c
5 * PURPOSE: Memory functions
6 * PROGRAMMER: David Welch (welch@mcmail.com)
9 /* INCLUDES *****************************************************************/
17 /* RtlUlonglongByteSwap is broken and cannot be done in C on x86 */
18 #error "Use rtlswap.S!"
21 #undef RtlUlonglongByteSwap
22 #undef RtlUlongByteSwap
23 #undef RtlUshortByteSwap
25 /*************************************************************************
28 * Swap the bytes of an unsigned short value.
31 * Based on the inline versions in Wine winternl.h
41 return _byteswap_ushort(Source
);
43 return (Source
>> 8) | (Source
<< 8);
49 /*************************************************************************
50 * RtlUlongByteSwap [NTDLL.@]
52 * Swap the bytes of an unsigned int value.
55 * Based on the inline versions in Wine winternl.h
65 return _byteswap_ulong(Source
);
67 return ((ULONG
)RtlUshortByteSwap((USHORT
)Source
) << 16) | RtlUshortByteSwap((USHORT
)(Source
>> 16));
72 /*************************************************************************
73 * RtlUlonglongByteSwap
75 * Swap the bytes of an unsigned long long value.
78 * i [I] Value to swap bytes of
81 * The value with its bytes swapped.
90 return _byteswap_uint64(Source
);
92 return ((ULONGLONG
) RtlUlongByteSwap (Source
) << 32) | RtlUlongByteSwap (Source
>>32);