libm.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*****************************************************************************/
  2. /*****************************************************************************/
  3. // portions extracted from musl-0.9.15 libm.h
  4. /*****************************************************************************/
  5. /*****************************************************************************/
  6. /* origin: FreeBSD /usr/src/lib/msun/src/math_private.h */
  7. /*
  8. * ====================================================
  9. * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
  10. *
  11. * Developed at SunPro, a Sun Microsystems, Inc. business.
  12. * Permission to use, copy, modify, and distribute this
  13. * software is freely granted, provided that this notice
  14. * is preserved.
  15. * ====================================================
  16. */
  17. #include <stdint.h>
  18. #include <math.h>
  19. #define FLT_EVAL_METHOD 0
  20. #define FORCE_EVAL(x) do { \
  21. if (sizeof(x) == sizeof(float)) { \
  22. volatile float __x; \
  23. __x = (x); \
  24. (void)__x; \
  25. } else if (sizeof(x) == sizeof(double)) { \
  26. volatile double __x; \
  27. __x = (x); \
  28. (void)__x; \
  29. } else { \
  30. volatile long double __x; \
  31. __x = (x); \
  32. (void)__x; \
  33. } \
  34. } while(0)
  35. /* Get a 32 bit int from a float. */
  36. #define GET_FLOAT_WORD(w,d) \
  37. do { \
  38. union {float f; uint32_t i;} __u; \
  39. __u.f = (d); \
  40. (w) = __u.i; \
  41. } while (0)
  42. /* Set a float from a 32 bit int. */
  43. #define SET_FLOAT_WORD(d,w) \
  44. do { \
  45. union {float f; uint32_t i;} __u; \
  46. __u.i = (w); \
  47. (d) = __u.f; \
  48. } while (0)