[Pixman] [PATCH v2] test: add a check for FE_DIVBYZERO

Thomas Petazzoni thomas.petazzoni at free-electrons.com
Sun Feb 23 02:10:06 PST 2014


Some architectures, such as Microblaze, currently do not implement
FE_DIVBYZERO, even though they have <fenv.h> and
feenableexcept(). This commit adds a configure.ac check to verify
whether FE_DIVBYZERO is defined or not, and if not, disables the
problematic code in test/utils.c.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>

---
Changes v1 -> v2:

 * Use the ac_cv_have_decl_FE_DIVBYZERO variable, which is
   automatically set by AC_CHECK_DECL, to decide whether or not
   HAVE_FEDIVBYZERO should be defined.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
---
 configure.ac | 5 +++++
 test/utils.c | 2 ++
 2 files changed, 7 insertions(+)

diff --git a/configure.ac b/configure.ac
index 6327972..7564b29 100644
--- a/configure.ac
+++ b/configure.ac
@@ -891,6 +891,11 @@ if test x$have_feenableexcept = xyes; then
    AC_DEFINE(HAVE_FEENABLEEXCEPT, 1, [Whether we have feenableexcept()])
 fi
 
+AC_CHECK_DECL([FE_DIVBYZERO], [], [], [[#include <fenv.h>]])
+if test x$ac_cv_have_decl_FE_DIVBYZERO = xyes; then
+   AC_DEFINE(HAVE_FEDIVBYZERO, 1, [Whether we have FE_DIVBYZERO])
+fi
+
 AC_CHECK_FUNC(gettimeofday, have_gettimeofday=yes, have_gettimeofday=no)
 AC_CHECK_HEADER(sys/time.h, have_sys_time_h=yes, have_sys_time_h=no)
 if test x$have_gettimeofday = xyes && test x$have_sys_time_h = xyes; then
diff --git a/test/utils.c b/test/utils.c
index 1888417..c973939 100644
--- a/test/utils.c
+++ b/test/utils.c
@@ -844,9 +844,11 @@ enable_divbyzero_exceptions (void)
 {
 #ifdef HAVE_FENV_H
 #ifdef HAVE_FEENABLEEXCEPT
+#ifdef HAVE_FE_DIVBYZERO
     feenableexcept (FE_DIVBYZERO);
 #endif
 #endif
+#endif
 }
 
 void *
-- 
1.8.3.2



More information about the Pixman mailing list