From a83889ef3bc93e68becaccc46fb22b78d459b418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Fru=C5=BCy=C5=84ski?= Date: Fri, 30 Dec 2016 19:49:12 +0100 Subject: [PATCH 1/2] Fixed compilation using MinGW from Cygwin 32 and 64 bit --- lib/diagnostics.cpp | 4 ++-- lib/diagnostics_win.cpp | 6 +++--- lib/diagnostics_win.h | 4 ++++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/diagnostics.cpp b/lib/diagnostics.cpp index cdcc632ec3..93fd9b2387 100644 --- a/lib/diagnostics.cpp +++ b/lib/diagnostics.cpp @@ -371,8 +371,8 @@ int diagnostics_init( #if defined(_WIN32) //_set_abort_behavior(NULL, _WRITE_ABORT_MSG); - set_terminate(boinc_term_func); - set_unexpected(boinc_term_func); + std::set_terminate(boinc_term_func); + std::set_unexpected(boinc_term_func); #if defined(_DEBUG) diff --git a/lib/diagnostics_win.cpp b/lib/diagnostics_win.cpp index 9e181c9259..838afbf53a 100644 --- a/lib/diagnostics_win.cpp +++ b/lib/diagnostics_win.cpp @@ -312,7 +312,7 @@ int diagnostics_update_thread_list() { // Enumerate the threads for(uiSystemIndex = 0; uiSystemIndex < pProcesses->ThreadCount; uiSystemIndex++) { pThread = &pProcesses->Threads[uiSystemIndex]; - pThreadEntry = diagnostics_find_thread_entry((DWORD)pThread->ClientId.UniqueThread); + pThreadEntry = diagnostics_find_thread_entry((DWORD)(uintptr_t)pThread->ClientId.UniqueThread); if (pThreadEntry) { pThreadEntry->crash_kernel_time = (FLOAT)pThread->KernelTime.QuadPart; @@ -326,12 +326,12 @@ int diagnostics_update_thread_list() { hThread = OpenThread( THREAD_ALL_ACCESS, FALSE, - (DWORD)(pThread->ClientId.UniqueThread) + (DWORD)(uintptr_t)(pThread->ClientId.UniqueThread) ); pThreadEntry = new BOINC_THREADLISTENTRY; diagnostics_init_thread_entry(pThreadEntry); - pThreadEntry->thread_id = (DWORD)(pThread->ClientId.UniqueThread); + pThreadEntry->thread_id = (DWORD)(uintptr_t)(pThread->ClientId.UniqueThread); pThreadEntry->thread_handle = hThread; pThreadEntry->crash_kernel_time = (FLOAT)pThread->KernelTime.QuadPart; pThreadEntry->crash_user_time = (FLOAT)pThread->UserTime.QuadPart; diff --git a/lib/diagnostics_win.h b/lib/diagnostics_win.h index 82af90d14a..e81a8767fe 100644 --- a/lib/diagnostics_win.h +++ b/lib/diagnostics_win.h @@ -27,6 +27,7 @@ typedef LONG NTSTATUS; typedef LONG KPRIORITY; //MinGW-W64 defines this struct in its own header +#define HAVE_CLIENT_ID 1 #ifndef HAVE_CLIENT_ID typedef struct _CLIENT_ID { DWORD UniqueProcess; @@ -35,6 +36,7 @@ typedef struct _CLIENT_ID { #endif //MinGW-W64 defines this struct in its own header +#define HAVE_VM_COUNTERS 1 #ifndef HAVE_VM_COUNTERS typedef struct _VM_COUNTERS { #ifdef _WIN64 @@ -67,6 +69,7 @@ typedef struct _VM_COUNTERS { #endif //MinGW-W64 defines this struct in its own header +#define HAVE_SYSTEM_THREADS 1 #ifndef HAVE_SYSTEM_THREADS typedef struct _SYSTEM_THREADS { LARGE_INTEGER KernelTime; @@ -112,6 +115,7 @@ typedef struct _SYSTEM_PROCESSES { #endif //MinGW-W64 defines this struct in its own header +#define HAVE_THREAD_STATE 1 #ifndef HAVE_THREAD_STATE typedef enum _THREAD_STATE { StateInitialized, From 5dbd9d2a19540c932134325320650b21ebebcf77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Fru=C5=BCy=C5=84ski?= Date: Sat, 31 Dec 2016 12:01:28 +0100 Subject: [PATCH 2/2] Include new changes conditionally for MinGW only to not break MSVC build --- lib/diagnostics.cpp | 5 +++++ lib/diagnostics_win.h | 12 ++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/diagnostics.cpp b/lib/diagnostics.cpp index 93fd9b2387..fddd6ca367 100644 --- a/lib/diagnostics.cpp +++ b/lib/diagnostics.cpp @@ -371,8 +371,13 @@ int diagnostics_init( #if defined(_WIN32) //_set_abort_behavior(NULL, _WRITE_ABORT_MSG); +#ifdef __MINGW32__ std::set_terminate(boinc_term_func); std::set_unexpected(boinc_term_func); +#else + set_terminate(boinc_term_func); + set_unexpected(boinc_term_func); +#endif #if defined(_DEBUG) diff --git a/lib/diagnostics_win.h b/lib/diagnostics_win.h index e81a8767fe..a6f6a5fc2e 100644 --- a/lib/diagnostics_win.h +++ b/lib/diagnostics_win.h @@ -27,8 +27,7 @@ typedef LONG NTSTATUS; typedef LONG KPRIORITY; //MinGW-W64 defines this struct in its own header -#define HAVE_CLIENT_ID 1 -#ifndef HAVE_CLIENT_ID +#if !defined(HAVE_CLIENT_ID) && !defined(__MINGW32__) typedef struct _CLIENT_ID { DWORD UniqueProcess; DWORD UniqueThread; @@ -36,8 +35,7 @@ typedef struct _CLIENT_ID { #endif //MinGW-W64 defines this struct in its own header -#define HAVE_VM_COUNTERS 1 -#ifndef HAVE_VM_COUNTERS +#if !defined(HAVE_VM_COUNTERS) && !defined(__MINGW32__) typedef struct _VM_COUNTERS { #ifdef _WIN64 // the following was inferred by painful reverse engineering @@ -69,8 +67,7 @@ typedef struct _VM_COUNTERS { #endif //MinGW-W64 defines this struct in its own header -#define HAVE_SYSTEM_THREADS 1 -#ifndef HAVE_SYSTEM_THREADS +#if !defined(HAVE_SYSTEM_THREADS) && !defined(__MINGW32__) typedef struct _SYSTEM_THREADS { LARGE_INTEGER KernelTime; LARGE_INTEGER UserTime; @@ -115,8 +112,7 @@ typedef struct _SYSTEM_PROCESSES { #endif //MinGW-W64 defines this struct in its own header -#define HAVE_THREAD_STATE 1 -#ifndef HAVE_THREAD_STATE +#if !defined(HAVE_THREAD_STATE) && !defined(__MINGW32__) typedef enum _THREAD_STATE { StateInitialized, StateReady,