1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-10 06:47:34 +00:00

LibPthread: Start working on a POSIX threading library

This patch adds pthread_create() and pthread_exit(), which currently
simply wrap our existing create_thread() and exit_thread() syscalls.

LibThread is also ported to using LibPthread.
This commit is contained in:
Andreas Kling 2019-11-13 21:49:24 +01:00
parent 4fe2ee0221
commit 69ca9cfd78
16 changed files with 89 additions and 31 deletions

View file

@ -0,0 +1,24 @@
#include <AK/StdLibExtras.h>
#include <pthread.h>
#include <unistd.h>
extern "C" {
int pthread_create(pthread_t* thread, pthread_attr_t* attributes, void *(*start_routine)(void*), void* argument_to_start_routine)
{
if (!thread)
return -EINVAL;
UNUSED_PARAM(attributes);
int rc = create_thread(start_routine, argument_to_start_routine);
if (rc < 0)
return rc;
*thread = rc;
return 0;
}
void pthread_exit(void* value_ptr)
{
exit_thread(value_ptr);
}
}