repositories
/
deb_libcec.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sync LibCecSharp
[deb_libcec.git]
/
src
/
lib
/
platform
/
util
/
timeutils.h
diff --git
a/src/lib/platform/util/timeutils.h
b/src/lib/platform/util/timeutils.h
index 367c80bbbc3c1db707046e2efec38f4d1a3f9b6d..e95c10df1ff44c3074a7f35d35f141531ad160b7 100644
(file)
--- a/
src/lib/platform/util/timeutils.h
+++ b/
src/lib/platform/util/timeutils.h
@@
-31,7
+31,8
@@
* http://www.pulse-eight.net/
*/
* http://www.pulse-eight.net/
*/
-#include "../os.h"
+#include "env.h"
+#include "lib/platform/os.h"
#if defined(__APPLE__)
#include <mach/mach_time.h>
#if defined(__APPLE__)
#include <mach/mach_time.h>
@@
-39,6
+40,7
@@
#elif defined(__WINDOWS__)
#include <time.h>
#else
#elif defined(__WINDOWS__)
#include <time.h>
#else
+#include <time.h>
#include <sys/time.h>
#endif
#include <sys/time.h>
#endif
@@
-78,23
+80,20
@@
namespace PLATFORM
inline int64_t GetTimeMs()
{
#if defined(__APPLE__)
inline int64_t GetTimeMs()
{
#if defined(__APPLE__)
- return (int64_t) (CVGetCurrentHostTime()
* 1000 / CVGetHostClockFrequency(
));
+ return (int64_t) (CVGetCurrentHostTime()
/ (int64_t)(CVGetHostClockFrequency() * 0.001
));
#elif defined(__WINDOWS__)
#elif defined(__WINDOWS__)
- time_t rawtime;
- time(&rawtime);
-
LARGE_INTEGER tickPerSecond;
LARGE_INTEGER tick;
if (QueryPerformanceFrequency(&tickPerSecond))
{
QueryPerformanceCounter(&tick);
LARGE_INTEGER tickPerSecond;
LARGE_INTEGER tick;
if (QueryPerformanceFrequency(&tickPerSecond))
{
QueryPerformanceCounter(&tick);
- return (int64_t) (tick.QuadPart /
1000.
);
+ return (int64_t) (tick.QuadPart /
(tickPerSecond.QuadPart / 1000.)
);
}
return -1;
#else
}
return -1;
#else
- time
val
time;
-
gettimeofday(&time, NULL
);
- return (int64_t)
(time.tv_sec * 1000 + time.tv_usec / 1000)
;
+ time
spec
time;
+
clock_gettime(CLOCK_MONOTONIC, &time
);
+ return (int64_t)
time.tv_sec * 1000 + time.tv_nsec / 1000000
;
#endif
}
#endif
}
@@
-107,13
+106,16
@@
namespace PLATFORM
class CTimeout
{
public:
class CTimeout
{
public:
- CTimeout(uint32_t iTime) :
- m_iTarget(GetTimeMs() + iTime) {}
+ CTimeout(void) : m_iTarget(0) {}
+ CTimeout(uint32_t iTimeout) { Init(iTimeout); }
+
+ bool IsSet(void) const { return m_iTarget > 0; }
+ void Init(uint32_t iTimeout) { m_iTarget = GetTimeMs() + iTimeout; }
- uint
64
_t TimeLeft(void) const
+ uint
32
_t TimeLeft(void) const
{
uint64_t iNow = GetTimeMs();
{
uint64_t iNow = GetTimeMs();
- return (iNow > m_iTarget) ? 0 :
m_iTarget - iNow
;
+ return (iNow > m_iTarget) ? 0 :
(uint32_t)(m_iTarget - iNow)
;
}
private:
}
private: