aboutsummaryrefslogtreecommitdiff
blob: 877c7c77a28440442e34d6842bbac40d748afaad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
diff -Naur a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
--- a/src/include/storage/s_lock.h	2011-01-27 21:24:47.000000000 -0500
+++ b/src/include/storage/s_lock.h	2011-03-20 16:59:30.462991541 -0400
@@ -298,6 +298,29 @@
 
 #endif	 /* __s390__ || __s390x__ */
 
+#if defined(__sh__)
+#define HAS_TEST_AND_SET
+
+typedef unsigned char slock_t;
+
+#define TAS(lock) tas(lock)
+
+static __inline__ int
+tas(volatile slock_t *lock)
+{
+    register int _res = 1;
+
+    __asm__ __volatile__(
+        "tas.b  @%1\n\t"
+        "movt   %0\n\t"
+        "xor    #1,%0"
+:       "=z"(_res)
+:       "r"(lock)
+:       "t","memory");
+    return _res;
+}
+
+#endif  /* __sh__ */
 
 #if defined(__sparc__)		/* Sparc */
 #define HAS_TEST_AND_SET