[uClibc-cvs] svn commit: trunk/uClibc/libc/sysdeps/linux/x86_64

vapier at uclibc.org vapier at uclibc.org
Wed Jun 29 00:56:10 UTC 2005


Author: vapier
Date: 2005-06-28 18:56:09 -0600 (Tue, 28 Jun 2005)
New Revision: 10619

Log:
add syscall error handling with jockes simple errno setting solution

Added:
   trunk/uClibc/libc/sysdeps/linux/x86_64/__syscall_error.c

Modified:
   trunk/uClibc/libc/sysdeps/linux/x86_64/clone.S
   trunk/uClibc/libc/sysdeps/linux/x86_64/syscall.S
   trunk/uClibc/libc/sysdeps/linux/x86_64/vfork.S


Changeset:
Added: trunk/uClibc/libc/sysdeps/linux/x86_64/__syscall_error.c
===================================================================
--- trunk/uClibc/libc/sysdeps/linux/x86_64/__syscall_error.c	2005-06-29 00:55:04 UTC (rev 10618)
+++ trunk/uClibc/libc/sysdeps/linux/x86_64/__syscall_error.c	2005-06-29 00:56:09 UTC (rev 10619)
@@ -0,0 +1,28 @@
+/* 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>
+
+/* 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;
+}

Modified: trunk/uClibc/libc/sysdeps/linux/x86_64/clone.S
===================================================================
--- trunk/uClibc/libc/sysdeps/linux/x86_64/clone.S	2005-06-29 00:55:04 UTC (rev 10618)
+++ trunk/uClibc/libc/sysdeps/linux/x86_64/clone.S	2005-06-29 00:56:09 UTC (rev 10619)
@@ -48,17 +48,17 @@
    r8:	thread pointer  */
 
 
-        .text
+.text
 .globl __clone;
 .type	__clone, at function
-.align 4;
+.align 4
 __clone:
 	/* Sanity check arguments.  */
 	movq	$-EINVAL,%rax
 	testq	%rdi,%rdi		/* no NULL function pointers */
-	jz	__syscall_error
+	jz	__error
 	testq	%rsi,%rsi		/* no NULL stack pointers */
-	jz	__syscall_error
+	jz	__error
 
 	/* Insert the argument onto the new stack.  */
 	subq	$16,%rsi
@@ -73,12 +73,12 @@
 	movq	%r8, %rdx
 	movq	%r9, %r8
 	movq	8(%rsp), %r10
-	movq	$__NR_clone,%rax
+	movq	__NR_clone,%rax
 
 	syscall
 
 	testq	%rax,%rax
-	jl	__syscall_error
+	jl	__error
 	jz	L(thread_start)
 
 L(pseudo_end):
@@ -110,7 +110,7 @@
 	movq	%rax, %rdi
 	call	HIDDEN_JUMPTARGET (_exit)
 
-	cfi_startproc;
-PSEUDO_END (BP_SYM (__clone))
+.size __clone,.-__clone
 
-weak_alias (BP_SYM (__clone), BP_SYM (clone))
+.weak clone
+	clone = __clone

Modified: trunk/uClibc/libc/sysdeps/linux/x86_64/syscall.S
===================================================================
--- trunk/uClibc/libc/sysdeps/linux/x86_64/syscall.S	2005-06-29 00:55:04 UTC (rev 10618)
+++ trunk/uClibc/libc/sysdeps/linux/x86_64/syscall.S	2005-06-29 00:56:09 UTC (rev 10619)
@@ -23,9 +23,10 @@
    We need to do some arg shifting, the syscall_number will be in
    rax.  */
 
-.globl syscall;
-.type	syscall, at function;
-.align 16;
+.text
+.globl syscall
+.type	syscall, at function
+.align 16
 syscall:
 	movq %rdi, %rax		/* Syscall number -> rax.  */
 	movq %rsi, %rdi		/* shift arg1 - arg5.  */
@@ -36,10 +37,10 @@
 	movq 8(%rsp),%r9	/* arg6 is on the stack.  */
 	syscall			/* Do the system call.  */
 	cmpq $-4095, %rax	/* Check %rax for error.  */
-	jae __syscall_error		/* Branch forward if it failed.  */
+	jae __error		/* Branch forward if it failed.  */
 	ret			/* Return to caller.  */
 
-__syscall_error:
-	/* TODO: implement this ! :D */
+__error:
+	jmp __syscall_error
 
-.size syscall,.-syscall;
+.size syscall,.-syscall

Modified: trunk/uClibc/libc/sysdeps/linux/x86_64/vfork.S
===================================================================
--- trunk/uClibc/libc/sysdeps/linux/x86_64/vfork.S	2005-06-29 00:55:04 UTC (rev 10618)
+++ trunk/uClibc/libc/sysdeps/linux/x86_64/vfork.S	2005-06-29 00:56:09 UTC (rev 10619)
@@ -18,15 +18,24 @@
 
 #define _ERRNO_H	1
 #include <bits/errno.h>
+#include <sys/syscall.h>
 
 /* Clone the calling process, but without copying the whole address space.
    The calling process is suspended until the new process exits or is
    replaced by a call to `execve'.  Return -1 for errors, 0 to the new process,
    and the process ID of the new process to the old process.  */
 
-.globl __vfork;
-.type	__vfork, at function;
-.align 16;
+#ifndef __NR_vfork
+#error wtf
+/* No vfork so use fork instead */
+.weak vfork ; vfork = __libc_fork
+
+#else
+
+.text
+.globl __vfork
+.type	__vfork, at function
+.align 16
 __vfork:
 
 	/* Pop the return PC value into RDI.  We need a register that
@@ -41,13 +50,17 @@
 	pushq	%rdi
 
 	cmpl	$-4095, %eax
-	jae __syscall_error		/* Branch forward if it failed.  */
+	jae __error		/* Branch forward if it failed.  */
 
 	/* Normal return.  */
 	ret
 
-__syscall_error:
-	/* TODO: implement this ! :D */
+__error:
+	jmp __syscall_error
 
-.size	 __vfork,.Lsize-__vfork
-.weak vfork ; vfork = __vfork
+.size __vfork,.-__vfork
+
+.weak vfork
+	vfork = __vfork
+
+#endif /* __NR_vfork */




More information about the uClibc-cvs mailing list