You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

math_compat.h 898 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef __math_compat_h
  2. #define __math_compat_h
  3. /**
  4. * @file
  5. * @brief Do not use, json-c internal, may be changed or removed at any time.
  6. */
  7. /* Define isnan, isinf, infinity and nan on Windows/MSVC */
  8. #ifndef HAVE_DECL_ISNAN
  9. #ifdef HAVE_DECL__ISNAN
  10. #include <float.h>
  11. #define isnan(x) _isnan(x)
  12. #else
  13. /* On platforms like AIX and "IBM i" we need to provide our own isnan */
  14. #define isnan(x) ((x) != (x))
  15. #endif
  16. #endif
  17. #ifndef HAVE_DECL_ISINF
  18. #ifdef HAVE_DECL__FINITE
  19. #include <float.h>
  20. #define isinf(x) (!_finite(x))
  21. #else
  22. #include <float.h>
  23. /* On platforms like AIX and "IBM i" we need to provide our own isinf */
  24. #define isinf(x) ((x) < -DBL_MAX || (x) > DBL_MAX)
  25. #endif
  26. #endif
  27. #ifndef HAVE_DECL_INFINITY
  28. #include <float.h>
  29. #define INFINITY (DBL_MAX + DBL_MAX)
  30. #define HAVE_DECL_INFINITY
  31. #endif
  32. #ifndef HAVE_DECL_NAN
  33. #define NAN (INFINITY - INFINITY)
  34. #define HAVE_DECL_NAN
  35. #endif
  36. #endif