ReactOS 0.4.15-dev-7842-g558ab78
byteswap.c
Go to the documentation of this file.
1/*
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)
7 */
8
9/* INCLUDES *****************************************************************/
10
11#include <rtl.h>
12
13#define NDEBUG
14#include <debug.h>
15
16#if defined(_M_IX86)
17/* RtlUlonglongByteSwap is broken and cannot be done in C on x86 */
18#error "Use rtlswap.S!"
19#endif
20
21#undef RtlUlonglongByteSwap
22#undef RtlUlongByteSwap
23#undef RtlUshortByteSwap
24
25/*************************************************************************
26 * RtlUshortByteSwap
27 *
28 * Swap the bytes of an unsigned short value.
29 *
30 * NOTES
31 * Based on the inline versions in Wine winternl.h
32 *
33 * @implemented
34 */
39{
40#if defined(_M_AMD64)
42#else
43 return (Source >> 8) | (Source << 8);
44#endif
45}
46
47
48
49/*************************************************************************
50 * RtlUlongByteSwap [NTDLL.@]
51 *
52 * Swap the bytes of an unsigned int value.
53 *
54 * NOTES
55 * Based on the inline versions in Wine winternl.h
56 *
57 * @implemented
58 */
63{
64#if defined(_M_AMD64)
65 return _byteswap_ulong(Source);
66#else
68#endif
69}
70
71
72/*************************************************************************
73 * RtlUlonglongByteSwap
74 *
75 * Swap the bytes of an unsigned long long value.
76 *
77 * PARAMS
78 * i [I] Value to swap bytes of
79 *
80 * RETURNS
81 * The value with its bytes swapped.
82 *
83 * @implemented
84 */
88{
89#if defined(_M_AMD64)
91#else
92 return ((ULONGLONG) RtlUlongByteSwap (Source) << 32) | RtlUlongByteSwap (Source>>32);
93#endif
94}
95
96
97/* EOF */
#define RtlUlongByteSwap(_x)
Definition: compat.h:815
_Check_return_ unsigned __int64 __cdecl _byteswap_uint64(_In_ unsigned __int64)
_Check_return_ unsigned long __cdecl _byteswap_ulong(_In_ unsigned long)
_Check_return_ unsigned short __cdecl _byteswap_ushort(_In_ unsigned short)
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169
#define FASTCALL
Definition: nt_native.h:50
unsigned short USHORT
Definition: pedump.c:61
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
#define RtlUlonglongByteSwap(_x)
Definition: rtlfuncs.h:3199
#define RtlUshortByteSwap(_x)
Definition: rtlfuncs.h:3197