Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / arch / blackfin / include / uapi / asm / swab.h
blobd3437933b95fd037246c4169654bb6ef48a27554
1 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2 /*
3 * Copyright 2009 Analog Devices Inc.
5 * Licensed under the GPL-2 or later.
6 */
8 #ifndef _UAPI_BLACKFIN_SWAB_H
9 #define _UAPI_BLACKFIN_SWAB_H
11 #include <linux/types.h>
12 #include <asm-generic/swab.h>
14 #ifdef __GNUC__
16 static __inline__ __attribute_const__ __u32 __arch_swahb32(__u32 xx)
18 __u32 tmp;
19 __asm__("%1 = %0 >> 8 (V);\n\t"
20 "%0 = %0 << 8 (V);\n\t"
21 "%0 = %0 | %1;\n\t"
22 : "+d"(xx), "=&d"(tmp));
23 return xx;
25 #define __arch_swahb32 __arch_swahb32
27 static __inline__ __attribute_const__ __u32 __arch_swahw32(__u32 xx)
29 __u32 rv;
30 __asm__("%0 = PACK(%1.L, %1.H);\n\t": "=d"(rv): "d"(xx));
31 return rv;
33 #define __arch_swahw32 __arch_swahw32
35 static __inline__ __attribute_const__ __u32 __arch_swab32(__u32 xx)
37 return __arch_swahb32(__arch_swahw32(xx));
39 #define __arch_swab32 __arch_swab32
41 static __inline__ __attribute_const__ __u16 __arch_swab16(__u16 xx)
43 __u32 xw = xx;
44 __asm__("%0 <<= 8;\n %0.L = %0.L + %0.H (NS);\n": "+d"(xw));
45 return (__u16)xw;
47 #define __arch_swab16 __arch_swab16
49 #endif /* __GNUC__ */
51 #endif /* _UAPI_BLACKFIN_SWAB_H */