2014-03-02 12:16:37 -05:00
|
|
|
#ifndef __math_compat_h
|
|
|
|
|
#define __math_compat_h
|
|
|
|
|
|
2017-12-06 00:20:59 -05:00
|
|
|
/**
|
|
|
|
|
* @file
|
|
|
|
|
* @brief Do not use, json-c internal, may be changed or removed at any time.
|
|
|
|
|
*/
|
|
|
|
|
|
2015-02-05 15:56:49 +00:00
|
|
|
/* Define isnan, isinf, infinity and nan on Windows/MSVC */
|
2014-03-02 12:16:37 -05:00
|
|
|
|
|
|
|
|
#ifndef HAVE_DECL_ISNAN
|
2020-03-28 10:25:00 +08:00
|
|
|
#ifdef HAVE_DECL__ISNAN
|
2014-03-02 12:16:37 -05:00
|
|
|
#include <float.h>
|
|
|
|
|
#define isnan(x) _isnan(x)
|
2020-05-16 01:29:18 +00:00
|
|
|
#else
|
|
|
|
|
/* On platforms like AIX and "IBM i" we need to provide our own isnan */
|
|
|
|
|
#define isnan(x) ((x) != (x))
|
2020-03-28 10:25:00 +08:00
|
|
|
#endif
|
2014-03-02 12:16:37 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef HAVE_DECL_ISINF
|
2020-03-28 10:25:00 +08:00
|
|
|
#ifdef HAVE_DECL__FINITE
|
2014-03-02 12:16:37 -05:00
|
|
|
#include <float.h>
|
|
|
|
|
#define isinf(x) (!_finite(x))
|
2020-05-16 01:29:18 +00:00
|
|
|
#else
|
|
|
|
|
#include <float.h>
|
|
|
|
|
/* On platforms like AIX and "IBM i" we need to provide our own isinf */
|
|
|
|
|
#define isinf(x) ((x) < -DBL_MAX || (x) > DBL_MAX)
|
2020-03-28 10:25:00 +08:00
|
|
|
#endif
|
2014-03-02 12:16:37 -05:00
|
|
|
#endif
|
|
|
|
|
|
2015-02-05 15:56:49 +00:00
|
|
|
#ifndef HAVE_DECL_INFINITY
|
|
|
|
|
#include <float.h>
|
|
|
|
|
#define INFINITY (DBL_MAX + DBL_MAX)
|
|
|
|
|
#define HAVE_DECL_INFINITY
|
2014-03-09 16:41:33 -04:00
|
|
|
#endif
|
|
|
|
|
|
2015-02-05 15:56:49 +00:00
|
|
|
#ifndef HAVE_DECL_NAN
|
|
|
|
|
#define NAN (INFINITY - INFINITY)
|
|
|
|
|
#define HAVE_DECL_NAN
|
2014-03-22 17:28:40 -04:00
|
|
|
#endif
|
|
|
|
|
|
2014-03-02 12:16:37 -05:00
|
|
|
#endif
|