uthread/src/thread/thread.c
2025-03-14 18:04:41 +01:00

46 lines
1.1 KiB
C

#include "thread.h"
#include "debug.h"
#include "pthread.h"
#include <bits/pthreadtypes.h>
#include <sched.h>
int thread_yield(void) {
return sched_yield();
}
thread_t thread_self(void) {
return (void *) pthread_self();
}
int thread_create(thread_t *newthread, void *(*func)(void *), void *funcarg) {
TRACE("Create a new thread that execute function %p", func);
return pthread_create((pthread_t *) newthread, NULL, func, funcarg);
}
int thread_join(thread_t thread, void **retval) {
TRACE("Join thread %p", thread);
return pthread_join((pthread_t) thread, retval);
}
void thread_exit(void *retval) {
TRACE("Exit thread");
pthread_exit(retval);
}
int thread_mutex_init(thread_mutex_t *mutex) {
return pthread_mutex_init((pthread_mutex_t *) mutex, NULL);
}
int thread_mutex_destroy(thread_mutex_t *mutex) {
return pthread_mutex_destroy((pthread_mutex_t *) mutex);
}
int thread_mutex_lock(thread_mutex_t *mutex) {
return pthread_mutex_lock((pthread_mutex_t * )mutex);
}
int thread_mutex_unlock(thread_mutex_t *mutex) {
return pthread_mutex_unlock((pthread_mutex_t *)mutex);
}