]> git.sesse.net Git - ffmpeg/blobdiff - libavutil/thread.h
Merge commit '452d659aa4a742106c70ffe9ef3df47ef5b81ea6'
[ffmpeg] / libavutil / thread.h
index 297b5b9a5287e2a88bb4fc0e98a6d00ed24ffeec..3d1573775cc770f0049e71c082d1108b2f82b3b5 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 USE_ATOMICS 1
 #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 */