Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / arch / c6x / include / uapi / asm / swab.h
blobc407c0497718d7ece6bc3def5ecf426c7dafe4f2
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3 * Copyright (C) 2011 Texas Instruments Incorporated
4 * Author: Mark Salter <msalter@redhat.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10 #ifndef _ASM_C6X_SWAB_H
11 #define _ASM_C6X_SWAB_H
13 static inline __attribute_const__ __u16 __c6x_swab16(__u16 val)
15 asm("swap4 .l1 %0,%0\n" : "+a"(val));
16 return val;
19 static inline __attribute_const__ __u32 __c6x_swab32(__u32 val)
21 asm("swap4 .l1 %0,%0\n"
22 "swap2 .l1 %0,%0\n"
23 : "+a"(val));
24 return val;
27 static inline __attribute_const__ __u64 __c6x_swab64(__u64 val)
29 asm(" swap2 .s1 %p0,%P0\n"
30 "|| swap2 .l1 %P0,%p0\n"
31 " swap4 .l1 %p0,%p0\n"
32 " swap4 .l1 %P0,%P0\n"
33 : "+a"(val));
34 return val;
37 static inline __attribute_const__ __u32 __c6x_swahw32(__u32 val)
39 asm("swap2 .l1 %0,%0\n" : "+a"(val));
40 return val;
43 static inline __attribute_const__ __u32 __c6x_swahb32(__u32 val)
45 asm("swap4 .l1 %0,%0\n" : "+a"(val));
46 return val;
49 #define __arch_swab16 __c6x_swab16
50 #define __arch_swab32 __c6x_swab32
51 #define __arch_swab64 __c6x_swab64
52 #define __arch_swahw32 __c6x_swahw32
53 #define __arch_swahb32 __c6x_swahb32
55 #endif /* _ASM_C6X_SWAB_H */