aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4dateobject.cpp
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@digia.com>2013-11-07 09:08:05 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-08 12:31:03 +0100
commit8078e2ea1350fd5109074a2be7207d75840e57f7 (patch)
tree2633207e06960251114fdc05acde3567d07eccc8 /src/qml/jsruntime/qv4dateobject.cpp
parentc286b4fccb2d83fcc01b21913b95c5e4f21f2982 (diff)
Generalize check for localtime_r
Use the _POSIX_THREAD_SAFE_FUNCTIONS define to decide whether localtime_r is available, instead of guessing by Mingw-w64 version. This copies the logic of qdatetime.cpp in qtbase, and should fix compilations with older Mingw-w64 versions. It replaces ce3e8f93c. Task-number: QTBUG-34038 Change-Id: Iee8a9aa61d2af3e069e6365c40f81007c479d147 Reviewed-by: Mark Brand <mabrand@mabrand.nl> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4dateobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4dateobject.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp
index 462210adae..aee4917842 100644
--- a/src/qml/jsruntime/qv4dateobject.cpp
+++ b/src/qml/jsruntime/qv4dateobject.cpp
@@ -295,16 +295,16 @@ static inline double DaylightSavingTA(double t)
__time64_t tt = (__time64_t)(t / msPerSecond);
// _localtime_64_s returns non-zero on failure
if (_localtime64_s(&tmtm, &tt) != 0)
-#elif defined(Q_CC_MINGW) && !defined(__MINGW64_VERSION_MAJOR)
- // mingw.org headers do not define localtime_r.
- // luckily Windows localtime() is thread safe.
+#elif !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
+ long int tt = (long int)(t / msPerSecond);
+ if (!localtime_r((const time_t*) &tt, &tmtm))
+#else
+ // Returns shared static data which may be overwritten at any time
+ // (for MinGW/Windows localtime is luckily thread safe)
long int tt = (long int)(t / msPerSecond);
if (struct tm *tmtm_p = localtime((const time_t*) &tt))
tmtm = *tmtm_p;
else
-#else
- long int tt = (long int)(t / msPerSecond);
- if (!localtime_r((const time_t*) &tt, &tmtm))
#endif
return 0;
return (tmtm.tm_isdst > 0) ? msPerHour : 0;