Skip to content

Commit

Permalink
Improve timer functions
Browse files Browse the repository at this point in the history
  • Loading branch information
fjtrujy authored and irixxxx committed Jan 22, 2025
1 parent 21f0b13 commit 9bf0f76
Showing 1 changed file with 5 additions and 28 deletions.
33 changes: 5 additions & 28 deletions platform/psp/plat.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,30 +181,13 @@ int plat_is_dir(const char *path)
/* current time in ms */
unsigned int plat_get_ticks_ms(void)
{
struct timeval tv;
unsigned int ret;

gettimeofday(&tv, NULL);

ret = (unsigned)tv.tv_sec * 1000;
/* approximate /= 1000 */
ret += ((unsigned)tv.tv_usec * 4194) >> 22;

return ret;
return clock() / 1000;
}

/* current time in us */
unsigned int plat_get_ticks_us(void)
{
struct timeval tv;
unsigned int ret;

gettimeofday(&tv, NULL);

ret = (unsigned)tv.tv_sec * 1000000;
ret += (unsigned)tv.tv_usec;

return ret;
return clock();
}

/* sleep for some time in ms */
Expand All @@ -216,15 +199,9 @@ void plat_sleep_ms(int ms)
/* sleep for some time in us */
void plat_wait_till_us(unsigned int us_to)
{
unsigned int now;

now = plat_get_ticks_us();

while ((signed int)(us_to - now) > 512)
{
usleep(1024);
now = plat_get_ticks_us();
}
unsigned int ticks = clock();
if (us_to > ticks)
usleep(us_to - ticks);
}

/* wait until some event occurs, or timeout */
Expand Down

0 comments on commit 9bf0f76

Please sign in to comment.