clock: use div_const() to optimize the div speed
Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
parent
cce5280ebf
commit
a4ffa84974
|
@ -341,7 +341,7 @@ EXTERN volatile clock_t g_system_ticks;
|
||||||
while (0)
|
while (0)
|
||||||
|
|
||||||
#define clock_time2ticks(ts) \
|
#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) \
|
#define clock_usec2time(ts, usec) \
|
||||||
do \
|
do \
|
||||||
|
@ -354,7 +354,7 @@ EXTERN volatile clock_t g_system_ticks;
|
||||||
while (0)
|
while (0)
|
||||||
|
|
||||||
#define clock_time2usec(ts) \
|
#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) \
|
#define clock_nsec2time(ts, nsec) \
|
||||||
do \
|
do \
|
||||||
|
|
Loading…
Reference in New Issue