summaryrefslogtreecommitdiff
path: root/Zend/Zend.m4
diff options
context:
space:
mode:
Diffstat (limited to 'Zend/Zend.m4')
-rw-r--r--Zend/Zend.m432
1 files changed, 32 insertions, 0 deletions
diff --git a/Zend/Zend.m4 b/Zend/Zend.m4
index 904f188681..bf9be5c7f8 100644
--- a/Zend/Zend.m4
+++ b/Zend/Zend.m4
@@ -117,6 +117,38 @@ AC_CHECK_FUNCS(finite isfinite isinf isnan)
ZEND_FP_EXCEPT
ZEND_CHECK_FLOAT_PRECISION
+
+dnl test whether double cast to long preserves least significant bits
+AC_MSG_CHECKING(whether double cast to long preserves least significant bits)
+
+AC_TRY_RUN([
+#include <limits.h>
+
+int main()
+{
+ if (sizeof(long) == 4) {
+ double d = (double) LONG_MIN * LONG_MIN + 2e9;
+
+ if ((long) d == 2e9 && (long) -d == -2e9) {
+ exit(0);
+ }
+ } else if (sizeof(long) == 8) {
+ double correct = 18e18 - ((double) LONG_MIN * -2); /* Subtract ULONG_MAX + 1 */
+
+ if ((long) 18e18 == correct) { /* On 64-bit, only check between LONG_MAX and ULONG_MAX */
+ exit(0);
+ }
+ }
+ exit(1);
+}
+], [
+ AC_DEFINE([ZEND_DVAL_TO_LVAL_CAST_OK], 1, [Define if double cast to long preserves least significant bits])
+ AC_MSG_RESULT(yes)
+], [
+ AC_MSG_RESULT(no)
+], [
+ AC_MSG_RESULT(no)
+])
])