Skip to content
This repository was archived by the owner on Aug 24, 2021. It is now read-only.

Commit 251bd9c

Browse files
committed
Use C++ symbols with C++11, take 2
1 parent d6c05c6 commit 251bd9c

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

Zend/configure.ac

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,18 @@ int zend_sprintf(char *buffer, const char *format, ...);
5050
# define zend_sprintf sprintf
5151
#endif
5252
53+
#if defined(__cplusplus) && __cplusplus >= 201103L
54+
extern "C++" {
55+
#include <cmath>
56+
#define zend_isnan std::isnan
57+
#define zend_isinf std::isinf
58+
#define zend_finite std::isfinite
59+
}
60+
#else
5361
#include <math.h>
5462
5563
#ifndef zend_isnan
56-
#if HAVE_DECL_ISNAN && (!defined(__cplusplus) || __cplusplus < 201103L)
64+
#if HAVE_DECL_ISNAN
5765
#define zend_isnan(a) isnan(a)
5866
#elif defined(HAVE_FPCLASS)
5967
#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
@@ -62,7 +70,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
6270
#endif
6371
#endif
6472
65-
#if HAVE_DECL_ISINF && (!defined(__cplusplus) || __cplusplus < 201103L)
73+
#if HAVE_DECL_ISINF
6674
#define zend_isinf(a) isinf(a)
6775
#elif defined(INFINITY)
6876
/* Might not work, but is required by ISO C99 */
@@ -73,7 +81,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
7381
#define zend_isinf(a) 0
7482
#endif
7583
76-
#if HAVE_DECL_ISFINITE && (!defined(__cplusplus) || __cplusplus < 201103L)
84+
#if HAVE_DECL_ISFINITE
7785
#define zend_finite(a) isfinite(a)
7886
#elif defined(HAVE_FINITE)
7987
#define zend_finite(a) finite(a)
@@ -83,6 +91,8 @@ int zend_sprintf(char *buffer, const char *format, ...);
8391
#define zend_finite(a) (zend_isnan(a) ? 0 : zend_isinf(a) ? 0 : 1)
8492
#endif
8593
94+
#endif
95+
8696
#endif /* ifndef ZEND_ACCONFIG_H_NO_C_PROTOS */
8797
8898
])

Zend/zend_config.w32.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,18 @@ typedef unsigned int uint;
5050
#endif
5151
#define strcasecmp(s1, s2) _stricmp(s1, s2)
5252
#define strncasecmp(s1, s2, n) _strnicmp(s1, s2, n)
53+
#if defined(__cplusplus) && __cplusplus >= 201103L
54+
extern "C++" {
55+
#include <cmath>
56+
#define zend_isnan std::isnan
57+
#define zend_isinf std::isinf
58+
#define zend_finite std::isfinite
59+
}
60+
#else
5361
#define zend_isinf(a) ((_fpclass(a) == _FPCLASS_PINF) || (_fpclass(a) == _FPCLASS_NINF))
5462
#define zend_finite(x) _finite(x)
5563
#define zend_isnan(x) _isnan(x)
64+
#endif
5665

5766
#define zend_sprintf sprintf
5867

configure.ac

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,18 @@ int zend_sprintf(char *buffer, const char *format, ...);
5959
# define zend_sprintf sprintf
6060
#endif
6161
62+
#if defined(__cplusplus) && __cplusplus >= 201103L
63+
extern "C++" {
64+
#include <cmath>
65+
#define zend_isnan std::isnan
66+
#define zend_isinf std::isinf
67+
#define zend_finite std::isfinite
68+
}
69+
#else
6270
#include <math.h>
6371
6472
#ifndef zend_isnan
65-
#if HAVE_DECL_ISNAN && (!defined(__cplusplus) || __cplusplus < 201103L)
73+
#if HAVE_DECL_ISNAN
6674
#define zend_isnan(a) isnan(a)
6775
#elif defined(HAVE_FPCLASS)
6876
#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
@@ -71,7 +79,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
7179
#endif
7280
#endif
7381
74-
#if HAVE_DECL_ISINF && (!defined(__cplusplus) || __cplusplus < 201103L)
82+
#if HAVE_DECL_ISINF
7583
#define zend_isinf(a) isinf(a)
7684
#elif defined(INFINITY)
7785
/* Might not work, but is required by ISO C99 */
@@ -82,7 +90,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
8290
#define zend_isinf(a) 0
8391
#endif
8492
85-
#if HAVE_DECL_ISFINITE && (!defined(__cplusplus) || __cplusplus < 201103L)
93+
#if HAVE_DECL_ISFINITE
8694
#define zend_finite(a) isfinite(a)
8795
#elif defined(HAVE_FINITE)
8896
#define zend_finite(a) finite(a)
@@ -92,6 +100,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
92100
#define zend_finite(a) (zend_isnan(a) ? 0 : zend_isinf(a) ? 0 : 1)
93101
#endif
94102
103+
#endif
95104
#endif /* ifndef ZEND_ACCONFIG_H_NO_C_PROTOS */
96105
97106
#undef PTHREADS

0 commit comments

Comments
 (0)