test: add a check for FE_DIVBYZERO
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Thu, 17 Sep 2015 13:43:27 +0000 (15:43 +0200)
committerOded Gabbay <oded.gabbay@gmail.com>
Sun, 20 Sep 2015 12:50:04 +0000 (15:50 +0300)
Some architectures, such as Microblaze and Nios2, 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@free-electrons.com>
Signed-off-by: Marek Vasut <marex@denx.de>
Acked-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
configure.ac
test/utils.c

index f93cc30f220e478ac9206bb68228b43ef266355d..424bfd34624a73d4539b14165d85afca2ed843c8 100644 (file)
@@ -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],
+       [AC_DEFINE(HAVE_FEDIVBYZERO, 1, [Whether we have FE_DIVBYZERO])],
+       [],
+       [[#include <fenv.h>]])
+
 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
index 222d4d537e1a03e715732b1ef76638093ade99a5..86579669327e37bc3a9e9c3598af6bdf2cd0c89e 100644 (file)
@@ -966,9 +966,11 @@ enable_divbyzero_exceptions (void)
 {
 #ifdef HAVE_FENV_H
 #ifdef HAVE_FEENABLEEXCEPT
+#ifdef HAVE_FEDIVBYZERO
     feenableexcept (FE_DIVBYZERO);
 #endif
 #endif
+#endif
 }
 
 void