Bug 331545 - "Use _InterlockedCompareExchange for js_CompareAndSwap" [p=mmoy@yahoo.com (Michael Moy) r+a1.9=brendan a=blocking1.9+]

This commit is contained in:
reed@reedloden.com 2008-01-19 20:39:10 -08:00
Родитель c845698fff
Коммит c031ce7f17
1 изменённых файлов: 9 добавлений и 6 удалений

Просмотреть файл

@ -85,20 +85,23 @@ js_UnlockGlobal(void *id)
/* Exclude Alpha NT. */
#if defined(_WIN32) && defined(_M_IX86)
#pragma warning( disable : 4035 )
#pragma intrinsic(_InterlockedCompareExchange)
static JS_INLINE int
js_CompareAndSwap(jsword *w, jsword ov, jsword nv)
js_CompareAndSwapHelper(jsword *w, jsword ov, jsword nv)
{
_InterlockedCompareExchange(w, nv, ov);
__asm {
mov eax, ov
mov ecx, nv
mov ebx, w
lock cmpxchg [ebx], ecx
sete al
and eax, 1h
}
}
static JS_INLINE int
js_CompareAndSwapHelper(jsword *w, jsword ov, jsword nv)
{
return (js_CompareAndSwapHelper(w, ov, nv) & 1);
}
#elif defined(XP_MACOSX) || defined(DARWIN)
#include <libkern/OSAtomic.h>