From 34d77bd3b9811752154a103430a83bd8bff954ad Mon Sep 17 00:00:00 2001 From: ckolivas Date: Wed, 9 Jul 2014 11:55:12 +0300 Subject: [PATCH] Make significant floating point errors fatal to avoid subtle bugs being missed --- configure.ac | 2 +- src/ckpool.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 223fc2d1..1059c64d 100644 --- a/configure.ac +++ b/configure.ac @@ -32,7 +32,7 @@ AC_FUNC_ALLOCA PKG_PROG_PKG_CONFIG() AC_CHECK_HEADERS(stdio.h stdlib.h fcntl.h sys/time.h unistd.h dirent.h) -AC_CHECK_HEADERS(ctype.h errno.h byteswap.h string.h time.h) +AC_CHECK_HEADERS(ctype.h errno.h byteswap.h string.h time.h fenv.h) AC_CHECK_HEADERS(endian.h sys/endian.h arpa/inet.h sys/poll.h syslog.h) AC_CHECK_HEADERS(alloca.h pthread.h stdio.h math.h signal.h sys/prctl.h) AC_CHECK_HEADERS(sys/types.h sys/socket.h sys/stat.h linux/un.h netdb.h) diff --git a/src/ckpool.c b/src/ckpool.c index fc3dd3a4..e08cbc2f 100644 --- a/src/ckpool.c +++ b/src/ckpool.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -877,6 +878,9 @@ int main(int argc, char **argv) int c, ret, i; ckpool_t ckp; + /* Make significant floating point errors fatal to avoid subtle bugs being missed */ + feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW ); + global_ckp = &ckp; memset(&ckp, 0, sizeof(ckp)); ckp.loglevel = LOG_NOTICE;