diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2021-08-08 16:54:20 +0200 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2021-08-08 17:02:12 +0200 |
commit | aa0424ade806715ea0f410dc068a1eb648300bb9 (patch) | |
tree | ddaaa8279a1932c50b5b68cd9a5db2e965152a33 /configure.ac | |
parent | 10e9ffd8e5c353e8a04acbdfcaf0495bd130e96c (diff) |
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.
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 17 |
1 files changed, 17 insertions, 0 deletions
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 <math.h> + ]], + [[ + 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)]) + # ---------------------------------------------------------------------- |