diff options
author | Luca Barbato <lu_zero@gentoo.org> | 2015-10-07 22:43:38 +0200 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2015-10-14 14:35:34 +0200 |
commit | c53e796f8b69799b7ad6d28fbab981d37edf1bc9 (patch) | |
tree | 24d09272adbcc1a9382e61d1a7336e7dc53fbe65 /libavutil/thread.h | |
parent | 08377f9c3bf6dbe216512a2e05c9fac837b13fc0 (diff) | |
download | ffmpeg-c53e796f8b69799b7ad6d28fbab981d37edf1bc9.tar.gz |
thread: Provide no-op variants for pthread_once
Diffstat (limited to 'libavutil/thread.h')
-rw-r--r-- | libavutil/thread.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libavutil/thread.h b/libavutil/thread.h index 35565440f2..cf0fbdda5f 100644 --- a/libavutil/thread.h +++ b/libavutil/thread.h @@ -39,6 +39,11 @@ #define ff_mutex_unlock pthread_mutex_unlock #define ff_mutex_destroy pthread_mutex_destroy +#define AVOnce pthread_once_t +#define AV_ONCE_INIT PTHREAD_ONCE_INIT + +#define ff_thread_once(control, routine) pthread_once(control, routine) + #else #define AVMutex char @@ -48,6 +53,18 @@ #define ff_mutex_unlock(mutex) (0) #define ff_mutex_destroy(mutex) (0) +#define AVOnce char +#define AV_ONCE_INIT 0 + +static inline int ff_thread_once(char *control, void (*routine)(void)) +{ + if (!*control) { + routine(); + *control = 1; + } + return 0; +} + #endif #endif /* AVUTIL_THREAD_H */ |