clock: use div_const() to optimize the div speed

Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
ligd 2024-06-04 20:41:20 +08:00 committed by Xiang Xiao
parent cce5280ebf
commit a4ffa84974
1 changed files with 2 additions and 2 deletions

View File

@ -341,7 +341,7 @@ EXTERN volatile clock_t g_system_ticks;
while (0)
#define clock_time2ticks(ts) \
((clock_t)(ts)->tv_sec * TICK_PER_SEC + (ts)->tv_nsec / NSEC_PER_TICK)
((clock_t)(ts)->tv_sec * TICK_PER_SEC + div_const((ts)->tv_nsec, NSEC_PER_TICK))
#define clock_usec2time(ts, usec) \
do \
@ -354,7 +354,7 @@ EXTERN volatile clock_t g_system_ticks;
while (0)
#define clock_time2usec(ts) \
((uint64_t)(ts)->tv_sec * USEC_PER_SEC + (ts)->tv_nsec / NSEC_PER_USEC)
((uint64_t)(ts)->tv_sec * USEC_PER_SEC + div_const((ts)->tv_nsec, NSEC_PER_USEC))
#define clock_nsec2time(ts, nsec) \
do \