File 0001-debian-ports.patch of Package leveldb
206
1
Description: Add support for most of Debian architectures
2
Author: Nobuhiro Iwamatsu <iwamatsu@debian.org>
3
---
4
port/atomic_pointer.h | 136 ++++++++++++++++++++++++++++++++++++++++++++++----
5
1 file changed, 126 insertions(+), 10 deletions(-)
6
7
Index: leveldb-1.18/port/atomic_pointer.h
8
===================================================================
9
--- leveldb-1.18.orig/port/atomic_pointer.h
10
+++ leveldb-1.18/port/atomic_pointer.h
11
12
#define ARCH_CPU_ARM_FAMILY 1
13
#elif defined(__ppc__) || defined(__powerpc__) || defined(__powerpc64__)
14
#define ARCH_CPU_PPC_FAMILY 1
15
+#elif defined(__ia64__)
16
+#define ARCH_CPU_IA64_FAMILY 1
17
+#elif defined(__alpha__)
18
+#define ARCH_CPU_ALPHA_FAMILY 1
19
+#elif defined(__s390x__) || defined(__s390__)
20
+#define ARCH_CPU_S390_FAMILY 1
21
+#elif defined(__sparc__) || defined(__sparc64__)
22
+#define ARCH_CPU_SPARC_FAMILY 1
23
+#elif defined(__sh__)
24
+#define ARCH_CPU_SH_FAMILY 1
25
+#elif defined(__hppa__) || defined(__parisc__)
26
+#define ARCH_CPU_PARISC_FAMILY 1
27
#endif
28
29
namespace leveldb {
30
31
// http://msdn.microsoft.com/en-us/library/ms684208(v=vs.85).aspx
32
#define LEVELDB_HAVE_MEMORY_BARRIER
33
34
+#define ReadMemoryBarrier MemoryBarrier()
35
+#define WriteMemoryBarrier MemoryBarrier()
36
+
37
// Mac OS
38
#elif defined(OS_MACOSX)
39
-inline void MemoryBarrier() {
40
+inline void ReadMemoryBarrier() {
41
+ OSMemoryBarrier();
42
+}
43
+inline void WriteMemoryBarrier() {
44
OSMemoryBarrier();
45
}
46
#define LEVELDB_HAVE_MEMORY_BARRIER
47
48
// Gcc on x86
49
#elif defined(ARCH_CPU_X86_FAMILY) && defined(__GNUC__)
50
-inline void MemoryBarrier() {
51
+inline void ReadMemoryBarrier() {
52
+ // See http://gcc.gnu.org/ml/gcc/2003-04/msg01180.html for a discussion on
53
+ // this idiom. Also see http://en.wikipedia.org/wiki/Memory_ordering.
54
+ __asm__ __volatile__("" : : : "memory");
55
+}
56
+inline void WriteMemoryBarrier() {
57
// See http://gcc.gnu.org/ml/gcc/2003-04/msg01180.html for a discussion on
58
// this idiom. Also see http://en.wikipedia.org/wiki/Memory_ordering.
59
__asm__ __volatile__("" : : : "memory");
60
61
62
// Sun Studio
63
#elif defined(ARCH_CPU_X86_FAMILY) && defined(__SUNPRO_CC)
64
-inline void MemoryBarrier() {
65
+inline void ReadMemoryBarrier() {
66
+ // See http://gcc.gnu.org/ml/gcc/2003-04/msg01180.html for a discussion on
67
+ // this idiom. Also see http://en.wikipedia.org/wiki/Memory_ordering.
68
+ asm volatile("" : : : "memory");
69
+}
70
+inline void WriteMemoryBarrier() {
71
// See http://gcc.gnu.org/ml/gcc/2003-04/msg01180.html for a discussion on
72
// this idiom. Also see http://en.wikipedia.org/wiki/Memory_ordering.
73
asm volatile("" : : : "memory");
74
75
// shows that the extra function call cost is completely negligible on
76
// multi-core devices.
77
//
78
-inline void MemoryBarrier() {
79
+inline void ReadMemoryBarrier() {
80
+ (*(LinuxKernelMemoryBarrierFunc)0xffff0fa0)();
81
+}
82
+inline void WriteMemoryBarrier() {
83
(*(LinuxKernelMemoryBarrierFunc)0xffff0fa0)();
84
}
85
#define LEVELDB_HAVE_MEMORY_BARRIER
86
87
// PPC
88
#elif defined(ARCH_CPU_PPC_FAMILY) && defined(__GNUC__)
89
-inline void MemoryBarrier() {
90
- // TODO for some powerpc expert: is there a cheaper suitable variant?
91
- // Perhaps by having separate barriers for acquire and release ops.
92
- asm volatile("sync" : : : "memory");
93
+
94
+inline void ReadMemoryBarrier() {
95
+#ifdef __powerpc64__
96
+ __asm__ __volatile__ ("lwsync" : : : "memory");
97
+#else
98
+ __asm__ __volatile__ ("sync" : : : "memory");
99
+#endif
100
+}
101
+inline void WriteMemoryBarrier() {
102
+ __asm__ __volatile__ ("sync" : : : "memory");
103
+}
104
+#define LEVELDB_HAVE_MEMORY_BARRIER
105
+
106
+// IA64
107
+#elif defined(ARCH_CPU_IA64_FAMILY)
108
+inline void ReadMemoryBarrier() {
109
+ __asm__ __volatile__ ("mf" : : : "memory");
110
+}
111
+inline void WriteMemoryBarrier() {
112
+ __asm__ __volatile__ ("mf" : : : "memory");
113
+}
114
+#define LEVELDB_HAVE_MEMORY_BARRIER
115
+
116
+// ALPHA
117
+#elif defined(ARCH_CPU_ALPHA_FAMILY)
118
+
119
+inline void ReadMemoryBarrier() {
120
+ __asm__ __volatile__("mb" : : : "memory");
121
+}
122
+inline void WriteMemoryBarrier() {
123
+ __asm__ __volatile__("wmb" : : : "memory");
124
+}
125
+#define LEVELDB_HAVE_MEMORY_BARRIER
126
+
127
+// S390
128
+#elif defined(ARCH_CPU_S390_FAMILY)
129
+
130
+inline void ReadMemoryBarrier() {
131
+ asm volatile("bcr 15,0" : : : "memory");
132
+}
133
+inline void WriteMemoryBarrier() {
134
+ asm volatile("bcr 15,0" : : : "memory");
135
+}
136
+#define LEVELDB_HAVE_MEMORY_BARRIER
137
+
138
+// SPARC
139
+#elif defined(ARCH_CPU_SPARC_FAMILY)
140
+
141
+inline void ReadMemoryBarrier() {
142
+ __asm__ __volatile__("" : : : "memory");
143
+}
144
+inline void WriteMemoryBarrier() {
145
+ __asm__ __volatile__("" : : : "memory");
146
+}
147
+#define LEVELDB_HAVE_MEMORY_BARRIER
148
+
149
+// SH
150
+#elif defined(ARCH_CPU_SH_FAMILY)
151
+#if defined(__SH4A__) || defined(__SH5__)
152
+inline void ReadMemoryBarrier() {
153
+ __asm__ __volatile__ ("synco": : :"memory");
154
+}
155
+inline void WriteMemoryBarrier() {
156
+ __asm__ __volatile__ ("synco": : :"memory");
157
+}
158
+#else
159
+inline void ReadMemoryBarrier() {
160
+ __asm__ __volatile__ ("": : :"memory");
161
+}
162
+inline void WriteMemoryBarrier() {
163
+ __asm__ __volatile__ ("": : :"memory");
164
+}
165
+#endif
166
+#define LEVELDB_HAVE_MEMORY_BARRIER
167
+
168
+// PARISC
169
+#elif defined(ARCH_CPU_PARISC_FAMILY)
170
+
171
+inline void ReadMemoryBarrier() {
172
+ __asm__ __volatile__("" : : : "memory")
173
+}
174
+inline void WriteMemoryBarrier() {
175
+ __asm__ __volatile__("" : : : "memory")
176
}
177
#define LEVELDB_HAVE_MEMORY_BARRIER
178
179
180
inline void NoBarrier_Store(void* v) { rep_ = v; }
181
inline void* Acquire_Load() const {
182
void* result = rep_;
183
- MemoryBarrier();
184
+ ReadMemoryBarrier();
185
return result;
186
}
187
inline void Release_Store(void* v) {
188
- MemoryBarrier();
189
+ WriteMemoryBarrier();
190
rep_ = v;
191
}
192
};
193
194
#undef ARCH_CPU_X86_FAMILY
195
#undef ARCH_CPU_ARM_FAMILY
196
#undef ARCH_CPU_PPC_FAMILY
197
+#undef ARCH_CPU_IA64_FAMILY
198
+#undef ARCH_CPU_ALPHA_FAMILY
199
+#undef ARCH_CPU_S390_FAMILY
200
+#undef ARCH_CPU_SPARC_FAMILY
201
+#undef ARCH_CPU_SH_FAMILY
202
+#undef ARCH_CPU_PARISC_FAMILY
203
204
} // namespace port
205
} // namespace leveldb
206