diff options
author | Eric Haszlakiewicz <erh+git@nimenees.com> | 2014-03-02 12:16:37 -0500 |
---|---|---|
committer | Eric Haszlakiewicz <erh+git@nimenees.com> | 2014-03-02 12:16:37 -0500 |
commit | e6f1322b5e0fbbd5b8767b60c5fe34ff4468ec42 (patch) | |
tree | 268b98c1cc6987a728d8646a34e37881169010e3 | |
parent | db117ca02bdd744a54f7258a2927aa97edbc5f0d (diff) | |
download | android_external_json-c-e6f1322b5e0fbbd5b8767b60c5fe34ff4468ec42.tar.gz android_external_json-c-e6f1322b5e0fbbd5b8767b60c5fe34ff4468ec42.tar.bz2 android_external_json-c-e6f1322b5e0fbbd5b8767b60c5fe34ff4468ec42.zip |
Issue#114: check for the presence of isnan and isinf, and provide compat macros on MSCV where _isnan and _finite exist instead.
-rw-r--r-- | config.h.in | 16 | ||||
-rw-r--r-- | configure.ac | 6 | ||||
-rw-r--r-- | json_object.c | 1 | ||||
-rw-r--r-- | math_compat.h | 20 |
4 files changed, 42 insertions, 1 deletions
diff --git a/config.h.in b/config.h.in index e59a5a3..d612636 100644 --- a/config.h.in +++ b/config.h.in @@ -3,6 +3,22 @@ /* Define if .gnu.warning accepts long strings. */ #undef HAS_GNU_WARNING_LONG +/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't. + */ +#undef HAVE_DECL_ISINF + +/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't. + */ +#undef HAVE_DECL_ISNAN + +/* Define to 1 if you have the declaration of `_finite', and to 0 if you + don't. */ +#undef HAVE_DECL__FINITE + +/* Define to 1 if you have the declaration of `_isnan', and to 0 if you don't. + */ +#undef HAVE_DECL__ISNAN + /* Define to 1 if you have the <dlfcn.h> header file. */ #undef HAVE_DLFCN_H diff --git a/configure.ac b/configure.ac index 5c0a0e8..a7d2d7b 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ(2.52) # Process this file with autoconf to produce a configure script. AC_INIT([json-c], 0.11.99, [json-c@googlegroups.com]) -AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION) +AM_INIT_AUTOMAKE AC_PROG_MAKE_SET @@ -29,6 +29,10 @@ AC_FUNC_MEMCMP AC_FUNC_MALLOC AC_FUNC_REALLOC AC_CHECK_FUNCS(strcasecmp strdup strerror snprintf vsnprintf vasprintf open vsyslog strncasecmp setlocale) +AC_CHECK_DECLS([isnan], [], [], [[#include <math.h>]]) +AC_CHECK_DECLS([isinf], [], [], [[#include <math.h>]]) +AC_CHECK_DECLS([_isnan], [], [], [[#include <float.h>]]) +AC_CHECK_DECLS([_finite], [], [], [[#include <float.h>]]) #check if .section.gnu.warning accepts long strings (for __warn_references) AC_LANG_PUSH([C]) diff --git a/json_object.c b/json_object.c index 377ab59..6cc73bc 100644 --- a/json_object.c +++ b/json_object.c @@ -27,6 +27,7 @@ #include "json_object.h" #include "json_object_private.h" #include "json_util.h" +#include "math_compat.h" #if !defined(HAVE_STRDUP) && defined(_MSC_VER) /* MSC has the version as _strdup */ diff --git a/math_compat.h b/math_compat.h new file mode 100644 index 0000000..4a2721e --- /dev/null +++ b/math_compat.h @@ -0,0 +1,20 @@ +#ifndef __math_compat_h +#define __math_compat_h + +/* Define isnan and isinf on Windows/MSVC */ + +#ifndef HAVE_DECL_ISNAN +# ifdef HAVE_DECL__ISNAN +#include <float.h> +#define isnan(x) _isnan(x) +# endif +#endif + +#ifndef HAVE_DECL_ISINF +# ifdef HAVE_DECL__FINITE +#include <float.h> +#define isinf(x) (!_finite(x)) +# endif +#endif + +#endif |