Alternative for isinf (fix for bug 12008)
Petr Sumbera
petr.sumbera at sun.com
Thu Apr 17 09:10:17 CDT 2008
---
configure | 148 ++++++++++++++++++++++++++++++++++++++++
configure.ac | 6 ++
dlls/wined3d/wined3d_private.h | 9 +++
include/config.h.in | 3 +
4 files changed, 166 insertions(+), 0 deletions(-)
diff --git a/configure b/configure
index 01fdf19..23d8891 100755
--- a/configure
+++ b/configure
@@ -16977,6 +16977,154 @@ fi
done
+
+for ac_func in isinf
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext &&
+ $as_test_x conftest$ac_exeext; then
+ eval "$as_ac_var=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+ { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+else
+ { echo "$as_me:$LINENO: checking for isinf with <math.h>" >&5
+echo $ECHO_N "checking for isinf with <math.h>... $ECHO_C" >&6; }
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <math.h>
+int
+main ()
+{
+float f = 0.0; isinf(f)
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext &&
+ $as_test_x conftest$ac_exeext; then
+ { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_ISINF 1
+_ACEOF
+
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+done
+
+
if test "$ac_cv_func_dlopen" = no
then
{ echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
diff --git a/configure.ac b/configure.ac
index b5c4bf2..2d932d7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1406,6 +1406,12 @@ AC_CHECK_FUNCS(\
waitpid \
)
+dnl Check for isinf
+AC_CHECK_FUNCS(isinf, ,
+ [AC_MSG_CHECKING(for isinf with <math.h>)
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <math.h>]], [[float f = 0.0; isinf(f)]])],[AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_ISINF,1,we have the isinf function)],[AC_MSG_RESULT(no)])])
+
dnl Check for -ldl
if test "$ac_cv_func_dlopen" = no
then
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 18c7a09..7c51d3a 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -26,6 +26,9 @@
#include <stdarg.h>
#include <math.h>
+#ifdef HAVE_IEEEFP_H
+#include <ieeefp.h>
+#endif
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#define COBJMACROS
@@ -161,7 +164,13 @@ static inline unsigned short float_32_to_16(const float *in) {
/* Deal with special numbers */
if(*in == 0.0) return 0x0000;
if(isnan(*in)) return 0x7C01;
+#if defined (HAVE_ISINF)
if(isinf(*in)) return (*in < 0.0 ? 0xFC00 : 0x7c00);
+#elif defined (HAVE_IEEEFP_H)
+ if(!(finite(*in) || isnand(*in))) (*in < 0.0 ? 0xFC00 : 0x7c00);
+#else
+ #error "isinf() or ieeefp.h needed"
+#endif
if(tmp < pow(2, 10)) {
do
diff --git a/include/config.h.in b/include/config.h.in
index f867662..206cf49 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -249,6 +249,9 @@
/* Define to 1 if you have the <io.h> header file. */
#undef HAVE_IO_H
+/* Define to 1 if you have the `isinf' function. */
+#undef HAVE_ISINF
+
/* Define to 1 if you have the <jack/jack.h> header file. */
#undef HAVE_JACK_JACK_H
--
1.5.4.5
--Boundary_(ID_7+obP62Ps8n4rQwQHV5bjA)--
More information about the wine-patches
mailing list