![K. Lange](/assets/img/avatar_default.png)
While POSIX.1-2001 says that pthread_t is allowed to be "non-arithmetic", earlier revisions did not allow it, and many things still assume the original rule and either complain loudly or fail completely if pthread_t is a struct. In glibc, pthread_t is typedef'd to 'unsigned long int', but in musl, it is a pointer type to an opaque struct. We'll go with the latter option here. Note that while this breaks ABI combatibility for the libc, nothing in the x86-64 or aarch64 package repositories uses pthreads, so this probably doesn't matter too much. If you are one of the handful of souls brave enough to be maintaining your own downstream software for ToaruOS and you use pthreads, it's time to rebuild. This is an initial change that will be followed up with more thorough internal changes to our pthreads implementation.
50 lines
1.5 KiB
C
50 lines
1.5 KiB
C
#pragma once
|
|
|
|
#include <_cheader.h>
|
|
#include <stdint.h>
|
|
|
|
_Begin_C_Header
|
|
|
|
typedef struct __pthread * pthread_t;
|
|
typedef unsigned int pthread_attr_t;
|
|
|
|
typedef struct {
|
|
int volatile atomic_lock;
|
|
int volatile readers;
|
|
int writerPid;
|
|
} pthread_rwlock_t;
|
|
|
|
extern int pthread_create(pthread_t * thread, pthread_attr_t * attr, void *(*start_routine)(void *), void * arg);
|
|
extern void pthread_exit(void * value);
|
|
extern int pthread_kill(pthread_t thread, int sig);
|
|
|
|
extern int clone(uintptr_t,uintptr_t,void*);
|
|
extern int gettid();
|
|
|
|
extern void pthread_cleanup_push(void (*routine)(void *), void *arg);
|
|
extern void pthread_cleanup_pop(int execute);
|
|
|
|
typedef int volatile pthread_mutex_t;
|
|
typedef int pthread_mutexattr_t;
|
|
|
|
extern int pthread_join(pthread_t thread, void **retval);
|
|
|
|
#define PTHREAD_MUTEX_INITIALIZER 0
|
|
|
|
extern int pthread_mutex_lock(pthread_mutex_t *mutex);
|
|
extern int pthread_mutex_trylock(pthread_mutex_t *mutex);
|
|
extern int pthread_mutex_unlock(pthread_mutex_t *mutex);
|
|
extern int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr);
|
|
extern int pthread_mutex_destroy(pthread_mutex_t *mutex);
|
|
|
|
extern int pthread_attr_init(pthread_attr_t *attr);
|
|
extern int pthread_attr_destroy(pthread_attr_t *attr);
|
|
|
|
extern int pthread_rwlock_init(pthread_rwlock_t * lock, void * args);
|
|
extern int pthread_rwlock_wrlock(pthread_rwlock_t * lock);
|
|
extern int pthread_rwlock_rdlock(pthread_rwlock_t * lock);
|
|
extern int pthread_rwlock_unlock(pthread_rwlock_t * lock);
|
|
extern int pthread_rwlock_destroy(pthread_rwlock_t * lock);
|
|
|
|
_End_C_Header
|