Commit 3c0a081a authored by KO Myung-Hun's avatar KO Myung-Hun Committed by James Almer

compat/os2threads: support static mutexes

Reviewed-by: 's avatarwm4 <nfxjfg@googlemail.com>
Signed-off-by: 's avatarJames Almer <jamrial@gmail.com>
parent d03c39b4
/* /*
* Copyright (c) 2011 KO Myung-Hun <komh@chollian.net> * Copyright (c) 2011-2017 KO Myung-Hun <komh@chollian.net>
* *
* This file is part of FFmpeg. * This file is part of FFmpeg.
* *
...@@ -46,9 +46,11 @@ typedef struct { ...@@ -46,9 +46,11 @@ typedef struct {
typedef void pthread_attr_t; typedef void pthread_attr_t;
typedef HMTX pthread_mutex_t; typedef _fmutex pthread_mutex_t;
typedef void pthread_mutexattr_t; typedef void pthread_mutexattr_t;
#define PTHREAD_MUTEX_INITIALIZER _FMUTEX_INITIALIZER
typedef struct { typedef struct {
HEV event_sem; HEV event_sem;
HEV ack_sem; HEV ack_sem;
...@@ -98,28 +100,28 @@ static av_always_inline int pthread_join(pthread_t thread, void **value_ptr) ...@@ -98,28 +100,28 @@ 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, static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex,
const pthread_mutexattr_t *attr) const pthread_mutexattr_t *attr)
{ {
DosCreateMutexSem(NULL, (PHMTX)mutex, 0, FALSE); _fmutex_create(mutex, 0);
return 0; return 0;
} }
static av_always_inline int pthread_mutex_destroy(pthread_mutex_t *mutex) static av_always_inline int pthread_mutex_destroy(pthread_mutex_t *mutex)
{ {
DosCloseMutexSem(*(PHMTX)mutex); _fmutex_close(mutex);
return 0; return 0;
} }
static av_always_inline int pthread_mutex_lock(pthread_mutex_t *mutex) static av_always_inline int pthread_mutex_lock(pthread_mutex_t *mutex)
{ {
DosRequestMutexSem(*(PHMTX)mutex, SEM_INDEFINITE_WAIT); _fmutex_request(mutex, 0);
return 0; return 0;
} }
static av_always_inline int pthread_mutex_unlock(pthread_mutex_t *mutex) static av_always_inline int pthread_mutex_unlock(pthread_mutex_t *mutex)
{ {
DosReleaseMutexSem(*(PHMTX)mutex); _fmutex_release(mutex);
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment