summaryrefslogtreecommitdiff
path: root/libavutil/thread.h
diff options
context:
space:
mode:
authorHendrik Leppkes <h.leppkes@gmail.com>2015-10-14 23:02:35 +0200
committerHendrik Leppkes <h.leppkes@gmail.com>2015-10-14 23:02:35 +0200
commitf05021f3f49a45b36411ec9de3cd7522dc9f9110 (patch)
tree119abab826cc68205bdab65ed1593db25d24f27b /libavutil/thread.h
parentb66a94ab539cbebf8dc6ca53d81dfa47d6dd59ac (diff)
parentc53e796f8b69799b7ad6d28fbab981d37edf1bc9 (diff)
downloadffmpeg-f05021f3f49a45b36411ec9de3cd7522dc9f9110.tar.gz
Merge commit 'c53e796f8b69799b7ad6d28fbab981d37edf1bc9'
* commit 'c53e796f8b69799b7ad6d28fbab981d37edf1bc9': thread: Provide no-op variants for pthread_once Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
Diffstat (limited to 'libavutil/thread.h')
-rw-r--r--libavutil/thread.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/libavutil/thread.h b/libavutil/thread.h
index 297b5b9a52..3d1573775c 100644
--- a/libavutil/thread.h
+++ b/libavutil/thread.h
@@ -43,6 +43,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 USE_ATOMICS 1
@@ -54,6 +59,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 */