aboutsummaryrefslogtreecommitdiff
path: root/memory.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2012-02-08 16:39:45 +0200
committerAvi Kivity <avi@redhat.com>2012-02-29 13:44:41 +0200
commit0e0d36b446bbe913edcf5a7af24590360845f824 (patch)
tree77d9dbe0e85897388cd6950b69c1cdeb42ed4909 /memory.c
parent72e22d2fe17b85e56b4f0c437c61c6e2de97b308 (diff)
downloadqemu-0e0d36b446bbe913edcf5a7af24590360845f824.zip
qemu-0e0d36b446bbe913edcf5a7af24590360845f824.tar.gz
qemu-0e0d36b446bbe913edcf5a7af24590360845f824.tar.bz2
memory: code motion: move MEMORY_LISTENER_CALL()
So it can be used in earlier code. Signed-off-by: Avi Kivity <avi@redhat.com> Reviewed-by: Richard Henderson <rth@twiddle.net>
Diffstat (limited to 'memory.c')
-rw-r--r--memory.c64
1 files changed, 32 insertions, 32 deletions
diff --git a/memory.c b/memory.c
index a8fb39e..90f5973 100644
--- a/memory.c
+++ b/memory.c
@@ -82,6 +82,38 @@ static AddrRange addrrange_intersection(AddrRange r1, AddrRange r2)
return addrrange_make(start, int128_sub(end, start));
}
+enum ListenerDirection { Forward, Reverse };
+
+#define MEMORY_LISTENER_CALL(_callback, _direction, _args...) \
+ do { \
+ MemoryListener *_listener; \
+ \
+ switch (_direction) { \
+ case Forward: \
+ QTAILQ_FOREACH(_listener, &memory_listeners, link) { \
+ _listener->_callback(_listener, ##_args); \
+ } \
+ break; \
+ case Reverse: \
+ QTAILQ_FOREACH_REVERSE(_listener, &memory_listeners, \
+ memory_listeners, link) { \
+ _listener->_callback(_listener, ##_args); \
+ } \
+ break; \
+ default: \
+ abort(); \
+ } \
+ } while (0)
+
+#define MEMORY_LISTENER_UPDATE_REGION(fr, as, dir, callback) \
+ MEMORY_LISTENER_CALL(callback, dir, &(MemoryRegionSection) { \
+ .mr = (fr)->mr, \
+ .address_space = (as)->root, \
+ .offset_within_region = (fr)->offset_in_region, \
+ .size = int128_get64((fr)->addr.size), \
+ .offset_within_address_space = int128_get64((fr)->addr.start), \
+ })
+
struct CoalescedMemoryRange {
AddrRange addr;
QTAILQ_ENTRY(CoalescedMemoryRange) link;
@@ -678,38 +710,6 @@ static void address_space_update_ioeventfds(AddressSpace *as)
as->ioeventfd_nb = ioeventfd_nb;
}
-enum ListenerDirection { Forward, Reverse };
-
-#define MEMORY_LISTENER_CALL(_callback, _direction, _args...) \
- do { \
- MemoryListener *_listener; \
- \
- switch (_direction) { \
- case Forward: \
- QTAILQ_FOREACH(_listener, &memory_listeners, link) { \
- _listener->_callback(_listener, ##_args); \
- } \
- break; \
- case Reverse: \
- QTAILQ_FOREACH_REVERSE(_listener, &memory_listeners, \
- memory_listeners, link) { \
- _listener->_callback(_listener, ##_args); \
- } \
- break; \
- default: \
- abort(); \
- } \
- } while (0)
-
-#define MEMORY_LISTENER_UPDATE_REGION(fr, as, dir, callback) \
- MEMORY_LISTENER_CALL(callback, dir, &(MemoryRegionSection) { \
- .mr = (fr)->mr, \
- .address_space = (as)->root, \
- .offset_within_region = (fr)->offset_in_region, \
- .size = int128_get64((fr)->addr.size), \
- .offset_within_address_space = int128_get64((fr)->addr.start), \
- })
-
static void address_space_update_topology_pass(AddressSpace *as,
FlatView old_view,
FlatView new_view,