Files
rosetta/lib/libc/pthread/thread/pthread_exit.c

32 lines
589 B
C
Raw Normal View History

2026-03-18 21:08:49 +00:00
#include "pthread.h"
#include <mango/handle.h>
#include <mango/task.h>
#include <pthread.h>
#include <stdlib.h>
extern void pthread_exit(void *retval)
{
struct __pthread *self = pthread_self();
if (!self) {
/* TODO: abort(); */
return;
}
if (self->thr_flags & THREAD_DETACHED) {
kern_handle_t task;
kern_handle_t address_space;
task_self(&task);
task_get_address_space(task, &address_space);
kern_handle_close(task);
__pthread_unmap_exit(
address_space,
self->thr_map_base,
self->thr_map_size);
} else {
self->thr_result = retval;
thread_exit();
}
}