mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-01 03:34:39 +02:00
wolfcrypt/src/wc_port.c, wolfssl/wolfcrypt/wc_port.h: refactor WOLFSSL_GMTIME gmtime() into gmtime_r(), and always define HAVE_GMTIME_R when defined(WOLFSSL_GMTIME).
This commit is contained in:
@@ -2922,7 +2922,7 @@ time_t mynewt_time(time_t* timer)
|
||||
#endif /* WOLFSSL_APACHE_MYNEWT */
|
||||
|
||||
#if defined(WOLFSSL_GMTIME)
|
||||
struct tm* gmtime(const time_t* timer)
|
||||
struct tm* gmtime_r(const time_t* timer, struct tm *ret)
|
||||
{
|
||||
#define YEAR0 1900
|
||||
#define EPOCH_YEAR 1970
|
||||
@@ -2936,8 +2936,6 @@ struct tm* gmtime(const time_t* timer)
|
||||
{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
|
||||
};
|
||||
|
||||
static struct tm st_time;
|
||||
struct tm* ret = &st_time;
|
||||
time_t secs = *timer;
|
||||
unsigned long dayclock, dayno;
|
||||
int year = EPOCH_YEAR;
|
||||
@@ -2971,6 +2969,12 @@ struct tm* gmtime(const time_t* timer)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct tm* gmtime(const time_t* timer) {
|
||||
static struct tm st_time;
|
||||
return gmtime_r(timer, &st_time);
|
||||
}
|
||||
|
||||
#endif /* WOLFSSL_GMTIME */
|
||||
|
||||
|
||||
|
@@ -1063,6 +1063,11 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
|
||||
#define XTIME(tl) time((tl))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(WOLFSSL_GMTIME) && !defined(HAVE_GMTIME_R)
|
||||
#define HAVE_GMTIME_R
|
||||
#endif
|
||||
|
||||
#if !defined(XGMTIME) && !defined(TIME_OVERRIDES)
|
||||
/* Always use gmtime_r if available. */
|
||||
#if defined(HAVE_GMTIME_S)
|
||||
@@ -1128,8 +1133,9 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
|
||||
extern struct tm* XGMTIME(const time_t* timer, struct tm* tmp);
|
||||
#elif defined(WOLFSSL_GMTIME)
|
||||
struct tm* gmtime(const time_t* timer);
|
||||
struct tm* gmtime_r(const time_t* timer, struct tm *ret);
|
||||
#endif
|
||||
#endif /* NO_ASN_TIME */
|
||||
#endif /* !NO_ASN_TIME */
|
||||
|
||||
|
||||
#ifndef WOLFSSL_LEANPSK
|
||||
|
Reference in New Issue
Block a user