Procházet zdrojové kódy

Fix build on systems that do not have nearbyintf().

Try to use rintf() on such systems; if neither nearbyintf nor rintf are available, give an explicit answer message to the user.
Cyril Roelandt před 13 roky
rodič
revize
59cb5ccbb9
2 změnil soubory, kde provedl 14 přidání a 0 odebrání
  1. 6 0
      configure.ac
  2. 8 0
      examples/basic_examples/vector_scal.c

+ 6 - 0
configure.ac

@@ -177,6 +177,12 @@ AC_CHECK_FUNC([setenv], [AC_DEFINE([STARPU_HAVE_SETENV], [1], [Define to 1 if th
 # Some systems do not define unsetenv
 AC_CHECK_FUNC([unsetenv], [AC_DEFINE([STARPU_HAVE_UNSETENV], [1], [Define to 1 if the function unsetenv is available.])])
 
+# Some systems do not define nearbyintf...
+AC_CHECK_FUNC([nearbyintf], [AC_DEFINE([STARPU_HAVE_NEARBYINTF], [1], [Define to 1 if the function nearbyintf is available.])])
+
+# ... but they may define rintf.
+AC_CHECK_FUNC([rintf], [AC_DEFINE([STARPU_HAVE_RINTF], [1], [Define to 1 if the function rintf is available.])])
+
 # Define slow machine
 AC_ARG_ENABLE(slow-machine, [AS_HELP_STRING([--enable-slow-machine],
 				   [Lower default values for the testcases run by make check])],

+ 8 - 0
examples/basic_examples/vector_scal.c

@@ -23,6 +23,7 @@
  *  3- how a kernel can manipulate the data (buffers[0].vector.ptr)
  */
 
+#include <config.h>
 #include <starpu.h>
 #include <starpu_opencl.h>
 #include <stdlib.h>
@@ -88,8 +89,15 @@ struct starpu_opencl_program opencl_program;
 
 static int approximately_equal(float a, float b)
 {
+#ifdef STARPU_HAVE_NEARBYINTF
 	int ai = (int) nearbyintf(a * 1000.0);
 	int bi = (int) nearbyintf(b * 1000.0);
+#elif defined(STARPU_HAVE_RINTF)
+	int ai = (int) rintf(a * 1000.0);
+	int bi = (int) rintf(b * 1000.0);
+#else
+#error "Please define either nearbyintf or rintf."
+#endif
 	return ai == bi;
 }