multifd: multifd_queue_page only needs the qemufile
[qemu/kevin.git] / include / migration / qemu-file-types.h
blob2867e3da84ab94eda680b9f0033a7f370ec75a3c
1 /*
2 * QEMU System Emulator
4 * Copyright (c) 2003-2008 Fabrice Bellard
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
25 #ifndef MIGRATION_QEMU_FILE_TYPES_H
26 #define MIGRATION_QEMU_FILE_TYPES_H
28 int qemu_file_get_error(QEMUFile *f);
30 void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, size_t size);
31 void qemu_put_byte(QEMUFile *f, int v);
33 #define qemu_put_sbyte qemu_put_byte
35 void qemu_put_be16(QEMUFile *f, unsigned int v);
36 void qemu_put_be32(QEMUFile *f, unsigned int v);
37 void qemu_put_be64(QEMUFile *f, uint64_t v);
38 size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size);
40 int qemu_get_byte(QEMUFile *f);
42 static inline unsigned int qemu_get_ubyte(QEMUFile *f)
44 return (unsigned int)qemu_get_byte(f);
47 #define qemu_get_sbyte qemu_get_byte
49 unsigned int qemu_get_be16(QEMUFile *f);
50 unsigned int qemu_get_be32(QEMUFile *f);
51 uint64_t qemu_get_be64(QEMUFile *f);
53 static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv)
55 qemu_put_be64(f, *pv);
58 static inline void qemu_put_be32s(QEMUFile *f, const uint32_t *pv)
60 qemu_put_be32(f, *pv);
63 static inline void qemu_put_be16s(QEMUFile *f, const uint16_t *pv)
65 qemu_put_be16(f, *pv);
68 static inline void qemu_put_8s(QEMUFile *f, const uint8_t *pv)
70 qemu_put_byte(f, *pv);
73 static inline void qemu_get_be64s(QEMUFile *f, uint64_t *pv)
75 *pv = qemu_get_be64(f);
78 static inline void qemu_get_be32s(QEMUFile *f, uint32_t *pv)
80 *pv = qemu_get_be32(f);
83 static inline void qemu_get_be16s(QEMUFile *f, uint16_t *pv)
85 *pv = qemu_get_be16(f);
88 static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv)
90 *pv = qemu_get_byte(f);
93 /* Signed versions for type safety */
94 static inline void qemu_put_sbe16(QEMUFile *f, int v)
96 qemu_put_be16(f, (unsigned int)v);
99 static inline void qemu_put_sbe32(QEMUFile *f, int v)
101 qemu_put_be32(f, (unsigned int)v);
104 static inline void qemu_put_sbe64(QEMUFile *f, int64_t v)
106 qemu_put_be64(f, (uint64_t)v);
109 static inline int qemu_get_sbe16(QEMUFile *f)
111 return (int)qemu_get_be16(f);
114 static inline int qemu_get_sbe32(QEMUFile *f)
116 return (int)qemu_get_be32(f);
119 static inline int64_t qemu_get_sbe64(QEMUFile *f)
121 return (int64_t)qemu_get_be64(f);
124 static inline void qemu_put_s8s(QEMUFile *f, const int8_t *pv)
126 qemu_put_8s(f, (const uint8_t *)pv);
129 static inline void qemu_put_sbe16s(QEMUFile *f, const int16_t *pv)
131 qemu_put_be16s(f, (const uint16_t *)pv);
134 static inline void qemu_put_sbe32s(QEMUFile *f, const int32_t *pv)
136 qemu_put_be32s(f, (const uint32_t *)pv);
139 static inline void qemu_put_sbe64s(QEMUFile *f, const int64_t *pv)
141 qemu_put_be64s(f, (const uint64_t *)pv);
144 static inline void qemu_get_s8s(QEMUFile *f, int8_t *pv)
146 qemu_get_8s(f, (uint8_t *)pv);
149 static inline void qemu_get_sbe16s(QEMUFile *f, int16_t *pv)
151 qemu_get_be16s(f, (uint16_t *)pv);
154 static inline void qemu_get_sbe32s(QEMUFile *f, int32_t *pv)
156 qemu_get_be32s(f, (uint32_t *)pv);
159 static inline void qemu_get_sbe64s(QEMUFile *f, int64_t *pv)
161 qemu_get_be64s(f, (uint64_t *)pv);
164 size_t qemu_get_counted_string(QEMUFile *f, char buf[256]);
166 void qemu_put_counted_string(QEMUFile *f, const char *name);
168 int qemu_file_rate_limit(QEMUFile *f);
170 #endif