xref: /linux/arch/m68k/include/uapi/asm/swab.h (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef _M68K_SWAB_H
3 #define _M68K_SWAB_H
4 
5 #include <linux/types.h>
6 #include <linux/compiler.h>
7 
8 #define __SWAB_64_THRU_32__
9 
10 #if defined (__mcfisaaplus__) || defined (__mcfisac__)
11 static inline __attribute_const__ __u32 __arch_swab32(__u32 val)
12 {
13 	__asm__("byterev %0" : "=d" (val) : "0" (val));
14 	return val;
15 }
16 
17 #define __arch_swab32 __arch_swab32
18 #elif !defined(__mcoldfire__)
19 
20 static inline __attribute_const__ __u32 __arch_swab32(__u32 val)
21 {
22 	__asm__("rolw #8,%0; swap %0; rolw #8,%0" : "=d" (val) : "0" (val));
23 	return val;
24 }
25 #define __arch_swab32 __arch_swab32
26 #endif
27 
28 #endif /* _M68K_SWAB_H */
29