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.
This commit is contained in:
Christian Göttsche 2021-08-08 16:54:20 +02:00 committed by BenBE
parent 10e9ffd8e5
commit aa0424ade8
1 changed files with 17 additions and 0 deletions

View File

@ -187,6 +187,23 @@ AC_COMPILE_IFELSE([
AC_MSG_RESULT(no)) AC_MSG_RESULT(no))
CFLAGS="$old_CFLAGS" 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)])
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------