WIP FPC-III support
[linux/fpc-iii.git] / arch / nds32 / include / asm / swab.h
blob362a466f2976a7ebea95ea22f1669027ff37abe8
1 /* SPDX-License-Identifier: GPL-2.0 */
2 // Copyright (C) 2005-2017 Andes Technology Corporation
4 #ifndef __NDS32_SWAB_H__
5 #define __NDS32_SWAB_H__
7 #include <linux/types.h>
8 #include <linux/compiler.h>
10 static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x)
12 __asm__("wsbh %0, %0\n\t" /* word swap byte within halfword */
13 "rotri %0, %0, #16\n"
14 :"=r"(x)
15 :"0"(x));
16 return x;
19 static __inline__ __attribute_const__ __u16 ___arch__swab16(__u16 x)
21 __asm__("wsbh %0, %0\n" /* word swap byte within halfword */
22 :"=r"(x)
23 :"0"(x));
24 return x;
27 #define __arch_swab32(x) ___arch__swab32(x)
28 #define __arch_swab16(x) ___arch__swab16(x)
30 #if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
31 #define __BYTEORDER_HAS_U64__
32 #define __SWAB_64_THRU_32__
33 #endif
35 #endif /* __NDS32_SWAB_H__ */