aboutsummaryrefslogtreecommitdiffstats
path: root/qemu_file.h
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-03 19:30:32 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-03 19:30:32 -0800
commit8b23a6c7e1aee255004dd19098d4c2462b61b849 (patch)
tree7a4d682ba51f0ff0364c5ca2509f515bdaf96de9 /qemu_file.h
parentf721e3ac031f892af46f255a47d7f54a91317b30 (diff)
downloadexternal_qemu-8b23a6c7e1aee255004dd19098d4c2462b61b849.zip
external_qemu-8b23a6c7e1aee255004dd19098d4c2462b61b849.tar.gz
external_qemu-8b23a6c7e1aee255004dd19098d4c2462b61b849.tar.bz2
auto import from //depot/cupcake/@135843
Diffstat (limited to 'qemu_file.h')
-rw-r--r--qemu_file.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/qemu_file.h b/qemu_file.h
new file mode 100644
index 0000000..682e092
--- /dev/null
+++ b/qemu_file.h
@@ -0,0 +1,52 @@
+#ifndef _QEMU_FILE_H
+#define _QEMU_FILE_H
+
+#include "hw/hw.h"
+
+typedef enum {
+ Q_FIELD_END, /* mark end of field list */
+ Q_FIELD_BYTE, /* for 1-byte fields */
+ Q_FIELD_INT16, /* for 2-byte fields */
+ Q_FIELD_INT32, /* for 4-byte fields */
+ Q_FIELD_INT64, /* for 8-byte fields */
+ Q_FIELD_BUFFER, /* for buffer fields */
+ Q_FIELD_BUFFER_SIZE, /* to specify the size of buffers */
+
+#if TARGET_LONG_BITS == 64
+ Q_FIELD_TL = Q_FIELD_INT64, /* target long, either 4 or 8 bytes */
+#else
+ Q_FIELD_TL = Q_FIELD_INT32
+#endif
+
+} QFieldType;
+
+typedef struct {
+ QFieldType type : 16; /* field type */
+ uint16_t offset; /* offset of field in structure */
+} QField;
+
+#define QFIELD_BEGIN(name) \
+ static const QField name[] = {
+
+#define _QFIELD_(t, f) { t, offsetof(QFIELD_STRUCT,f) }
+#define QFIELD_BYTE(f) _QFIELD_(Q_FIELD_BYTE, f)
+#define QFIELD_INT16(f) _QFIELD_(Q_FIELD_INT16, f)
+#define QFIELD_INT32(f) _QFIELD_(Q_FIELD_INT32, f)
+#define QFIELD_INT64(f) _QFIELD_(Q_FIELD_INT64, f)
+#define QFIELD_TL(f) _QFIELD_(Q_FIELD_TL, f)
+
+#define _QFIELD_SIZEOF(f) sizeof(((QFIELD_STRUCT*)0)->f)
+
+#define QFIELD_BUFFER(f) \
+ _QFIELD_(Q_FIELD_BUFFER, f), \
+ { Q_FIELD_BUFFER_SIZE, (uint16_t)(_QFIELD_SIZEOF(f) >> 16) }, \
+ { Q_FIELD_BUFFER_SIZE, (uint16_t) _QFIELD_SIZEOF(f) }
+
+#define QFIELD_END \
+ { Q_FIELD_END, 0 }, \
+ };
+
+extern void qemu_put_struct(QEMUFile* f, const QField* fields, const void* s);
+extern int qemu_get_struct(QEMUFile* f, const QField* fields, void* s);
+
+#endif /* _QEMU_FILE_H */