mirror of https://github.com/openssl/openssl.git
Avoid using union wrt. SystemTimeToFileTime
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18660)
This commit is contained in:
parent
8e949b35d3
commit
8eca6864e0
|
|
@ -1900,20 +1900,19 @@ static void get_current_time(struct timeval *t)
|
||||||
{
|
{
|
||||||
# if defined(_WIN32)
|
# if defined(_WIN32)
|
||||||
SYSTEMTIME st;
|
SYSTEMTIME st;
|
||||||
union {
|
unsigned __int64 now_ul;
|
||||||
unsigned __int64 ul;
|
FILETIME now_ft;
|
||||||
FILETIME ft;
|
|
||||||
} now;
|
|
||||||
|
|
||||||
GetSystemTime(&st);
|
GetSystemTime(&st);
|
||||||
SystemTimeToFileTime(&st, &now.ft);
|
SystemTimeToFileTime(&st, &now_ft);
|
||||||
|
now_ul = ((unsigned __int64)now_ft.dwHighDateTime << 32) | now_ft.dwLowDateTime;
|
||||||
# ifdef __MINGW32__
|
# ifdef __MINGW32__
|
||||||
now.ul -= 116444736000000000ULL;
|
now_ul -= 116444736000000000ULL;
|
||||||
# else
|
# else
|
||||||
now.ul -= 116444736000000000UI64; /* re-bias to 1/1/1970 */
|
now_ul -= 116444736000000000UI64; /* re-bias to 1/1/1970 */
|
||||||
# endif
|
# endif
|
||||||
t->tv_sec = (long)(now.ul / 10000000);
|
t->tv_sec = (long)(now_ul / 10000000);
|
||||||
t->tv_usec = ((int)(now.ul % 10000000)) / 10;
|
t->tv_usec = ((int)(now_ul % 10000000)) / 10;
|
||||||
# else
|
# else
|
||||||
gettimeofday(t, NULL);
|
gettimeofday(t, NULL);
|
||||||
# endif
|
# endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue