mirror of
https://github.com/yuzu-emu/FasTC.git
synced 2025-01-23 12:11:10 +00:00
Fix stop watch for unix.
This commit is contained in:
parent
70674e5665
commit
588f58b237
|
@ -19,6 +19,9 @@ ELSEIF( APPLE )
|
||||||
SET( SOURCES ${SOURCES} "src/StopWatchOSX.cpp" )
|
SET( SOURCES ${SOURCES} "src/StopWatchOSX.cpp" )
|
||||||
ELSE()
|
ELSE()
|
||||||
SET( SOURCES ${SOURCES} "src/StopWatchUnix.cpp" )
|
SET( SOURCES ${SOURCES} "src/StopWatchUnix.cpp" )
|
||||||
|
|
||||||
|
# Assume compiler is GCC
|
||||||
|
SET( LINK_FLAGS -lrt ${LINK_FLAGS} )
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES( ${TexC_SOURCE_DIR}/BPTCEncoder/include )
|
INCLUDE_DIRECTORIES( ${TexC_SOURCE_DIR}/BPTCEncoder/include )
|
||||||
|
@ -50,3 +53,7 @@ TARGET_LINK_LIBRARIES( TexCompCore BPTCEncoder )
|
||||||
IF( Boost_FOUND )
|
IF( Boost_FOUND )
|
||||||
TARGET_LINK_LIBRARIES( TexCompCore ${Boost_LIBRARIES} )
|
TARGET_LINK_LIBRARIES( TexCompCore ${Boost_LIBRARIES} )
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
IF( NOT WIN32 AND NOT APPLE )
|
||||||
|
TARGET_LINK_LIBRARIES( TexCompCore rt )
|
||||||
|
ENDIF()
|
||||||
|
|
|
@ -23,7 +23,7 @@ StopWatch &StopWatch::operator=(const StopWatch &other) {
|
||||||
delete impl;
|
delete impl;
|
||||||
}
|
}
|
||||||
impl = new StopWatchImpl();
|
impl = new StopWatchImpl();
|
||||||
memcpy(impl, other.impl. sizeof(StopWatchImpl));
|
memcpy(impl, other.impl, sizeof(StopWatchImpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
StopWatch::~StopWatch() {
|
StopWatch::~StopWatch() {
|
||||||
|
@ -36,17 +36,17 @@ StopWatch::StopWatch() : impl(new StopWatchImpl) {
|
||||||
|
|
||||||
void StopWatch::Start() {
|
void StopWatch::Start() {
|
||||||
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &(impl->ts));
|
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &(impl->ts));
|
||||||
impl->timer = double(ts.tv_sec) + 1e-9 * double(ts.tv_nsec);
|
impl->timer = double(impl->ts.tv_sec) + 1e-9 * double(impl->ts.tv_nsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StopWatch::Stop() {
|
void StopWatch::Stop() {
|
||||||
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &(impl->ts));
|
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &(impl->ts));
|
||||||
impl->duration = -(impl->timer) + (double(ts.tv_sec) + 1e-9 * double(ts.tv_nsec));
|
impl->duration = -(impl->timer) + (double(impl->ts.tv_sec) + 1e-9 * double(impl->ts.tv_nsec));
|
||||||
}
|
}
|
||||||
|
|
||||||
void StopWatch::Reset() {
|
void StopWatch::Reset() {
|
||||||
impl->timer = impl->duration = 0.0;
|
impl->timer = impl->duration = 0.0;
|
||||||
memset(impl->ts, 0, sizeof(timespec));
|
memset(&(impl->ts), 0, sizeof(timespec));
|
||||||
}
|
}
|
||||||
|
|
||||||
double StopWatch::TimeInSeconds() const {
|
double StopWatch::TimeInSeconds() const {
|
||||||
|
|
|
@ -47,7 +47,7 @@ StopWatch &StopWatch::operator=(const StopWatch &other) {
|
||||||
delete impl;
|
delete impl;
|
||||||
}
|
}
|
||||||
impl = new StopWatchImpl();
|
impl = new StopWatchImpl();
|
||||||
memcpy(impl, other.impl. sizeof(StopWatchImpl));
|
memcpy(impl, other.impl, sizeof(StopWatchImpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
StopWatch::~StopWatch() {
|
StopWatch::~StopWatch() {
|
||||||
|
|
Loading…
Reference in a new issue