2015-05-23 22:55:12 -06:00
|
|
|
// Copyright 2014 Dolphin Emulator Project
|
2015-05-17 17:08:10 -06:00
|
|
|
// Licensed under GPLv2+
|
2014-10-17 18:50:02 -06:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#if !defined(_WIN32)
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
#include <ctime>
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "Common/CommonTypes.h"
|
|
|
|
#include "Common/PerformanceCounter.h"
|
|
|
|
|
|
|
|
#if defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0
|
2016-06-24 02:43:46 -06:00
|
|
|
#if defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK > 0
|
2014-10-17 18:50:02 -06:00
|
|
|
#define DOLPHIN_CLOCK CLOCK_MONOTONIC
|
|
|
|
#else
|
|
|
|
#define DOLPHIN_CLOCK CLOCK_REALTIME
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
bool QueryPerformanceCounter(u64* out)
|
|
|
|
{
|
|
|
|
#if defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0
|
2016-06-24 02:43:46 -06:00
|
|
|
timespec tp;
|
|
|
|
if (clock_gettime(DOLPHIN_CLOCK, &tp))
|
|
|
|
return false;
|
|
|
|
*out = (u64)tp.tv_nsec + (u64)1000000000 * (u64)tp.tv_sec;
|
|
|
|
return true;
|
2014-10-17 18:50:02 -06:00
|
|
|
#else
|
2016-06-24 02:43:46 -06:00
|
|
|
*out = 0;
|
|
|
|
return false;
|
2014-10-17 18:50:02 -06:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool QueryPerformanceFrequency(u64* out)
|
|
|
|
{
|
|
|
|
#if defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0
|
2016-06-24 02:43:46 -06:00
|
|
|
*out = 1000000000;
|
|
|
|
return true;
|
2014-10-17 18:50:02 -06:00
|
|
|
#else
|
2016-06-24 02:43:46 -06:00
|
|
|
*out = 1;
|
|
|
|
return false;
|
2014-10-17 18:50:02 -06:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|