diff options
author | Philip Guenthe <guenther@cvs.openbsd.org> | 2011-10-13 01:07:02 +0000 |
---|---|---|
committer | Philip Guenthe <guenther@cvs.openbsd.org> | 2011-10-13 01:07:02 +0000 |
commit | 0285fe51a0c38fac8b3f172671e1e4b3b697fab1 (patch) | |
tree | 7c30d60921de912eba5c4f552c95d11cc2943614 | |
parent | 2dab5b62e278e529431d17abfd16a8149a09d601 (diff) |
Convert rfork_thread() from int$80 to syscall.
Tune the asm slightly to avoid using the stack and use smaller instructions.
Pass threxit() a NULL pointer.
seemed okay to kettenis@
-rw-r--r-- | lib/librthread/arch/amd64/rfork_thread.S | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/lib/librthread/arch/amd64/rfork_thread.S b/lib/librthread/arch/amd64/rfork_thread.S index 26a6f9bcc56..636e60724f7 100644 --- a/lib/librthread/arch/amd64/rfork_thread.S +++ b/lib/librthread/arch/amd64/rfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: rfork_thread.S,v 1.3 2009/09/24 19:47:35 guenther Exp $ */ +/* $OpenBSD: rfork_thread.S,v 1.4 2011/10/13 01:07:01 guenther Exp $ */ /*- * Copyright (c) 2000 Peter Wemm <peter@FreeBSD.org> * Copyright (c) 2003 Alan L. Cox <alc@cs.rice.edu> @@ -48,16 +48,14 @@ __FBSDID("$FreeBSD: /repoman/r/ncvs/src/lib/libc/amd64/gen/rfork_thread.S,v 1.1 */ ENTRY(rfork_thread) - pushq %rbx - pushq %r12 - movq %rdx, %rbx - movq %rcx, %r12 + movq %rdx, %r8 + movq %rcx, %r9 /* * Prepare and execute the thread creation syscall */ - movq $SYS_rfork, %rax - int $0x80 + movl $SYS_rfork, %eax + syscall jb 2f /* @@ -65,33 +63,29 @@ ENTRY(rfork_thread) */ cmpl $0, %edx jnz 1f - popq %r12 - popq %rbx ret /* * If we are in the child (new thread), then * set-up the call to the internal subroutine. If it - * returns, then call __exit. + * returns, then call threxit. */ 1: movq %rsi, %rsp - movq %r12, %rdi - call *%rbx - movl %eax, %edi + movq %r9, %rdi + call *%r8 /* - * Exit system call + * Thread exit system call */ - movq $SYS_threxit, %rax - int $0x80 + movl $SYS_threxit, %eax + xorl %edi, %edi + syscall /* * Branch here if the thread creation fails: */ 2: - popq %r12 - popq %rbx #ifdef PIC movq PIC_GOT(CERROR), %rcx jmp *%rcx |