summaryrefslogtreecommitdiff
path: root/shared/nm-macros-internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'shared/nm-macros-internal.h')
-rw-r--r--shared/nm-macros-internal.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/shared/nm-macros-internal.h b/shared/nm-macros-internal.h
index e584b9d031..7a5c90fc53 100644
--- a/shared/nm-macros-internal.h
+++ b/shared/nm-macros-internal.h
@@ -27,6 +27,9 @@
/********************************************************/
#define _nm_packed __attribute__ ((packed))
+#define _nm_unused __attribute__ ((unused))
+#define _nm_pure __attribute__ ((pure))
+#define _nm_const __attribute__ ((const))
#define nm_auto(fcn) __attribute__ ((cleanup(fcn)))
@@ -296,6 +299,22 @@ _NM_IN_STRSET_streq (const char *x, const char *s)
/*****************************************************************************/
+/* glib/C provides the following kind of assertions:
+ * - assert() -- disable with NDEBUG
+ * - g_return_if_fail() -- disable with G_DISABLE_CHECKS
+ * - g_assert() -- disable with G_DISABLE_ASSERT
+ * but they are all enabled by default and usually even production builds have
+ * these kind of assertions enabled. It also means, that disabling assertions
+ * is an untested configuration, and might have bugs.
+ *
+ * Add our own assertion macro nm_assert(), which is disabled by default and must
+ * be explicitly enabled. They are useful for more expensive checks or checks that
+ * depend less on runtime conditions (that is, are generally expected to be true). */
+
+#ifndef NM_MORE_ASSERTS
+#define NM_MORE_ASSERTS 0
+#endif
+
#if NM_MORE_ASSERTS
#define nm_assert(cond) G_STMT_START { g_assert (cond); } G_STMT_END
#define nm_assert_not_reached() G_STMT_START { g_assert_not_reached (); } G_STMT_END