xref: /onnv-gate/usr/src/cmd/mdb/intel/ia32/libstand/setjmp.s (revision 0:68f95e015346)
1*0Sstevel@tonic-gate/*
2*0Sstevel@tonic-gate * CDDL HEADER START
3*0Sstevel@tonic-gate *
4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate * with the License.
8*0Sstevel@tonic-gate *
9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate * and limitations under the License.
13*0Sstevel@tonic-gate *
14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate *
20*0Sstevel@tonic-gate * CDDL HEADER END
21*0Sstevel@tonic-gate */
22*0Sstevel@tonic-gate/*
23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate * Use is subject to license terms.
25*0Sstevel@tonic-gate */
26*0Sstevel@tonic-gate
27*0Sstevel@tonic-gate#pragma ident	"%Z%%M%	%I%	%E% SMI"
28*0Sstevel@tonic-gate
29*0Sstevel@tonic-gate#if defined(__lint)
30*0Sstevel@tonic-gate#include <setjmp.h>
31*0Sstevel@tonic-gate#endif
32*0Sstevel@tonic-gate
33*0Sstevel@tonic-gate#include <sys/asm_linkage.h>
34*0Sstevel@tonic-gate
35*0Sstevel@tonic-gate/*
36*0Sstevel@tonic-gate *	longjmp(env, val)
37*0Sstevel@tonic-gate * will generate a "return(val)" from
38*0Sstevel@tonic-gate * the last call to
39*0Sstevel@tonic-gate *	setjmp(env)
40*0Sstevel@tonic-gate * by restoring registers ip, sp, bp, bx, si, and di from 'env'
41*0Sstevel@tonic-gate * and doing a return.
42*0Sstevel@tonic-gate *
43*0Sstevel@tonic-gate * entry    reg	offset from (%si)
44*0Sstevel@tonic-gate * env[0] = %ebx	 0	/ register variables
45*0Sstevel@tonic-gate * env[1] = %esi	 4
46*0Sstevel@tonic-gate * env[2] = %edi	 8
47*0Sstevel@tonic-gate * env[3] = %ebp	 12	/ stack frame
48*0Sstevel@tonic-gate * env[4] = %esp	 16
49*0Sstevel@tonic-gate * env[5] = %eip	 20
50*0Sstevel@tonic-gate */
51*0Sstevel@tonic-gate
52*0Sstevel@tonic-gate#if defined(__lint)
53*0Sstevel@tonic-gate/* ARGSUSED */
54*0Sstevel@tonic-gateint
55*0Sstevel@tonic-gatesetjmp(jmp_buf env)
56*0Sstevel@tonic-gate{
57*0Sstevel@tonic-gate	return (0);
58*0Sstevel@tonic-gate}
59*0Sstevel@tonic-gate
60*0Sstevel@tonic-gate/* ARGSUSED */
61*0Sstevel@tonic-gateint
62*0Sstevel@tonic-gatesigsetjmp(sigjmp_buf env, int savemask)
63*0Sstevel@tonic-gate{
64*0Sstevel@tonic-gate	return (0);
65*0Sstevel@tonic-gate}
66*0Sstevel@tonic-gate#else	/* __lint */
67*0Sstevel@tonic-gate
68*0Sstevel@tonic-gate	ENTRY(setjmp)
69*0Sstevel@tonic-gate	ALTENTRY(sigsetjmp)
70*0Sstevel@tonic-gate	movl	4(%esp),%eax	/ jmpbuf address
71*0Sstevel@tonic-gate	movl	%ebx,0(%eax)	/ save ebx
72*0Sstevel@tonic-gate	movl	%esi,4(%eax)	/ save esi
73*0Sstevel@tonic-gate	movl	%edi,8(%eax)	/ save edi
74*0Sstevel@tonic-gate	movl	%ebp,12(%eax)	/ save caller's ebp
75*0Sstevel@tonic-gate	popl	%edx		/ return address
76*0Sstevel@tonic-gate	movl	%esp,16(%eax)	/ save caller's esp
77*0Sstevel@tonic-gate	movl	%edx,20(%eax)
78*0Sstevel@tonic-gate	subl	%eax,%eax	/ return 0
79*0Sstevel@tonic-gate	jmp	*%edx
80*0Sstevel@tonic-gate	SET_SIZE(sigsetjmp)
81*0Sstevel@tonic-gate	SET_SIZE(setjmp)
82*0Sstevel@tonic-gate
83*0Sstevel@tonic-gate#endif	/* __lint */
84*0Sstevel@tonic-gate
85*0Sstevel@tonic-gate#if defined(__lint)
86*0Sstevel@tonic-gate/* ARGSUSED */
87*0Sstevel@tonic-gatevoid
88*0Sstevel@tonic-gatelongjmp(jmp_buf env, int val)
89*0Sstevel@tonic-gate{
90*0Sstevel@tonic-gate}
91*0Sstevel@tonic-gate
92*0Sstevel@tonic-gate/* ARGSUSED */
93*0Sstevel@tonic-gatevoid
94*0Sstevel@tonic-gatesiglongjmp(sigjmp_buf env, int val)
95*0Sstevel@tonic-gate{
96*0Sstevel@tonic-gate}
97*0Sstevel@tonic-gate#else	/* __lint */
98*0Sstevel@tonic-gate
99*0Sstevel@tonic-gate	ENTRY(longjmp)
100*0Sstevel@tonic-gate	ALTENTRY(siglongjmp)
101*0Sstevel@tonic-gate	movl	4(%esp),%edx	/ first parameter after return addr
102*0Sstevel@tonic-gate	movl	8(%esp),%eax	/ second parameter
103*0Sstevel@tonic-gate	movl	0(%edx),%ebx	/ restore ebx
104*0Sstevel@tonic-gate	movl	4(%edx),%esi	/ restore esi
105*0Sstevel@tonic-gate	movl	8(%edx),%edi	/ restore edi
106*0Sstevel@tonic-gate	movl	12(%edx),%ebp	/ restore caller's ebp
107*0Sstevel@tonic-gate	movl	16(%edx),%esp	/ restore caller's esp
108*0Sstevel@tonic-gate	test	%eax,%eax	/ if val != 0
109*0Sstevel@tonic-gate	jnz	.ret		/ 	return val
110*0Sstevel@tonic-gate	incl	%eax		/ else return 1
111*0Sstevel@tonic-gate.ret:
112*0Sstevel@tonic-gate	jmp	*20(%edx)	/ return to caller
113*0Sstevel@tonic-gate	SET_SIZE(siglongjmp)
114*0Sstevel@tonic-gate	SET_SIZE(longjmp)
115*0Sstevel@tonic-gate
116*0Sstevel@tonic-gate#endif	/* __lint */
117