Skip to content

Commit b1d3509

Browse files
committed
Refactor Zend/acinclude.m4 local macro
There is now only a single M4 macro in the legacy acinclude.m4 file. A separate acinclude file was once used with a standalone Zend engine building but with current build system this can be simplified a bit.
1 parent 1c94aac commit b1d3509

File tree

4 files changed

+115
-120
lines changed

4 files changed

+115
-120
lines changed

Zend/Zend.m4

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,120 @@ dnl
22
dnl This file contains Zend specific autoconf functions.
33
dnl
44

5+
dnl x87 floating point internal precision control checks
6+
dnl See: http://wiki.php.net/rfc/rounding
7+
AC_DEFUN([ZEND_CHECK_FLOAT_PRECISION],[
8+
AC_MSG_CHECKING([for usable _FPU_SETCW])
9+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
10+
#include <fpu_control.h>
11+
]],[[
12+
fpu_control_t fpu_oldcw, fpu_cw;
13+
volatile double result;
14+
double a = 2877.0;
15+
volatile double b = 1000000.0;
16+
17+
_FPU_GETCW(fpu_oldcw);
18+
fpu_cw = (fpu_oldcw & ~_FPU_EXTENDED & ~_FPU_SINGLE) | _FPU_DOUBLE;
19+
_FPU_SETCW(fpu_cw);
20+
result = a / b;
21+
_FPU_SETCW(fpu_oldcw);
22+
]])],[ac_cfp_have__fpu_setcw=yes],[ac_cfp_have__fpu_setcw=no])
23+
if test "$ac_cfp_have__fpu_setcw" = "yes" ; then
24+
AC_DEFINE(HAVE__FPU_SETCW, 1, [whether _FPU_SETCW is present and usable])
25+
AC_MSG_RESULT(yes)
26+
else
27+
AC_MSG_RESULT(no)
28+
fi
29+
30+
AC_MSG_CHECKING([for usable fpsetprec])
31+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
32+
#include <machine/ieeefp.h>
33+
]],[[
34+
fp_prec_t fpu_oldprec;
35+
volatile double result;
36+
double a = 2877.0;
37+
volatile double b = 1000000.0;
38+
39+
fpu_oldprec = fpgetprec();
40+
fpsetprec(FP_PD);
41+
result = a / b;
42+
fpsetprec(fpu_oldprec);
43+
]])], [ac_cfp_have_fpsetprec=yes], [ac_cfp_have_fpsetprec=no])
44+
if test "$ac_cfp_have_fpsetprec" = "yes" ; then
45+
AC_DEFINE(HAVE_FPSETPREC, 1, [whether fpsetprec is present and usable])
46+
AC_MSG_RESULT(yes)
47+
else
48+
AC_MSG_RESULT(no)
49+
fi
50+
51+
AC_MSG_CHECKING([for usable _controlfp])
52+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
53+
#include <float.h>
54+
]],[[
55+
unsigned int fpu_oldcw;
56+
volatile double result;
57+
double a = 2877.0;
58+
volatile double b = 1000000.0;
59+
60+
fpu_oldcw = _controlfp(0, 0);
61+
_controlfp(_PC_53, _MCW_PC);
62+
result = a / b;
63+
_controlfp(fpu_oldcw, _MCW_PC);
64+
]])], [ac_cfp_have__controlfp=yes], [ac_cfp_have__controlfp=no])
65+
if test "$ac_cfp_have__controlfp" = "yes" ; then
66+
AC_DEFINE(HAVE__CONTROLFP, 1, [whether _controlfp is present usable])
67+
AC_MSG_RESULT(yes)
68+
else
69+
AC_MSG_RESULT(no)
70+
fi
71+
72+
AC_MSG_CHECKING([for usable _controlfp_s])
73+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
74+
#include <float.h>
75+
]],[[
76+
unsigned int fpu_oldcw, fpu_cw;
77+
volatile double result;
78+
double a = 2877.0;
79+
volatile double b = 1000000.0;
80+
81+
_controlfp_s(&fpu_cw, 0, 0);
82+
fpu_oldcw = fpu_cw;
83+
_controlfp_s(&fpu_cw, _PC_53, _MCW_PC);
84+
result = a / b;
85+
_controlfp_s(&fpu_cw, fpu_oldcw, _MCW_PC);
86+
]])], [ac_cfp_have__controlfp_s=yes], [ac_cfp_have__controlfp_s=no])
87+
if test "$ac_cfp_have__controlfp_s" = "yes" ; then
88+
AC_DEFINE(HAVE__CONTROLFP_S, 1, [whether _controlfp_s is present and usable])
89+
AC_MSG_RESULT(yes)
90+
else
91+
AC_MSG_RESULT(no)
92+
fi
93+
94+
AC_MSG_CHECKING([whether FPU control word can be manipulated by inline assembler])
95+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
96+
/* nothing */
97+
]],[[
98+
unsigned int oldcw, cw;
99+
volatile double result;
100+
double a = 2877.0;
101+
volatile double b = 1000000.0;
102+
103+
__asm__ __volatile__ ("fnstcw %0" : "=m" (*&oldcw));
104+
cw = (oldcw & ~0x0 & ~0x300) | 0x200;
105+
__asm__ __volatile__ ("fldcw %0" : : "m" (*&cw));
106+
107+
result = a / b;
108+
109+
__asm__ __volatile__ ("fldcw %0" : : "m" (*&oldcw));
110+
]])], [ac_cfp_have_fpu_inline_asm_x86=yes], [ac_cfp_have_fpu_inline_asm_x86=no])
111+
if test "$ac_cfp_have_fpu_inline_asm_x86" = "yes" ; then
112+
AC_DEFINE(HAVE_FPU_INLINE_ASM_X86, 1, [whether FPU control word can be manipulated by inline assembler])
113+
AC_MSG_RESULT(yes)
114+
else
115+
AC_MSG_RESULT(no)
116+
fi
117+
])
118+
5119
AC_DEFUN([LIBZEND_BASIC_CHECKS],[
6120
AC_REQUIRE([AC_PROG_CC])
7121

Zend/acinclude.m4

Lines changed: 0 additions & 115 deletions
This file was deleted.

buildconf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,4 @@ $MAKE -s -f build/build.mk \
103103
PHP_AUTOCONF="$PHP_AUTOCONF" \
104104
PHP_AUTOHEADER="$PHP_AUTOHEADER" \
105105
PHP_AUTOCONF_FLAGS="$autoconf_flags" \
106-
PHP_M4_FILES="$(echo TSRM/*.m4 Zend/*.m4 ext/*/config*.m4 sapi/*/config*.m4)"
106+
PHP_M4_FILES="$(echo TSRM/*.m4 Zend/Zend.m4 ext/*/config*.m4 sapi/*/config*.m4)"

configure.ac

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
dnl ## Process this file with autoconf to produce a configure script.
22

3-
dnl include Zend specific macro definitions first
4-
dnl -------------------------------------------------------------------------
5-
sinclude(Zend/acinclude.m4)
6-
73
dnl Basic autoconf initialization, generation of config.nice.
84
dnl -------------------------------------------------------------------------
95

0 commit comments

Comments
 (0)