Merge tag 'v3.3.7' into 3.3/master
[zen-stable.git] / arch / c6x / include / asm / swab.h
blobfd4bb0520e5e86efdac59b5e6e68b51e3fcd9bc4
1 /*
2 * Copyright (C) 2011 Texas Instruments Incorporated
3 * Author: Mark Salter <msalter@redhat.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9 #ifndef _ASM_C6X_SWAB_H
10 #define _ASM_C6X_SWAB_H
12 static inline __attribute_const__ __u16 __c6x_swab16(__u16 val)
14 asm("swap4 .l1 %0,%0\n" : "+a"(val));
15 return val;
18 static inline __attribute_const__ __u32 __c6x_swab32(__u32 val)
20 asm("swap4 .l1 %0,%0\n"
21 "swap2 .l1 %0,%0\n"
22 : "+a"(val));
23 return val;
26 static inline __attribute_const__ __u64 __c6x_swab64(__u64 val)
28 asm(" swap2 .s1 %p0,%P0\n"
29 "|| swap2 .l1 %P0,%p0\n"
30 " swap4 .l1 %p0,%p0\n"
31 " swap4 .l1 %P0,%P0\n"
32 : "+a"(val));
33 return val;
36 static inline __attribute_const__ __u32 __c6x_swahw32(__u32 val)
38 asm("swap2 .l1 %0,%0\n" : "+a"(val));
39 return val;
42 static inline __attribute_const__ __u32 __c6x_swahb32(__u32 val)
44 asm("swap4 .l1 %0,%0\n" : "+a"(val));
45 return val;
48 #define __arch_swab16 __c6x_swab16
49 #define __arch_swab32 __c6x_swab32
50 #define __arch_swab64 __c6x_swab64
51 #define __arch_swahw32 __c6x_swahw32
52 #define __arch_swahb32 __c6x_swahb32
54 #endif /* _ASM_C6X_SWAB_H */