xref: /titanic_52/usr/src/cmd/mdb/intel/amd64/libstand/setjmp.s (revision 6185db853e024a486ff8837e6784dd290d866112)
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 2004 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#if defined(__lint)
30#include <setjmp.h>
31#endif
32
33#include <sys/asm_linkage.h>
34
35/*
36 *	longjmp(env, val)
37 * will generate a "return(val)" from
38 * the last call to
39 *	setjmp(env)
40 * by restoring registers rip rsp rbp rbx r12 r13 r14 r15 from 'env'
41 * and doing a return.
42 *
43 * entry    reg   offset
44 * env[0] = %rbx  0	register variables
45 * env[1] = %r12  8
46 * env[2] = %r13  16
47 * env[3] = %r14  24
48 * env[4] = %r15  32
49 * env[5] = %rbp  40	stack frame
50 * env[6] = %rsp  48
51 * env[7] = %rip  56
52 */
53
54#if defined(__lint)
55/*ARGSUSED*/
56int
57setjmp(jmp_buf env)
58{
59	return (0);
60}
61
62/*ARGSUSED*/
63int
64sigsetjmp(sigjmp_buf env, int savemask)
65{
66	return (0);
67}
68#else	/* __lint */
69
70	ENTRY(setjmp)
71	ALTENTRY(sigsetjmp)
72	movq	%rbx, 0(%rdi)
73	movq	%r12, 8(%rdi)
74	movq	%r13, 16(%rdi)
75	movq	%r14, 24(%rdi)
76	movq	%r15, 32(%rdi)
77	movq	%rbp, 40(%rdi)
78	popq	%rdx		/* return address */
79	movq	%rsp, 48(%rdi)
80	movq	%rdx, 56(%rdi)
81	xorl	%eax, %eax	/* return 0 */
82	jmp	*%rdx
83	SET_SIZE(sigsetjmp)
84	SET_SIZE(setjmp)
85
86#endif	/* __lint */
87
88#if defined(__lint)
89/*ARGSUSED*/
90void
91longjmp(jmp_buf env, int val)
92{
93}
94
95/*ARGSUSED*/
96void
97siglongjmp(sigjmp_buf env, int val)
98{
99}
100#else	/* __lint */
101
102	ENTRY(longjmp)
103	ALTENTRY(siglongjmp)
104	movq	0(%rdi), %rbx
105	movq	8(%rdi), %r12
106	movq	16(%rdi), %r13
107	movq	24(%rdi), %r14
108	movq	32(%rdi), %r15
109	movq	40(%rdi), %rbp
110	movq	48(%rdi), %rsp
111	movl	%esi, %eax
112	test	%eax, %eax	/* if val != 0		*/
113	jnz	1f		/* 	return val	*/
114	incl	%eax		/* else return 1	*/
1151:
116	movq	56(%rdi), %rdx	/* return to caller of setjmp */
117	jmp	*%rdx
118	SET_SIZE(siglongjmp)
119	SET_SIZE(longjmp)
120
121#endif	/* __lint */
122