The threads.h and threads.c code define the following portable API:
- THREAD_TYPE portable thread type
- THREAD_ID returns current thread ID of type THREAD_TYPE*
- THREAD_CREATE(t,f,a) start a thread (THREAD_TYPE*)t that calls f(a)
- THREAD_DETACH(t) detach thread (THREAD_TYPE*)t
- THREAD_JOIN(t) wait to join (THREAD_TYPE*)t
- THREAD_EXIT exit the current thread
- THREAD_CANCEL(t) kill a thread, dangerous, use only in extreme cases!
- MUTEX_TYPE portable mutex type
- MUTEX_INITIALIZER global initializer value for static locks
- MUTEX_SETUP(m) setup lock (MUTEX_TYPE*)m
- MUTEX_CLEANUP(m) cleanup lock (MUTEX_TYPE*)m
- MUTEX_LOCK(m) acquire lock (MUTEX_TYPE*)m
- MUTEX_UNLOCK(m) release lock (MUTEX_TYPE*)m
- COND_TYPE portable condition variable type
- COND_SETUP(c) setup condition variable (COND_TYPE*)c
- COND_CLEANUP(c) cleanup condition variable (COND_TYPE*)c
- COND_SIGNAL(c) signal condition variable (COND_TYPE*)c
- COND_WAIT(c,m) wait on variable (COND_TYPE*)c in mutex (MUTEX_TYPE*)m