diff --git a/pthread.c b/pthread.c new file mode 100644 index 0000000..58e3549 --- /dev/null +++ b/pthread.c @@ -0,0 +1,53 @@ +#include "pthread.h" + +_syscall2(int, create_thread, unsigned long, start, void*, arg); +_syscall2(int, syspthread_join, pthread_t, thread, void*, value_ptr); +_syscall1(int, endthread, int, value); + +int pthread_attr_init(pthread_attr_t* attr) +{ + ;;;;; + return 0; +} +int pthread_create(pthread_t* thread, const pthread_attr_t* attr, void* (*start)(void*), void* arg) +{ + int id = 0; + if (!thread) return EINVAL; + + id = create_thread((unsigned long)start, (int*)arg); + + if (id < 0) return errno; + *thread = id; + return id; +} + +void pthread_exit(void* value_ptr) +{ + endthread((int)value_ptr); +} +int pthread_join(pthread_t thread, void** value_ptr) +{ + syspthread_join(thread, value_ptr); + return 0; +} + + + + + + + + + + + + + + + + + + + + +