aboutsummaryrefslogtreecommitdiff
path: root/hw/hw.h
diff options
context:
space:
mode:
authorblueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162>2008-09-20 08:04:11 +0000
committerblueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162>2008-09-20 08:04:11 +0000
commit67d8cec34b1560973f5c25e14fac53b4ef5b0f6e (patch)
treee498b399e74162fc7b45d025170247f05990bcea /hw/hw.h
parentb40d0353b0d43517ba1ab1c07eb86a1cb27f87f9 (diff)
downloadqemu-67d8cec34b1560973f5c25e14fac53b4ef5b0f6e.zip
qemu-67d8cec34b1560973f5c25e14fac53b4ef5b0f6e.tar.gz
qemu-67d8cec34b1560973f5c25e14fac53b4ef5b0f6e.tar.bz2
Add signed versions of save/load functions
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5274 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw/hw.h')
-rw-r--r--hw/hw.h121
1 files changed, 113 insertions, 8 deletions
diff --git a/hw/hw.h b/hw/hw.h
index b84ace0..069c992 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -10,15 +10,31 @@
QEMUFile *qemu_fopen(const char *filename, const char *mode);
void qemu_fflush(QEMUFile *f);
void qemu_fclose(QEMUFile *f);
-void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size);
-void qemu_put_byte(QEMUFile *f, int v);
-void qemu_put_be16(QEMUFile *f, unsigned int v);
-void qemu_put_be32(QEMUFile *f, unsigned int v);
+void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, size_t size);
+void qemu_put_byte(QEMUFile *f, int8_t v);
+
+static inline void qemu_put_ubyte(QEMUFile *f, uint8_t v)
+{
+ qemu_put_byte(f, (int8_t)v);
+}
+
+#define qemu_put_sbyte qemu_put_byte
+
+void qemu_put_be16(QEMUFile *f, uint16_t v);
+void qemu_put_be32(QEMUFile *f, uint32_t v);
void qemu_put_be64(QEMUFile *f, uint64_t v);
-int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size);
-int qemu_get_byte(QEMUFile *f);
-unsigned int qemu_get_be16(QEMUFile *f);
-unsigned int qemu_get_be32(QEMUFile *f);
+size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size);
+int8_t qemu_get_byte(QEMUFile *f);
+
+static inline uint8_t qemu_get_ubyte(QEMUFile *f)
+{
+ return (uint8_t)qemu_get_byte(f);
+}
+
+#define qemu_get_sbyte qemu_get_byte
+
+uint16_t qemu_get_be16(QEMUFile *f);
+uint32_t qemu_get_be32(QEMUFile *f);
uint64_t qemu_get_be64(QEMUFile *f);
static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv)
@@ -61,17 +77,106 @@ static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv)
*pv = qemu_get_byte(f);
}
+// Signed versions for type safety
+static inline void qemu_put_sbuffer(QEMUFile *f, const int8_t *buf, size_t size)
+{
+ qemu_put_buffer(f, (const uint8_t *)buf, size);
+}
+
+static inline void qemu_put_sbe16(QEMUFile *f, int16_t v)
+{
+ qemu_put_be16(f, (uint16_t)v);
+}
+
+static inline void qemu_put_sbe32(QEMUFile *f, int32_t v)
+{
+ qemu_put_be32(f, (uint32_t)v);
+}
+
+static inline void qemu_put_sbe64(QEMUFile *f, int64_t v)
+{
+ qemu_put_be64(f, (uint64_t)v);
+}
+
+static inline size_t qemu_get_sbuffer(QEMUFile *f, int8_t *buf, size_t size)
+{
+ return qemu_get_buffer(f, (uint8_t *)buf, size);
+}
+
+static inline int16_t qemu_get_sbe16(QEMUFile *f)
+{
+ return (int16_t)qemu_get_be16(f);
+}
+
+static inline int32_t qemu_get_sbe32(QEMUFile *f)
+{
+ return (int32_t)qemu_get_be32(f);
+}
+
+static inline int64_t qemu_get_sbe64(QEMUFile *f)
+{
+ return (int64_t)qemu_get_be64(f);
+}
+
+static inline void qemu_put_s8s(QEMUFile *f, const int8_t *pv)
+{
+ qemu_put_8s(f, (const uint8_t *)pv);
+}
+
+static inline void qemu_put_sbe16s(QEMUFile *f, const int16_t *pv)
+{
+ qemu_put_be16s(f, (const uint16_t *)pv);
+}
+
+static inline void qemu_put_sbe32s(QEMUFile *f, const int32_t *pv)
+{
+ qemu_put_be32s(f, (const uint32_t *)pv);
+}
+
+static inline void qemu_put_sbe64s(QEMUFile *f, const int64_t *pv)
+{
+ qemu_put_be64s(f, (const uint64_t *)pv);
+}
+
+static inline void qemu_get_s8s(QEMUFile *f, int8_t *pv)
+{
+ qemu_get_8s(f, (uint8_t *)pv);
+}
+
+static inline void qemu_get_sbe16s(QEMUFile *f, int16_t *pv)
+{
+ qemu_get_be16s(f, (uint16_t *)pv);
+}
+
+static inline void qemu_get_sbe32s(QEMUFile *f, int32_t *pv)
+{
+ qemu_get_be32s(f, (uint32_t *)pv);
+}
+
+static inline void qemu_get_sbe64s(QEMUFile *f, int64_t *pv)
+{
+ qemu_get_be64s(f, (uint64_t *)pv);
+}
+
#ifdef NEED_CPU_H
#if TARGET_LONG_BITS == 64
#define qemu_put_betl qemu_put_be64
#define qemu_get_betl qemu_get_be64
#define qemu_put_betls qemu_put_be64s
#define qemu_get_betls qemu_get_be64s
+#define qemu_put_sbetl qemu_put_sbe64
+#define qemu_get_sbetl qemu_get_sbe64
+#define qemu_put_sbetls qemu_put_sbe64s
+#define qemu_get_sbetls qemu_get_sbe64s
#else
#define qemu_put_betl qemu_put_be32
#define qemu_get_betl qemu_get_be32
#define qemu_put_betls qemu_put_be32s
#define qemu_get_betls qemu_get_be32s
+#define qemu_put_sbetl qemu_put_sbe32
+#define qemu_get_sbetl qemu_get_sbe32
+#define qemu_put_sbetls qemu_put_sbe32s
+#define qemu_get_sbetls qemu_get_sbe32s
#endif
#endif