15#include <sys/syscall.h>
27 void *(*entry)(
void *);
39#define THREAD_HASH_SLOTS 32
93 printf(
"pthread_self failed to find current thread!\n");
102 thr->result = (thr->entry)(thr->arg);
109 void *(*start_routine)(
void *),
void *arg)
114 thr =
malloc(
sizeof(*thr));
119 memset(thr, 0,
sizeof(*thr));
121 thr->entry = start_routine;
146 thr->result = value_ptr;
160 *value_ptr = (
void *)thr->result;
236 }
else if (mtx->
lock == 1) {
250 if (*mutex ==
NULL) {
259 while (__sync_lock_test_and_set(&mtx->
lock, 1) == 1) {
271 if (*mutex ==
NULL) {
279 if (__sync_lock_test_and_set(&mtx->
lock, 1) == 1) {
292 if (*mutex ==
NULL) {
300 __sync_lock_release(&mtx->
lock);
379 while (level >= cnd->
exit) {
420 while (level >= cnd->
exit) {
void CoreMutex_Lock(CoreMutex *mtx)
void CoreMutex_Unlock(CoreMutex *mtx)
void CoreMutex_Init(CoreMutex *mtx)
int OSThreadSleep(uint64_t time)
int OSThreadExit(uint64_t status)
int OSThreadWait(uint64_t tid)
int OSThreadCreate(uint64_t rip, uint64_t arg)
void pthread_exit(void *value_ptr)
int pthread_mutex_lock(pthread_mutex_t *mutex)
int pthread_cond_signal(pthread_cond_t *cond)
int pthread_mutex_trylock(pthread_mutex_t *mutex)
int pthread_mutex_destroy(pthread_mutex_t *mutex)
#define THREAD_HASH_SLOTS
pthread_t pthread_self(void)
int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
int pthread_barrier_wait(pthread_barrier_t *barrier)
int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
int pthread_mutex_unlock(pthread_mutex_t *mutex)
int pthread_cond_destroy(pthread_cond_t *cond)
int pthread_join(pthread_t thread, void **value_ptr)
void __pthread_init(void)
int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime)
int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
int pthread_barrier_init(pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, unsigned count)
int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg)
void pthreadCreateHelper(void *arg)
int pthread_barrier_destroy(pthread_barrier_t *barrier)
int pthread_cond_broadcast(pthread_cond_t *cond)
struct pthread_barrier * pthread_barrier_t
struct pthread_barrierattr * pthread_barrierattr_t
#define TAILQ_FOREACH(var, head, field)
#define TAILQ_HEAD(name, type)
#define TAILQ_REMOVE(head, elm, field)
#define TAILQ_INSERT_HEAD(head, elm, field)
#define TAILQ_ENTRY(type)
int printf(const char *fmt,...)
_Noreturn void abort(void)
void * memset(void *dst, int c, size_t len)
#define SYSCALL_ERRCODE(_result)
#define SYSCALL_VALUE(_result)