aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil
diff options
context:
space:
mode:
authorJoão Valverde <j@v6e.pt>2023-01-09 12:58:45 +0000
committerJoão Valverde <j@v6e.pt>2023-01-12 00:59:15 +0000
commit4c9b0d846c588f0303ea4e55353a0d1970e6a0a9 (patch)
treed878c68d015fa0e887baba2d5a08b62d3352652f /wsutil
parent25d4a099f7c5578d1d43f66f8e9ea567f698cc4b (diff)
CMake: Reverse debug macros
Originally WS_DISABLE_DEBUG was chosen to be similar to G_DISABLE_ASSERT and NDEBUG. However generator expressions are essential for modern CMake but the syntax is weird and having to use negations makes it ten-fold worse. Remove the negation. Instead of changing the CMake variable reverse the macro definition for WS_DISABLE_DEBUG. The $<CONFIG:cgs> generator expression with multiple config arguments requires CMake >= 3.19 so we can't use that yet for a further syntactical simplification.
Diffstat (limited to 'wsutil')
-rw-r--r--wsutil/wmem/wmem-int.h6
-rw-r--r--wsutil/ws_assert.h16
-rw-r--r--wsutil/wslog.h8
3 files changed, 15 insertions, 15 deletions
diff --git a/wsutil/wmem/wmem-int.h b/wsutil/wmem/wmem-int.h
index 4cc14106ba..8102742d0c 100644
--- a/wsutil/wmem/wmem-int.h
+++ b/wsutil/wmem/wmem-int.h
@@ -15,10 +15,10 @@
#include <glib.h>
-#ifdef WS_DISABLE_DEBUG
-#define ASSERT(...) (void)0
-#else
+#ifdef WS_DEBUG
#define ASSERT(...) g_assert(__VA_ARGS__)
+#else
+#define ASSERT(...) (void)0
#endif /* WS_DISABLE_DEBUG */
#endif /* __WMEM_INT_H__ */
diff --git a/wsutil/ws_assert.h b/wsutil/ws_assert.h
index 3b394e0616..e85c27dc46 100644
--- a/wsutil/ws_assert.h
+++ b/wsutil/ws_assert.h
@@ -16,10 +16,10 @@
#include <string.h>
#include <wsutil/wslog.h>
-#ifdef WS_DISABLE_DEBUG
-#define _ASSERT_ENABLED false
-#else
+#ifdef WS_DEBUG
#define _ASSERT_ENABLED true
+#else
+#define _ASSERT_ENABLED false
#endif
#ifdef __cplusplus
@@ -27,9 +27,9 @@ extern "C" {
#endif /* __cplusplus */
/*
- * We don't want to execute the expression with WS_DISABLE_DEBUG because
+ * We don't want to execute the expression with !WS_DEBUG because
* it might be time and space costly and the goal here is to optimize for
- * WS_DISABLE_DEBUG. However removing it completely is not good enough
+ * !WS_DEBUG. However removing it completely is not good enough
* because it might generate many unused variable warnings. So we use
* if (false) and let the compiler optimize away the dead execution branch.
*/
@@ -40,7 +40,7 @@ extern "C" {
} while (0)
/*
- * ws_abort_if_fail() is not conditional on WS_DISABLE_DEBUG.
+ * ws_abort_if_fail() is not conditional on WS_DEBUG.
* Usually used to appease a static analyzer.
*/
#define ws_abort_if_fail(expr) \
@@ -48,7 +48,7 @@ extern "C" {
/*
* ws_assert() cannot produce side effects, otherwise code will
- * behave differently because of WS_DISABLE_DEBUG, and probably introduce
+ * behave differently because of WS_DEBUG, and probably introduce
* some difficult to track bugs.
*/
#define ws_assert(expr) \
@@ -70,7 +70,7 @@ extern "C" {
} while (0)
/*
- * We don't want to disable ws_assert_not_reached() with WS_DISABLE_DEBUG.
+ * We don't want to disable ws_assert_not_reached() with WS_DEBUG.
* That would blast compiler warnings everywhere for no benefit, not
* even a miniscule performance gain. Reaching this function is always
* a programming error and will unconditionally abort execution.
diff --git a/wsutil/wslog.h b/wsutil/wslog.h
index 0f23ade4c6..74a88a9b15 100644
--- a/wsutil/wslog.h
+++ b/wsutil/wslog.h
@@ -30,10 +30,10 @@
#define _LOG_DOMAIN ""
#endif
-#ifdef WS_DISABLE_DEBUG
-#define _LOG_DEBUG_ENABLED false
-#else
+#ifdef WS_DEBUG
#define _LOG_DEBUG_ENABLED true
+#else
+#define _LOG_DEBUG_ENABLED false
#endif
/*
@@ -308,7 +308,7 @@ void ws_log_fatal_full(const char *domain, enum ws_log_level level,
/*
* The if condition avoids -Wunused warnings for variables used only with
- * !WS_DISABLE_DEBUG, typically inside a ws_debug() call. The compiler will
+ * WS_DEBUG, typically inside a ws_debug() call. The compiler will
* optimize away the dead execution branch.
*/
#define _LOG_IF_ACTIVE(active, level, file, line, func, ...) \