Go to the documentation of this file.
26 #ifndef COMPAT_OS2THREADS_H
27 #define COMPAT_OS2THREADS_H
30 #define INCL_DOSERRORS
33 #undef __STRICT_ANSI__
37 #include <sys/builtin.h>
38 #include <sys/fmutex.h>
46 void *(*start_routine)(
void *);
56 #define PTHREAD_MUTEX_INITIALIZER _FMUTEX_INITIALIZER
71 #define PTHREAD_ONCE_INIT {0, _FMUTEX_INITIALIZER}
82 void *(*start_routine)(
void*),
96 DosWaitThread(&thread.
tid, DCWW_WAIT);
99 *value_ptr = thread.
result;
107 _fmutex_create(
mutex, 0);
114 _fmutex_close(
mutex);
121 _fmutex_request(
mutex, 0);
128 _fmutex_release(
mutex);
136 DosCreateEventSem(
NULL, &
cond->event_sem, DCE_POSTONE, FALSE);
137 DosCreateEventSem(
NULL, &
cond->ack_sem, DCE_POSTONE, FALSE);
139 cond->wait_count = 0;
146 DosCloseEventSem(
cond->event_sem);
147 DosCloseEventSem(
cond->ack_sem);
154 if (!__atomic_cmpxchg32(&
cond->wait_count, 0, 0)) {
155 DosPostEventSem(
cond->event_sem);
156 DosWaitEventSem(
cond->ack_sem, SEM_INDEFINITE_WAIT);
164 while (!__atomic_cmpxchg32(&
cond->wait_count, 0, 0))
172 const struct timespec *abstime)
174 int64_t abs_milli = abstime->tv_sec * 1000LL + abstime->tv_nsec / 1000000;
177 __atomic_increment(&
cond->wait_count);
181 APIRET
ret = DosWaitEventSem(
cond->event_sem, t);
183 __atomic_decrement(&
cond->wait_count);
185 DosPostEventSem(
cond->ack_sem);
189 return (
ret == ERROR_TIMEOUT) ? ETIMEDOUT : 0;
195 __atomic_increment(&
cond->wait_count);
199 DosWaitEventSem(
cond->event_sem, SEM_INDEFINITE_WAIT);
201 __atomic_decrement(&
cond->wait_count);
203 DosPostEventSem(
cond->ack_sem);
211 void (*init_routine)(
void))
213 if (!once_control->
done)
215 _fmutex_request(&once_control->
mtx, 0);
217 if (!once_control->
done)
221 once_control->
done = 1;
224 _fmutex_release(&once_control->
mtx);
static av_always_inline int pthread_join(pthread_t thread, void **value_ptr)
static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
volatile unsigned wait_count
static av_always_inline int pthread_mutex_lock(pthread_mutex_t *mutex)
static av_always_inline int pthread_mutex_unlock(pthread_mutex_t *mutex)
static av_always_inline int pthread_cond_broadcast(pthread_cond_t *cond)
static void thread_entry(void *arg)
static av_always_inline int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg)
static av_always_inline int pthread_once(pthread_once_t *once_control, void(*init_routine)(void))
CONDITION_VARIABLE pthread_cond_t
static av_always_inline int pthread_cond_destroy(pthread_cond_t *cond)
static av_always_inline int pthread_mutex_destroy(pthread_mutex_t *mutex)
void *(* start_routine)(void *)
static av_always_inline int pthread_cond_signal(pthread_cond_t *cond)
static av_always_inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
int64_t av_gettime(void)
Get the current time in microseconds.
static av_always_inline int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime)
static av_always_inline int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
int(* cond)(enum AVPixelFormat pix_fmt)