goffice r2133 - in branches/goffice-0-6: . goffice/math



Author: mortenw
Date: Tue Jul  1 00:27:47 2008
New Revision: 2133
URL: http://svn.gnome.org/viewvc/goffice?rev=2133&view=rev

Log:
2008-06-30  Morten Welinder  <terra gnome org>

	* goffice/math/go-math.c (go_math_init): Check for buggy
	valgrind (finitel problem) and limp on.



Modified:
   branches/goffice-0-6/ChangeLog
   branches/goffice-0-6/NEWS
   branches/goffice-0-6/goffice/math/go-math.c

Modified: branches/goffice-0-6/NEWS
==============================================================================
--- branches/goffice-0-6/NEWS	(original)
+++ branches/goffice-0-6/NEWS	Tue Jul  1 00:27:47 2008
@@ -5,6 +5,9 @@
 	* Fixed plot types activation/deactivation issues.
 	* Always use full lines when drawing markers. [#536276]
 
+Morten:
+	* Work around valgrind bug.
+
 Rob Staudinger:
 	* Use plain menu items for toolbar overflow image menu item proxies, 
 	so they are displayed correctly with gtk-menu-images=0. [#537541]

Modified: branches/goffice-0-6/goffice/math/go-math.c
==============================================================================
--- branches/goffice-0-6/goffice/math/go-math.c	(original)
+++ branches/goffice-0-6/goffice/math/go-math.c	Tue Jul  1 00:27:47 2008
@@ -40,6 +40,37 @@
 double go_pinf;
 double go_ninf;
 
+#ifdef GOFFICE_WITH_LONG_DOUBLE
+static gboolean
+running_under_buggy_valgrind (void)
+{
+	long double one = atof ("1");
+	if (one * LDBL_MIN > (long double)0)
+		return FALSE;
+
+	/*
+	 * We get here is long double fails to satisfy a requirement of
+	 * C99, namely that LDBL_MIN is positive.  That is probably
+	 * valgrind mapping long doubles to doubles.
+	 *
+	 * Chances are that go_pinfl/go_ninf/go_nanl are fine, but that
+	 * finitel fails.  Perform alternate tests.
+	 */
+
+	if (!(go_pinfl > DBL_MAX && !isnanl (go_pinfl) && isnanl (go_pinfl - go_pinfl)))
+		return FALSE;
+
+	if (!(-go_ninfl > DBL_MAX && !isnanl (go_ninfl) && isnanl (go_ninfl - go_ninfl)))
+		return FALSE;
+
+	if (!isnanl (go_nanl) && !(go_nanl >= 0) && !(go_nanl <= 0))
+		return FALSE;
+
+	/* finitel must be hosed.  Blame valgrind.  */
+	return TRUE;
+}
+#endif
+
 void
 go_math_init (void)
 {
@@ -136,14 +167,18 @@
 	if (!(isnanl (go_nanl) &&
 	      go_pinfl > 0 && !finitel (go_pinfl) &&
 	      go_ninfl < 0 && !finitel (go_ninfl))) {
-		g_error ("Failed to generate long double NaN/+Inf/-Inf.\n"
-			 "    go_nanl=%.20Lg\n"
-			 "    go_pinfl=%.20Lg\n"
-			 "    go_ninfl=%.20Lg\n"
-			 "Please report at %s",
-			 go_nanl, go_pinfl, go_ninfl,
-			 bug_url);
-		abort ();
+		if (running_under_buggy_valgrind ()) {
+			g_warning ("Running under buggy valgrind, see http://bugs.kde.org/show_bug.cgi?id=164298";);
+		} else {
+			g_error ("Failed to generate long double NaN/+Inf/-Inf.\n"
+				 "    go_nanl=%.20Lg\n"
+				 "    go_pinfl=%.20Lg\n"
+				 "    go_ninfl=%.20Lg\n"
+				 "Please report at %s",
+				 go_nanl, go_pinfl, go_ninfl,
+				 bug_url);
+			abort ();
+		}
 	}
 #endif
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]