import less(1)
[unleashed/tickless.git] / usr / src / lib / libc / i386 / threads / asm_subr.s
blob33659ad9b8e209e0c57a29068962c1fc0db788b9
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
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 .file "asm_subr.s"
29 #include <SYS.h>
31 / This is where execution resumes when a thread created with
32 / thr_create() or pthread_create() returns (see setup_context()).
33 / We pass the (void *) return value to _thrp_terminate().
34 ENTRY(_lwp_start)
35 addl $4, %esp
36 pushl %eax
37 call _thrp_terminate
38 addl $4, %esp / actually, never returns
39 SET_SIZE(_lwp_start)
41 / All we need to do now is (carefully) call lwp_exit().
42 ENTRY(_lwp_terminate)
43 SYSTRAP_RVAL1(lwp_exit)
44 RET / if we return, it is very bad
45 SET_SIZE(_lwp_terminate)
47 ENTRY(set_curthread)
48 movl 4(%esp), %eax
49 movl %eax, %gs:0
50 ret
51 SET_SIZE(set_curthread)
53 ENTRY(__lwp_park)
54 popl %edx / add subcode; save return address
55 pushl $0
56 pushl %edx
57 SYSTRAP_RVAL1(lwp_park)
58 SYSLWPERR
59 popl %edx / restore return address
60 movl %edx, 0(%esp)
61 RET
62 SET_SIZE(__lwp_park)
64 ENTRY(__lwp_unpark)
65 popl %edx / add subcode; save return address
66 pushl $1
67 pushl %edx
68 SYSTRAP_RVAL1(lwp_park)
69 SYSLWPERR
70 popl %edx / restore return address
71 movl %edx, 0(%esp)
72 RET
73 SET_SIZE(__lwp_unpark)
75 ENTRY(__lwp_unpark_all)
76 popl %edx / add subcode; save return address
77 pushl $2
78 pushl %edx
79 SYSTRAP_RVAL1(lwp_park)
80 SYSLWPERR
81 popl %edx / restore return address
82 movl %edx, 0(%esp)
83 RET
84 SET_SIZE(__lwp_unpark_all)
87 * __sighndlr(int sig, siginfo_t *si, ucontext_t *uc, void (*hndlr)())
89 * This is called from sigacthandler() for the purpose of
90 * communicating the ucontext to java's stack tracing functions
91 * and to ensure a 16-byte aligned stack pointer for the benefit
92 * of gcc-compiled floating point code
94 ENTRY(__sighndlr)
95 .globl __sighndlrend
96 pushl %ebp
97 movl %esp, %ebp
98 andl $-16,%esp / make sure handler is called with
99 subl $4,%esp / a 16-byte aligned stack pointer
100 pushl 16(%ebp)
101 pushl 12(%ebp)
102 pushl 8(%ebp)
103 call *20(%ebp)
104 leave
106 __sighndlrend:
107 SET_SIZE(__sighndlr)
110 * int _sigsetjmp(sigjmp_buf env, int savemask)
112 * This version is faster than the old non-threaded version because we
113 * don't normally have to call __getcontext() to get the signal mask.
114 * (We have a copy of it in the ulwp_t structure.)
117 #undef sigsetjmp
119 ENTRY2(sigsetjmp,_sigsetjmp) / EIP already pushed
120 pusha / EAX .. EDI
121 push %ds / segment registers
122 push %es
123 push %fs
124 push %gs
125 push %ss
126 push %cs
127 / args: cs, ss, gs, ..., eip, env, savemask
128 call __csigsetjmp
129 addl $56, %esp / pop 14 words
131 SET_SIZE(sigsetjmp)
132 SET_SIZE(_sigsetjmp)