1 / See the file LICENSE for redistribution information. 2 / 3 / Copyright (c) 1997,2008 Oracle. All rights reserved. 4 / 5 / $Id: uts4_cc.s,v 12.6 2008/01/08 20:58:43 bostic Exp $ 6 / 7 / int uts_lock ( int *p, int i ); 8 / Update the lock word pointed to by p with the 9 / value i, using compare-and-swap. 10 / Returns 0 if update was successful. 11 / Returns 1 if update failed. 12 / 13 entry uts_lock 14 uts_lock: 15 using .,r15 16 st r2,8(sp) / Save R2 17 l r2,64+0(sp) / R2 -> word to update 18 slr r0, r0 / R0 = current lock value must be 0 19 l r1,64+4(sp) / R1 = new lock value 20 cs r0,r1,0(r2) / Try the update ... 21 be x / ... Success. Return 0 22 la r0,1 / ... Failure. Return 1 23 x: / 24 l r2,8(sp) / Restore R2 25 b 2(,r14) / Return to caller 26 drop r15 27