2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Modified for incorporation into newlib by Joel Sherrill
6 * (joel@OARcorp.com), On-Line Applications Research, 1995.
9 * + removed error check since it prevented using this setjmp
11 * + added the support for the "user label" and "register" prefix
13 * This software was developed by the Computer Systems Engineering group
14 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
15 * contributed to Berkeley.
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions
20 * 1. Redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer.
22 * 2. Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution.
25 * 3. Neither the name of the University nor the names of its contributors
26 * may be used to endorse or promote products derived from this software
27 * without specific prior written permission.
29 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
44 #if defined(LIBC_SCCS) && !defined(lint)
45 .asciz "@(#)_setjmp.s 8.1 (Berkeley) 6/4/93"
46 #endif /* LIBC_SCCS and not lint */
49 * Recent versions of GNU cpp define variables which indicate the
50 * need for underscores and percents. If not using GNU cpp or
51 * the version does not support this, then you will obviously
52 * have to define these as appropriate.
55 #ifndef __USER_LABEL_PREFIX__
56 #define __USER_LABEL_PREFIX__ _
59 #ifndef __REGISTER_PREFIX__
60 #define __REGISTER_PREFIX__
63 /* ANSI concatenation macros. */
65 #define CONCAT1(a, b) CONCAT2(a, b)
66 #define CONCAT2(a, b) a ## b
68 /* Use the right prefix for global labels. */
70 #define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x)
72 /*********************************************************************
73 *********************************************************************
74 * Contents of DEFS.h *
75 *********************************************************************
76 *********************************************************************/
80 .align 4; .globl SYM(x); .proc 1; SYM(x):; .data; .align 4; 1: .long 0; \
81 .text; save %sp,-96,%sp; sethi %hi(1b),%o0; call mcount; \
82 or %lo(1b),%o0,%o0; restore
85 .align 4; .globl SYM(x); .proc 1; SYM(x):
90 /*********************************************************************
91 *********************************************************************
93 *********************************************************************
94 *********************************************************************/
98 * C library -- _setjmp, _longjmp
101 * will generate a "return(v?v:1)" from
104 * by unwinding the call stack.
105 * The previous signal state is NOT restored.
109 /* #include "DEFS.h" */
113 ta 0x03 /* Flush registers, just in case another stack
114 is used after the setjmp(). */
115 st %sp, [%o0] /* caller's stack pointer */
116 st %i7, [%o0+4] /* caller's return pc */
117 st %fp, [%o0+8] /* store caller's frame pointer */
124 ta 0x03 /* flush registers */
125 addcc %o1, %g0, %g1 ! compute v ? v : 1 in a global register
129 ld [%o0], %sp /* caller's stack pointer */
140 ld [%o0+4], %i7 /* caller's return pc */
141 ld [%o0+8], %fp /* caller's frame pointer */
144 jmp %o7 + 8 ! success, return %g1