summaryrefslogtreecommitdiff
blob: d5f916d455eb2a6f02bcaa14e35309b2193a69d6 (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
--- postgresql-7.4.12.orig/src/include/port/linux.h	2003-10-26 01:41:10.000000000 +0000
+++ postgresql-7.4.12/src/include/port/linux.h	2004-01-09 20:22:50.000000000 +0000
@@ -3,6 +3,11 @@
 
 #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;
 
--- postgresql-7.4.12.orig/src/include/storage/s_lock.h	2003-11-04 09:43:56.000000000 +0000
+++ postgresql-7.4.12/src/include/storage/s_lock.h	2004-01-09 20:12:15.000000000 +0000
@@ -112,6 +112,33 @@
 
 #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)