1 /* Copyright (C) 1991, 1993, 1996, 1997, 1998 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
23 #include <bits/setjmp.h>
24 #define ENV(reg) [%g1 + (reg * 4)]
27 /* Store our arguments in global registers so we can still
28 use them while unwinding frames and their register windows. */
29 mov %o0, %g1 /* ENV in %g1 */
30 orcc %o1, %g0, %g2 /* VAL in %g2 */
31 be,a 0f /* Branch if zero; else skip delay slot. */
32 mov 1, %g2 /* Delay slot only hit if zero: VAL = 1. */
34 /* Cache target FP in register %g3. */
37 /* Now we will loop, unwinding the register windows up the stack
38 until the restored %fp value matches the target value in %g3. */
41 cmp %fp, %g3 /* Have we reached the target frame? */
42 bl,a LOC(loop) /* Loop while current fp is below target. */
43 restore /* Unwind register window in delay slot. */
44 be,a LOC(found) /* Better have hit it exactly. */
45 ld ENV(JB_SP), %o0 /* Delay slot: extract target SP. */
48 /* Get here only if the jmp_buf or stack is clobbered. */
49 call C_SYMBOL_NAME(abort)
54 /* We have unwound register windows so %fp matches the target. */
55 cmp %o0, %sp /* Check jmp_buf SP vs register window. */
56 bge,a LOC(sp_ok) /* Saved must not be deeper than register. */
57 mov %o0, %sp /* OK, install new SP. */
58 b,a LOC(bogus) /* Bogus, we lose. */
61 ld ENV(JB_PC), %o0 /* Extract target return PC. */
62 jmp %o0 + 8 /* Return there. */
63 mov %g2, %o0 /* Delay slot: set return value. */