usr/src/lib/libc/sparc/sys/_lwp_mutex_unlock.s
author Mark J. Nelson <Mark.J.Nelson@Sun.COM>
Wed, 06 Aug 2008 16:29:39 -0600
changeset 7298 b69e27387f74
parent 6812 febeba71273d
permissions -rw-r--r--
6733918 Teamware has retired, please welcome your new manager, Mercurial 4758439 some files use "current date" sccs keywords 6560843 asm sources should not rely on .file "%M%" for naming STT_FILE symbols 6560958 Solaris:: perl modules should not use SCCS keywords in version information 6729074 webrev doesn't deal well with remote ssh hg parents
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
     1
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
     2
 * CDDL HEADER START
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
     3
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
4574
4e479ec6ce6f PSARC 2007/285 robust locks revisited
raf
parents: 0
diff changeset
     5
 * Common Development and Distribution License (the "License").
4e479ec6ce6f PSARC 2007/285 robust locks revisited
raf
parents: 0
diff changeset
     6
 * You may not use this file except in compliance with the License.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
     7
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    11
 * and limitations under the License.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    12
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    18
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    19
 * CDDL HEADER END
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    20
 */
4574
4e479ec6ce6f PSARC 2007/285 robust locks revisited
raf
parents: 0
diff changeset
    21
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    22
/*
6515
10dab2b883e0 6678310 using LD_AUDIT, ld.so.1 calls shared library's .init before library is fully relocated
raf
parents: 4574
diff changeset
    23
 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    24
 * Use is subject to license terms.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    25
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    26
7298
b69e27387f74 6733918 Teamware has retired, please welcome your new manager, Mercurial
Mark J. Nelson <Mark.J.Nelson@Sun.COM>
parents: 6812
diff changeset
    27
	.file	"_lwp_mutex_unlock.s"
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    28
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    29
#include "SYS.h"
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    30
#include <../assym.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    31
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    32
	ENTRY(_lwp_mutex_unlock)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    33
	membar	#LoadStore|#StoreStore
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    34
	add	%o0, MUTEX_LOCK_WORD, %o1
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    35
	ld	[%o1], %o2
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    36
1:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    37
	clr	%o3				! clear lock/get waiter field
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    38
	cas	[%o1], %o2, %o3			! atomically
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    39
	cmp	%o2, %o3
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    40
	bne,a,pn %icc, 1b
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    41
	  mov	%o3, %o2
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    42
	btst	WAITER_MASK, %o3		! check for waiters
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    43
	beq,a,pt %icc,2f			! if no waiters
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    44
	  clr 	%o0				! 	return 0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    45
						! else (note that %o0 is still
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    46
						!	&mutex)
4574
4e479ec6ce6f PSARC 2007/285 robust locks revisited
raf
parents: 0
diff changeset
    47
	clr	%o1				! call kernel to wakeup waiter:
4e479ec6ce6f PSARC 2007/285 robust locks revisited
raf
parents: 0
diff changeset
    48
	SYSTRAP_RVAL1(lwp_mutex_wakeup)		!    lwp_mutex_wakeup(mp, 0)
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    49
	SYSLWPERR
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    50
2: 	RET
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    51
	SET_SIZE(_lwp_mutex_unlock)