Browse Source

OpenBSD systems can also not read NAN values

Nathalie Furmento 7 years ago
parent
commit
38f5b9c9a6
2 changed files with 18 additions and 6 deletions
  1. 5 0
      configure.ac
  2. 13 6
      src/core/perfmodel/perfmodel_nan.c

+ 5 - 0
configure.ac

@@ -592,6 +592,10 @@ case "$target" in
   starpu_linux=yes
   AC_DEFINE(STARPU_LINUX_SYS, [1], [Define to 1 on Linux])
   ;;
+*-*-openbsd*)
+  starpu_openbsd=yes
+  AC_DEFINE(STARPU_OPENBSD_SYS, [1], [Define to 1 on OpenBSD systems])
+  ;;
 *-*darwin*)
   starpu_darwin=yes
   AC_DEFINE(STARPU_HAVE_DARWIN, [1], [Define this on darwin.])
@@ -600,6 +604,7 @@ esac
 AM_CONDITIONAL([STARPU_HAVE_WINDOWS], [test "x$starpu_windows" = "xyes"])
 AM_CONDITIONAL([STARPU_LINUX_SYS], [test "x$starpu_linux" = "xyes"])
 AM_CONDITIONAL([STARPU_HAVE_DARWIN], [test "x$starpu_darwin" = "xyes"])
+AM_CONDITIONAL([STARPU_OPENBSD_SYS], [test "x$starpu_openbsd" = "xyes"])
 
 # on Darwin, GCC targets i386 by default, so we don't have atomic ops
 AC_CHECK_SIZEOF([void *])

+ 13 - 6
src/core/perfmodel/perfmodel_nan.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2013, 2015, 2016  CNRS
+ * Copyright (C) 2013, 2015, 2016, 2017  CNRS
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -22,7 +22,15 @@
 #include <core/perfmodel/perfmodel.h>
 #include <ctype.h>
 
-#ifdef STARPU_HAVE_WINDOWS
+/** Some systems cannot read NAN values, yes, it is really bad ... */
+
+#if defined(STARPU_HAVE_WINDOWS) || defined(STARPU_OPENBSD_SYS)
+#  define _STARPU_OWN_NAN 1
+#else
+#  define _STARPU_OWN_NAN 0
+#endif
+
+#if _STARPU_OWN_NAN == 1
 static
 void _starpu_read_spaces(FILE *f)
 {
@@ -37,11 +45,11 @@ void _starpu_read_spaces(FILE *f)
 		ungetc(c, f);
 	}
 }
-#endif /* STARPU_HAVE_WINDOWS */
+#endif /* _STARPU_OWN_NAN */
 
 void _starpu_write_double(FILE *f, char *format, double val)
 {
-#ifdef STARPU_HAVE_WINDOWS
+#if _STARPU_OWN_NAN == 1
         if (isnan(val))
         {
                 fprintf(f, "NaN");
@@ -57,8 +65,7 @@ void _starpu_write_double(FILE *f, char *format, double val)
 
 int _starpu_read_double(FILE *f, char *format, double *val)
 {
-#ifdef STARPU_HAVE_WINDOWS
-/** Windows cannot read NAN values, yes, it is really bad ... */
+#if _STARPU_OWN_NAN == 1
 	_starpu_read_spaces(f);
 
 	int x1 = getc(f);