From d2afe974f9d751de144ef09d31255aea13b442c0 Mon Sep 17 00:00:00 2001 From: James Zern Date: Mon, 23 Nov 2015 20:41:26 -0800 Subject: [PATCH] thread: use CreateThread for windows phone _beginthreadex is unavailable for winrt/uwp Change-Id: Ie7412a568278ac67f0047f1764e2521193d74d4d --- src/utils/thread.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/utils/thread.c b/src/utils/thread.c index d58f74e5..93f76227 100644 --- a/src/utils/thread.c +++ b/src/utils/thread.c @@ -35,6 +35,15 @@ typedef struct { } pthread_cond_t; #endif // _WIN32_WINNT >= 0x600 +#ifndef WINAPI_FAMILY_PARTITION +#define WINAPI_PARTITION_DESKTOP 1 +#define WINAPI_FAMILY_PARTITION(x) x +#endif + +#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) +#define USE_CREATE_THREAD +#endif + #else // !_WIN32 #include @@ -66,12 +75,21 @@ struct WebPWorkerImpl { static int pthread_create(pthread_t* const thread, const void* attr, unsigned int (__stdcall *start)(void*), void* arg) { (void)attr; +#ifdef USE_CREATE_THREAD + *thread = CreateThread(NULL, /* lpThreadAttributes */ + 0, /* dwStackSize */ + start, + arg, + 0, /* dwStackSize */ + NULL); /* lpThreadId */ +#else *thread = (pthread_t)_beginthreadex(NULL, /* void *security */ 0, /* unsigned stack_size */ start, arg, 0, /* unsigned initflag */ NULL); /* unsigned *thrdaddr */ +#endif if (*thread == NULL) return 1; SetThreadPriority(*thread, THREAD_PRIORITY_ABOVE_NORMAL); return 0;