|
2 | 2 | dnl This file contains Zend specific autoconf functions.
|
3 | 3 | dnl
|
4 | 4 |
|
| 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 | + |
5 | 119 | AC_DEFUN([LIBZEND_BASIC_CHECKS],[
|
6 | 120 | AC_REQUIRE([AC_PROG_CC])
|
7 | 121 |
|
|
0 commit comments