setjmp.S revision 165903
1164426Ssam/*-
2164426Ssam * Copyright (c) 1990 The Regents of the University of California.
3164426Ssam * All rights reserved.
4164426Ssam *
5164426Ssam * This code is derived from software contributed to Berkeley by
6164426Ssam * William Jolitz.
7164426Ssam *
8164426Ssam * Redistribution and use in source and binary forms, with or without
9164426Ssam * modification, are permitted provided that the following conditions
10164426Ssam * are met:
11164426Ssam * 1. Redistributions of source code must retain the above copyright
12164426Ssam *    notice, this list of conditions and the following disclaimer.
13164426Ssam * 2. Redistributions in binary form must reproduce the above copyright
14164426Ssam *    notice, this list of conditions and the following disclaimer in the
15164426Ssam *    documentation and/or other materials provided with the distribution.
16164426Ssam * 4. Neither the name of the University nor the names of its contributors
17164426Ssam *    may be used to endorse or promote products derived from this software
18164426Ssam *    without specific prior written permission.
19164426Ssam *
20164426Ssam * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21164426Ssam * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22164426Ssam * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23164426Ssam * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24164426Ssam * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25164426Ssam * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26164426Ssam * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27164426Ssam * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28164426Ssam * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29164426Ssam * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30164426Ssam * SUCH DAMAGE.
31164426Ssam */
32164426Ssam
33164426Ssam#if defined(LIBC_SCCS) && !defined(lint)
34164426Ssam	.asciz "@(#)setjmp.s	5.1 (Berkeley) 4/23/90"
35164426Ssam#endif /* LIBC_SCCS and not lint */
36164426Ssam#include <machine/asm.h>
37164426Ssam__FBSDID("$FreeBSD: head/lib/libc/i386/gen/setjmp.S 165903 2007-01-09 00:28:16Z imp $");
38164426Ssam
39164426Ssam/*
40164426Ssam * C library -- _setjmp, _longjmp
41164426Ssam *
42164426Ssam *	longjmp(a,v)
43164426Ssam * will generate a "return(v)" from the last call to
44164426Ssam *	setjmp(a)
45164426Ssam * by restoring registers from the environment 'a'.
46164426Ssam * The previous signal state is restored.
47164426Ssam */
48164426Ssam
49186352Ssam#include "SYS.h"
50186418Ssam
51186352SsamENTRY(setjmp)
52186352Ssam	movl	4(%esp),%ecx
53186352Ssam	PIC_PROLOGUE
54164426Ssam	leal	28(%ecx), %eax
55164426Ssam	pushl	%eax			/* (sigset_t*)oset */
56164426Ssam	pushl	$0			/* (sigset_t*)set  */
57164426Ssam	pushl	$1			/* SIG_BLOCK       */
58164426Ssam	call	PIC_PLT(CNAME(_sigprocmask))
59164426Ssam	addl	$12,%esp
60164426Ssam	PIC_EPILOGUE
61164426Ssam	movl	4(%esp),%ecx
62164426Ssam	movl	0(%esp),%edx
63164426Ssam	movl	%edx, 0(%ecx)
64166064Scognet	movl	%ebx, 4(%ecx)
65164426Ssam	movl	%esp, 8(%ecx)
66164426Ssam	movl	%ebp,12(%ecx)
67194653Ssam	movl	%esi,16(%ecx)
68194653Ssam	movl	%edi,20(%ecx)
69164426Ssam	fnstcw	24(%ecx)
70164426Ssam	xorl	%eax,%eax
71164426Ssam	ret
72164426Ssam
73164426Ssam	.weak CNAME(longjmp)
74164426Ssam	.set CNAME(longjmp),CNAME(__longjmp)
75164426SsamENTRY(__longjmp)
76164426Ssam	movl	4(%esp),%edx
77164426Ssam	PIC_PROLOGUE
78164426Ssam	pushl	$0			/* (sigset_t*)oset */
79164426Ssam	leal	28(%edx), %eax
80164426Ssam	pushl	%eax			/* (sigset_t*)set  */
81164426Ssam	pushl	$3			/* SIG_SETMASK     */
82164426Ssam	call	PIC_PLT(CNAME(_sigprocmask))
83166064Scognet	addl	$12,%esp
84164426Ssam	PIC_EPILOGUE
85164426Ssam	movl	4(%esp),%edx
86164426Ssam	movl	8(%esp),%eax
87164426Ssam	movl	0(%edx),%ecx
88164426Ssam	movl	4(%edx),%ebx
89164426Ssam	movl	8(%edx),%esp
90164426Ssam	movl	12(%edx),%ebp
91164426Ssam	movl	16(%edx),%esi
92164426Ssam	movl	20(%edx),%edi
93164426Ssam	fninit
94164426Ssam	fldcw	24(%edx)
95215319Sthompsa	testl	%eax,%eax
96215319Sthompsa	jnz	1f
97215319Sthompsa	incl	%eax
98164426Ssam1:	movl	%ecx,0(%esp)
99164426Ssam	ret
100164426Ssam