mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 12:14:38 +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 */
|
#endif /* WOLFSSL_APACHE_MYNEWT */
|
||||||
|
|
||||||
#if defined(WOLFSSL_GMTIME)
|
#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 YEAR0 1900
|
||||||
#define EPOCH_YEAR 1970
|
#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}
|
{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;
|
time_t secs = *timer;
|
||||||
unsigned long dayclock, dayno;
|
unsigned long dayclock, dayno;
|
||||||
int year = EPOCH_YEAR;
|
int year = EPOCH_YEAR;
|
||||||
@@ -2971,6 +2969,12 @@ struct tm* gmtime(const time_t* timer)
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct tm* gmtime(const time_t* timer) {
|
||||||
|
static struct tm st_time;
|
||||||
|
return gmtime_r(timer, &st_time);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* WOLFSSL_GMTIME */
|
#endif /* WOLFSSL_GMTIME */
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1063,6 +1063,11 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
|
|||||||
#define XTIME(tl) time((tl))
|
#define XTIME(tl) time((tl))
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(WOLFSSL_GMTIME) && !defined(HAVE_GMTIME_R)
|
||||||
|
#define HAVE_GMTIME_R
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(XGMTIME) && !defined(TIME_OVERRIDES)
|
#if !defined(XGMTIME) && !defined(TIME_OVERRIDES)
|
||||||
/* Always use gmtime_r if available. */
|
/* Always use gmtime_r if available. */
|
||||||
#if defined(HAVE_GMTIME_S)
|
#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);
|
extern struct tm* XGMTIME(const time_t* timer, struct tm* tmp);
|
||||||
#elif defined(WOLFSSL_GMTIME)
|
#elif defined(WOLFSSL_GMTIME)
|
||||||
struct tm* gmtime(const time_t* timer);
|
struct tm* gmtime(const time_t* timer);
|
||||||
|
struct tm* gmtime_r(const time_t* timer, struct tm *ret);
|
||||||
#endif
|
#endif
|
||||||
#endif /* NO_ASN_TIME */
|
#endif /* !NO_ASN_TIME */
|
||||||
|
|
||||||
|
|
||||||
#ifndef WOLFSSL_LEANPSK
|
#ifndef WOLFSSL_LEANPSK
|
||||||
|
Reference in New Issue
Block a user