aom: Move THREADFN macro definitions to aom_pthread.h

From 5d1b2f69dc80606877e85e083a161125b03cedbd Mon Sep 17 00:00:00 2001
From: Wan-Teh Chang <[EMAIL REDACTED]>
Date: Fri, 16 Feb 2024 09:59:10 -0800
Subject: [PATCH] Move THREADFN macro definitions to aom_pthread.h

The THREADFN and THREAD_EXIT_SUCCESS macros are used to define the
thread start routines passed to our implementation of pthread_create(),
so it makes sense to define these macros in aom_util/aom_pthread.h. This
allows us to call pthread_create() in files besides
aom_util/aom_thread.c.

Change-Id: I2a2015afc3df6e626674b9be48d9ef79ab6b7a4b
---
 aom_util/aom_pthread.h | 11 +++++++++++
 aom_util/aom_thread.c  | 14 --------------
 2 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/aom_util/aom_pthread.h b/aom_util/aom_pthread.h
index fbf0d1c5e..827b9c231 100644
--- a/aom_util/aom_pthread.h
+++ b/aom_util/aom_pthread.h
@@ -52,6 +52,15 @@ typedef CONDITION_VARIABLE pthread_cond_t;
 //------------------------------------------------------------------------------
 // simplistic pthread emulation layer
 
+// _beginthreadex requires __stdcall
+#if defined(__GNUC__) && \
+    (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2))
+#define THREADFN __attribute__((force_align_arg_pointer)) unsigned int __stdcall
+#else
+#define THREADFN unsigned int __stdcall
+#endif
+#define THREAD_EXIT_SUCCESS 0
+
 static INLINE int pthread_attr_init(pthread_attr_t *attr) {
   (void)attr;
   return 0;
@@ -148,6 +157,8 @@ static INLINE int pthread_cond_wait(pthread_cond_t *const condition,
 }
 #else                 // _WIN32
 #include <pthread.h>  // NOLINT
+#define THREADFN void *
+#define THREAD_EXIT_SUCCESS NULL
 #endif
 
 #ifdef __cplusplus
diff --git a/aom_util/aom_thread.c b/aom_util/aom_thread.c
index a353b523d..bdf2b7dfa 100644
--- a/aom_util/aom_thread.c
+++ b/aom_util/aom_thread.c
@@ -32,20 +32,6 @@
 
 #if CONFIG_MULTITHREAD
 
-#if defined(_WIN32) && !HAVE_PTHREAD_H
-// _beginthreadex requires __stdcall
-#if defined(__GNUC__) && \
-    (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2))
-#define THREADFN __attribute__((force_align_arg_pointer)) unsigned int __stdcall
-#else
-#define THREADFN unsigned int __stdcall
-#endif
-#define THREAD_EXIT_SUCCESS 0
-#else  // _WIN32
-#define THREADFN void *
-#define THREAD_EXIT_SUCCESS NULL
-#endif
-
 struct AVxWorkerImpl {
   pthread_mutex_t mutex_;
   pthread_cond_t condition_;