]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/sparc/sparc32/__longjmp.S
Update.
[thirdparty/glibc.git] / sysdeps / sparc / sparc32 / __longjmp.S
1 /* Copyright (C) 1991, 1993, 1996, 1997 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
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.
8
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.
13
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. */
18
19 #include <sysdep.h>
20
21 #define _ASM 1
22 #include <bits/setjmp.h>
23 #define ENV(reg) [%g1 + (reg * 4)]
24
25 ENTRY (__longjmp)
26 /* Store our arguments in global registers so we can still
27 use them while unwinding frames and their register windows. */
28 mov %o0, %g1 /* ENV in %g1 */
29 orcc %o1, %g0, %g6 /* VAL in %g6 */
30 be,a 0f /* Branch if zero; else skip delay slot. */
31 mov 1, %g6 /* Delay slot only hit if zero: VAL = 1. */
32 0:
33
34 /* Cache target FP in register %g7. */
35 ld ENV (JB_FP), %g7
36
37 /* Now we will loop, unwinding the register windows up the stack
38 until the restored %fp value matches the target value in %g7. */
39
40 loop: cmp %fp, %g7 /* Have we reached the target frame? */
41 bl,a loop /* Loop while current fp is below target. */
42 restore /* Unwind register window in delay slot. */
43 be,a found /* Better have hit it exactly. */
44 ld ENV (JB_SP), %o0 /* Delay slot: extract target SP. */
45
46 bogus: /* Get here only if the jmp_buf or stack is clobbered. */
47 call C_SYMBOL_NAME (abort)
48 nop
49 unimp 0
50
51 found: /* We have unwound register windows so %fp matches the target. */
52 cmp %o0, %sp /* Check jmp_buf SP vs register window. */
53 bge,a sp_ok /* Saved must not be deeper than register. */
54 mov %o0, %sp /* OK, install new SP. */
55 b,a bogus /* Bogus, we lose. */
56
57 sp_ok: ld ENV (JB_PC), %o0 /* Extract target return PC. */
58 jmp %o0 + 8 /* Return there. */
59 mov %g6, %o0 /* Delay slot: set return value. */