build: fix build on win32
Manually pick changes and improvements from master to build on win32 (without specifying platform toolset)
This commit is contained in:
parent
3cd91cf599
commit
f42b03f7bb
@ -175,9 +175,24 @@ endif()
|
||||
|
||||
if(WIN32)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUNICODE -D_UNICODE")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_WIN32_WINNT=0x0501")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWIN32_LEAN_AND_MEAN")
|
||||
|
||||
if(NOT DEFINED CMAKE_WINDOWS_VERSION)
|
||||
set(CMAKE_WINDOWS_VERSION "WINXP")
|
||||
endif()
|
||||
|
||||
if(CMAKE_WINDOWS_VERSION STREQUAL "WINXP")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWINVER=0x0501 -DWIN32_WINNT=0x0501")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWINVER=0x0501 -DWIN32_WINNT=0x0501")
|
||||
elseif(CMAKE_WINDOWS_VERSION STREQUAL "WIN7")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWINVER=0x0601 -DWIN32_WINNT=0x0601")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWINVER=0x0601 -DWIN32_WINNT=0x0601")
|
||||
elseif(CMAKE_WINDOWS_VERSION STREQUAL "WIN8")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWINVER=0x0602 -DWIN32_WINNT=0x0602")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWINVER=0x0602 -DWIN32_WINNT=0x0602")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
if(IOS)
|
||||
|
@ -156,8 +156,16 @@ WINPR_API LONG InterlockedCompareExchange(LONG volatile *Destination, LONG Excha
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#if (!defined(_WIN32) || (defined(_WIN32) && (_WIN32_WINNT < 0x0502)))
|
||||
#define WINPR_INTERLOCKED_COMPARE_EXCHANGE64 1
|
||||
#endif
|
||||
|
||||
#ifdef WINPR_INTERLOCKED_COMPARE_EXCHANGE64
|
||||
|
||||
WINPR_API LONGLONG InterlockedCompareExchange64(LONGLONG volatile *Destination, LONGLONG Exchange, LONGLONG Comperand);
|
||||
|
||||
#endif
|
||||
|
||||
/* Doubly-Linked List */
|
||||
|
||||
WINPR_API VOID InitializeListHead(PLIST_ENTRY ListHead);
|
||||
|
@ -121,7 +121,9 @@ typedef struct _TP_WAIT TP_WAIT, *PTP_WAIT;
|
||||
|
||||
typedef struct _TP_IO TP_IO, *PTP_IO;
|
||||
|
||||
#if !defined(_WIN32) || (defined(_WIN32) && (_WIN32_WINNT < 0x0601))
|
||||
typedef TP_CALLBACK_ENVIRON_V1 TP_CALLBACK_ENVIRON, *PTP_CALLBACK_ENVIRON;
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
@ -152,13 +154,18 @@ typedef VOID (*PTP_WIN32_IO_CALLBACK)(PTP_CALLBACK_INSTANCE Instance, PVOID Cont
|
||||
|
||||
#endif
|
||||
|
||||
#if (!defined(_WIN32) || ((defined(_WIN32) && (_WIN32_WINNT < 0x0601))))
|
||||
#define WINPR_THREAD_POOL 1
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Synch */
|
||||
|
||||
#ifdef WINPR_THREAD_POOL
|
||||
|
||||
WINPR_API PTP_WAIT CreateThreadpoolWait(PTP_WAIT_CALLBACK pfnwa, PVOID pv, PTP_CALLBACK_ENVIRON pcbe);
|
||||
WINPR_API VOID CloseThreadpoolWait(PTP_WAIT pwa);
|
||||
WINPR_API VOID SetThreadpoolWait(PTP_WAIT pwa, HANDLE h, PFILETIME pftTimeout);
|
||||
@ -225,6 +232,7 @@ WINPR_API VOID LeaveCriticalSectionWhenCallbackReturns(PTP_CALLBACK_INSTANCE pci
|
||||
WINPR_API VOID FreeLibraryWhenCallbackReturns(PTP_CALLBACK_INSTANCE pci, HMODULE mod);
|
||||
WINPR_API VOID DisassociateCurrentThreadFromCallback(PTP_CALLBACK_INSTANCE pci);
|
||||
|
||||
#endif
|
||||
/* Dummy */
|
||||
|
||||
WINPR_API void winpr_pool_dummy(void);
|
||||
|
@ -236,11 +236,12 @@ LONG InterlockedCompareExchange(LONG volatile *Destination, LONG Exchange, LONG
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#if defined(_WIN64)
|
||||
#if defined(_WIN32) && !defined(WINPR_INTERLOCKED_COMPARE_EXCHANGE64)
|
||||
|
||||
/* InterlockedCompareExchange64 already defined */
|
||||
|
||||
#elif (_WIN32 && (_WIN32_WINNT < 0x0502))
|
||||
#elif defined(_WIN32) && defined(WINPR_INTERLOCKED_COMPARE_EXCHANGE64)
|
||||
|
||||
|
||||
static volatile HANDLE mutex = NULL;
|
||||
|
||||
|
@ -50,6 +50,7 @@ static void module_init()
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef WINPR_THREAD_POOL
|
||||
BOOL CallbackMayRunLong(PTP_CALLBACK_INSTANCE pci)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
@ -61,3 +62,4 @@ BOOL CallbackMayRunLong(PTP_CALLBACK_INSTANCE pci)
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
@ -62,6 +62,7 @@ static void module_init()
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef WINPR_THREAD_POOL
|
||||
VOID SetEventWhenCallbackReturns(PTP_CALLBACK_INSTANCE pci, HANDLE evt)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
@ -127,6 +128,4 @@ VOID DisassociateCurrentThreadFromCallback(PTP_CALLBACK_INSTANCE pci)
|
||||
#else
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -26,6 +26,8 @@
|
||||
|
||||
#include "pool.h"
|
||||
|
||||
#ifdef WINPR_THREAD_POOL
|
||||
|
||||
VOID InitializeCallbackEnvironment_V1(TP_CALLBACK_ENVIRON_V1* pcbe)
|
||||
{
|
||||
pcbe->Version = 1;
|
||||
@ -193,3 +195,5 @@ VOID SetThreadpoolCallbackPriority(PTP_CALLBACK_ENVIRON pcbe, TP_CALLBACK_PRIORI
|
||||
#else
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
@ -56,6 +56,8 @@ static void module_init()
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef WINPR_THREAD_POOL
|
||||
|
||||
PTP_CLEANUP_GROUP CreateThreadpoolCleanupGroup()
|
||||
{
|
||||
PTP_CLEANUP_GROUP cleanupGroup = NULL;
|
||||
@ -93,5 +95,4 @@ VOID CloseThreadpoolCleanupGroup(PTP_CLEANUP_GROUP ptpcg)
|
||||
free(ptpcg);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#endif
|
@ -24,6 +24,8 @@
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/pool.h>
|
||||
|
||||
#ifdef WINPR_THREAD_POOL
|
||||
|
||||
PTP_IO CreateThreadpoolIo(HANDLE fl, PTP_WIN32_IO_CALLBACK pfnio, PVOID pv, PTP_CALLBACK_ENVIRON pcbe)
|
||||
{
|
||||
return NULL;
|
||||
@ -49,3 +51,4 @@ VOID WaitForThreadpoolIoCallbacks(PTP_IO pio, BOOL fCancelPendingCallbacks)
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -144,6 +144,8 @@ PTP_POOL GetDefaultThreadpool()
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef WINPR_THREAD_POOL
|
||||
|
||||
PTP_POOL CreateThreadpool(PVOID reserved)
|
||||
{
|
||||
PTP_POOL pool = NULL;
|
||||
@ -230,6 +232,7 @@ VOID SetThreadpoolThreadMaximum(PTP_POOL ptpp, DWORD cthrdMost)
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
/* dummy */
|
||||
|
||||
void winpr_pool_dummy()
|
||||
|
@ -24,6 +24,8 @@
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/pool.h>
|
||||
|
||||
#ifdef WINPR_THREAD_POOL
|
||||
|
||||
PTP_WAIT CreateThreadpoolWait(PTP_WAIT_CALLBACK pfnwa, PVOID pv, PTP_CALLBACK_ENVIRON pcbe)
|
||||
{
|
||||
return NULL;
|
||||
@ -44,4 +46,4 @@ VOID WaitForThreadpoolWaitCallbacks(PTP_WAIT pwa, BOOL fCancelPendingCallbacks)
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
@ -24,6 +24,7 @@
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/pool.h>
|
||||
|
||||
#ifdef WINPR_THREAD_POOL
|
||||
PTP_TIMER CreateThreadpoolTimer(PTP_TIMER_CALLBACK pfnti, PVOID pv, PTP_CALLBACK_ENVIRON pcbe)
|
||||
{
|
||||
return NULL;
|
||||
@ -49,4 +50,4 @@ VOID WaitForThreadpoolTimerCallbacks(PTP_TIMER pti, BOOL fCancelPendingCallbacks
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
@ -60,6 +60,7 @@ static void module_init()
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef WINPR_THREAD_POOL
|
||||
PTP_WORK CreateThreadpoolWork(PTP_WORK_CALLBACK pfnwk, PVOID pv, PTP_CALLBACK_ENVIRON pcbe)
|
||||
{
|
||||
PTP_WORK work = NULL;
|
||||
@ -153,3 +154,4 @@ VOID WaitForThreadpoolWorkCallbacks(PTP_WORK pwk, BOOL fCancelPendingCallbacks)
|
||||
printf("WaitForThreadpoolWorkCallbacks: error waiting on work completion\n");
|
||||
#endif
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user