1dnl This file contains local autoconf functions. 2 3AC_DEFUN([LIBZEND_BISON_CHECK],[ 4 # we only support certain bison versions; 5 # min: 2.4 (i.e. 204, major * 100 + minor for easier comparison) 6 bison_version_min="204" 7 # non-working versions, e.g. "3.0 3.2"; 8 # remove "none" when introducing the first incompatible bison version an 9 # separate any following additions by spaces 10 bison_version_exclude="" 11 12 # for standalone build of Zend Engine 13 test -z "$SED" && SED=sed 14 15 bison_version=none 16 if test "$YACC"; then 17 AC_CACHE_CHECK([for bison version], php_cv_bison_version, [ 18 bison_version_vars=`$YACC --version 2> /dev/null | grep 'GNU Bison' | cut -d ' ' -f 4 | $SED -e 's/\./ /g' | tr -d a-z` 19 php_cv_bison_version=invalid 20 if test -n "$bison_version_vars"; then 21 set $bison_version_vars 22 bison_version="${1}.${2}" 23 bison_version_num="`expr ${1} \* 100 + ${2}`" 24 if test $bison_version_num -ge $bison_version_min; then 25 php_cv_bison_version="$bison_version (ok)" 26 for bison_check_version in $bison_version_exclude; do 27 if test "$bison_version" = "$bison_check_version"; then 28 php_cv_bison_version=invalid 29 break 30 fi 31 done 32 fi 33 fi 34 ]) 35 fi 36 case $php_cv_bison_version in 37 ""|invalid[)] 38 bison_msg="This bison version is not supported for regeneration of the Zend/PHP parsers (found: $bison_version, min: $bison_version_min, excluded: $bison_version_exclude)." 39 AC_MSG_WARN([$bison_msg]) 40 YACC="exit 0;" 41 ;; 42 esac 43]) 44 45AC_DEFUN([ZEND_FP_EXCEPT],[ 46 AC_CACHE_CHECK(whether fp_except is defined, ac_cv_type_fp_except,[ 47 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 48#include <floatingpoint.h> 49]],[[ 50fp_except x = (fp_except) 0; 51]])],[ 52 ac_cv_type_fp_except=yes 53],[ 54 ac_cv_type_fp_except=no 55])]) 56 if test "$ac_cv_type_fp_except" = "yes"; then 57 AC_DEFINE(HAVE_FP_EXCEPT, 1, [whether floatingpoint.h defines fp_except]) 58 fi 59]) 60 61dnl 62dnl Check for broken sprintf() 63dnl 64AC_DEFUN([AC_ZEND_BROKEN_SPRINTF],[ 65 AC_CACHE_CHECK(whether sprintf is broken, ac_cv_broken_sprintf,[ 66 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 67#include <stdio.h> 68int main() {char buf[20]; return sprintf(buf,"testing 123")!=11; } 69]])],[ 70 ac_cv_broken_sprintf=no 71 ],[ 72 ac_cv_broken_sprintf=yes 73 ],[ 74 ac_cv_broken_sprintf=no 75 ]) 76 ]) 77 if test "$ac_cv_broken_sprintf" = "yes"; then 78 ac_result=1 79 else 80 ac_result=0 81 fi 82 AC_DEFINE_UNQUOTED(ZEND_BROKEN_SPRINTF, $ac_result, [Whether sprintf is broken]) 83]) 84 85dnl 86dnl AC_ZEND_C_BIGENDIAN 87dnl Replacement macro for AC_C_BIGENDIAN 88dnl 89AC_DEFUN([AC_ZEND_C_BIGENDIAN], 90[AC_CACHE_CHECK([whether byte ordering is bigendian], ac_cv_c_bigendian_php, 91 [ 92 ac_cv_c_bigendian_php=unknown 93 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 94int main(void) 95{ 96 short one = 1; 97 char *cp = (char *)&one; 98 99 if (*cp == 0) { 100 return(0); 101 } else { 102 return(1); 103 } 104} 105 ]])], [ac_cv_c_bigendian_php=yes], [ac_cv_c_bigendian_php=no], [ac_cv_c_bigendian_php=unknown]) 106 ]) 107 if test $ac_cv_c_bigendian_php = yes; then 108 AC_DEFINE(WORDS_BIGENDIAN, 1, [Define if processor uses big-endian word]) 109 fi 110]) 111 112AC_DEFUN([AM_SET_LIBTOOL_VARIABLE],[ 113 LIBTOOL='$(SHELL) $(top_builddir)/libtool $1' 114]) 115 116dnl x87 floating point internal precision control checks 117dnl See: http://wiki.php.net/rfc/rounding 118AC_DEFUN([ZEND_CHECK_FLOAT_PRECISION],[ 119 AC_MSG_CHECKING([for usable _FPU_SETCW]) 120 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 121 #include <fpu_control.h> 122 ]],[[ 123 fpu_control_t fpu_oldcw, fpu_cw; 124 volatile double result; 125 double a = 2877.0; 126 volatile double b = 1000000.0; 127 128 _FPU_GETCW(fpu_oldcw); 129 fpu_cw = (fpu_oldcw & ~_FPU_EXTENDED & ~_FPU_SINGLE) | _FPU_DOUBLE; 130 _FPU_SETCW(fpu_cw); 131 result = a / b; 132 _FPU_SETCW(fpu_oldcw); 133 ]])],[ac_cfp_have__fpu_setcw=yes],[ac_cfp_have__fpu_setcw=no]) 134 if test "$ac_cfp_have__fpu_setcw" = "yes" ; then 135 AC_DEFINE(HAVE__FPU_SETCW, 1, [whether _FPU_SETCW is present and usable]) 136 AC_MSG_RESULT(yes) 137 else 138 AC_MSG_RESULT(no) 139 fi 140 141 AC_MSG_CHECKING([for usable fpsetprec]) 142 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 143 #include <machine/ieeefp.h> 144 ]],[[ 145 fp_prec_t fpu_oldprec; 146 volatile double result; 147 double a = 2877.0; 148 volatile double b = 1000000.0; 149 150 fpu_oldprec = fpgetprec(); 151 fpsetprec(FP_PD); 152 result = a / b; 153 fpsetprec(fpu_oldprec); 154 ]])], [ac_cfp_have_fpsetprec=yes], [ac_cfp_have_fpsetprec=no]) 155 if test "$ac_cfp_have_fpsetprec" = "yes" ; then 156 AC_DEFINE(HAVE_FPSETPREC, 1, [whether fpsetprec is present and usable]) 157 AC_MSG_RESULT(yes) 158 else 159 AC_MSG_RESULT(no) 160 fi 161 162 AC_MSG_CHECKING([for usable _controlfp]) 163 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 164 #include <float.h> 165 ]],[[ 166 unsigned int fpu_oldcw; 167 volatile double result; 168 double a = 2877.0; 169 volatile double b = 1000000.0; 170 171 fpu_oldcw = _controlfp(0, 0); 172 _controlfp(_PC_53, _MCW_PC); 173 result = a / b; 174 _controlfp(fpu_oldcw, _MCW_PC); 175 ]])], [ac_cfp_have__controlfp=yes], [ac_cfp_have__controlfp=no]) 176 if test "$ac_cfp_have__controlfp" = "yes" ; then 177 AC_DEFINE(HAVE__CONTROLFP, 1, [whether _controlfp is present usable]) 178 AC_MSG_RESULT(yes) 179 else 180 AC_MSG_RESULT(no) 181 fi 182 183 AC_MSG_CHECKING([for usable _controlfp_s]) 184 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 185 #include <float.h> 186 ]],[[ 187 unsigned int fpu_oldcw, fpu_cw; 188 volatile double result; 189 double a = 2877.0; 190 volatile double b = 1000000.0; 191 192 _controlfp_s(&fpu_cw, 0, 0); 193 fpu_oldcw = fpu_cw; 194 _controlfp_s(&fpu_cw, _PC_53, _MCW_PC); 195 result = a / b; 196 _controlfp_s(&fpu_cw, fpu_oldcw, _MCW_PC); 197 ]])], [ac_cfp_have__controlfp_s=yes], [ac_cfp_have__controlfp_s=no]) 198 if test "$ac_cfp_have__controlfp_s" = "yes" ; then 199 AC_DEFINE(HAVE__CONTROLFP_S, 1, [whether _controlfp_s is present and usable]) 200 AC_MSG_RESULT(yes) 201 else 202 AC_MSG_RESULT(no) 203 fi 204 205 AC_MSG_CHECKING([whether FPU control word can be manipulated by inline assembler]) 206 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 207 /* nothing */ 208 ]],[[ 209 unsigned int oldcw, cw; 210 volatile double result; 211 double a = 2877.0; 212 volatile double b = 1000000.0; 213 214 __asm__ __volatile__ ("fnstcw %0" : "=m" (*&oldcw)); 215 cw = (oldcw & ~0x0 & ~0x300) | 0x200; 216 __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw)); 217 218 result = a / b; 219 220 __asm__ __volatile__ ("fldcw %0" : : "m" (*&oldcw)); 221 ]])], [ac_cfp_have_fpu_inline_asm_x86=yes], [ac_cfp_have_fpu_inline_asm_x86=no]) 222 if test "$ac_cfp_have_fpu_inline_asm_x86" = "yes" ; then 223 AC_DEFINE(HAVE_FPU_INLINE_ASM_X86, 1, [whether FPU control word can be manipulated by inline assembler]) 224 AC_MSG_RESULT(yes) 225 else 226 AC_MSG_RESULT(no) 227 fi 228]) 229