Loading...
pthreads/lock.s Libc-262 Libc-262.2.12
--- Libc/Libc-262/pthreads/lock.s
+++ Libc/Libc-262.2.12/pthreads/lock.s
@@ -25,6 +25,11 @@
 
 #if defined(__ppc__)
 
+
+#define	__APPLE_API_PRIVATE
+#include <machine/cpu_capabilities.h>
+#undef	__APPLE_API_PRIVATE
+
 #import	<architecture/ppc/asm_help.h>
 #import	<architecture/ppc/pseudo_inst.h>
 
@@ -35,37 +40,14 @@
  */
 
 .text
-
 LEAF(__spin_lock_try)
-1:
-	lwarx   r5,0,r3		// Read the lock
-	addi    r4,0,0x1	// Lock value
-	cmpwi   r5,0x0		// Is it busy?
-	bne-    2f		// Yes, return 0
-	stwcx.  r4,0,r3		// Try to lock the lock
-	bne-    1b		// Lost reservation, try again
-        addi	r3,0,1		// Got the lock
-	isync			// Sync instruction stream 
-	blr			// Return 1
-2:	addi	r3,0,0		// Could not get the lock
-	blr			// Return 0
+    ba		_COMM_PAGE_SPINLOCK_TRY
 END(__spin_lock_try)
 
 .globl _spin_lock
 LEAF(__spin_lock)
 _spin_lock:
-1:
-	lwarx   r5,0,r3		// Read the lock
-	addi    r4,0,0x1	// Lock value
-	cmpwi   r5,0x0		// Is it busy?
-	bne-    2f		// Yes, goto retry logic
-	stwcx.  r4,0,r3		// Try to lock the lock
-	bne-    1b		// Lost reservation, try again
-	isync			// Sync instruction stream 
-	blr			// Return
-2:
-	CALL_EXTERN(__spin_lock_retry)
-	blr			// Return
+    ba		_COMM_PAGE_SPINLOCK_LOCK
 END(__spin_lock)
 
 /* void spin_unlock(int *p);
@@ -75,10 +57,7 @@
 .globl _spin_unlock
 LEAF(__spin_unlock)
 _spin_unlock:
-	sync
-	li32	r4,0
-	stw	r4,0(r3)
-	blr
+    ba		_COMM_PAGE_SPINLOCK_UNLOCK
 END(__spin_unlock)
 
 #elif defined(__i386__)