summaryrefslogtreecommitdiffstats
path: root/lib/libc/arch
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/arch')
-rw-r--r--lib/libc/arch/alpha/Makefile.inc4
-rw-r--r--lib/libc/arch/alpha/sys/Ovfork.S4
-rw-r--r--lib/libc/arch/alpha/sys/cerror.S25
-rw-r--r--lib/libc/arch/alpha/sys/fork.S34
-rw-r--r--lib/libc/arch/alpha/sys/sigsuspend.S6
-rw-r--r--lib/libc/arch/amd64/SYS.h64
-rw-r--r--lib/libc/arch/amd64/sys/Ovfork.S14
-rw-r--r--lib/libc/arch/amd64/sys/brk.S22
-rw-r--r--lib/libc/arch/amd64/sys/cerror.S55
-rw-r--r--lib/libc/arch/amd64/sys/fork.S43
-rw-r--r--lib/libc/arch/amd64/sys/sbrk.S21
-rw-r--r--lib/libc/arch/amd64/sys/sigprocmask.S14
-rw-r--r--lib/libc/arch/amd64/sys/sigsuspend.S16
-rw-r--r--lib/libc/arch/amd64/sys/syscall.S17
-rw-r--r--lib/libc/arch/amd64/sys/tfork_thread.S10
-rw-r--r--lib/libc/arch/arm/Makefile.inc4
-rw-r--r--lib/libc/arch/arm/SYS.h3
-rw-r--r--lib/libc/arch/arm/sys/Ovfork.S6
-rw-r--r--lib/libc/arch/arm/sys/cerror.S35
-rw-r--r--lib/libc/arch/arm/sys/fork.S38
-rw-r--r--lib/libc/arch/arm/sys/sigsuspend.S6
-rw-r--r--lib/libc/arch/hppa/SYS.h17
-rw-r--r--lib/libc/arch/hppa/sys/Ovfork.S17
-rw-r--r--lib/libc/arch/hppa/sys/cerror.S48
-rw-r--r--lib/libc/arch/hppa/sys/fork.S32
-rw-r--r--lib/libc/arch/hppa/sys/sigsuspend.S6
-rw-r--r--lib/libc/arch/hppa64/SYS.h18
-rw-r--r--lib/libc/arch/hppa64/sys/Ovfork.S15
-rw-r--r--lib/libc/arch/hppa64/sys/cerror.S48
-rw-r--r--lib/libc/arch/hppa64/sys/fork.S32
-rw-r--r--lib/libc/arch/hppa64/sys/sigsuspend.S6
-rw-r--r--lib/libc/arch/i386/SYS.h51
-rw-r--r--lib/libc/arch/i386/sys/Ovfork.S19
-rw-r--r--lib/libc/arch/i386/sys/brk.S13
-rw-r--r--lib/libc/arch/i386/sys/cerror.S52
-rw-r--r--lib/libc/arch/i386/sys/fork.S37
-rw-r--r--lib/libc/arch/i386/sys/sbrk.S13
-rw-r--r--lib/libc/arch/i386/sys/sigprocmask.S13
-rw-r--r--lib/libc/arch/i386/sys/sigsuspend.S18
-rw-r--r--lib/libc/arch/i386/sys/syscall.S13
-rw-r--r--lib/libc/arch/i386/sys/tfork_thread.S12
-rw-r--r--lib/libc/arch/m88k/Makefile.inc3
-rw-r--r--lib/libc/arch/m88k/sys/Ovfork.S4
-rw-r--r--lib/libc/arch/m88k/sys/cerror.S48
-rw-r--r--lib/libc/arch/m88k/sys/fork.S39
-rw-r--r--lib/libc/arch/m88k/sys/sigsuspend.S6
-rw-r--r--lib/libc/arch/mips64/Makefile.inc3
-rw-r--r--lib/libc/arch/mips64/SYS.h6
-rw-r--r--lib/libc/arch/mips64/sys/Ovfork.S4
-rw-r--r--lib/libc/arch/mips64/sys/cerror.S38
-rw-r--r--lib/libc/arch/mips64/sys/fork.S37
-rw-r--r--lib/libc/arch/mips64/sys/sigsuspend.S6
-rw-r--r--lib/libc/arch/powerpc/Makefile.inc3
-rw-r--r--lib/libc/arch/powerpc/SYS.h6
-rw-r--r--lib/libc/arch/powerpc/sys/Ovfork.S4
-rw-r--r--lib/libc/arch/powerpc/sys/brk.S4
-rw-r--r--lib/libc/arch/powerpc/sys/cerror.S13
-rw-r--r--lib/libc/arch/powerpc/sys/fork.S33
-rw-r--r--lib/libc/arch/powerpc/sys/sbrk.S4
-rw-r--r--lib/libc/arch/powerpc/sys/sigprocmask.S4
-rw-r--r--lib/libc/arch/powerpc/sys/sigsuspend.S6
-rw-r--r--lib/libc/arch/powerpc/sys/tfork_thread.S4
-rw-r--r--lib/libc/arch/sh/Makefile.inc3
-rw-r--r--lib/libc/arch/sh/SYS.h3
-rw-r--r--lib/libc/arch/sh/sys/Ovfork.S4
-rw-r--r--lib/libc/arch/sh/sys/cerror.S41
-rw-r--r--lib/libc/arch/sh/sys/fork.S41
-rw-r--r--lib/libc/arch/sh/sys/sigsuspend.S6
-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
-rw-r--r--lib/libc/arch/sparc64/SYS.h28
-rw-r--r--lib/libc/arch/sparc64/sys/Ovfork.S4
-rw-r--r--lib/libc/arch/sparc64/sys/cerror.S57
-rw-r--r--lib/libc/arch/sparc64/sys/fork.S41
-rw-r--r--lib/libc/arch/sparc64/sys/sigsuspend.S6
78 files changed, 337 insertions, 1233 deletions
diff --git a/lib/libc/arch/alpha/Makefile.inc b/lib/libc/arch/alpha/Makefile.inc
index 5bfc478e8ef..050910e7bcd 100644
--- a/lib/libc/arch/alpha/Makefile.inc
+++ b/lib/libc/arch/alpha/Makefile.inc
@@ -1,6 +1,8 @@
-# $OpenBSD: Makefile.inc,v 1.6 2014/06/09 20:47:10 miod Exp $
+# $OpenBSD: Makefile.inc,v 1.7 2016/05/07 19:05:21 guenther Exp $
# $NetBSD: Makefile.inc,v 1.4 1996/10/17 02:58:18 cgd Exp $
+CERROR= cerror.S
+
# `source' files built from m4 source
SRCS+= __divqu.S __divq.S __divlu.S __divl.S
SRCS+= __remqu.S __remq.S __remlu.S __reml.S
diff --git a/lib/libc/arch/alpha/sys/Ovfork.S b/lib/libc/arch/alpha/sys/Ovfork.S
index 5da581bcc6f..d5df4e99f08 100644
--- a/lib/libc/arch/alpha/sys/Ovfork.S
+++ b/lib/libc/arch/alpha/sys/Ovfork.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: Ovfork.S,v 1.6 2015/03/31 04:32:01 guenther Exp $ */
+/* $OpenBSD: Ovfork.S,v 1.7 2016/05/07 19:05:21 guenther Exp $ */
/* $NetBSD: Ovfork.S,v 1.1 1995/02/10 17:50:29 cgd Exp $ */
/*
@@ -30,4 +30,4 @@
#include "SYS.h"
-RSYSCALL(vfork)
+RSYSCALL_HIDDEN(vfork)
diff --git a/lib/libc/arch/alpha/sys/cerror.S b/lib/libc/arch/alpha/sys/cerror.S
index c85de3282e9..6bee6c9e106 100644
--- a/lib/libc/arch/alpha/sys/cerror.S
+++ b/lib/libc/arch/alpha/sys/cerror.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: cerror.S,v 1.6 2011/04/04 12:42:39 guenther Exp $ */
+/* $OpenBSD: cerror.S,v 1.7 2016/05/07 19:05:21 guenther Exp $ */
/* $NetBSD: cerror.S,v 1.3 1996/10/17 03:08:17 cgd Exp $ */
/*
@@ -30,14 +30,25 @@
#include "SYS.h"
-IMPORT(errno, 4)
+#define FRAME_SIZE 16
+#define FRAME_RA_OFFSET 0
+#define FRAME_V0_OFFSET 8
-WEAK_ALIAS(__cerror, ___cerror)
-
-LEAF(___cerror, 0)
+NESTED(__cerror, 0, FRAME_SIZE, ra, IM_RA|IM_V0, 0)
+LEAF_NOPROFILE(__cerror, 0)
br t0, L1
L1: LDGP(t0)
- stl v0, errno
+
+ 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)
+END(__cerror)
diff --git a/lib/libc/arch/alpha/sys/fork.S b/lib/libc/arch/alpha/sys/fork.S
deleted file mode 100644
index 59b96139585..00000000000
--- a/lib/libc/arch/alpha/sys/fork.S
+++ /dev/null
@@ -1,34 +0,0 @@
-/* $OpenBSD: fork.S,v 1.7 2015/04/07 01:27:06 guenther Exp $ */
-/* $NetBSD: fork.S,v 1.1 1995/02/10 17:50:34 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"
-
-RSYSCALL_HIDDEN(fork)
-WEAK_ALIAS(_thread_fork,_thread_sys_fork)
diff --git a/lib/libc/arch/alpha/sys/sigsuspend.S b/lib/libc/arch/alpha/sys/sigsuspend.S
index f5201db29f6..f5f05ec3098 100644
--- a/lib/libc/arch/alpha/sys/sigsuspend.S
+++ b/lib/libc/arch/alpha/sys/sigsuspend.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: sigsuspend.S,v 1.7 2015/10/23 04:39:24 guenther Exp $ */
+/* $OpenBSD: sigsuspend.S,v 1.8 2016/05/07 19:05:21 guenther Exp $ */
/* $NetBSD: sigsuspend.S,v 1.2 1996/10/17 03:08:22 cgd Exp $ */
/*
@@ -30,9 +30,9 @@
#include "SYS.h"
-SYSLEAF(sigsuspend, 1)
+SYSLEAF_HIDDEN(sigsuspend, 1)
ldl a0, 0(a0) /* pass *mask instead of mask */
CALLSYS_ERROR(sigsuspend)
mov zero, v0 /* shouldn't need; just in case... */
RET
-SYSCALL_END(sigsuspend)
+SYSCALL_END_HIDDEN(sigsuspend)
diff --git a/lib/libc/arch/amd64/SYS.h b/lib/libc/arch/amd64/SYS.h
index 3168fa60ab2..3479377f801 100644
--- a/lib/libc/arch/amd64/SYS.h
+++ b/lib/libc/arch/amd64/SYS.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: SYS.h,v 1.18 2015/11/14 21:53:03 guenther Exp $ */
+/* $OpenBSD: SYS.h,v 1.19 2016/05/07 19:05:21 guenther Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -38,6 +38,8 @@
#include "DEFS.h"
#include <sys/syscall.h>
+/* offsetof(struct tib, tib_errno) - offsetof(struct tib, __tib_tcb) */
+#define TCB_OFFSET_ERRNO 32
#define SYSTRAP(x) movl $(SYS_ ## x),%eax; movq %rcx, %r10; syscall
@@ -53,8 +55,14 @@
END(_HIDDEN(x))
#define SYSCALL_END(x) SYSCALL_END_HIDDEN(x); END(x)
-#define CERROR _C_LABEL(__cerror)
-#define _CERROR _C_LABEL(___cerror)
+
+#define SET_ERRNO \
+ movl %eax,%fs:(TCB_OFFSET_ERRNO); \
+ movq $-1, %rax
+#define HANDLE_ERRNO \
+ jnc,pt 99f; \
+ SET_ERRNO; \
+ 99:
#define _SYSCALL_NOERROR(x,y) \
SYSENTRY(x); \
@@ -63,39 +71,23 @@
SYSENTRY_HIDDEN(x); \
SYSTRAP(y)
-#ifdef __PIC__
-#define _SYSCALL(x,y) \
- .text; _ALIGN_TEXT; \
- 2: mov PIC_GOT(CERROR), %rcx; \
- jmp *%rcx; \
- _SYSCALL_NOERROR(x,y); \
- jc 2b
-#define _SYSCALL_HIDDEN(x,y) \
- .text; _ALIGN_TEXT; \
- 2: mov PIC_GOT(CERROR), %rcx; \
- jmp *%rcx; \
- _SYSCALL_HIDDEN_NOERROR(x,y); \
- jc 2b
-#else
-#define _SYSCALL(x,y) \
- .text; _ALIGN_TEXT; \
- 2: jmp CERROR; \
- _SYSCALL_NOERROR(x,y); \
- jc 2b
-#define _SYSCALL_HIDDEN(x,y) \
- .text; _ALIGN_TEXT; \
- 2: jmp CERROR; \
- _SYSCALL_HIDDEN_NOERROR(x,y); \
- jc 2b
-#endif
-
#define SYSCALL_NOERROR(x) \
_SYSCALL_NOERROR(x,x)
#define SYSCALL_HIDDEN(x) \
- _SYSCALL_HIDDEN(x,x)
+ _SYSCALL_HIDDEN_NOERROR(x,x); \
+ HANDLE_ERRNO
#define SYSCALL(x) \
- _SYSCALL(x,x)
+ _SYSCALL_NOERROR(x,x); \
+ HANDLE_ERRNO
+
+
+/* return, handling errno for failed calls */
+#define _RSYSCALL_RET \
+ jc,pn 99f; \
+ ret; \
+ 99: SET_ERRNO; \
+ ret
#define PSEUDO_NOERROR(x,y) \
_SYSCALL_NOERROR(x,y); \
@@ -103,12 +95,12 @@
SYSCALL_END(x)
#define PSEUDO(x,y) \
- _SYSCALL(x,y); \
- ret; \
+ _SYSCALL_NOERROR(x,y); \
+ _RSYSCALL_RET; \
SYSCALL_END(x)
#define PSEUDO_HIDDEN(x,y) \
- _SYSCALL_HIDDEN(x,y); \
- ret; \
+ _SYSCALL_HIDDEN_NOERROR(x,y); \
+ _RSYSCALL_RET; \
SYSCALL_END_HIDDEN(x)
#define RSYSCALL_NOERROR(x) \
@@ -118,5 +110,3 @@
PSEUDO(x,x)
#define RSYSCALL_HIDDEN(x) \
PSEUDO_HIDDEN(x,x)
-
- .globl CERROR
diff --git a/lib/libc/arch/amd64/sys/Ovfork.S b/lib/libc/arch/amd64/sys/Ovfork.S
index 6e70f7231a8..e42649e28ce 100644
--- a/lib/libc/arch/amd64/sys/Ovfork.S
+++ b/lib/libc/arch/amd64/sys/Ovfork.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: Ovfork.S,v 1.7 2015/10/17 22:40:54 guenther Exp $ */
+/* $OpenBSD: Ovfork.S,v 1.8 2016/05/07 19:05:21 guenther Exp $ */
/* $NetBSD: Ovfork.S,v 1.2 2002/06/03 18:30:33 fvdl Exp $ */
/*-
@@ -39,17 +39,13 @@
#include "SYS.h"
-SYSENTRY(vfork)
+SYSENTRY_HIDDEN(vfork)
popq %r9 /* my rta into r9 */
SYSTRAP(vfork)
jc 1f
jmp *%r9
1:
pushq %r9
-#ifdef __PIC__
- movq PIC_GOT(CERROR), %rcx
- jmp *%rcx
-#else
- jmp CERROR
-#endif
-SYSCALL_END(vfork)
+ SET_ERRNO
+ ret
+SYSCALL_END_HIDDEN(vfork)
diff --git a/lib/libc/arch/amd64/sys/brk.S b/lib/libc/arch/amd64/sys/brk.S
index c59f0036eb0..26fb2893b58 100644
--- a/lib/libc/arch/amd64/sys/brk.S
+++ b/lib/libc/arch/amd64/sys/brk.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: brk.S,v 1.7 2015/09/05 06:22:47 guenther Exp $ */
+/* $OpenBSD: brk.S,v 1.8 2016/05/07 19:05:21 guenther Exp $ */
/* $NetBSD: brk.S,v 1.2 2002/06/03 18:30:33 fvdl Exp $ */
/*-
@@ -51,22 +51,6 @@ __minbrk:
.weak brk
ENTRY(brk)
-#ifdef __PIC__
- movq PIC_GOT(__minbrk),%rdx
- cmpq %rdi,(%rdx)
- jb 1f
- movq (%rdx),%rdi
-1:
- SYSTRAP(break)
- jc 1f
- movq PIC_GOT(__curbrk),%rdx # set up GOT addressing
- movq %rdi,(%rdx)
- xorl %eax,%eax
- ret
-1:
- movq PIC_GOT(CERROR),%rdx
- jmp *%rdx
-#else
cmpq %rdi,__minbrk(%rip)
jb 1f
movq __minbrk(%rip),%rdi
@@ -77,6 +61,6 @@ ENTRY(brk)
xorl %eax,%eax
ret
1:
- jmp CERROR
-#endif
+ SET_ERRNO
+ ret
END(brk)
diff --git a/lib/libc/arch/amd64/sys/cerror.S b/lib/libc/arch/amd64/sys/cerror.S
deleted file mode 100644
index 89bf7f69aa4..00000000000
--- a/lib/libc/arch/amd64/sys/cerror.S
+++ /dev/null
@@ -1,55 +0,0 @@
-/* $OpenBSD: cerror.S,v 1.7 2015/06/01 09:31:40 uebayasi 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"
-
- .globl _C_LABEL(errno)
-
-WEAK_ALIAS(CERROR, _CERROR)
-
-_ENTRY(_CERROR)
-#ifdef __PIC__
- movq PIC_GOT(_C_LABEL(errno)), %rcx
- movl %eax, (%rcx)
-#else
- movl %eax, _C_LABEL(errno)(%rip)
-#endif /* PIC */
- movq $-1,%rax
- ret
-END(_CERROR)
diff --git a/lib/libc/arch/amd64/sys/fork.S b/lib/libc/arch/amd64/sys/fork.S
deleted file mode 100644
index 6582d8a9a32..00000000000
--- a/lib/libc/arch/amd64/sys/fork.S
+++ /dev/null
@@ -1,43 +0,0 @@
-/* $OpenBSD: fork.S,v 1.4 2015/04/07 01:27:06 guenther Exp $ */
-/* $NetBSD: fork.S,v 1.2 2003/02/13 02:50:51 nathanw 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: @(#)fork.s 5.1 (Berkeley) 4/23/90
- */
-
-#include <machine/asm.h>
-
-#include "SYS.h"
-
-RSYSCALL_HIDDEN(fork)
-WEAK_ALIAS(_thread_fork,_thread_sys_fork)
diff --git a/lib/libc/arch/amd64/sys/sbrk.S b/lib/libc/arch/amd64/sys/sbrk.S
index 06ed6ba7cca..05d289b03b9 100644
--- a/lib/libc/arch/amd64/sys/sbrk.S
+++ b/lib/libc/arch/amd64/sys/sbrk.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: sbrk.S,v 1.7 2015/09/05 06:22:47 guenther Exp $ */
+/* $OpenBSD: sbrk.S,v 1.8 2016/05/07 19:05:21 guenther Exp $ */
/* $NetBSD: sbrk.S,v 1.1 2001/06/19 00:25:06 fvdl Exp $ */
/*-
@@ -55,21 +55,6 @@ __curbrk: .quad _end
.weak sbrk
ENTRY(sbrk)
-#ifdef __PIC__
- movq PIC_GOT(__curbrk),%rdx
- movslq %edi, %rax
- movq (%rdx),%rdi
- addq %rax,%rdi
- SYSTRAP(break)
- jc 1f
- movq PIC_GOT(__curbrk),%rdx
- movq (%rdx),%rax
- movq %rdi,(%rdx)
- ret
-1:
- mov PIC_GOT(CERROR),%rdx
- jmp *%rdx
-#else
movq __curbrk(%rip),%rax
movslq %edi,%rsi
movq %rsi,%rdi
@@ -80,6 +65,6 @@ ENTRY(sbrk)
addq %rsi,__curbrk(%rip)
ret
1:
- jmp CERROR
-#endif
+ SET_ERRNO
+ ret
END(sbrk)
diff --git a/lib/libc/arch/amd64/sys/sigprocmask.S b/lib/libc/arch/amd64/sys/sigprocmask.S
index 065088d6548..308c5800b50 100644
--- a/lib/libc/arch/amd64/sys/sigprocmask.S
+++ b/lib/libc/arch/amd64/sys/sigprocmask.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: sigprocmask.S,v 1.8 2015/10/23 04:39:24 guenther Exp $ */
+/* $OpenBSD: sigprocmask.S,v 1.9 2016/05/07 19:05:21 guenther Exp $ */
/* $NetBSD: sigprocmask.S,v 1.1 2001/06/19 00:25:06 fvdl Exp $ */
/*-
@@ -48,16 +48,12 @@ SYSENTRY_HIDDEN(sigprocmask)
2: SYSTRAP(sigprocmask)
jc 1f
testq %rdx,%rdx # test if old mask requested
- jz out
+ jz 3f
movl %eax,(%rdx) # store old mask
-out:
+3:
xorl %eax,%eax
ret
1:
-#ifdef __PIC__
- movq PIC_GOT(CERROR), %rcx
- jmp *%rcx
-#else
- jmp CERROR
-#endif
+ SET_ERRNO
+ ret
SYSCALL_END_HIDDEN(sigprocmask)
diff --git a/lib/libc/arch/amd64/sys/sigsuspend.S b/lib/libc/arch/amd64/sys/sigsuspend.S
index 43e6ac3be3c..9abb04e1079 100644
--- a/lib/libc/arch/amd64/sys/sigsuspend.S
+++ b/lib/libc/arch/amd64/sys/sigsuspend.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: sigsuspend.S,v 1.6 2015/10/17 22:40:54 guenther Exp $ */
+/* $OpenBSD: sigsuspend.S,v 1.7 2016/05/07 19:05:21 guenther Exp $ */
/* $NetBSD: sigsuspend.S,v 1.1 2001/06/19 00:25:07 fvdl Exp $ */
/*-
@@ -39,17 +39,9 @@
#include "SYS.h"
-SYSENTRY(sigsuspend)
+SYSENTRY_HIDDEN(sigsuspend)
movl (%rdi),%edi # indirect to mask arg
SYSTRAP(sigsuspend)
- jc 1f
- xorl %eax,%eax # shouldn t happen
+ SET_ERRNO
ret
-1:
-#ifdef __PIC__
- movq PIC_GOT(CERROR), %rcx
- jmp *%rcx
-#else
- jmp CERROR
-#endif
-SYSCALL_END(sigsuspend)
+SYSCALL_END_HIDDEN(sigsuspend)
diff --git a/lib/libc/arch/amd64/sys/syscall.S b/lib/libc/arch/amd64/sys/syscall.S
index 0bf3ccfec47..6568ecc55af 100644
--- a/lib/libc/arch/amd64/sys/syscall.S
+++ b/lib/libc/arch/amd64/sys/syscall.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: syscall.S,v 1.7 2015/10/17 22:40:54 guenther Exp $ */
+/* $OpenBSD: syscall.S,v 1.8 2016/05/07 19:05:21 guenther Exp $ */
/* $NetBSD: syscall.S,v 1.2 2002/06/03 18:30:33 fvdl Exp $ */
/*-
@@ -39,17 +39,4 @@
#include "SYS.h"
-SYSENTRY(syscall)
- movq $0,%rax
- movq %rcx,%r10
- syscall
- jc 1f
- ret
-1:
-#ifdef __PIC__
- movq PIC_GOT(CERROR), %rcx
- jmp *%rcx
-#else
- jmp CERROR
-#endif
-SYSCALL_END(syscall)
+RSYSCALL(syscall)
diff --git a/lib/libc/arch/amd64/sys/tfork_thread.S b/lib/libc/arch/amd64/sys/tfork_thread.S
index 0f67225830e..3477228a40b 100644
--- a/lib/libc/arch/amd64/sys/tfork_thread.S
+++ b/lib/libc/arch/amd64/sys/tfork_thread.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: tfork_thread.S,v 1.5 2015/06/01 09:27:53 uebayasi Exp $ */
+/* $OpenBSD: tfork_thread.S,v 1.6 2016/05/07 19:05:21 guenther Exp $ */
/*-
* Copyright (c) 2000 Peter Wemm <peter@FreeBSD.org>
* Copyright (c) 2003 Alan L. Cox <alc@cs.rice.edu>
@@ -85,10 +85,6 @@ ENTRY(__tfork_thread)
* Branch here if the thread creation fails:
*/
2:
-#ifdef __PIC__
- movq PIC_GOT(CERROR), %rcx
- jmp *%rcx
-#else
- jmp CERROR
-#endif
+ SET_ERRNO
+ ret
END(__tfork_thread)
diff --git a/lib/libc/arch/arm/Makefile.inc b/lib/libc/arch/arm/Makefile.inc
index 429d29db9ee..3347bcd9a54 100644
--- a/lib/libc/arch/arm/Makefile.inc
+++ b/lib/libc/arch/arm/Makefile.inc
@@ -1,9 +1,9 @@
-# $OpenBSD: Makefile.inc,v 1.5 2014/06/09 20:47:10 miod Exp $
+# $OpenBSD: Makefile.inc,v 1.6 2016/05/07 19:05:21 guenther Exp $
# $NetBSD: Makefile.inc,v 1.5 2002/07/10 04:29:06 thorpej Exp $
.include <bsd.own.mk>
-#SRCS+= __sigaction14_sigtramp.c __sigtramp1.S
+CERROR= cerror.S
CPPFLAGS += -DSOFTFLOAT
diff --git a/lib/libc/arch/arm/SYS.h b/lib/libc/arch/arm/SYS.h
index 9812bb3ebc6..baa5f1aefbc 100644
--- a/lib/libc/arch/arm/SYS.h
+++ b/lib/libc/arch/arm/SYS.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: SYS.h,v 1.14 2015/10/23 04:39:24 guenther Exp $ */
+/* $OpenBSD: SYS.h,v 1.15 2016/05/07 19:05:21 guenther Exp $ */
/* $NetBSD: SYS.h,v 1.8 2003/08/07 16:42:02 agc Exp $ */
/*-
@@ -80,7 +80,6 @@
swi 0
#define CERROR _C_LABEL(__cerror)
-#define _CERROR _C_LABEL(___cerror)
#define _SYSCALL_NOERROR(x,y) \
SYSENTRY(x); \
diff --git a/lib/libc/arch/arm/sys/Ovfork.S b/lib/libc/arch/arm/sys/Ovfork.S
index 10d3ef3ec51..560949a3237 100644
--- a/lib/libc/arch/arm/sys/Ovfork.S
+++ b/lib/libc/arch/arm/sys/Ovfork.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: Ovfork.S,v 1.5 2015/09/10 13:29:09 guenther Exp $ */
+/* $OpenBSD: Ovfork.S,v 1.6 2016/05/07 19:05:21 guenther Exp $ */
/* $NetBSD: Ovfork.S,v 1.6 2003/08/07 16:42:03 agc Exp $ */
/*-
@@ -37,9 +37,9 @@
.text
.align 0
-SYSENTRY(vfork)
+SYSENTRY_HIDDEN(vfork)
mov r2, r14
SYSTRAP(vfork)
bcs PIC_SYM(CERROR, PLT)
mov r15, r2
-SYSCALL_END(vfork)
+SYSCALL_END_HIDDEN(vfork)
diff --git a/lib/libc/arch/arm/sys/cerror.S b/lib/libc/arch/arm/sys/cerror.S
index d595caa8f36..05ac31af3c0 100644
--- a/lib/libc/arch/arm/sys/cerror.S
+++ b/lib/libc/arch/arm/sys/cerror.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: cerror.S,v 1.7 2015/09/10 13:29:09 guenther Exp $ */
+/* $OpenBSD: cerror.S,v 1.8 2016/05/07 19:05:21 guenther Exp $ */
/* $NetBSD: cerror.S,v 1.5 2003/08/07 16:42:04 agc Exp $ */
/*-
@@ -34,32 +34,11 @@
#include "SYS.h"
-WEAK_ALIAS(CERROR, _CERROR)
-
-ASENTRY(_CERROR)
-#ifdef __PIC__
- /* Setup the GOT */
- ldr r3, .Lgot
- ldr r1, .Lerrno
-.L1:
- add r3, pc, r3
- ldr r1, [r3, r1]
-#else
- ldr r1, .Lerrno
-#endif /* PIC */
- str r0, [r1]
+_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
- mov pc, lr
-
-#ifdef __PIC__
- .align 0
-.Lgot:
- .word _C_LABEL(_GLOBAL_OFFSET_TABLE_) - (.L1+8)
-#endif /* PIC */
-
- .globl _C_LABEL(errno)
-
-.Lerrno:
- .word PIC_SYM(_C_LABEL(errno), GOT)
-END(_CERROR)
+ ldmfd sp!, {r4, pc}
diff --git a/lib/libc/arch/arm/sys/fork.S b/lib/libc/arch/arm/sys/fork.S
deleted file mode 100644
index 8d92b286369..00000000000
--- a/lib/libc/arch/arm/sys/fork.S
+++ /dev/null
@@ -1,38 +0,0 @@
-/* $OpenBSD: fork.S,v 1.4 2015/04/07 01:27:06 guenther Exp $ */
-/* $NetBSD: fork.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: @(#)fork.s 5.1 (Berkeley) 4/23/90
- */
-
-#include "SYS.h"
-
-RSYSCALL_HIDDEN(fork)
-WEAK_ALIAS(_thread_fork,_thread_sys_fork)
diff --git a/lib/libc/arch/arm/sys/sigsuspend.S b/lib/libc/arch/arm/sys/sigsuspend.S
index b1d695e2f20..3360eab7021 100644
--- a/lib/libc/arch/arm/sys/sigsuspend.S
+++ b/lib/libc/arch/arm/sys/sigsuspend.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: sigsuspend.S,v 1.4 2015/09/10 13:29:09 guenther Exp $ */
+/* $OpenBSD: sigsuspend.S,v 1.5 2016/05/07 19:05:21 guenther Exp $ */
/* $NetBSD: sigsuspend.S,v 1.6 2003/08/07 16:42:05 agc Exp $ */
/*-
@@ -34,10 +34,10 @@
#include "SYS.h"
-SYSENTRY(sigsuspend)
+SYSENTRY_HIDDEN(sigsuspend)
ldr r0, [r0]
SYSTRAP(sigsuspend)
bcs PIC_SYM(CERROR, PLT)
mov r0, #0x00000000
mov r15, r14
-SYSCALL_END(sigsuspend)
+SYSCALL_END_HIDDEN(sigsuspend)
diff --git a/lib/libc/arch/hppa/SYS.h b/lib/libc/arch/hppa/SYS.h
index 7f891b4f899..79cfa517c2c 100644
--- a/lib/libc/arch/hppa/SYS.h
+++ b/lib/libc/arch/hppa/SYS.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: SYS.h,v 1.21 2015/09/10 13:29:09 guenther Exp $ */
+/* $OpenBSD: SYS.h,v 1.22 2016/05/07 19:05:21 guenther Exp $ */
/*
* Copyright (c) 1998-2002 Michael Shalayeff
@@ -33,6 +33,9 @@
#include <machine/vmparam.h>
#undef _LOCORE
+/* offsetof(struct tib, tib_errno) - offsetof(struct tib, __tib_tcb) */
+#define TCB_OFFSET_ERRNO -8
+
/*
* We define a hidden alias with the prefix "_libc_" for each global symbol
* that may be used internally. By referencing _libc_x instead of x, other
@@ -83,9 +86,15 @@ LEAF_ENTRY(__CONCAT(_thread_sys_,x))
ldil L%SYSCALLGATE, r1 !\
ble 4(sr7, r1) !\
ldi __CONCAT(SYS_,x), t1 !\
- .import __cerror, code !\
- comb,<> r0, t1, __cerror !\
- ldw HPPA_FRAME_ERP(sr0,sp), rp
+ comb,= 0, t1, 1f !\
+ ldw HPPA_FRAME_ERP(sr0,sp), rp !\
+ /* set errno */ \
+ mfctl cr27, r1 !\
+ stw t1, TCB_OFFSET_ERRNO(r1) !\
+ ldi -1, ret0 !\
+ bv r0(rp) !\
+ ldi -1, ret1 !\
+1:
#define PSEUDO(x,y) !\
SYSENTRY(x) !\
diff --git a/lib/libc/arch/hppa/sys/Ovfork.S b/lib/libc/arch/hppa/sys/Ovfork.S
index 880c92ad961..8be9141b338 100644
--- a/lib/libc/arch/hppa/sys/Ovfork.S
+++ b/lib/libc/arch/hppa/sys/Ovfork.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: Ovfork.S,v 1.14 2015/03/31 04:32:01 guenther Exp $ */
+/* $OpenBSD: Ovfork.S,v 1.15 2016/05/07 19:05:21 guenther Exp $ */
/*
* Copyright (c) 1999,2002 Michael Shalayeff
@@ -28,17 +28,20 @@
#include "SYS.h"
-SYSENTRY(vfork)
+SYSENTRY_HIDDEN(vfork)
.import errno, data
copy rp, t4
ldil L%SYSCALLGATE, r1
ble 4(sr7, r1)
ldi __CONCAT(SYS_,vfork), t1
- .import __cerror, code
- comb,<> r0, t1, __cerror
+ comb,= r0, t1, 1f
copy t4, rp
- bv r0(rp)
- nop
-SYSEXIT(vfork)
+ /* set errno */
+ mfctl cr27, r1
+ stw t1, TCB_OFFSET_ERRNO(r1)
+ ldi -1, ret0
+1: bv r0(rp)
+ nop
+SYSEXIT_HIDDEN(vfork)
.end
diff --git a/lib/libc/arch/hppa/sys/cerror.S b/lib/libc/arch/hppa/sys/cerror.S
deleted file mode 100644
index fbec5adfd92..00000000000
--- a/lib/libc/arch/hppa/sys/cerror.S
+++ /dev/null
@@ -1,48 +0,0 @@
-/* $OpenBSD: cerror.S,v 1.6 2012/08/22 17:19:34 pascal Exp $ */
-
-/*
- * Copyright (c) 2004 Michael Shalayeff
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR OR HIS RELATIVES 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 MIND, 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"
-
-WEAK_ALIAS(__cerror, ___cerror)
-
- .import errno, data
-ENTRY(___cerror,0)
-#ifdef __PIC__
- addil LT%errno, r19
- ldw RT%errno(r1), r1
- stw t1, 0(r1)
-#else
- ldil L%errno, r1
- stw t1, R%errno(r1)
-#endif
- ldi -1, ret0
- bv r0(rp)
- ldi -1, ret1
-EXIT(___cerror)
-
- .end
diff --git a/lib/libc/arch/hppa/sys/fork.S b/lib/libc/arch/hppa/sys/fork.S
deleted file mode 100644
index 8bb3bc545b9..00000000000
--- a/lib/libc/arch/hppa/sys/fork.S
+++ /dev/null
@@ -1,32 +0,0 @@
-/* $OpenBSD: fork.S,v 1.13 2015/04/07 01:27:06 guenther Exp $ */
-
-/*
- * Copyright (c) 1999 Michael Shalayeff
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR OR HIS RELATIVES 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 MIND, 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/hppa/sys/sigsuspend.S b/lib/libc/arch/hppa/sys/sigsuspend.S
index 4cf34ec6b32..9853ccbb196 100644
--- a/lib/libc/arch/hppa/sys/sigsuspend.S
+++ b/lib/libc/arch/hppa/sys/sigsuspend.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: sigsuspend.S,v 1.10 2006/01/05 22:13:55 kettenis Exp $ */
+/* $OpenBSD: sigsuspend.S,v 1.11 2016/05/07 19:05:21 guenther Exp $ */
/*
* Copyright (c) 1999 Michael Shalayeff
@@ -28,11 +28,11 @@
#include "SYS.h"
-SYSENTRY(sigsuspend)
+SYSENTRY_HIDDEN(sigsuspend)
ldw 0(arg0), arg0
stw arg0, HPPA_FRAME_ARG(0)(sp)
SYSCALL(sigsuspend)
-SYSEXIT(sigsuspend)
+SYSEXIT_HIDDEN(sigsuspend)
.end
diff --git a/lib/libc/arch/hppa64/SYS.h b/lib/libc/arch/hppa64/SYS.h
index f8afd9b22b8..fd1a5f1af43 100644
--- a/lib/libc/arch/hppa64/SYS.h
+++ b/lib/libc/arch/hppa64/SYS.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: SYS.h,v 1.10 2015/09/10 13:29:09 guenther Exp $ */
+/* $OpenBSD: SYS.h,v 1.11 2016/05/07 19:05:21 guenther Exp $ */
/*
* Copyright (c) 1998-2002 Michael Shalayeff
@@ -33,6 +33,9 @@
#include <machine/vmparam.h>
#undef _LOCORE
+/* offsetof(struct tib, tib_errno) - offsetof(struct tib, __tib_tcb) */
+#define TCB_OFFSET_ERRNO -12
+
/*
* We define a hidden alias with the prefix "_libc_" for each global symbol
* that may be used internally. By referencing _libc_x instead of x, other
@@ -84,10 +87,15 @@ LEAF_ENTRY(__CONCAT(_thread_sys_,x))
depd %r0, 31, 32, %r1 !\
ble 4(%sr7, %r1) !\
ldi __CONCAT(SYS_,x), %r1 !\
- .import __cerror, code !\
- sub,*= %r0, %r1, %r0 !\
- b,l __cerror, %rp !\
- ldd HPPA_FRAME_RP(%sr0,%sp), %rp
+ comb,==,tr %r0, %ret0, 1f !\
+ ldd HPPA_FRAME_RP(%sr0,%sp), %rp !\
+ /* set errno */ \
+ mfctl %cr27, %r1 !\
+ stw %t1, TCB_OFFSET_ERRNO(%r1) !\
+ bv %r0(%rp) !\
+ ldi -1, %ret0 !\
+1:
+
#define PSEUDO(x,y) !\
SYSENTRY(x) !\
diff --git a/lib/libc/arch/hppa64/sys/Ovfork.S b/lib/libc/arch/hppa64/sys/Ovfork.S
index de7cd713ad1..ca40cfef79b 100644
--- a/lib/libc/arch/hppa64/sys/Ovfork.S
+++ b/lib/libc/arch/hppa64/sys/Ovfork.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: Ovfork.S,v 1.5 2015/03/31 04:32:01 guenther Exp $ */
+/* $OpenBSD: Ovfork.S,v 1.6 2016/05/07 19:05:21 guenther Exp $ */
/*
* Copyright (c) 1999,2002 Michael Shalayeff
@@ -28,17 +28,20 @@
#include "SYS.h"
-SYSENTRY(vfork)
+SYSENTRY_HIDDEN(vfork)
.import errno, data
copy %rp, arg7
ldil L%SYSCALLGATE, %r1
ble 4(%sr7, %r1)
ldi __CONCAT(SYS_,vfork), arg4
- .import __cerror, code
- comb,<> %r0, arg4, __cerror
+ comb,==,tr %r0, arg4, 1f
copy arg7, %rp
- bv %r0(%rp)
+ /* set errno */
+ mfctl %cr27, %r1
+ stw %t1, TCB_OFFSET_ERRNO(%r1)
+ ldi -1, %ret0
+1: bv %r0(%rp)
nop
-SYSEXIT(vfork)
+SYSEXIT_HIDDEN(vfork)
.end
diff --git a/lib/libc/arch/hppa64/sys/cerror.S b/lib/libc/arch/hppa64/sys/cerror.S
deleted file mode 100644
index ab81d5ecffa..00000000000
--- a/lib/libc/arch/hppa64/sys/cerror.S
+++ /dev/null
@@ -1,48 +0,0 @@
-/* $OpenBSD: cerror.S,v 1.5 2012/08/22 17:19:34 pascal Exp $ */
-
-/*
- * Copyright (c) 2004 Michael Shalayeff
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR OR HIS RELATIVES 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 MIND, 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"
-
-WEAK_ALIAS(__cerror, ___cerror)
-
- .import errno, data
-ENTRY(___cerror,0)
-#ifdef __PIC__
- addil LT%errno, %dp
- ldd RT%errno(%r1), %r1
- stw %ret0, 0(%r1)
-#else
- ldil L%errno, %r1
- stw %ret0, R%errno(%r1)
-#endif
- ldi -1, %ret0
- bv %r0(%rp)
- ldi -1, %ret1
-EXIT(___cerror)
-
- .end
diff --git a/lib/libc/arch/hppa64/sys/fork.S b/lib/libc/arch/hppa64/sys/fork.S
deleted file mode 100644
index 7602c801601..00000000000
--- a/lib/libc/arch/hppa64/sys/fork.S
+++ /dev/null
@@ -1,32 +0,0 @@
-/* $OpenBSD: fork.S,v 1.6 2015/04/07 01:27:06 guenther Exp $ */
-
-/*
- * Copyright (c) 1999 Michael Shalayeff
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR OR HIS RELATIVES 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 MIND, 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/hppa64/sys/sigsuspend.S b/lib/libc/arch/hppa64/sys/sigsuspend.S
index a9c2aa19b50..468f49b6e58 100644
--- a/lib/libc/arch/hppa64/sys/sigsuspend.S
+++ b/lib/libc/arch/hppa64/sys/sigsuspend.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: sigsuspend.S,v 1.5 2011/08/16 18:58:45 kettenis Exp $ */
+/* $OpenBSD: sigsuspend.S,v 1.6 2016/05/07 19:05:21 guenther Exp $ */
/*
* Copyright (c) 1999 Michael Shalayeff
@@ -28,10 +28,10 @@
#include "SYS.h"
-SYSENTRY(sigsuspend)
+SYSENTRY_HIDDEN(sigsuspend)
ldw 0(%arg0), %arg0
SYSCALL(sigsuspend)
-SYSEXIT(sigsuspend)
+SYSEXIT_HIDDEN(sigsuspend)
.end
diff --git a/lib/libc/arch/i386/SYS.h b/lib/libc/arch/i386/SYS.h
index 7373a9796a9..59852a449a7 100644
--- a/lib/libc/arch/i386/SYS.h
+++ b/lib/libc/arch/i386/SYS.h
@@ -29,12 +29,13 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: SYS.h,v 1.24 2015/10/23 04:39:24 guenther Exp $
+ * $OpenBSD: SYS.h,v 1.25 2016/05/07 19:05:21 guenther Exp $
*/
#include <machine/asm.h>
#include <sys/syscall.h>
+#define TCB_OFFSET_ERRNO 16
/*
* We define a hidden alias with the prefix "_libc_" for each global symbol
@@ -70,9 +71,8 @@
/* Use both _thread_sys_{syscall} and [weak] {syscall}. */
#define SYSENTRY(x) \
- ENTRY(_thread_sys_ ## x); \
- .weak _C_LABEL(x); \
- _C_LABEL(x) = _C_LABEL(_thread_sys_ ## x)
+ ENTRY(_thread_sys_##x); \
+ WEAK_ALIAS(x, _thread_sys_##x)
#define SYSENTRY_HIDDEN(x) \
ENTRY(_thread_sys_ ## x)
#define __END_HIDDEN(x) END(_thread_sys_ ## x); \
@@ -84,8 +84,14 @@
movl $(SYS_ ## x),%eax; \
int $0x80
-#define CERROR _C_LABEL(__cerror)
-#define _CERROR _C_LABEL(___cerror)
+#define SET_ERRNO() \
+ movl %eax,%gs:(TCB_OFFSET_ERRNO); \
+ movl $-1, %eax; \
+ movl $-1, %edx /* for lseek */
+#define HANDLE_ERRNO() \
+ jnc,pt 99f; \
+ SET_ERRNO(); \
+ 99:
/* perform a syscall */
#define _SYSCALL_NOERROR(x,y) \
@@ -99,44 +105,21 @@
_SYSCALL_NOERROR(x,x)
/* perform a syscall, set errno */
-#ifdef __PIC__
#define _SYSCALL(x,y) \
.text; \
.align 2; \
- 2: PIC_PROLOGUE; \
- movl PIC_GOT(CERROR), %ecx; \
- PIC_EPILOGUE; \
- jmp *%ecx; \
_SYSCALL_NOERROR(x,y) \
- jc 2b
+ HANDLE_ERRNO()
#define _SYSCALL_HIDDEN(x,y) \
.text; \
.align 2; \
- 2: PIC_PROLOGUE; \
- movl PIC_GOT(CERROR), %ecx; \
- PIC_EPILOGUE; \
- jmp *%ecx; \
_SYSCALL_HIDDEN_NOERROR(x,y) \
- jc 2b
-#else
-#define _SYSCALL(x,y) \
- .text; \
- .align 2; \
- 2: \
- jmp PIC_PLT(CERROR); \
- _SYSCALL_NOERROR(x,y) \
- jc 2b
-#define _SYSCALL_HIDDEN(x,y) \
- .text; \
- .align 2; \
- 2: \
- jmp PIC_PLT(CERROR); \
- _SYSCALL_HIDDEN_NOERROR(x,y) \
- jc 2b
-#endif
+ HANDLE_ERRNO()
#define SYSCALL(x) \
_SYSCALL(x,x)
+#define SYSCALL_HIDDEN(x) \
+ _SYSCALL_HIDDEN(x,y)
/* perform a syscall, return */
#define PSEUDO_NOERROR(x,y) \
@@ -162,5 +145,3 @@
#define SYSCALL_END(x) __END(x)
#define SYSCALL_END_HIDDEN(x) \
__END_HIDDEN(x)
-
- .globl CERROR
diff --git a/lib/libc/arch/i386/sys/Ovfork.S b/lib/libc/arch/i386/sys/Ovfork.S
index 7068e0bd144..2c276186606 100644
--- a/lib/libc/arch/i386/sys/Ovfork.S
+++ b/lib/libc/arch/i386/sys/Ovfork.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: Ovfork.S,v 1.9 2015/09/05 06:22:47 guenther Exp $ */
+/* $OpenBSD: Ovfork.S,v 1.10 2016/05/07 19:05:21 guenther Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
@@ -33,21 +33,10 @@
#include "SYS.h"
-SYSENTRY(vfork)
+SYSENTRY_HIDDEN(vfork)
popl %ecx /* my rta into ecx */
movl $(SYS_vfork),%eax
int $0x80
- jc 1f
+ HANDLE_ERRNO()
jmp *%ecx
-1:
-#ifdef __PIC__
- PIC_PROLOGUE
- movl PIC_GOT(_C_LABEL(errno)),%edx
- PIC_EPILOGUE
- movl %eax,(%edx)
-#else
- movl %eax,_C_LABEL(errno)
-#endif
- movl $-1,%eax
- jmp *%ecx
-SYSCALL_END(vfork)
+SYSCALL_END_HIDDEN(vfork)
diff --git a/lib/libc/arch/i386/sys/brk.S b/lib/libc/arch/i386/sys/brk.S
index f918b4379e7..05afec06b11 100644
--- a/lib/libc/arch/i386/sys/brk.S
+++ b/lib/libc/arch/i386/sys/brk.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: brk.S,v 1.11 2015/09/05 06:22:47 guenther Exp $ */
+/* $OpenBSD: brk.S,v 1.12 2016/05/07 19:05:21 guenther Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
@@ -64,12 +64,6 @@ ENTRY(brk)
PIC_EPILOGUE
xorl %eax,%eax
movl %ecx,(%edx)
- ret
-2:
- PIC_PROLOGUE
- movl PIC_GOT(CERROR),%ecx # set up GOT addressing
- PIC_EPILOGUE
- jmp *%ecx
#else
@@ -84,8 +78,9 @@ ENTRY(brk)
jc 2f
xorl %eax,%eax
movl %ecx,__curbrk
+#endif
ret
2:
- jmp CERROR
-#endif
+ SET_ERRNO()
+ ret
END(brk)
diff --git a/lib/libc/arch/i386/sys/cerror.S b/lib/libc/arch/i386/sys/cerror.S
deleted file mode 100644
index e30a46e1aa6..00000000000
--- a/lib/libc/arch/i386/sys/cerror.S
+++ /dev/null
@@ -1,52 +0,0 @@
-/* $OpenBSD: cerror.S,v 1.10 2015/09/05 06:22:47 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"
-
- .globl _C_LABEL(errno)
-
-WEAK_ALIAS(CERROR, _CERROR)
-
-_ENTRY(_CERROR)
-#ifdef __PIC__
- PIC_PROLOGUE
- movl PIC_GOT(_C_LABEL(errno)),%ecx
- PIC_EPILOGUE
- movl %eax,(%ecx)
-#else
- movl %eax,_C_LABEL(errno)
-#endif
- movl $-1,%eax
- movl $-1,%edx
- ret
-END(_CERROR)
diff --git a/lib/libc/arch/i386/sys/fork.S b/lib/libc/arch/i386/sys/fork.S
deleted file mode 100644
index 1e750d3f0d6..00000000000
--- a/lib/libc/arch/i386/sys/fork.S
+++ /dev/null
@@ -1,37 +0,0 @@
-/* $OpenBSD: fork.S,v 1.6 2015/04/07 01:27:06 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"
-
-RSYSCALL_HIDDEN(fork)
-WEAK_ALIAS(_thread_fork,_thread_sys_fork)
diff --git a/lib/libc/arch/i386/sys/sbrk.S b/lib/libc/arch/i386/sys/sbrk.S
index 6c0da58b8a2..a22cb1f895d 100644
--- a/lib/libc/arch/i386/sys/sbrk.S
+++ b/lib/libc/arch/i386/sys/sbrk.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: sbrk.S,v 1.11 2015/09/05 06:22:47 guenther Exp $ */
+/* $OpenBSD: sbrk.S,v 1.12 2016/05/07 19:05:21 guenther Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
@@ -61,12 +61,6 @@ ENTRY(sbrk)
PIC_EPILOGUE
movl (%edx),%eax
addl %ecx,(%edx)
- ret
-2:
- PIC_PROLOGUE
- movl PIC_GOT(CERROR), %ecx
- PIC_EPILOGUE
- jmp *%ecx
#else
@@ -78,8 +72,9 @@ ENTRY(sbrk)
jc 2f
movl __curbrk,%eax
addl %ecx,__curbrk
+#endif
ret
2:
- jmp CERROR
-#endif
+ SET_ERRNO()
+ ret
END(sbrk)
diff --git a/lib/libc/arch/i386/sys/sigprocmask.S b/lib/libc/arch/i386/sys/sigprocmask.S
index 2f7b31e2de9..489eabcbf11 100644
--- a/lib/libc/arch/i386/sys/sigprocmask.S
+++ b/lib/libc/arch/i386/sys/sigprocmask.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: sigprocmask.S,v 1.11 2015/10/23 04:39:24 guenther Exp $ */
+/* $OpenBSD: sigprocmask.S,v 1.12 2016/05/07 19:05:21 guenther Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
@@ -53,13 +53,6 @@ out:
xorl %eax,%eax
ret
1:
-#ifdef __PIC__
- PIC_PROLOGUE
- movl PIC_GOT(CERROR), %ecx
- PIC_EPILOGUE
- jmp *%ecx
-
-#else
- jmp CERROR
-#endif
+ SET_ERRNO()
+ ret
SYSCALL_END_HIDDEN(sigprocmask)
diff --git a/lib/libc/arch/i386/sys/sigsuspend.S b/lib/libc/arch/i386/sys/sigsuspend.S
index cc9b1dda885..88a08c7a1c4 100644
--- a/lib/libc/arch/i386/sys/sigsuspend.S
+++ b/lib/libc/arch/i386/sys/sigsuspend.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: sigsuspend.S,v 1.9 2015/09/05 06:22:47 guenther Exp $ */
+/* $OpenBSD: sigsuspend.S,v 1.10 2016/05/07 19:05:21 guenther Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
@@ -33,22 +33,12 @@
#include "SYS.h"
-SYSENTRY(sigsuspend)
+SYSENTRY_HIDDEN(sigsuspend)
movl 4(%esp),%eax # fetch mask arg
movl (%eax),%eax # indirect to mask arg
movl %eax,4(%esp)
movl $(SYS_sigsuspend),%eax
int $0x80
- jc 1f
- xorl %eax,%eax # shouldn t happen
+ SET_ERRNO()
ret
-1:
-#ifdef __PIC__
- PIC_PROLOGUE
- movl PIC_GOT(CERROR), %ecx
- PIC_EPILOGUE
- jmp *%ecx
-#else
- jmp CERROR
-#endif
-SYSCALL_END(sigsuspend)
+SYSCALL_END_HIDDEN(sigsuspend)
diff --git a/lib/libc/arch/i386/sys/syscall.S b/lib/libc/arch/i386/sys/syscall.S
index 315c1624536..fa2dd652c52 100644
--- a/lib/libc/arch/i386/sys/syscall.S
+++ b/lib/libc/arch/i386/sys/syscall.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: syscall.S,v 1.10 2015/09/05 06:22:47 guenther Exp $ */
+/* $OpenBSD: syscall.S,v 1.11 2016/05/07 19:05:21 guenther Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
@@ -39,15 +39,6 @@ SYSENTRY(syscall)
push %ecx
int $0x80
push %ecx /* Keep stack frame consistent */
- jc 1f
+ HANDLE_ERRNO()
ret
-1:
-#ifdef __PIC__
- PIC_PROLOGUE
- movl PIC_GOT(CERROR), %ecx
- PIC_EPILOGUE
- jmp *%ecx
-#else
- jmp CERROR
-#endif
SYSCALL_END(syscall)
diff --git a/lib/libc/arch/i386/sys/tfork_thread.S b/lib/libc/arch/i386/sys/tfork_thread.S
index 2f07845ea68..97a515f0ae8 100644
--- a/lib/libc/arch/i386/sys/tfork_thread.S
+++ b/lib/libc/arch/i386/sys/tfork_thread.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: tfork_thread.S,v 1.7 2015/09/05 06:22:47 guenther Exp $ */
+/* $OpenBSD: tfork_thread.S,v 1.8 2016/05/07 19:05:21 guenther Exp $ */
/*-
* Copyright (c) 2000 Peter Wemm <peter@FreeBSD.org>
* All rights reserved.
@@ -112,12 +112,6 @@ ENTRY(__tfork_thread)
popl %esi
movl %ebp, %esp
popl %ebp
-#ifdef __PIC__
- PIC_PROLOGUE
- movl PIC_GOT(CERROR), %ecx
- PIC_EPILOGUE
- jmp *%ecx
-#else
- jmp CERROR
-#endif
+ HANDLE_ERRNO()
+ ret
END(__tfork_thread)
diff --git a/lib/libc/arch/m88k/Makefile.inc b/lib/libc/arch/m88k/Makefile.inc
index 60b23aad174..ed176e74648 100644
--- a/lib/libc/arch/m88k/Makefile.inc
+++ b/lib/libc/arch/m88k/Makefile.inc
@@ -1 +1,2 @@
-# $OpenBSD: Makefile.inc,v 1.3 2014/06/09 20:47:11 miod Exp $
+# $OpenBSD: Makefile.inc,v 1.4 2016/05/07 19:05:21 guenther Exp $
+CERROR= cerror.S
diff --git a/lib/libc/arch/m88k/sys/Ovfork.S b/lib/libc/arch/m88k/sys/Ovfork.S
index 916f563de92..65de6ed8b52 100644
--- a/lib/libc/arch/m88k/sys/Ovfork.S
+++ b/lib/libc/arch/m88k/sys/Ovfork.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: Ovfork.S,v 1.10 2015/03/31 04:32:02 guenther Exp $ */
+/* $OpenBSD: Ovfork.S,v 1.11 2016/05/07 19:05:21 guenther Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -35,4 +35,4 @@
#include "SYS.h"
-RSYSCALL(vfork)
+RSYSCALL_HIDDEN(vfork)
diff --git a/lib/libc/arch/m88k/sys/cerror.S b/lib/libc/arch/m88k/sys/cerror.S
index 933f2400067..5fa6765c740 100644
--- a/lib/libc/arch/m88k/sys/cerror.S
+++ b/lib/libc/arch/m88k/sys/cerror.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: cerror.S,v 1.12 2013/01/11 21:23:24 miod Exp $ */
+/* $OpenBSD: cerror.S,v 1.13 2016/05/07 19:05:21 guenther Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -33,28 +33,40 @@
* SUCH DAMAGE.
*/
-#include "SYS.h"
+#include "DEFS.h"
-WEAK_ALIAS(__cerror,___cerror)
+ .globl _C_LABEL(__errno)
- .globl _C_LABEL(errno)
-ENTRY(___cerror)
-#ifdef __PIC__
- PIC_SAVE(%r9)
- PIC_SETUP
-#endif
+/*
+ * long long __cerror(register_t errcode)
+ * stores `errcode' into the current thread's errno variable, and returns
+ * -1LL.
+ */
+
+ASENTRY(__cerror)
+ /* if %r26 has been initialized, don't bother setting up a frame */
+ bcnd ne0, %r26, has_r26
+
+ subu %r31,%r31,16
+ st %r25,%r0,%r31
+ st %r1,%r31,4
#ifdef __PIC__
- PIC_STORE(%r2,_C_LABEL(errno))
+ bsr.n _C_LABEL(__errno)#plt
#else
- or.u %r4,%r0,%hi16(_C_LABEL(errno))
- st %r2,%r4,%lo16(_C_LABEL(errno))
+ bsr.n _C_LABEL(__errno)
#endif
+ or %r25,%r0,%r2
+ or %r26,%r0,%r2 /* save errno ptr */
+ or %r2,%r0,%r25 /* and restore errno value */
-#ifdef __PIC__
- PIC_RESTORE(%r9)
-#endif
- sub %r2,%r0,0x1
+ ld %r1,%r31,4
+ ld %r25,%r0,%r31
+ addu %r31,%r31,16
+
+has_r26:
+ st %r2,%r0,%r26
+ subu %r2,%r0,1
jmp.n %r1
- sub %r3,%r0,0x1
-END(___cerror)
+ or %r3, %r0, %r2
+END(__cerror)
diff --git a/lib/libc/arch/m88k/sys/fork.S b/lib/libc/arch/m88k/sys/fork.S
deleted file mode 100644
index 2c664f74fd2..00000000000
--- a/lib/libc/arch/m88k/sys/fork.S
+++ /dev/null
@@ -1,39 +0,0 @@
-/* $OpenBSD: fork.S,v 1.9 2015/04/07 01:27:06 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"
-
-RSYSCALL_HIDDEN(fork)
-WEAK_ALIAS(_thread_fork,_thread_sys_fork)
diff --git a/lib/libc/arch/m88k/sys/sigsuspend.S b/lib/libc/arch/m88k/sys/sigsuspend.S
index 7ba0e873353..847179c0845 100644
--- a/lib/libc/arch/m88k/sys/sigsuspend.S
+++ b/lib/libc/arch/m88k/sys/sigsuspend.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: sigsuspend.S,v 1.12 2015/09/10 13:29:09 guenther Exp $ */
+/* $OpenBSD: sigsuspend.S,v 1.13 2016/05/07 19:05:21 guenther Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -42,11 +42,11 @@
* sigset_t != sizeof int.
*/
-SYSENTRY(sigsuspend)
+SYSENTRY_HIDDEN(sigsuspend)
ld %r2,%r2,0 /* dereference the pointer mask */
or %r13,%r0,SYS_sigsuspend
tb0 0,%r0,450
br CERROR
jmp.n %r1
or %r2,%r0,0
-SYSCALL_END(sigsuspend)
+SYSCALL_END_HIDDEN(sigsuspend)
diff --git a/lib/libc/arch/mips64/Makefile.inc b/lib/libc/arch/mips64/Makefile.inc
index d8c4bff9a3e..e41f5ca03d1 100644
--- a/lib/libc/arch/mips64/Makefile.inc
+++ b/lib/libc/arch/mips64/Makefile.inc
@@ -1 +1,2 @@
-# $OpenBSD: Makefile.inc,v 1.2 2014/06/09 20:47:11 miod Exp $
+# $OpenBSD: Makefile.inc,v 1.3 2016/05/07 19:05:22 guenther Exp $
+CERROR= cerror.S
diff --git a/lib/libc/arch/mips64/SYS.h b/lib/libc/arch/mips64/SYS.h
index bc4bcfa9f45..0eae2a001cc 100644
--- a/lib/libc/arch/mips64/SYS.h
+++ b/lib/libc/arch/mips64/SYS.h
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: SYS.h,v 1.11 2015/10/23 04:39:24 guenther Exp $
+ * $OpenBSD: SYS.h,v 1.12 2016/05/07 19:05:22 guenther Exp $
*/
#include <sys/syscall.h>
@@ -60,8 +60,8 @@
#define END_WEAK(x) END_STRONG(x); .weak x
-#define CERROR _C_LABEL(__cerror)
-#define _CERROR _C_LABEL(___cerror)
+#define CERROR __cerror
+ .hidden CERROR
# define __ENTRY(p,x) ENTRY(p ## x)
diff --git a/lib/libc/arch/mips64/sys/Ovfork.S b/lib/libc/arch/mips64/sys/Ovfork.S
index 6c1896bb8e6..85962be2c7f 100644
--- a/lib/libc/arch/mips64/sys/Ovfork.S
+++ b/lib/libc/arch/mips64/sys/Ovfork.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: Ovfork.S,v 1.6 2015/03/31 04:32:02 guenther Exp $ */
+/* $OpenBSD: Ovfork.S,v 1.7 2016/05/07 19:05:22 guenther Exp $ */
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
@@ -33,4 +33,4 @@
#include "SYS.h"
-RSYSCALL(vfork)
+RSYSCALL_HIDDEN(vfork)
diff --git a/lib/libc/arch/mips64/sys/cerror.S b/lib/libc/arch/mips64/sys/cerror.S
index c6c5819fabd..b521bf8bc0f 100644
--- a/lib/libc/arch/mips64/sys/cerror.S
+++ b/lib/libc/arch/mips64/sys/cerror.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: cerror.S,v 1.6 2011/07/08 19:31:41 miod Exp $ */
+/* $OpenBSD: cerror.S,v 1.7 2016/05/07 19:05:22 guenther Exp $ */
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
@@ -33,20 +33,36 @@
#include "SYS.h"
-FRAMESZ= MKFSIZ(1,1)
+FRAMESZ= 4*REGSZ
+S0OFF= FRAMESZ-3*REGSZ
GPOFF= FRAMESZ-2*REGSZ
+RAOFF= FRAMESZ-1*REGSZ
-WEAK_ALIAS(CERROR, _CERROR)
+ .hidden _thread_cb
+ .hidden CERROR
- .globl _C_LABEL(errno)
-LEAF(_CERROR, FRAMESZ)
+NON_LEAF(CERROR, FRAMESZ, ra)
PTR_SUBU sp, FRAMESZ
- SETUP_GP64(GPOFF, _CERROR)
- .set noreorder
- sw v0, _C_LABEL(errno)
- li v0, -1
+#if !__PIC__ || !notyet
+ SETUP_GP64(GPOFF, CERROR)
+#endif
+ .set reorder
+ REG_S ra, RAOFF(sp)
+ REG_S s0, S0OFF(sp)
+
+ move s0, v0
+ dla v0, _thread_cb
+ ld t9, 0(v0)
+ jal t9
+
+ sw s0, 0(v0)
+
+ LI v0, -1
+ REG_L s0, S0OFF(sp)
+ REG_L ra, RAOFF(sp)
+#if !__PIC__ || !notyet
RESTORE_GP64
+#endif
PTR_ADDU sp, FRAMESZ
j ra
- li v1, -1
-END(_CERROR)
+END(CERROR)
diff --git a/lib/libc/arch/mips64/sys/fork.S b/lib/libc/arch/mips64/sys/fork.S
deleted file mode 100644
index be3b2851414..00000000000
--- a/lib/libc/arch/mips64/sys/fork.S
+++ /dev/null
@@ -1,37 +0,0 @@
-/* $OpenBSD: fork.S,v 1.7 2015/04/07 01:27:06 guenther 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 "SYS.h"
-
-RSYSCALL_HIDDEN(fork)
-WEAK_ALIAS(_thread_fork,_thread_sys_fork)
diff --git a/lib/libc/arch/mips64/sys/sigsuspend.S b/lib/libc/arch/mips64/sys/sigsuspend.S
index 8fec33adb6e..6c445f61037 100644
--- a/lib/libc/arch/mips64/sys/sigsuspend.S
+++ b/lib/libc/arch/mips64/sys/sigsuspend.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: sigsuspend.S,v 1.6 2015/10/23 04:39:24 guenther Exp $ */
+/* $OpenBSD: sigsuspend.S,v 1.7 2016/05/07 19:05:22 guenther Exp $ */
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
@@ -36,7 +36,7 @@
FRAMESZ= MKFSIZ(1,1)
GPOFF= FRAMESZ-2*REGSZ
-SYSLEAF(sigsuspend, FRAMESZ)
+SYSLEAF_HIDDEN(sigsuspend, FRAMESZ)
PTR_SUBU sp, FRAMESZ
SETUP_GP64(GPOFF, _HIDDEN(sigsuspend))
.set reorder
@@ -53,4 +53,4 @@ SYSLEAF(sigsuspend, FRAMESZ)
RESTORE_GP64
PTR_ADDU sp, FRAMESZ
jr t9
-SYSCALL_END(sigsuspend)
+SYSCALL_END_HIDDEN(sigsuspend)
diff --git a/lib/libc/arch/powerpc/Makefile.inc b/lib/libc/arch/powerpc/Makefile.inc
index 7e94acff690..74ee41bf416 100644
--- a/lib/libc/arch/powerpc/Makefile.inc
+++ b/lib/libc/arch/powerpc/Makefile.inc
@@ -1 +1,2 @@
-# $OpenBSD: Makefile.inc,v 1.4 2014/06/09 20:47:11 miod Exp $
+# $OpenBSD: Makefile.inc,v 1.5 2016/05/07 19:05:22 guenther Exp $
+CERROR= cerror.S
diff --git a/lib/libc/arch/powerpc/SYS.h b/lib/libc/arch/powerpc/SYS.h
index 61036697b71..05fe72401fa 100644
--- a/lib/libc/arch/powerpc/SYS.h
+++ b/lib/libc/arch/powerpc/SYS.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: SYS.h,v 1.20 2015/10/23 04:39:24 guenther Exp $ */
+/* $OpenBSD: SYS.h,v 1.21 2016/05/07 19:05:22 guenther Exp $ */
/*-
* Copyright (c) 1994
* Andrew Cagney. All rights reserved.
@@ -68,13 +68,13 @@
#define _CONCAT(x,y) x##y
-#define PSEUDO_PREFIX(p,x,y) .extern _ASM_LABEL(___cerror) ; \
+#define PSEUDO_PREFIX(p,x,y) .extern _ASM_LABEL(__cerror) ; \
ENTRY(p##x) \
li 0, SYS_##y ; \
/* sc */
#define PSEUDO_SUFFIX cmpwi 0, 0 ; \
beqlr+ ; \
- b _ASM_LABEL(___cerror)
+ b _ASM_LABEL(__cerror)
#define PSEUDO_NOERROR_SUFFIX blr
diff --git a/lib/libc/arch/powerpc/sys/Ovfork.S b/lib/libc/arch/powerpc/sys/Ovfork.S
index 09edfc32c9d..daaa26cff52 100644
--- a/lib/libc/arch/powerpc/sys/Ovfork.S
+++ b/lib/libc/arch/powerpc/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) 1996 Dale Rahn
@@ -27,4 +27,4 @@
#include "SYS.h"
-RSYSCALL(vfork)
+RSYSCALL_HIDDEN(vfork)
diff --git a/lib/libc/arch/powerpc/sys/brk.S b/lib/libc/arch/powerpc/sys/brk.S
index 91753f5afc1..77ea58769a0 100644
--- a/lib/libc/arch/powerpc/sys/brk.S
+++ b/lib/libc/arch/powerpc/sys/brk.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: brk.S,v 1.11 2015/09/05 06:22:47 guenther Exp $ */
+/* $OpenBSD: brk.S,v 1.12 2016/05/07 19:05:22 guenther Exp $ */
/*
* Copyright (c) 1996 Dale Rahn
@@ -66,7 +66,7 @@ PSEUDO_PREFIX(,brk,break)
/* check for error */
cmpwi 0, 0
beq+ .L_brk_ok /* OK so this is stupid but I haven't read b */
- b _ASM_LABEL(___cerror)
+ b _ASM_LABEL(__cerror)
/* update, __curbrk and return */
.L_brk_ok:
diff --git a/lib/libc/arch/powerpc/sys/cerror.S b/lib/libc/arch/powerpc/sys/cerror.S
index 5dad24e0962..bd5b6a0edf5 100644
--- a/lib/libc/arch/powerpc/sys/cerror.S
+++ b/lib/libc/arch/powerpc/sys/cerror.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: cerror.S,v 1.12 2015/09/09 08:24:12 kettenis Exp $ */
+/* $OpenBSD: cerror.S,v 1.13 2016/05/07 19:05:22 guenther Exp $ */
/*
* Copyright (c) 1996 Dale Rahn
@@ -30,11 +30,10 @@
#define ERRNOPTR_OFFSET 16
-WEAK_ALIAS(__cerror, ___cerror)
-
.text
- .protected _ASM_LABEL(___cerror)
-ASENTRY(___cerror)
+ .hidden _ASM_LABEL(__cerror)
+ .hidden _ASM_LABEL(_HIDDEN(__errno))
+ASENTRY(__cerror)
stwu 1, -16(1) /* follow the SVR4 ABI */
mflr 3 /* error value is in r0, use r3 */
stw 3, 20(1)
@@ -47,7 +46,7 @@ ASENTRY(___cerror)
addi 30, 30, _GLOBAL_OFFSET_TABLE_-1b@l
#endif
mr 31, 0
- bl PIC_PLT(__errno)
+ bl _ASM_LABEL(_HIDDEN(__errno))
stw 31, 0(3)
#ifdef __PIC__
lwz 30, 8(1)
@@ -59,4 +58,4 @@ ASENTRY(___cerror)
li 3, -1
li 4, -1
blr
-END(___cerror)
+END(__cerror)
diff --git a/lib/libc/arch/powerpc/sys/fork.S b/lib/libc/arch/powerpc/sys/fork.S
deleted file mode 100644
index ace55a4a4d1..00000000000
--- a/lib/libc/arch/powerpc/sys/fork.S
+++ /dev/null
@@ -1,33 +0,0 @@
-/* $OpenBSD: fork.S,v 1.3 2015/04/07 01:27:06 guenther Exp $ */
-
-/*
- * Copyright (c) 1996 Dale Rahn
- *
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
- */
-
-/* pid = fork() */
-
-#include "SYS.h"
-
-RSYSCALL_HIDDEN(fork)
-WEAK_ALIAS(_thread_fork,_thread_sys_fork)
diff --git a/lib/libc/arch/powerpc/sys/sbrk.S b/lib/libc/arch/powerpc/sys/sbrk.S
index 7303bc58fbf..36016f63055 100644
--- a/lib/libc/arch/powerpc/sys/sbrk.S
+++ b/lib/libc/arch/powerpc/sys/sbrk.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: sbrk.S,v 1.10 2015/09/05 06:22:47 guenther Exp $ */
+/* $OpenBSD: sbrk.S,v 1.11 2016/05/07 19:05:22 guenther Exp $ */
/*
* Copyright (c) 1996 Dale Rahn
@@ -63,7 +63,7 @@ PSEUDO_PREFIX(,sbrk,break)
/* check for error */
cmpwi 0, 0
beq+ .L_sbrk_ok
- b _ASM_LABEL(___cerror)
+ b _ASM_LABEL(__cerror)
/* update, __curbrk and return */
.L_sbrk_ok:
diff --git a/lib/libc/arch/powerpc/sys/sigprocmask.S b/lib/libc/arch/powerpc/sys/sigprocmask.S
index 2d43827bb82..373685891f4 100644
--- a/lib/libc/arch/powerpc/sys/sigprocmask.S
+++ b/lib/libc/arch/powerpc/sys/sigprocmask.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: sigprocmask.S,v 1.10 2015/10/23 04:39:24 guenther Exp $ */
+/* $OpenBSD: sigprocmask.S,v 1.11 2016/05/07 19:05:22 guenther Exp $ */
/*
* Copyright (c) 1996 Dale Rahn
@@ -49,7 +49,7 @@ PREFIX_HIDDEN(sigprocmask)
/* didnt work? */
cmpwi 0, 0
beq+ .L_sigprocmask_ok
- b _ASM_LABEL(___cerror)
+ b _ASM_LABEL(__cerror)
.L_sigprocmask_ok:
lwz 5, 12(1)
diff --git a/lib/libc/arch/powerpc/sys/sigsuspend.S b/lib/libc/arch/powerpc/sys/sigsuspend.S
index cab1d4efe32..cbdd4ca971e 100644
--- a/lib/libc/arch/powerpc/sys/sigsuspend.S
+++ b/lib/libc/arch/powerpc/sys/sigsuspend.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: sigsuspend.S,v 1.4 2015/09/05 20:06:04 guenther Exp $ */
+/* $OpenBSD: sigsuspend.S,v 1.5 2016/05/07 19:05:22 guenther Exp $ */
/*
* Copyright (c) 1996 Dale Rahn
@@ -30,8 +30,8 @@
#include "SYS.h"
.text
-PREFIX(sigsuspend)
+PREFIX_HIDDEN(sigsuspend)
lwz 3, 0(3) /* load the mask */
sc
PSEUDO_SUFFIX
-SYSCALL_END(sigsuspend)
+SYSCALL_END_HIDDEN(sigsuspend)
diff --git a/lib/libc/arch/powerpc/sys/tfork_thread.S b/lib/libc/arch/powerpc/sys/tfork_thread.S
index 6c154b8a22b..a59d22051c8 100644
--- a/lib/libc/arch/powerpc/sys/tfork_thread.S
+++ b/lib/libc/arch/powerpc/sys/tfork_thread.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: tfork_thread.S,v 1.5 2015/09/05 06:22:47 guenther Exp $ */
+/* $OpenBSD: tfork_thread.S,v 1.6 2016/05/07 19:05:22 guenther Exp $ */
/*
* Copyright (c) 2005 Tim Wiess <tim@nop.cx>
@@ -46,5 +46,5 @@ ENTRY(__tfork_thread)
1:
li %r3, -1
2:
- b _C_LABEL(___cerror)
+ b _C_LABEL(__cerror)
END(__tfork_thread)
diff --git a/lib/libc/arch/sh/Makefile.inc b/lib/libc/arch/sh/Makefile.inc
index 69a13eed486..74ee41bf416 100644
--- a/lib/libc/arch/sh/Makefile.inc
+++ b/lib/libc/arch/sh/Makefile.inc
@@ -1 +1,2 @@
-# $OpenBSD: Makefile.inc,v 1.4 2007/03/02 06:11:54 miod Exp $
+# $OpenBSD: Makefile.inc,v 1.5 2016/05/07 19:05:22 guenther Exp $
+CERROR= cerror.S
diff --git a/lib/libc/arch/sh/SYS.h b/lib/libc/arch/sh/SYS.h
index c3b95350399..5458eee62d8 100644
--- a/lib/libc/arch/sh/SYS.h
+++ b/lib/libc/arch/sh/SYS.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: SYS.h,v 1.9 2015/10/23 04:39:24 guenther Exp $ */
+/* $OpenBSD: SYS.h,v 1.10 2016/05/07 19:05:22 guenther Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
@@ -85,7 +85,6 @@
904:
#define CERROR _C_LABEL(__cerror)
-#define _CERROR _C_LABEL(___cerror)
#define _SYSCALL_NOERROR(x,y) \
SYSENTRY(x); \
diff --git a/lib/libc/arch/sh/sys/Ovfork.S b/lib/libc/arch/sh/sys/Ovfork.S
index a8d7d5e442e..ce21487d807 100644
--- a/lib/libc/arch/sh/sys/Ovfork.S
+++ b/lib/libc/arch/sh/sys/Ovfork.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: Ovfork.S,v 1.2 2015/03/31 04:32:02 guenther Exp $ */
+/* $OpenBSD: Ovfork.S,v 1.3 2016/05/07 19:05:22 guenther Exp $ */
/* $NetBSD: Ovfork.S,v 1.5 2003/08/07 16:42:20 agc Exp $ */
/*-
@@ -37,4 +37,4 @@
#include "SYS.h"
-RSYSCALL(vfork)
+RSYSCALL_HIDDEN(vfork)
diff --git a/lib/libc/arch/sh/sys/cerror.S b/lib/libc/arch/sh/sys/cerror.S
index 0740e7bb558..92e365571ff 100644
--- a/lib/libc/arch/sh/sys/cerror.S
+++ b/lib/libc/arch/sh/sys/cerror.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: cerror.S,v 1.5 2015/09/10 13:29:09 guenther Exp $ */
+/* $OpenBSD: cerror.S,v 1.6 2016/05/07 19:05:22 guenther Exp $ */
/* $NetBSD: cerror.S,v 1.10 2006/01/06 05:14:39 uwe Exp $ */
/*-
@@ -37,29 +37,22 @@
#include "SYS.h"
-WEAK_ALIAS(CERROR, _CERROR)
-
-ASENTRY(_CERROR)
-#ifdef __PIC__
- mova L_GOT, r0
- mov.l L_GOT, r1
- add r0, r1
- mov.l L_errno, r0
- mov.l @(r0, r1), r1
- mov.l r4, @r1
-#else
- mov.l L_errno, r1
- mov.l r4, @r1
-#endif
- mov #-1, r0
+ASENTRY(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, r1
+ mov #-1, r0
.align 2
-#ifdef __PIC__
-L_GOT: .long _GLOBAL_OFFSET_TABLE_
-L_errno: .long _C_LABEL(errno)@GOT
-#else
-L_errno: .long _C_LABEL(errno)
-#endif
- SET_ENTRY_SIZE(_CERROR)
+.L_got: PIC_GOT_DATUM
+.L___errno: CALL_DATUM(_C_LABEL(__errno), 1b)
+ SET_ASENTRY_SIZE(CERROR)
+
diff --git a/lib/libc/arch/sh/sys/fork.S b/lib/libc/arch/sh/sys/fork.S
deleted file mode 100644
index 4ee5a0442df..00000000000
--- a/lib/libc/arch/sh/sys/fork.S
+++ /dev/null
@@ -1,41 +0,0 @@
-/* $OpenBSD: fork.S,v 1.4 2015/04/07 01:27:07 guenther Exp $ */
-/* $NetBSD: fork.S,v 1.10 2006/01/06 05:11:29 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: @(#)fork.s 5.1 (Berkeley) 4/23/90
- */
-
-#include "SYS.h"
-
-RSYSCALL_HIDDEN(fork)
-WEAK_ALIAS(_thread_fork,_thread_sys_fork)
diff --git a/lib/libc/arch/sh/sys/sigsuspend.S b/lib/libc/arch/sh/sys/sigsuspend.S
index 2b1401bbcb2..f8aca89650d 100644
--- a/lib/libc/arch/sh/sys/sigsuspend.S
+++ b/lib/libc/arch/sh/sys/sigsuspend.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: sigsuspend.S,v 1.2 2015/09/10 13:29:09 guenther Exp $ */
+/* $OpenBSD: sigsuspend.S,v 1.3 2016/05/07 19:05:22 guenther Exp $ */
/* $NetBSD: sigsuspend.S,v 1.5 2003/08/07 16:42:21 agc Exp $ */
/*-
@@ -37,7 +37,7 @@
#include "SYS.h"
-SYSENTRY(sigsuspend)
+SYSENTRY_HIDDEN(sigsuspend)
mov r4, r0 /* fetch mask arg */
mov.l @r0, r0 /* indirect to mask arg */
mov r0, r4
@@ -53,4 +53,4 @@ SYSENTRY(sigsuspend)
.align 2
LSYS_sigsuspend:
.long SYS_sigsuspend
-SYSCALL_END(sigsuspend)
+SYSCALL_END_HIDDEN(sigsuspend)
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)
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)