diff --git a/lib/curl_setup.h b/lib/curl_setup.h index 01f91c0223..8381324aa2 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -643,9 +643,11 @@ #if defined(CURL_WINDOWS_UWP) || defined(UNDER_CE) #define CURL_THREAD_RETURN_T DWORD typedef HANDLE curl_win_thread_handle_t; +#define CURL_WIN_BEGINTHREAD CreateThread #else #define CURL_THREAD_RETURN_T unsigned int typedef uintptr_t curl_win_thread_handle_t; +#define CURL_WIN_BEGINTHREAD _beginthreadex #endif /* diff --git a/lib/curl_threads.c b/lib/curl_threads.c index 6fef025182..cc91f68bc3 100644 --- a/lib/curl_threads.c +++ b/lib/curl_threads.c @@ -135,11 +135,7 @@ curl_thread_t Curl_thread_create(CURL_THREAD_RETURN_T { curl_thread_t t; curl_win_thread_handle_t thread_handle; -#if defined(CURL_WINDOWS_UWP) || defined(UNDER_CE) - thread_handle = CreateThread(NULL, 0, func, arg, 0, NULL); -#else - thread_handle = _beginthreadex(NULL, 0, func, arg, 0, NULL); -#endif + thread_handle = CURL_WIN_BEGINTHREAD(NULL, 0, func, arg, 0, NULL); t = (curl_thread_t)thread_handle; if((t == 0) || (t == LongToHandle(-1L))) { #ifdef UNDER_CE diff --git a/tests/libtest/lib3026.c b/tests/libtest/lib3026.c index 3e95ebec19..92d637aa7c 100644 --- a/tests/libtest/lib3026.c +++ b/tests/libtest/lib3026.c @@ -58,11 +58,7 @@ static CURLcode test_lib3026(const char *URL) for(i = 0; i < tid_count; i++) { curl_win_thread_handle_t th; results[i] = CURL_LAST; /* initialize with invalid value */ -#if defined(CURL_WINDOWS_UWP) || defined(UNDER_CE) - th = CreateThread(NULL, 0, t3026_run_thread, &results[i], 0, NULL); -#else - th = _beginthreadex(NULL, 0, t3026_run_thread, &results[i], 0, NULL); -#endif + th = CURL_WIN_BEGINTHREAD(NULL, 0, t3026_run_thread, &results[i], 0, NULL); if(!th) { curl_mfprintf(stderr, "%s:%d Couldn't create thread, errno %lu\n", __FILE__, __LINE__, GetLastError()); diff --git a/tests/server/sockfilt.c b/tests/server/sockfilt.c index 7867b66d59..a16f032e04 100644 --- a/tests/server/sockfilt.c +++ b/tests/server/sockfilt.c @@ -568,7 +568,8 @@ static HANDLE select_ws_wait(HANDLE handle, HANDLE signal, HANDLE abort) data->abort = abort; /* launch waiting thread */ - thread = _beginthreadex(NULL, 0, &select_ws_wait_thread, data, 0, NULL); + thread = CURL_WIN_BEGINTHREAD(NULL, 0, &select_ws_wait_thread, data, 0, + NULL); /* free data if thread failed to launch */ if(!thread) { diff --git a/tests/server/util.c b/tests/server/util.c index f35f6fa4fb..72e91f9f8d 100644 --- a/tests/server/util.c +++ b/tests/server/util.c @@ -625,8 +625,9 @@ void install_signal_handlers(bool keep_sigalrm) #if !defined(CURL_WINDOWS_UWP) && !defined(UNDER_CE) { curl_win_thread_handle_t thread; - thread = _beginthreadex(NULL, 0, &main_window_loop, - (void *)GetModuleHandle(NULL), 0, &thread_main_id); + thread = CURL_WIN_BEGINTHREAD(NULL, 0, &main_window_loop, + (void *)GetModuleHandle(NULL), 0, + &thread_main_id); thread_main_window = (HANDLE)thread; if(!thread_main_window || !thread_main_id) logmsg("cannot start main window loop");