From 8026c47ef51d37a1c88bb75ea17d5cf20edbc1a7 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Wed, 11 Oct 2023 15:23:34 +0800 Subject: [PATCH] fix timerprovider arm32 bug --- util/src/tc_timeprovider.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/util/src/tc_timeprovider.cpp b/util/src/tc_timeprovider.cpp index e240efd8..eca0609e 100644 --- a/util/src/tc_timeprovider.cpp +++ b/util/src/tc_timeprovider.cpp @@ -90,16 +90,22 @@ uint64_t TC_TimeProvider::GetCycleCount() void TC_TimeProvider::getNow(timeval *tv) { #if TARGET_PLATFORM_IOS || TARGET_PLATFORM_LINUX - - int idx = _buf_idx; - *tv = _t[idx]; - if(fabs(_cpu_cycle - 0) < 0.0001 && _use_tsc) + if(GetCycleCount() != 0) { - addTimeOffset(*tv, idx); + int idx = _buf_idx; + *tv = _t[idx]; + if (fabs(_cpu_cycle - 0) < 0.0001 && _use_tsc) + { + addTimeOffset(*tv, idx); + } + else + { + TC_Common::gettimeofday(*tv); + } } else { - TC_Common::gettimeofday(*tv); + TC_Common::gettimeofday(*tv); } #else TC_Common::gettimeofday(*tv);