acinclude.m4 6.6 KB

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