Browse Source

fix errno handling with some magical hacks

Mike Frysinger 19 years ago
parent
commit
bc9ff8040e

+ 3 - 2
libc/sysdeps/linux/x86_64/__syscall_error.c

@@ -22,8 +22,9 @@
 
 /* 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)
+int attribute_hidden __syscall_error(void)
 {
-	__set_errno(err_no);
+	register int err_no asm("%rax");
+	__set_errno(-err_no);
 	return -1;
 }

+ 3 - 6
libc/sysdeps/linux/x86_64/clone.S

@@ -57,9 +57,9 @@ __clone:
 	/* Sanity check arguments.  */
 	movq	$-EINVAL,%rax
 	testq	%rdi,%rdi		/* no NULL function pointers */
-	jz	__error
+	jz	__syscall_error
 	testq	%rsi,%rsi		/* no NULL stack pointers */
-	jz	__error
+	jz	__syscall_error
 
 	/* Insert the argument onto the new stack.  */
 	subq	$16,%rsi
@@ -79,7 +79,7 @@ __clone:
 	syscall
 
 	testq	%rax,%rax
-	jl	__error
+	jl	__syscall_error
 	jz	.Lthread_start
 
 .Lpseudo_end:
@@ -111,9 +111,6 @@ __clone:
 	movq	%rax, %rdi
 	call	_exit_internal
 
-__error:
-	jmp __syscall_error
-
 .size __clone,.-__clone
 
 .weak clone

+ 1 - 4
libc/sysdeps/linux/x86_64/syscall.S

@@ -37,10 +37,7 @@ syscall:
 	movq 8(%rsp),%r9	/* arg6 is on the stack.  */
 	syscall			/* Do the system call.  */
 	cmpq $-4095, %rax	/* Check %rax for error.  */
-	jae __error		/* Branch forward if it failed.  */
+	jae __syscall_error		/* Branch forward if it failed.  */
 	ret			/* Return to caller.  */
 
-__error:
-	jmp __syscall_error
-
 .size syscall,.-syscall

+ 1 - 4
libc/sysdeps/linux/x86_64/vfork.S

@@ -51,14 +51,11 @@ __vfork:
 	pushq	%rdi
 
 	cmpl	$-4095, %eax
-	jae __error		/* Branch forward if it failed.  */
+	jae __syscall_error		/* Branch forward if it failed.  */
 
 	/* Normal return.  */
 	ret
 
-__error:
-	jmp __syscall_error
-
 .size __vfork,.-__vfork
 
 #endif /* __NR_vfork */