Skip to content

Commit 322b97a

Browse files
committed
Use C++ symbols, when C++11 or upper is compiled
1 parent a4b33f7 commit 322b97a

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

Zend/configure.ac

+11-3
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,16 @@ int zend_sprintf(char *buffer, const char *format, ...);
5050
# define zend_sprintf sprintf
5151
#endif
5252
53+
#if defined(__cplusplus) && __cplusplus >= 201103L
54+
#include <cmath>
55+
#define zend_isnan std::isnan
56+
#define zend_isinf std::isinf
57+
#define zend_finite std::isfinite
58+
#else
5359
#include <math.h>
5460
5561
#ifndef zend_isnan
56-
#if HAVE_DECL_ISNAN && (!defined(__cplusplus) || __cplusplus < 201103L)
62+
#if HAVE_DECL_ISNAN
5763
#define zend_isnan(a) isnan(a)
5864
#elif defined(HAVE_FPCLASS)
5965
#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
@@ -62,7 +68,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
6268
#endif
6369
#endif
6470
65-
#if HAVE_DECL_ISINF && (!defined(__cplusplus) || __cplusplus < 201103L)
71+
#if HAVE_DECL_ISINF
6672
#define zend_isinf(a) isinf(a)
6773
#elif defined(INFINITY)
6874
/* Might not work, but is required by ISO C99 */
@@ -73,7 +79,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
7379
#define zend_isinf(a) 0
7480
#endif
7581
76-
#if HAVE_DECL_ISFINITE && (!defined(__cplusplus) || __cplusplus < 201103L)
82+
#if HAVE_DECL_ISFINITE
7783
#define zend_finite(a) isfinite(a)
7884
#elif defined(HAVE_FINITE)
7985
#define zend_finite(a) finite(a)
@@ -83,6 +89,8 @@ int zend_sprintf(char *buffer, const char *format, ...);
8389
#define zend_finite(a) (zend_isnan(a) ? 0 : zend_isinf(a) ? 0 : 1)
8490
#endif
8591
92+
#endif
93+
8694
#endif /* ifndef ZEND_ACCONFIG_H_NO_C_PROTOS */
8795
8896
])

Zend/zend_config.w32.h

+7
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,16 @@ 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+
#include <cmath>
55+
#define zend_isnan std::isnan
56+
#define zend_isinf std::isinf
57+
#define zend_finite std::isfinite
58+
#else
5359
#define zend_isinf(a) ((_fpclass(a) == _FPCLASS_PINF) || (_fpclass(a) == _FPCLASS_NINF))
5460
#define zend_finite(x) _finite(x)
5561
#define zend_isnan(x) _isnan(x)
62+
#endif
5663

5764
#define zend_sprintf sprintf
5865

configure.ac

+10-3
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,16 @@ int zend_sprintf(char *buffer, const char *format, ...);
5959
# define zend_sprintf sprintf
6060
#endif
6161
62+
#if defined(__cplusplus) && __cplusplus >= 201103L
63+
#include <cmath>
64+
#define zend_isnan std::isnan
65+
#define zend_isinf std::isinf
66+
#define zend_finite std::isfinite
67+
#else
6268
#include <math.h>
6369
6470
#ifndef zend_isnan
65-
#if HAVE_DECL_ISNAN && (!defined(__cplusplus) || __cplusplus < 201103L)
71+
#if HAVE_DECL_ISNAN
6672
#define zend_isnan(a) isnan(a)
6773
#elif defined(HAVE_FPCLASS)
6874
#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
@@ -71,7 +77,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
7177
#endif
7278
#endif
7379
74-
#if HAVE_DECL_ISINF && (!defined(__cplusplus) || __cplusplus < 201103L)
80+
#if HAVE_DECL_ISINF
7581
#define zend_isinf(a) isinf(a)
7682
#elif defined(INFINITY)
7783
/* Might not work, but is required by ISO C99 */
@@ -82,7 +88,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
8288
#define zend_isinf(a) 0
8389
#endif
8490
85-
#if HAVE_DECL_ISFINITE && (!defined(__cplusplus) || __cplusplus < 201103L)
91+
#if HAVE_DECL_ISFINITE
8692
#define zend_finite(a) isfinite(a)
8793
#elif defined(HAVE_FINITE)
8894
#define zend_finite(a) finite(a)
@@ -92,6 +98,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
9298
#define zend_finite(a) (zend_isnan(a) ? 0 : zend_isinf(a) ? 0 : 1)
9399
#endif
94100
101+
#endif
95102
#endif /* ifndef ZEND_ACCONFIG_H_NO_C_PROTOS */
96103
97104
#undef PTHREADS

0 commit comments

Comments
 (0)