diff options
-rw-r--r-- | kern/kmem.c | 2 | ||||
-rw-r--r-- | kern/log2.h | 16 | ||||
-rw-r--r-- | vm/vm_page.h | 2 |
3 files changed, 13 insertions, 7 deletions
diff --git a/kern/kmem.c b/kern/kmem.c index 1d9fe4e0..398e03fc 100644 --- a/kern/kmem.c +++ b/kern/kmem.c @@ -1242,7 +1242,7 @@ INIT_OP_DEFINE(kmem_setup, static inline size_t kmem_get_index(unsigned long size) { - return iorder2(size) - KMEM_CACHES_FIRST_ORDER; + return log2_order(size) - KMEM_CACHES_FIRST_ORDER; } static void diff --git a/kern/log2.h b/kern/log2.h index 762aaa77..1799b825 100644 --- a/kern/log2.h +++ b/kern/log2.h @@ -16,8 +16,6 @@ * * * Integer base 2 logarithm operations. - * - * TODO Fix naming. */ #ifndef _KERN_LOG2_H @@ -26,15 +24,23 @@ #include <assert.h> #include <limits.h> +/* + * Return the base-2 logarithm of the given value, or of the first + * power-of-two below the given value if it's not a power-of-two. + */ static inline unsigned int -ilog2(unsigned long x) +log2(unsigned long x) { assert(x != 0); return LONG_BIT - __builtin_clzl(x) - 1; } +/* + * Return the base-2 logarithm of the given value, or of the first + * power-of-two above the given value if it's not a power-of-two. + */ static inline unsigned int -iorder2(unsigned long size) +log2_order(unsigned long size) { assert(size != 0); @@ -42,7 +48,7 @@ iorder2(unsigned long size) return 0; } - return ilog2(size - 1) + 1; + return log2(size - 1) + 1; } #endif /* _KERN_LOG2_H */ diff --git a/vm/vm_page.h b/vm/vm_page.h index 6a161c07..8cd7a11d 100644 --- a/vm/vm_page.h +++ b/vm/vm_page.h @@ -108,7 +108,7 @@ void vm_page_set_type(struct vm_page *page, unsigned int order, static inline unsigned int vm_page_order(size_t size) { - return iorder2(vm_page_btop(vm_page_round(size))); + return log2_order(vm_page_btop(vm_page_round(size))); } static inline phys_addr_t |