use gmtime_r if there

This commit is contained in:
toddouska
2015-11-09 14:48:39 -08:00
parent 756feb37f5
commit 417f85da86
2 changed files with 9 additions and 3 deletions

View File

@ -70,6 +70,7 @@ m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
AC_CHECK_FUNCS([gethostbyname]) AC_CHECK_FUNCS([gethostbyname])
AC_CHECK_FUNCS([getaddrinfo]) AC_CHECK_FUNCS([getaddrinfo])
AC_CHECK_FUNCS([gettimeofday]) AC_CHECK_FUNCS([gettimeofday])
AC_CHECK_FUNCS([gmtime_r])
AC_CHECK_FUNCS([inet_ntoa]) AC_CHECK_FUNCS([inet_ntoa])
AC_CHECK_FUNCS([memset]) AC_CHECK_FUNCS([memset])
AC_CHECK_FUNCS([socket]) AC_CHECK_FUNCS([socket])

View File

@ -200,7 +200,12 @@
/* uses complete <time.h> facility */ /* uses complete <time.h> facility */
#include <time.h> #include <time.h>
#define XTIME(tl) time((tl)) #define XTIME(tl) time((tl))
#define XGMTIME(c, t) gmtime((c)) #ifdef HAVE_GMTIME_R
#define XGMTIME(c, t) gmtime_r((c), (t))
#define NEED_TMP_TIME
#else
#define XGMTIME(c, t) gmtime((c))
#endif
#define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t)) #define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t))
#endif #endif
@ -2558,7 +2563,7 @@ int ValidateDate(const byte* date, byte format, int dateType)
int diffHH = 0 ; int diffMM = 0 ; int diffHH = 0 ; int diffMM = 0 ;
int diffSign = 0 ; int diffSign = 0 ;
#if defined(FREESCALE_MQX) || defined(TIME_OVERRIDES) #if defined(FREESCALE_MQX) || defined(TIME_OVERRIDES) || defined(NEED_TMP_TIME)
struct tm tmpTimeStorage; struct tm tmpTimeStorage;
tmpTime = &tmpTimeStorage; tmpTime = &tmpTimeStorage;
#else #else
@ -5754,7 +5759,7 @@ static int SetValidity(byte* output, int daysValid)
struct tm* tmpTime = NULL; struct tm* tmpTime = NULL;
struct tm local; struct tm local;
#if defined(FREESCALE_MQX) || defined(TIME_OVERRIDES) #if defined(FREESCALE_MQX) || defined(TIME_OVERRIDES) || defined(NEED_TMP_TIME)
/* for use with gmtime_r */ /* for use with gmtime_r */
struct tm tmpTimeStorage; struct tm tmpTimeStorage;
tmpTime = &tmpTimeStorage; tmpTime = &tmpTimeStorage;