Brian Silverman | d8c81de | 2013-04-16 23:20:54 -0700 | [diff] [blame^] | 1 | #include <stdint.h> |
| 2 | |
| 3 | // stolen from |
| 4 | // http://llvm.org/svn/llvm-project/compiler-rt/trunk/lib/floatundidf.c@179666 |
| 5 | // |
| 6 | // Lame hack to provide a libgcc function that the version on the crio doesn't |
| 7 | // have. |
| 8 | // TODO(brians): make this nicer and figure out which other ones we need |
| 9 | |
| 10 | double __floatundidf(unsigned long long a) |
| 11 | { |
| 12 | static const double twop52 = 0x1.0p52; |
| 13 | static const double twop84 = 0x1.0p84; |
| 14 | static const double twop84_plus_twop52 = 0x1.00000001p84; |
| 15 | |
| 16 | union { uint64_t x; double d; } high = { .d = twop84 }; |
| 17 | union { uint64_t x; double d; } low = { .d = twop52 }; |
| 18 | |
| 19 | high.x |= a >> 32; |
| 20 | low.x |= a & 0x00000000ffffffffULL; |
| 21 | |
| 22 | const double result = (high.d - twop84_plus_twop52) + low.d; |
| 23 | return result; |
| 24 | } |