/*
 * $Id: asm_sparc.s,v 1.1 2001/01/26 04:56:03 m-hirano Exp $
 * $RWC_Release: Omni-1.6 $
 * $RWC_Copyright:
 *  Omni Compiler Software Version 1.5-1.6
 *  Copyright (C) 2002 PC Cluster Consortium
 *  
 *  This software is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License version
 *  2.1 published by the Free Software Foundation.
 *  
 *  Omni Compiler Software Version 1.0-1.4
 *  Copyright (C) 1999, 2000, 2001.
 *   Tsukuba Research Center, Real World Computing Partnership, Japan.
 *  
 *  Please check the Copyright and License information in the files named
 *  COPYRIGHT and LICENSE under the top  directory of the Omni Compiler
 *  Software release kit.
 *  
 *  
 *  $
 */

	.align  8
	.skip   16

	.type   LockWithLdstUB,#function
	.global LockWithLdstUB
LockWithLdstUB:
retry:
	ldstub  [%o0],%o1       ! atomic load store
	tst     %o1
	be      out
	nop
loop:
	ldub    [%o0],%o1       ! load and test
	tst     %o1
	bne     loop
	nop
	ba,a    retry
out:
	nop
	jmp     %o7+8   ! return
	nop

	.type   TestLockWithLdstUB,#function
	.global TestLockWithLdstUB
TestLockWithLdstUB:
	ldstub  [%o0],%o0       ! atomic load store
	jmp     %o7+8   ! return
	nop

	.type   UnlockWithLdstUB,#function
	.global UnlockWithLdstUB
UnlockWithLdstUB:
	stbar
	stb     %g0,[%o0]       ! clear lock
	jmp     %o7+8           ! return
	nop
