Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
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
Иван Мажукин
mpd
Commits
837134da
Commit
837134da
authored
Dec 28, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
system/Clock: remove obsolete MonotonicClock*() functions
We're using std::chrono::steady_clock now. No need to duplicate code.
parent
40118998
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
121 deletions
+0
-121
Clock.cxx
src/system/Clock.cxx
+0
-98
Clock.hxx
src/system/Clock.hxx
+0
-23
No files found.
src/system/Clock.cxx
View file @
837134da
...
...
@@ -21,104 +21,6 @@
#ifdef WIN32
#include <windows.h>
#elif defined(__APPLE__)
#include <mach/mach_time.h>
#else
#include <time.h>
#ifndef CLOCK_MONOTONIC
#include <sys/time.h>
#endif
#endif
unsigned
MonotonicClockS
(
void
)
{
#ifdef WIN32
return
GetTickCount
()
/
1000
;
#elif defined(__APPLE__)
/* OS X does not define CLOCK_MONOTONIC */
static
mach_timebase_info_data_t
base
;
if
(
base
.
denom
==
0
)
(
void
)
mach_timebase_info
(
&
base
);
return
(
unsigned
)(((
double
)
mach_absolute_time
()
*
base
.
numer
/
1000
)
/
base
.
denom
/
1000000
);
#elif defined(CLOCK_MONOTONIC)
struct
timespec
ts
;
clock_gettime
(
CLOCK_MONOTONIC
,
&
ts
);
return
ts
.
tv_sec
;
#else
/* we have no monotonic clock, fall back to time() */
return
time
(
nullptr
);
#endif
}
unsigned
MonotonicClockMS
(
void
)
{
#ifdef WIN32
return
GetTickCount
();
#elif defined(__APPLE__)
/* OS X does not define CLOCK_MONOTONIC */
static
mach_timebase_info_data_t
base
;
if
(
base
.
denom
==
0
)
(
void
)
mach_timebase_info
(
&
base
);
return
(
unsigned
)(((
double
)
mach_absolute_time
()
*
base
.
numer
)
/
base
.
denom
/
1000000
);
#elif defined(CLOCK_MONOTONIC)
struct
timespec
ts
;
clock_gettime
(
CLOCK_MONOTONIC
,
&
ts
);
return
ts
.
tv_sec
*
1000
+
ts
.
tv_nsec
/
1000000
;
#else
/* we have no monotonic clock, fall back to gettimeofday() */
struct
timeval
tv
;
gettimeofday
(
&
tv
,
0
);
return
tv
.
tv_sec
*
1000
+
tv
.
tv_usec
/
1000
;
#endif
}
uint64_t
MonotonicClockUS
(
void
)
{
#ifdef WIN32
LARGE_INTEGER
l_value
,
l_frequency
;
if
(
!
QueryPerformanceCounter
(
&
l_value
)
||
!
QueryPerformanceFrequency
(
&
l_frequency
))
return
0
;
uint64_t
value
=
l_value
.
QuadPart
;
uint64_t
frequency
=
l_frequency
.
QuadPart
;
if
(
frequency
>
1000000
)
{
value
*=
10000
;
value
/=
frequency
/
100
;
}
else
if
(
frequency
<
1000000
)
{
value
*=
10000
;
value
/=
frequency
;
value
*=
100
;
}
return
value
;
#elif defined(__APPLE__)
/* OS X does not define CLOCK_MONOTONIC */
static
mach_timebase_info_data_t
base
;
if
(
base
.
denom
==
0
)
(
void
)
mach_timebase_info
(
&
base
);
return
(
uint64_t
)(((
double
)
mach_absolute_time
()
*
base
.
numer
)
/
base
.
denom
/
1000
);
#elif defined(CLOCK_MONOTONIC)
struct
timespec
ts
;
clock_gettime
(
CLOCK_MONOTONIC
,
&
ts
);
return
(
uint64_t
)
ts
.
tv_sec
*
1000000
+
(
uint64_t
)(
ts
.
tv_nsec
/
1000
);
#else
/* we have no monotonic clock, fall back to gettimeofday() */
struct
timeval
tv
;
gettimeofday
(
&
tv
,
0
);
return
(
uint64_t
)
tv
.
tv_sec
*
1000
+
(
uint64_t
)
tv
.
tv_usec
;
#endif
}
#ifdef WIN32
gcc_const
static
unsigned
...
...
src/system/Clock.hxx
View file @
837134da
...
...
@@ -22,29 +22,6 @@
#include "Compiler.h"
#include <stdint.h>
/**
* Returns the value of a monotonic clock in seconds.
*/
gcc_pure
unsigned
MonotonicClockS
();
/**
* Returns the value of a monotonic clock in milliseconds.
*/
gcc_pure
unsigned
MonotonicClockMS
();
/**
* Returns the value of a monotonic clock in microseconds.
*/
gcc_pure
uint64_t
MonotonicClockUS
();
#ifdef WIN32
/**
...
...
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