summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-time
diff options
context:
space:
mode:
authormattn <[email protected]>2014-03-06 19:57:22 +0900
committermattn <[email protected]>2014-03-06 19:57:22 +0900
commita9ac721e38efdb6eccb0b3d010cde2e5ddbf7624 (patch)
treefa076f7fc47a122e177ea64f1d0bc4ea9bafbe54 /mrbgems/mruby-time
parent50974614ec8fdcfb644c6897605bca565bf01533 (diff)
downloadmruby-a9ac721e38efdb6eccb0b3d010cde2e5ddbf7624.tar.gz
mruby-a9ac721e38efdb6eccb0b3d010cde2e5ddbf7624.zip
Fix build on mingw32
Diffstat (limited to 'mrbgems/mruby-time')
-rw-r--r--mrbgems/mruby-time/src/time.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/mrbgems/mruby-time/src/time.c b/mrbgems/mruby-time/src/time.c
index 61466f05e..3ba3c66ba 100644
--- a/mrbgems/mruby-time/src/time.c
+++ b/mrbgems/mruby-time/src/time.c
@@ -45,6 +45,13 @@
# define WIN32_LEAN_AND_MEAN /* don't include winsock.h */
# include <windows.h>
# define gettimeofday my_gettimeofday
+
+# ifdef _MSC_VER
+# define UI64(x) x##ui64
+# else
+# define UI64(x) x##ull
+# endif
+
typedef long suseconds_t;
struct timeval {
time_t tv_sec;
@@ -62,7 +69,7 @@ gettimeofday(struct timeval *tv, void *tz)
unsigned __int64 u64;
} t;
GetSystemTimeAsFileTime(&t.ft); /* 100 ns intervals since Windows epoch */
- t.u64 -= 116444736000000000ui64; /* Unix epoch bias */
+ t.u64 -= UI64(116444736000000000); /* Unix epoch bias */
t.u64 /= 10; /* to microseconds */
tv->tv_sec = (time_t)(t.u64 / (1000 * 1000));
tv->tv_usec = t.u64 % 1000 * 1000;