Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
cd215bb4
Commit
cd215bb4
authored
May 21, 2020
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Use the user shared data to implement GetTickCount().
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
8ca9e0b1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
49 deletions
+15
-49
time.c
dlls/kernel32/time.c
+15
-47
time.c
dlls/ntdll/tests/time.c
+0
-2
No files found.
dlls/kernel32/time.c
View file @
cd215bb4
...
...
@@ -38,9 +38,6 @@
#elif defined(HAVE_MACHINE_LIMITS_H)
#include <machine/limits.h>
#endif
#ifdef __APPLE__
# include <mach/mach_time.h>
#endif
#include "ntstatus.h"
#define WIN32_NO_STATUS
...
...
@@ -49,49 +46,21 @@
#include "winbase.h"
#include "winreg.h"
#include "winternl.h"
#include "ddk/wdm.h"
#include "kernel_private.h"
#include "wine/unicode.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
time
);
static
const
struct
_KUSER_SHARED_DATA
*
user_shared_data
=
(
struct
_KUSER_SHARED_DATA
*
)
0x7ffe0000
;
static
inline
void
longlong_to_filetime
(
LONGLONG
t
,
FILETIME
*
ft
)
{
ft
->
dwLowDateTime
=
(
DWORD
)
t
;
ft
->
dwHighDateTime
=
(
DWORD
)(
t
>>
32
);
}
#define TICKSPERSEC 10000000
#define TICKSPERMSEC 10000
/* return a monotonic time counter, in Win32 ticks */
static
inline
ULONGLONG
monotonic_counter
(
void
)
{
LARGE_INTEGER
counter
;
#ifdef __APPLE__
static
mach_timebase_info_data_t
timebase
;
if
(
!
timebase
.
denom
)
mach_timebase_info
(
&
timebase
);
#ifdef HAVE_MACH_CONTINUOUS_TIME
if
(
&
mach_continuous_time
!=
NULL
)
return
mach_continuous_time
()
*
timebase
.
numer
/
timebase
.
denom
/
100
;
#endif
return
mach_absolute_time
()
*
timebase
.
numer
/
timebase
.
denom
/
100
;
#elif defined(HAVE_CLOCK_GETTIME)
struct
timespec
ts
;
#ifdef CLOCK_MONOTONIC_RAW
if
(
!
clock_gettime
(
CLOCK_MONOTONIC_RAW
,
&
ts
))
return
ts
.
tv_sec
*
(
ULONGLONG
)
TICKSPERSEC
+
ts
.
tv_nsec
/
100
;
#endif
if
(
!
clock_gettime
(
CLOCK_MONOTONIC
,
&
ts
))
return
ts
.
tv_sec
*
(
ULONGLONG
)
TICKSPERSEC
+
ts
.
tv_nsec
/
100
;
#endif
NtQueryPerformanceCounter
(
&
counter
,
NULL
);
return
counter
.
QuadPart
;
}
/***********************************************************************
* GetSystemTimeAdjustment (KERNEL32.@)
...
...
@@ -394,24 +363,23 @@ BOOL WINAPI GetSystemTimes(LPFILETIME lpIdleTime, LPFILETIME lpKernelTime, LPFIL
*/
ULONGLONG
WINAPI
DECLSPEC_HOTPATCH
GetTickCount64
(
void
)
{
return
monotonic_counter
()
/
TICKSPERMSEC
;
ULONG
high
,
low
;
do
{
high
=
user_shared_data
->
u
.
TickCount
.
High1Time
;
low
=
user_shared_data
->
u
.
TickCount
.
LowPart
;
}
while
(
high
!=
user_shared_data
->
u
.
TickCount
.
High2Time
);
/* note: we ignore TickCountMultiplier */
return
(
ULONGLONG
)
high
<<
32
|
low
;
}
/***********************************************************************
* GetTickCount (KERNEL32.@)
*
* Get the number of milliseconds the system has been running.
*
* PARAMS
* None.
*
* RETURNS
* The current tick count.
*
* NOTES
* The value returned will wrap around every 2^32 milliseconds.
*/
DWORD
WINAPI
DECLSPEC_HOTPATCH
GetTickCount
(
void
)
{
return
monotonic_counter
()
/
TICKSPERMSEC
;
/* note: we ignore TickCountMultiplier */
return
user_shared_data
->
u
.
TickCount
.
LowPart
;
}
dlls/ntdll/tests/time.c
View file @
cd215bb4
...
...
@@ -185,8 +185,6 @@ static void test_user_shared_data_time(void)
t3
=
GetTickCount
();
}
while
(
t3
<
t1
&&
i
++
<
1
);
/* allow for wrap, but only once */
/* FIXME: not always in order, but should be close */
todo_wine_if
(
t1
>
t2
&&
t1
-
t2
<
50
)
ok
(
t1
<=
t2
,
"USD TickCount / GetTickCount are out of order: %s %s
\n
"
,
wine_dbgstr_longlong
(
t1
),
wine_dbgstr_longlong
(
t2
));
ok
(
t2
<=
t3
,
"USD TickCount / GetTickCount are out of order: %s %s
\n
"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment