cvs: ZendEngine2 / acinclude.m4

[email protected] ("Christian Seiler")
Newsgroups php.zend-engine.cvs
Message-ID <cvscseiler1228251993@cvsserver>
cseiler		Tue Dec  2 21:06:33 2008 UTC

  Modified files:              
    /ZendEngine2	acinclude.m4 
  Log:
  - Fixed autoconf 2.13 issues with FP checks.
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/acinclude.m4?r1=1.22&r2=1.23&diff_format=u
Index: ZendEngine2/acinclude.m4
diff -u ZendEngine2/acinclude.m4:1.22 ZendEngine2/acinclude.m4:1.23
--- ZendEngine2/acinclude.m4:1.22	Tue Dec  2 16:17:44 2008
+++ ZendEngine2/acinclude.m4	Tue Dec  2 21:06:33 2008
@@ -1,4 +1,4 @@
-dnl $Id: acinclude.m4,v 1.22 2008/12/02 16:17:44 cseiler Exp $
+dnl $Id: acinclude.m4,v 1.23 2008/12/02 21:06:33 cseiler Exp $
 dnl
 dnl This file contains local autoconf functions.
 
@@ -110,31 +110,20 @@
 dnl See: http://wiki.php.net/rfc/rounding
 AC_DEFUN([ZEND_CHECK_FLOAT_PRECISION],[
   AC_MSG_CHECKING([for usable _FPU_SETCW])
-  AC_LINK_IFELSE([[
-   #include <stdio.h>
-   #include <string.h>
-   #include <fpu_control.h>
-  
-   double div (double a, double b) {
-     fpu_control_t fpu_oldcw, fpu_cw;
-     volatile double result;
-  
-     _FPU_GETCW(fpu_oldcw);
-     fpu_cw = (fpu_oldcw & ~_FPU_EXTENDED & ~_FPU_SINGLE) | _FPU_DOUBLE;
-     _FPU_SETCW(fpu_cw);
-     result = a / b;
-     _FPU_SETCW(fpu_oldcw);
-     return result;
-   }
-  
-   int main (int argc, char **argv) {
-     double d = div (2877.0, 1000000.0);
-     char buf[255];
-     sprintf(buf, "%.30f", d);
-     /* see if the result is actually in double precision */
-     return strncmp(buf, "0.00287699", 10) == 0 ? 0 : 1;
-   }
-  ]], [ac_cfp_have__fpu_setcw=yes], [ac_cfp_have__fpu_setcw=no])
+  AC_TRY_LINK([
+    #include <fpu_control.h>
+  ],[
+    fpu_control_t fpu_oldcw, fpu_cw;
+    volatile double result;
+    double a = 2877.0;
+    volatile double b = 1000000.0;
+
+    _FPU_GETCW(fpu_oldcw);
+    fpu_cw = (fpu_oldcw & ~_FPU_EXTENDED & ~_FPU_SINGLE) | _FPU_DOUBLE;
+    _FPU_SETCW(fpu_cw);
+    result = a / b;
+    _FPU_SETCW(fpu_oldcw);
+  ], [ac_cfp_have__fpu_setcw=yes], [ac_cfp_have__fpu_setcw=no])
   if test "$ac_cfp_have__fpu_setcw" = "yes" ; then
     AC_DEFINE(HAVE__FPU_SETCW, 1, [whether _FPU_SETCW is present and usable])
     AC_MSG_RESULT(yes)
@@ -143,30 +132,19 @@
   fi
   
   AC_MSG_CHECKING([for usable fpsetprec])
-  AC_LINK_IFELSE([[
-   #include <stdio.h>
-   #include <string.h>
-   #include <machine/ieeefp.h>
-  
-   double div (double a, double b) {
-     fp_prec_t fpu_oldprec;
-     volatile double result;
-  
-     fpu_oldprec = fpgetprec();
-     fpsetprec(FP_PD);
-     result = a / b;
-     fpsetprec(fpu_oldprec);
-     return result;
-   }
-  
-   int main (int argc, char **argv) {
-     double d = div (2877.0, 1000000.0);
-     char buf[255];
-     sprintf(buf, "%.30f", d);
-     /* see if the result is actually in double precision */
-     return strncmp(buf, "0.00287699", 10) == 0 ? 0 : 1;
-   }
-  ]], [ac_cfp_have_fpsetprec=yes], [ac_cfp_have_fpsetprec=no])
+  AC_TRY_LINK([
+    #include <machine/ieeefp.h>
+  ],[
+    fp_prec_t fpu_oldprec;
+    volatile double result;
+    double a = 2877.0;
+    volatile double b = 1000000.0;
+
+    fpu_oldprec = fpgetprec();
+    fpsetprec(FP_PD);
+    result = a / b;
+    fpsetprec(fpu_oldprec);
+  ], [ac_cfp_have_fpsetprec=yes], [ac_cfp_have_fpsetprec=no])
   if test "$ac_cfp_have_fpsetprec" = "yes" ; then
     AC_DEFINE(HAVE_FPSETPREC, 1, [whether fpsetprec is present and usable])
     AC_MSG_RESULT(yes)
@@ -175,30 +153,19 @@
   fi
 
   AC_MSG_CHECKING([for usable _controlfp])
-  AC_LINK_IFELSE([[
-   #include <stdio.h>
-   #include <string.h>
-   #include <float.h>
-  
-   double div (double a, double b) {
-     unsigned int fpu_oldcw;
-     volatile double result;
-  
-     fpu_oldcw = _controlfp(0, 0);
-     _controlfp(_PC_53, _MCW_PC);
-     result = a / b;
-     _controlfp(fpu_oldcw, _MCW_PC);
-     return result;
-   }
-  
-   int main (int argc, char **argv) {
-     double d = div (2877.0, 1000000.0);
-     char buf[255];
-     sprintf(buf, "%.30f", d);
-     /* see if the result is actually in double precision */
-     return strncmp(buf, "0.00287699", 10) == 0 ? 0 : 1;
-   }
-  ]], [ac_cfp_have__controlfp=yes], [ac_cfp_have__controlfp=no])
+  AC_TRY_LINK([
+    #include <float.h>
+  ],[
+    unsigned int fpu_oldcw;
+    volatile double result;
+    double a = 2877.0;
+    volatile double b = 1000000.0;
+
+    fpu_oldcw = _controlfp(0, 0);
+    _controlfp(_PC_53, _MCW_PC);
+    result = a / b;
+    _controlfp(fpu_oldcw, _MCW_PC);
+  ], [ac_cfp_have__controlfp=yes], [ac_cfp_have__controlfp=no])
   if test "$ac_cfp_have__controlfp" = "yes" ; then
     AC_DEFINE(HAVE__CONTROLFP, 1, [whether _controlfp is present usable])
     AC_MSG_RESULT(yes)
@@ -207,31 +174,20 @@
   fi
 
   AC_MSG_CHECKING([for usable _controlfp_s])
-  AC_LINK_IFELSE([[
-   #include <stdio.h>
-   #include <string.h>
+  AC_TRY_LINK([
    #include <float.h>
-  
-   double div (double a, double b) {
-     unsigned int fpu_oldcw, fpu_cw;
-     volatile double result;
-  
-     _controlfp_s(&fpu_cw, 0, 0);
-     fpu_oldcw = fpu_cw;
-     _controlfp_s(&fpu_cw, _PC_53, _MCW_PC);
-     result = a / b;
-     _controlfp_s(&fpu_cw, fpu_oldcw, _MCW_PC);
-     return result;
-   }
-  
-   int main (int argc, char **argv) {
-     double d = div (2877.0, 1000000.0);
-     char buf[255];
-     sprintf(buf, "%.30f", d);
-     /* see if the result is actually in double precision */
-     return strncmp(buf, "0.00287699", 10) == 0 ? 0 : 1;
-   }
-  ]], [ac_cfp_have__controlfp_s=yes], [ac_cfp_have__controlfp_s=no])
+  ],[
+    unsigned int fpu_oldcw, fpu_cw;
+    volatile double result;
+    double a = 2877.0;
+    volatile double b = 1000000.0;
+
+    _controlfp_s(&fpu_cw, 0, 0);
+    fpu_oldcw = fpu_cw;
+    _controlfp_s(&fpu_cw, _PC_53, _MCW_PC);
+    result = a / b;
+    _controlfp_s(&fpu_cw, fpu_oldcw, _MCW_PC);
+  ], [ac_cfp_have__controlfp_s=yes], [ac_cfp_have__controlfp_s=no])
   if test "$ac_cfp_have__controlfp_s" = "yes" ; then
     AC_DEFINE(HAVE__CONTROLFP_S, 1, [whether _controlfp_s is present and usable])
     AC_MSG_RESULT(yes)
@@ -240,33 +196,22 @@
   fi
 
   AC_MSG_CHECKING([whether FPU control word can be manipulated by inline assembler])
-  AC_LINK_IFELSE([[
-   #include <stdio.h>
-   #include <string.h>
-   
-   double div (double a, double b) {
-     unsigned int oldcw, cw;
-     volatile double result;
-     
-     __asm__ __volatile__ ("fnstcw %0" : "=m" (*&oldcw));
-     cw = (oldcw & ~0x0 & ~0x300) | 0x200;
-     __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw));
-     
-     result = a / b;
-     
-     __asm__ __volatile__ ("fldcw %0" : : "m" (*&oldcw));
-     
-     return result;
-   }
-  
-   int main (int argc, char **argv) {
-     double d = div (2877.0, 1000000.0);
-     char buf[255];
-     sprintf(buf, "%.30f", d);
-     /* see if the result is actually in double precision */
-     return strncmp(buf, "0.00287699", 10) == 0 ? 0 : 1;
-   }
-  ]], [ac_cfp_have_fpu_inline_asm_x86=yes], [ac_cfp_have_fpu_inline_asm_x86=no])
+  AC_TRY_LINK([
+    /* nothing */
+  ],[
+    unsigned int oldcw, cw;
+    volatile double result;
+    double a = 2877.0;
+    volatile double b = 1000000.0;
+
+    __asm__ __volatile__ ("fnstcw %0" : "=m" (*&oldcw));
+    cw = (oldcw & ~0x0 & ~0x300) | 0x200;
+    __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw));
+
+    result = a / b;
+
+    __asm__ __volatile__ ("fldcw %0" : : "m" (*&oldcw));
+  ], [ac_cfp_have_fpu_inline_asm_x86=yes], [ac_cfp_have_fpu_inline_asm_x86=no])
   if test "$ac_cfp_have_fpu_inline_asm_x86" = "yes" ; then
     AC_DEFINE(HAVE_FPU_INLINE_ASM_X86, 1, [whether FPU control word can be manipulated by inline assembler])
     AC_MSG_RESULT(yes)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.