DD.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef COMPILERRT_DD_HEADER
  2. #define COMPILERRT_DD_HEADER
  3. #include "../int_lib.h"
  4. typedef union {
  5. long double ld;
  6. struct {
  7. double hi;
  8. double lo;
  9. } s;
  10. } DD;
  11. typedef union {
  12. double d;
  13. uint64_t x;
  14. } doublebits;
  15. #define LOWORDER(xy, xHi, xLo, yHi, yLo) \
  16. (((((xHi) * (yHi) - (xy)) + (xHi) * (yLo)) + (xLo) * (yHi)) + (xLo) * (yLo))
  17. static __inline ALWAYS_INLINE double local_fabs(double x) {
  18. doublebits result = {.d = x};
  19. result.x &= UINT64_C(0x7fffffffffffffff);
  20. return result.d;
  21. }
  22. static __inline ALWAYS_INLINE double high26bits(double x) {
  23. doublebits result = {.d = x};
  24. result.x &= UINT64_C(0xfffffffff8000000);
  25. return result.d;
  26. }
  27. static __inline ALWAYS_INLINE int different_sign(double x, double y) {
  28. doublebits xsignbit = {.d = x}, ysignbit = {.d = y};
  29. int result = (int)(xsignbit.x >> 63) ^ (int)(ysignbit.x >> 63);
  30. return result;
  31. }
  32. long double __gcc_qadd(long double, long double);
  33. long double __gcc_qsub(long double, long double);
  34. long double __gcc_qmul(long double, long double);
  35. long double __gcc_qdiv(long double, long double);
  36. #endif // COMPILERRT_DD_HEADER