Browse code

- compilation fix for gcc < 2.9 (workaround for unsuported contraint)

Andrei Pelinescu-Onciul authored on 28/02/2007 19:20:24
Showing 2 changed files
... ...
@@ -117,6 +117,19 @@
117 117
 	}
118 118
 
119 119
 
120
+#if defined __GNUC__ &&  __GNUC__ < 3 && __GNUC_MINOR__ < 9
121
+#define ATOMIC_FUNC_DECL01_1(NAME, OP, P_TYPE, RET_TYPE, RET_EXPR) \
122
+	inline static RET_TYPE atomic_##NAME##_##P_TYPE (volatile P_TYPE *var, \
123
+														P_TYPE v ) \
124
+	{ \
125
+		P_TYPE ret; \
126
+		asm volatile( \
127
+			ATOMIC_ASM_OP01_##P_TYPE(OP) \
128
+			: "=&r"(ret), "=r"(v), "=m"(*var), "0"(v)  : "m"(*var) \
129
+			); \
130
+		return RET_EXPR; \
131
+	}
132
+#else
120 133
 /* input in %0, and %1 (param), output in %1,  %0 goes in ret */
121 134
 #define ATOMIC_FUNC_DECL01_1(NAME, OP, P_TYPE, RET_TYPE, RET_EXPR) \
122 135
 	inline static RET_TYPE atomic_##NAME##_##P_TYPE (volatile P_TYPE *var, \
... ...
@@ -129,7 +142,7 @@
129 129
 			); \
130 130
 		return RET_EXPR; \
131 131
 	}
132
-
132
+#endif /* gcc && gcc version < 2.9 */
133 133
 
134 134
 /* input in %0, output in %1, %0 goes in ret */
135 135
 #define ATOMIC_FUNC_DECL0_1(NAME, OP, P_TYPE, RET_TYPE, RET_EXPR) \
... ...
@@ -129,6 +129,18 @@
129 129
 				); \
130 130
 	}
131 131
 
132
+#if defined __GNUC__ &&  __GNUC__ < 3 && __GNUC_MINOR__ < 9
133
+/* gcc version < 2.9 */
134
+#define ATOMIC_FUNC_XCHG(NAME, OP, TYPE) \
135
+	inline static TYPE atomic_##NAME##_##TYPE(volatile TYPE* var, TYPE v) \
136
+{ \
137
+	asm volatile( \
138
+			OP " \n\t" \
139
+			: "=q"(v), "=m"(*var) :"m"(*var), "0"(v) : "memory" \
140
+			); \
141
+	return v; \
142
+}
143
+#else
132 144
 #define ATOMIC_FUNC_XCHG(NAME, OP, TYPE) \
133 145
 	inline static TYPE atomic_##NAME##_##TYPE(volatile TYPE* var, TYPE v) \
134 146
 { \
... ...
@@ -138,6 +150,7 @@
138 138
 			); \
139 139
 	return v; \
140 140
 }
141
+#endif /* gcc & gcc version < 2.9 */
141 142
 
142 143
 /* returns a value, 1 param */
143 144
 #define ATOMIC_FUNC_TEST(NAME, OP, P_TYPE, RET_TYPE) \
... ...
@@ -218,7 +231,11 @@ inline static void mb_atomic_set_int(volatile int* v, int i)
218 218
 {
219 219
 	asm volatile(
220 220
 			"xchgl %1, %0 \n\t"
221
+#if defined __GNUC__ &&  __GNUC__ < 3 && __GNUC_MINOR__ < 9
222
+			: "=q"(i), "=m"(*v) : "m"(*v), "0"(i) : "memory" 
223
+#else
221 224
 			: "+q"(i), "=m"(*v) : "m"(*v) : "memory" 
225
+#endif
222 226
 			);
223 227
 }
224 228
 
... ...
@@ -231,7 +248,11 @@ inline static void mb_atomic_set_long(volatile long* v, long l)
231 231
 #else
232 232
 			"xchgl %1, %0 \n\t"
233 233
 #endif
234
+#if defined __GNUC__ &&  __GNUC__ < 3 && __GNUC_MINOR__ < 9
235
+			: "=q"(l), "=m"(*v) : "m"(*v), "0"(l) : "memory" 
236
+#else
234 237
 			: "+q"(l), "=m"(*v) : "m"(*v) : "memory" 
238
+#endif
235 239
 			);
236 240
 }
237 241