[PATCH] mingw32 cross-compilation tweaks

Paul Fertser fercerpav at gmail.com
Thu Dec 16 09:48:07 UTC 2010


This adds defines for usleep (windows lacks that) and also missing
define for SVC_EVENT.
---
 clients/upsclient.h       |    4 ++++
 clients/upsmon.c          |    1 +
 clients/upssched.c        |    1 +
 drivers/main.h            |    1 +
 scripts/Windows/wininit.c |    1 +
 5 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/clients/upsclient.h b/clients/upsclient.h
index 6e23971..9edda90 100644
--- a/clients/upsclient.h
+++ b/clients/upsclient.h
@@ -25,6 +25,10 @@
 #include <openssl/ssl.h>
 #endif
 
+#ifdef WIN32
+#define usleep(n) Sleep(n / 1000)
+#endif
+
 #ifdef __cplusplus
 /* *INDENT-OFF* */
 extern "C" {
diff --git a/clients/upsmon.c b/clients/upsmon.c
index 0248617..ee11324 100644
--- a/clients/upsmon.c
+++ b/clients/upsmon.c
@@ -26,6 +26,7 @@
 #else
 #include <winsock2.h>
 #define sleep(n) Sleep(1000 * n)
+#define usleep(n) Sleep(n / 1000)
 #endif
 
 #include "upsclient.h"
diff --git a/clients/upssched.c b/clients/upssched.c
index 7daf1f9..73e9341 100644
--- a/clients/upssched.c
+++ b/clients/upssched.c
@@ -50,6 +50,7 @@
 #else
 #include <winsock2.h>
 #include <ws2tcpip.h>
+#define usleep(n) Sleep(n / 1000)
 #endif
 
 #include "upssched.h"
diff --git a/drivers/main.h b/drivers/main.h
index 882fe6a..a4ef221 100644
--- a/drivers/main.h
+++ b/drivers/main.h
@@ -8,6 +8,7 @@
 
 #ifdef WIN32
 #define sleep(a) Sleep(a*1000)
+#define usleep(n) Sleep(n / 1000)
 #define strtok_r(a,b,c) strtok(a,b)
 #endif
 
diff --git a/scripts/Windows/wininit.c b/scripts/Windows/wininit.c
index b4f136c..862699c 100644
--- a/scripts/Windows/wininit.c
+++ b/scripts/Windows/wininit.c
@@ -44,6 +44,7 @@ static BOOL			service_flag = TRUE;
 HANDLE				svc_stop = NULL;
 static SERVICE_STATUS		SvcStatus;
 static SERVICE_STATUS_HANDLE	SvcStatusHandle;
+#define SVC_EVENT                        ((DWORD)0xC0020001L)
 
 static void print_event(DWORD priority, const char * string)
 {
-- 
1.5.6.5

Thanks again and happy hacking :)

-- 
Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software!
mailto:fercerpav at gmail.com



More information about the Nut-upsdev mailing list