summaryrefslogtreecommitdiff
path: root/lib/librthread/arch
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2012-02-17 18:02:19 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2012-02-17 18:02:19 +0000
commit8d802d9d37e9cbe3c46b08d65963986d646c3f4a (patch)
tree29339cce4812e52891741ab4ef3b98d51d39f504 /lib/librthread/arch
parente49bf67259249ef5f557557593afdf38293cedf8 (diff)
Allow librthread to build on mips64.
Diffstat (limited to 'lib/librthread/arch')
-rw-r--r--lib/librthread/arch/mips64/cerror.S60
-rw-r--r--lib/librthread/arch/mips64/rfork_thread.S23
2 files changed, 72 insertions, 11 deletions
diff --git a/lib/librthread/arch/mips64/cerror.S b/lib/librthread/arch/mips64/cerror.S
new file mode 100644
index 00000000000..b24be16d6ce
--- /dev/null
+++ b/lib/librthread/arch/mips64/cerror.S
@@ -0,0 +1,60 @@
+/* $OpenBSD: cerror.S,v 1.1 2012/02/17 18:02:18 miod Exp $ */
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+FRAMESZ= 4*REGSZ
+S0OFF= FRAMESZ-3*REGSZ
+GPOFF= FRAMESZ-2*REGSZ
+RAOFF= FRAMESZ-1*REGSZ
+
+ .globl _C_LABEL(__errno)
+NON_LEAF(__cerror, FRAMESZ, ra)
+ PTR_SUBU sp, FRAMESZ
+ SETUP_GP64(GPOFF, __cerror)
+ .set reorder
+ REG_S ra, RAOFF(sp)
+ REG_S s0, S0OFF(sp)
+
+ move s0, a0
+ jal _C_LABEL(__errno)
+
+ sw s0, 0(v0)
+
+ LI v0, -1
+ REG_L s0, S0OFF(sp)
+ REG_L ra, RAOFF(sp)
+ RESTORE_GP64
+ PTR_ADDU sp, FRAMESZ
+ j ra
+END(__cerror)
diff --git a/lib/librthread/arch/mips64/rfork_thread.S b/lib/librthread/arch/mips64/rfork_thread.S
index adb73dbc24d..500f9a19495 100644
--- a/lib/librthread/arch/mips64/rfork_thread.S
+++ b/lib/librthread/arch/mips64/rfork_thread.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: rfork_thread.S,v 1.3 2012/01/17 02:34:18 guenther Exp $ */
+/* $OpenBSD: rfork_thread.S,v 1.4 2012/02/17 18:02:18 miod Exp $ */
/*
* Copyright (c) 2005, Miodrag Vallat
@@ -30,10 +30,13 @@
/*
* int __tfork_thread(const struct __tfork *param, void *stack, void (*func)(void *), void *arg);
*/
-LEAF(__tfork_thread, 32)
- /* a0 = flags, a1 = stack, a2 = func, a3 = arg */
- PTR_SUBU sp, 32
- SETUP_GP64(16, _C_LABEL(__tfork_thread))
+FRAMESZ=4*REGSZ
+GPOFF=FRAMESZ-2*REGSZ
+LEAF(__tfork_thread, FRAMESZ)
+ /* a0 = param, a1 = stack, a2 = func, a3 = arg */
+ PTR_SUBU sp, FRAMESZ
+ SETUP_GP64(GPOFF, _C_LABEL(__tfork_thread))
+ .set reorder
move t0, a1 /* stack */
move t1, a3 /* arg */
@@ -42,7 +45,7 @@ LEAF(__tfork_thread, 32)
bnez a3, 9f
RESTORE_GP64
- PTR_ADDU sp, 32
+ PTR_ADDU sp, FRAMESZ
beqz v0, 1f
@@ -50,7 +53,6 @@ LEAF(__tfork_thread, 32)
* In parent process: just return.
*/
j ra
- nop
1:
/*
@@ -60,8 +62,8 @@ LEAF(__tfork_thread, 32)
move sp, t0 /* stack */
move t9, a2 /* func */
move a0, t1 /* arg */
+ move v0, zero
jal ra, t9
- move v0, zero
move a0, zero
__DO_SYSCALL(__threxit)
@@ -70,10 +72,9 @@ LEAF(__tfork_thread, 32)
/*
* System call failure.
*/
- LA t9, _C_LABEL(cerror)
+ LA t9, CERROR
RESTORE_GP64
- PTR_ADDU sp, 32
+ PTR_ADDU sp, FRAMESZ
jr t9
- nop
END(__tfork_thread)