Use wrap-safe TIME_BEFORE/TIME_AFTER macros to compare times with current_time, instead of comparing them directly.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23246 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
1c64a4d3e0
commit
d24d885aa4
14 changed files with 29 additions and 30 deletions
|
@ -599,8 +599,7 @@ bool gui_synclist_do_button(struct gui_synclist * lists,
|
|||
{
|
||||
if (!last_accel_tick)
|
||||
last_accel_tick = current_tick + start_delay;
|
||||
else if (current_tick >=
|
||||
last_accel_tick + accel_wait)
|
||||
else if (TIME_AFTER(current_tick, last_accel_tick + accel_wait))
|
||||
{
|
||||
last_accel_tick = current_tick;
|
||||
next_item_modifier++;
|
||||
|
|
|
@ -1067,7 +1067,7 @@ static void brickmania_sleep(int secs)
|
|||
{
|
||||
if (count == 0)
|
||||
count = *rb->current_tick + HZ*secs;
|
||||
if ( (*rb->current_tick >= count) && (vscore == score) )
|
||||
if ( (TIME_AFTER(*rb->current_tick, count)) && (vscore == score) )
|
||||
done = true;
|
||||
|
||||
if(vscore != score)
|
||||
|
@ -1323,7 +1323,7 @@ static int brickmania_game_loop(void)
|
|||
|
||||
if (flip_sides)
|
||||
{
|
||||
if (*rb->current_tick>=sec_count)
|
||||
if (TIME_AFTER(*rb->current_tick, sec_count))
|
||||
{
|
||||
sec_count=*rb->current_tick+HZ;
|
||||
if (num_count!=0)
|
||||
|
@ -2111,7 +2111,7 @@ static int brickmania_game_loop(void)
|
|||
rb->yield();
|
||||
|
||||
/* Sleep for a bit if there is time to spare */
|
||||
if (end > *rb->current_tick)
|
||||
if (TIME_BEFORE(*rb->current_tick, end))
|
||||
rb->sleep(end-*rb->current_tick);
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -684,7 +684,7 @@ static int clix_handle_game(struct clix_game_state_t* state)
|
|||
|
||||
while(true)
|
||||
{
|
||||
if (blink_tick < *rb->current_tick) {
|
||||
if (TIME_AFTER(*rb->current_tick, blink_tick)) {
|
||||
state->blink = state->blink ? false : true;
|
||||
blink_tick = *rb->current_tick + BLINK_TICKCOUNT;
|
||||
}
|
||||
|
@ -692,7 +692,7 @@ static int clix_handle_game(struct clix_game_state_t* state)
|
|||
time = 6; /* number of ticks this function will loop reading keys */
|
||||
start = *rb->current_tick;
|
||||
end = start + time;
|
||||
while(end > *rb->current_tick)
|
||||
while(TIME_BEFORE(*rb->current_tick, end))
|
||||
{
|
||||
oldx = state->x;
|
||||
oldy = state->y;
|
||||
|
|
|
@ -1751,7 +1751,7 @@ void game_loop(void)
|
|||
|
||||
/* Wait until next frame */
|
||||
DBG("%ld (%d)\n", end - *rb->current_tick, (CYCLETIME * HZ) / 1000);
|
||||
if (end > *rb->current_tick) {
|
||||
if (TIME_BEFORE(*rb->current_tick, end)) {
|
||||
rb->sleep(end - *rb->current_tick);
|
||||
} else {
|
||||
rb->yield();
|
||||
|
|
|
@ -643,7 +643,7 @@ void calc_mandelbrot_low_prec(void)
|
|||
|
||||
/* be nice to other threads:
|
||||
* if at least one tick has passed, yield */
|
||||
if (*rb->current_tick > last_yield) {
|
||||
if (TIME_AFTER(*rb->current_tick, last_yield)) {
|
||||
rb->yield();
|
||||
last_yield = *rb->current_tick;
|
||||
}
|
||||
|
@ -706,7 +706,7 @@ void calc_mandelbrot_high_prec(void)
|
|||
|
||||
/* be nice to other threads:
|
||||
* if at least one tick has passed, yield */
|
||||
if (*rb->current_tick > last_yield) {
|
||||
if (TIME_AFTER(*rb->current_tick, last_yield)) {
|
||||
rb->yield();
|
||||
last_yield = *rb->current_tick;
|
||||
}
|
||||
|
|
|
@ -450,21 +450,21 @@ int keys(struct pong *p)
|
|||
int start = *rb->current_tick;
|
||||
int end = start + time;
|
||||
|
||||
while(end > *rb->current_tick) {
|
||||
while(TIME_BEFORE(*rb->current_tick, end)) {
|
||||
key = rb->button_get_w_tmo(end - *rb->current_tick);
|
||||
|
||||
#ifdef HAVE_TOUCHSCREEN
|
||||
short touch_x, touch_y;
|
||||
if(key & BUTTON_TOUCHSCREEN)
|
||||
{
|
||||
touch_x = rb->button_get_data() >> 16;
|
||||
touch_y = rb->button_get_data() & 0xFFFF;
|
||||
if(touch_x >= xpos[0] && touch_x <= xpos[0]+(PAD_WIDTH*4))
|
||||
padmove(&p->w_pad[0], touch_y-(p->e_pad[0]*2+PAD_HEIGHT)/2);
|
||||
short touch_x, touch_y;
|
||||
if(key & BUTTON_TOUCHSCREEN)
|
||||
{
|
||||
touch_x = rb->button_get_data() >> 16;
|
||||
touch_y = rb->button_get_data() & 0xFFFF;
|
||||
if(touch_x >= xpos[0] && touch_x <= xpos[0]+(PAD_WIDTH*4))
|
||||
padmove(&p->w_pad[0], touch_y-(p->e_pad[0]*2+PAD_HEIGHT)/2);
|
||||
|
||||
if(touch_x >= xpos[1]-(PAD_WIDTH*4) && touch_x <= xpos[1])
|
||||
padmove(&p->w_pad[1], touch_y-(p->e_pad[1]*2+PAD_HEIGHT)/2);
|
||||
}
|
||||
if(touch_x >= xpos[1]-(PAD_WIDTH*4) && touch_x <= xpos[1])
|
||||
padmove(&p->w_pad[1], touch_y-(p->e_pad[1]*2+PAD_HEIGHT)/2);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAS_BUTTON_HOLD
|
||||
|
|
|
@ -302,7 +302,7 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
++pos_cur_brick;
|
||||
}
|
||||
|
||||
if (end > *rb->current_tick)
|
||||
if (TIME_BEFORE(*rb->current_tick, end))
|
||||
rb->sleep(end-*rb->current_tick);
|
||||
else
|
||||
rb->yield();
|
||||
|
|
|
@ -2059,7 +2059,7 @@ static int spacerocks_game_loop(void)
|
|||
if(next_thrust_count)
|
||||
next_thrust_count--;
|
||||
|
||||
if (end > *rb->current_tick)
|
||||
if (TIME_BEFORE(*rb->current_tick, end))
|
||||
rb->sleep(end-*rb->current_tick);
|
||||
else
|
||||
rb->yield();
|
||||
|
|
|
@ -1045,7 +1045,7 @@ static int xobox_loop (void)
|
|||
}
|
||||
}
|
||||
|
||||
if (end > *rb->current_tick)
|
||||
if (TIME_BEFORE(*rb->current_tick, end))
|
||||
rb->sleep (end - *rb->current_tick);
|
||||
else
|
||||
rb->yield ();
|
||||
|
|
|
@ -352,7 +352,7 @@ static bool do_timed_yield(void)
|
|||
{
|
||||
/* Sorting can lock up for quite a while, so yield occasionally */
|
||||
static long wakeup_tick = 0;
|
||||
if (current_tick >= wakeup_tick)
|
||||
if (TIME_AFTER(current_tick, wakeup_tick))
|
||||
{
|
||||
wakeup_tick = current_tick + (HZ/4);
|
||||
yield();
|
||||
|
|
|
@ -64,7 +64,7 @@ struct tm *get_time(void)
|
|||
static long timeout = 0;
|
||||
|
||||
/* Don't read the RTC more than once per second */
|
||||
if (current_tick > timeout)
|
||||
if (TIME_AFTER(current_tick, timeout))
|
||||
{
|
||||
/* Once per second, 1/10th of a second off */
|
||||
timeout = HZ * (current_tick / HZ + 1) + HZ / 5;
|
||||
|
|
|
@ -261,7 +261,7 @@ void sleep(int ticks)
|
|||
#elif defined(CREATIVE_ZVx) && defined(BOOTLOADER)
|
||||
/* hacky.. */
|
||||
long sleep_ticks = current_tick + ticks + 1;
|
||||
while (sleep_ticks > current_tick)
|
||||
while (TIME_BEFORE(current_tick, sleep_ticks))
|
||||
switch_thread();
|
||||
#else
|
||||
disable_irq();
|
||||
|
|
|
@ -261,7 +261,7 @@ static int sd_init_card(const int drive)
|
|||
|
||||
do {
|
||||
/* timeout */
|
||||
if(current_tick > init_timeout)
|
||||
if(TIME_AFTER(current_tick, init_timeout))
|
||||
return -2;
|
||||
|
||||
/* app_cmd */
|
||||
|
|
|
@ -39,7 +39,7 @@ static struct adc_struct adcdata[NUM_ADC_CHANNELS] IDATA_ATTR;
|
|||
|
||||
static unsigned short _adc_read(struct adc_struct *adc)
|
||||
{
|
||||
if (adc->timeout < current_tick) {
|
||||
if (TIME_AFTER(current_tick, adc->timeout)) {
|
||||
unsigned char data[2];
|
||||
unsigned short value;
|
||||
|
||||
|
|
Loading…
Reference in a new issue