[PATCH] test: Define optional exception classes

Uli Schlachter <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
From d5f9c694b9145f0464c8bd58d844bddedcb77d5e Mon Sep 17 00:00:00 2001
From: Uli Schlachter <[email protected]>
Date: Tue, 16 Oct 2012 17:09:42 +0200
Subject: [PATCH] test: Define optional exception classes

According to musl libc author:

"C99 requires the FE_ macros to be defined if and only if the exception they
correspond to is supported"

So we define these macros to 0 if they are not supported. Support for these FPU
exceptions is not necessary for correct functionality, but makes some tests less
effective.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=55771
Signed-off-by: Uli Schlachter <[email protected]>
---
 test/cairo-test.c     |    3 ---
 test/cairo-test.h     |   20 ++++++++++++++++++++
 test/invalid-matrix.c |    4 ----
 3 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/test/cairo-test.c b/test/cairo-test.c
index 3f37147..076b014 100644
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -35,9 +35,6 @@
 #include <stdlib.h>
 #include <stdarg.h>
 #include <ctype.h>
-#if HAVE_FEENABLEEXCEPT
-#include <fenv.h>
-#endif
 #include <assert.h>
 #if HAVE_UNISTD_H
 #include <unistd.h>
diff --git a/test/cairo-test.h b/test/cairo-test.h
index d41cd29..87ba7df 100644
--- a/test/cairo-test.h
+++ b/test/cairo-test.h
@@ -62,6 +62,26 @@ typedef unsigned __int64 uint64_t;

 #endif

+#if HAVE_FENV_H
+# include <fenv.h>
+#endif
+/* The following are optional in C99, so define them if they aren't yet */
+#ifndef FE_DIVBYZERO
+#define FE_DIVBYZERO 0
+#endif
+#ifndef FE_INEXACT
+#define FE_INEXACT 0
+#endif
+#ifndef FE_INVALID
+#define FE_INVALID 0
+#endif
+#ifndef FE_OVERFLOW
+#define FE_OVERFLOW 0
+#endif
+#ifndef FE_UNDERFLOW
+#define FE_UNDERFLOW 0
+#endif
+
 #include <math.h>

 static inline double
diff --git a/test/invalid-matrix.c b/test/invalid-matrix.c
index 6cfaedf..9bb26be 100644
--- a/test/invalid-matrix.c
+++ b/test/invalid-matrix.c
@@ -33,10 +33,6 @@
 #define INFINITY HUGE_VAL
 #endif

-#if HAVE_FENV_H
-# include <fenv.h>
-#endif
-
 static cairo_test_status_t
 draw (cairo_t *cr, int width, int height)
 {
-- 
1.7.10.4
-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.