Skip to content

Commit

Permalink
Fix MINGW gmtime_r() segfault and move to compat.h
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-kristjansson committed Aug 23, 2011
1 parent c7b18db commit 77d0b59
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
15 changes: 15 additions & 0 deletions mythtv/libs/libmythbase/compat.h
Expand Up @@ -245,6 +245,21 @@ inline const char *dlerror(void)
#define setuid(x)
#endif // USING_MINGW

#if defined(USING_MINGW)
static inline struct tm *gmtime_r(const time_t *timep, struct tm *result)
{
// this is safe on windows, where gmtime uses a thread local variable.
// using _gmtime_s() would be better, but needs to be tested on windows.
struct tm *tmp = gmtime(timep);
if (tmp)
{
*result = *tmp;
return result;
}
return NULL;
}
#endif

#ifdef USING_MINGW
#define timeradd(a, b, result) \
do { \
Expand Down
7 changes: 1 addition & 6 deletions mythtv/libs/libmythtv/eithelper.cpp
Expand Up @@ -20,12 +20,7 @@ using namespace std;
#include "util.h"
#include "programdata.h"
#include "programinfo.h" // for subtitle types and audio and video properties

#ifdef USING_MINGW
#define gmtime_r( _clock, _result ) \
( *(_result) = *gmtime( (_clock) ), \
(_result) )
#endif
#include "compat.h" // for gmtime_r on windows.

const uint EITHelper::kChunkSize = 20;
EITCache *EITHelper::eitcache = new EITCache();
Expand Down

0 comments on commit 77d0b59

Please sign in to comment.