_setjmp.S revision 22993
1133129Smarkm/*-
2133129Smarkm * Copyright (c) 1990 The Regents of the University of California.
3133129Smarkm * All rights reserved.
4133129Smarkm *
5133129Smarkm * This code is derived from software contributed to Berkeley by
6133129Smarkm * William Jolitz.
7133129Smarkm *
8133129Smarkm * Redistribution and use in source and binary forms, with or without
9133129Smarkm * modification, are permitted provided that the following conditions
10133129Smarkm * are met:
11133129Smarkm * 1. Redistributions of source code must retain the above copyright
12133129Smarkm *    notice, this list of conditions and the following disclaimer.
13133129Smarkm * 2. Redistributions in binary form must reproduce the above copyright
14133129Smarkm *    notice, this list of conditions and the following disclaimer in the
15133129Smarkm *    documentation and/or other materials provided with the distribution.
16133129Smarkm * 3. All advertising materials mentioning features or use of this software
17133129Smarkm *    must display the following acknowledgement:
18133129Smarkm *	This product includes software developed by the University of
19133129Smarkm *	California, Berkeley and its contributors.
20133129Smarkm * 4. Neither the name of the University nor the names of its contributors
21133129Smarkm *    may be used to endorse or promote products derived from this software
22133129Smarkm *    without specific prior written permission.
23133129Smarkm *
24133129Smarkm * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25133129Smarkm * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26133129Smarkm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27133129Smarkm * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28133129Smarkm * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29133129Smarkm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30133129Smarkm * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31217515Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32217515Sjkim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33133129Smarkm * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34133129Smarkm * SUCH DAMAGE.
35217515Sjkim *
36133129Smarkm *	$Id$
37133129Smarkm */
38217515Sjkim
39217515Sjkim#if defined(LIBC_RCS) && !defined(lint)
40133129Smarkm	.text
41133129Smarkm	.asciz "$Id$"
42133129Smarkm#endif /* LIBC_RCS and not lint */
43133129Smarkm
44217515Sjkim/*
45217515Sjkim * C library -- _setjmp, _longjmp
46217515Sjkim *
47217515Sjkim *	_longjmp(a,v)
48217515Sjkim * will generate a "return(v)" from the last call to
49217515Sjkim *	_setjmp(a)
50217515Sjkim * by restoring registers from the environment 'a'.
51217515Sjkim * The previous signal state is NOT restored.
52217515Sjkim */
53217515Sjkim
54217515Sjkim#include "DEFS.h"
55217515Sjkim
56217515Sjkim#ifdef _THREAD_SAFE
57217515SjkimENTRY(__thread_sys_setjmp)
58217515Sjkim#else
59217515SjkimENTRY(_setjmp)
60217515Sjkim#endif
61217515Sjkim	movl	4(%esp),%eax
62217515Sjkim	movl	0(%esp),%edx
63133129Smarkm	movl	%edx, 0(%eax)		/* rta */
64133129Smarkm	movl	%ebx, 4(%eax)
65133129Smarkm	movl	%esp, 8(%eax)
66217515Sjkim	movl	%ebp,12(%eax)
67217515Sjkim	movl	%esi,16(%eax)
68133129Smarkm	movl	%edi,20(%eax)
69133129Smarkm	fnstcw	28(%eax)
70217515Sjkim	xorl	%eax,%eax
71217515Sjkim	ret
72217515Sjkim
73133129Smarkm#ifdef _THREAD_SAFE
74133129SmarkmENTRY(__thread_sys_longjmp)
75217515Sjkim#else
76217515SjkimENTRY(_longjmp)
77133129Smarkm#endif
78133129Smarkm	movl	4(%esp),%edx
79133129Smarkm	movl	8(%esp),%eax
80133129Smarkm	movl	0(%edx),%ecx
81133129Smarkm	movl	4(%edx),%ebx
82133129Smarkm	movl	8(%edx),%esp
83217515Sjkim	movl	12(%edx),%ebp
84217515Sjkim	movl	16(%edx),%esi
85133129Smarkm	movl	20(%edx),%edi
86133129Smarkm	fninit
87217515Sjkim	fldcw	28(%edx)
88217515Sjkim	testl	%eax,%eax
89217515Sjkim	jnz	1f
90217515Sjkim	incl	%eax
91133129Smarkm1:	movl	%ecx,0(%esp)
92	ret
93