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:
Bertrik Sikken 2009-10-18 15:50:30 +00:00
parent 1c64a4d3e0
commit d24d885aa4
14 changed files with 29 additions and 30 deletions

View file

@ -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;

View file

@ -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();

View file

@ -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 */

View file

@ -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;