From dbba685c697d31fcb7ece6d7435989dbccc71866 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 19 Jan 2019 23:39:51 +0100 Subject: build: include auto/config.h explicitly Otherwise the symbols defined in config/config.h.in may not be defined, depending on include-order. --- src/nvim/assert.h | 6 ++++-- src/nvim/log.c | 1 + src/nvim/log.h | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/assert.h b/src/nvim/assert.h index 29195a49dc..f3a5c71341 100644 --- a/src/nvim/assert.h +++ b/src/nvim/assert.h @@ -1,6 +1,8 @@ #ifndef NVIM_ASSERT_H #define NVIM_ASSERT_H +#include "auto/config.h" + // support static asserts (aka compile-time asserts) // some compilers don't properly support short-circuiting apparently, giving @@ -133,7 +135,7 @@ /// /// @param MAX Maximum value of the narrowest type of operand. /// Not used if compiler supports __builtin_add_overflow. -#if HAVE_BUILTIN_ADD_OVERFLOW +#ifdef HAVE_BUILTIN_ADD_OVERFLOW # define STRICT_ADD(a, b, c, t) \ do { if (__builtin_add_overflow(a, b, c)) { abort(); } } while (0) #else @@ -143,7 +145,7 @@ /// @def STRICT_SUB /// @brief Subtracts (a - b) and stores result in `c`. Aborts on overflow. -#if HAVE_BUILTIN_ADD_OVERFLOW +#ifdef HAVE_BUILTIN_ADD_OVERFLOW # define STRICT_SUB(a, b, c, t) \ do { if (__builtin_sub_overflow(a, b, c)) { abort(); } } while (0) #else diff --git a/src/nvim/log.c b/src/nvim/log.c index 4d912c452b..8066b6e828 100644 --- a/src/nvim/log.c +++ b/src/nvim/log.c @@ -12,6 +12,7 @@ #endif #include +#include "auto/config.h" #include "nvim/log.h" #include "nvim/types.h" #include "nvim/os/os.h" diff --git a/src/nvim/log.h b/src/nvim/log.h index 7d4c033565..17ff095473 100644 --- a/src/nvim/log.h +++ b/src/nvim/log.h @@ -4,6 +4,8 @@ #include #include +#include "auto/config.h" + #define DEBUG_LOG_LEVEL 0 #define INFO_LOG_LEVEL 1 #define WARN_LOG_LEVEL 2 -- cgit From c11b79ce51ad1c52e2c2e2700fcaff35b851bc97 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 20 Jan 2019 00:12:16 +0100 Subject: STRICT_ADD, STRICT_SUB: Log error before abort --- src/nvim/assert.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/assert.h b/src/nvim/assert.h index f3a5c71341..db21bed0e2 100644 --- a/src/nvim/assert.h +++ b/src/nvim/assert.h @@ -137,7 +137,12 @@ /// Not used if compiler supports __builtin_add_overflow. #ifdef HAVE_BUILTIN_ADD_OVERFLOW # define STRICT_ADD(a, b, c, t) \ - do { if (__builtin_add_overflow(a, b, c)) { abort(); } } while (0) + do { \ + if (__builtin_add_overflow(a, b, c)) { \ + ELOG("STRICT_ADD overflow"); \ + abort(); \ + } \ + } while (0) #else # define STRICT_ADD(a, b, c, t) \ do { *(c) = (t)(a + b); } while (0) @@ -147,7 +152,12 @@ /// @brief Subtracts (a - b) and stores result in `c`. Aborts on overflow. #ifdef HAVE_BUILTIN_ADD_OVERFLOW # define STRICT_SUB(a, b, c, t) \ - do { if (__builtin_sub_overflow(a, b, c)) { abort(); } } while (0) + do { \ + if (__builtin_sub_overflow(a, b, c)) { \ + ELOG("STRICT_SUB overflow"); \ + abort(); \ + } \ + } while (0) #else # define STRICT_SUB(a, b, c, t) \ do { *(c) = (t)(a - b); } while (0) -- cgit