From 83a63cb10109c137607056d4ac2f07a1af05bb7f Mon Sep 17 00:00:00 2001 From: "sayrer@gmail.com" Date: Fri, 11 Jan 2008 23:16:14 -0800 Subject: [PATCH] Bug 353962. Use OSAtomic on Darwin for JS thinlocks. r/a=brendan --- js/src/jslock.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/js/src/jslock.c b/js/src/jslock.c index acd13c3ca9b3..9dc5cc3c88db 100644 --- a/js/src/jslock.c +++ b/js/src/jslock.c @@ -99,6 +99,21 @@ js_CompareAndSwap(jsword *w, jsword ov, jsword nv) } } +#elif defined(XP_MACOSX) || defined(DARWIN) + +#include + +static JS_INLINE int +js_CompareAndSwap(jsword *w, jsword ov, jsword nv) +{ + // Details on these functions available in the manpage for atomic +#if JS_BYTES_PER_WORD == 8 && JS_BYTES_PER_LONG != 8 + return OSAtomicCompareAndSwap64Barrier(ov, nv, (int64_t*) w); +#else + return OSAtomicCompareAndSwap32Barrier(ov, nv, (int32_t*) w); +#endif +} + #elif defined(__GNUC__) && defined(__i386__) /* Note: This fails on 386 cpus, cmpxchgl is a >= 486 instruction */