aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/include/asm/byteorder.h
diff options
context:
space:
mode:
authorHarvey Harrison <harvey.harrison@gmail.com>2009-01-06 17:56:25 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-01-06 21:10:27 -0500
commit1af84a625356768ab1f9687b70c825250123d7fd (patch)
tree9bf824eab0ccaed29b217964d4ec5d0bc715fcc8 /arch/sh/include/asm/byteorder.h
parent13f7877bb5aeb1d5ad01ffbf17a80fb550fa6642 (diff)
sh: introduce asm/swab.h
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/sh/include/asm/byteorder.h')
-rw-r--r--arch/sh/include/asm/byteorder.h62
1 files changed, 3 insertions, 59 deletions
diff --git a/arch/sh/include/asm/byteorder.h b/arch/sh/include/asm/byteorder.h
index f5fa0653ebc6..e95c41a5c8cc 100644
--- a/arch/sh/include/asm/byteorder.h
+++ b/arch/sh/include/asm/byteorder.h
@@ -1,68 +1,12 @@
1#ifndef __ASM_SH_BYTEORDER_H 1#ifndef __ASM_SH_BYTEORDER_H
2#define __ASM_SH_BYTEORDER_H 2#define __ASM_SH_BYTEORDER_H
3 3
4/* 4#include <asm/swab.h>
5 * Copyright (C) 1999 Niibe Yutaka
6 * Copyright (C) 2000, 2001 Paolo Alberelli
7 */
8#include <linux/compiler.h>
9#include <linux/types.h>
10 5
11#ifdef __LITTLE_ENDIAN__ 6#ifdef __LITTLE_ENDIAN__
12# define __LITTLE_ENDIAN 7#include <linux/byteorder/little_endian.h>
13#else 8#else
14# define __BIG_ENDIAN 9#include <linux/byteorder/big_endian.h>
15#endif 10#endif
16 11
17#define __SWAB_64_THRU_32__
18
19static inline __attribute_const__ __u32 __arch_swab32(__u32 x)
20{
21 __asm__(
22#ifdef __SH5__
23 "byterev %0, %0\n\t"
24 "shari %0, 32, %0"
25#else
26 "swap.b %0, %0\n\t"
27 "swap.w %0, %0\n\t"
28 "swap.b %0, %0"
29#endif
30 : "=r" (x)
31 : "0" (x));
32
33 return x;
34}
35#define __arch_swab32 __arch_swab32
36
37static inline __attribute_const__ __u16 __arch_swab16(__u16 x)
38{
39 __asm__(
40#ifdef __SH5__
41 "byterev %0, %0\n\t"
42 "shari %0, 32, %0"
43#else
44 "swap.b %0, %0"
45#endif
46 : "=r" (x)
47 : "0" (x));
48
49 return x;
50}
51#define __arch_swab16 __arch_swab16
52
53static inline __u64 __arch_swab64(__u64 val)
54{
55 union {
56 struct { __u32 a,b; } s;
57 __u64 u;
58 } v, w;
59 v.u = val;
60 w.s.b = __arch_swab32(v.s.a);
61 w.s.a = __arch_swab32(v.s.b);
62 return w.u;
63}
64#define __arch_swab64 __arch_swab64
65
66#include <linux/byteorder.h>
67
68#endif /* __ASM_SH_BYTEORDER_H */ 12#endif /* __ASM_SH_BYTEORDER_H */