summaryrefslogtreecommitdiff
path: root/shared/nm-default.h
diff options
context:
space:
mode:
Diffstat (limited to 'shared/nm-default.h')
-rw-r--r--shared/nm-default.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/shared/nm-default.h b/shared/nm-default.h
index aeb977a935..5d7c8f141c 100644
--- a/shared/nm-default.h
+++ b/shared/nm-default.h
@@ -53,6 +53,50 @@
#define NM_VERSION_MIN_REQUIRED NM_VERSION_0_9_8
#include <stdlib.h>
+#include <glib.h>
+
+/*****************************************************************************/
+
+#ifndef NM_MORE_ASSERTS
+#define NM_MORE_ASSERTS 0
+#endif
+
+#if NM_MORE_ASSERTS == 0
+
+/* glib assertions (g_return_*(), g_assert*()) contain a textual representation
+ * of the checked statement. This part of the assertion blows up the size of the
+ * binary. Unless we compile a debug-build with NM_MORE_ASSERTS, drop these
+ * parts. Note that the failed assertion still prints the file and line where the
+ * assertion fails. That shall suffice. */
+
+static inline void
+_nm_g_return_if_fail_warning (const char *log_domain,
+ const char *file,
+ int line)
+{
+ char file_buf[256 + 15];
+
+ g_snprintf (file_buf, sizeof (file_buf), "((%s:%d))", file, line);
+ g_return_if_fail_warning (log_domain, file_buf, "<dropped>");
+}
+
+#define g_return_if_fail_warning(log_domain, pretty_function, expression) \
+ _nm_g_return_if_fail_warning (log_domain, __FILE__, __LINE__)
+
+#define g_assertion_message_expr(domain, file, line, func, expr) \
+ g_assertion_message_expr(domain, file, line, "<unknown-fcn>", (expr) ? "<dropped>" : NULL)
+
+#define NM_ASSERT_G_RETURN_EXPR(expr) "<dropped>"
+#define NM_ASSERT_NO_MSG 1
+
+#else
+
+#define NM_ASSERT_G_RETURN_EXPR(expr) ""expr""
+#define NM_ASSERT_NO_MSG 0
+
+#endif
+
+/*****************************************************************************/
#include "nm-glib.h"
#include "nm-version.h"