summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2005-07-09 00:57:49 +0000
committerMike Frysinger <vapier@gentoo.org>2005-07-09 00:57:49 +0000
commit0f40e2b464119e3c36a0f35ee93cfadecade2cd7 (patch)
tree0bac8fbc688aa9dd8f641e99f8f56f050e16c9ae /libc
parentc7f096da1a44a7811f820ea7f888d616b7c3f5f7 (diff)
import the __syscall_error trick for errno handling
Diffstat (limited to 'libc')
-rw-r--r--libc/sysdeps/linux/sparc/Makefile2
-rw-r--r--libc/sysdeps/linux/sparc/__syscall_error.c29
-rw-r--r--libc/sysdeps/linux/sparc/clone.S15
3 files changed, 35 insertions, 11 deletions
diff --git a/libc/sysdeps/linux/sparc/Makefile b/libc/sysdeps/linux/sparc/Makefile
index 5c91176dd..8a2549cb2 100644
--- a/libc/sysdeps/linux/sparc/Makefile
+++ b/libc/sysdeps/linux/sparc/Makefile
@@ -27,7 +27,7 @@ SSRC=__longjmp.S fork.S vfork.S clone.S setjmp.S bsd-setjmp.S bsd-_setjmp.S \
urem.S udiv.S umul.S sdiv.S rem.S
SOBJS=$(patsubst %.S,%.o, $(SSRC))
-CSRC=brk.c
+CSRC=brk.c __syscall_error.c
COBJS=$(patsubst %.c,%.o, $(CSRC))
OBJS=$(SOBJS) $(MOBJ) $(COBJS)
diff --git a/libc/sysdeps/linux/sparc/__syscall_error.c b/libc/sysdeps/linux/sparc/__syscall_error.c
new file mode 100644
index 000000000..de65a1f39
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/__syscall_error.c
@@ -0,0 +1,29 @@
+/* Wrapper for setting errno.
+ Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <features.h>
+
+/* This routine is jumped to by all the syscall handlers, to stash
+ * an error number into errno. */
+int attribute_hidden __syscall_error(int err_no)
+{
+ __set_errno(err_no);
+ return -1;
+}
diff --git a/libc/sysdeps/linux/sparc/clone.S b/libc/sysdeps/linux/sparc/clone.S
index 1bd10561a..7421ef672 100644
--- a/libc/sysdeps/linux/sparc/clone.S
+++ b/libc/sysdeps/linux/sparc/clone.S
@@ -20,7 +20,6 @@
/* clone() is even more special than fork() as it mucks with stacks
and invokes a function in the right context after its all over. */
-#include <asm/errno.h>
#include <asm/unistd.h>
/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
@@ -35,27 +34,23 @@ __clone:
/* sanity check arguments */
tst %i0
- be .Lerror
+ be __error
orcc %i1,%g0,%o1
- be .Lerror
+ be __error
mov %i2,%o0
/* Do the system call */
set __NR_clone,%g1
ta 0x10
- bcs .Lerror
+ bcs __error
tst %o1
bne __thread_start
nop
ret
restore %o0,%g0,%o0
-.Lerror:
- call __errno_location
- or %g0,EINVAL,%i0
- st %i0,[%o0]
- ret
- restore %g0,-1,%o0
+__error:
+ jmp __syscall_error
.size __clone,.-__clone