|
1 | | -#include <stdlib.h> |
| 1 | +#include <assert.h> |
2 | 2 | #include <limits.h> |
3 | | -#include <string.h> |
4 | 3 | #include <stdint.h> |
5 | | -#include <assert.h> |
| 4 | +#include <stdlib.h> |
| 5 | +#include <string.h> |
6 | 6 |
|
7 | 7 | #include "int_types.h" |
8 | 8 |
|
@@ -233,43 +233,43 @@ static inline double makeQNaN64(void) |
233 | 233 |
|
234 | 234 | #if HAS_80_BIT_LONG_DOUBLE |
235 | 235 | static inline xf_float F80FromRep80(uint16_t hi, uint64_t lo) { |
236 | | - uqwords bits; |
237 | | - bits.high.all = hi; |
238 | | - bits.low.all = lo; |
239 | | - xf_float ret; |
240 | | - static_assert(sizeof(xf_float) <= sizeof(uqwords), "wrong representation"); |
241 | | - memcpy(&ret, &bits, sizeof(ret)); |
242 | | - return ret; |
| 236 | + uqwords bits; |
| 237 | + bits.high.all = hi; |
| 238 | + bits.low.all = lo; |
| 239 | + xf_float ret; |
| 240 | + static_assert(sizeof(xf_float) <= sizeof(uqwords), "wrong representation"); |
| 241 | + memcpy(&ret, &bits, sizeof(ret)); |
| 242 | + return ret; |
243 | 243 | } |
244 | 244 |
|
245 | 245 | static inline uqwords F80ToRep80(xf_float x) { |
246 | | - uqwords ret; |
247 | | - memset(&ret, 0, sizeof(ret)); |
248 | | - memcpy(&ret, &x, sizeof(x)); |
249 | | - // Any bits beyond the first 16 in high are undefined. |
250 | | - ret.high.all = (uint16_t)ret.high.all; |
251 | | - return ret; |
| 246 | + uqwords ret; |
| 247 | + memset(&ret, 0, sizeof(ret)); |
| 248 | + memcpy(&ret, &x, sizeof(x)); |
| 249 | + // Any bits beyond the first 16 in high are undefined. |
| 250 | + ret.high.all = (uint16_t)ret.high.all; |
| 251 | + return ret; |
252 | 252 | } |
253 | 253 |
|
254 | 254 | static inline int compareResultF80(xf_float result, uint16_t expectedHi, |
255 | 255 | uint64_t expectedLo) { |
256 | | - uqwords rep = F80ToRep80(result); |
257 | | - // F80 high occupies the lower 16 bits of high. |
258 | | - assert((uint64_t)(uint16_t)rep.high.all == rep.high.all); |
259 | | - return !(rep.high.all == expectedHi && rep.low.all == expectedLo); |
| 256 | + uqwords rep = F80ToRep80(result); |
| 257 | + // F80 high occupies the lower 16 bits of high. |
| 258 | + assert((uint64_t)(uint16_t)rep.high.all == rep.high.all); |
| 259 | + return !(rep.high.all == expectedHi && rep.low.all == expectedLo); |
260 | 260 | } |
261 | 261 |
|
262 | 262 | static inline xf_float makeQNaN80(void) { |
263 | | - return F80FromRep80(0x7fffu, 0xc000000000000000UL); |
| 263 | + return F80FromRep80(0x7fffu, 0xc000000000000000UL); |
264 | 264 | } |
265 | 265 |
|
266 | 266 | static inline xf_float makeNaN80(uint64_t rand) { |
267 | | - return F80FromRep80(0x7fffu, |
268 | | - 0x8000000000000000 | (rand & 0x3fffffffffffffff)); |
| 267 | + return F80FromRep80(0x7fffu, |
| 268 | + 0x8000000000000000 | (rand & 0x3fffffffffffffff)); |
269 | 269 | } |
270 | 270 |
|
271 | 271 | static inline xf_float makeInf80(void) { |
272 | | - return F80FromRep80(0x7fffu, 0x8000000000000000UL); |
| 272 | + return F80FromRep80(0x7fffu, 0x8000000000000000UL); |
273 | 273 | } |
274 | 274 |
|
275 | 275 | static inline xf_float makeNegativeInf80(void) { |
|
0 commit comments