xref: /onnv-gate/usr/src/lib/libc/sparc/threads/sparc.il (revision 4570:f93b74ddbdd5)
10Sstevel@tonic-gate/*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
53446Smrj * Common Development and Distribution License (the "License").
63446Smrj * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
210Sstevel@tonic-gate/*
223446Smrj * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate * Use is subject to license terms.
240Sstevel@tonic-gate */
250Sstevel@tonic-gate
260Sstevel@tonic-gate#pragma ident	"%Z%%M%	%I%	%E% SMI"
270Sstevel@tonic-gate
280Sstevel@tonic-gate	.inline	_curthread, 0
290Sstevel@tonic-gate	.register %g7, #scratch
300Sstevel@tonic-gate	mov	%g7, %o0
310Sstevel@tonic-gate	.end
320Sstevel@tonic-gate
330Sstevel@tonic-gate	.inline	__curthread, 0
340Sstevel@tonic-gate	.register %g7, #scratch
350Sstevel@tonic-gate	ld	[%g7 + 80], %o0		! ul_self
360Sstevel@tonic-gate	.end
370Sstevel@tonic-gate
380Sstevel@tonic-gate	.inline	stkptr, 0
390Sstevel@tonic-gate	mov	%sp, %o0
400Sstevel@tonic-gate	.end
410Sstevel@tonic-gate
420Sstevel@tonic-gate	.inline	gethrtime, 0
430Sstevel@tonic-gate	ta	0x24
440Sstevel@tonic-gate	.end
450Sstevel@tonic-gate
460Sstevel@tonic-gate	.inline	set_lock_byte, 0
470Sstevel@tonic-gate	ldstub	[%o0], %o0
480Sstevel@tonic-gate	.end
490Sstevel@tonic-gate
500Sstevel@tonic-gate	/*
510Sstevel@tonic-gate	 * When compiling with -xarch=v8, the compiler refuses to
520Sstevel@tonic-gate	 * accept the 'cas' instruction, so we encode it in hex below.
530Sstevel@tonic-gate	 * We can't compile the 32-bit libc with -xarch=v8plus because
540Sstevel@tonic-gate	 * then %g5 would become a scratch register and we would break
550Sstevel@tonic-gate	 * 32-bit applications that use %g5 as an invariant register.
560Sstevel@tonic-gate	 */
570Sstevel@tonic-gate
58*4570Sraf	.inline	atomic_cas_32, 0
590Sstevel@tonic-gate	.word	0xd5e21009	! cas [%o0], %o1, %o2
600Sstevel@tonic-gate	mov	%o2, %o0
610Sstevel@tonic-gate	.end
620Sstevel@tonic-gate
63*4570Sraf	.inline	atomic_swap_32, 0
640Sstevel@tonic-gate	ld	[%o0], %o2
650Sstevel@tonic-gate1:
660Sstevel@tonic-gate	mov	%o1, %o3
670Sstevel@tonic-gate	.word	0xd7e2100a	! cas [%o0], %o2, %o3
680Sstevel@tonic-gate	cmp	%o2, %o3
690Sstevel@tonic-gate	bne,a	1b
700Sstevel@tonic-gate	  mov	%o3, %o2
710Sstevel@tonic-gate	mov	%o3, %o0
720Sstevel@tonic-gate	.end
730Sstevel@tonic-gate
74*4570Sraf	.inline	atomic_inc_32, 0
750Sstevel@tonic-gate	ld	[%o0], %o2
760Sstevel@tonic-gate1:
770Sstevel@tonic-gate	add	%o2, 1, %o3
780Sstevel@tonic-gate	.word	0xd7e2100a	! cas [%o0], %o2, %o3
790Sstevel@tonic-gate	cmp	%o2, %o3
800Sstevel@tonic-gate	bne,a	1b
810Sstevel@tonic-gate	  mov	%o3, %o2
820Sstevel@tonic-gate	.end
830Sstevel@tonic-gate
84*4570Sraf	.inline	atomic_dec_32, 0
850Sstevel@tonic-gate	ld	[%o0], %o2
860Sstevel@tonic-gate1:
870Sstevel@tonic-gate	sub	%o2, 1, %o3
880Sstevel@tonic-gate	.word	0xd7e2100a	! cas [%o0], %o2, %o3
890Sstevel@tonic-gate	cmp	%o2, %o3
900Sstevel@tonic-gate	bne,a	1b
910Sstevel@tonic-gate	  mov	%o3, %o2
920Sstevel@tonic-gate	.end
930Sstevel@tonic-gate
94*4570Sraf	.inline	atomic_and_32, 0
95*4570Sraf	ld	[%o0], %o2
96*4570Sraf1:
97*4570Sraf	and	%o2, %o1, %o3
98*4570Sraf	.word	0xd7e2100a	! cas [%o0], %o2, %o3
99*4570Sraf	cmp	%o2, %o3
100*4570Sraf	bne,a	1b
101*4570Sraf	  mov	%o3, %o2
102*4570Sraf	.end
103*4570Sraf
104*4570Sraf	.inline	atomic_or_32, 0
105*4570Sraf	ld	[%o0], %o2
106*4570Sraf1:
107*4570Sraf	or	%o2, %o1, %o3
108*4570Sraf	.word	0xd7e2100a	! cas [%o0], %o2, %o3
109*4570Sraf	cmp	%o2, %o3
110*4570Sraf	bne,a	1b
111*4570Sraf	  mov	%o3, %o2
112*4570Sraf	.end
113*4570Sraf
1140Sstevel@tonic-gate	.inline	caller, 0
1150Sstevel@tonic-gate	mov	%i7, %o0
1160Sstevel@tonic-gate	.end
1170Sstevel@tonic-gate
1180Sstevel@tonic-gate	.inline	getfp, 0
1190Sstevel@tonic-gate	mov	%fp, %o0
1200Sstevel@tonic-gate	.end
121