]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - lib/libc/mips/gen/_setjmp.S
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / lib / libc / mips / gen / _setjmp.S
1 /*      $NetBSD: _setjmp.S,v 1.20 2005/10/07 17:16:40 tsutsui Exp $     */
2
3 /*-
4  * Copyright (c) 1991, 1993
5  *      The Regents of the University of California.  All rights reserved.
6  *
7  * This code is derived from software contributed to Berkeley by
8  * Ralph Campbell.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
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.
21  *
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
32  * SUCH DAMAGE.
33  */
34
35 #include <machine/asm.h>
36 __FBSDID("$FreeBSD$");
37 #include <machine/regnum.h>
38
39 #if defined(LIBC_SCCS) && !defined(lint)
40         ASMSTR("from: @(#)_setjmp.s     8.1 (Berkeley) 6/4/93")
41         ASMSTR("$NetBSD: _setjmp.S,v 1.20 2005/10/07 17:16:40 tsutsui Exp $")
42 #endif /* LIBC_SCCS and not lint */
43
44 #ifdef __ABICALLS__
45         .abicalls
46 #endif
47
48 /*
49  * C library -- _setjmp, _longjmp
50  *
51  *      _longjmp(a,v)
52  * will generate a "return(v)" from
53  * the last call to
54  *      _setjmp(a)
55  * by restoring registers from the stack,
56  * The previous signal state is NOT restored.
57  */
58
59
60 LEAF(_setjmp)
61 #ifdef __ABICALLS__ 
62         .set    noreorder
63         .cpload t9
64         subu    sp, sp, CALLFRAME_SIZ   # allocate stack frame
65         .cprestore 16
66 #endif
67         li      v0, _JB_MAGIC__SETJMP
68         sw      v0, (_JB_MAGIC  * SZREG)(a0)
69         sw      ra, (_JB_REG_RA * SZREG)(a0)
70         sw      s0, (_JB_REG_S0 * SZREG)(a0)
71         sw      s1, (_JB_REG_S1 * SZREG)(a0)
72         sw      s2, (_JB_REG_S2 * SZREG)(a0)
73         sw      s3, (_JB_REG_S3 * SZREG)(a0)
74         sw      s4, (_JB_REG_S4 * SZREG)(a0)
75         sw      s5, (_JB_REG_S5 * SZREG)(a0)
76         sw      s6, (_JB_REG_S6 * SZREG)(a0)
77         sw      s7, (_JB_REG_S7 * SZREG)(a0)
78         sw      s8, (_JB_REG_S8 * SZREG)(a0)
79 #ifdef __ABICALLS__
80         addu    sp, sp, CALLFRAME_SIZ   # un-allocate the stack frame
81 #endif  
82         sw      sp, (_JB_REG_SP * SZREG)(a0)
83         j       ra
84         move    v0, zero
85 END(_setjmp)
86
87 LEAF(_longjmp)
88 #ifdef __ABICALLS__ 
89         .set    noreorder
90         .cpload t9
91         subu    sp, sp, CALLFRAME_SIZ   # allocate stack frame
92         .cprestore 16
93 #endif  
94         lw      v0, (_JB_MAGIC  * SZREG)(a0)
95         lw      ra, (_JB_REG_RA * SZREG)(a0)
96         li      t0, _JB_MAGIC__SETJMP
97         bne     v0, t0, botch           # jump if error
98         lw      s0, (_JB_REG_S0 * SZREG)(a0)
99         lw      s1, (_JB_REG_S1 * SZREG)(a0)
100         lw      s2, (_JB_REG_S2 * SZREG)(a0)
101         lw      s3, (_JB_REG_S3 * SZREG)(a0)
102         lw      s4, (_JB_REG_S4 * SZREG)(a0)
103         lw      s5, (_JB_REG_S5 * SZREG)(a0)
104         lw      s6, (_JB_REG_S6 * SZREG)(a0)
105         lw      s7, (_JB_REG_S7 * SZREG)(a0)
106         lw      sp, (_JB_REG_SP * SZREG)(a0)
107         lw      s8, (_JB_REG_S8 * SZREG)(a0)
108
109         j       ra
110         move    v0, a1
111
112 botch:
113         jal     _C_LABEL(longjmperror)
114         nop
115         jal     _C_LABEL(abort)
116         nop
117 END(_longjmp)