summaryrefslogtreecommitdiff
path: root/libc/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'libc/sysdeps')
-rw-r--r--libc/sysdeps/linux/x86_64/__syscall_error.c5
-rw-r--r--libc/sysdeps/linux/x86_64/clone.S9
-rw-r--r--libc/sysdeps/linux/x86_64/syscall.S5
-rw-r--r--libc/sysdeps/linux/x86_64/vfork.S5
4 files changed, 8 insertions, 16 deletions
diff --git a/libc/sysdeps/linux/x86_64/__syscall_error.c b/libc/sysdeps/linux/x86_64/__syscall_error.c
index de65a1f39..d8cf84c2b 100644
--- a/libc/sysdeps/linux/x86_64/__syscall_error.c
+++ b/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;
}
diff --git a/libc/sysdeps/linux/x86_64/clone.S b/libc/sysdeps/linux/x86_64/clone.S
index 4a7e96500..0ae999722 100644
--- a/libc/sysdeps/linux/x86_64/clone.S
+++ b/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
diff --git a/libc/sysdeps/linux/x86_64/syscall.S b/libc/sysdeps/linux/x86_64/syscall.S
index f6273b75f..86306906a 100644
--- a/libc/sysdeps/linux/x86_64/syscall.S
+++ b/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
diff --git a/libc/sysdeps/linux/x86_64/vfork.S b/libc/sysdeps/linux/x86_64/vfork.S
index 5786058d2..996f1289e 100644
--- a/libc/sysdeps/linux/x86_64/vfork.S
+++ b/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 */