[FFmpeg-devel] [PATCH v2] avutil/thread: add wrappers for pthread_cond_t and pthread_t functions
James Almer
jamrial at gmail.com
Fri Aug 18 19:14:27 EEST 2023
Signed-off-by: James Almer <jamrial at gmail.com>
---
Now not defining pthread_t when !HAVE_THREADS, like it's done with cond, mutex,
and once.
libavutil/thread.h | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/libavutil/thread.h b/libavutil/thread.h
index 2f5e7e1cb5..7dfa54c6a9 100644
--- a/libavutil/thread.h
+++ b/libavutil/thread.h
@@ -155,6 +155,15 @@ static inline int strict_pthread_once(pthread_once_t *once_control, void (*init_
#include "compat/w32pthreads.h"
#endif
+#define AVCond pthread_cond_t
+
+#define ff_cond_init pthread_cond_init
+#define ff_cond_destroy pthread_cond_destroy
+#define ff_cond_signal pthread_cond_signal
+#define ff_cond_broadcast pthread_cond_broadcast
+#define ff_cond_wait pthread_cond_wait
+#define ff_cond_timedwait pthread_cond_timedwait
+
#define AVMutex pthread_mutex_t
#define AV_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
@@ -168,8 +177,23 @@ static inline int strict_pthread_once(pthread_once_t *once_control, void (*init_
#define ff_thread_once(control, routine) pthread_once(control, routine)
+#define AVThread pthread_t
+
+#define ff_thread_create pthread_create
+#define ff_thread_join pthread_join
+
#else
+#define AVCond char
+
+static inline int ff_cond_init(AVCond *cond, const void *attr){ return 0; }
+static inline int ff_cond_destroy(AVCond *cond){ return 0; }
+static inline int ff_cond_signal(AVCond *cond){ return 0; }
+static inline int ff_cond_broadcast(AVCond *cond){ return 0; }
+static inline int ff_cond_wait(AVCond *cond, AVMutex *mutex){ return 0; }
+static inline int ff_cond_timedwait(AVCond *cond, AVMutex *mutex,
+ const void *abstime){ return 0; }
+
#define AVMutex char
#define AV_MUTEX_INITIALIZER 0
@@ -190,6 +214,12 @@ static inline int ff_thread_once(char *control, void (*routine)(void))
return 0;
}
+#define AVThread char
+
+static inline int ff_thread_create(AVThread *thread, const void *unused_attr,
+ void *(*start_routine)(void*), void *arg){ return 0; }
+static inline int ff_thread_join(AVThread thread, void **value_ptr){ return 0; }
+
#endif
static inline int ff_thread_setname(const char *name)
--
2.41.0
More information about the ffmpeg-devel
mailing list