]>
Commit | Line | Data |
---|---|---|
218414b1 JB |
1 | --- openhpi-2.2.1/marshal/marshal.c.orig 2005-09-27 12:19:54.000000000 +0200 |
2 | +++ openhpi-2.2.1/marshal/marshal.c 2005-10-30 18:14:44.051581512 +0100 | |
3 | @@ -20,6 +20,7 @@ | |
8d432159 JB |
4 | #include <assert.h> |
5 | #include <endian.h> | |
6 | #include <byteswap.h> | |
7 | +#include <string.h> | |
8 | #include "marshal.h" | |
9 | ||
10 | ||
218414b1 | 11 | @@ -279,8 +280,7 @@ |
6bc61e99 | 12 | case eMtInt16: |
13 | case eMtUint16: | |
14 | { | |
15 | - tUint16 v = *(const tUint16 *)data; | |
16 | - *(tUint16 *)buffer = v; | |
17 | + memcpy(buffer, data, sizeof(tUint16)); | |
18 | } | |
19 | ||
20 | return sizeof( tUint16 ); | |
218414b1 | 21 | @@ -288,8 +288,7 @@ |
6bc61e99 | 22 | case eMtUint32: |
23 | case eMtInt32: | |
24 | { | |
25 | - tUint32 v = *(const tUint32 *)data; | |
26 | - *(tUint32 *)buffer = v; | |
27 | + memcpy(buffer, data, sizeof(tUint32)); | |
28 | } | |
29 | ||
30 | return sizeof( tUint32 ); | |
218414b1 | 31 | @@ -297,24 +296,21 @@ |
6bc61e99 | 32 | case eMtUint64: |
33 | case eMtInt64: | |
34 | { | |
35 | - tUint64 v = *(const tUint64 *)data; | |
36 | - *(tUint64 *)buffer = v; | |
37 | + memcpy(buffer, data, sizeof(tUint64)); | |
38 | } | |
39 | ||
40 | return sizeof( tUint64 ); | |
41 | ||
42 | case eMtFloat32: | |
43 | { | |
44 | - tFloat32 v = *(const tFloat32 *)data; | |
45 | - *(tFloat32 *)buffer = v; | |
46 | + memcpy(buffer, data, sizeof(tFloat32)); | |
47 | } | |
48 | ||
49 | return sizeof( tFloat32 ); | |
50 | ||
51 | case eMtFloat64: | |
52 | { | |
53 | - tFloat64 v = *(const tFloat64 *)data; | |
54 | - *(tFloat64 *)buffer = v; | |
55 | + memcpy(buffer, data, sizeof(tFloat64)); | |
56 | } | |
57 | ||
58 | return sizeof( tFloat64 ); | |
218414b1 | 59 | @@ -347,16 +343,16 @@ |
6bc61e99 | 60 | |
61 | case eMtUint16: | |
62 | case eMtInt16: | |
218414b1 JB |
63 | - /* compile error */ |
64 | -// m = (tUint32)*(const tUint16 *)so; | |
65 | - m = (tUint32)(*(const tUint16 *)(const void *)so); | |
6bc61e99 | 66 | + { |
67 | + tUint16 buf; | |
68 | + memcpy(&buf, so, sizeof(tUint16)); | |
69 | + m = (tUint32)buf; | |
70 | + } | |
71 | break; | |
72 | ||
73 | case eMtUint32: | |
74 | case eMtInt32: | |
218414b1 JB |
75 | - /* compile error */ |
76 | -// m = *(const tUint32 *)so; | |
77 | - m = *(const tUint32 *)(const void *)so; | |
8d432159 | 78 | + memcpy(&m, so, sizeof(tUint32)); |
6bc61e99 | 79 | break; |
80 | ||
81 | default: | |
218414b1 | 82 | @@ -395,16 +391,16 @@ |
6bc61e99 | 83 | |
84 | case eMtUint16: | |
85 | case eMtInt16: | |
218414b1 JB |
86 | - /* compile error */ |
87 | -// size = (tUint32)*(const tUint16 *)so; | |
88 | - size = (tUint32)*(const tUint16 *)(const void *)so; | |
8d432159 | 89 | + { |
6bc61e99 | 90 | + tUint16 buf; |
91 | + memcpy(&buf, so, sizeof(tUint16)); | |
92 | + size = (tUint32)buf; | |
8d432159 | 93 | + } |
6bc61e99 | 94 | break; |
95 | ||
96 | case eMtUint32: | |
97 | case eMtInt32: | |
218414b1 JB |
98 | - /* compile error */ |
99 | -// size = *(const tUint32 *)so; | |
100 | - size = *(const tUint32 *)(const void *)so; | |
6bc61e99 | 101 | + memcpy(&size, so, sizeof(tUint32)); |
102 | break; | |
103 | ||
104 | default: | |
218414b1 | 105 | @@ -612,12 +608,13 @@ |
6bc61e99 | 106 | case eMtInt16: |
107 | case eMtUint16: | |
108 | { | |
109 | - tUint16 v = *(const tUint16 *)buffer; | |
110 | + tUint16 v; | |
111 | + memcpy(&v, buffer, sizeof(tUint16)); | |
112 | ||
113 | if ( MarshalByteOrder() != byte_order ) | |
114 | v = bswap_16( v ); | |
115 | ||
116 | - *(tUint16 *)data = v; | |
117 | + memcpy(data, &v, sizeof(tUint16)); | |
118 | } | |
119 | ||
120 | return sizeof( tUint16 ); | |
218414b1 | 121 | @@ -625,12 +622,13 @@ |
6bc61e99 | 122 | case eMtUint32: |
123 | case eMtInt32: | |
124 | { | |
125 | - tUint32 v = *(const tUint32 *)buffer; | |
126 | + tUint32 v; | |
127 | + memcpy(&v, buffer, sizeof(tUint32)); | |
128 | ||
129 | if ( MarshalByteOrder() != byte_order ) | |
130 | v = bswap_32( v ); | |
131 | ||
132 | - *(tUint32 *)data = v; | |
133 | + memcpy(data, &v, sizeof(tUint32)); | |
134 | } | |
135 | ||
136 | return sizeof( tUint32 ); | |
218414b1 | 137 | @@ -638,12 +636,13 @@ |
6bc61e99 | 138 | case eMtUint64: |
139 | case eMtInt64: | |
140 | { | |
141 | - tUint64 v = *(const tUint64 *)buffer; | |
142 | + tUint64 v; | |
143 | + memcpy(&v, buffer, sizeof(tUint64)); | |
144 | ||
145 | if ( MarshalByteOrder() != byte_order ) | |
146 | v = bswap_64( v ); | |
147 | ||
148 | - *(tUint64 *)data = v; | |
149 | + memcpy(data, &v, sizeof(tUint64)); | |
150 | } | |
151 | ||
152 | return sizeof( tUint64 ); | |
218414b1 | 153 | @@ -651,13 +650,16 @@ |
6bc61e99 | 154 | case eMtFloat32: |
155 | { | |
156 | // this has been tested for i386 and PPC | |
157 | + tFloat32 v2; | |
158 | tFloat32Uint32 v; | |
159 | - v.m_f32 = *(const tFloat32 *)buffer; | |
8d432159 | 160 | + memcpy(&v2, buffer, sizeof(tFloat32)); |
6bc61e99 | 161 | + v.m_f32 = v2; |
162 | ||
163 | if ( MarshalByteOrder() != byte_order ) | |
164 | v.m_u32 = bswap_32( v.m_u32 ); | |
165 | ||
166 | - *(tFloat32 *)data = v.m_f32; | |
167 | + v2 = v.m_f32; | |
168 | + memcpy(data, &v2, sizeof(tFloat32)); | |
169 | } | |
170 | ||
171 | return sizeof( tFloat32 ); | |
218414b1 | 172 | @@ -665,13 +667,16 @@ |
6bc61e99 | 173 | case eMtFloat64: |
174 | { | |
175 | // this has been tested for i386 and PPC | |
176 | + tFloat64 v2; | |
177 | tFloat64Uint64 v; | |
178 | - v.m_f64 = *(const tFloat64 *)buffer; | |
8d432159 | 179 | + memcpy(&v2, buffer, sizeof(tFloat64)); |
6bc61e99 | 180 | + v.m_f64 = v2; |
181 | ||
182 | if ( MarshalByteOrder() != byte_order ) | |
183 | v.m_u64 = bswap_64( v.m_u64 ); | |
184 | ||
185 | - *(tFloat64 *)data = v.m_f64; | |
186 | + v2 = v.m_f64; | |
187 | + memcpy(data, &v2, sizeof(tFloat64)); | |
188 | } | |
189 | ||
190 | return sizeof( tFloat64 ); |