Linux 2.6.39-rc2
[pohmelfs.git] / arch / blackfin / include / asm / swab.h
blob89de6507ca2bbd38adcae0503fafff08b8fae61f
1 /*
2 * Copyright 2009 Analog Devices Inc.
4 * Licensed under the GPL-2 or later.
5 */
7 #ifndef _BLACKFIN_SWAB_H
8 #define _BLACKFIN_SWAB_H
10 #include <linux/types.h>
11 #include <asm-generic/swab.h>
13 #ifdef __GNUC__
15 static __inline__ __attribute_const__ __u32 __arch_swahb32(__u32 xx)
17 __u32 tmp;
18 __asm__("%1 = %0 >> 8 (V);\n\t"
19 "%0 = %0 << 8 (V);\n\t"
20 "%0 = %0 | %1;\n\t"
21 : "+d"(xx), "=&d"(tmp));
22 return xx;
24 #define __arch_swahb32 __arch_swahb32
26 static __inline__ __attribute_const__ __u32 __arch_swahw32(__u32 xx)
28 __u32 rv;
29 __asm__("%0 = PACK(%1.L, %1.H);\n\t": "=d"(rv): "d"(xx));
30 return rv;
32 #define __arch_swahw32 __arch_swahw32
34 static __inline__ __attribute_const__ __u32 __arch_swab32(__u32 xx)
36 return __arch_swahb32(__arch_swahw32(xx));
38 #define __arch_swab32 __arch_swab32
40 static __inline__ __attribute_const__ __u16 __arch_swab16(__u16 xx)
42 __u32 xw = xx;
43 __asm__("%0 <<= 8;\n %0.L = %0.L + %0.H (NS);\n": "+d"(xw));
44 return (__u16)xw;
46 #define __arch_swab16 __arch_swab16
48 #endif /* __GNUC__ */
50 #endif /* _BLACKFIN_SWAB_H */