]>
Commit | Line | Data |
---|---|---|
08a0aee1 JQ |
1 | /* |
2 | * QEMU System Emulator | |
3 | * | |
4 | * Copyright (c) 2003-2008 Fabrice Bellard | |
5 | * | |
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: | |
12 | * | |
13 | * The above copyright notice and this permission notice shall be included in | |
14 | * all copies or substantial portions of the Software. | |
15 | * | |
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. | |
23 | */ | |
24 | ||
58ea30f5 MA |
25 | #ifndef MIGRATION_QEMU_FILE_TYPES_H |
26 | #define MIGRATION_QEMU_FILE_TYPES_H | |
08a0aee1 | 27 | |
d8903441 MAL |
28 | int qemu_file_get_error(QEMUFile *f); |
29 | ||
08a0aee1 JQ |
30 | void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, size_t size); |
31 | void qemu_put_byte(QEMUFile *f, int v); | |
32 | ||
33 | #define qemu_put_sbyte qemu_put_byte | |
34 | ||
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); | |
39 | ||
40 | int qemu_get_byte(QEMUFile *f); | |
41 | ||
42 | static inline unsigned int qemu_get_ubyte(QEMUFile *f) | |
43 | { | |
44 | return (unsigned int)qemu_get_byte(f); | |
45 | } | |
46 | ||
47 | #define qemu_get_sbyte qemu_get_byte | |
48 | ||
49 | unsigned int qemu_get_be16(QEMUFile *f); | |
50 | unsigned int qemu_get_be32(QEMUFile *f); | |
51 | uint64_t qemu_get_be64(QEMUFile *f); | |
52 | ||
53 | static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv) | |
54 | { | |
55 | qemu_put_be64(f, *pv); | |
56 | } | |
57 | ||
58 | static inline void qemu_put_be32s(QEMUFile *f, const uint32_t *pv) | |
59 | { | |
60 | qemu_put_be32(f, *pv); | |
61 | } | |
62 | ||
63 | static inline void qemu_put_be16s(QEMUFile *f, const uint16_t *pv) | |
64 | { | |
65 | qemu_put_be16(f, *pv); | |
66 | } | |
67 | ||
68 | static inline void qemu_put_8s(QEMUFile *f, const uint8_t *pv) | |
69 | { | |
70 | qemu_put_byte(f, *pv); | |
71 | } | |
72 | ||
73 | static inline void qemu_get_be64s(QEMUFile *f, uint64_t *pv) | |
74 | { | |
75 | *pv = qemu_get_be64(f); | |
76 | } | |
77 | ||
78 | static inline void qemu_get_be32s(QEMUFile *f, uint32_t *pv) | |
79 | { | |
80 | *pv = qemu_get_be32(f); | |
81 | } | |
82 | ||
83 | static inline void qemu_get_be16s(QEMUFile *f, uint16_t *pv) | |
84 | { | |
85 | *pv = qemu_get_be16(f); | |
86 | } | |
87 | ||
88 | static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv) | |
89 | { | |
90 | *pv = qemu_get_byte(f); | |
91 | } | |
92 | ||
93 | /* Signed versions for type safety */ | |
94 | static inline void qemu_put_sbe16(QEMUFile *f, int v) | |
95 | { | |
96 | qemu_put_be16(f, (unsigned int)v); | |
97 | } | |
98 | ||
99 | static inline void qemu_put_sbe32(QEMUFile *f, int v) | |
100 | { | |
101 | qemu_put_be32(f, (unsigned int)v); | |
102 | } | |
103 | ||
104 | static inline void qemu_put_sbe64(QEMUFile *f, int64_t v) | |
105 | { | |
106 | qemu_put_be64(f, (uint64_t)v); | |
107 | } | |
108 | ||
109 | static inline int qemu_get_sbe16(QEMUFile *f) | |
110 | { | |
111 | return (int)qemu_get_be16(f); | |
112 | } | |
113 | ||
114 | static inline int qemu_get_sbe32(QEMUFile *f) | |
115 | { | |
116 | return (int)qemu_get_be32(f); | |
117 | } | |
118 | ||
119 | static inline int64_t qemu_get_sbe64(QEMUFile *f) | |
120 | { | |
121 | return (int64_t)qemu_get_be64(f); | |
122 | } | |
123 | ||
124 | static inline void qemu_put_s8s(QEMUFile *f, const int8_t *pv) | |
125 | { | |
126 | qemu_put_8s(f, (const uint8_t *)pv); | |
127 | } | |
128 | ||
129 | static inline void qemu_put_sbe16s(QEMUFile *f, const int16_t *pv) | |
130 | { | |
131 | qemu_put_be16s(f, (const uint16_t *)pv); | |
132 | } | |
133 | ||
134 | static inline void qemu_put_sbe32s(QEMUFile *f, const int32_t *pv) | |
135 | { | |
136 | qemu_put_be32s(f, (const uint32_t *)pv); | |
137 | } | |
138 | ||
139 | static inline void qemu_put_sbe64s(QEMUFile *f, const int64_t *pv) | |
140 | { | |
141 | qemu_put_be64s(f, (const uint64_t *)pv); | |
142 | } | |
143 | ||
144 | static inline void qemu_get_s8s(QEMUFile *f, int8_t *pv) | |
145 | { | |
146 | qemu_get_8s(f, (uint8_t *)pv); | |
147 | } | |
148 | ||
149 | static inline void qemu_get_sbe16s(QEMUFile *f, int16_t *pv) | |
150 | { | |
151 | qemu_get_be16s(f, (uint16_t *)pv); | |
152 | } | |
153 | ||
154 | static inline void qemu_get_sbe32s(QEMUFile *f, int32_t *pv) | |
155 | { | |
156 | qemu_get_be32s(f, (uint32_t *)pv); | |
157 | } | |
158 | ||
159 | static inline void qemu_get_sbe64s(QEMUFile *f, int64_t *pv) | |
160 | { | |
161 | qemu_get_be64s(f, (uint64_t *)pv); | |
162 | } | |
163 | ||
3170a645 MAL |
164 | size_t qemu_get_counted_string(QEMUFile *f, char buf[256]); |
165 | ||
166 | void qemu_put_counted_string(QEMUFile *f, const char *name); | |
167 | ||
08a0aee1 JQ |
168 | int qemu_file_rate_limit(QEMUFile *f); |
169 | ||
170 | #endif |