Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
nu11secur1ty
GitHub Repository: nu11secur1ty/Kali-Linux
Path: blob/master/ALFA-W1F1/RTL8814AU/include/byteorder/swab.h
1307 views
1
/******************************************************************************
2
*
3
* Copyright(c) 2007 - 2017 Realtek Corporation.
4
*
5
* This program is free software; you can redistribute it and/or modify it
6
* under the terms of version 2 of the GNU General Public License as
7
* published by the Free Software Foundation.
8
*
9
* This program is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
* more details.
13
*
14
*****************************************************************************/
15
#ifndef _LINUX_BYTEORDER_SWAB_H
16
#define _LINUX_BYTEORDER_SWAB_H
17
18
#if !defined(CONFIG_PLATFORM_MSTAR)
19
#ifndef __u16
20
typedef unsigned short __u16;
21
#endif
22
23
#ifndef __u32
24
typedef unsigned int __u32;
25
#endif
26
27
#ifndef __u8
28
typedef unsigned char __u8;
29
#endif
30
31
#ifndef __u64
32
typedef unsigned long long __u64;
33
#endif
34
35
36
__inline static __u16 ___swab16(__u16 x)
37
{
38
__u16 __x = x;
39
return
40
(__u16)(
41
(((__u16)(__x)&(__u16)0x00ffU) << 8) |
42
(((__u16)(__x)&(__u16)0xff00U) >> 8));
43
44
}
45
46
__inline static __u32 ___swab32(__u32 x)
47
{
48
__u32 __x = (x);
49
return (__u32)(
50
(((__u32)(__x)&(__u32)0x000000ffUL) << 24) |
51
(((__u32)(__x)&(__u32)0x0000ff00UL) << 8) |
52
(((__u32)(__x)&(__u32)0x00ff0000UL) >> 8) |
53
(((__u32)(__x)&(__u32)0xff000000UL) >> 24));
54
}
55
56
__inline static __u64 ___swab64(__u64 x)
57
{
58
__u64 __x = (x);
59
60
return
61
(__u64)(\
62
(__u64)(((__u64)(__x)&(__u64)0x00000000000000ffULL) << 56) | \
63
(__u64)(((__u64)(__x)&(__u64)0x000000000000ff00ULL) << 40) | \
64
(__u64)(((__u64)(__x)&(__u64)0x0000000000ff0000ULL) << 24) | \
65
(__u64)(((__u64)(__x)&(__u64)0x00000000ff000000ULL) << 8) | \
66
(__u64)(((__u64)(__x)&(__u64)0x000000ff00000000ULL) >> 8) | \
67
(__u64)(((__u64)(__x)&(__u64)0x0000ff0000000000ULL) >> 24) | \
68
(__u64)(((__u64)(__x)&(__u64)0x00ff000000000000ULL) >> 40) | \
69
(__u64)(((__u64)(__x)&(__u64)0xff00000000000000ULL) >> 56));
70
\
71
}
72
#endif /* CONFIG_PLATFORM_MSTAR */
73
74
#ifndef __arch__swab16
75
__inline static __u16 __arch__swab16(__u16 x)
76
{
77
return ___swab16(x);
78
}
79
80
#endif
81
82
#ifndef __arch__swab32
83
__inline static __u32 __arch__swab32(__u32 x)
84
{
85
__u32 __tmp = (x) ;
86
return ___swab32(__tmp);
87
}
88
#endif
89
90
#ifndef __arch__swab64
91
92
__inline static __u64 __arch__swab64(__u64 x)
93
{
94
__u64 __tmp = (x) ;
95
return ___swab64(__tmp);
96
}
97
98
99
#endif
100
101
#ifndef __swab16
102
#define __swab16(x) __fswab16(x)
103
#define __swab32(x) __fswab32(x)
104
#define __swab64(x) __fswab64(x)
105
#endif /* __swab16 */
106
107
#ifdef PLATFORM_FREEBSD
108
__inline static __u16 __fswab16(__u16 x)
109
#else
110
__inline static const __u16 __fswab16(__u16 x)
111
#endif /* PLATFORM_FREEBSD */
112
{
113
return __arch__swab16(x);
114
}
115
#ifdef PLATFORM_FREEBSD
116
__inline static __u32 __fswab32(__u32 x)
117
#else
118
__inline static const __u32 __fswab32(__u32 x)
119
#endif /* PLATFORM_FREEBSD */
120
{
121
return __arch__swab32(x);
122
}
123
124
#if defined(PLATFORM_LINUX) || defined(PLATFORM_WINDOWS)
125
#define swab16 __swab16
126
#define swab32 __swab32
127
#define swab64 __swab64
128
#define swab16p __swab16p
129
#define swab32p __swab32p
130
#define swab64p __swab64p
131
#define swab16s __swab16s
132
#define swab32s __swab32s
133
#define swab64s __swab64s
134
#endif
135
136
#endif /* _LINUX_BYTEORDER_SWAB_H */
137
138