xref: /titanic_41/usr/src/cmd/mdb/intel/ia32/libstand/setjmp.s (revision 37714ae43602c675f9dc59b070bfdf9fa702872c)
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 ip, sp, bp, bx, si, and di from 'env'
41 * and doing a return.
42 *
43 * entry    reg	offset from (%si)
44 * env[0] = %ebx	 0	/ register variables
45 * env[1] = %esi	 4
46 * env[2] = %edi	 8
47 * env[3] = %ebp	 12	/ stack frame
48 * env[4] = %esp	 16
49 * env[5] = %eip	 20
50 */
51
52#if defined(__lint)
53/* ARGSUSED */
54int
55setjmp(jmp_buf env)
56{
57	return (0);
58}
59
60/* ARGSUSED */
61int
62sigsetjmp(sigjmp_buf env, int savemask)
63{
64	return (0);
65}
66#else	/* __lint */
67
68	ENTRY(setjmp)
69	ALTENTRY(sigsetjmp)
70	movl	4(%esp),%eax	/ jmpbuf address
71	movl	%ebx,0(%eax)	/ save ebx
72	movl	%esi,4(%eax)	/ save esi
73	movl	%edi,8(%eax)	/ save edi
74	movl	%ebp,12(%eax)	/ save caller's ebp
75	popl	%edx		/ return address
76	movl	%esp,16(%eax)	/ save caller's esp
77	movl	%edx,20(%eax)
78	subl	%eax,%eax	/ return 0
79	jmp	*%edx
80	SET_SIZE(sigsetjmp)
81	SET_SIZE(setjmp)
82
83#endif	/* __lint */
84
85#if defined(__lint)
86/* ARGSUSED */
87void
88longjmp(jmp_buf env, int val)
89{
90}
91
92/* ARGSUSED */
93void
94siglongjmp(sigjmp_buf env, int val)
95{
96}
97#else	/* __lint */
98
99	ENTRY(longjmp)
100	ALTENTRY(siglongjmp)
101	movl	4(%esp),%edx	/ first parameter after return addr
102	movl	8(%esp),%eax	/ second parameter
103	movl	0(%edx),%ebx	/ restore ebx
104	movl	4(%edx),%esi	/ restore esi
105	movl	8(%edx),%edi	/ restore edi
106	movl	12(%edx),%ebp	/ restore caller's ebp
107	movl	16(%edx),%esp	/ restore caller's esp
108	test	%eax,%eax	/ if val != 0
109	jnz	.ret		/ 	return val
110	incl	%eax		/ else return 1
111.ret:
112	jmp	*20(%edx)	/ return to caller
113	SET_SIZE(siglongjmp)
114	SET_SIZE(longjmp)
115
116#endif	/* __lint */
117