From aa0424ade806715ea0f410dc068a1eb648300bb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Sun, 8 Aug 2021 16:54:20 +0200 Subject: [PATCH] configure: check for NaN compiler support Compilers might due to optimizations, like -ffast-math (included in -Ofast) expect floating point variables to be never NaN and replace each call to isnan() with false. Htop uses the value NaN for signaling no data available for various information. Warn at configure time if the compiler will ignore NaN values. Note: this can not be implemented as a compile time static assert, as some compilers handle compile NaNs differently than runtime NaNs. --- configure.ac | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/configure.ac b/configure.ac index 99915cce..7ac7377b 100644 --- a/configure.ac +++ b/configure.ac @@ -187,6 +187,23 @@ AC_COMPILE_IFELSE([ AC_MSG_RESULT(no)) CFLAGS="$old_CFLAGS" +AC_MSG_CHECKING(for NaN support) +AC_RUN_IFELSE([ + AC_LANG_PROGRAM( + [[ + #include + ]], + [[ + double x = NAN; return !isnan(x); + ]] + )], + [AC_MSG_RESULT(yes)], + [ + AC_MSG_RESULT(no) + AC_MSG_WARN([Compiler does not respect NaN, some functionality might break; consider using '-fno-finite-math-only']) + ], + [AC_MSG_RESULT(skipped)]) + # ----------------------------------------------------------------------