1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

win32/win32.c: mingw jungle

* configure.in: let mingw do something black-magic, and check if
  _gmtime64_s() is available actually.
* win32/win32.c (gmtime_s, localtime_s): use _gmtime64_s() and
  _localtime64_s() if available, not depending on very confusing
  mingw variants macros.  based on the patch by phasis68 (Heesob
  Park) at [ruby-core:58764].  [ruby-core:58391] [Bug #9119]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-12-25 04:00:59 +00:00
parent cf0540cf55
commit 58a7cdaaf0
3 changed files with 20 additions and 4 deletions

View file

@ -1,3 +1,13 @@
Wed Dec 25 13:00:54 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in: let mingw do something black-magic, and check if
_gmtime64_s() is available actually.
* win32/win32.c (gmtime_s, localtime_s): use _gmtime64_s() and
_localtime64_s() if available, not depending on very confusing
mingw variants macros. based on the patch by phasis68 (Heesob
Park) at [ruby-core:58764]. [ruby-core:58391] [Bug #9119]
Wed Dec 25 12:33:41 2013 Yusuke Endoh <mame@tsg.ne.jp> Wed Dec 25 12:33:41 2013 Yusuke Endoh <mame@tsg.ne.jp>
* sample/trick2013/: added the award-winning entries of TRICK 2013. * sample/trick2013/: added the award-winning entries of TRICK 2013.

View file

@ -888,6 +888,7 @@ AC_ARG_WITH(winnt-ver,
AS_CASE(["$target_os"], AS_CASE(["$target_os"],
[mingw*], [ [mingw*], [
RUBY_APPEND_OPTION(CPPFLAGS, -D_WIN32_WINNT=$with_winnt_ver) RUBY_APPEND_OPTION(CPPFLAGS, -D_WIN32_WINNT=$with_winnt_ver)
RUBY_APPEND_OPTION(CPPFLAGS, -D__MINGW_USE_VC2005_COMPAT)
]) ])
AS_CASE(["$target_os"], AS_CASE(["$target_os"],
@ -1040,6 +1041,7 @@ main()
if test x"$ac_cv_type_NET_LUID" = xyes; then if test x"$ac_cv_type_NET_LUID" = xyes; then
AC_DEFINE(HAVE_TYPE_NET_LUID, 1) AC_DEFINE(HAVE_TYPE_NET_LUID, 1)
fi fi
AC_CHECK_FUNCS(_gmtime64_s)
AC_LIBOBJ([langinfo]) AC_LIBOBJ([langinfo])
], ],
[os2-emx*], [ LIBS="-lm $LIBS" [os2-emx*], [ LIBS="-lm $LIBS"

View file

@ -6965,7 +6965,7 @@ rb_w32_fd_is_text(int fd)
return _osfile(fd) & FTEXT; return _osfile(fd) & FTEXT;
} }
#if RUBY_MSVCRT_VERSION < 80 && !defined(__MINGW64__) #if RUBY_MSVCRT_VERSION < 80 && !defined(HAVE__GMTIME64_S)
/* License: Ruby's */ /* License: Ruby's */
static int static int
unixtime_to_systemtime(const time_t t, SYSTEMTIME *st) unixtime_to_systemtime(const time_t t, SYSTEMTIME *st)
@ -7027,7 +7027,11 @@ systemtime_to_localtime(TIME_ZONE_INFORMATION *tz, SYSTEMTIME *gst, SYSTEMTIME *
} }
#endif #endif
#ifdef __MINGW64__ #ifdef HAVE__GMTIME64_S
# ifndef HAVE__LOCALTIME64_S
/* assume same as _gmtime64_s() */
# define HAVE__LOCALTIME64_S 1
# endif
# ifndef MINGW_HAS_SECURE_API # ifndef MINGW_HAS_SECURE_API
_CRTIMP errno_t __cdecl _gmtime64_s(struct tm* tm, const __time64_t *time); _CRTIMP errno_t __cdecl _gmtime64_s(struct tm* tm, const __time64_t *time);
_CRTIMP errno_t __cdecl _localtime64_s(struct tm* tm, const __time64_t *time); _CRTIMP errno_t __cdecl _localtime64_s(struct tm* tm, const __time64_t *time);
@ -7046,7 +7050,7 @@ gmtime_r(const time_t *tp, struct tm *rp)
errno = e; errno = e;
return NULL; return NULL;
} }
#if RUBY_MSVCRT_VERSION >= 80 || defined(__MINGW64__) #if RUBY_MSVCRT_VERSION >= 80 || defined(HAVE__GMTIME64_S)
e = gmtime_s(rp, tp); e = gmtime_s(rp, tp);
if (e != 0) goto error; if (e != 0) goto error;
#else #else
@ -7070,7 +7074,7 @@ localtime_r(const time_t *tp, struct tm *rp)
errno = e; errno = e;
return NULL; return NULL;
} }
#if RUBY_MSVCRT_VERSION >= 80 || defined(__MINGW64__) #if RUBY_MSVCRT_VERSION >= 80 || defined(HAVE__LOCALTIME64_S)
e = localtime_s(rp, tp); e = localtime_s(rp, tp);
if (e) goto error; if (e) goto error;
#else #else