Added implementation for wxLocaltime_r/wxGmtime_r.
Improved handling of windows compilers. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36438 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -169,6 +169,36 @@ wxCUSTOM_TYPE_INFO(wxDateTime, wxToStringConverter<wxDateTime> , wxFromStringCon
|
||||
#endif
|
||||
#endif // !WX_TIMEZONE && !WX_GMTOFF_IN_TM
|
||||
|
||||
#if wxUSE_THREADS
|
||||
static wxMutex timeLock;
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_LOCALTIME_R
|
||||
struct tm *wxLocaltime_r(const time_t* ticks, struct tm* temp)
|
||||
{
|
||||
#if wxUSE_THREADS && !defined(__WINDOWS__)
|
||||
// No need to waste time with a mutex on windows since it's using
|
||||
// thread local storage for localtime anyway.
|
||||
wxMutexLocker(timeLock);
|
||||
#endif
|
||||
memcpy(temp, localtime(ticks), sizeof(struct tm));
|
||||
return temp;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_GMTIME_R
|
||||
struct tm *wxGmtime_r(const time_t* ticks, struct tm* temp)
|
||||
{
|
||||
#if wxUSE_THREADS && !defined(__WINDOWS__)
|
||||
// No need to waste time with a mutex on windows since it's
|
||||
// using thread local storage for gmtime anyway.
|
||||
wxMutexLocker(timeLock);
|
||||
#endif
|
||||
memcpy(temp, gmtime(ticks), sizeof(struct tm));
|
||||
return temp;
|
||||
}
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// macros
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user