diff options
author | 2016-05-07 19:05:21 +0000 | |
---|---|---|
committer | 2016-05-07 19:05:21 +0000 | |
commit | fe38b55cb0aae270de3f844146814682e8cd345c (patch) | |
tree | 9825cc8aa96314e8e79ea1802ccbc9349772680b /lib/libc/arch/sparc64 | |
parent | Implement ACPI 5.0 GeneralPurposeIo OpRegion support. This basically allows (diff) | |
download | wireguard-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/sparc64')
-rw-r--r-- | lib/libc/arch/sparc64/SYS.h | 28 | ||||
-rw-r--r-- | lib/libc/arch/sparc64/sys/Ovfork.S | 4 | ||||
-rw-r--r-- | lib/libc/arch/sparc64/sys/cerror.S | 57 | ||||
-rw-r--r-- | lib/libc/arch/sparc64/sys/fork.S | 41 | ||||
-rw-r--r-- | lib/libc/arch/sparc64/sys/sigsuspend.S | 6 |
5 files changed, 14 insertions, 122 deletions
diff --git a/lib/libc/arch/sparc64/SYS.h b/lib/libc/arch/sparc64/SYS.h index 85c48829f8c..891323eb508 100644 --- a/lib/libc/arch/sparc64/SYS.h +++ b/lib/libc/arch/sparc64/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.15 2015/10/23 04:39:25 guenther Exp $ */ +/* $OpenBSD: SYS.h,v 1.16 2016/05/07 19:05:22 guenther Exp $ */ /*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -41,6 +41,9 @@ #include <sys/syscall.h> #include <machine/trap.h> +/* offsetof(struct tib, tib_errno) - offsetof(struct tib, __tib_tcb) */ +#define TCB_OFFSET_ERRNO 24 + #define _CAT(x,y) x##y #define __ENTRY(p,x) ENTRY(_CAT(p,x)) ; .weak x; x = _CAT(p,x) @@ -76,23 +79,12 @@ #define __END(p,x) __END_HIDDEN(p,x); END(x) /* - * ERROR branches to cerror. This is done with a macro so that I can - * change it to be position independent later, if need be. + * ERROR sets the thread's errno and returns */ -#ifdef __PIC__ -#define CALL(name) \ - PIC_PROLOGUE(%g1,%g2); \ - sethi %hi(name),%g2; \ - or %g2,%lo(name),%g2; \ - ldx [%g1+%g2],%g2; \ - jmp %g2; \ - nop -#else -#define CALL(name) \ - sethi %hi(name),%g1; or %lo(name),%g1,%g1; \ - jmp %g1; nop -#endif -#define ERROR() CALL(_C_LABEL(__cerror)) +#define ERROR() \ + st %o0, [%g7 + TCB_OFFSET_ERRNO]; \ + retl; \ + mov -1, %o0 /* * SYSCALL is used when further action must be taken before returning. @@ -155,8 +147,6 @@ __ENTRY(p,x); mov (_CAT(SYS_,y))|SYSCALL_G2RFLAG,%g1; add %o7,8,%g2; \ t ST_SYSCALL; __END(p,x) - .globl _C_LABEL(__cerror) - /* * SYSENTRY is for functions that pretend to be syscalls. */ diff --git a/lib/libc/arch/sparc64/sys/Ovfork.S b/lib/libc/arch/sparc64/sys/Ovfork.S index 86860d38482..a34a0ea3117 100644 --- a/lib/libc/arch/sparc64/sys/Ovfork.S +++ b/lib/libc/arch/sparc64/sys/Ovfork.S @@ -1,4 +1,4 @@ -/* $OpenBSD: Ovfork.S,v 1.3 2015/03/31 04:32:02 guenther Exp $ */ +/* $OpenBSD: Ovfork.S,v 1.4 2016/05/07 19:05:22 guenther Exp $ */ /* * Copyright (c) 1992, 1993 @@ -37,4 +37,4 @@ #include "SYS.h" -RSYSCALL(vfork) +RSYSCALL_HIDDEN(vfork) diff --git a/lib/libc/arch/sparc64/sys/cerror.S b/lib/libc/arch/sparc64/sys/cerror.S deleted file mode 100644 index d00ed87c596..00000000000 --- a/lib/libc/arch/sparc64/sys/cerror.S +++ /dev/null @@ -1,57 +0,0 @@ -/* $OpenBSD: cerror.S,v 1.6 2015/09/05 06:22:47 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" - -WEAK_ALIAS(__cerror, ___cerror) - - .globl _C_LABEL(errno) -FUNC(___cerror) -#ifdef __PIC__ - PIC_PROLOGUE(%g1, %o3) - sethi %hi(_C_LABEL(errno)), %o3 - or %o3, %lo(_C_LABEL(errno)), %o3 - ldx [ %g1 + %o3 ], %g1 - st %o0, [%g1] -#else - sethi %hi(_C_LABEL(errno)), %g1 - st %o0, [%g1 + %lo(_C_LABEL(errno))] -#endif - mov -1, %o0 - retl - mov -1, %o1 -END(___cerror) diff --git a/lib/libc/arch/sparc64/sys/fork.S b/lib/libc/arch/sparc64/sys/fork.S deleted file mode 100644 index f432448d4ad..00000000000 --- a/lib/libc/arch/sparc64/sys/fork.S +++ /dev/null @@ -1,41 +0,0 @@ -/* $OpenBSD: fork.S,v 1.4 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 <machine/asm.h> - -#include "SYS.h" - -RSYSCALL_HIDDEN(fork) -WEAK_ALIAS(_thread_fork,_thread_sys_fork) diff --git a/lib/libc/arch/sparc64/sys/sigsuspend.S b/lib/libc/arch/sparc64/sys/sigsuspend.S index c81c9d4310e..0bede84ef73 100644 --- a/lib/libc/arch/sparc64/sys/sigsuspend.S +++ b/lib/libc/arch/sparc64/sys/sigsuspend.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigsuspend.S,v 1.3 2015/09/05 06:22:47 guenther Exp $ */ +/* $OpenBSD: sigsuspend.S,v 1.4 2016/05/07 19:05:22 guenther Exp $ */ /* * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -36,9 +36,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) |