lib: c: add pthread implementation
This commit is contained in:
35
lib/libc/pthread/sys/x86_64/pthread_unmap_exit.S
Normal file
35
lib/libc/pthread/sys/x86_64/pthread_unmap_exit.S
Normal file
@@ -0,0 +1,35 @@
|
||||
.code64
|
||||
|
||||
#include "mango/syscall.h"
|
||||
|
||||
.global __pthread_unmap_exit
|
||||
.type __pthread_unmap_exit, @function
|
||||
|
||||
/*
|
||||
%rdi = (kern_handle_t)address_space
|
||||
%rsi = (void *)unmap_base
|
||||
%rdx = (size_t)unmap_length
|
||||
*/
|
||||
__pthread_unmap_exit:
|
||||
push %rbp
|
||||
mov %rsp, %rbp
|
||||
|
||||
/* save the address space handle for later */
|
||||
mov %rdi, %rbx
|
||||
|
||||
/* first, unmap the specified region */
|
||||
mov $SYS_ADDRESS_SPACE_UNMAP, %rax
|
||||
/* args are already in the correct registers */
|
||||
syscall
|
||||
|
||||
/* next, close the handle to the address space */
|
||||
mov $SYS_THREAD_EXIT, %rax
|
||||
mov %rbx, %rdi
|
||||
syscall
|
||||
|
||||
/* finally, stop the current thread */
|
||||
mov $SYS_THREAD_EXIT, %rax
|
||||
syscall
|
||||
|
||||
/* unreachable */
|
||||
ret
|
||||
Reference in New Issue
Block a user