shithub: mc

ref: 34f2230c4a505f3b94bc33ed07f0839fe66a0e93
dir: /lib/thread/exit+openbsd-x64.s/

View raw version
/*
const thread.exit	: (stacksz : std.size -> void)
*/
.globl thread$exit
thread$exit:
	/* 
	  Because OpenBSD wants a valid stack whenever
	  we enter the kernel, we need to toss a preallocated
	  stack pointer into %rsp.
	 */
	movq	thread$exitstk,%rsp

	/* munmap(base, size) */
	movq	$73,%rax	/* munmap */
	movq	%fs:0x08,%rdi	/* base */
	movq	%fs:0x10,%rsi	/* stksz */
	syscall

	/* __threxit(0) */
	movq	$302,%rax	/* exit */
	xorq	%rdi,%rdi	/* 0 */
	syscall