This is a micro optimization.
The upstream code uses the binary search.
Details
Diff Detail
- Lint
No Lint Coverage - Unit
No Test Coverage
Event Timeline
It would be good to upstream it. I don't know why it was implemented originally, but it seems that at least on user level Illumos has fsll() and co.
highbit: use only fast flsl/flsll versions
Currently libkern flsl/flsll are even less optimized than the original
code. The same goes for libc implementations on most platforms.
Could you please re-review?
I believe that the latest diff should be safe on all platforms.
Looks fine to me. FWIW, illumos appears to have flsll() in userland but not kernel. It's implemented similarly to highbit().
Checking HAVE_INLINE_* define is what I am successfully using in SCHED_ULE for some time now, so it should work. Though I hope somebody implement missing functions on other platforms to reach the parity and avoid this mess.