summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorshirosaki <shirosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-28 07:36:51 +0000
committershirosaki <shirosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-28 07:36:51 +0000
commitce2a1e109c10d28f6f6908aff3a8b3209a77c5bb (patch)
tree32807e1699746d69e023dd131516511b332059c0 /win32
parentc1ef657b39c153f49660c15f88c31645a710cb98 (diff)
win32/win32.c: fix localtime_r() on x64-mingw
* win32/win32.c (gmtime_r): use _gmtime64_s() with x86_64-w64-mingw32. * win32/win32.c (localtime_r): use _localtime64_s() with x86_64-w64-mingw32. Since FileTimeToSystemTime() seems not work with large value under x64. Mingw-w64 doesn't have these declaration. [ruby-core:46780] [Bug #6794] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r--win32/win32.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/win32/win32.c b/win32/win32.c
index f330ee1591..c48979d913 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -6555,7 +6555,7 @@ rb_w32_fd_is_text(int fd) {
return _osfile(fd) & FTEXT;
}
-#if RUBY_MSVCRT_VERSION < 80
+#if RUBY_MSVCRT_VERSION < 80 && !defined(__MINGW64__)
/* License: Ruby's */
static int
unixtime_to_systemtime(const time_t t, SYSTEMTIME *st)
@@ -6617,6 +6617,17 @@ systemtime_to_localtime(TIME_ZONE_INFORMATION *tz, SYSTEMTIME *gst, SYSTEMTIME *
}
#endif
+#ifdef __MINGW64__
+#ifndef gmtime_s
+# define gmtime_s _gmtime64_s
+ errno_t gmtime_s(struct tm* _tm, const time_t *time);
+#endif
+#ifndef localtime_s
+# define localtime_s _localtime64_s
+ errno_t localtime_s(struct tm* _tm, const time_t *time);
+#endif
+#endif
+
/* License: Ruby's */
struct tm *
gmtime_r(const time_t *tp, struct tm *rp)
@@ -6627,7 +6638,7 @@ gmtime_r(const time_t *tp, struct tm *rp)
errno = e;
return NULL;
}
-#if RUBY_MSVCRT_VERSION >= 80
+#if RUBY_MSVCRT_VERSION >= 80 || defined(__MINGW64__)
e = gmtime_s(rp, tp);
if (e != 0) goto error;
#else
@@ -6651,7 +6662,7 @@ localtime_r(const time_t *tp, struct tm *rp)
errno = e;
return NULL;
}
-#if RUBY_MSVCRT_VERSION >= 80
+#if RUBY_MSVCRT_VERSION >= 80 || defined(__MINGW64__)
e = localtime_s(rp, tp);
if (e) goto error;
#else