[boinc_dev] [PATCH] MinGW lib build currently broken

2014-04-28 Thread Timo Strunk

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 timo.str...@gmail.com
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 timo.str...@gmail.com
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 

Re: [boinc_dev] [PATCH] MinGW lib build currently broken

2014-04-28 Thread Josef W. Segur

Thanks, I greatly appreciate your work to keep this open source project 
buildable with open source tools.
--
 Joe
___
boinc_dev mailing list
boinc_dev@ssl.berkeley.edu
http://lists.ssl.berkeley.edu/mailman/listinfo/boinc_dev
To unsubscribe, visit the above URL and
(near bottom of page) enter your email address.


Re: [boinc_dev] [PATCH] MinGW lib build currently broken

2014-04-28 Thread Rom Walton
I've applied patches 1, 3, and 4.

I need to investigate 2 a little bit more.  One of the first things
winsock.h does is pull in windows.h.  

Can you point me to the recommendation?

- Rom

-Original Message-
From: boinc_dev [mailto:boinc_dev-boun...@ssl.berkeley.edu] On Behalf Of
Timo Strunk
Sent: Monday, April 28, 2014 12:34 PM
To: boinc_dev@ssl.berkeley.edu
Subject: [boinc_dev] [PATCH] MinGW lib build currently broken

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

___
boinc_dev mailing list
boinc_dev@ssl.berkeley.edu
http://lists.ssl.berkeley.edu/mailman/listinfo/boinc_dev
To unsubscribe, visit the above URL and
(near bottom of page) enter your email address.