summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwchang0222%aol.com <devnull@localhost>2004-12-06 20:04:13 +0000
committerwchang0222%aol.com <devnull@localhost>2004-12-06 20:04:13 +0000
commit68a8de9df4681829abce4ceeaf8541ca5ebd6fa4 (patch)
tree291f15d2d888dde4c8fe1eade40a399d91b8b03c
parente71c29daff662ff57555f42973aedf2d75645973 (diff)
downloadnspr-hg-68a8de9df4681829abce4ceeaf8541ca5ebd6fa4.tar.gz
Bugzilla bug 151709: implemented atomic operations in assembly on Alpha
Linux. The patch is contributed by falk@debian.org. r=darin,wtc. Tag: NSPRPUB_PRE_4_2_CLIENT_BRANCH
-rw-r--r--pr/include/md/_linux.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/pr/include/md/_linux.h b/pr/include/md/_linux.h
index 68a9265f..66e0ccf4 100644
--- a/pr/include/md/_linux.h
+++ b/pr/include/md/_linux.h
@@ -127,6 +127,62 @@ extern PRInt32 _PR_x86_64_AtomicSet(PRInt32 *val, PRInt32 newval);
#define _MD_ATOMIC_SET _PR_x86_64_AtomicSet
#endif
+#if defined(__alpha)
+#define _PR_HAVE_ATOMIC_OPS
+#define _MD_INIT_ATOMIC()
+#define _MD_ATOMIC_ADD(ptr, i) ({ \
+ unsigned long __atomic_tmp, __atomic_ret; \
+ __asm__ __volatile__( \
+ "1: ldl_l %[ret], %[val] \n" \
+ " addl %[ret], %[inc], %[tmp] \n" \
+ " addl %[ret], %[inc], %[ret] \n" \
+ " stl_c %[tmp], %[val] \n" \
+ " beq %[tmp], 2f \n" \
+ ".subsection 2 \n" \
+ "2: br 1b \n" \
+ ".previous" \
+ : [ret] "=&r" (__atomic_ret), \
+ [tmp] "=&r" (__atomic_tmp), \
+ [val] "=m" (*ptr) \
+ : [inc] "Ir" (i), "m" (*ptr)); \
+ __atomic_ret; \
+})
+#define _MD_ATOMIC_INCREMENT(ptr) _MD_ATOMIC_ADD(ptr, 1)
+#define _MD_ATOMIC_DECREMENT(ptr) ({ \
+ unsigned long __atomic_tmp, __atomic_ret; \
+ __asm__ __volatile__( \
+ "1: ldl_l %[ret], %[val] \n" \
+ " subl %[ret], 1, %[tmp] \n" \
+ " subl %[ret], 1, %[ret] \n" \
+ " stl_c %[tmp], %[val] \n" \
+ " beq %[tmp], 2f \n" \
+ ".subsection 2 \n" \
+ "2: br 1b \n" \
+ ".previous" \
+ : [ret] "=&r" (__atomic_ret), \
+ [tmp] "=&r" (__atomic_tmp), \
+ [val] "=m" (*ptr) \
+ : "m" (*ptr)); \
+ __atomic_ret; \
+})
+#define _MD_ATOMIC_SET(ptr, n) ({ \
+ unsigned long __atomic_tmp, __atomic_ret; \
+ __asm__ __volatile__( \
+ "1: ldl_l %[ret], %[val] \n" \
+ " mov %[newval], %[tmp] \n" \
+ " stl_c %[tmp], %[val] \n" \
+ " beq %[tmp], 2f \n" \
+ ".subsection 2 \n" \
+ "2: br 1b \n" \
+ ".previous" \
+ : [ret] "=&r" (__atomic_ret), \
+ [tmp] "=&r"(__atomic_tmp), \
+ [val] "=m" (*ptr) \
+ : [newval] "Ir" (n), "m" (*ptr)); \
+ __atomic_ret; \
+})
+#endif
+
#define USE_SETJMP
#if defined(__GLIBC__) && __GLIBC__ >= 2
#define _PR_POLL_AVAILABLE