Using macros, just to avoid repeating code.

Signed-off-by: Juan Quintela <quint...@redhat.com>
---
 include/migration/vmstate.h | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index e7e1705..001ff76 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -769,4 +769,26 @@ void vmstate_register_ram(struct MemoryRegion *memory, 
DeviceState *dev);
 void vmstate_unregister_ram(struct MemoryRegion *memory, DeviceState *dev);
 void vmstate_register_ram_global(struct MemoryRegion *memory);

+/* version is X or bigger */
+#define VMSTATE_X_PLUS(X)\
+static inline bool vmstate_##X##_plus(void *opaque, int version_id)\
+{\
+    return version_id >= X;\
+}
+
+VMSTATE_X_PLUS(2)
+VMSTATE_X_PLUS(3)
+VMSTATE_X_PLUS(4)
+VMSTATE_X_PLUS(5)
+VMSTATE_X_PLUS(6)
+VMSTATE_X_PLUS(7)
+VMSTATE_X_PLUS(8)
+VMSTATE_X_PLUS(9)
+VMSTATE_X_PLUS(10)
+VMSTATE_X_PLUS(11)
+VMSTATE_X_PLUS(12)
+VMSTATE_X_PLUS(13)
+VMSTATE_X_PLUS(14)
+VMSTATE_X_PLUS(15)
+
 #endif
-- 
1.9.0


Reply via email to