Shin-ichiro KAWASAKI | 1009327 | 2009-09-28 16:11:39 +0900 | [diff] [blame] | 1 | /* $OpenBSD: sigsetjmp.S,v 1.2 2007/03/02 06:11:54 miod Exp $ */ |
| 2 | /* $NetBSD: sigsetjmp.S,v 1.9 2006/01/05 19:21:37 uwe Exp $ */ |
| 3 | |
| 4 | /*- |
| 5 | * Copyright (c) 1990 The Regents of the University of California. |
| 6 | * All rights reserved. |
| 7 | * |
| 8 | * This code is derived from software contributed to Berkeley by |
| 9 | * William Jolitz. |
| 10 | * |
| 11 | * Redistribution and use in source and binary forms, with or without |
| 12 | * modification, are permitted provided that the following conditions |
| 13 | * are met: |
| 14 | * 1. Redistributions of source code must retain the above copyright |
| 15 | * notice, this list of conditions and the following disclaimer. |
| 16 | * 2. Redistributions in binary form must reproduce the above copyright |
| 17 | * notice, this list of conditions and the following disclaimer in the |
| 18 | * documentation and/or other materials provided with the distribution. |
| 19 | * 3. Neither the name of the University nor the names of its contributors |
| 20 | * may be used to endorse or promote products derived from this software |
| 21 | * without specific prior written permission. |
| 22 | * |
| 23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 33 | * SUCH DAMAGE. |
| 34 | * |
| 35 | * from: @(#)setjmp.s 5.1 (Berkeley) 4/23/90 |
| 36 | */ |
| 37 | |
| 38 | #include <machine/asm.h> |
| 39 | #include <machine/setjmp.h> |
| 40 | |
| 41 | ENTRY(sigsetjmp) |
| 42 | tst r5, r5 /* if (savemask == 0) */ |
| 43 | bt 2f |
| 44 | |
| 45 | /* identical to setjmp */ |
| 46 | PIC_PROLOGUE(.L_got_1) |
| 47 | sts.l pr, @-sp |
| 48 | mov.l r4, @-sp |
| 49 | mov.l r5, @-sp |
| 50 | |
| 51 | mov.l .L_sigprocmask_1, r0 |
| 52 | mov r4, r6 |
| 53 | mov #1, r4 /* how = SIG_BLOCK */ |
| 54 | mov #0, r5 /* new = NULL */ |
| 55 | 1: CALL r0 |
| 56 | add #4, r6 /* old = &sigmask */ |
| 57 | |
| 58 | mov.l @sp+, r5 |
| 59 | mov.l @sp+, r4 |
| 60 | lds.l @sp+, pr |
| 61 | PIC_EPILOGUE |
| 62 | |
| 63 | 2: /* identical to _setjmp except that first word is in r5 */ |
| 64 | #if defined(__SH4__) && !defined(__SH4_NOFPU__) |
| 65 | add #(_JBLEN * 4), r4 |
| 66 | sts fpscr, r1 |
| 67 | xor r0, r0 |
| 68 | mov.l r1, @-r4 |
| 69 | lds r0, fpscr |
| 70 | sts.l fpul, @-r4 |
| 71 | fmov.s fr15, @-r4 |
| 72 | fmov.s fr14, @-r4 |
| 73 | fmov.s fr13, @-r4 |
| 74 | fmov.s fr12, @-r4 |
| 75 | frchg |
| 76 | fmov.s fr15, @-r4 |
| 77 | fmov.s fr14, @-r4 |
| 78 | fmov.s fr13, @-r4 |
| 79 | fmov.s fr12, @-r4 |
| 80 | lds r1, fpscr |
| 81 | #else |
| 82 | add #((_JBLEN - 10) * 4), r4 |
| 83 | #endif |
| 84 | sts.l mach, @-r4 |
| 85 | sts.l macl, @-r4 |
| 86 | mov.l r15, @-r4 |
| 87 | mov.l r14, @-r4 |
| 88 | mov.l r13, @-r4 |
| 89 | mov.l r12, @-r4 |
| 90 | mov.l r11, @-r4 |
| 91 | mov.l r10, @-r4 |
| 92 | mov.l r9, @-r4 |
| 93 | mov.l r8, @-r4 |
| 94 | sts.l pr, @-r4 |
| 95 | add #-4, r4 /* skip signal mask */ |
| 96 | mov.l r5, @-r4 /* has signal mask? */ |
| 97 | rts |
| 98 | xor r0, r0 |
| 99 | |
| 100 | .align 2 |
| 101 | .L_got_1: PIC_GOT_DATUM |
| 102 | .L_sigprocmask_1: CALL_DATUM(_C_LABEL(sigprocmask), 1b) |
| 103 | SET_ENTRY_SIZE(sigsetjmp) |
| 104 | |
| 105 | ENTRY(siglongjmp) |
| 106 | mov.l @r4+, r0 |
| 107 | tst r0, r0 |
| 108 | bt 2f /* if no mask */ |
| 109 | |
| 110 | /* identical to longjmp */ |
| 111 | /* we won't return here, so we don't need to save pr and r12 */ |
| 112 | PIC_PROLOGUE_NOSAVE(.L_got_2) |
| 113 | mov.l r5, @-sp |
| 114 | mov.l r4, @-sp |
| 115 | |
| 116 | mov.l .L_sigprocmask_2, r0 |
| 117 | mov r4, r5 /* new = &sigmask */ |
| 118 | mov #3, r4 /* how = SIG_SETMASK */ |
| 119 | 1: CALL r0 |
| 120 | mov #0, r6 /* old = NULL */ |
| 121 | |
| 122 | mov.l @sp+, r4 |
| 123 | mov.l @sp+, r5 |
| 124 | |
| 125 | 2: /* identical to _longjmp */ |
| 126 | add #4, r4 |
| 127 | lds.l @r4+, pr |
| 128 | mov.l @r4+, r8 |
| 129 | mov.l @r4+, r9 |
| 130 | mov.l @r4+, r10 |
| 131 | mov.l @r4+, r11 |
| 132 | mov.l @r4+, r12 |
| 133 | mov.l @r4+, r13 |
| 134 | mov.l @r4+, r14 |
| 135 | mov.l @r4+, r15 |
| 136 | lds.l @r4+, macl |
| 137 | lds.l @r4+, mach |
| 138 | #if defined(__SH4__) && !defined(__SH4_NOFPU__) |
| 139 | xor r0, r0 |
| 140 | lds r0, fpscr |
| 141 | frchg |
| 142 | fmov.s @r4+, fr12 |
| 143 | fmov.s @r4+, fr13 |
| 144 | fmov.s @r4+, fr14 |
| 145 | fmov.s @r4+, fr15 |
| 146 | frchg |
| 147 | fmov.s @r4+, fr12 |
| 148 | fmov.s @r4+, fr13 |
| 149 | fmov.s @r4+, fr14 |
| 150 | fmov.s @r4+, fr15 |
| 151 | lds.l @r4+, fpul |
| 152 | lds.l @r4+, fpscr |
| 153 | #endif |
| 154 | |
| 155 | mov r5, r0 |
| 156 | tst r0, r0 /* make sure return value is non-zero */ |
| 157 | bf .L0 |
| 158 | add #1, r0 |
| 159 | .L0: |
| 160 | rts |
| 161 | nop |
| 162 | |
| 163 | .align 2 |
| 164 | .L_got_2: PIC_GOT_DATUM |
| 165 | .L_sigprocmask_2: CALL_DATUM(_C_LABEL(sigprocmask), 1b) |
| 166 | SET_ENTRY_SIZE(siglongjmp) |