diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/asm-s390/byteorder.h |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'include/asm-s390/byteorder.h')
-rw-r--r-- | include/asm-s390/byteorder.h | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/include/asm-s390/byteorder.h b/include/asm-s390/byteorder.h new file mode 100644 index 000000000000..2cc35a0e188e --- /dev/null +++ b/include/asm-s390/byteorder.h | |||
@@ -0,0 +1,131 @@ | |||
1 | #ifndef _S390_BYTEORDER_H | ||
2 | #define _S390_BYTEORDER_H | ||
3 | |||
4 | /* | ||
5 | * include/asm-s390/byteorder.h | ||
6 | * | ||
7 | * S390 version | ||
8 | * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation | ||
9 | * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) | ||
10 | */ | ||
11 | |||
12 | #include <asm/types.h> | ||
13 | |||
14 | #ifdef __GNUC__ | ||
15 | |||
16 | #ifdef __s390x__ | ||
17 | static __inline__ __u64 ___arch__swab64p(const __u64 *x) | ||
18 | { | ||
19 | __u64 result; | ||
20 | |||
21 | __asm__ __volatile__ ( | ||
22 | " lrvg %0,%1" | ||
23 | : "=d" (result) : "m" (*x) ); | ||
24 | return result; | ||
25 | } | ||
26 | |||
27 | static __inline__ __u64 ___arch__swab64(__u64 x) | ||
28 | { | ||
29 | __u64 result; | ||
30 | |||
31 | __asm__ __volatile__ ( | ||
32 | " lrvgr %0,%1" | ||
33 | : "=d" (result) : "d" (x) ); | ||
34 | return result; | ||
35 | } | ||
36 | |||
37 | static __inline__ void ___arch__swab64s(__u64 *x) | ||
38 | { | ||
39 | *x = ___arch__swab64p(x); | ||
40 | } | ||
41 | #endif /* __s390x__ */ | ||
42 | |||
43 | static __inline__ __u32 ___arch__swab32p(const __u32 *x) | ||
44 | { | ||
45 | __u32 result; | ||
46 | |||
47 | __asm__ __volatile__ ( | ||
48 | #ifndef __s390x__ | ||
49 | " icm %0,8,3(%1)\n" | ||
50 | " icm %0,4,2(%1)\n" | ||
51 | " icm %0,2,1(%1)\n" | ||
52 | " ic %0,0(%1)" | ||
53 | : "=&d" (result) : "a" (x), "m" (*x) : "cc" ); | ||
54 | #else /* __s390x__ */ | ||
55 | " lrv %0,%1" | ||
56 | : "=d" (result) : "m" (*x) ); | ||
57 | #endif /* __s390x__ */ | ||
58 | return result; | ||
59 | } | ||
60 | |||
61 | static __inline__ __u32 ___arch__swab32(__u32 x) | ||
62 | { | ||
63 | #ifndef __s390x__ | ||
64 | return ___arch__swab32p(&x); | ||
65 | #else /* __s390x__ */ | ||
66 | __u32 result; | ||
67 | |||
68 | __asm__ __volatile__ ( | ||
69 | " lrvr %0,%1" | ||
70 | : "=d" (result) : "d" (x) ); | ||
71 | return result; | ||
72 | #endif /* __s390x__ */ | ||
73 | } | ||
74 | |||
75 | static __inline__ void ___arch__swab32s(__u32 *x) | ||
76 | { | ||
77 | *x = ___arch__swab32p(x); | ||
78 | } | ||
79 | |||
80 | static __inline__ __u16 ___arch__swab16p(const __u16 *x) | ||
81 | { | ||
82 | __u16 result; | ||
83 | |||
84 | __asm__ __volatile__ ( | ||
85 | #ifndef __s390x__ | ||
86 | " icm %0,2,1(%1)\n" | ||
87 | " ic %0,0(%1)\n" | ||
88 | : "=&d" (result) : "a" (x), "m" (*x) : "cc" ); | ||
89 | #else /* __s390x__ */ | ||
90 | " lrvh %0,%1" | ||
91 | : "=d" (result) : "m" (*x) ); | ||
92 | #endif /* __s390x__ */ | ||
93 | return result; | ||
94 | } | ||
95 | |||
96 | static __inline__ __u16 ___arch__swab16(__u16 x) | ||
97 | { | ||
98 | return ___arch__swab16p(&x); | ||
99 | } | ||
100 | |||
101 | static __inline__ void ___arch__swab16s(__u16 *x) | ||
102 | { | ||
103 | *x = ___arch__swab16p(x); | ||
104 | } | ||
105 | |||
106 | #ifdef __s390x__ | ||
107 | #define __arch__swab64(x) ___arch__swab64(x) | ||
108 | #define __arch__swab64p(x) ___arch__swab64p(x) | ||
109 | #define __arch__swab64s(x) ___arch__swab64s(x) | ||
110 | #endif /* __s390x__ */ | ||
111 | #define __arch__swab32(x) ___arch__swab32(x) | ||
112 | #define __arch__swab16(x) ___arch__swab16(x) | ||
113 | #define __arch__swab32p(x) ___arch__swab32p(x) | ||
114 | #define __arch__swab16p(x) ___arch__swab16p(x) | ||
115 | #define __arch__swab32s(x) ___arch__swab32s(x) | ||
116 | #define __arch__swab16s(x) ___arch__swab16s(x) | ||
117 | |||
118 | #ifndef __s390x__ | ||
119 | #if !defined(__STRICT_ANSI__) || defined(__KERNEL__) | ||
120 | # define __BYTEORDER_HAS_U64__ | ||
121 | # define __SWAB_64_THRU_32__ | ||
122 | #endif | ||
123 | #else /* __s390x__ */ | ||
124 | #define __BYTEORDER_HAS_U64__ | ||
125 | #endif /* __s390x__ */ | ||
126 | |||
127 | #endif /* __GNUC__ */ | ||
128 | |||
129 | #include <linux/byteorder/big_endian.h> | ||
130 | |||
131 | #endif /* _S390_BYTEORDER_H */ | ||