diff mbox series

[FFmpeg-devel] avutil/thread: add wrappers for pthread_cond_t and pthread_t functions

Message ID 20230818160656.3938-1-jamrial@gmail.com
State New
Headers show
Series [FFmpeg-devel] avutil/thread: add wrappers for pthread_cond_t and pthread_t functions | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

James Almer Aug. 18, 2023, 4:06 p.m. UTC
Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavutil/thread.h | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
diff mbox series

Patch

diff --git a/libavutil/thread.h b/libavutil/thread.h
index 2f5e7e1cb5..1e456f1c29 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
 
@@ -170,6 +179,16 @@  static inline int strict_pthread_once(pthread_once_t *once_control, void (*init_
 
 #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 +209,14 @@  static inline int ff_thread_once(char *control, void (*routine)(void))
     return 0;
 }
 
+typedef struct pthread_t {
+    void *dummy;
+} pthread_t;
+
+static inline int pthread_create(pthread_t *thread, const void *unused_attr,
+                                 void *(*start_routine)(void*), void *arg){ return 0; }
+static inline int pthread_join(pthread_t thread, void **value_ptr){ return 0; }
+
 #endif
 
 static inline int ff_thread_setname(const char *name)