Commit 67d8cec34b1560973f5c25e14fac53b4ef5b0f6e
1 parent
b40d0353
Add signed versions of save/load functions
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5274 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
12 changed files
with
183 additions
and
78 deletions
hw/e1000.c
@@ -102,8 +102,8 @@ typedef struct E1000State_st { | @@ -102,8 +102,8 @@ typedef struct E1000State_st { | ||
102 | uint32_t paylen; | 102 | uint32_t paylen; |
103 | uint16_t tso_frames; | 103 | uint16_t tso_frames; |
104 | char tse; | 104 | char tse; |
105 | - char ip; | ||
106 | - char tcp; | 105 | + int8_t ip; |
106 | + int8_t tcp; | ||
107 | char cptse; // current packet tse bit | 107 | char cptse; // current packet tse bit |
108 | } tx; | 108 | } tx; |
109 | 109 | ||
@@ -824,8 +824,8 @@ nic_save(QEMUFile *f, void *opaque) | @@ -824,8 +824,8 @@ nic_save(QEMUFile *f, void *opaque) | ||
824 | qemu_put_be16s(f, &s->tx.size); | 824 | qemu_put_be16s(f, &s->tx.size); |
825 | qemu_put_be16s(f, &s->tx.tso_frames); | 825 | qemu_put_be16s(f, &s->tx.tso_frames); |
826 | qemu_put_8s(f, &s->tx.sum_needed); | 826 | qemu_put_8s(f, &s->tx.sum_needed); |
827 | - qemu_put_8s(f, &s->tx.ip); | ||
828 | - qemu_put_8s(f, &s->tx.tcp); | 827 | + qemu_put_s8s(f, &s->tx.ip); |
828 | + qemu_put_s8s(f, &s->tx.tcp); | ||
829 | qemu_put_buffer(f, s->tx.header, sizeof s->tx.header); | 829 | qemu_put_buffer(f, s->tx.header, sizeof s->tx.header); |
830 | qemu_put_buffer(f, s->tx.data, sizeof s->tx.data); | 830 | qemu_put_buffer(f, s->tx.data, sizeof s->tx.data); |
831 | for (i = 0; i < 64; i++) | 831 | for (i = 0; i < 64; i++) |
@@ -849,7 +849,7 @@ nic_load(QEMUFile *f, void *opaque, int version_id) | @@ -849,7 +849,7 @@ nic_load(QEMUFile *f, void *opaque, int version_id) | ||
849 | if ((ret = pci_device_load(&s->dev, f)) < 0) | 849 | if ((ret = pci_device_load(&s->dev, f)) < 0) |
850 | return ret; | 850 | return ret; |
851 | if (version_id == 1) | 851 | if (version_id == 1) |
852 | - qemu_get_be32s(f, &i); /* once some unused instance id */ | 852 | + qemu_get_sbe32s(f, &i); /* once some unused instance id */ |
853 | qemu_get_be32s(f, &s->mmio_base); | 853 | qemu_get_be32s(f, &s->mmio_base); |
854 | qemu_get_be32s(f, &s->rxbuf_size); | 854 | qemu_get_be32s(f, &s->rxbuf_size); |
855 | qemu_get_be32s(f, &s->rxbuf_min_shift); | 855 | qemu_get_be32s(f, &s->rxbuf_min_shift); |
@@ -870,8 +870,8 @@ nic_load(QEMUFile *f, void *opaque, int version_id) | @@ -870,8 +870,8 @@ nic_load(QEMUFile *f, void *opaque, int version_id) | ||
870 | qemu_get_be16s(f, &s->tx.size); | 870 | qemu_get_be16s(f, &s->tx.size); |
871 | qemu_get_be16s(f, &s->tx.tso_frames); | 871 | qemu_get_be16s(f, &s->tx.tso_frames); |
872 | qemu_get_8s(f, &s->tx.sum_needed); | 872 | qemu_get_8s(f, &s->tx.sum_needed); |
873 | - qemu_get_8s(f, &s->tx.ip); | ||
874 | - qemu_get_8s(f, &s->tx.tcp); | 873 | + qemu_get_s8s(f, &s->tx.ip); |
874 | + qemu_get_s8s(f, &s->tx.tcp); | ||
875 | qemu_get_buffer(f, s->tx.header, sizeof s->tx.header); | 875 | qemu_get_buffer(f, s->tx.header, sizeof s->tx.header); |
876 | qemu_get_buffer(f, s->tx.data, sizeof s->tx.data); | 876 | qemu_get_buffer(f, s->tx.data, sizeof s->tx.data); |
877 | for (i = 0; i < 64; i++) | 877 | for (i = 0; i < 64; i++) |
hw/esp.c
@@ -578,7 +578,7 @@ static void esp_save(QEMUFile *f, void *opaque) | @@ -578,7 +578,7 @@ static void esp_save(QEMUFile *f, void *opaque) | ||
578 | 578 | ||
579 | qemu_put_buffer(f, s->rregs, ESP_REGS); | 579 | qemu_put_buffer(f, s->rregs, ESP_REGS); |
580 | qemu_put_buffer(f, s->wregs, ESP_REGS); | 580 | qemu_put_buffer(f, s->wregs, ESP_REGS); |
581 | - qemu_put_be32s(f, (uint32_t *)&s->ti_size); | 581 | + qemu_put_sbe32s(f, &s->ti_size); |
582 | qemu_put_be32s(f, &s->ti_rptr); | 582 | qemu_put_be32s(f, &s->ti_rptr); |
583 | qemu_put_be32s(f, &s->ti_wptr); | 583 | qemu_put_be32s(f, &s->ti_wptr); |
584 | qemu_put_buffer(f, s->ti_buf, TI_BUFSZ); | 584 | qemu_put_buffer(f, s->ti_buf, TI_BUFSZ); |
@@ -600,7 +600,7 @@ static int esp_load(QEMUFile *f, void *opaque, int version_id) | @@ -600,7 +600,7 @@ static int esp_load(QEMUFile *f, void *opaque, int version_id) | ||
600 | 600 | ||
601 | qemu_get_buffer(f, s->rregs, ESP_REGS); | 601 | qemu_get_buffer(f, s->rregs, ESP_REGS); |
602 | qemu_get_buffer(f, s->wregs, ESP_REGS); | 602 | qemu_get_buffer(f, s->wregs, ESP_REGS); |
603 | - qemu_get_be32s(f, (uint32_t *)&s->ti_size); | 603 | + qemu_get_sbe32s(f, &s->ti_size); |
604 | qemu_get_be32s(f, &s->ti_rptr); | 604 | qemu_get_be32s(f, &s->ti_rptr); |
605 | qemu_get_be32s(f, &s->ti_wptr); | 605 | qemu_get_be32s(f, &s->ti_wptr); |
606 | qemu_get_buffer(f, s->ti_buf, TI_BUFSZ); | 606 | qemu_get_buffer(f, s->ti_buf, TI_BUFSZ); |
hw/hw.h
@@ -10,15 +10,31 @@ | @@ -10,15 +10,31 @@ | ||
10 | QEMUFile *qemu_fopen(const char *filename, const char *mode); | 10 | QEMUFile *qemu_fopen(const char *filename, const char *mode); |
11 | void qemu_fflush(QEMUFile *f); | 11 | void qemu_fflush(QEMUFile *f); |
12 | void qemu_fclose(QEMUFile *f); | 12 | void qemu_fclose(QEMUFile *f); |
13 | -void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size); | ||
14 | -void qemu_put_byte(QEMUFile *f, int v); | ||
15 | -void qemu_put_be16(QEMUFile *f, unsigned int v); | ||
16 | -void qemu_put_be32(QEMUFile *f, unsigned int v); | 13 | +void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, size_t size); |
14 | +void qemu_put_byte(QEMUFile *f, int8_t v); | ||
15 | + | ||
16 | +static inline void qemu_put_ubyte(QEMUFile *f, uint8_t v) | ||
17 | +{ | ||
18 | + qemu_put_byte(f, (int8_t)v); | ||
19 | +} | ||
20 | + | ||
21 | +#define qemu_put_sbyte qemu_put_byte | ||
22 | + | ||
23 | +void qemu_put_be16(QEMUFile *f, uint16_t v); | ||
24 | +void qemu_put_be32(QEMUFile *f, uint32_t v); | ||
17 | void qemu_put_be64(QEMUFile *f, uint64_t v); | 25 | void qemu_put_be64(QEMUFile *f, uint64_t v); |
18 | -int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size); | ||
19 | -int qemu_get_byte(QEMUFile *f); | ||
20 | -unsigned int qemu_get_be16(QEMUFile *f); | ||
21 | -unsigned int qemu_get_be32(QEMUFile *f); | 26 | +size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size); |
27 | +int8_t qemu_get_byte(QEMUFile *f); | ||
28 | + | ||
29 | +static inline uint8_t qemu_get_ubyte(QEMUFile *f) | ||
30 | +{ | ||
31 | + return (uint8_t)qemu_get_byte(f); | ||
32 | +} | ||
33 | + | ||
34 | +#define qemu_get_sbyte qemu_get_byte | ||
35 | + | ||
36 | +uint16_t qemu_get_be16(QEMUFile *f); | ||
37 | +uint32_t qemu_get_be32(QEMUFile *f); | ||
22 | uint64_t qemu_get_be64(QEMUFile *f); | 38 | uint64_t qemu_get_be64(QEMUFile *f); |
23 | 39 | ||
24 | static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv) | 40 | 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) | @@ -61,17 +77,106 @@ static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv) | ||
61 | *pv = qemu_get_byte(f); | 77 | *pv = qemu_get_byte(f); |
62 | } | 78 | } |
63 | 79 | ||
80 | +// Signed versions for type safety | ||
81 | +static inline void qemu_put_sbuffer(QEMUFile *f, const int8_t *buf, size_t size) | ||
82 | +{ | ||
83 | + qemu_put_buffer(f, (const uint8_t *)buf, size); | ||
84 | +} | ||
85 | + | ||
86 | +static inline void qemu_put_sbe16(QEMUFile *f, int16_t v) | ||
87 | +{ | ||
88 | + qemu_put_be16(f, (uint16_t)v); | ||
89 | +} | ||
90 | + | ||
91 | +static inline void qemu_put_sbe32(QEMUFile *f, int32_t v) | ||
92 | +{ | ||
93 | + qemu_put_be32(f, (uint32_t)v); | ||
94 | +} | ||
95 | + | ||
96 | +static inline void qemu_put_sbe64(QEMUFile *f, int64_t v) | ||
97 | +{ | ||
98 | + qemu_put_be64(f, (uint64_t)v); | ||
99 | +} | ||
100 | + | ||
101 | +static inline size_t qemu_get_sbuffer(QEMUFile *f, int8_t *buf, size_t size) | ||
102 | +{ | ||
103 | + return qemu_get_buffer(f, (uint8_t *)buf, size); | ||
104 | +} | ||
105 | + | ||
106 | +static inline int16_t qemu_get_sbe16(QEMUFile *f) | ||
107 | +{ | ||
108 | + return (int16_t)qemu_get_be16(f); | ||
109 | +} | ||
110 | + | ||
111 | +static inline int32_t qemu_get_sbe32(QEMUFile *f) | ||
112 | +{ | ||
113 | + return (int32_t)qemu_get_be32(f); | ||
114 | +} | ||
115 | + | ||
116 | +static inline int64_t qemu_get_sbe64(QEMUFile *f) | ||
117 | +{ | ||
118 | + return (int64_t)qemu_get_be64(f); | ||
119 | +} | ||
120 | + | ||
121 | +static inline void qemu_put_s8s(QEMUFile *f, const int8_t *pv) | ||
122 | +{ | ||
123 | + qemu_put_8s(f, (const uint8_t *)pv); | ||
124 | +} | ||
125 | + | ||
126 | +static inline void qemu_put_sbe16s(QEMUFile *f, const int16_t *pv) | ||
127 | +{ | ||
128 | + qemu_put_be16s(f, (const uint16_t *)pv); | ||
129 | +} | ||
130 | + | ||
131 | +static inline void qemu_put_sbe32s(QEMUFile *f, const int32_t *pv) | ||
132 | +{ | ||
133 | + qemu_put_be32s(f, (const uint32_t *)pv); | ||
134 | +} | ||
135 | + | ||
136 | +static inline void qemu_put_sbe64s(QEMUFile *f, const int64_t *pv) | ||
137 | +{ | ||
138 | + qemu_put_be64s(f, (const uint64_t *)pv); | ||
139 | +} | ||
140 | + | ||
141 | +static inline void qemu_get_s8s(QEMUFile *f, int8_t *pv) | ||
142 | +{ | ||
143 | + qemu_get_8s(f, (uint8_t *)pv); | ||
144 | +} | ||
145 | + | ||
146 | +static inline void qemu_get_sbe16s(QEMUFile *f, int16_t *pv) | ||
147 | +{ | ||
148 | + qemu_get_be16s(f, (uint16_t *)pv); | ||
149 | +} | ||
150 | + | ||
151 | +static inline void qemu_get_sbe32s(QEMUFile *f, int32_t *pv) | ||
152 | +{ | ||
153 | + qemu_get_be32s(f, (uint32_t *)pv); | ||
154 | +} | ||
155 | + | ||
156 | +static inline void qemu_get_sbe64s(QEMUFile *f, int64_t *pv) | ||
157 | +{ | ||
158 | + qemu_get_be64s(f, (uint64_t *)pv); | ||
159 | +} | ||
160 | + | ||
64 | #ifdef NEED_CPU_H | 161 | #ifdef NEED_CPU_H |
65 | #if TARGET_LONG_BITS == 64 | 162 | #if TARGET_LONG_BITS == 64 |
66 | #define qemu_put_betl qemu_put_be64 | 163 | #define qemu_put_betl qemu_put_be64 |
67 | #define qemu_get_betl qemu_get_be64 | 164 | #define qemu_get_betl qemu_get_be64 |
68 | #define qemu_put_betls qemu_put_be64s | 165 | #define qemu_put_betls qemu_put_be64s |
69 | #define qemu_get_betls qemu_get_be64s | 166 | #define qemu_get_betls qemu_get_be64s |
167 | +#define qemu_put_sbetl qemu_put_sbe64 | ||
168 | +#define qemu_get_sbetl qemu_get_sbe64 | ||
169 | +#define qemu_put_sbetls qemu_put_sbe64s | ||
170 | +#define qemu_get_sbetls qemu_get_sbe64s | ||
70 | #else | 171 | #else |
71 | #define qemu_put_betl qemu_put_be32 | 172 | #define qemu_put_betl qemu_put_be32 |
72 | #define qemu_get_betl qemu_get_be32 | 173 | #define qemu_get_betl qemu_get_be32 |
73 | #define qemu_put_betls qemu_put_be32s | 174 | #define qemu_put_betls qemu_put_be32s |
74 | #define qemu_get_betls qemu_get_be32s | 175 | #define qemu_get_betls qemu_get_be32s |
176 | +#define qemu_put_sbetl qemu_put_sbe32 | ||
177 | +#define qemu_get_sbetl qemu_get_sbe32 | ||
178 | +#define qemu_put_sbetls qemu_put_sbe32s | ||
179 | +#define qemu_get_sbetls qemu_get_sbe32s | ||
75 | #endif | 180 | #endif |
76 | #endif | 181 | #endif |
77 | 182 |
hw/pcnet.c
@@ -1877,9 +1877,9 @@ static void pcnet_save(QEMUFile *f, void *opaque) | @@ -1877,9 +1877,9 @@ static void pcnet_save(QEMUFile *f, void *opaque) | ||
1877 | if (s->pci_dev) | 1877 | if (s->pci_dev) |
1878 | pci_device_save(s->pci_dev, f); | 1878 | pci_device_save(s->pci_dev, f); |
1879 | 1879 | ||
1880 | - qemu_put_be32(f, s->rap); | ||
1881 | - qemu_put_be32(f, s->isr); | ||
1882 | - qemu_put_be32(f, s->lnkst); | 1880 | + qemu_put_sbe32(f, s->rap); |
1881 | + qemu_put_sbe32(f, s->isr); | ||
1882 | + qemu_put_sbe32(f, s->lnkst); | ||
1883 | qemu_put_be32s(f, &s->rdra); | 1883 | qemu_put_be32s(f, &s->rdra); |
1884 | qemu_put_be32s(f, &s->tdra); | 1884 | qemu_put_be32s(f, &s->tdra); |
1885 | qemu_put_buffer(f, s->prom, 16); | 1885 | qemu_put_buffer(f, s->prom, 16); |
@@ -1888,10 +1888,10 @@ static void pcnet_save(QEMUFile *f, void *opaque) | @@ -1888,10 +1888,10 @@ static void pcnet_save(QEMUFile *f, void *opaque) | ||
1888 | for (i = 0; i < 32; i++) | 1888 | for (i = 0; i < 32; i++) |
1889 | qemu_put_be16s(f, &s->bcr[i]); | 1889 | qemu_put_be16s(f, &s->bcr[i]); |
1890 | qemu_put_be64s(f, &s->timer); | 1890 | qemu_put_be64s(f, &s->timer); |
1891 | - qemu_put_be32(f, s->xmit_pos); | ||
1892 | - qemu_put_be32(f, s->recv_pos); | 1891 | + qemu_put_sbe32(f, s->xmit_pos); |
1892 | + qemu_put_sbe32(f, s->recv_pos); | ||
1893 | qemu_put_buffer(f, s->buffer, 4096); | 1893 | qemu_put_buffer(f, s->buffer, 4096); |
1894 | - qemu_put_be32(f, s->tx_busy); | 1894 | + qemu_put_sbe32(f, s->tx_busy); |
1895 | qemu_put_timer(f, s->poll_timer); | 1895 | qemu_put_timer(f, s->poll_timer); |
1896 | } | 1896 | } |
1897 | 1897 | ||
@@ -1909,9 +1909,9 @@ static int pcnet_load(QEMUFile *f, void *opaque, int version_id) | @@ -1909,9 +1909,9 @@ static int pcnet_load(QEMUFile *f, void *opaque, int version_id) | ||
1909 | return ret; | 1909 | return ret; |
1910 | } | 1910 | } |
1911 | 1911 | ||
1912 | - qemu_get_be32s(f, (uint32_t*)&s->rap); | ||
1913 | - qemu_get_be32s(f, (uint32_t*)&s->isr); | ||
1914 | - qemu_get_be32s(f, (uint32_t*)&s->lnkst); | 1912 | + qemu_get_sbe32s(f, &s->rap); |
1913 | + qemu_get_sbe32s(f, &s->isr); | ||
1914 | + qemu_get_sbe32s(f, &s->lnkst); | ||
1915 | qemu_get_be32s(f, &s->rdra); | 1915 | qemu_get_be32s(f, &s->rdra); |
1916 | qemu_get_be32s(f, &s->tdra); | 1916 | qemu_get_be32s(f, &s->tdra); |
1917 | qemu_get_buffer(f, s->prom, 16); | 1917 | qemu_get_buffer(f, s->prom, 16); |
@@ -1920,10 +1920,10 @@ static int pcnet_load(QEMUFile *f, void *opaque, int version_id) | @@ -1920,10 +1920,10 @@ static int pcnet_load(QEMUFile *f, void *opaque, int version_id) | ||
1920 | for (i = 0; i < 32; i++) | 1920 | for (i = 0; i < 32; i++) |
1921 | qemu_get_be16s(f, &s->bcr[i]); | 1921 | qemu_get_be16s(f, &s->bcr[i]); |
1922 | qemu_get_be64s(f, &s->timer); | 1922 | qemu_get_be64s(f, &s->timer); |
1923 | - qemu_get_be32s(f, (uint32_t*)&s->xmit_pos); | ||
1924 | - qemu_get_be32s(f, (uint32_t*)&s->recv_pos); | 1923 | + qemu_get_sbe32s(f, &s->xmit_pos); |
1924 | + qemu_get_sbe32s(f, &s->recv_pos); | ||
1925 | qemu_get_buffer(f, s->buffer, 4096); | 1925 | qemu_get_buffer(f, s->buffer, 4096); |
1926 | - qemu_get_be32s(f, (uint32_t*)&s->tx_busy); | 1926 | + qemu_get_sbe32s(f, &s->tx_busy); |
1927 | qemu_get_timer(f, s->poll_timer); | 1927 | qemu_get_timer(f, s->poll_timer); |
1928 | 1928 | ||
1929 | return 0; | 1929 | return 0; |
hw/ptimer.c
@@ -165,9 +165,9 @@ void qemu_put_ptimer(QEMUFile *f, ptimer_state *s) | @@ -165,9 +165,9 @@ void qemu_put_ptimer(QEMUFile *f, ptimer_state *s) | ||
165 | qemu_put_be64s(f, &s->limit); | 165 | qemu_put_be64s(f, &s->limit); |
166 | qemu_put_be64s(f, &s->delta); | 166 | qemu_put_be64s(f, &s->delta); |
167 | qemu_put_be32s(f, &s->period_frac); | 167 | qemu_put_be32s(f, &s->period_frac); |
168 | - qemu_put_be64s(f, &s->period); | ||
169 | - qemu_put_be64s(f, &s->last_event); | ||
170 | - qemu_put_be64s(f, &s->next_event); | 168 | + qemu_put_sbe64s(f, &s->period); |
169 | + qemu_put_sbe64s(f, &s->last_event); | ||
170 | + qemu_put_sbe64s(f, &s->next_event); | ||
171 | qemu_put_timer(f, s->timer); | 171 | qemu_put_timer(f, s->timer); |
172 | } | 172 | } |
173 | 173 | ||
@@ -177,9 +177,9 @@ void qemu_get_ptimer(QEMUFile *f, ptimer_state *s) | @@ -177,9 +177,9 @@ void qemu_get_ptimer(QEMUFile *f, ptimer_state *s) | ||
177 | qemu_get_be64s(f, &s->limit); | 177 | qemu_get_be64s(f, &s->limit); |
178 | qemu_get_be64s(f, &s->delta); | 178 | qemu_get_be64s(f, &s->delta); |
179 | qemu_get_be32s(f, &s->period_frac); | 179 | qemu_get_be32s(f, &s->period_frac); |
180 | - qemu_get_be64s(f, &s->period); | ||
181 | - qemu_get_be64s(f, &s->last_event); | ||
182 | - qemu_get_be64s(f, &s->next_event); | 180 | + qemu_get_sbe64s(f, &s->period); |
181 | + qemu_get_sbe64s(f, &s->last_event); | ||
182 | + qemu_get_sbe64s(f, &s->next_event); | ||
183 | qemu_get_timer(f, s->timer); | 183 | qemu_get_timer(f, s->timer); |
184 | } | 184 | } |
185 | 185 |
hw/pxa2xx.c
@@ -1233,9 +1233,9 @@ static void pxa2xx_rtc_save(QEMUFile *f, void *opaque) | @@ -1233,9 +1233,9 @@ static void pxa2xx_rtc_save(QEMUFile *f, void *opaque) | ||
1233 | qemu_put_be32s(f, &s->last_rycr); | 1233 | qemu_put_be32s(f, &s->last_rycr); |
1234 | qemu_put_be32s(f, &s->last_swcr); | 1234 | qemu_put_be32s(f, &s->last_swcr); |
1235 | qemu_put_be32s(f, &s->last_rtcpicr); | 1235 | qemu_put_be32s(f, &s->last_rtcpicr); |
1236 | - qemu_put_be64s(f, (uint64_t *) &s->last_hz); | ||
1237 | - qemu_put_be64s(f, (uint64_t *) &s->last_sw); | ||
1238 | - qemu_put_be64s(f, (uint64_t *) &s->last_pi); | 1236 | + qemu_put_sbe64s(f, &s->last_hz); |
1237 | + qemu_put_sbe64s(f, &s->last_sw); | ||
1238 | + qemu_put_sbe64s(f, &s->last_pi); | ||
1239 | } | 1239 | } |
1240 | 1240 | ||
1241 | static int pxa2xx_rtc_load(QEMUFile *f, void *opaque, int version_id) | 1241 | static int pxa2xx_rtc_load(QEMUFile *f, void *opaque, int version_id) |
@@ -1257,9 +1257,9 @@ static int pxa2xx_rtc_load(QEMUFile *f, void *opaque, int version_id) | @@ -1257,9 +1257,9 @@ static int pxa2xx_rtc_load(QEMUFile *f, void *opaque, int version_id) | ||
1257 | qemu_get_be32s(f, &s->last_rycr); | 1257 | qemu_get_be32s(f, &s->last_rycr); |
1258 | qemu_get_be32s(f, &s->last_swcr); | 1258 | qemu_get_be32s(f, &s->last_swcr); |
1259 | qemu_get_be32s(f, &s->last_rtcpicr); | 1259 | qemu_get_be32s(f, &s->last_rtcpicr); |
1260 | - qemu_get_be64s(f, (uint64_t *) &s->last_hz); | ||
1261 | - qemu_get_be64s(f, (uint64_t *) &s->last_sw); | ||
1262 | - qemu_get_be64s(f, (uint64_t *) &s->last_pi); | 1260 | + qemu_get_sbe64s(f, &s->last_hz); |
1261 | + qemu_get_sbe64s(f, &s->last_sw); | ||
1262 | + qemu_get_sbe64s(f, &s->last_pi); | ||
1263 | 1263 | ||
1264 | pxa2xx_rtc_alarm_update(s, s->rtsr); | 1264 | pxa2xx_rtc_alarm_update(s, s->rtsr); |
1265 | 1265 |
hw/pxa2xx_timer.c
@@ -384,8 +384,8 @@ static void pxa2xx_timer_save(QEMUFile *f, void *opaque) | @@ -384,8 +384,8 @@ static void pxa2xx_timer_save(QEMUFile *f, void *opaque) | ||
384 | for (i = 0; i < 8; i ++) { | 384 | for (i = 0; i < 8; i ++) { |
385 | qemu_put_be32s(f, &s->tm4[i].tm.value); | 385 | qemu_put_be32s(f, &s->tm4[i].tm.value); |
386 | qemu_put_be32(f, s->tm4[i].tm.level); | 386 | qemu_put_be32(f, s->tm4[i].tm.level); |
387 | - qemu_put_be32s(f, (uint32_t *) &s->tm4[i].oldclock); | ||
388 | - qemu_put_be32s(f, (uint32_t *) &s->tm4[i].clock); | 387 | + qemu_put_sbe32s(f, &s->tm4[i].oldclock); |
388 | + qemu_put_sbe32s(f, &s->tm4[i].clock); | ||
389 | qemu_put_be64s(f, &s->tm4[i].lastload); | 389 | qemu_put_be64s(f, &s->tm4[i].lastload); |
390 | qemu_put_be32s(f, &s->tm4[i].freq); | 390 | qemu_put_be32s(f, &s->tm4[i].freq); |
391 | qemu_put_be32s(f, &s->tm4[i].control); | 391 | qemu_put_be32s(f, &s->tm4[i].control); |
@@ -418,8 +418,8 @@ static int pxa2xx_timer_load(QEMUFile *f, void *opaque, int version_id) | @@ -418,8 +418,8 @@ static int pxa2xx_timer_load(QEMUFile *f, void *opaque, int version_id) | ||
418 | for (i = 0; i < 8; i ++) { | 418 | for (i = 0; i < 8; i ++) { |
419 | qemu_get_be32s(f, &s->tm4[i].tm.value); | 419 | qemu_get_be32s(f, &s->tm4[i].tm.value); |
420 | s->tm4[i].tm.level = qemu_get_be32(f); | 420 | s->tm4[i].tm.level = qemu_get_be32(f); |
421 | - qemu_get_be32s(f, (uint32_t *) &s->tm4[i].oldclock); | ||
422 | - qemu_get_be32s(f, (uint32_t *) &s->tm4[i].clock); | 421 | + qemu_get_sbe32s(f, &s->tm4[i].oldclock); |
422 | + qemu_get_sbe32s(f, &s->tm4[i].clock); | ||
423 | qemu_get_be64s(f, &s->tm4[i].lastload); | 423 | qemu_get_be64s(f, &s->tm4[i].lastload); |
424 | qemu_get_be32s(f, &s->tm4[i].freq); | 424 | qemu_get_be32s(f, &s->tm4[i].freq); |
425 | qemu_get_be32s(f, &s->tm4[i].control); | 425 | qemu_get_be32s(f, &s->tm4[i].control); |
hw/tcx.c
@@ -372,9 +372,9 @@ static void tcx_save(QEMUFile *f, void *opaque) | @@ -372,9 +372,9 @@ static void tcx_save(QEMUFile *f, void *opaque) | ||
372 | { | 372 | { |
373 | TCXState *s = opaque; | 373 | TCXState *s = opaque; |
374 | 374 | ||
375 | - qemu_put_be16s(f, (uint16_t *)&s->height); | ||
376 | - qemu_put_be16s(f, (uint16_t *)&s->width); | ||
377 | - qemu_put_be16s(f, (uint16_t *)&s->depth); | 375 | + qemu_put_be16s(f, &s->height); |
376 | + qemu_put_be16s(f, &s->width); | ||
377 | + qemu_put_be16s(f, &s->depth); | ||
378 | qemu_put_buffer(f, s->r, 256); | 378 | qemu_put_buffer(f, s->r, 256); |
379 | qemu_put_buffer(f, s->g, 256); | 379 | qemu_put_buffer(f, s->g, 256); |
380 | qemu_put_buffer(f, s->b, 256); | 380 | qemu_put_buffer(f, s->b, 256); |
@@ -391,13 +391,13 @@ static int tcx_load(QEMUFile *f, void *opaque, int version_id) | @@ -391,13 +391,13 @@ static int tcx_load(QEMUFile *f, void *opaque, int version_id) | ||
391 | return -EINVAL; | 391 | return -EINVAL; |
392 | 392 | ||
393 | if (version_id == 3) { | 393 | if (version_id == 3) { |
394 | - qemu_get_be32s(f, (uint32_t *)&dummy); | ||
395 | - qemu_get_be32s(f, (uint32_t *)&dummy); | ||
396 | - qemu_get_be32s(f, (uint32_t *)&dummy); | 394 | + qemu_get_be32s(f, &dummy); |
395 | + qemu_get_be32s(f, &dummy); | ||
396 | + qemu_get_be32s(f, &dummy); | ||
397 | } | 397 | } |
398 | - qemu_get_be16s(f, (uint16_t *)&s->height); | ||
399 | - qemu_get_be16s(f, (uint16_t *)&s->width); | ||
400 | - qemu_get_be16s(f, (uint16_t *)&s->depth); | 398 | + qemu_get_be16s(f, &s->height); |
399 | + qemu_get_be16s(f, &s->width); | ||
400 | + qemu_get_be16s(f, &s->depth); | ||
401 | qemu_get_buffer(f, s->r, 256); | 401 | qemu_get_buffer(f, s->r, 256); |
402 | qemu_get_buffer(f, s->g, 256); | 402 | qemu_get_buffer(f, s->g, 256); |
403 | qemu_get_buffer(f, s->b, 256); | 403 | qemu_get_buffer(f, s->b, 256); |
hw/tmp105.c
@@ -185,9 +185,9 @@ static void tmp105_save(QEMUFile *f, void *opaque) | @@ -185,9 +185,9 @@ static void tmp105_save(QEMUFile *f, void *opaque) | ||
185 | 185 | ||
186 | qemu_put_8s(f, &s->pointer); | 186 | qemu_put_8s(f, &s->pointer); |
187 | qemu_put_8s(f, &s->config); | 187 | qemu_put_8s(f, &s->config); |
188 | - qemu_put_be16s(f, (uint16_t *) &s->temperature); | ||
189 | - qemu_put_be16s(f, (uint16_t *) &s->limit[0]); | ||
190 | - qemu_put_be16s(f, (uint16_t *) &s->limit[1]); | 188 | + qemu_put_sbe16s(f, &s->temperature); |
189 | + qemu_put_sbe16s(f, &s->limit[0]); | ||
190 | + qemu_put_sbe16s(f, &s->limit[1]); | ||
191 | qemu_put_byte(f, s->alarm); | 191 | qemu_put_byte(f, s->alarm); |
192 | s->faults = tmp105_faultq[(s->config >> 3) & 3]; /* F */ | 192 | s->faults = tmp105_faultq[(s->config >> 3) & 3]; /* F */ |
193 | 193 | ||
@@ -204,9 +204,9 @@ static int tmp105_load(QEMUFile *f, void *opaque, int version_id) | @@ -204,9 +204,9 @@ static int tmp105_load(QEMUFile *f, void *opaque, int version_id) | ||
204 | 204 | ||
205 | qemu_get_8s(f, &s->pointer); | 205 | qemu_get_8s(f, &s->pointer); |
206 | qemu_get_8s(f, &s->config); | 206 | qemu_get_8s(f, &s->config); |
207 | - qemu_get_be16s(f, (uint16_t *) &s->temperature); | ||
208 | - qemu_get_be16s(f, (uint16_t *) &s->limit[0]); | ||
209 | - qemu_get_be16s(f, (uint16_t *) &s->limit[1]); | 207 | + qemu_get_sbe16s(f, &s->temperature); |
208 | + qemu_get_sbe16s(f, &s->limit[0]); | ||
209 | + qemu_get_sbe16s(f, &s->limit[1]); | ||
210 | s->alarm = qemu_get_byte(f); | 210 | s->alarm = qemu_get_byte(f); |
211 | 211 | ||
212 | tmp105_interrupt_update(s); | 212 | tmp105_interrupt_update(s); |
hw/tsc210x.c
@@ -1046,8 +1046,8 @@ static void tsc210x_save(QEMUFile *f, void *opaque) | @@ -1046,8 +1046,8 @@ static void tsc210x_save(QEMUFile *f, void *opaque) | ||
1046 | qemu_put_be16s(f, &s->pll[0]); | 1046 | qemu_put_be16s(f, &s->pll[0]); |
1047 | qemu_put_be16s(f, &s->pll[1]); | 1047 | qemu_put_be16s(f, &s->pll[1]); |
1048 | qemu_put_be16s(f, &s->volume); | 1048 | qemu_put_be16s(f, &s->volume); |
1049 | - qemu_put_be64(f, (uint64_t) (s->volume_change - now)); | ||
1050 | - qemu_put_be64(f, (uint64_t) (s->powerdown - now)); | 1049 | + qemu_put_sbe64(f, (s->volume_change - now)); |
1050 | + qemu_put_sbe64(f, (s->powerdown - now)); | ||
1051 | qemu_put_byte(f, s->softstep); | 1051 | qemu_put_byte(f, s->softstep); |
1052 | qemu_put_be16s(f, &s->dac_power); | 1052 | qemu_put_be16s(f, &s->dac_power); |
1053 | 1053 | ||
@@ -1092,8 +1092,8 @@ static int tsc210x_load(QEMUFile *f, void *opaque, int version_id) | @@ -1092,8 +1092,8 @@ static int tsc210x_load(QEMUFile *f, void *opaque, int version_id) | ||
1092 | qemu_get_be16s(f, &s->pll[0]); | 1092 | qemu_get_be16s(f, &s->pll[0]); |
1093 | qemu_get_be16s(f, &s->pll[1]); | 1093 | qemu_get_be16s(f, &s->pll[1]); |
1094 | qemu_get_be16s(f, &s->volume); | 1094 | qemu_get_be16s(f, &s->volume); |
1095 | - s->volume_change = (int64_t) qemu_get_be64(f) + now; | ||
1096 | - s->powerdown = (int64_t) qemu_get_be64(f) + now; | 1095 | + s->volume_change = qemu_get_sbe64(f) + now; |
1096 | + s->powerdown = qemu_get_sbe64(f) + now; | ||
1097 | s->softstep = qemu_get_byte(f); | 1097 | s->softstep = qemu_get_byte(f); |
1098 | qemu_get_be16s(f, &s->dac_power); | 1098 | qemu_get_be16s(f, &s->dac_power); |
1099 | 1099 |
target-i386/machine.c
@@ -102,7 +102,7 @@ void cpu_save(QEMUFile *f, void *opaque) | @@ -102,7 +102,7 @@ void cpu_save(QEMUFile *f, void *opaque) | ||
102 | 102 | ||
103 | /* MMU */ | 103 | /* MMU */ |
104 | a20_mask = (int32_t) env->a20_mask; | 104 | a20_mask = (int32_t) env->a20_mask; |
105 | - qemu_put_be32s(f, &a20_mask); | 105 | + qemu_put_sbe32s(f, &a20_mask); |
106 | 106 | ||
107 | /* XMM */ | 107 | /* XMM */ |
108 | qemu_put_be32s(f, &env->mxcsr); | 108 | qemu_put_be32s(f, &env->mxcsr); |
@@ -256,7 +256,7 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id) | @@ -256,7 +256,7 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id) | ||
256 | qemu_get_betls(f, &env->dr[i]); | 256 | qemu_get_betls(f, &env->dr[i]); |
257 | 257 | ||
258 | /* MMU */ | 258 | /* MMU */ |
259 | - qemu_get_be32s(f, &a20_mask); | 259 | + qemu_get_sbe32s(f, &a20_mask); |
260 | env->a20_mask = a20_mask; | 260 | env->a20_mask = a20_mask; |
261 | 261 | ||
262 | qemu_get_be32s(f, &env->mxcsr); | 262 | qemu_get_be32s(f, &env->mxcsr); |
vl.c
@@ -6247,9 +6247,9 @@ void qemu_fclose(QEMUFile *f) | @@ -6247,9 +6247,9 @@ void qemu_fclose(QEMUFile *f) | ||
6247 | qemu_free(f); | 6247 | qemu_free(f); |
6248 | } | 6248 | } |
6249 | 6249 | ||
6250 | -void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size) | 6250 | +void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, size_t size) |
6251 | { | 6251 | { |
6252 | - int l; | 6252 | + size_t l; |
6253 | while (size > 0) { | 6253 | while (size > 0) { |
6254 | l = IO_BUF_SIZE - f->buf_index; | 6254 | l = IO_BUF_SIZE - f->buf_index; |
6255 | if (l > size) | 6255 | if (l > size) |
@@ -6263,16 +6263,16 @@ void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size) | @@ -6263,16 +6263,16 @@ void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size) | ||
6263 | } | 6263 | } |
6264 | } | 6264 | } |
6265 | 6265 | ||
6266 | -void qemu_put_byte(QEMUFile *f, int v) | 6266 | +void qemu_put_byte(QEMUFile *f, int8_t v) |
6267 | { | 6267 | { |
6268 | f->buf[f->buf_index++] = v; | 6268 | f->buf[f->buf_index++] = v; |
6269 | if (f->buf_index >= IO_BUF_SIZE) | 6269 | if (f->buf_index >= IO_BUF_SIZE) |
6270 | qemu_fflush(f); | 6270 | qemu_fflush(f); |
6271 | } | 6271 | } |
6272 | 6272 | ||
6273 | -int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size1) | 6273 | +size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size1) |
6274 | { | 6274 | { |
6275 | - int size, l; | 6275 | + size_t size, l; |
6276 | 6276 | ||
6277 | size = size1; | 6277 | size = size1; |
6278 | while (size > 0) { | 6278 | while (size > 0) { |
@@ -6293,7 +6293,7 @@ int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size1) | @@ -6293,7 +6293,7 @@ int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size1) | ||
6293 | return size1 - size; | 6293 | return size1 - size; |
6294 | } | 6294 | } |
6295 | 6295 | ||
6296 | -int qemu_get_byte(QEMUFile *f) | 6296 | +int8_t qemu_get_byte(QEMUFile *f) |
6297 | { | 6297 | { |
6298 | if (f->buf_index >= f->buf_size) { | 6298 | if (f->buf_index >= f->buf_size) { |
6299 | qemu_fill_buffer(f); | 6299 | qemu_fill_buffer(f); |
@@ -6329,13 +6329,13 @@ int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence) | @@ -6329,13 +6329,13 @@ int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence) | ||
6329 | return pos; | 6329 | return pos; |
6330 | } | 6330 | } |
6331 | 6331 | ||
6332 | -void qemu_put_be16(QEMUFile *f, unsigned int v) | 6332 | +void qemu_put_be16(QEMUFile *f, uint16_t v) |
6333 | { | 6333 | { |
6334 | qemu_put_byte(f, v >> 8); | 6334 | qemu_put_byte(f, v >> 8); |
6335 | qemu_put_byte(f, v); | 6335 | qemu_put_byte(f, v); |
6336 | } | 6336 | } |
6337 | 6337 | ||
6338 | -void qemu_put_be32(QEMUFile *f, unsigned int v) | 6338 | +void qemu_put_be32(QEMUFile *f, uint32_t v) |
6339 | { | 6339 | { |
6340 | qemu_put_byte(f, v >> 24); | 6340 | qemu_put_byte(f, v >> 24); |
6341 | qemu_put_byte(f, v >> 16); | 6341 | qemu_put_byte(f, v >> 16); |
@@ -6349,17 +6349,17 @@ void qemu_put_be64(QEMUFile *f, uint64_t v) | @@ -6349,17 +6349,17 @@ void qemu_put_be64(QEMUFile *f, uint64_t v) | ||
6349 | qemu_put_be32(f, v); | 6349 | qemu_put_be32(f, v); |
6350 | } | 6350 | } |
6351 | 6351 | ||
6352 | -unsigned int qemu_get_be16(QEMUFile *f) | 6352 | +uint16_t qemu_get_be16(QEMUFile *f) |
6353 | { | 6353 | { |
6354 | - unsigned int v; | 6354 | + uint16_t v; |
6355 | v = qemu_get_byte(f) << 8; | 6355 | v = qemu_get_byte(f) << 8; |
6356 | v |= qemu_get_byte(f); | 6356 | v |= qemu_get_byte(f); |
6357 | return v; | 6357 | return v; |
6358 | } | 6358 | } |
6359 | 6359 | ||
6360 | -unsigned int qemu_get_be32(QEMUFile *f) | 6360 | +uint32_t qemu_get_be32(QEMUFile *f) |
6361 | { | 6361 | { |
6362 | - unsigned int v; | 6362 | + uint32_t v; |
6363 | v = qemu_get_byte(f) << 24; | 6363 | v = qemu_get_byte(f) << 24; |
6364 | v |= qemu_get_byte(f) << 16; | 6364 | v |= qemu_get_byte(f) << 16; |
6365 | v |= qemu_get_byte(f) << 8; | 6365 | v |= qemu_get_byte(f) << 8; |