8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / libc / i386 / threads / tls_get_addr.s
blobeb3f814d51ee23d5fc212918a52e0a656f4f9cc7
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 .file "tls_get_addr.s"
29 * To make thread-local storage accesses as fast as possible, we
30 * hand-craft the __tls_get_addr() function below, from this C code:
31 * void *
32 * __tls_get_addr(TLS_index *tls_index)
33 * {
34 * ulwp_t *self = curthread;
35 * tls_t *tlsent = self->ul_tlsent;
36 * ulong_t moduleid;
37 * caddr_t base;
39 * if ((moduleid = tls_index->ti_moduleid) < self->ul_ntlsent &&
40 * (base = tlsent[moduleid].tls_data) != NULL)
41 * return (base + tls_index->ti_tlsoffset);
43 * return (slow_tls_get_addr(tls_index));
44 * }
46 * ___tls_get_addr() is identical to __tls_get_addr() except that it
47 * assumes its argument is passed in %eax rather than on the stack.
50 #include "SYS.h"
51 #include <assym.h>
53 ENTRY_NP(__tls_get_addr)
54 movl 4(%esp), %eax
55 ALTENTRY(___tls_get_addr)
56 movl %gs:UL_TLSENT, %edx
57 movl TI_MODULEID (%eax), %ecx
58 cmpl %gs:UL_NTLSENT, %ecx
59 jae 1f
60 movl TLS_DATA (%edx,%ecx,SIZEOF_TLS_T), %edx
61 testl %edx, %edx
62 je 1f
63 addl TI_TLSOFFSET (%eax), %edx
64 movl %edx, %eax
65 ret
67 pushl %ebp
68 movl %esp, %ebp
69 pushl %eax
70 call slow_tls_get_addr
71 addl $4, %esp
72 leave
73 ret
74 SET_SIZE(___tls_get_addr)
75 SET_SIZE(__tls_get_addr)