* src/native/vm/sun_misc_Unsafe.c: Use new atomic primitve functions.
[cacao.git] / src / threads / posix / lock.c
index 71e5a0077132212fb2704d721e2057344bf81e7b..36607054bc1bcbf4adb7432fb7c8ae6c9444d564 100644 (file)
@@ -72,7 +72,7 @@
 #if defined(USE_FAKE_ATOMIC_INSTRUCTIONS)
 #include "threads/posix/generic-primitives.h"
 #else
-#include "machine-instr.h"
+#include "atomic.hpp"
 #endif
 
 #if defined(ENABLE_JVMTI)
@@ -856,7 +856,7 @@ static void sable_flc_waiting(ptrint lockword, threadobject *t, java_handle_t *o
                                t->index, t_other->index));
 
        /* Set FLC bit first, then read the lockword again */
-       MEMORY_BARRIER();
+       Atomic_mb();
 
        lockword = lock_lockword_get(t, o);
 
@@ -973,7 +973,7 @@ retry:
        /* most common case: try to thin-lock an unlocked object */
 
        LLNI_CRITICAL_START_THREAD(t);
-       lockword = COMPARE_AND_SWAP_OLD_VALUE(&(LLNI_DIRECT(o)->lockword), THIN_UNLOCKED, thinlock);
+       lockword = Atomic_cas_ptr(&(LLNI_DIRECT(o)->lockword), THIN_UNLOCKED, thinlock);
        LLNI_CRITICAL_END_THREAD(t);
 
        if (lockword == THIN_UNLOCKED) {
@@ -1097,8 +1097,8 @@ bool lock_monitor_exit(java_handle_t *o)
                /* memory barrier for Java Memory Model */
                STORE_ORDER_BARRIER();
                lock_lockword_set(t, o, THIN_UNLOCKED);
-               /* memory barrier for thin locking */
-               MEMORY_BARRIER();
+               /* Memory barrier for thin locking. */
+               Atomic_mb();
 
                /* check if there has been a flat lock contention on this object */