|
15 | 15 | // |
16 | 16 | //===----------------------------------------------------------------------===// |
17 | 17 |
|
18 | | -unsigned __compiler_rt_fnan2(unsigned a, unsigned b) { |
| 18 | +#include <stdint.h> |
| 19 | + |
| 20 | +uint32_t __compiler_rt_fnan2(uint32_t a, uint32_t b) { |
19 | 21 | // Make shifted-left copies of a and b to discard the sign bit. Then add 1 at |
20 | 22 | // the bit position where the quiet vs signalling bit ended up. This squashes |
21 | 23 | // all the signalling NaNs to the top of the range of 32-bit values, from |
22 | 24 | // 0xff800001 to 0xffffffff inclusive; meanwhile, all the quiet NaN values |
23 | 25 | // wrap round to the bottom, from 0 to 0x007fffff inclusive. So we can detect |
24 | 26 | // a signalling NaN by asking if it's greater than 0xff800000, and a quiet |
25 | 27 | // one by asking if it's less than 0x00800000. |
26 | | - unsigned aadj = (a << 1) + 0x00800000; |
27 | | - unsigned badj = (b << 1) + 0x00800000; |
| 28 | + uint32_t aadj = (a << 1) + 0x00800000; |
| 29 | + uint32_t badj = (b << 1) + 0x00800000; |
28 | 30 | if (aadj > 0xff800000) // a is a signalling NaN? |
29 | 31 | return a | 0x00400000; // if so, return it with the quiet bit set |
30 | 32 | if (badj > 0xff800000) // b is a signalling NaN? |
31 | 33 | return b | 0x00400000; // if so, return it with the quiet bit set |
32 | 34 | if (aadj < 0x00800000) // a is a quiet NaN? |
33 | 35 | return a; // if so, return it |
34 | | - else /* expect (badj < 0x00800000) */ |
35 | | - return b; // in that case b must be a quiet NaN |
| 36 | + return b; // otherwise we expect b must be a quiet NaN |
36 | 37 | } |
0 commit comments