From 35c7e80281ff6079b6e89dd421addd0a5f6b8b2c Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 18 Aug 2022 17:14:16 -0400 Subject: Fix thread function attributes on Windows --- include/zix/thread.h | 5 ++--- test/test_ring.c | 6 ++---- test/test_sem.c | 6 ++---- test/test_thread.c | 3 +-- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/include/zix/thread.h b/include/zix/thread.h index 29dee44..9c213de 100644 --- a/include/zix/thread.h +++ b/include/zix/thread.h @@ -27,7 +27,7 @@ extern "C" { #ifdef _WIN32 # define ZIX_THREAD_RESULT 0 -# define ZIX_THREAD_FUNC __attribute__((stdcall)) +# define ZIX_THREAD_FUNC __stdcall typedef HANDLE ZixThread; typedef DWORD ZixThreadResult; @@ -51,8 +51,7 @@ typedef void* ZixThreadResult; "Returning" a result, and communicating with the parent thread in general, can be done through the pointer argument. */ -typedef ZIX_THREAD_FUNC -ZixThreadResult (*ZixThreadFunc)(void*); +typedef ZixThreadResult(ZIX_THREAD_FUNC* ZixThreadFunc)(void*); /** Initialize `thread` to a new thread. diff --git a/test/test_ring.c b/test/test_ring.c index 8016910..7209ac0 100644 --- a/test/test_ring.c +++ b/test/test_ring.c @@ -43,8 +43,7 @@ cmp_msg(const int* const msg1, const int* const msg2) return 1; } -ZIX_THREAD_FUNC -static ZixThreadResult +static ZixThreadResult ZIX_THREAD_FUNC reader(void* ZIX_UNUSED(arg)) { printf("Reader starting\n"); @@ -67,8 +66,7 @@ reader(void* ZIX_UNUSED(arg)) return ZIX_THREAD_RESULT; } -ZIX_THREAD_FUNC -static ZixThreadResult +static ZixThreadResult ZIX_THREAD_FUNC writer(void* ZIX_UNUSED(arg)) { printf("Writer starting\n"); diff --git a/test/test_sem.c b/test/test_sem.c index 3cda8ea..023b8ee 100644 --- a/test/test_sem.c +++ b/test/test_sem.c @@ -14,8 +14,7 @@ static ZixSem sem; static unsigned n_signals = 1024; -ZIX_THREAD_FUNC -static ZixThreadResult +static ZixThreadResult ZIX_THREAD_FUNC reader(void* ZIX_UNUSED(arg)) { printf("Reader starting\n"); @@ -28,8 +27,7 @@ reader(void* ZIX_UNUSED(arg)) return ZIX_THREAD_RESULT; } -ZIX_THREAD_FUNC -static ZixThreadResult +static ZixThreadResult ZIX_THREAD_FUNC writer(void* ZIX_UNUSED(arg)) { printf("Writer starting\n"); diff --git a/test/test_thread.c b/test/test_thread.c index 6fe80a5..8cfc9f4 100644 --- a/test/test_thread.c +++ b/test/test_thread.c @@ -13,8 +13,7 @@ typedef struct { int output; } SharedData; -ZIX_THREAD_FUNC -static ZixThreadResult +static ZixThreadResult ZIX_THREAD_FUNC thread_func(void* const arg) { SharedData* const data = (SharedData*)arg; -- cgit v1.2.1