From 1d8fcfcd0d1b93d04ea5adcb980ffac38bd3d140 Mon Sep 17 00:00:00 2001 From: Gwendal Grignou Date: Sat, 19 Sep 2015 10:48:19 -0700 Subject: common: Add __fls function Returns the most significant bit set. Replace 31 - __builtin_clz(x), so x must be different from 0. Use get_next_bit when not on the performance path, on performance path set the bit field just after reading it. BRANCH=smaug BUG=none TEST=compile, check Ryu still works. Change-Id: Ie1a4cda4188f45b4bf92d0549d5c8fb401a30e5d Signed-off-by: Gwendal Grignou Reviewed-on: https://chromium-review.googlesource.com/301300 --- common/timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common/timer.c') diff --git a/common/timer.c b/common/timer.c index f6c69ac5d2..289314e74a 100644 --- a/common/timer.c +++ b/common/timer.c @@ -65,8 +65,8 @@ void process_timers(int overflow) /* read atomically the current state of timer running */ check_timer = running_t0 = timer_running; while (check_timer) { - int tskid = 31 - __builtin_clz(check_timer); + int tskid = __fls(check_timer); /* timer has expired ? */ if (timer_deadline[tskid].val <= now.val) expire_timer(tskid); -- cgit v1.2.1