From b52127bcbf817ff8285b36d22198b275327e16bb Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Sun, 16 Dec 2012 17:47:51 -0800 Subject: Cleanup headers and remove all uses of va_list except logging --- src/common/timer.cpp | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) (limited to 'src/common/timer.cpp') diff --git a/src/common/timer.cpp b/src/common/timer.cpp index 8a12d19..0215b53 100644 --- a/src/common/timer.cpp +++ b/src/common/timer.cpp @@ -1,18 +1,23 @@ -#include -#include -#include -#include +#include "timer.hpp" #include #include +#include + +#include +#include +#include -#include "timer.hpp" #include "utils.hpp" -static struct TimerData *timer_data; -static uint32_t timer_data_max, timer_data_num; -static timer_id *free_timer_list; -static uint32_t free_timer_list_max, free_timer_list_pos; +static +struct TimerData *timer_data; +static +uint32_t timer_data_max, timer_data_num; +static +timer_id *free_timer_list; +static +uint32_t free_timer_list_max, free_timer_list_pos; /// Okay, I think I understand this structure now: /// the timer heap is a magic queue that allows inserting timers and then popping them in order @@ -20,14 +25,18 @@ static uint32_t free_timer_list_max, free_timer_list_pos; // timer_heap[0] is the size (greatest index into the heap) // timer_heap[1] is the first actual element // timer_heap_max increases 256 at a time and never decreases -static uint32_t timer_heap_max = 0; +static +uint32_t timer_heap_max = 0; /// FIXME: refactor the code to put the size in a separate variable //nontrivial because indices get multiplied -static timer_id *timer_heap = NULL; +static +timer_id *timer_heap = NULL; -static uint32_t gettick_cache; -static uint8_t gettick_count = 0; +static +uint32_t gettick_cache; +static +uint8_t gettick_count = 0; uint32_t gettick_nocache(void) { @@ -46,7 +55,8 @@ uint32_t gettick(void) return gettick_nocache(); } -static void push_timer_heap(timer_id index) +static +void push_timer_heap(timer_id index) { if (timer_heap == NULL || timer_heap[0] + 1 >= timer_heap_max) { @@ -71,14 +81,16 @@ static void push_timer_heap(timer_id index) timer_heap[h + 1] = index; } -static timer_id top_timer_heap(void) +static +timer_id top_timer_heap(void) { if (!timer_heap || !timer_heap[0]) return -1; return timer_heap[1]; } -static timer_id pop_timer_heap(void) +static +timer_id pop_timer_heap(void) { if (!timer_heap || !timer_heap[0]) return -1; -- cgit v1.2.3-60-g2f50