Merge tag 'sound-6.13-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai...
[linux.git] / arch / sh / include / uapi / asm / swab.h
blobc727d381a30affe6a243f2139000e29778845706
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef __ASM_SH_SWAB_H
3 #define __ASM_SH_SWAB_H
5 /*
6 * Copyright (C) 1999 Niibe Yutaka
7 * Copyright (C) 2000, 2001 Paolo Alberelli
8 */
9 #include <linux/compiler.h>
10 #include <linux/types.h>
11 #include <asm-generic/swab.h>
13 static inline __attribute_const__ __u32 __arch_swab32(__u32 x)
15 __asm__(
16 "swap.b %1, %0\n\t"
17 "swap.w %0, %0\n\t"
18 "swap.b %0, %0"
19 : "=r" (x)
20 : "r" (x));
22 return x;
24 #define __arch_swab32 __arch_swab32
26 static inline __attribute_const__ __u16 __arch_swab16(__u16 x)
28 __asm__(
29 "swap.b %1, %0"
30 : "=r" (x)
31 : "r" (x));
33 return x;
35 #define __arch_swab16 __arch_swab16
37 static inline __u64 __arch_swab64(__u64 val)
39 union {
40 struct { __u32 a,b; } s;
41 __u64 u;
42 } v, w;
43 v.u = val;
44 w.s.b = __arch_swab32(v.s.a);
45 w.s.a = __arch_swab32(v.s.b);
46 return w.u;
48 #define __arch_swab64 __arch_swab64
50 #endif /* __ASM_SH_SWAB_H */