diff options
Diffstat (limited to 'src/lib/clog2.c')
-rw-r--r-- | src/lib/clog2.c | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/src/lib/clog2.c b/src/lib/clog2.c deleted file mode 100644 index 5e0d591de4..0000000000 --- a/src/lib/clog2.c +++ /dev/null @@ -1,37 +0,0 @@ -#include <console/console.h> -#include <lib.h> - -/* Assume 8 bits per byte */ -#define CHAR_BIT 8 - -unsigned long log2(unsigned long x) -{ - /* assume 8 bits per byte. */ - unsigned long pow = sizeof(x) * CHAR_BIT - 1ULL; - unsigned long i = 1ULL << pow; - - if (!x) { - printk(BIOS_WARNING, "%s called with invalid parameter of 0\n", - __func__); - return -1; - } - - for (; i > x; i >>= 1, pow--); - - return pow; -} - -unsigned long log2_ceil(unsigned long x) -{ - unsigned long pow; - - if (!x) - return -1; - - pow = log2(x); - - if (x > (1ULL << pow)) - pow++; - - return pow; -} |