diff --git a/a8/sysutils.cc b/a8/sysutils.cc index f62dfd8..5e47ea9 100644 --- a/a8/sysutils.cc +++ b/a8/sysutils.cc @@ -12,9 +12,18 @@ namespace a8 { a8::tick_t XGetTickCount() { + #if 1 + struct timeval tv; + gettimeofday(&tv, NULL); + long long time = tv.tv_usec; + time /= 1000; + time += (tv.tv_sec * 1000); + return time; + #else struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); return (ts.tv_sec*1000 + ts.tv_nsec/(1000*1000)); + #endif } long long XGetNanoSeconds() diff --git a/a8/timer.cc b/a8/timer.cc index 39a71dc..73c00fd 100644 --- a/a8/timer.cc +++ b/a8/timer.cc @@ -245,7 +245,7 @@ namespace a8 int idle_time = 1; for (int lv1_idx = base_->timer_tick & TVR_MASK; lv1_idx < TVR_SIZE; ++lv1_idx) { if (!list_empty(base_->tv1.vec + lv1_idx)) { - return idle_time; + return idle_time <= 1 ? 1 : idle_time - 1; } ++idle_time; } @@ -257,7 +257,7 @@ namespace a8 idle_time += TVR_SIZE; } #endif - return idle_time; + return idle_time <= 1 ? 1 : idle_time - 1; } void Timer::UpdateTimer()