VirtualBox

source: vbox/trunk/src/VBox/Runtime/r0drv/nt/time-r0drv-nt.cpp@ 5528

Last change on this file since 5528 was 4781, checked in by vboxsync, 17 years ago

eol

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.3 KB
Line 
1/* $Id: time-r0drv-nt.cpp 4781 2007-09-13 19:07:42Z vboxsync $ */
2/** @file
3 * innotek Portable Runtime - Time, Ring-0 Driver, Nt.
4 */
5
6/*
7 * Copyright (C) 2007 innotek GmbH
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19/*******************************************************************************
20* Header Files *
21*******************************************************************************/
22#define LOG_GROUP RTLOGGROUP_TIME
23#include "the-nt-kernel.h"
24#include <iprt/time.h>
25
26
27DECLINLINE(uint64_t) rtTimeGetSystemNanoTS(void)
28{
29#if 1
30 ULONGLONG InterruptTime = KeQueryInterruptTime();
31 return (uint64_t)InterruptTime * 100;
32#else
33 LARGE_INTEGER InterruptTime;
34 do
35 {
36 InterruptTime.HighPart = ((KUSER_SHARED_DATA volatile *)SharedUserData)->InterruptTime.High1Time;
37 InterruptTime.LowPart = ((KUSER_SHARED_DATA volatile *)SharedUserData)->InterruptTime.LowPart;
38 } while (((KUSER_SHARED_DATA volatile *)SharedUserData)->InterruptTime.High2Time != InterruptTime.HighPart);
39
40 return (uint64_t)InterruptTime.QuadPart * 100;
41#endif
42}
43
44
45RTDECL(uint64_t) RTTimeNanoTS(void)
46{
47 return rtTimeGetSystemNanoTS();
48}
49
50
51RTDECL(uint64_t) RTTimeMilliTS(void)
52{
53 return rtTimeGetSystemNanoTS() / 1000000;
54}
55
56
57RTDECL(uint64_t) RTTimeSystemNanoTS(void)
58{
59 return rtTimeGetSystemNanoTS();
60}
61
62
63RTDECL(uint64_t) RTTimeSystemMilliTS(void)
64{
65 return rtTimeGetSystemNanoTS() / 1000000;
66}
67
68
69RTDECL(PRTTIMESPEC) RTTimeNow(PRTTIMESPEC pTime)
70{
71 LARGE_INTEGER SystemTime;
72#if 1
73 KeQuerySystemTime(&SystemTime);
74#else
75 do
76 {
77 SystemTime.HighPart = ((KUSER_SHARED_DATA volatile *)SharedUserData)->SystemTime.High1Time;
78 SystemTime.LowPart = ((KUSER_SHARED_DATA volatile *)SharedUserData)->SystemTime.LowPart;
79 } while (((KUSER_SHARED_DATA volatile *)SharedUserData)->SystemTime.High2Time != SystemTime.HighPart);
80#endif
81 return RTTimeSpecSetNtTime(pTime, SystemTime.QuadPart);
82}
83
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette