Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
15b35f4d
Commit
15b35f4d
authored
Jul 27, 2011
by
Daniel Lehman
Committed by
Alexandre Julliard
Nov 25, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Return wall-clock time from clock().
parent
f65f951c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
10 deletions
+32
-10
time.c
dlls/msvcrt/tests/time.c
+17
-0
time.c
dlls/msvcrt/time.c
+15
-10
No files found.
dlls/msvcrt/tests/time.c
View file @
15b35f4d
...
...
@@ -852,6 +852,22 @@ static void test__tzset(void)
_putenv
(
TZ_env
);
}
static
void
test_clock
(
void
)
{
static
const
int
THRESH
=
50
;
clock_t
s
,
e
;
int
i
;
for
(
i
=
0
;
i
<
10
;
i
++
)
{
s
=
clock
();
Sleep
(
1000
);
e
=
clock
();
ok
(
abs
((
e
-
s
)
-
1000
)
<
THRESH
,
"clock off on loop %i: %i
\n
"
,
i
,
e
-
s
);
}
}
START_TEST
(
time
)
{
init
();
...
...
@@ -870,4 +886,5 @@ START_TEST(time)
test_localtime64_s
();
test_daylight
();
test_asctime
();
test_clock
();
}
dlls/msvcrt/time.c
View file @
15b35f4d
...
...
@@ -30,6 +30,7 @@
#include "mtdll.h"
#include "winbase.h"
#include "winnls.h"
#include "winternl.h"
#include "wine/debug.h"
#include "wine/unicode.h"
...
...
@@ -709,19 +710,23 @@ int CDECL _wstrtime_s(MSVCRT_wchar_t* time, MSVCRT_size_t size)
*/
MSVCRT_clock_t
CDECL
MSVCRT_clock
(
void
)
{
FILETIME
ftc
,
fte
,
ftk
,
ftu
;
ULONGLONG
utime
,
ktime
;
MSVCRT_clock_t
clock
;
static
LONGLONG
start_time
;
LARGE_INTEGER
systime
;
GetProcessTimes
(
GetCurrentProcess
(),
&
ftc
,
&
fte
,
&
ftk
,
&
ftu
);
if
(
!
start_time
)
{
KERNEL_USER_TIMES
pti
;
ktime
=
((
ULONGLONG
)
ftk
.
dwHighDateTime
<<
32
)
|
ftk
.
dwLowDateTime
;
utime
=
((
ULONGLONG
)
ftu
.
dwHighDateTime
<<
32
)
|
ftu
.
dwLowDateTime
;
clock
=
(
utime
+
ktime
)
/
(
TICKSPERSEC
/
MSVCRT_CLOCKS_PER_SEC
);
/* while Linux's clock returns user time, Windows' clock
* returns wall-clock time from process start. cache the
* process start time since it won't change and to avoid
* wineserver round-trip overhead */
if
(
NtQueryInformationProcess
(
GetCurrentProcess
(),
ProcessTimes
,
&
pti
,
sizeof
(
pti
),
NULL
))
return
-
1
;
start_time
=
pti
.
CreateTime
.
QuadPart
;
}
return
clock
;
NtQuerySystemTime
(
&
systime
);
return
(
systime
.
QuadPart
-
start_time
)
*
MSVCRT_CLOCKS_PER_SEC
/
TICKSPERSEC
;
}
/*********************************************************************
...
...
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