| 91 | } |
| 92 | |
| 93 | static inline void sync_timers(uc_engine *uc) { |
| 94 | uc->get_timer_countdown(uc->ctx, &uc->fw->timers.cur_countdown); |
| 95 | |
| 96 | // This does not perform reloading as syncing is assumed to only occur and to be handled |
| 97 | // within the timer callback. All manual timer syncs are on a non-elapsed state |
| 98 | |
| 99 | // In case the countdown is 0, we are currently handling timer timer callbacks |
| 100 | struct TimerState* timers = &uc->fw->timers; |
| 101 | if(timers->cur_countdown != 0) { |
| 102 | int64_t elapsed = timers->cur_interval - timers->cur_countdown; |
| 103 | |
| 104 | #ifdef DEBUG_TIMER |
| 105 | printf("[sync_timers] timers.cur_interval: %lu, timers.cur_countdown: %lu -> elapsed: %ld\n", timers->cur_interval, timers->cur_countdown, elapsed); fflush(NULL); |
| 106 | #endif |
| 107 | |
| 108 | timers->global_ticker += elapsed; |
| 109 | timers->cur_interval = timers->cur_countdown; |
| 110 | |
| 111 | for(struct Timer *cursor=timers->active_head; cursor; cursor = cursor->next) { |
| 112 | cursor->ticker_val -= elapsed; |
| 113 | } |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | uc_err rem_timer(uc_engine *uc, uint32_t id) { |
| 118 | struct TimerState* timers = &uc->fw->timers; |
no outgoing calls
no test coverage detected