summaryrefslogtreecommitdiffstatshomepage
path: root/unix
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-05-11 15:06:26 +0100
committerDamien George <damien.p.george@gmail.com>2014-05-11 15:06:26 +0100
commitbd651d1a67e7f0876693f9d97f79463d412d1588 (patch)
tree087dcba9847a764add5a8a8f04cf9a3ccae3e6d8 /unix
parentc3dcb590b8d8557c9aafdf308c29f3815d600a9c (diff)
parentf45a83d7fc964b10acc5d7d0da65a8157489562f (diff)
downloadmicropython-bd651d1a67e7f0876693f9d97f79463d412d1588.tar.gz
micropython-bd651d1a67e7f0876693f9d97f79463d412d1588.zip
Merge pull request #597 from stinos/mingw-compilation
mingw: Fix compilation issues
Diffstat (limited to 'unix')
-rw-r--r--unix/modtime.c14
1 files changed, 12 insertions, 2 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