OSDN Git Service

import the __syscall_error trick for errno handling
authorMike Frysinger <vapier@gentoo.org>
Sat, 9 Jul 2005 00:57:49 +0000 (00:57 -0000)
committerMike Frysinger <vapier@gentoo.org>
Sat, 9 Jul 2005 00:57:49 +0000 (00:57 -0000)
libc/sysdeps/linux/sparc/Makefile
libc/sysdeps/linux/sparc/__syscall_error.c [new file with mode: 0644]
libc/sysdeps/linux/sparc/clone.S

index 5c91176..8a2549c 100644 (file)
@@ -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 (file)
index 0000000..de65a1f
--- /dev/null
@@ -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;
+}
index 1bd1056..7421ef6 100644 (file)
@@ -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