Skip to content

Commit

Permalink
Merge pull request torvalds#161 from Rondom/fix_win32_timens
Browse files Browse the repository at this point in the history
lkl: Change win32 timens to return ns since epoch
  • Loading branch information
Octavian Purdila committed Jun 2, 2016
2 parents 0789bce + 25775e0 commit 66753ca
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tools/lkl/lib/nt-host.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <lkl_host.h>
#include "iomem.h"

#define DIFF_1601_TO_1970_IN_100NS (11644473600L * 10000000L)

struct lkl_mutex_t {
HANDLE mutex;
};
Expand Down Expand Up @@ -117,14 +119,14 @@ static unsigned long long time_ns(void)
{
SYSTEMTIME st;
FILETIME ft;
LARGE_INTEGER li;
ULARGE_INTEGER uli;

GetSystemTime(&st);
SystemTimeToFileTime(&st, &ft);
li.LowPart = ft.dwLowDateTime;
li.HighPart = ft.dwHighDateTime;
uli.LowPart = ft.dwLowDateTime;
uli.HighPart = ft.dwHighDateTime;

return li.QuadPart*100;
return (uli.QuadPart - DIFF_1601_TO_1970_IN_100NS) * 100;
}

struct timer {
Expand Down

0 comments on commit 66753ca

Please sign in to comment.