[commit: packages/time] format-widths, ghc, improve-leapseconds, master, posix-perf, tasty, wip/travis: Use `_tzset()` for non-POSIX Windows environments (9f12261)

git at git.haskell.org git at git.haskell.org
Fri Apr 21 16:53:00 UTC 2017


Repository : ssh://git@git.haskell.org/time

On branches: format-widths,ghc,improve-leapseconds,master,posix-perf,tasty,wip/travis
Link       : http://git.haskell.org/packages/time.git/commitdiff/9f12261f5e81f70a50f29f0a43d487070cfa1ab4

>---------------------------------------------------------------

commit 9f12261f5e81f70a50f29f0a43d487070cfa1ab4
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date:   Sun Oct 12 10:26:50 2014 +0200

    Use `_tzset()` for non-POSIX Windows environments
    
    When compiling with MinGW (which does not provide a full POSIX layer as
    opposed to CygWin) it's better to use the CRT's underscore-prefixed
    `_tzset()` variant to avoid linker issues as Microsoft considers the
    POSIX named `tzset()` function deprecated
    
    Further reading
    
     - http://msdn.microsoft.com/en-us/library/ms235384.aspx
     - http://stackoverflow.com/questions/23477746/what-are-the-posix-like-functions-in-msvcs-c-runtime
    
    This hopefully addresses #2


>---------------------------------------------------------------

9f12261f5e81f70a50f29f0a43d487070cfa1ab4
 lib/cbits/HsTime.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lib/cbits/HsTime.c b/lib/cbits/HsTime.c
index 646fac6..e2be98a 100644
--- a/lib/cbits/HsTime.c
+++ b/lib/cbits/HsTime.c
@@ -3,7 +3,17 @@
 
 long int get_current_timezone_seconds (time_t t,int* pdst,char const* * pname)
 {
+#if defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32)
+    // When compiling with MinGW (which does not provide a full POSIX
+    // layer as opposed to CygWin) it's better to use the CRT's
+    // underscore-prefixed `_tzset()` variant to avoid linker issues
+    // as Microsoft considers the POSIX named `tzset()` function
+    // deprecated (see http://msdn.microsoft.com/en-us/library/ms235384.aspx)
+    _tzset();
+#else
     tzset();
+#endif
+
 #if HAVE_LOCALTIME_R
     struct tm tmd;
     struct tm* ptm = localtime_r(&t,&tmd);



More information about the ghc-commits mailing list