Browse Source

Added android specific atomic ops.

woollybah 10 years ago
parent
commit
b152634cd5
1 changed files with 9 additions and 2 deletions
  1. 9 2
      blitz.mod/blitz_thread.c

+ 9 - 2
blitz.mod/blitz_thread.c

@@ -278,13 +278,20 @@ int bbThreadResume( BBThread *thread ){
 #endif
 
 //***** Atomic ops *****
-
 int bbAtomicCAS( volatile int *addr,int old,int new_val ){
-	return AO_compare_and_swap(addr, old, new_val);
+#ifndef __ANDROID__
+	return AO_int_compare_and_swap(addr, old, new_val);
+#else
+	return __sync_val_compare_and_swap(addr, old, new_val);
+#endif
 }
 
 int bbAtomicAdd( volatile int *p,int incr ){
+#ifndef __ANDROID__
 	return AO_fetch_and_add((AO_t*)p, incr);
+#else
+	return __sync_fetch_and_add(p, incr);
+#endif
 }
 
 #endif // __EMSCRIPTEN__