about summary refs log tree commit diff
path: root/shared/nm-default.h
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2016-08-26 02:18:32 +0200
committerMichael Biebl <biebl@debian.org>2016-08-26 02:18:32 +0200
commit7514efc2f38c9ace4557d4e69d68e7d380389030 (patch)
tree7fb00fda86cfcc2ca377f191633a7cfdbfea7ca3 /shared/nm-default.h
parentd6201f5d8daada3d64a0a3e0038e14eebec683ce (diff)
Imported Upstream version 1.4.0 upstream/1.4.0
Diffstat (limited to 'shared/nm-default.h')
-rw-r--r--shared/nm-default.h75
1 files changed, 71 insertions, 4 deletions
diff --git a/shared/nm-default.h b/shared/nm-default.h
index aeb977a9..e3e3ea44 100644
--- a/shared/nm-default.h
+++ b/shared/nm-default.h
@@ -53,12 +53,79 @@
 #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)
+
+#undef g_return_val_if_reached
+#define g_return_val_if_reached(val) \
+    G_STMT_START { \
+        g_log (G_LOG_DOMAIN, \
+               G_LOG_LEVEL_CRITICAL, \
+               "file %s: line %d (%s): should not be reached", \
+               __FILE__, \
+               __LINE__, \
+               "<dropped>"); \
+        return (val); \
+    } G_STMT_END
+
+#undef g_return_if_reached
+#define g_return_if_reached() \
+    G_STMT_START { \
+        g_log (G_LOG_DOMAIN, \
+               G_LOG_LEVEL_CRITICAL, \
+               "file %s: line %d (%s): should not be reached", \
+               __FILE__, \
+               __LINE__, \
+               "<dropped>"); \
+        return; \
+    } G_STMT_END
+
+#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-utils/nm-macros-internal.h"
+#include "nm-utils/nm-shared-utils.h"
 
-#include "nm-glib.h"
 #include "nm-version.h"
-#include "gsystem-local-alloc.h"
-#include "nm-macros-internal.h"
-#include "nm-shared-utils.h"
 
 /*****************************************************************************/