blob: f19eb385371bc532cf39ac8689341ac8ee5f8400 (
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
diff --git a/src/include/port/linux.h b/src/include/port/linux.h
index 159db31..bef4c9e 100644
--- a/src/include/port/linux.h
+++ b/src/include/port/linux.h
@@ -3,6 +3,11 @@ typedef unsigned char slock_t;
#define HAS_TEST_AND_SET
+#elif defined(__hppa__)
+typedef struct { int sema[4]; } slock_t;
+
+#define HAS_TEST_AND_SET
+
#elif defined(__sparc__)
typedef unsigned char slock_t;
diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
index 578d8cf..ceed34a 100644
--- a/src/include/storage/s_lock.h
+++ b/src/include/storage/s_lock.h
@@ -112,6 +112,33 @@ tas(volatile slock_t *lock)
#endif /* __i386__ || __x86_64__ */
+#if defined(__hppa__) || defined(__hppa)
+#define TAS(lock) tas(lock)
+
+#define __ldcw(a) ({ \
+ unsigned int __ret; \
+ __asm__ __volatile__("ldcw 0(%2),%0" \
+ : "=r" (__ret), "=m" (*(a)) : "r" (a)); \
+ __ret; \
+})
+
+#define __PA_LDCW_ALIGNMENT 16
+#define __ldcw_align(a) ({ \
+ volatile unsigned int __ret = (unsigned int) a; \
+ if ((__ret & ~(__PA_LDCW_ALIGNMENT - 1)) < (unsigned int) a) \
+ __ret = (__ret & ~(__PA_LDCW_ALIGNMENT - 1)) + __PA_LDCW_ALIGNMENT; \
+ (unsigned int *) __ret; \
+})
+
+static __inline__ int
+tas(volatile slock_t *lock)
+{
+ volatile unsigned int *a = __ldcw_align (lock);
+ return (__ldcw(a) == 0);
+}
+
+#endif /* __hppa__ || __hppa */
+
/* Intel Itanium */
#if defined(__ia64__) || defined(__ia64)
|