Subversion Repositories Kolibri OS

Rev

Rev 6934 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6934 Rev 7143
Line 43... Line 43...
43
 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
43
 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
44
 */
44
 */
Line 45... Line 45...
45
 
45
 
46
static inline __attribute_const__ __u16 __fswab16(__u16 val)
46
static inline __attribute_const__ __u16 __fswab16(__u16 val)
47
{
-
 
48
#ifdef __HAVE_BUILTIN_BSWAP16__
-
 
49
	return __builtin_bswap16(val);
47
{
50
#elif defined (__arch_swab16)
48
#if defined (__arch_swab16)
51
	return __arch_swab16(val);
49
	return __arch_swab16(val);
52
#else
50
#else
53
	return ___constant_swab16(val);
51
	return ___constant_swab16(val);
54
#endif
52
#endif
Line 55... Line 53...
55
}
53
}
56
 
54
 
57
static inline __attribute_const__ __u32 __fswab32(__u32 val)
-
 
58
{
-
 
59
#ifdef __HAVE_BUILTIN_BSWAP32__
55
static inline __attribute_const__ __u32 __fswab32(__u32 val)
60
	return __builtin_bswap32(val);
56
{
61
#elif defined(__arch_swab32)
57
#if defined(__arch_swab32)
62
	return __arch_swab32(val);
58
	return __arch_swab32(val);
63
#else
59
#else
64
	return ___constant_swab32(val);
60
	return ___constant_swab32(val);
Line 65... Line 61...
65
#endif
61
#endif
66
}
62
}
67
 
-
 
68
static inline __attribute_const__ __u64 __fswab64(__u64 val)
-
 
69
{
63
 
70
#ifdef __HAVE_BUILTIN_BSWAP64__
64
static inline __attribute_const__ __u64 __fswab64(__u64 val)
71
	return __builtin_bswap64(val);
65
{
72
#elif defined (__arch_swab64)
66
#if defined (__arch_swab64)
73
	return __arch_swab64(val);
67
	return __arch_swab64(val);
74
#elif defined(__SWAB_64_THRU_32__)
68
#elif defined(__SWAB_64_THRU_32__)
Line 100... Line 94...
100
 
94
 
101
/**
95
/**
102
 * __swab16 - return a byteswapped 16-bit value
96
 * __swab16 - return a byteswapped 16-bit value
103
 * @x: value to byteswap
97
 * @x: value to byteswap
-
 
98
 */
-
 
99
#ifdef __HAVE_BUILTIN_BSWAP16__
-
 
100
#define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
104
 */
101
#else
105
#define __swab16(x)				\
102
#define __swab16(x)				\
106
	(__builtin_constant_p((__u16)(x)) ?	\
103
	(__builtin_constant_p((__u16)(x)) ?	\
107
	___constant_swab16(x) :			\
104
	___constant_swab16(x) :			\
-
 
105
	__fswab16(x))
Line 108... Line 106...
108
	__fswab16(x))
106
#endif
109
 
107
 
110
/**
108
/**
111
 * __swab32 - return a byteswapped 32-bit value
109
 * __swab32 - return a byteswapped 32-bit value
-
 
110
 * @x: value to byteswap
-
 
111
 */
-
 
112
#ifdef __HAVE_BUILTIN_BSWAP32__
112
 * @x: value to byteswap
113
#define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
113
 */
114
#else
114
#define __swab32(x)				\
115
#define __swab32(x)				\
115
	(__builtin_constant_p((__u32)(x)) ?	\
116
	(__builtin_constant_p((__u32)(x)) ?	\
-
 
117
	___constant_swab32(x) :			\
Line 116... Line 118...
116
	___constant_swab32(x) :			\
118
	__fswab32(x))
117
	__fswab32(x))
119
#endif
118
 
120
 
119
/**
121
/**
-
 
122
 * __swab64 - return a byteswapped 64-bit value
-
 
123
 * @x: value to byteswap
-
 
124
 */
120
 * __swab64 - return a byteswapped 64-bit value
125
#ifdef __HAVE_BUILTIN_BSWAP64__
121
 * @x: value to byteswap
126
#define __swab64(x) (__u64)__builtin_bswap64((__u64)(x))
122
 */
127
#else
123
#define __swab64(x)				\
128
#define __swab64(x)				\
-
 
129
	(__builtin_constant_p((__u64)(x)) ?	\
Line 124... Line 130...
124
	(__builtin_constant_p((__u64)(x)) ?	\
130
	___constant_swab64(x) :			\
125
	___constant_swab64(x) :			\
131
	__fswab64(x))
126
	__fswab64(x))
132
#endif
127
 
133
 
Line 149... Line 155...
149
 
155
 
150
/**
156
/**
151
 * __swab16p - return a byteswapped 16-bit value from a pointer
157
 * __swab16p - return a byteswapped 16-bit value from a pointer
152
 * @p: pointer to a naturally-aligned 16-bit value
158
 * @p: pointer to a naturally-aligned 16-bit value
153
 */
159
 */
154
static inline __u16 __swab16p(const __u16 *p)
160
static __always_inline __u16 __swab16p(const __u16 *p)
155
{
161
{
156
#ifdef __arch_swab16p
162
#ifdef __arch_swab16p
157
	return __arch_swab16p(p);
163
	return __arch_swab16p(p);
158
#else
164
#else
Line 162... Line 168...
162
 
168
 
163
/**
169
/**
164
 * __swab32p - return a byteswapped 32-bit value from a pointer
170
 * __swab32p - return a byteswapped 32-bit value from a pointer
165
 * @p: pointer to a naturally-aligned 32-bit value
171
 * @p: pointer to a naturally-aligned 32-bit value
166
 */
172
 */
167
static inline __u32 __swab32p(const __u32 *p)
173
static __always_inline __u32 __swab32p(const __u32 *p)
168
{
174
{
169
#ifdef __arch_swab32p
175
#ifdef __arch_swab32p
170
	return __arch_swab32p(p);
176
	return __arch_swab32p(p);
171
#else
177
#else
Line 175... Line 181...
175
 
181
 
176
/**
182
/**
177
 * __swab64p - return a byteswapped 64-bit value from a pointer
183
 * __swab64p - return a byteswapped 64-bit value from a pointer
178
 * @p: pointer to a naturally-aligned 64-bit value
184
 * @p: pointer to a naturally-aligned 64-bit value
179
 */
185
 */
180
static inline __u64 __swab64p(const __u64 *p)
186
static __always_inline __u64 __swab64p(const __u64 *p)
181
{
187
{
182
#ifdef __arch_swab64p
188
#ifdef __arch_swab64p
183
	return __arch_swab64p(p);
189
	return __arch_swab64p(p);
184
#else
190
#else
Line 230... Line 236...
230
}
236
}
231
/**
237
/**
232
 * __swab32s - byteswap a 32-bit value in-place
238
 * __swab32s - byteswap a 32-bit value in-place
233
 * @p: pointer to a naturally-aligned 32-bit value
239
 * @p: pointer to a naturally-aligned 32-bit value
234
 */
240
 */
235
static inline void __swab32s(__u32 *p)
241
static __always_inline void __swab32s(__u32 *p)
236
{
242
{
237
#ifdef __arch_swab32s
243
#ifdef __arch_swab32s
238
	__arch_swab32s(p);
244
	__arch_swab32s(p);
239
#else
245
#else
240
	*p = __swab32p(p);
246
	*p = __swab32p(p);
Line 243... Line 249...
243
 
249
 
244
/**
250
/**
245
 * __swab64s - byteswap a 64-bit value in-place
251
 * __swab64s - byteswap a 64-bit value in-place
246
 * @p: pointer to a naturally-aligned 64-bit value
252
 * @p: pointer to a naturally-aligned 64-bit value
247
 */
253
 */
248
static inline void __swab64s(__u64 *p)
254
static __always_inline void __swab64s(__u64 *p)
249
{
255
{
250
#ifdef __arch_swab64s
256
#ifdef __arch_swab64s
251
	__arch_swab64s(p);
257
	__arch_swab64s(p);
252
#else
258
#else