1 /* $NetBSD: _setjmp.S,v 1.20.34.5 2010/02/03 23:46:47 matt Exp $ */
4 * Copyright (c) 1991, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #include <machine/asm.h>
36 __FBSDID("$FreeBSD$");
37 #include <machine/regnum.h>
41 #if defined(LIBC_SCCS) && !defined(lint)
43 RCSID("from: @(#)_setjmp.s 8.1 (Berkeley) 6/4/93")
45 RCSID("$NetBSD: _setjmp.S,v 1.20.34.5 2010/02/03 23:46:47 matt Exp $")
47 #endif /* LIBC_SCCS and not lint */
50 * C library -- _setjmp, _longjmp
53 * will generate a "return(v)" from
56 * by restoring registers from the stack,
57 * The previous signal state is NOT restored.
64 REG_LI v0, _JB_MAGIC__SETJMP
65 REG_S v0, (_JB_MAGIC * SZREG)(a0)
66 REG_S ra, (_JB_REG_RA * SZREG)(a0)
67 REG_S s0, (_JB_REG_S0 * SZREG)(a0)
68 REG_S s1, (_JB_REG_S1 * SZREG)(a0)
69 REG_S s2, (_JB_REG_S2 * SZREG)(a0)
70 REG_S s3, (_JB_REG_S3 * SZREG)(a0)
71 REG_S s4, (_JB_REG_S4 * SZREG)(a0)
72 REG_S s5, (_JB_REG_S5 * SZREG)(a0)
73 REG_S s6, (_JB_REG_S6 * SZREG)(a0)
74 REG_S s7, (_JB_REG_S7 * SZREG)(a0)
75 REG_S s8, (_JB_REG_S8 * SZREG)(a0)
76 #if defined(__mips_n32) || defined(__mips_n64)
77 REG_S gp, (_JB_REG_GP * SZREG)(a0) # newabi gp is callee-saved
79 REG_S sp, (_JB_REG_SP * SZREG)(a0)
87 PIC_PROLOGUE(_longjmp)
88 PTR_SUBU sp, sp, CALLFRAME_SIZ
92 REG_L v0, (_JB_MAGIC * SZREG)(a0) # get magic number
93 REG_L ra, (_JB_REG_RA * SZREG)(a0)
94 REG_LI t0, _JB_MAGIC__SETJMP
95 bne v0, t0, botch # jump if error
96 PTR_ADDU sp, sp, CALLFRAME_SIZ # does not matter, sanity
97 REG_L s0, (_JB_REG_S0 * SZREG)(a0)
98 REG_L s1, (_JB_REG_S1 * SZREG)(a0)
99 REG_L s2, (_JB_REG_S2 * SZREG)(a0)
100 REG_L s3, (_JB_REG_S3 * SZREG)(a0)
101 REG_L s4, (_JB_REG_S4 * SZREG)(a0)
102 REG_L s5, (_JB_REG_S5 * SZREG)(a0)
103 REG_L s6, (_JB_REG_S6 * SZREG)(a0)
104 REG_L s7, (_JB_REG_S7 * SZREG)(a0)
105 #if defined(__mips_n32) || defined(__mips_n64)
106 REG_L gp, (_JB_REG_GP * SZREG)(a0)
108 REG_L sp, (_JB_REG_SP * SZREG)(a0)
109 REG_L s8, (_JB_REG_S8 * SZREG)(a0)
112 move v0, a1 # get return value in 1st arg
118 * We know we aren't returning so we don't care about restoring
121 PTR_LA t9, _C_LABEL(longjmperror)