_setjmp.S revision 56345
191094Sdes/*-
292289Sdes * Copyright (c) 1990 The Regents of the University of California.
391094Sdes * All rights reserved.
491094Sdes *
591094Sdes * This code is derived from software contributed to Berkeley by
691094Sdes * William Jolitz.
791094Sdes *
891094Sdes * Redistribution and use in source and binary forms, with or without
991094Sdes * modification, are permitted provided that the following conditions
1091094Sdes * are met:
1191094Sdes * 1. Redistributions of source code must retain the above copyright
1291094Sdes *    notice, this list of conditions and the following disclaimer.
1391094Sdes * 2. Redistributions in binary form must reproduce the above copyright
1491094Sdes *    notice, this list of conditions and the following disclaimer in the
1591094Sdes *    documentation and/or other materials provided with the distribution.
1691094Sdes * 3. All advertising materials mentioning features or use of this software
1791094Sdes *    must display the following acknowledgement:
1891094Sdes *	This product includes software developed by the University of
1991094Sdes *	California, Berkeley and its contributors.
2091094Sdes * 4. Neither the name of the University nor the names of its contributors
2191094Sdes *    may be used to endorse or promote products derived from this software
2291094Sdes *    without specific prior written permission.
2391094Sdes *
2491094Sdes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2591094Sdes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2691094Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2791094Sdes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2891094Sdes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2991094Sdes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3091094Sdes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3191094Sdes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3291094Sdes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3391094Sdes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3492289Sdes * SUCH DAMAGE.
3591094Sdes *
3691094Sdes * $FreeBSD: head/lib/libc/i386/gen/_setjmp.S 56345 2000-01-20 21:58:27Z jasone $
3791097Sdes */
3891094Sdes
3991094Sdes#if defined(LIBC_RCS) && !defined(lint)
4091094Sdes	.text
4191796Sdes	.asciz "$FreeBSD: head/lib/libc/i386/gen/_setjmp.S 56345 2000-01-20 21:58:27Z jasone $"
4291094Sdes#endif /* LIBC_RCS and not lint */
4391094Sdes
4491094Sdes/*
4591094Sdes * C library -- _setjmp, _longjmp
4691094Sdes *
4791094Sdes *	_longjmp(a,v)
4891094Sdes * will generate a "return(v)" from the last call to
4991094Sdes *	_setjmp(a)
5091094Sdes * by restoring registers from the environment 'a'.
5191100Sdes * The previous signal state is NOT restored.
5291100Sdes */
5391094Sdes
5491094Sdes#include "DEFS.h"
5591094Sdes
5691094SdesENTRY(_setjmp)
5791094Sdes	movl	4(%esp),%eax
5891094Sdes	movl	0(%esp),%edx
5991094Sdes	movl	%edx, 0(%eax)		/* rta */
6091094Sdes	movl	%ebx, 4(%eax)
6191097Sdes	movl	%esp, 8(%eax)
6291094Sdes	movl	%ebp,12(%eax)
6391094Sdes	movl	%esi,16(%eax)
6491094Sdes	movl	%edi,20(%eax)
6592289Sdes	fnstcw	24(%eax)
6692289Sdes	xorl	%eax,%eax
6792289Sdes	ret
6891094Sdes
6991094Sdes#ifdef _THREAD_SAFE
7091094SdesENTRY(___longjmp)
7191094Sdes#else
7291094SdesALTENTRY(___longjmp)
7391094SdesENTRY(_longjmp)
7491094Sdes#endif
7591094Sdes	movl	4(%esp),%edx
7691094Sdes	movl	8(%esp),%eax
7791094Sdes	movl	0(%edx),%ecx
7891094Sdes	movl	4(%edx),%ebx
7991094Sdes	movl	8(%edx),%esp
8091094Sdes	movl	12(%edx),%ebp
8191097Sdes	movl	16(%edx),%esi
8291097Sdes	movl	20(%edx),%edi
8391097Sdes	fninit
8491097Sdes	fldcw	24(%edx)
8591094Sdes	testl	%eax,%eax
8691097Sdes	jnz	1f
8791097Sdes	incl	%eax
8891097Sdes1:	movl	%ecx,0(%esp)
8991094Sdes	ret
9091094Sdes