|
35 | 35 | > alias uint32_u = align(1) uint; |
36 | 36 | > alias uint64_u = align(1) c_ulong; |
37 | 37 | > }else{ |
38 | | -77a99,144 |
| 38 | +77a99,142 |
39 | 39 | > } |
40 | 40 | > |
41 | 41 | > |
|
80 | 80 | > } |
81 | 81 | > |
82 | 82 | > |
83 | | -> |
84 | | -> |
85 | | -78a146,186 |
| 83 | +80,83d144 |
| 84 | +< /* @param buf Pointer to source byte, may be unaligned |
| 85 | +< * @return An 8-bit unsigned integer |
| 86 | +< */ |
| 87 | +< ubyte le_to_u8(const(ubyte)* buf); |
| 88 | +84a146,186 |
86 | 89 | > private struct int16_t |
87 | 90 | > { |
88 | 91 | > short _val; |
|
124 | 127 | > @nogc: |
125 | 128 | > @system: |
126 | 129 | > nothrow: |
127 | | -84c192,198 |
| 130 | +90c192,198 |
128 | 131 | < ushort le_to_u16(const(ubyte)* buf); |
129 | 132 | --- |
130 | 133 | > ushort le_to_u16(const(ubyte)* buf) |
|
134 | 137 | > else |
135 | 138 | > return cast(ushort) buf[0] | (cast(ushort) buf[1] << 8); |
136 | 139 | > } |
137 | | -91c205,214 |
| 140 | +97c205,214 |
138 | 141 | < uint le_to_u32(const(ubyte)* buf); |
139 | 142 | --- |
140 | 143 | > uint le_to_u32(const(ubyte)* buf) |
|
147 | 150 | > (cast(uint) buf[2] << 16) | |
148 | 151 | > (cast(uint) buf[3] << 24)); |
149 | 152 | > } |
150 | | -98c221,234 |
| 153 | +104c221,234 |
151 | 154 | < ulong le_to_u64(const(ubyte)* buf); |
152 | 155 | --- |
153 | 156 | > ulong le_to_u64(const(ubyte)* buf) |
|
164 | 167 | > (cast(ulong) buf[6] << 48) | |
165 | 168 | > (cast(ulong) buf[7] << 56)); |
166 | 169 | > } |
167 | | -104c240,248 |
| 170 | +110c240,248 |
168 | 171 | < void u16_to_le(ushort val, ubyte* buf); |
169 | 172 | --- |
170 | 173 | > void u16_to_le(ushort val, ubyte* buf) |
|
176 | 179 | > buf[1] = (val >> 8) & 0xff; |
177 | 180 | > } |
178 | 181 | > } |
179 | | -110c254,264 |
| 182 | +116c254,264 |
180 | 183 | < void u32_to_le(uint val, ubyte* buf); |
181 | 184 | --- |
182 | 185 | > void u32_to_le(uint val, ubyte* buf) |
|
190 | 193 | > buf[3] = (val >> 24) & 0xff; |
191 | 194 | > } |
192 | 195 | > } |
193 | | -116c270,284 |
| 196 | +122c270,284 |
194 | 197 | < void u64_to_le(ulong val, ubyte* buf); |
195 | 198 | --- |
196 | 199 | > void u64_to_le(ulong val, ubyte* buf) |
|
208 | 211 | > buf[7] = (val >> 56) & 0xff; |
209 | 212 | > } |
210 | 213 | > } |
211 | | -128c296,299 |
| 214 | +134c296,299 |
212 | 215 | < byte le_to_i8(const(ubyte)* buf); |
213 | 216 | --- |
214 | 217 | > byte le_to_i8(const(ubyte)* buf) |
215 | 218 | > { |
216 | 219 | > return *buf < 0x80 ? cast(int8_t) *buf : -((int8_t(cast(byte)0xff) - cast(int8_t)*buf)) - int8_t(1); |
217 | 220 | > } |
218 | | -136c307,311 |
| 221 | +142c307,311 |
219 | 222 | < short le_to_i16(const(ubyte)* buf); |
220 | 223 | --- |
221 | 224 | > short le_to_i16(const(ubyte)* buf) |
222 | 225 | > { |
223 | 226 | > ushort v = le_to_u16(buf); |
224 | 227 | > return v < 0x8000 ? cast(int16_t) v : -((int16_t(cast(short)0xffff) - v)) - cast(int16_t)1; |
225 | 228 | > } |
226 | | -144c319,323 |
| 229 | +150c319,323 |
227 | 230 | < int le_to_i32(const(ubyte)* buf); |
228 | 231 | --- |
229 | 232 | > int le_to_i32(const(ubyte)* buf) |
230 | 233 | > { |
231 | 234 | > uint v = le_to_u32(buf); |
232 | 235 | > return v < 0x80000000U ? cast(int) v : -(cast(int) (0xffffffffU - v)) - 1; |
233 | 236 | > } |
234 | | -152c331,336 |
| 237 | +158c331,336 |
235 | 238 | < long le_to_i64(const(ubyte)* buf); |
236 | 239 | --- |
237 | 240 | > long le_to_i64(const(ubyte)* buf) |
|
240 | 243 | > return (v < 0x8000000000000000UL |
241 | 244 | > ? cast(long) v : -(cast(long) (0xffffffffffffffffUL - v)) - 1); |
242 | 245 | > } |
243 | | -160c344,347 |
| 246 | +166c344,347 |
244 | 247 | < void i16_to_le(short val, ubyte* buf); |
245 | 248 | --- |
246 | 249 | > void i16_to_le(short val, ubyte* buf) |
247 | 250 | > { |
248 | 251 | > u16_to_le(val, buf); |
249 | 252 | > } |
250 | | -166c353,356 |
| 253 | +172c353,356 |
251 | 254 | < void i32_to_le(int val, ubyte* buf); |
252 | 255 | --- |
253 | 256 | > void i32_to_le(int val, ubyte* buf) |
254 | 257 | > { |
255 | 258 | > u32_to_le(val, buf); |
256 | 259 | > } |
257 | | -172c362,365 |
| 260 | +178c362,365 |
258 | 261 | < void i64_to_le(long val, ubyte* buf); |
259 | 262 | --- |
260 | 263 | > void i64_to_le(long val, ubyte* buf) |
261 | 264 | > { |
262 | 265 | > u64_to_le(val, buf); |
263 | 266 | > } |
264 | | -176,177c369,370 |
| 267 | +182,183c369,370 |
265 | 268 | < * sizeof(float) == sizeof(uint32_t) |
266 | 269 | < * sizeof(double) == sizeof(uint64_t) |
267 | 270 | --- |
268 | 271 | > * sizeof(float) == sizeof(uint) |
269 | 272 | > * sizeof(double) == sizeof(ulong) |
270 | | -188c381,392 |
| 273 | +194c381,392 |
271 | 274 | < float le_to_float(const(ubyte)* buf); |
272 | 275 | --- |
273 | 276 | > float le_to_float(const(ubyte)* buf) |
|
282 | 285 | > convert.u = le_to_u32(buf); |
283 | 286 | > return convert.f; |
284 | 287 | > } |
285 | | -196c400,410 |
| 288 | +202c400,410 |
286 | 289 | < double le_to_double(const(ubyte)* buf); |
287 | 290 | --- |
288 | 291 | > double le_to_double(const(ubyte)* buf) |
|
296 | 299 | > convert.u = le_to_u64(buf); |
297 | 300 | > return convert.f; |
298 | 301 | > } |
299 | | -202c416,426 |
| 302 | +208c416,426 |
300 | 303 | < void float_to_le(float val, ubyte* buf); |
301 | 304 | --- |
302 | 305 | > void float_to_le(float val, ubyte* buf) |
|
310 | 313 | > convert.f = val; |
311 | 314 | > u32_to_le(convert.u, buf); |
312 | 315 | > } |
313 | | -208c432,442 |
| 316 | +214c432,442 |
314 | 317 | < void double_to_le(double val, ubyte* buf); |
315 | 318 | --- |
316 | 319 | > void double_to_le(double val, ubyte* buf) |
|
0 commit comments