Merge illumos-gate
[unleashed/lotheac.git] / usr / src / cmd / mdb / intel / amd64 / libstand / setjmp.s
bloba1ae4beb673c3a34a7102205d9a7f123c96a3fb4
1 /*
2 * CDDL HEADER START
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.
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.
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]
20 * CDDL HEADER END
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 #include <sys/asm_linkage.h>
33 * longjmp(env, val)
34 * will generate a "return(val)" from
35 * the last call to
36 * setjmp(env)
37 * by restoring registers rip rsp rbp rbx r12 r13 r14 r15 from 'env'
38 * and doing a return.
40 * entry reg offset
41 * env[0] = %rbx 0 register variables
42 * env[1] = %r12 8
43 * env[2] = %r13 16
44 * env[3] = %r14 24
45 * env[4] = %r15 32
46 * env[5] = %rbp 40 stack frame
47 * env[6] = %rsp 48
48 * env[7] = %rip 56
52 ENTRY(setjmp)
53 ALTENTRY(sigsetjmp)
54 movq %rbx, 0(%rdi)
55 movq %r12, 8(%rdi)
56 movq %r13, 16(%rdi)
57 movq %r14, 24(%rdi)
58 movq %r15, 32(%rdi)
59 movq %rbp, 40(%rdi)
60 popq %rdx /* return address */
61 movq %rsp, 48(%rdi)
62 movq %rdx, 56(%rdi)
63 xorl %eax, %eax /* return 0 */
64 jmp *%rdx
65 SET_SIZE(sigsetjmp)
66 SET_SIZE(setjmp)
70 ENTRY(longjmp)
71 ALTENTRY(siglongjmp)
72 movq 0(%rdi), %rbx
73 movq 8(%rdi), %r12
74 movq 16(%rdi), %r13
75 movq 24(%rdi), %r14
76 movq 32(%rdi), %r15
77 movq 40(%rdi), %rbp
78 movq 48(%rdi), %rsp
79 movl %esi, %eax
80 test %eax, %eax /* if val != 0 */
81 jnz 1f /* return val */
82 incl %eax /* else return 1 */
84 movq 56(%rdi), %rdx /* return to caller of setjmp */
85 jmp *%rdx
86 SET_SIZE(siglongjmp)
87 SET_SIZE(longjmp)