Skip to content
Commit 1a94dc35 authored by Tim Abbott's avatar Tim Abbott Committed by Rusty Russell
Browse files

lib: Add generic binary search function to the kernel.



There a large number hand-coded binary searches in the kernel (run
"git grep search | grep binary" to find many of them).  Since in my
experience, hand-coding binary searches can be error-prone, it seems
worth cleaning this up by providing a generic binary search function.

This generic binary search implementation comes from Ksplice.  It has
the same basic API as the C library bsearch() function.  Ksplice uses
it in half a dozen places with 4 different comparison functions, and I
think our code is substantially cleaner because of this.

Signed-off-by: default avatarTim Abbott <tabbott@ksplice.com>
Extra-bikeshedding-by: default avatarAlan Jenkins <alan-jenkins@tuffmail.co.uk>
Extra-bikeshedding-by: default avatarAndré Goddard Rosa <andre.goddard@gmail.com>
Extra-bikeshedding-by: default avatarRusty Russell <rusty@rustcorp.com.au>
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
Signed-off-by: default avatarAlessio Igor Bogani <abogani@kernel.org>
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent f02e8a65
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment