Windows; GetSystemTimeAsFileTime

As per Raymond Chen's "The Old New Thing" blog

  http://blogs.msdn.com/b/oldnewthing/archive/2013/11/01/10462403.aspx

Calling GetSystemTime() followed by SystemTimeToFileTime() performs
two format translations which can be avoided by using
GetSystemTimeAsFileTime() directly.

Change-Id: I3d3de0e045777c9dfdb1c1f4503bfdfe19fb7b73
Reviewed-on: http://gerrit.openafs.org/10430
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
This commit is contained in:
Jeffrey Altman 2013-11-04 00:12:07 -05:00
parent 3f5f3013e9
commit 727e951d8c

View File

@ -197,7 +197,6 @@ void osi_Init(void)
static osi_once_t once; static osi_once_t once;
unsigned long remainder; /* for division output */ unsigned long remainder; /* for division output */
osi_fdType_t *typep; osi_fdType_t *typep;
SYSTEMTIME sysTime;
FILETIME fileTime; FILETIME fileTime;
osi_hyper_t bootTime; osi_hyper_t bootTime;
@ -206,8 +205,7 @@ void osi_Init(void)
return; return;
/* setup boot time values */ /* setup boot time values */
GetSystemTime(&sysTime); GetSystemTimeAsFileTime(&fileTime);
SystemTimeToFileTime(&sysTime, &fileTime);
/* change the base of the time so it won't be negative for a long time */ /* change the base of the time so it won't be negative for a long time */
fileTime.dwHighDateTime -= 28000000; fileTime.dwHighDateTime -= 28000000;
@ -708,13 +706,11 @@ void osi_panic(char *msgp, char *filep, long line)
time_t osi_Time(void) time_t osi_Time(void)
{ {
FILETIME fileTime; FILETIME fileTime;
SYSTEMTIME sysTime;
unsigned long remainder; unsigned long remainder;
LARGE_INTEGER bootTime; LARGE_INTEGER bootTime;
/* setup boot time values */ /* setup boot time values */
GetSystemTime(&sysTime); GetSystemTimeAsFileTime(&fileTime);
SystemTimeToFileTime(&sysTime, &fileTime);
/* change the base of the time so it won't be negative for a long time */ /* change the base of the time so it won't be negative for a long time */
fileTime.dwHighDateTime -= 28000000; fileTime.dwHighDateTime -= 28000000;
@ -737,13 +733,11 @@ time_t osi_Time(void)
void osi_GetTime(long *timesp) void osi_GetTime(long *timesp)
{ {
FILETIME fileTime; FILETIME fileTime;
SYSTEMTIME sysTime;
unsigned long remainder; unsigned long remainder;
LARGE_INTEGER bootTime; LARGE_INTEGER bootTime;
/* setup boot time values */ /* setup boot time values */
GetSystemTime(&sysTime); GetSystemTimeAsFileTime(&fileTime);
SystemTimeToFileTime(&sysTime, &fileTime);
/* change the base of the time so it won't be negative for a long time */ /* change the base of the time so it won't be negative for a long time */
fileTime.dwHighDateTime -= 28000000; fileTime.dwHighDateTime -= 28000000;