acinclude.m4 6.5 KB

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