Hi everybody,
The commit afb6dcc6f3166f004327ec6fe32f39c577b40b38
"MGR & Client: Massive code clean-up. Remove as much of the
LoadLibrary[...]"
breaks MinGW compilation because of the line
#include <winternl.h>
The stock MinGW distribution does not carry this include, but the newer
MinGW-W64(http://sourceforge.net/apps/trac/mingw-w64/browser/trunk/mingw-w64-headers/include/winternl.h?rev=5224),
does. However also here the compilation fails with the commit.
We (Thomas Koch and me) therefore tried fixing this situation for MinGW-W64:
The problem is simply that MinGW-W64's winternl.h defines another
THREAD_STATE enum (also in diagnostics_win.h), which is similar to the
one of the BOINC lib, but has members, which carry different names.
The reason this is possible, is that there is no official THREAD_STATE
enum; Microsoft's implementation is a simple DWORD and some #defines for
the STATEs. (I'm definitely no expert on this, so I might be completely
wrong. I did not find any _official_ THREAD_STATE definition).
1.) As I think it will be really hard to change the naming of the MinGW
compiler, the attached patch changes the naming in the BOINC library and
does not define the enums in case of __MINGW32__ defines, as it relies
on the ones found in winternl.h.
In this way we don't change functionality in case of MSVC compiles
(please test, I only checked MinGW), but still allow compilation with
MinGW-W64. Another occurence happens in the installer directory, but I did
not touch this, because I think it's not intended to be MinGW
compatible anyways.
These are:
0001-Renamed-Thread_State-enum-names-to-mingw-standard-in.patch
0003-Renamed-StateWaiting-again-to-StateWait-as-per-mingw.patch
2.) The attached patches also include <delayimp.h> for MinGW, as it
seems to be required nowadays.
0004-MinGW-also-requires-delayimp-now.patch
This patch here is not required for making everything compile:
3.) winsock.h is now included prior to windows.h as recommended. Also
WIN32_LEAN_AND_MEAN is defined, because I saw no reason not to. If it is
defined somewhere else or even required to be absent and I didn't
notice, please remove it. It might not be good style to define it just
like that in a header.
0002-Include-winsock-before-windows.h.patch
With these 4 patches, mingw still doesn't compile using the supplied
makefile, but requires -fpermissive to be set. The reasons are multiple
deprecated string conversions.
After the commit mentioned at the beginning of the mail Windows 2000
support was dropped for the lib. Maybe the switch to Winsock2.h (Win98
and NT4 and upwards) and ws2tcpip.h (ipv6) should also be made now as
the code still seems to use winsock.h and it should be a simple change
of one include. However: Again, I'm no expert on the subject and there
might be good legacy reasons to keep everything as is.
Best,
Timo
>From 0d4767500f16aaee5a7c19bd4b2cdeabaff17931 Mon Sep 17 00:00:00 2001
From: Timo Strunk <[email protected]>
Date: Mon, 28 Apr 2014 17:35:16 +0200
Subject: [PATCH 4/4] MinGW also requires delayimp now
---
lib/boinc_win.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/lib/boinc_win.h b/lib/boinc_win.h
index 7ffbadc..95f5205 100644
--- a/lib/boinc_win.h
+++ b/lib/boinc_win.h
@@ -184,9 +184,14 @@ typedef LPCSTR PCTSTR, LPCTSTR, PCUTSTR, LPCUTSTR;
#if !defined(__MINGW32__) && !defined(__CYGWIN32__)
#include <crtdbg.h>
+#endif
+
+#if !defined(__CYGWIN32__)
#include <delayimp.h>
#endif
+
+
#ifdef __cplusplus
#include <algorithm>
#include <cassert>
--
1.9.1
>From ba77389e5aa1dfc1ae630f2423c0c1e74f2aa491 Mon Sep 17 00:00:00 2001
From: Timo Strunk <[email protected]>
Date: Mon, 28 Apr 2014 17:34:47 +0200
Subject: [PATCH 3/4] Renamed StateWaiting again to StateWait as per mingw-w64
---
lib/diagnostics_win.cpp | 4 ++--
lib/diagnostics_win.h | 15 ++++++++++++++-
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/lib/diagnostics_win.cpp b/lib/diagnostics_win.cpp
index 2b5c127..ebcf1ce 100644
--- a/lib/diagnostics_win.cpp
+++ b/lib/diagnostics_win.cpp
@@ -522,7 +522,7 @@ char* diagnostics_format_thread_state(int thread_state) {
case StateRunning: return "Running";
case StateStandby: return "Standby";
case StateTerminated: return "Terminated";
- case StateWaiting: return "Waiting";
+ case StateWait: return "Waiting";
case StateTransition: return "Transition";
default: return "Unknown";
}
@@ -1337,7 +1337,7 @@ int diagnostics_dump_process_information() {
int diagnostics_dump_thread_information(PBOINC_THREADLISTENTRY pThreadEntry) {
std::string strStatusExtra;
- if (pThreadEntry->crash_state == StateWaiting) {
+ if (pThreadEntry->crash_state == StateWait) {
strStatusExtra += "Wait Reason: ";
strStatusExtra += diagnostics_format_thread_wait_reason(pThreadEntry->crash_wait_reason);
strStatusExtra += ", ";
diff --git a/lib/diagnostics_win.h b/lib/diagnostics_win.h
index b2531e4..cf00c5e 100644
--- a/lib/diagnostics_win.h
+++ b/lib/diagnostics_win.h
@@ -20,17 +20,23 @@
#include "boinc_win.h"
+
#define STATUS_INFO_LENGTH_MISMATCH ((NTSTATUS)0xC0000004L)
typedef LONG NTSTATUS;
typedef LONG KPRIORITY;
+//MinGW-W64 defines this struct in its own header
+#ifndef __MINGW32__
typedef struct _CLIENT_ID {
DWORD UniqueProcess;
DWORD UniqueThread;
} CLIENT_ID;
+#endif
+//MinGW-W64 defines this struct in its own header
+#ifndef __MINGW32__
typedef struct _VM_COUNTERS {
#ifdef _WIN64
// the following was inferred by painful reverse engineering
@@ -59,7 +65,10 @@ typedef struct _VM_COUNTERS {
SIZE_T PeakPagefileUsage;
#endif
} VM_COUNTERS;
+#endif
+//MinGW-W64 defines this struct in its own header
+#ifndef __MINGW32__
typedef struct _SYSTEM_THREADS {
LARGE_INTEGER KernelTime;
LARGE_INTEGER UserTime;
@@ -73,6 +82,7 @@ typedef struct _SYSTEM_THREADS {
LONG State;
LONG WaitReason;
} SYSTEM_THREADS, * PSYSTEM_THREADS;
+#endif
typedef struct _SYSTEM_PROCESSES {
ULONG NextEntryDelta;
@@ -100,15 +110,18 @@ typedef struct _SYSTEM_PROCESSES {
SYSTEM_THREADS Threads[1];
} SYSTEM_PROCESSES, * PSYSTEM_PROCESSES;
+//MinGW-W64 defines this struct in its own header
+#ifndef __MINGW32__
typedef enum _THREAD_STATE {
StateInitialized,
StateReady,
StateRunning,
StateStandby,
StateTerminated,
- StateWaiting,
+ StateWait,
StateTransition
} THREAD_STATE, *PTHREAD_STATE;
+#endif
typedef enum _THREAD_WAIT_REASON {
ThreadWaitReasonExecutive,
--
1.9.1
>From 292b28b083bf8c8b4518c525ec6e7d002fa56649 Mon Sep 17 00:00:00 2001
From: Timo Strunk <[email protected]>
Date: Mon, 28 Apr 2014 17:21:16 +0200
Subject: [PATCH 2/4] Include winsock before windows.h
---
lib/boinc_win.h | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/lib/boinc_win.h b/lib/boinc_win.h
index 8772a11..7ffbadc 100644
--- a/lib/boinc_win.h
+++ b/lib/boinc_win.h
@@ -90,15 +90,7 @@
#define SECURITY_WIN32
#endif
-#include <windows.h>
-#include <winternl.h>
-#include <share.h>
-#include <shlobj.h>
-#include <userenv.h>
-#include <aclapi.h>
-#include <psapi.h>
-#include <iphlpapi.h>
-#include <wtsapi32.h>
+#define WIN32_LEAN_AND_MEAN
#if !defined(__CYGWIN32__) || defined(USE_WINSOCK)
@@ -128,6 +120,17 @@ typedef size_t socklen_t;
#endif
+#include <windows.h>
+#include <winternl.h>
+#include <share.h>
+#include <shlobj.h>
+#include <userenv.h>
+#include <aclapi.h>
+#include <psapi.h>
+#include <iphlpapi.h>
+#include <wtsapi32.h>
+
+
#include <process.h>
#if defined(__MINGW32__) || defined(__CYGWIN32__)
#include <pbt.h>
--
1.9.1
>From 4929729033d461ae5c05c41139791fd3e64dc3da Mon Sep 17 00:00:00 2001
From: Timo Strunk <[email protected]>
Date: Mon, 28 Apr 2014 16:40:37 +0200
Subject: [PATCH 1/4] Renamed Thread_State enum names to mingw standard in
winternl.h
---
lib/diagnostics_win.cpp | 16 ++++++++--------
lib/diagnostics_win.h | 14 +++++++-------
2 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/lib/diagnostics_win.cpp b/lib/diagnostics_win.cpp
index e0337b3..2b5c127 100644
--- a/lib/diagnostics_win.cpp
+++ b/lib/diagnostics_win.cpp
@@ -517,13 +517,13 @@ int diagnostics_set_thread_crash_message(char* message) {
//
char* diagnostics_format_thread_state(int thread_state) {
switch(thread_state) {
- case ThreadStateInitialized: return "Initialized";
- case ThreadStateReady: return "Ready";
- case ThreadStateRunning: return "Running";
- case ThreadStateStandby: return "Standby";
- case ThreadStateTerminated: return "Terminated";
- case ThreadStateWaiting: return "Waiting";
- case ThreadStateTransition: return "Transition";
+ case StateInitialized: return "Initialized";
+ case StateReady: return "Ready";
+ case StateRunning: return "Running";
+ case StateStandby: return "Standby";
+ case StateTerminated: return "Terminated";
+ case StateWaiting: return "Waiting";
+ case StateTransition: return "Transition";
default: return "Unknown";
}
return "";
@@ -1337,7 +1337,7 @@ int diagnostics_dump_process_information() {
int diagnostics_dump_thread_information(PBOINC_THREADLISTENTRY pThreadEntry) {
std::string strStatusExtra;
- if (pThreadEntry->crash_state == ThreadStateWaiting) {
+ if (pThreadEntry->crash_state == StateWaiting) {
strStatusExtra += "Wait Reason: ";
strStatusExtra += diagnostics_format_thread_wait_reason(pThreadEntry->crash_wait_reason);
strStatusExtra += ", ";
diff --git a/lib/diagnostics_win.h b/lib/diagnostics_win.h
index 666d080..b2531e4 100644
--- a/lib/diagnostics_win.h
+++ b/lib/diagnostics_win.h
@@ -101,13 +101,13 @@ typedef struct _SYSTEM_PROCESSES {
} SYSTEM_PROCESSES, * PSYSTEM_PROCESSES;
typedef enum _THREAD_STATE {
- ThreadStateInitialized,
- ThreadStateReady,
- ThreadStateRunning,
- ThreadStateStandby,
- ThreadStateTerminated,
- ThreadStateWaiting,
- ThreadStateTransition
+ StateInitialized,
+ StateReady,
+ StateRunning,
+ StateStandby,
+ StateTerminated,
+ StateWaiting,
+ StateTransition
} THREAD_STATE, *PTHREAD_STATE;
typedef enum _THREAD_WAIT_REASON {
--
1.9.1
_______________________________________________
boinc_dev mailing list
[email protected]
http://lists.ssl.berkeley.edu/mailman/listinfo/boinc_dev
To unsubscribe, visit the above URL and
(near bottom of page) enter your email address.