aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes2014-12-08 19:18:32 -0600
committerGerrit Code Review2014-12-08 19:18:32 -0600
commitaa0002de89ee4753bce6e4d714e5d4cc4d9709eb (patch)
treea56104dc40c7cc7b2dab9f94afc1f50585dc5693
parent0b7d9d6f37d33a155a22efbafa911a5de54f7b65 (diff)
parentd27ae2f8d75bca71ba5c043ded5d26675ffe532b (diff)
downloadplatform-bionic-aa0002de89ee4753bce6e4d714e5d4cc4d9709eb.tar.gz
platform-bionic-aa0002de89ee4753bce6e4d714e5d4cc4d9709eb.tar.xz
platform-bionic-aa0002de89ee4753bce6e4d714e5d4cc4d9709eb.zip
Merge "Merge mips setjmp/longjmp family."
-rw-r--r--libc/arch-mips/bionic/_setjmp.S172
-rw-r--r--libc/arch-mips/bionic/setjmp.S292
-rw-r--r--libc/arch-mips/bionic/sigsetjmp.S76
-rw-r--r--libc/arch-mips/include/machine/signal.h78
-rw-r--r--libc/arch-mips/mips.mk2
-rw-r--r--libc/arch-mips64/bionic/_setjmp.S172
l---------[-rw-r--r--]libc/arch-mips64/bionic/setjmp.S190
-rw-r--r--libc/arch-mips64/bionic/sigsetjmp.S76
-rw-r--r--libc/arch-mips64/mips64.mk2
9 files changed, 287 insertions, 773 deletions
diff --git a/libc/arch-mips/bionic/_setjmp.S b/libc/arch-mips/bionic/_setjmp.S
deleted file mode 100644
index 052dacb4..00000000
--- a/libc/arch-mips/bionic/_setjmp.S
+++ /dev/null
@@ -1,172 +0,0 @@
1/* $OpenBSD: _setjmp.S,v 1.4 2005/08/07 16:40:15 espie Exp $ */
2
3/*
4 * Copyright (c) 2002 Opsycon AB (www.opsycon.se / www.opsycon.com)
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of Opsycon AB nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
19 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 */
31
32#include <private/bionic_asm.h>
33#include <machine/signal.h>
34
35/*
36 * _setjmp, _longjmp (not restoring signal state)
37 *
38 * GPOFF and FRAMESIZE must be the same for both _setjmp and _longjmp!
39 *
40 */
41
42FRAMESZ= MKFSIZ(0,4)
43GPOFF= FRAMESZ-2*REGSZ
44
45LEAF(_setjmp, FRAMESZ)
46 PTR_SUBU sp, FRAMESZ
47 SETUP_GP64(GPOFF, _setjmp)
48 SAVE_GP(GPOFF)
49 .set reorder
50
51#ifndef __LP64__
52 addiu a0, 7 # roundup jmpbuf addr to 8-byte boundary
53 li t0, ~7
54 and a0, t0
55#endif
56
57 # SC_MASK is unused here
58
59 li v0, 0xACEDBADE # sigcontext magic number
60 sw v0, SC_MAGIC(a0)
61 # callee-saved long-sized regs:
62 REG_S ra, SC_REGS+0*REGSZ(a0)
63 REG_S s0, SC_REGS+1*REGSZ(a0)
64 REG_S s1, SC_REGS+2*REGSZ(a0)
65 REG_S s2, SC_REGS+3*REGSZ(a0)
66 REG_S s3, SC_REGS+4*REGSZ(a0)
67 REG_S s4, SC_REGS+5*REGSZ(a0)
68 REG_S s5, SC_REGS+6*REGSZ(a0)
69 REG_S s6, SC_REGS+7*REGSZ(a0)
70 REG_S s7, SC_REGS+8*REGSZ(a0)
71 REG_S s8, SC_REGS+9*REGSZ(a0)
72 REG_L v0, GPOFF(sp)
73 REG_S v0, SC_REGS+10*REGSZ(a0)
74 PTR_ADDU v0, sp, FRAMESZ
75 REG_S v0, SC_REGS+11*REGSZ(a0)
76
77 cfc1 v0, $31
78
79#ifdef __LP64__
80 # callee-saved fp regs on mips n64 ABI are $f24..$f31
81 s.d $f24, SC_FPREGS+0*REGSZ_FP(a0)
82 s.d $f25, SC_FPREGS+1*REGSZ_FP(a0)
83 s.d $f26, SC_FPREGS+2*REGSZ_FP(a0)
84 s.d $f27, SC_FPREGS+3*REGSZ_FP(a0)
85 s.d $f28, SC_FPREGS+4*REGSZ_FP(a0)
86 s.d $f29, SC_FPREGS+5*REGSZ_FP(a0)
87 s.d $f30, SC_FPREGS+6*REGSZ_FP(a0)
88 s.d $f31, SC_FPREGS+7*REGSZ_FP(a0)
89#else
90 # callee-saved fp regs on mips o32 ABI are
91 # the even-numbered fp regs $f20,$f22,...$f30
92 s.d $f20, SC_FPREGS+0*REGSZ_FP(a0)
93 s.d $f22, SC_FPREGS+1*REGSZ_FP(a0)
94 s.d $f24, SC_FPREGS+2*REGSZ_FP(a0)
95 s.d $f26, SC_FPREGS+3*REGSZ_FP(a0)
96 s.d $f28, SC_FPREGS+4*REGSZ_FP(a0)
97 s.d $f30, SC_FPREGS+5*REGSZ_FP(a0)
98#endif
99 sw v0, SC_FPSR(a0)
100 move v0, zero
101 RESTORE_GP64
102 PTR_ADDU sp, FRAMESZ
103 j ra
104END(_setjmp)
105
106
107LEAF(_longjmp, FRAMESZ)
108 PTR_SUBU sp, FRAMESZ
109 SETUP_GP64(GPOFF, _longjmp)
110 SAVE_GP(GPOFF)
111 .set reorder
112
113#ifndef __LP64__
114 addiu a0, 7 # roundup jmpbuf addr to 8-byte boundary
115 li t0, ~7
116 and a0, t0
117#endif
118
119 # SC_MASK is unused here
120
121 lw v0, SC_MAGIC(a0)
122 li t0, 0xACEDBADE
123 bne v0, t0, botch # jump if error
124
125 # callee-saved long-sized regs:
126 REG_L ra, SC_REGS+0*REGSZ(a0)
127 REG_L s0, SC_REGS+1*REGSZ(a0)
128 REG_L s1, SC_REGS+2*REGSZ(a0)
129 REG_L s2, SC_REGS+3*REGSZ(a0)
130 REG_L s3, SC_REGS+4*REGSZ(a0)
131 REG_L s4, SC_REGS+5*REGSZ(a0)
132 REG_L s5, SC_REGS+6*REGSZ(a0)
133 REG_L s6, SC_REGS+7*REGSZ(a0)
134 REG_L s7, SC_REGS+8*REGSZ(a0)
135 REG_L s8, SC_REGS+9*REGSZ(a0)
136 REG_L gp, SC_REGS+10*REGSZ(a0)
137 REG_L sp, SC_REGS+11*REGSZ(a0)
138
139 lw v0, SC_FPSR(a0)
140 ctc1 v0, $31
141#ifdef __LP64__
142 # callee-saved fp regs on mips n64 ABI are $f24..$f31
143 l.d $f24, SC_FPREGS+0*REGSZ_FP(a0)
144 l.d $f25, SC_FPREGS+1*REGSZ_FP(a0)
145 l.d $f26, SC_FPREGS+2*REGSZ_FP(a0)
146 l.d $f27, SC_FPREGS+3*REGSZ_FP(a0)
147 l.d $f28, SC_FPREGS+4*REGSZ_FP(a0)
148 l.d $f29, SC_FPREGS+5*REGSZ_FP(a0)
149 l.d $f30, SC_FPREGS+6*REGSZ_FP(a0)
150 l.d $f31, SC_FPREGS+7*REGSZ_FP(a0)
151#else
152 # callee-saved fp regs on mips o32 ABI are
153 # the even-numbered fp regs $f20,$f22,...$f30
154 l.d $f20, SC_FPREGS+0*REGSZ_FP(a0)
155 l.d $f22, SC_FPREGS+1*REGSZ_FP(a0)
156 l.d $f24, SC_FPREGS+2*REGSZ_FP(a0)
157 l.d $f26, SC_FPREGS+3*REGSZ_FP(a0)
158 l.d $f28, SC_FPREGS+4*REGSZ_FP(a0)
159 l.d $f30, SC_FPREGS+5*REGSZ_FP(a0)
160#endif
161 bne a1, zero, 1f
162 li a1, 1 # never return 0!
1631:
164 move v0, a1
165 j ra
166
167botch:
168 jal longjmperror
169 jal abort
170 RESTORE_GP64
171 PTR_ADDU sp, FRAMESZ
172END(_longjmp)
diff --git a/libc/arch-mips/bionic/setjmp.S b/libc/arch-mips/bionic/setjmp.S
index a1d46955..05d0e256 100644
--- a/libc/arch-mips/bionic/setjmp.S
+++ b/libc/arch-mips/bionic/setjmp.S
@@ -1,5 +1,3 @@
1/* $OpenBSD: setjmp.S,v 1.5 2005/08/07 16:40:15 espie Exp $ */
2
3/* 1/*
4 * Copyright (c) 2001-2002 Opsycon AB (www.opsycon.se / www.opsycon.com) 2 * Copyright (c) 2001-2002 Opsycon AB (www.opsycon.se / www.opsycon.com)
5 * 3 *
@@ -28,9 +26,111 @@
28 * SUCH DAMAGE. 26 * SUCH DAMAGE.
29 * 27 *
30 */ 28 */
29/*-
30 * Copyright (c) 1991, 1993, 1995,
31 * The Regents of the University of California. All rights reserved.
32 *
33 * This code is derived from software contributed to Berkeley by
34 * Havard Eidnes.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in the
43 * documentation and/or other materials provided with the distribution.
44 * 3. Neither the name of the University nor the names of its contributors
45 * may be used to endorse or promote products derived from this software
46 * without specific prior written permission.
47 *
48 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
49 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE.
59 */
60/*
61 * Copyright (c) 1992, 1993
62 * The Regents of the University of California. All rights reserved.
63 *
64 * This code is derived from software contributed to Berkeley by
65 * Ralph Campbell.
66 *
67 * Redistribution and use in source and binary forms, with or without
68 * modification, are permitted provided that the following conditions
69 * are met:
70 * 1. Redistributions of source code must retain the above copyright
71 * notice, this list of conditions and the following disclaimer.
72 * 2. Redistributions in binary form must reproduce the above copyright
73 * notice, this list of conditions and the following disclaimer in the
74 * documentation and/or other materials provided with the distribution.
75 * 3. Neither the name of the University nor the names of its contributors
76 * may be used to endorse or promote products derived from this software
77 * without specific prior written permission.
78 *
79 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
80 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
81 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
82 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
83 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
84 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
85 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
86 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
87 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
88 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
89 * SUCH DAMAGE.
90 *
91 * @(#)signal.h 8.1 (Berkeley) 6/10/93
92 */
31 93
32#include <private/bionic_asm.h> 94#include <private/bionic_asm.h>
33#include <machine/signal.h> 95#include <machine/setjmp.h>
96
97/* On Mips32, jmpbuf begins with optional 4-byte filler so that
98 * all saved FP regs are aligned on 8-byte boundary, despite this whole
99 * struct being mis-declared to users as an array of (4-byte) longs.
100 * All the following offsets are then from the rounded-up base addr
101 */
102
103/* Fields of same size on all MIPS abis: */
104#define SC_MAGIC (0*4) /* 4 bytes, identify jmpbuf */
105#define SC_MASK (1*4) /* 4 bytes, saved signal mask */
106#define SC_FPSR (2*4) /* 4 bytes, floating point control/status reg */
107/* filler2 (3*4) 4 bytes, pad to 8-byte boundary */
108
109/* Registers that are 4-byte on mips32 o32, and 8-byte on mips64 n64 abi */
110#define SC_REGS_SAVED 12 /* ra,gp,sp,s0-s8 */
111#define SC_REGS (4*4) /* SC_REGS_SAVED*REGSZ bytes */
112
113/* Floating pt registers are 8-bytes on all abis,
114 * but the number of saved fp regs varies for o32/n32 versus n64 abis:
115 */
116
117#ifdef __LP64__
118#define SC_FPREGS_SAVED 8 /* all fp regs f24,f25,f26,f27,f28,f29,f30,f31 */
119#else
120#define SC_FPREGS_SAVED 6 /* even fp regs f20,f22,f24,f26,f28,f30 */
121#endif
122
123#define SC_FPREGS (SC_REGS + SC_REGS_SAVED*REGSZ) /* SC_FPREGS_SAVED*REGSZ_FP bytes */
124
125#define SC_BYTES (SC_FPREGS + SC_FPREGS_SAVED*REGSZ_FP)
126#define SC_LONGS (SC_BYTES/REGSZ)
127
128#ifdef __LP64__
129/* SC_LONGS is 22, so _JBLEN should be 22 or larger */
130#else
131/* SC_LONGS is 28, but must also allocate dynamic-roundup filler.
132 so _JBLEN should be 29 or larger */
133#endif
34 134
35/* 135/*
36 * _setjmp, _longjmp (restoring signal state) 136 * _setjmp, _longjmp (restoring signal state)
@@ -114,7 +214,6 @@ NON_LEAF(setjmp, FRAMESZ, ra)
114 j ra 214 j ra
115END(setjmp) 215END(setjmp)
116 216
117
118NON_LEAF(longjmp, FRAMESZ, ra) 217NON_LEAF(longjmp, FRAMESZ, ra)
119 .mask 0x80000000, RAOFF 218 .mask 0x80000000, RAOFF
120 PTR_SUBU sp, FRAMESZ 219 PTR_SUBU sp, FRAMESZ
@@ -137,7 +236,7 @@ NON_LEAF(longjmp, FRAMESZ, ra)
137 236
138 lw v0, SC_MAGIC(a0) 237 lw v0, SC_MAGIC(a0)
139 li t0, 0xACEDBADE 238 li t0, 0xACEDBADE
140 bne v0, t0, botch # jump if error 239 bne v0, t0, longjmp_botch # jump if error
141 240
142 # callee-saved long-sized regs: 241 # callee-saved long-sized regs:
143 REG_L ra, SC_REGS+0*REGSZ(a0) 242 REG_L ra, SC_REGS+0*REGSZ(a0)
@@ -181,9 +280,190 @@ NON_LEAF(longjmp, FRAMESZ, ra)
181 move v0, a1 280 move v0, a1
182 j ra 281 j ra
183 282
184botch: 283longjmp_botch:
185 jal longjmperror 284 jal longjmperror
186 jal abort 285 jal abort
187 RESTORE_GP64 286 RESTORE_GP64
188 PTR_ADDU sp, FRAMESZ 287 PTR_ADDU sp, FRAMESZ
189END(longjmp) 288END(longjmp)
289
290
291/*
292 * _setjmp, _longjmp (not restoring signal state)
293 *
294 * GPOFF and FRAMESIZE must be the same for both _setjmp and _longjmp!
295 *
296 */
297
298FRAMESZ= MKFSIZ(0,4)
299GPOFF= FRAMESZ-2*REGSZ
300
301LEAF(_setjmp, FRAMESZ)
302 PTR_SUBU sp, FRAMESZ
303 SETUP_GP64(GPOFF, _setjmp)
304 SAVE_GP(GPOFF)
305 .set reorder
306
307#ifndef __LP64__
308 addiu a0, 7 # roundup jmpbuf addr to 8-byte boundary
309 li t0, ~7
310 and a0, t0
311#endif
312
313 # SC_MASK is unused here
314
315 li v0, 0xACEDBADE # sigcontext magic number
316 sw v0, SC_MAGIC(a0)
317 # callee-saved long-sized regs:
318 REG_S ra, SC_REGS+0*REGSZ(a0)
319 REG_S s0, SC_REGS+1*REGSZ(a0)
320 REG_S s1, SC_REGS+2*REGSZ(a0)
321 REG_S s2, SC_REGS+3*REGSZ(a0)
322 REG_S s3, SC_REGS+4*REGSZ(a0)
323 REG_S s4, SC_REGS+5*REGSZ(a0)
324 REG_S s5, SC_REGS+6*REGSZ(a0)
325 REG_S s6, SC_REGS+7*REGSZ(a0)
326 REG_S s7, SC_REGS+8*REGSZ(a0)
327 REG_S s8, SC_REGS+9*REGSZ(a0)
328 REG_L v0, GPOFF(sp)
329 REG_S v0, SC_REGS+10*REGSZ(a0)
330 PTR_ADDU v0, sp, FRAMESZ
331 REG_S v0, SC_REGS+11*REGSZ(a0)
332
333 cfc1 v0, $31
334
335#ifdef __LP64__
336 # callee-saved fp regs on mips n64 ABI are $f24..$f31
337 s.d $f24, SC_FPREGS+0*REGSZ_FP(a0)
338 s.d $f25, SC_FPREGS+1*REGSZ_FP(a0)
339 s.d $f26, SC_FPREGS+2*REGSZ_FP(a0)
340 s.d $f27, SC_FPREGS+3*REGSZ_FP(a0)
341 s.d $f28, SC_FPREGS+4*REGSZ_FP(a0)
342 s.d $f29, SC_FPREGS+5*REGSZ_FP(a0)
343 s.d $f30, SC_FPREGS+6*REGSZ_FP(a0)
344 s.d $f31, SC_FPREGS+7*REGSZ_FP(a0)
345#else
346 # callee-saved fp regs on mips o32 ABI are
347 # the even-numbered fp regs $f20,$f22,...$f30
348 s.d $f20, SC_FPREGS+0*REGSZ_FP(a0)
349 s.d $f22, SC_FPREGS+1*REGSZ_FP(a0)
350 s.d $f24, SC_FPREGS+2*REGSZ_FP(a0)
351 s.d $f26, SC_FPREGS+3*REGSZ_FP(a0)
352 s.d $f28, SC_FPREGS+4*REGSZ_FP(a0)
353 s.d $f30, SC_FPREGS+5*REGSZ_FP(a0)
354#endif
355 sw v0, SC_FPSR(a0)
356 move v0, zero
357 RESTORE_GP64
358 PTR_ADDU sp, FRAMESZ
359 j ra
360END(_setjmp)
361
362
363LEAF(_longjmp, FRAMESZ)
364 PTR_SUBU sp, FRAMESZ
365 SETUP_GP64(GPOFF, _longjmp)
366 SAVE_GP(GPOFF)
367 .set reorder
368
369#ifndef __LP64__
370 addiu a0, 7 # roundup jmpbuf addr to 8-byte boundary
371 li t0, ~7
372 and a0, t0
373#endif
374
375 # SC_MASK is unused here
376
377 lw v0, SC_MAGIC(a0)
378 li t0, 0xACEDBADE
379 bne v0, t0, _longjmp_botch # jump if error
380
381 # callee-saved long-sized regs:
382 REG_L ra, SC_REGS+0*REGSZ(a0)
383 REG_L s0, SC_REGS+1*REGSZ(a0)
384 REG_L s1, SC_REGS+2*REGSZ(a0)
385 REG_L s2, SC_REGS+3*REGSZ(a0)
386 REG_L s3, SC_REGS+4*REGSZ(a0)
387 REG_L s4, SC_REGS+5*REGSZ(a0)
388 REG_L s5, SC_REGS+6*REGSZ(a0)
389 REG_L s6, SC_REGS+7*REGSZ(a0)
390 REG_L s7, SC_REGS+8*REGSZ(a0)
391 REG_L s8, SC_REGS+9*REGSZ(a0)
392 REG_L gp, SC_REGS+10*REGSZ(a0)
393 REG_L sp, SC_REGS+11*REGSZ(a0)
394
395 lw v0, SC_FPSR(a0)
396 ctc1 v0, $31
397#ifdef __LP64__
398 # callee-saved fp regs on mips n64 ABI are $f24..$f31
399 l.d $f24, SC_FPREGS+0*REGSZ_FP(a0)
400 l.d $f25, SC_FPREGS+1*REGSZ_FP(a0)
401 l.d $f26, SC_FPREGS+2*REGSZ_FP(a0)
402 l.d $f27, SC_FPREGS+3*REGSZ_FP(a0)
403 l.d $f28, SC_FPREGS+4*REGSZ_FP(a0)
404 l.d $f29, SC_FPREGS+5*REGSZ_FP(a0)
405 l.d $f30, SC_FPREGS+6*REGSZ_FP(a0)
406 l.d $f31, SC_FPREGS+7*REGSZ_FP(a0)
407#else
408 # callee-saved fp regs on mips o32 ABI are
409 # the even-numbered fp regs $f20,$f22,...$f30
410 l.d $f20, SC_FPREGS+0*REGSZ_FP(a0)
411 l.d $f22, SC_FPREGS+1*REGSZ_FP(a0)
412 l.d $f24, SC_FPREGS+2*REGSZ_FP(a0)
413 l.d $f26, SC_FPREGS+3*REGSZ_FP(a0)
414 l.d $f28, SC_FPREGS+4*REGSZ_FP(a0)
415 l.d $f30, SC_FPREGS+5*REGSZ_FP(a0)
416#endif
417 bne a1, zero, 1f
418 li a1, 1 # never return 0!
4191:
420 move v0, a1
421 j ra
422
423_longjmp_botch:
424 jal longjmperror
425 jal abort
426 RESTORE_GP64
427 PTR_ADDU sp, FRAMESZ
428END(_longjmp)
429
430/*
431 * trampolines for sigsetjmp and siglongjmp save and restore mask.
432 *
433 */
434FRAMESZ= MKFSIZ(1,1)
435GPOFF= FRAMESZ-2*REGSZ
436
437LEAF(sigsetjmp, FRAMESZ)
438 PTR_SUBU sp, FRAMESZ
439 SETUP_GP64(GPOFF, sigsetjmp)
440 .set reorder
441 sw a1, _JBLEN*REGSZ(a0) # save "savemask"
442 bne a1, 0x0, 1f # do saving of signal mask?
443 LA t9, _setjmp
444 RESTORE_GP64
445 PTR_ADDU sp, FRAMESZ
446 jr t9
447
4481: LA t9, setjmp
449 RESTORE_GP64
450 PTR_ADDU sp, FRAMESZ
451 jr t9
452END(sigsetjmp)
453
454LEAF(siglongjmp, FRAMESZ)
455 PTR_SUBU sp, FRAMESZ
456 SETUP_GP64(GPOFF, siglongjmp)
457 .set reorder
458 lw t0, _JBLEN*REGSZ(a0) # get "savemask"
459 bne t0, 0x0, 1f # restore signal mask?
460 LA t9, _longjmp
461 RESTORE_GP64
462 PTR_ADDU sp, FRAMESZ
463 jr t9
4641:
465 LA t9, longjmp
466 RESTORE_GP64
467 PTR_ADDU sp, FRAMESZ
468 jr t9
469END(siglongjmp)
diff --git a/libc/arch-mips/bionic/sigsetjmp.S b/libc/arch-mips/bionic/sigsetjmp.S
deleted file mode 100644
index 3ef0a6fd..00000000
--- a/libc/arch-mips/bionic/sigsetjmp.S
+++ /dev/null
@@ -1,76 +0,0 @@
1/* $OpenBSD: sigsetjmp.S,v 1.5 2005/08/07 16:40:15 espie Exp $ */
2/*-
3 * Copyright (c) 1991, 1993, 1995,
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * Havard Eidnes.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#include <private/bionic_asm.h>
35#include <machine/setjmp.h>
36
37/*
38 * trampolines for sigsetjmp and siglongjmp save and restore mask.
39 *
40 */
41FRAMESZ= MKFSIZ(1,1)
42GPOFF= FRAMESZ-2*REGSZ
43
44LEAF(sigsetjmp, FRAMESZ)
45 PTR_SUBU sp, FRAMESZ
46 SETUP_GP64(GPOFF, sigsetjmp)
47 .set reorder
48 sw a1, _JBLEN*REGSZ(a0) # save "savemask"
49 bne a1, 0x0, 1f # do saving of signal mask?
50 LA t9, _setjmp
51 RESTORE_GP64
52 PTR_ADDU sp, FRAMESZ
53 jr t9
54
551: LA t9, setjmp
56 RESTORE_GP64
57 PTR_ADDU sp, FRAMESZ
58 jr t9
59END(sigsetjmp)
60
61LEAF(siglongjmp, FRAMESZ)
62 PTR_SUBU sp, FRAMESZ
63 SETUP_GP64(GPOFF, siglongjmp)
64 .set reorder
65 lw t0, _JBLEN*REGSZ(a0) # get "savemask"
66 bne t0, 0x0, 1f # restore signal mask?
67 LA t9, _longjmp
68 RESTORE_GP64
69 PTR_ADDU sp, FRAMESZ
70 jr t9
711:
72 LA t9, longjmp
73 RESTORE_GP64
74 PTR_ADDU sp, FRAMESZ
75 jr t9
76END(siglongjmp)
diff --git a/libc/arch-mips/include/machine/signal.h b/libc/arch-mips/include/machine/signal.h
deleted file mode 100644
index b9c13671..00000000
--- a/libc/arch-mips/include/machine/signal.h
+++ /dev/null
@@ -1,78 +0,0 @@
1/* $OpenBSD: signal.h,v 1.8 2006/01/09 18:18:37 millert Exp $ */
2
3/*
4 * Copyright (c) 1992, 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 * @(#)signal.h 8.1 (Berkeley) 6/10/93
35 */
36
37#ifndef _MIPS_SIGNAL_H_
38#define _MIPS_SIGNAL_H_
39
40/* On Mips32, jmpbuf begins with optional 4-byte filler so that
41 * all saved FP regs are aligned on 8-byte boundary, despite this whole
42 * struct being mis-declared to users as an array of (4-byte) longs.
43 * All the following offsets are then from the rounded-up base addr
44 */
45
46/* Fields of same size on all MIPS abis: */
47#define SC_MAGIC (0*4) /* 4 bytes, identify jmpbuf */
48#define SC_MASK (1*4) /* 4 bytes, saved signal mask */
49#define SC_FPSR (2*4) /* 4 bytes, floating point control/status reg */
50/* filler2 (3*4) 4 bytes, pad to 8-byte boundary */
51
52/* Registers that are 4-byte on mips32 o32, and 8-byte on mips64 n64 abi */
53#define SC_REGS_SAVED 12 /* ra,gp,sp,s0-s8 */
54#define SC_REGS (4*4) /* SC_REGS_SAVED*REGSZ bytes */
55
56/* Floating pt registers are 8-bytes on all abis,
57 * but the number of saved fp regs varies for o32/n32 versus n64 abis:
58 */
59
60#ifdef __LP64__
61#define SC_FPREGS_SAVED 8 /* all fp regs f24,f25,f26,f27,f28,f29,f30,f31 */
62#else
63#define SC_FPREGS_SAVED 6 /* even fp regs f20,f22,f24,f26,f28,f30 */
64#endif
65
66#define SC_FPREGS (SC_REGS + SC_REGS_SAVED*REGSZ) /* SC_FPREGS_SAVED*REGSZ_FP bytes */
67
68#define SC_BYTES (SC_FPREGS + SC_FPREGS_SAVED*REGSZ_FP)
69#define SC_LONGS (SC_BYTES/REGSZ)
70
71#ifdef __LP64__
72/* SC_LONGS is 22, so _JBLEN should be 22 or larger */
73#else
74/* SC_LONGS is 28, but must also allocate dynamic-roundup filler.
75 so _JBLEN should be 29 or larger */
76#endif
77
78#endif /* !_MIPS_SIGNAL_H_ */
diff --git a/libc/arch-mips/mips.mk b/libc/arch-mips/mips.mk
index ac75a4bb..d558baa0 100644
--- a/libc/arch-mips/mips.mk
+++ b/libc/arch-mips/mips.mk
@@ -67,9 +67,7 @@ libc_bionic_src_files_mips += \
67 arch-mips/bionic/bzero.S \ 67 arch-mips/bionic/bzero.S \
68 arch-mips/bionic/cacheflush.cpp \ 68 arch-mips/bionic/cacheflush.cpp \
69 arch-mips/bionic/_exit_with_stack_teardown.S \ 69 arch-mips/bionic/_exit_with_stack_teardown.S \
70 arch-mips/bionic/_setjmp.S \
71 arch-mips/bionic/setjmp.S \ 70 arch-mips/bionic/setjmp.S \
72 arch-mips/bionic/sigsetjmp.S \
73 arch-mips/bionic/syscall.S \ 71 arch-mips/bionic/syscall.S \
74 arch-mips/bionic/vfork.S \ 72 arch-mips/bionic/vfork.S \
75 73
diff --git a/libc/arch-mips64/bionic/_setjmp.S b/libc/arch-mips64/bionic/_setjmp.S
deleted file mode 100644
index 052dacb4..00000000
--- a/libc/arch-mips64/bionic/_setjmp.S
+++ /dev/null
@@ -1,172 +0,0 @@
1/* $OpenBSD: _setjmp.S,v 1.4 2005/08/07 16:40:15 espie Exp $ */
2
3/*
4 * Copyright (c) 2002 Opsycon AB (www.opsycon.se / www.opsycon.com)
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of Opsycon AB nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
19 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 */
31
32#include <private/bionic_asm.h>
33#include <machine/signal.h>
34
35/*
36 * _setjmp, _longjmp (not restoring signal state)
37 *
38 * GPOFF and FRAMESIZE must be the same for both _setjmp and _longjmp!
39 *
40 */
41
42FRAMESZ= MKFSIZ(0,4)
43GPOFF= FRAMESZ-2*REGSZ
44
45LEAF(_setjmp, FRAMESZ)
46 PTR_SUBU sp, FRAMESZ
47 SETUP_GP64(GPOFF, _setjmp)
48 SAVE_GP(GPOFF)
49 .set reorder
50
51#ifndef __LP64__
52 addiu a0, 7 # roundup jmpbuf addr to 8-byte boundary
53 li t0, ~7
54 and a0, t0
55#endif
56
57 # SC_MASK is unused here
58
59 li v0, 0xACEDBADE # sigcontext magic number
60 sw v0, SC_MAGIC(a0)
61 # callee-saved long-sized regs:
62 REG_S ra, SC_REGS+0*REGSZ(a0)
63 REG_S s0, SC_REGS+1*REGSZ(a0)
64 REG_S s1, SC_REGS+2*REGSZ(a0)
65 REG_S s2, SC_REGS+3*REGSZ(a0)
66 REG_S s3, SC_REGS+4*REGSZ(a0)
67 REG_S s4, SC_REGS+5*REGSZ(a0)
68 REG_S s5, SC_REGS+6*REGSZ(a0)
69 REG_S s6, SC_REGS+7*REGSZ(a0)
70 REG_S s7, SC_REGS+8*REGSZ(a0)
71 REG_S s8, SC_REGS+9*REGSZ(a0)
72 REG_L v0, GPOFF(sp)
73 REG_S v0, SC_REGS+10*REGSZ(a0)
74 PTR_ADDU v0, sp, FRAMESZ
75 REG_S v0, SC_REGS+11*REGSZ(a0)
76
77 cfc1 v0, $31
78
79#ifdef __LP64__
80 # callee-saved fp regs on mips n64 ABI are $f24..$f31
81 s.d $f24, SC_FPREGS+0*REGSZ_FP(a0)
82 s.d $f25, SC_FPREGS+1*REGSZ_FP(a0)
83 s.d $f26, SC_FPREGS+2*REGSZ_FP(a0)
84 s.d $f27, SC_FPREGS+3*REGSZ_FP(a0)
85 s.d $f28, SC_FPREGS+4*REGSZ_FP(a0)
86 s.d $f29, SC_FPREGS+5*REGSZ_FP(a0)
87 s.d $f30, SC_FPREGS+6*REGSZ_FP(a0)
88 s.d $f31, SC_FPREGS+7*REGSZ_FP(a0)
89#else
90 # callee-saved fp regs on mips o32 ABI are
91 # the even-numbered fp regs $f20,$f22,...$f30
92 s.d $f20, SC_FPREGS+0*REGSZ_FP(a0)
93 s.d $f22, SC_FPREGS+1*REGSZ_FP(a0)
94 s.d $f24, SC_FPREGS+2*REGSZ_FP(a0)
95 s.d $f26, SC_FPREGS+3*REGSZ_FP(a0)
96 s.d $f28, SC_FPREGS+4*REGSZ_FP(a0)
97 s.d $f30, SC_FPREGS+5*REGSZ_FP(a0)
98#endif
99 sw v0, SC_FPSR(a0)
100 move v0, zero
101 RESTORE_GP64
102 PTR_ADDU sp, FRAMESZ
103 j ra
104END(_setjmp)
105
106
107LEAF(_longjmp, FRAMESZ)
108 PTR_SUBU sp, FRAMESZ
109 SETUP_GP64(GPOFF, _longjmp)
110 SAVE_GP(GPOFF)
111 .set reorder
112
113#ifndef __LP64__
114 addiu a0, 7 # roundup jmpbuf addr to 8-byte boundary
115 li t0, ~7
116 and a0, t0
117#endif
118
119 # SC_MASK is unused here
120
121 lw v0, SC_MAGIC(a0)
122 li t0, 0xACEDBADE
123 bne v0, t0, botch # jump if error
124
125 # callee-saved long-sized regs:
126 REG_L ra, SC_REGS+0*REGSZ(a0)
127 REG_L s0, SC_REGS+1*REGSZ(a0)
128 REG_L s1, SC_REGS+2*REGSZ(a0)
129 REG_L s2, SC_REGS+3*REGSZ(a0)
130 REG_L s3, SC_REGS+4*REGSZ(a0)
131 REG_L s4, SC_REGS+5*REGSZ(a0)
132 REG_L s5, SC_REGS+6*REGSZ(a0)
133 REG_L s6, SC_REGS+7*REGSZ(a0)
134 REG_L s7, SC_REGS+8*REGSZ(a0)
135 REG_L s8, SC_REGS+9*REGSZ(a0)
136 REG_L gp, SC_REGS+10*REGSZ(a0)
137 REG_L sp, SC_REGS+11*REGSZ(a0)
138
139 lw v0, SC_FPSR(a0)
140 ctc1 v0, $31
141#ifdef __LP64__
142 # callee-saved fp regs on mips n64 ABI are $f24..$f31
143 l.d $f24, SC_FPREGS+0*REGSZ_FP(a0)
144 l.d $f25, SC_FPREGS+1*REGSZ_FP(a0)
145 l.d $f26, SC_FPREGS+2*REGSZ_FP(a0)
146 l.d $f27, SC_FPREGS+3*REGSZ_FP(a0)
147 l.d $f28, SC_FPREGS+4*REGSZ_FP(a0)
148 l.d $f29, SC_FPREGS+5*REGSZ_FP(a0)
149 l.d $f30, SC_FPREGS+6*REGSZ_FP(a0)
150 l.d $f31, SC_FPREGS+7*REGSZ_FP(a0)
151#else
152 # callee-saved fp regs on mips o32 ABI are
153 # the even-numbered fp regs $f20,$f22,...$f30
154 l.d $f20, SC_FPREGS+0*REGSZ_FP(a0)
155 l.d $f22, SC_FPREGS+1*REGSZ_FP(a0)
156 l.d $f24, SC_FPREGS+2*REGSZ_FP(a0)
157 l.d $f26, SC_FPREGS+3*REGSZ_FP(a0)
158 l.d $f28, SC_FPREGS+4*REGSZ_FP(a0)
159 l.d $f30, SC_FPREGS+5*REGSZ_FP(a0)
160#endif
161 bne a1, zero, 1f
162 li a1, 1 # never return 0!
1631:
164 move v0, a1
165 j ra
166
167botch:
168 jal longjmperror
169 jal abort
170 RESTORE_GP64
171 PTR_ADDU sp, FRAMESZ
172END(_longjmp)
diff --git a/libc/arch-mips64/bionic/setjmp.S b/libc/arch-mips64/bionic/setjmp.S
index a1d46955..b117bb69 100644..120000
--- a/libc/arch-mips64/bionic/setjmp.S
+++ b/libc/arch-mips64/bionic/setjmp.S
@@ -1,189 +1 @@
1/* $OpenBSD: setjmp.S,v 1.5 2005/08/07 16:40:15 espie Exp $ */ ../../arch-mips/bionic/setjmp.S \ No newline at end of file
2
3/*
4 * Copyright (c) 2001-2002 Opsycon AB (www.opsycon.se / www.opsycon.com)
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of Opsycon AB nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
19 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 */
31
32#include <private/bionic_asm.h>
33#include <machine/signal.h>
34
35/*
36 * _setjmp, _longjmp (restoring signal state)
37 *
38 * GPOFF and FRAMESIZE must be the same for both _setjmp and _longjmp!
39 *
40 */
41
42FRAMESZ= MKFSIZ(2,6)
43A1OFF= FRAMESZ-4*REGSZ
44A0OFF= FRAMESZ-3*REGSZ
45GPOFF= FRAMESZ-2*REGSZ
46RAOFF= FRAMESZ-1*REGSZ
47
48NON_LEAF(setjmp, FRAMESZ, ra)
49 .mask 0x80000000, RAOFF
50 PTR_SUBU sp, FRAMESZ # allocate stack frame
51 SETUP_GP64(GPOFF, setjmp)
52 SAVE_GP(GPOFF)
53 .set reorder
54
55#ifndef __LP64__
56 addiu a0, 7 # roundup jmpbuf addr to 8-byte boundary
57 li t0, ~7
58 and a0, t0
59#endif
60
61 REG_S ra, RAOFF(sp) # save state
62 REG_S a0, A0OFF(sp)
63 move a0, zero # get current signal mask
64 jal sigblock
65 REG_L a0, A0OFF(sp)
66 REG_L ra, RAOFF(sp)
67
68 REG_S v0, SC_MASK(a0) # save sc_mask = sigblock(0)
69
70 li v0, 0xACEDBADE # sigcontext magic number
71 sw v0, SC_MAGIC(a0)
72 # callee-saved long-sized regs:
73 REG_S ra, SC_REGS+0*REGSZ(a0)
74 REG_S s0, SC_REGS+1*REGSZ(a0)
75 REG_S s1, SC_REGS+2*REGSZ(a0)
76 REG_S s2, SC_REGS+3*REGSZ(a0)
77 REG_S s3, SC_REGS+4*REGSZ(a0)
78 REG_S s4, SC_REGS+5*REGSZ(a0)
79 REG_S s5, SC_REGS+6*REGSZ(a0)
80 REG_S s6, SC_REGS+7*REGSZ(a0)
81 REG_S s7, SC_REGS+8*REGSZ(a0)
82 REG_S s8, SC_REGS+9*REGSZ(a0)
83 REG_L v0, GPOFF(sp)
84 REG_S v0, SC_REGS+10*REGSZ(a0)
85 PTR_ADDU v0, sp, FRAMESZ
86 REG_S v0, SC_REGS+11*REGSZ(a0)
87
88 cfc1 v0, $31
89
90#ifdef __LP64__
91 # callee-saved fp regs on mips n64 ABI are $f24..$f31
92 s.d $f24, SC_FPREGS+0*REGSZ_FP(a0)
93 s.d $f25, SC_FPREGS+1*REGSZ_FP(a0)
94 s.d $f26, SC_FPREGS+2*REGSZ_FP(a0)
95 s.d $f27, SC_FPREGS+3*REGSZ_FP(a0)
96 s.d $f28, SC_FPREGS+4*REGSZ_FP(a0)
97 s.d $f29, SC_FPREGS+5*REGSZ_FP(a0)
98 s.d $f30, SC_FPREGS+6*REGSZ_FP(a0)
99 s.d $f31, SC_FPREGS+7*REGSZ_FP(a0)
100#else
101 # callee-saved fp regs on mips o32 ABI are
102 # the even-numbered fp regs $f20,$f22,...$f30
103 s.d $f20, SC_FPREGS+0*REGSZ_FP(a0)
104 s.d $f22, SC_FPREGS+1*REGSZ_FP(a0)
105 s.d $f24, SC_FPREGS+2*REGSZ_FP(a0)
106 s.d $f26, SC_FPREGS+3*REGSZ_FP(a0)
107 s.d $f28, SC_FPREGS+4*REGSZ_FP(a0)
108 s.d $f30, SC_FPREGS+5*REGSZ_FP(a0)
109#endif
110 sw v0, SC_FPSR(a0)
111 move v0, zero
112 RESTORE_GP64
113 PTR_ADDU sp, FRAMESZ
114 j ra
115END(setjmp)
116
117
118NON_LEAF(longjmp, FRAMESZ, ra)
119 .mask 0x80000000, RAOFF
120 PTR_SUBU sp, FRAMESZ
121 SETUP_GP64(GPOFF, longjmp)
122 SAVE_GP(GPOFF)
123 .set reorder
124
125#ifndef __LP64__
126 addiu a0, 7 # roundup jmpbuf addr to 8-byte boundary
127 li t0, ~7
128 and a0, t0
129#endif
130
131 REG_S a1, A1OFF(sp)
132 REG_S a0, A0OFF(sp)
133 lw a0, SC_MASK(a0)
134 jal sigsetmask
135 REG_L a0, A0OFF(sp)
136 REG_L a1, A1OFF(sp)
137
138 lw v0, SC_MAGIC(a0)
139 li t0, 0xACEDBADE
140 bne v0, t0, botch # jump if error
141
142 # callee-saved long-sized regs:
143 REG_L ra, SC_REGS+0*REGSZ(a0)
144 REG_L s0, SC_REGS+1*REGSZ(a0)
145 REG_L s1, SC_REGS+2*REGSZ(a0)
146 REG_L s2, SC_REGS+3*REGSZ(a0)
147 REG_L s3, SC_REGS+4*REGSZ(a0)
148 REG_L s4, SC_REGS+5*REGSZ(a0)
149 REG_L s5, SC_REGS+6*REGSZ(a0)
150 REG_L s6, SC_REGS+7*REGSZ(a0)
151 REG_L s7, SC_REGS+8*REGSZ(a0)
152 REG_L s8, SC_REGS+9*REGSZ(a0)
153 REG_L gp, SC_REGS+10*REGSZ(a0)
154 REG_L sp, SC_REGS+11*REGSZ(a0)
155
156 lw v0, SC_FPSR(a0)
157 ctc1 v0, $31
158#ifdef __LP64__
159 # callee-saved fp regs on mips n64 ABI are $f24..$f31
160 l.d $f24, SC_FPREGS+0*REGSZ_FP(a0)
161 l.d $f25, SC_FPREGS+1*REGSZ_FP(a0)
162 l.d $f26, SC_FPREGS+2*REGSZ_FP(a0)
163 l.d $f27, SC_FPREGS+3*REGSZ_FP(a0)
164 l.d $f28, SC_FPREGS+4*REGSZ_FP(a0)
165 l.d $f29, SC_FPREGS+5*REGSZ_FP(a0)
166 l.d $f30, SC_FPREGS+6*REGSZ_FP(a0)
167 l.d $f31, SC_FPREGS+7*REGSZ_FP(a0)
168#else
169 # callee-saved fp regs on mips o32 ABI are
170 # the even-numbered fp regs $f20,$f22,...$f30
171 l.d $f20, SC_FPREGS+0*REGSZ_FP(a0)
172 l.d $f22, SC_FPREGS+1*REGSZ_FP(a0)
173 l.d $f24, SC_FPREGS+2*REGSZ_FP(a0)
174 l.d $f26, SC_FPREGS+3*REGSZ_FP(a0)
175 l.d $f28, SC_FPREGS+4*REGSZ_FP(a0)
176 l.d $f30, SC_FPREGS+5*REGSZ_FP(a0)
177#endif
178 bne a1, zero, 1f
179 li a1, 1 # never return 0!
1801:
181 move v0, a1
182 j ra
183
184botch:
185 jal longjmperror
186 jal abort
187 RESTORE_GP64
188 PTR_ADDU sp, FRAMESZ
189END(longjmp)
diff --git a/libc/arch-mips64/bionic/sigsetjmp.S b/libc/arch-mips64/bionic/sigsetjmp.S
deleted file mode 100644
index 3ef0a6fd..00000000
--- a/libc/arch-mips64/bionic/sigsetjmp.S
+++ /dev/null
@@ -1,76 +0,0 @@
1/* $OpenBSD: sigsetjmp.S,v 1.5 2005/08/07 16:40:15 espie Exp $ */
2/*-
3 * Copyright (c) 1991, 1993, 1995,
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * Havard Eidnes.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#include <private/bionic_asm.h>
35#include <machine/setjmp.h>
36
37/*
38 * trampolines for sigsetjmp and siglongjmp save and restore mask.
39 *
40 */
41FRAMESZ= MKFSIZ(1,1)
42GPOFF= FRAMESZ-2*REGSZ
43
44LEAF(sigsetjmp, FRAMESZ)
45 PTR_SUBU sp, FRAMESZ
46 SETUP_GP64(GPOFF, sigsetjmp)
47 .set reorder
48 sw a1, _JBLEN*REGSZ(a0) # save "savemask"
49 bne a1, 0x0, 1f # do saving of signal mask?
50 LA t9, _setjmp
51 RESTORE_GP64
52 PTR_ADDU sp, FRAMESZ
53 jr t9
54
551: LA t9, setjmp
56 RESTORE_GP64
57 PTR_ADDU sp, FRAMESZ
58 jr t9
59END(sigsetjmp)
60
61LEAF(siglongjmp, FRAMESZ)
62 PTR_SUBU sp, FRAMESZ
63 SETUP_GP64(GPOFF, siglongjmp)
64 .set reorder
65 lw t0, _JBLEN*REGSZ(a0) # get "savemask"
66 bne t0, 0x0, 1f # restore signal mask?
67 LA t9, _longjmp
68 RESTORE_GP64
69 PTR_ADDU sp, FRAMESZ
70 jr t9
711:
72 LA t9, longjmp
73 RESTORE_GP64
74 PTR_ADDU sp, FRAMESZ
75 jr t9
76END(siglongjmp)
diff --git a/libc/arch-mips64/mips64.mk b/libc/arch-mips64/mips64.mk
index b9622833..6fa7d335 100644
--- a/libc/arch-mips64/mips64.mk
+++ b/libc/arch-mips64/mips64.mk
@@ -49,9 +49,7 @@ libc_openbsd_src_files_mips64 += \
49libc_bionic_src_files_mips64 += \ 49libc_bionic_src_files_mips64 += \
50 arch-mips64/bionic/__bionic_clone.S \ 50 arch-mips64/bionic/__bionic_clone.S \
51 arch-mips64/bionic/_exit_with_stack_teardown.S \ 51 arch-mips64/bionic/_exit_with_stack_teardown.S \
52 arch-mips64/bionic/_setjmp.S \
53 arch-mips64/bionic/setjmp.S \ 52 arch-mips64/bionic/setjmp.S \
54 arch-mips64/bionic/sigsetjmp.S \
55 arch-mips64/bionic/syscall.S \ 53 arch-mips64/bionic/syscall.S \
56 arch-mips64/bionic/vfork.S \ 54 arch-mips64/bionic/vfork.S \
57 55