shithub: mc

Download patch

ref: e841ef7c45f5ed30368c5070d52e1cf5912a1a41
parent: 10a209f1937d161e1ff5409deb06253facff73a6
author: Ori Bernstein <ori@eigenstate.org>
date: Fri Aug 28 16:49:37 EDT 2015

Move to use libsys's fnclone.

    We had our own. We don't need it any more.

--- a/lib/thread/bld.proj
+++ b/lib/thread/bld.proj
@@ -1,6 +1,5 @@
 lib thread =
 	spawn+linux.myr
-	clone+linux-x64.s
 	atomic-impl+x64.s
 	atomic.myr
 ;;
--- a/lib/thread/clone+linux-x64.s
+++ /dev/null
@@ -1,27 +1,0 @@
-.globl thread$clone
-thread$clone:
-	pushq %r15
-	movq 16(%rsp),%r15
-	/* clone(flags, stack, ptid, tls, ctid, regs) */
-	movq $56,%rax	/* syscall num */
-	/* %rdi: flags */
-	/* %rsi: stack */
-	/* %rdx: ptid */
-	movq %rcx,%r10	/* tls */
-	/* %r8: ctid */
-	/* %r9: regs */
-	syscall
-	
-	/* fn() */
-	testl %eax,%eax
-	jnz parent
-	call *%r15
-	
-	/* exit(0) */
-	movq $60, %rax  /* exit */
-	movq $0, %rdi   /* arg: 0 */
-	syscall
-
-parent:
-	popq %r15
-	ret
--- a/lib/thread/spawn+linux.myr
+++ b/lib/thread/spawn+linux.myr
@@ -7,14 +7,6 @@
 	const spawn : (fn : (-> void) -> std.result(tid, byte[:]))
 ;;
 
-extern const clone	: ( flags : sys.cloneopt, \
-				stk : byte#, \
-				ptid : sys.pid#, \
-				tls : byte#, \
-				ctid : sys.pid#, \
-				ptreg : byte#, \
-				fn : (-> void) \
-				-> sys.pid)
 /* Holy shit flag mania. */
 const Thrflag = sys.Clonevm | sys.Clonefs | sys.Clonefiles  | \
 	sys.Clonesighand | sys.Clonethread |sys.Clonesysvsem | \
@@ -34,7 +26,7 @@
 		-> `std.Fail "couldn't get stack"
 	;;
 
-	ret = clone(Thrflag, stk, &tid, 0 castto(byte#), &ctid, 0 castto(byte#), fn) castto(tid)
+	ret = sys.fnclone(Thrflag, stk, &tid, 0 castto(byte#), &ctid, 0 castto(byte#), fn) castto(tid)
 	if ret < 0
 		std.put("errno={}\n", -ret)
 		-> `std.Fail "couldn't spawn thread"