10#ifndef STK_C_PTHREAD_H_
11#define STK_C_PTHREAD_H_
160#ifndef STK_C_PTHREAD_MAX_THREADS
161 #define STK_C_PTHREAD_MAX_THREADS (8U)
172#ifndef STK_C_PTHREAD_DEFAULT_STACK_WORDS
173 #define STK_C_PTHREAD_DEFAULT_STACK_WORDS (1024U)
180#ifndef STK_C_PTHREAD_REAPER_STACK_WORDS
181 #define STK_C_PTHREAD_REAPER_STACK_WORDS (256U)
188#ifndef STK_C_PTHREAD_KEYS_MAX
189 #define STK_C_PTHREAD_KEYS_MAX (8U)
226#define PTHREAD_CREATE_JOINABLE (0)
227#define PTHREAD_CREATE_DETACHED (1)
237#define PTHREAD_MUTEX_NORMAL (0)
238#define PTHREAD_MUTEX_DEFAULT (PTHREAD_MUTEX_NORMAL)
239#define PTHREAD_MUTEX_ERRORCHECK (1)
240#define PTHREAD_MUTEX_RECURSIVE (2)
253#define PTHREAD_MUTEX_INITIALIZER {0}
273#define PTHREAD_COND_INITIALIZER {0}
299#define PTHREAD_RWLOCK_INITIALIZER {0}
301#define PTHREAD_PROCESS_PRIVATE (0)
302#define PTHREAD_PROCESS_SHARED (1)
339#define PTHREAD_BARRIER_SERIAL_THREAD (-1)
354#define PTHREAD_ONCE_INIT {0}
365#define PTHREAD_KEYS_MAX (STK_C_PTHREAD_KEYS_MAX)
373#define PTHREAD_DESTRUCTOR_ITERATIONS (4)
435 void *(*start_routine)(
void *),
void *arg);
535 const struct timespec *abstime);
C language binding/interface for SuperTinyKernel RTOS.
C language binding for stk::memory::BlockMemoryPool.
struct stk_kernel_t stk_kernel_t
Opaque handle to a kernel instance.
uintptr_t stk_word_t
CPU register type.
int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock)
Try to acquire the write lock without blocking.
int pthread_condattr_destroy(pthread_condattr_t *attr)
int pthread_attr_init(pthread_attr_t *attr)
Initialize a thread attributes object with default values (default stack size, no external stack,...
int pthread_mutex_lock(pthread_mutex_t *mutex)
int pthread_rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr)
Initialize a read-write lock.
int pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, const struct timespec *abstime)
Acquire the write lock with an absolute deadline.
int pthread_once(pthread_once_t *once_control, void(*init_routine)(void))
Call init_routine exactly once for a given once_control, no matter how many threads call pthread_once...
int pthread_cond_signal(pthread_cond_t *cond)
int pthread_setspecific(pthread_key_t key, const void *value)
Set the calling thread's value for key.
int pthread_mutexattr_destroy(pthread_mutexattr_t *attr)
void pthread_exit(void *retval)
Terminate the calling thread.
int pthread_mutex_trylock(pthread_mutex_t *mutex)
int pthread_join(pthread_t thread, void **retval)
Block until the given joinable thread finishes, then reclaim its resources.
int pthread_condattr_init(pthread_condattr_t *attr)
int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate)
Get the current detach-state setting.
int pthread_spin_unlock(pthread_spinlock_t *lock)
int pthread_mutex_destroy(pthread_mutex_t *mutex)
int pthread_attr_destroy(pthread_attr_t *attr)
Destroy a thread attributes object (no-op; no owned resources).
pthread_t pthread_self(void)
Return the calling thread's own handle.
int pthread_spin_lock(pthread_spinlock_t *lock)
Acquire the spinlock, spinning until available.
int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock)
Acquire the lock for exclusive writing. Blocks until available.
int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *abstime)
Lock with an absolute deadline.
int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
Initialize a mutex.
int pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr)
int pthread_rwlock_destroy(pthread_rwlock_t *rwlock)
int pthread_detach(pthread_t thread)
Mark a thread as detached.
unsigned int pthread_key_t
A thread-specific data key.
int pthread_rwlock_unlock(pthread_rwlock_t *rwlock)
Release a read or write hold, whichever the calling thread holds.
int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *type)
struct pthread_stk_ctrl_t * pthread_t
Opaque thread handle.
int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize)
Set the requested stack size in bytes.
int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type)
Set the mutex type.
int pthread_barrier_wait(pthread_barrier_t *barrier)
Block until count threads have called this function, then release them all together; the barrier rese...
int pthread_spin_destroy(pthread_spinlock_t *lock)
void stk_pthread_bind_kernel(stk_kernel_t *kernel)
Bind the STK kernel instance that pthread_create() will add new threads to.
int pthread_barrier_init(pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, unsigned int count)
Initialize a barrier for count participating threads.
int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
Atomically unlock mutex and wait for a signal; re-locks mutex before returning.
int pthread_attr_setstack(pthread_attr_t *attr, void *stackaddr, size_t stacksize)
Supply an external, caller-owned stack buffer for the thread.
int pthread_mutex_unlock(pthread_mutex_t *mutex)
int pthread_equal(pthread_t t1, pthread_t t2)
Compare two thread handles for equality.
int pthread_rwlockattr_init(pthread_rwlockattr_t *attr)
int pthread_barrierattr_init(pthread_barrierattr_t *attr)
int pthread_cond_destroy(pthread_cond_t *cond)
int pthread_spin_init(pthread_spinlock_t *lock, int pshared)
Initialize a spinlock.
int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock)
Try to acquire the read lock without blocking.
int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime)
As pthread_cond_wait(), with an absolute deadline.
int pthread_barrierattr_destroy(pthread_barrierattr_t *attr)
int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock)
Acquire the lock for shared reading. Blocks until available.
int pthread_spin_trylock(pthread_spinlock_t *lock)
Try to acquire the spinlock without blocking.
void * pthread_getspecific(pthread_key_t key)
Get the calling thread's value for key.
int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
int pthread_rwlock_timedrdlock(pthread_rwlock_t *rwlock, const struct timespec *abstime)
Acquire the read lock with an absolute deadline.
int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize)
Get the currently requested stack size in bytes (0 = default).
int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg)
Create and start a new thread.
int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate)
Set PTHREAD_CREATE_JOINABLE or PTHREAD_CREATE_DETACHED.
int pthread_barrier_destroy(pthread_barrier_t *barrier)
int pthread_attr_getstack(const pthread_attr_t *attr, void **stackaddr, size_t *stacksize)
Get the previously-set external stack (NULL/0 if none set).
int pthread_key_delete(pthread_key_t key)
Free a thread-specific data key.
int pthread_yield(void)
Voluntarily give up the CPU to another ready task (cooperative yield), then resume once rescheduled.
int pthread_key_create(pthread_key_t *key, void(*destructor)(void *))
Allocate a new thread-specific data key.
int pthread_mutexattr_init(pthread_mutexattr_t *attr)
int pthread_cond_broadcast(pthread_cond_t *cond)
Opaque memory container for a Mutex instance.
Opaque memory container for SpinLock object.
Opaque memory container for a ConditionVariable instance.
Opaque memory container for an RWMutex instance.
Opaque memory container for a Barrier instance.
Thread creation attributes.
Condition variable attributes (currently no settable properties).
A pthread condition variable.
Read-write lock attributes (currently no settable properties).
A pthread read-write lock.
stk_spinlock_t * __handle
Barrier attributes (currently no settable properties).
A pthread_once() control object.