nbd: Fix trace message for disconnect
[qemu/ar7.git] / include / migration / qemu-file-types.h
blobbd6d7dd7f96758cd841df44db4433be5a456a867
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 QEMU_FILE_H
26 #define QEMU_FILE_H
28 void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, size_t size);
29 void qemu_put_byte(QEMUFile *f, int v);
31 #define qemu_put_sbyte qemu_put_byte
33 void qemu_put_be16(QEMUFile *f, unsigned int v);
34 void qemu_put_be32(QEMUFile *f, unsigned int v);
35 void qemu_put_be64(QEMUFile *f, uint64_t v);
36 size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size);
38 int qemu_get_byte(QEMUFile *f);
40 static inline unsigned int qemu_get_ubyte(QEMUFile *f)
42 return (unsigned int)qemu_get_byte(f);
45 #define qemu_get_sbyte qemu_get_byte
47 unsigned int qemu_get_be16(QEMUFile *f);
48 unsigned int qemu_get_be32(QEMUFile *f);
49 uint64_t qemu_get_be64(QEMUFile *f);
51 static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv)
53 qemu_put_be64(f, *pv);
56 static inline void qemu_put_be32s(QEMUFile *f, const uint32_t *pv)
58 qemu_put_be32(f, *pv);
61 static inline void qemu_put_be16s(QEMUFile *f, const uint16_t *pv)
63 qemu_put_be16(f, *pv);
66 static inline void qemu_put_8s(QEMUFile *f, const uint8_t *pv)
68 qemu_put_byte(f, *pv);
71 static inline void qemu_get_be64s(QEMUFile *f, uint64_t *pv)
73 *pv = qemu_get_be64(f);
76 static inline void qemu_get_be32s(QEMUFile *f, uint32_t *pv)
78 *pv = qemu_get_be32(f);
81 static inline void qemu_get_be16s(QEMUFile *f, uint16_t *pv)
83 *pv = qemu_get_be16(f);
86 static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv)
88 *pv = qemu_get_byte(f);
91 /* Signed versions for type safety */
92 static inline void qemu_put_sbe16(QEMUFile *f, int v)
94 qemu_put_be16(f, (unsigned int)v);
97 static inline void qemu_put_sbe32(QEMUFile *f, int v)
99 qemu_put_be32(f, (unsigned int)v);
102 static inline void qemu_put_sbe64(QEMUFile *f, int64_t v)
104 qemu_put_be64(f, (uint64_t)v);
107 static inline int qemu_get_sbe16(QEMUFile *f)
109 return (int)qemu_get_be16(f);
112 static inline int qemu_get_sbe32(QEMUFile *f)
114 return (int)qemu_get_be32(f);
117 static inline int64_t qemu_get_sbe64(QEMUFile *f)
119 return (int64_t)qemu_get_be64(f);
122 static inline void qemu_put_s8s(QEMUFile *f, const int8_t *pv)
124 qemu_put_8s(f, (const uint8_t *)pv);
127 static inline void qemu_put_sbe16s(QEMUFile *f, const int16_t *pv)
129 qemu_put_be16s(f, (const uint16_t *)pv);
132 static inline void qemu_put_sbe32s(QEMUFile *f, const int32_t *pv)
134 qemu_put_be32s(f, (const uint32_t *)pv);
137 static inline void qemu_put_sbe64s(QEMUFile *f, const int64_t *pv)
139 qemu_put_be64s(f, (const uint64_t *)pv);
142 static inline void qemu_get_s8s(QEMUFile *f, int8_t *pv)
144 qemu_get_8s(f, (uint8_t *)pv);
147 static inline void qemu_get_sbe16s(QEMUFile *f, int16_t *pv)
149 qemu_get_be16s(f, (uint16_t *)pv);
152 static inline void qemu_get_sbe32s(QEMUFile *f, int32_t *pv)
154 qemu_get_be32s(f, (uint32_t *)pv);
157 static inline void qemu_get_sbe64s(QEMUFile *f, int64_t *pv)
159 qemu_get_be64s(f, (uint64_t *)pv);
162 int qemu_file_rate_limit(QEMUFile *f);
164 #endif