diff options
author | Richard Braun <rbraun@sceen.net> | 2018-02-24 15:36:59 +0100 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2018-02-24 15:36:59 +0100 |
commit | 253913f1af93ca59066df3682766eefdbe446f3b (patch) | |
tree | 4e9e973c09cdd33f1d728356b6d226581c043aeb | |
parent | d6415186a2cbcd75c7b9bacf235dc03a8145f2c2 (diff) |
kern/log2: fix naming
-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 1d9fe4e..398e03f 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 762aaa7..1799b82 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 6a161c0..8cd7a11 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 |