summaryrefslogtreecommitdiffstats
path: root/lib/libc/arch/sparc
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2016-05-07 19:05:21 +0000
committerguenther <guenther@openbsd.org>2016-05-07 19:05:21 +0000
commitfe38b55cb0aae270de3f844146814682e8cd345c (patch)
tree9825cc8aa96314e8e79ea1802ccbc9349772680b /lib/libc/arch/sparc
parentImplement ACPI 5.0 GeneralPurposeIo OpRegion support. This basically allows (diff)
downloadwireguard-openbsd-fe38b55cb0aae270de3f844146814682e8cd345c.tar.xz
wireguard-openbsd-fe38b55cb0aae270de3f844146814682e8cd345c.zip
Use a Thread Information Block in both single and multi-threaded programs.
This stores errno, the cancelation flags, and related bits for each thread and is allocated by ld.so or libc.a. This is an ABI break from 5.9-stable! Make libpthread dlopen'able by moving the cancelation wrappers into libc and doing locking and fork/errno handling via callbacks that libpthread registers when it first initializes. 'errno' *must* be declared via <errno.h> now! Clean up libpthread's symbol exports like libc. On powerpc, offset the TIB/TCB/TLS data from the register per the ELF spec. Testing by various, particularly sthen@ and patrick@ ok kettenis@
Diffstat (limited to 'lib/libc/arch/sparc')
-rw-r--r--lib/libc/arch/sparc/SYS.h33
-rw-r--r--lib/libc/arch/sparc/sys/Ovfork.S4
-rw-r--r--lib/libc/arch/sparc/sys/cerror.S59
-rw-r--r--lib/libc/arch/sparc/sys/fork.S38
-rw-r--r--lib/libc/arch/sparc/sys/sigsuspend.S6
5 files changed, 15 insertions, 125 deletions
diff --git a/lib/libc/arch/sparc/SYS.h b/lib/libc/arch/sparc/SYS.h
index 1e22754c186..b507659224a 100644
--- a/lib/libc/arch/sparc/SYS.h
+++ b/lib/libc/arch/sparc/SYS.h
@@ -30,13 +30,16 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: SYS.h,v 1.20 2015/10/23 04:39:25 guenther Exp $
+ * $OpenBSD: SYS.h,v 1.21 2016/05/07 19:05:22 guenther Exp $
*/
#include "DEFS.h"
#include <sys/syscall.h>
#include <machine/trap.h>
+/* offsetof(struct tib, tib_errno) - offsetof(struct tib, __tib_tcb) */
+#define TCB_OFFSET_ERRNO 12
+
#define _CAT(x,y) x##y
#define __ENTRY(p,x) ENTRY(_CAT(p,x)) ; .weak x ; x = _CAT(p,x)
@@ -48,27 +51,13 @@
#define __END(p,x) __END_HIDDEN(p,x); END(x)
/*
- * ERROR branches to cerror.
+ * ERROR sets the thread's errno and returns
*/
-#ifdef __PIC__
-#if __PIC__ == 1
-#define ERROR() \
- PIC_PROLOGUE(%g1,%g2); \
- ld [%g1+_C_LABEL(__cerror)],%g2; jmp %g2; nop
-#else /* __PIC__ == 2 */
-#define ERROR() \
- PIC_PROLOGUE(%g1,%g2); \
- sethi %hi(_C_LABEL(__cerror)),%g2; \
- or %g2,%lo(_C_LABEL(__cerror)),%g2; \
- ld [%g1+%g2],%g2; jmp %g2; nop
-#endif
-#else
-#define ERROR() \
- sethi %hi(_C_LABEL(__cerror)),%g1; \
- or %lo(_C_LABEL(__cerror)),%g1,%g1; \
- jmp %g1; \
- nop
-#endif
+#define ERROR() \
+ st %o0, [%g7 + TCB_OFFSET_ERRNO]; \
+ mov -1, %o0; \
+ retl; \
+ mov -1, %o1
/*
* SYSCALL is used when further action must be taken before returning.
@@ -112,5 +101,3 @@
# define SYSENTRY_HIDDEN(x) __ENTRY_HIDDEN(_thread_sys_,x)
# define SYSCALL_END(x) __END(_thread_sys_,x)
# define SYSCALL_END_HIDDEN(x) __END_HIDDEN(_thread_sys_,x)
-
- .globl _C_LABEL(__cerror)
diff --git a/lib/libc/arch/sparc/sys/Ovfork.S b/lib/libc/arch/sparc/sys/Ovfork.S
index a0a9ce8d3d8..fd37aecda0b 100644
--- a/lib/libc/arch/sparc/sys/Ovfork.S
+++ b/lib/libc/arch/sparc/sys/Ovfork.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: Ovfork.S,v 1.5 2015/03/31 04:32:02 guenther Exp $ */
+/* $OpenBSD: Ovfork.S,v 1.6 2016/05/07 19:05:22 guenther Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -34,4 +34,4 @@
#include "SYS.h"
-RSYSCALL(vfork)
+RSYSCALL_HIDDEN(vfork)
diff --git a/lib/libc/arch/sparc/sys/cerror.S b/lib/libc/arch/sparc/sys/cerror.S
deleted file mode 100644
index 5b565a70ebd..00000000000
--- a/lib/libc/arch/sparc/sys/cerror.S
+++ /dev/null
@@ -1,59 +0,0 @@
-/* $OpenBSD: cerror.S,v 1.8 2012/09/04 19:08:15 deraadt 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 "DEFS.h"
-#include "SYS.h"
-
- .globl _C_LABEL(errno)
-
-WEAK_ALIAS(__cerror, ___cerror)
-
-FUNC(_C_LABEL(___cerror))
-#ifdef __PIC__
-#if __PIC__ == 1
- ld [%g1 + _C_LABEL(errno)], %g1
- st %o0, [%g1]
-#else /* __PIC__ == 2 */
- sethi %hi(_C_LABEL(errno)), %g2
- or %g2, %lo(_C_LABEL(errno)), %g2
- ld [%g1 + %g2], %g1
- st %o0, [%g1]
-#endif
-#else
- sethi %hi(_C_LABEL(errno)), %g1
- st %o0, [%g1 + %lo(_C_LABEL(errno))]
-#endif
- mov -1, %o0
- retl
- mov -1, %o1
diff --git a/lib/libc/arch/sparc/sys/fork.S b/lib/libc/arch/sparc/sys/fork.S
deleted file mode 100644
index 911fce204dd..00000000000
--- a/lib/libc/arch/sparc/sys/fork.S
+++ /dev/null
@@ -1,38 +0,0 @@
-/* $OpenBSD: fork.S,v 1.6 2015/04/07 01:27:07 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"
-
-RSYSCALL_HIDDEN(fork)
-WEAK_ALIAS(_thread_fork,_thread_sys_fork)
diff --git a/lib/libc/arch/sparc/sys/sigsuspend.S b/lib/libc/arch/sparc/sys/sigsuspend.S
index ee728bd4f9f..0dcd0dbaff0 100644
--- a/lib/libc/arch/sparc/sys/sigsuspend.S
+++ b/lib/libc/arch/sparc/sys/sigsuspend.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: sigsuspend.S,v 1.6 2015/09/10 13:29:09 guenther Exp $ */
+/* $OpenBSD: sigsuspend.S,v 1.7 2016/05/07 19:05:22 guenther Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -34,9 +34,9 @@
#include "SYS.h"
-SYSENTRY(sigsuspend)
+SYSENTRY_HIDDEN(sigsuspend)
ld [%o0], %o0 ! indirect to mask argument
mov SYS_sigsuspend, %g1
t ST_SYSCALL
ERROR() ! always terminates with EINTR
-SYSCALL_END(sigsuspend)
+SYSCALL_END_HIDDEN(sigsuspend)