aboutsummaryrefslogtreecommitdiff
path: root/qemu-common.h
diff options
context:
space:
mode:
authorOrit Wasserman <owasserm@redhat.com>2012-08-06 21:42:50 +0300
committerJuan Quintela <quintela@redhat.com>2012-08-08 13:51:12 +0200
commit9fb26641ab497eda9138f9af75cbeb02ed59b5ae (patch)
treead4374600d582b27542fc8677048aa3f17f156ed /qemu-common.h
parent34c26412b76840e0cab9808047e29aebd429c139 (diff)
Add cache handling functions
Add MRU page cache mechanism. The page are accessed by their address. Signed-off-by: Benoit Hudzia <benoit.hudzia@sap.com> Signed-off-by: Petter Svard <petters@cs.umu.se> Signed-off-by: Aidan Shribman <aidan.shribman@sap.com> Signed-off-by: Orit Wasserman <owasserm@redhat.com> Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'qemu-common.h')
-rw-r--r--qemu-common.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/qemu-common.h b/qemu-common.h
index f16079f432..ff7026e377 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -1,3 +1,4 @@
+
/* Common header file that is included by all of qemu. */
#ifndef QEMU_COMMON_H
#define QEMU_COMMON_H
@@ -428,6 +429,18 @@ static inline uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c)
/* Round number up to multiple */
#define QEMU_ALIGN_UP(n, m) QEMU_ALIGN_DOWN((n) + (m) - 1, (m))
+static inline bool is_power_of_2(uint64_t value)
+{
+ if (!value) {
+ return 0;
+ }
+
+ return !(value & (value - 1));
+}
+
+/* round down to the nearest power of 2*/
+int64_t pow2floor(int64_t value);
+
#include "module.h"
#endif