summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorstijn <stinos@zoho.com>2014-05-10 10:42:40 +0200
committerstijn <stinos@zoho.com>2014-05-10 10:42:40 +0200
commitf45a83d7fc964b10acc5d7d0da65a8157489562f (patch)
tree427c6866161257e06465e77a9bba378c97c142fc
parent6e8085b425a9d02ac3e204651e2c9d8de9a23a85 (diff)
downloadmicropython-f45a83d7fc964b10acc5d7d0da65a8157489562f.tar.gz
micropython-f45a83d7fc964b10acc5d7d0da65a8157489562f.zip
mingw: Fix compilation issues
- use lowercase windows.h - fix for mingw32 using preprocessor-unfriendly definition of CLOCKS_PER_SEC
-rw-r--r--unix/modtime.c14
-rw-r--r--windows/init.c2
-rw-r--r--windows/sleep.c2
3 files changed, 14 insertions, 4 deletions
diff --git a/unix/modtime.c b/unix/modtime.c
index c497763bf3..77d2945b8f 100644
--- a/unix/modtime.c
+++ b/unix/modtime.c
@@ -45,9 +45,19 @@ void msec_sleep_tv(struct timeval *tv) {
#define sleep_select select
#endif
-#if CLOCKS_PER_SEC == 1000000 // POSIX
+// mingw32 defines CLOCKS_PER_SEC as ((clock_t)<somevalue>) but preprocessor does not handle casts
+#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
+#define MP_REMOVE_BRACKETSA(x)
+#define MP_REMOVE_BRACKETSB(x) MP_REMOVE_BRACKETSA x
+#define MP_REMOVE_BRACKETSC(x) MP_REMOVE_BRACKETSB x
+#define MP_CLOCKS_PER_SEC MP_REMOVE_BRACKETSC(CLOCKS_PER_SEC)
+#else
+#define MP_CLOCKS_PER_SEC CLOCKS_PER_SEC
+#endif
+
+#if defined(MP_CLOCKS_PER_SEC) && (MP_CLOCKS_PER_SEC == 1000000) // POSIX
#define CLOCK_DIV 1000.0
-#elif CLOCKS_PER_SEC == 1000 // WIN32
+#elif defined(MP_CLOCKS_PER_SEC) && (MP_CLOCKS_PER_SEC == 1000) // WIN32
#define CLOCK_DIV 1.0
#else
#error Unsupported clock() implementation
diff --git a/windows/init.c b/windows/init.c
index 69f1026bb2..a370c464e8 100644
--- a/windows/init.c
+++ b/windows/init.c
@@ -26,7 +26,7 @@
#include <stdlib.h>
#include <stdio.h>
-#include <Windows.h>
+#include <windows.h>
HANDLE hSleepEvent = NULL;
diff --git a/windows/sleep.c b/windows/sleep.c
index 98387350f0..a7e5125e5b 100644
--- a/windows/sleep.c
+++ b/windows/sleep.c
@@ -24,7 +24,7 @@
* THE SOFTWARE.
*/
-#include <Windows.h>
+#include <windows.h>
extern HANDLE hSleepEvent;