From 9fb26641ab497eda9138f9af75cbeb02ed59b5ae Mon Sep 17 00:00:00 2001 From: Orit Wasserman Date: Mon, 6 Aug 2012 21:42:50 +0300 Subject: Add cache handling functions Add MRU page cache mechanism. The page are accessed by their address. Signed-off-by: Benoit Hudzia Signed-off-by: Petter Svard Signed-off-by: Aidan Shribman Signed-off-by: Orit Wasserman Reviewed-by: Luiz Capitulino Reviewed-by: Eric Blake --- cutils.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'cutils.c') diff --git a/cutils.c b/cutils.c index 9d4c570..35e2e2b 100644 --- a/cutils.c +++ b/cutils.c @@ -382,3 +382,12 @@ 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; +} -- cgit v1.1