summaryrefslogtreecommitdiff
path: root/lib/librthread/arch
diff options
context:
space:
mode:
authorPhilip Guenthe <guenther@cvs.openbsd.org>2011-10-17 06:39:21 +0000
committerPhilip Guenthe <guenther@cvs.openbsd.org>2011-10-17 06:39:21 +0000
commit82cbd469f12cd3a22be520db0de2ead1449f271e (patch)
tree7f405c5d2faa96148d6ed5ebe126425e978967c4 /lib/librthread/arch
parent2f6d2040683851ec94ddc66982fcddb408ea5eb2 (diff)
Use __tfork, __get_tcb, and __set_tcb to have a real TCB and per-thread
errno. The ASM bits for _cerror are sketchy or missing for some archs but that can be corrected in-tree.
Diffstat (limited to 'lib/librthread/arch')
-rw-r--r--lib/librthread/arch/alpha/cerror.S54
-rw-r--r--lib/librthread/arch/alpha/rfork_thread.S10
-rw-r--r--lib/librthread/arch/amd64/cerror.S55
-rw-r--r--lib/librthread/arch/amd64/rfork_thread.S12
-rw-r--r--lib/librthread/arch/arm/cerror.S44
-rw-r--r--lib/librthread/arch/arm/rfork_thread.S10
-rw-r--r--lib/librthread/arch/hppa/rfork_thread.S10
-rw-r--r--lib/librthread/arch/i386/cerror.S49
-rw-r--r--lib/librthread/arch/i386/rfork_thread.S10
-rw-r--r--lib/librthread/arch/m68k/cerror.S53
-rw-r--r--lib/librthread/arch/m68k/rfork_thread.S8
-rw-r--r--lib/librthread/arch/m88k/rfork_thread.S8
-rw-r--r--lib/librthread/arch/mips64/rfork_thread.S12
-rw-r--r--lib/librthread/arch/powerpc/rfork_thread.S8
-rw-r--r--lib/librthread/arch/sh/cerror.S58
-rw-r--r--lib/librthread/arch/sh/rfork_thread.S14
-rw-r--r--lib/librthread/arch/sparc/cerror.S51
-rw-r--r--lib/librthread/arch/sparc/rfork_thread.S15
-rw-r--r--lib/librthread/arch/sparc64/cerror.S54
-rw-r--r--lib/librthread/arch/sparc64/rfork_thread.S12
-rw-r--r--lib/librthread/arch/vax/cerror.S40
-rw-r--r--lib/librthread/arch/vax/rfork_thread.S8
22 files changed, 527 insertions, 68 deletions
diff --git a/lib/librthread/arch/alpha/cerror.S b/lib/librthread/arch/alpha/cerror.S
new file mode 100644
index 00000000000..af21adebee7
--- /dev/null
+++ b/lib/librthread/arch/alpha/cerror.S
@@ -0,0 +1,54 @@
+/* $OpenBSD: cerror.S,v 1.1 2011/10/17 06:39:20 guenther Exp $ */
+/* $NetBSD: cerror.S,v 1.3 1996/10/17 03:08:17 cgd Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Author: Chris G. Demetriou
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ */
+
+#include "SYS.h"
+
+#define FRAME_SIZE 16
+#define FRAME_RA_OFFSET 0
+#define FRAME_V0_OFFSET 8
+
+NESTED(__cerror, 0, FRAME_SIZE, ra, IM_RA|IM_V0, 0)
+LEAF_NOPROFILE(__cerror, 0)
+ br t0, L1
+L1: LDGP(t0)
+
+ lda sp, -FRAME_SIZE(sp)
+ stq ra, FRAME_RA_OFFSET(sp)
+ stq v0, FRAME_V0_OFFSET(sp)
+
+ CALL(__errno)
+
+ ldq t0, FRAME_V0_OFFSET(sp)
+ stl t0, 0(v0)
+ ldiq v0, -1
+ ldq ra, FRAME_RA_OFFSET(sp)
+ lda sp, FRAME_SIZE(sp)
+ RET
+END(__cerror)
diff --git a/lib/librthread/arch/alpha/rfork_thread.S b/lib/librthread/arch/alpha/rfork_thread.S
index 8bbe879967d..3205958f6a9 100644
--- a/lib/librthread/arch/alpha/rfork_thread.S
+++ b/lib/librthread/arch/alpha/rfork_thread.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: rfork_thread.S,v 1.2 2005/12/25 00:21:59 miod Exp $ */
+/* $OpenBSD: rfork_thread.S,v 1.3 2011/10/17 06:39:20 guenther Exp $ */
/*
* Copyright (c) 2005, Miodrag Vallat
@@ -28,12 +28,12 @@
#include "../../../libc/arch/alpha/SYS.h"
/*
- * int rfork_thread(int flags, void *stack, void (*func)(void *), void *arg);
+ * int __tfork_thread(const struct __tfork *param, void *stack, void (*func)(void *), void *arg);
*/
-LEAF(rfork_thread,0)
+LEAF(__tfork_thread,0)
/* a0 = flags, a1 = stack, a2 = func, a3 = arg */
mov a3, a5
- CALLSYS_ERROR(rfork)
+ CALLSYS_ERROR(__tfork)
beq v0, 1f
@@ -54,4 +54,4 @@ LEAF(rfork_thread,0)
mov zero, a0
CALLSYS_NOERROR(threxit)
-END(rfork_thread)
+END(__tfork_thread)
diff --git a/lib/librthread/arch/amd64/cerror.S b/lib/librthread/arch/amd64/cerror.S
new file mode 100644
index 00000000000..2d9fe89d6e0
--- /dev/null
+++ b/lib/librthread/arch/amd64/cerror.S
@@ -0,0 +1,55 @@
+/* $OpenBSD: cerror.S,v 1.1 2011/10/17 06:39:20 guenther Exp $ */
+/* $NetBSD: cerror.S,v 1.2 2002/06/03 18:30:33 fvdl Exp $ */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * 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.
+ *
+ * from: @(#)cerror.s 5.1 (Berkeley) 4/23/90
+ */
+
+#include <machine/asm.h>
+
+#include "SYS.h"
+
+#define ERRNOPTR_OFFSET 24
+
+_ENTRY(CERROR)
+ movq %fs:(ERRNOPTR_OFFSET), %rcx
+ movl %eax, (%rcx)
+ movq $-1,%rax
+ ret
+
+#if 0 /* generic code works */
+NENTRY(__errno)
+ movq %fs:(ERRNOPTR_OFFSET),%rax
+ ret
+#endif
+
diff --git a/lib/librthread/arch/amd64/rfork_thread.S b/lib/librthread/arch/amd64/rfork_thread.S
index 636e60724f7..77b62ef8005 100644
--- a/lib/librthread/arch/amd64/rfork_thread.S
+++ b/lib/librthread/arch/amd64/rfork_thread.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: rfork_thread.S,v 1.4 2011/10/13 01:07:01 guenther Exp $ */
+/* $OpenBSD: rfork_thread.S,v 1.5 2011/10/17 06:39:20 guenther Exp $ */
/*-
* Copyright (c) 2000 Peter Wemm <peter@FreeBSD.org>
* Copyright (c) 2003 Alan L. Cox <alc@cs.rice.edu>
@@ -38,23 +38,23 @@ __FBSDID("$FreeBSD: /repoman/r/ncvs/src/lib/libc/amd64/gen/rfork_thread.S,v 1.1
#include "../../../libc/arch/amd64/SYS.h"
/*
- * %edi %rsi %rdx %rcx
- * rfork_thread(flags, stack_addr, start_fnc, start_arg);
+ * %rdi %rsi %rdx %rcx
+ * __tfork_thread(param, stack_addr, start_fnc, start_arg);
*
- * flags: Flags to rfork system call. See rfork(2).
+ * param: Argument to pass to the actual kernel call.
* stack_addr: Top of stack for thread.
* start_fnc: Address of thread function to call in child.
* start_arg: Argument to pass to the thread function in child.
*/
-ENTRY(rfork_thread)
+ENTRY(__tfork_thread)
movq %rdx, %r8
movq %rcx, %r9
/*
* Prepare and execute the thread creation syscall
*/
- movl $SYS_rfork, %eax
+ movl $SYS___tfork, %eax
syscall
jb 2f
diff --git a/lib/librthread/arch/arm/cerror.S b/lib/librthread/arch/arm/cerror.S
new file mode 100644
index 00000000000..08dc3706739
--- /dev/null
+++ b/lib/librthread/arch/arm/cerror.S
@@ -0,0 +1,44 @@
+/* $OpenBSD: cerror.S,v 1.1 2011/10/17 06:39:20 guenther Exp $ */
+/* $NetBSD: cerror.S,v 1.5 2003/08/07 16:42:04 agc Exp $ */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * from: @(#)cerror.s 5.1 (Berkeley) 4/23/90
+ */
+
+#include "SYS.h"
+
+_ENTRY(CERROR)
+ stmfd sp!, {r4, lr}
+ mov r4, r0
+ bl PIC_SYM(_C_LABEL(_errno), PLT)
+ str r4, [r0]
+ mvn r0, #0x00000000
+ mvn r1, #0x00000000
+ ldmfd sp!, {r4, pc}
diff --git a/lib/librthread/arch/arm/rfork_thread.S b/lib/librthread/arch/arm/rfork_thread.S
index 34bec22d5bc..a631b1b8ce3 100644
--- a/lib/librthread/arch/arm/rfork_thread.S
+++ b/lib/librthread/arch/arm/rfork_thread.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: rfork_thread.S,v 1.2 2005/12/31 21:11:49 drahn Exp $ */
+/* $OpenBSD: rfork_thread.S,v 1.3 2011/10/17 06:39:20 guenther Exp $ */
/*
* Copyright (c) 2005 Dale Rahn <drahn@openbsd.org>
*
@@ -19,16 +19,16 @@
#include "../../../libc/arch/arm/SYS.h"
/*
- * r0 r1 r2 r3
- * rfork_thread(flags, stack_addr, start_fnc, start_arg);
+ * r0 r1 r2 r3
+ * __tfork_thread(param, stack_addr, start_fnc, start_arg);
*/
-ENTRY(rfork_thread)
+ENTRY(__tfork_thread)
stmdb sp!, {r4}
mov r4, r1
- SYSTRAP(rfork)
+ SYSTRAP(__tfork)
bcs 1f
/* check if we are parent or child */
diff --git a/lib/librthread/arch/hppa/rfork_thread.S b/lib/librthread/arch/hppa/rfork_thread.S
index d10f09300d5..c98d4ee3bac 100644
--- a/lib/librthread/arch/hppa/rfork_thread.S
+++ b/lib/librthread/arch/hppa/rfork_thread.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: rfork_thread.S,v 1.1 2005/12/28 19:11:25 miod Exp $ */
+/* $OpenBSD: rfork_thread.S,v 1.2 2011/10/17 06:39:20 guenther Exp $ */
/*
* Copyright (c) 2005, Miodrag Vallat
@@ -28,10 +28,10 @@
#include "../../../libc/arch/hppa/SYS.h"
/*
- * int rfork_thread(int flags, void *stack, void (*func)(void *), void *arg);
+ * int __tfork_thread(param, void *stack, void (*func)(void *), void *arg);
*/
-ENTRY(rfork_thread, 0)
- SYSCALL(rfork)
+ENTRY(__tfork_thread, 0)
+ SYSCALL(__tfork)
comb,<> r0, ret0, 1f
nop
@@ -62,4 +62,4 @@ ENTRY(rfork_thread, 0)
bv r0(rp)
nop
-EXIT(rfork_thread)
+EXIT(__tfork_thread)
diff --git a/lib/librthread/arch/i386/cerror.S b/lib/librthread/arch/i386/cerror.S
new file mode 100644
index 00000000000..e2a298b83c8
--- /dev/null
+++ b/lib/librthread/arch/i386/cerror.S
@@ -0,0 +1,49 @@
+/* $OpenBSD: cerror.S,v 1.1 2011/10/17 06:39:20 guenther Exp $ */
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * 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 "SYS.h"
+
+#define ERRNOPTR_OFFSET 12
+
+_ENTRY(CERROR)
+ movl %gs:(ERRNOPTR_OFFSET),%ecx
+ movl %eax,(%ecx)
+ movl $-1,%eax
+ movl $-1,%edx
+ ret
+
+#if 0 /* generic code works */
+NENTRY(__errno)
+ movl %gs:(ERRNOPTR_OFFSET),%eax
+ ret
+#endif
diff --git a/lib/librthread/arch/i386/rfork_thread.S b/lib/librthread/arch/i386/rfork_thread.S
index e86484a13c2..1bc1d3e9e32 100644
--- a/lib/librthread/arch/i386/rfork_thread.S
+++ b/lib/librthread/arch/i386/rfork_thread.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: rfork_thread.S,v 1.3 2009/09/27 22:52:16 guenther Exp $ */
+/* $OpenBSD: rfork_thread.S,v 1.4 2011/10/17 06:39:20 guenther Exp $ */
/*-
* Copyright (c) 2000 Peter Wemm <peter@FreeBSD.org>
* All rights reserved.
@@ -38,15 +38,15 @@ __FBSDID("$FreeBSD: /repoman/r/ncvs/src/lib/libc/i386/gen/rfork_thread.S,v 1.5 2
/*
* 8 12 16 20
- * rfork_thread(flags, stack_addr, start_fnc, start_arg);
+ * __tfork_thread(param, stack_addr, start_fnc, start_arg);
*
- * flags: Flags to rfork system call. See rfork(2).
+ * param: Arguments to actual system call.
* stack_addr: Top of stack for thread.
* start_fnc: Address of thread function to call in child.
* start_arg: Argument to pass to the thread function in child.
*/
-ENTRY(rfork_thread)
+ENTRY(__tfork_thread)
pushl %ebp
movl %esp, %ebp
pushl %esi
@@ -69,7 +69,7 @@ ENTRY(rfork_thread)
*/
pushl 8(%ebp)
pushl $0
- movl $SYS_rfork, %eax
+ movl $SYS___tfork, %eax
int $0x80
jb 2f
diff --git a/lib/librthread/arch/m68k/cerror.S b/lib/librthread/arch/m68k/cerror.S
new file mode 100644
index 00000000000..0705a4aa841
--- /dev/null
+++ b/lib/librthread/arch/m68k/cerror.S
@@ -0,0 +1,53 @@
+/* $OpenBSD: cerror.S,v 1.1 2011/10/17 06:39:20 guenther Exp $ */
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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 "SYS.h"
+
+ .even
+ .globl ___errno
+__cerror:
+ movl d0,sp@-
+#ifdef PIC
+ movl #__GLOBAL_OFFSET_TABLE_,a0
+ lea pc@(0,a0:l),a0
+ movl a0@(___errno:l),a0
+ jsr a0@
+#else
+ jbsr ___errno
+#endif
+ movl d0,a0
+ movl sp@+,a0@
+ movl #-1,d0
+ movl #-1,d1
+ rts
diff --git a/lib/librthread/arch/m68k/rfork_thread.S b/lib/librthread/arch/m68k/rfork_thread.S
index e9b37eb2f8f..80c682baf50 100644
--- a/lib/librthread/arch/m68k/rfork_thread.S
+++ b/lib/librthread/arch/m68k/rfork_thread.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: rfork_thread.S,v 1.1 2005/12/23 18:50:23 miod Exp $ */
+/* $OpenBSD: rfork_thread.S,v 1.2 2011/10/17 06:39:20 guenther Exp $ */
/*
* Copyright (c) 2005, Miodrag Vallat
@@ -28,9 +28,9 @@
#include "../../../libc/arch/m68k/SYS.h"
/*
- * int rfork_thread(int flags, void *stack, void (*func)(void *), void *arg);
+ * int __tfork_thread(const struct __tfork *param, void *stack, void (*func)(void *), void *arg);
*/
-ENTRY(rfork_thread)
+ENTRY(__tfork_thread)
/*
* Set up the new thread's stack.
*/
@@ -42,7 +42,7 @@ ENTRY(rfork_thread)
* We did not create a frame, so the stack is ready for an immediate
* system call invocation.
*/
- __DO_SYSCALL(rfork)
+ __DO_SYSCALL(__tfork)
jcs 9f
tstl d0
diff --git a/lib/librthread/arch/m88k/rfork_thread.S b/lib/librthread/arch/m88k/rfork_thread.S
index 77afd78838d..2c820232a40 100644
--- a/lib/librthread/arch/m88k/rfork_thread.S
+++ b/lib/librthread/arch/m88k/rfork_thread.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: rfork_thread.S,v 1.1 2005/12/23 20:08:27 miod Exp $ */
+/* $OpenBSD: rfork_thread.S,v 1.2 2011/10/17 06:39:20 guenther Exp $ */
/*
* Copyright (c) 2005, Miodrag Vallat
@@ -28,11 +28,11 @@
#include "../../../libc/arch/m88k/SYS.h"
/*
- * int rfork_thread(int flags, void *stack, void (*func)(void *), void *arg);
+ * int __tfork_thread(const struct __tfork *param, void *stack, void (*func)(void *), void *arg);
*/
-ENTRY(rfork_thread)
+ENTRY(__tfork_thread)
or r6, r3, r0 /* save stack */
- or r13, r0, __SYSCALLNAME(SYS_,rfork)
+ or r13, r0, __SYSCALLNAME(SYS_,__tfork)
tb0 0, r0, 128 /* corrupts r2 and r3 in the child */
br __cerror
diff --git a/lib/librthread/arch/mips64/rfork_thread.S b/lib/librthread/arch/mips64/rfork_thread.S
index 14db8ab8a20..32ee5307bee 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.1 2005/12/24 12:01:26 miod Exp $ */
+/* $OpenBSD: rfork_thread.S,v 1.2 2011/10/17 06:39:20 guenther Exp $ */
/*
* Copyright (c) 2005, Miodrag Vallat
@@ -28,17 +28,17 @@
#include "../../../libc/arch/mips64/SYS.h"
/*
- * int rfork_thread(int flags, void *stack, void (*func)(void *), void *arg);
+ * int __tfork_thread(const struct __tfork *param, void *stack, void (*func)(void *), void *arg);
*/
-LEAF(rfork_thread, 32)
+LEAF(__tfork_thread, 32)
/* a0 = flags, a1 = stack, a2 = func, a3 = arg */
PTR_SUBU sp, 32
- SETUP_GP64(16, _C_LABEL(rfork_thread))
+ SETUP_GP64(16, _C_LABEL(__tfork_thread))
move t0, a1 /* stack */
move t1, a3 /* arg */
- __DO_SYSCALL(rfork)
+ __DO_SYSCALL(__tfork)
bnez a3, 9f
RESTORE_GP64
@@ -76,4 +76,4 @@ LEAF(rfork_thread, 32)
PTR_ADDU sp, 32
jr t9
nop
-END(rfork_thread)
+END(__tfork_thread)
diff --git a/lib/librthread/arch/powerpc/rfork_thread.S b/lib/librthread/arch/powerpc/rfork_thread.S
index 15e0667e12f..5731553fbe7 100644
--- a/lib/librthread/arch/powerpc/rfork_thread.S
+++ b/lib/librthread/arch/powerpc/rfork_thread.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: rfork_thread.S,v 1.3 2006/01/05 16:09:39 otto Exp $ */
+/* $OpenBSD: rfork_thread.S,v 1.4 2011/10/17 06:39:20 guenther Exp $ */
/*
* Copyright (c) 2005 Tim Wiess <tim@nop.cx>
@@ -19,7 +19,7 @@
#include <sys/syscall.h>
#include <machine/asm.h>
-ENTRY(rfork_thread)
+ENTRY(__tfork_thread)
/* sanity check */
cmpwi %r4, 0
beq 1f
@@ -28,8 +28,8 @@ ENTRY(rfork_thread)
mr %r7,%r4
- /* call rfork */
- li %r0, SYS_rfork
+ /* call __tfork */
+ li %r0, SYS___tfork
sc
cmpwi %r0, 0
bne 2f
diff --git a/lib/librthread/arch/sh/cerror.S b/lib/librthread/arch/sh/cerror.S
new file mode 100644
index 00000000000..1f19e2846d5
--- /dev/null
+++ b/lib/librthread/arch/sh/cerror.S
@@ -0,0 +1,58 @@
+/* $OpenBSD: cerror.S,v 1.1 2011/10/17 06:39:20 guenther Exp $ */
+/* $NetBSD: cerror.S,v 1.10 2006/01/06 05:14:39 uwe Exp $ */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * 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.
+ *
+ * from: @(#)cerror.s 5.1 (Berkeley) 4/23/90
+ */
+
+#include "SYS.h"
+
+NASENTRY(CERROR)
+ mov.l .L___errno, r1
+ PIC_PROLOGUE(.L_got)
+ sts.l pr, @-sp
+1: CALL r1
+ mov.l r4, @-sp ! save error code
+ mov.l @sp+, r4
+ lds.l @sp+, pr
+ PIC_EPILOGUE
+ mov.l r4, @r0
+ mov #-1, r1
+ rts
+ mov #-1, r0
+
+ .align 2
+.L_got: PIC_GOT_DATUM
+.L___errno: CALL_DATUM(_C_LABEL(_errno), 1b)
+ SET_ASENTRY_SIZE(CERROR)
+
diff --git a/lib/librthread/arch/sh/rfork_thread.S b/lib/librthread/arch/sh/rfork_thread.S
index 80fdf2c3cad..fb6002477fc 100644
--- a/lib/librthread/arch/sh/rfork_thread.S
+++ b/lib/librthread/arch/sh/rfork_thread.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: rfork_thread.S,v 1.1 2007/03/24 18:21:34 miod Exp $ */
+/* $OpenBSD: rfork_thread.S,v 1.2 2011/10/17 06:39:20 guenther Exp $ */
/*
* Copyright (c) 2007 Miodrag Vallat.
@@ -20,11 +20,11 @@
#include "../../../libc/arch/sh/SYS.h"
/*
- * int rfork_thread(int flags, void *stack, void (*func)(void *), void *arg);
- * r4 r5 r6 r7
+ * int __tfork_thread(const struct __tfork *param, void *stack, void (*func)(void *), void *arg);
+ * r4 r5 r6 r7
*/
-ENTRY(rfork_thread)
- mov.l .LSYS_rfork, r0
+ENTRY(__tfork_thread)
+ mov.l .LSYS___tfork, r0
.word 0xc380 /* trapa #0x80 */
bf 9f
@@ -55,7 +55,7 @@ ENTRY(rfork_thread)
JUMP_CERROR
.align 2
-.LSYS_rfork: .long SYS_rfork
+.LSYS___tfork: .long SYS___tfork
.LSYS_threxit: .long SYS_threxit
- SET_ENTRY_SIZE(rfork_thread)
+ SET_ENTRY_SIZE(__tfork_thread)
diff --git a/lib/librthread/arch/sparc/cerror.S b/lib/librthread/arch/sparc/cerror.S
new file mode 100644
index 00000000000..92b85f0338a
--- /dev/null
+++ b/lib/librthread/arch/sparc/cerror.S
@@ -0,0 +1,51 @@
+/* $OpenBSD: cerror.S,v 1.1 2011/10/17 06:39:20 guenther Exp $ */
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * 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 "SYS.h"
+
+#define ERRNOPTR_OFFSET 12
+
+ .globl _C_LABEL(errno)
+FUNC(_C_LABEL(__cerror))
+ ld [%g7 + ERRNOPTR_OFFSET], %g1
+ st %o0, [%g1]
+ mov -1, %o0
+ retl
+ mov -1, %o1
+
+#if 0 /* generic code works */
+NENTRY(__errno)
+ retl
+ ld [%g7 + ERRNOPTR_OFFSET], %o0
+#endif
diff --git a/lib/librthread/arch/sparc/rfork_thread.S b/lib/librthread/arch/sparc/rfork_thread.S
index a7dc8135e88..fc4b4f998c7 100644
--- a/lib/librthread/arch/sparc/rfork_thread.S
+++ b/lib/librthread/arch/sparc/rfork_thread.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: rfork_thread.S,v 1.1 2005/12/25 16:00:02 miod Exp $ */
+/* $OpenBSD: rfork_thread.S,v 1.2 2011/10/17 06:39:20 guenther Exp $ */
/*
* Copyright (c) 2005, Miodrag Vallat
@@ -28,16 +28,16 @@
#include "../../../libc/arch/sparc/SYS.h"
/*
- * int rfork_thread(int flags, void *stack, void (*func)(void *), void *arg);
+ * int __tfork_thread(const struct __tfork *param, void *stack, void (*func)(void *), void *arg);
*/
-ENTRY(rfork_thread)
+ENTRY(__tfork_thread)
mov %o1, %o4 /* save stack */
/*
- * We can not invoke rfork as a G2-style system call since we want
+ * We can not invoke __tfork as a G2-style system call since we want
* different return paths.
- */
- mov SYS_rfork, %g1
+ */
+ mov SYS___tfork, %g1
t ST_SYSCALL
bcs 9f
nop
@@ -58,7 +58,8 @@ ENTRY(rfork_thread)
* Don't forget to allocate room for a window save on the new
* stack!
*/
- sub %o4, 64, %sp /* stack */
+ sub %g0, %g0, %fp
+ sub %o4, 96, %sp /* stack */
call %o2 /* func */
mov %o3, %o0 /* arg */
diff --git a/lib/librthread/arch/sparc64/cerror.S b/lib/librthread/arch/sparc64/cerror.S
new file mode 100644
index 00000000000..18c4663bd44
--- /dev/null
+++ b/lib/librthread/arch/sparc64/cerror.S
@@ -0,0 +1,54 @@
+/* $OpenBSD: cerror.S,v 1.1 2011/10/17 06:39:20 guenther Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * 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>
+
+#include "SYS.h"
+
+#define ERRNOPTR_OFFSET 24
+
+ .globl _C_LABEL(errno)
+FUNC(__cerror)
+ ldx [%g7 + ERRNOPTR_OFFSET], %g1
+ st %o0, [%g1]
+ mov -1, %o0
+ retl
+ mov -1, %o1
+
+#if 0 /* generic code works */
+FUNC(__errno)
+ retl
+ ldx [%g7 + ERRNOPTR_OFFSET], %o0
+#endif
diff --git a/lib/librthread/arch/sparc64/rfork_thread.S b/lib/librthread/arch/sparc64/rfork_thread.S
index 9df22a351a0..d35f6ba1d74 100644
--- a/lib/librthread/arch/sparc64/rfork_thread.S
+++ b/lib/librthread/arch/sparc64/rfork_thread.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: rfork_thread.S,v 1.2 2011/10/13 05:29:51 guenther Exp $ */
+/* $OpenBSD: rfork_thread.S,v 1.3 2011/10/17 06:39:20 guenther Exp $ */
/*
* Copyright (c) 2005, Miodrag Vallat
@@ -28,16 +28,16 @@
#include "../../../libc/arch/sparc64/SYS.h"
/*
- * int rfork_thread(int flags, void *stack, void (*func)(void *), void *arg);
+ * int __tfork_thread(const struct __tfork *param, void *stack, void (*func)(void *), void *arg);
*/
-ENTRY(rfork_thread)
+ENTRY(__tfork_thread)
mov %o1, %o4 /* save stack */
/*
- * We can not invoke rfork as a G2-style system call since we want
+ * We can not invoke __tfork as a G2-style system call since we want
* different return paths.
- */
- mov SYS_rfork, %g1
+ */
+ mov SYS___tfork, %g1
t ST_SYSCALL
bcs 9f
nop
diff --git a/lib/librthread/arch/vax/cerror.S b/lib/librthread/arch/vax/cerror.S
new file mode 100644
index 00000000000..b5c468deeac
--- /dev/null
+++ b/lib/librthread/arch/vax/cerror.S
@@ -0,0 +1,40 @@
+/* $OpenBSD: cerror.S,v 1.1 2011/10/17 06:39:20 guenther Exp $ */
+/*
+ * Copyright (c) 1983, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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 "SYS.h"
+
+ .globl _C_LABEL(__errno)
+_C_LABEL(_cerror):
+ pushl r0
+ calls $0, _C_LABEL(__errno)
+ movl (sp)+, (r0)
+ mnegl $1,r0
+ movl r0,r1
+ ret
diff --git a/lib/librthread/arch/vax/rfork_thread.S b/lib/librthread/arch/vax/rfork_thread.S
index 85648cb8918..a7e6259b9e0 100644
--- a/lib/librthread/arch/vax/rfork_thread.S
+++ b/lib/librthread/arch/vax/rfork_thread.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: rfork_thread.S,v 1.2 2008/05/21 20:39:32 miod Exp $ */
+/* $OpenBSD: rfork_thread.S,v 1.3 2011/10/17 06:39:20 guenther Exp $ */
/*
* Copyright (c) 2005, Miodrag Vallat
@@ -28,9 +28,9 @@
#include "../../../libc/arch/vax/SYS.h"
/*
- * int rfork_thread(int flags, void *stack, void (*func)(void *), void *arg);
+ * int __tfork_thread(const struct __tfork *param, void *stack, void (*func)(void *), void *arg);
*/
-ENTRY(rfork_thread, R2|R3|R4)
+ENTRY(__tfork_thread, R2|R3|R4)
/*
* Save thread creation arguments into registers.
*/
@@ -38,7 +38,7 @@ ENTRY(rfork_thread, R2|R3|R4)
movl 12(ap), r3 /* func */
movl 16(ap), r4 /* arg */
- __DO_SYSCALL(rfork)
+ __DO_SYSCALL(__tfork)
jcs 9f
cmpl r0, $0