[FFmpeg-cvslog] w32pthreads: Fix function signature mismatches for CreateThread

Martin Storsjö git at videolan.org
Fri Aug 4 21:51:52 EEST 2023


ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Wed Aug  2 00:48:50 2023 +0300| [7aa9684db39a8ecf444b3af1c74c225757d8e49f] | committer: Martin Storsjö

w32pthreads: Fix function signature mismatches for CreateThread

In WinRT mode, we use CreateThread instead of _beginthreadex.

CreateThread takes a LPTHREAD_START_ROUTINE function pointer,
which has got the signature DWORD WINAPI ThreadProc(LPVOID).
_beginthreadex takes a function with the signature
unsigned __stdcall func(void *).

DWORD is defined as an unsigned long, which is different type
from unsigned int, even if they have the same size on Windows.

This fixes build failures with Clang 16 and newer, where function
pointer type mismatches are a fatal error by default.

Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7aa9684db39a8ecf444b3af1c74c225757d8e49f
---

 compat/w32pthreads.h | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/compat/w32pthreads.h b/compat/w32pthreads.h
index 6405e72b64..dae8d9420d 100644
--- a/compat/w32pthreads.h
+++ b/compat/w32pthreads.h
@@ -66,7 +66,14 @@ typedef CONDITION_VARIABLE pthread_cond_t;
 #define PTHREAD_CANCEL_ENABLE 1
 #define PTHREAD_CANCEL_DISABLE 0
 
-static av_unused unsigned __stdcall attribute_align_arg win32thread_worker(void *arg)
+#if HAVE_WINRT
+#define THREADFUNC_RETTYPE DWORD
+#else
+#define THREADFUNC_RETTYPE unsigned
+#endif
+
+static av_unused THREADFUNC_RETTYPE
+__stdcall attribute_align_arg win32thread_worker(void *arg)
 {
     pthread_t *h = (pthread_t*)arg;
     h->ret = h->func(h->arg);



More information about the ffmpeg-cvslog mailing list