summaryrefslogtreecommitdiffstats
path: root/util/cutils.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2015-07-24 13:33:12 +0100
committerPeter Maydell <peter.maydell@linaro.org>2015-09-07 14:19:01 +0100
commit8f1ed5f5081416d5d1cc9569aa826114c5b21213 (patch)
tree5572cb1ed9a1142cdbc77fe1fdb43de20b0e677b /util/cutils.c
parent10944a19209bb520054569e0f156f50338901264 (diff)
downloadhqemu-8f1ed5f5081416d5d1cc9569aa826114c5b21213.zip
hqemu-8f1ed5f5081416d5d1cc9569aa826114c5b21213.tar.gz
Make pow2ceil() and pow2floor() inline
Since the pow2floor() function is now used in a hot code path, make it inline; for consistency, provide pow2ceil() as an inline function too. Because these functions use ctz64() we have to put the inline versions into host-utils.h, so they have access to ctz64(), and move the inline is_power_of_2() along with them. We then need to include host-utils.h from qemu-common.h so that the files which use these functions via qemu-common.h still have access to them. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1437741192-20955-7-git-send-email-peter.maydell@linaro.org
Diffstat (limited to 'util/cutils.c')
-rw-r--r--util/cutils.c23
1 files changed, 0 insertions, 23 deletions
diff --git a/util/cutils.c b/util/cutils.c
index 43aafde..9234452 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -469,29 +469,6 @@ int qemu_parse_fd(const char *param)
return fd;
}
-/* round down to the nearest power of 2*/
-int64_t pow2floor(int64_t value)
-{
- if (!is_power_of_2(value)) {
- value = 0x8000000000000000ULL >> clz64(value);
- }
- return value;
-}
-
-/* round up to the nearest power of 2 (0 if overflow) */
-uint64_t pow2ceil(uint64_t value)
-{
- uint8_t nlz = clz64(value);
-
- if (is_power_of_2(value)) {
- return value;
- }
- if (!nlz) {
- return 0;
- }
- return 1ULL << (64 - nlz);
-}
-
/*
* Implementation of ULEB128 (http://en.wikipedia.org/wiki/LEB128)
* Input is limited to 14-bit numbers
OpenPOWER on IntegriCloud