xref: /titanic_44/usr/src/lib/libc/sparc/threads/sparc.il (revision fb3fb4f3d76d55b64440afd0af72775dfad3bd1d)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License").  You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22/*
23 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24 * Use is subject to license terms.
25 */
26
27#pragma ident	"%Z%%M%	%I%	%E% SMI"
28
29	.inline	_curthread, 0
30	.register %g7, #scratch
31	mov	%g7, %o0
32	.end
33
34	.inline	__curthread, 0
35	.register %g7, #scratch
36	tst	%g7
37	be,a	1f
38	  mov	%g0, %o0
39	ld	[%g7 + 80], %o0		! ul_self
401:
41	.end
42
43	.inline	stkptr, 0
44	mov	%sp, %o0
45	.end
46
47	.inline	gethrtime, 0
48	ta	0x24
49	.end
50
51	.inline	set_lock_byte, 0
52	ldstub	[%o0], %o0
53	.end
54
55	/*
56	 * When compiling with -xarch=v8, the compiler refuses to
57	 * accept the 'cas' instruction, so we encode it in hex below.
58	 * We can't compile the 32-bit libc with -xarch=v8plus because
59	 * then %g5 would become a scratch register and we would break
60	 * 32-bit applications that use %g5 as an invariant register.
61	 */
62
63	.inline	cas32, 0
64	.word	0xd5e21009	! cas [%o0], %o1, %o2
65	mov	%o2, %o0
66	.end
67
68	.inline	swap32, 0
69	ld	[%o0], %o2
701:
71	mov	%o1, %o3
72	.word	0xd7e2100a	! cas [%o0], %o2, %o3
73	cmp	%o2, %o3
74	bne,a	1b
75	  mov	%o3, %o2
76	mov	%o3, %o0
77	.end
78
79	.inline	incr32, 0
80	ld	[%o0], %o2
811:
82	add	%o2, 1, %o3
83	.word	0xd7e2100a	! cas [%o0], %o2, %o3
84	cmp	%o2, %o3
85	bne,a	1b
86	  mov	%o3, %o2
87	.end
88
89	.inline	decr32, 0
90	ld	[%o0], %o2
911:
92	sub	%o2, 1, %o3
93	.word	0xd7e2100a	! cas [%o0], %o2, %o3
94	cmp	%o2, %o3
95	bne,a	1b
96	  mov	%o3, %o2
97	.end
98
99	.inline	caller, 0
100	mov	%i7, %o0
101	.end
102
103	.inline	getfp, 0
104	mov	%fp, %o0
105	.end
106