]> git.sesse.net Git - ffmpeg/commitdiff
thread: Provide no-op variants for pthread_once
authorLuca Barbato <lu_zero@gentoo.org>
Wed, 7 Oct 2015 20:43:38 +0000 (22:43 +0200)
committerLuca Barbato <lu_zero@gentoo.org>
Wed, 14 Oct 2015 12:35:34 +0000 (14:35 +0200)
libavutil/thread.h

index 35565440f2dcbfae7447b5e82ac03d6baa196901..cf0fbdda5f3471cf1a4ae72c5aa05f6264e23d2e 100644 (file)
 #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
 #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 */