summaryrefslogtreecommitdiff
path: root/shared/nm-glib.h
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2016-02-11 12:39:42 -0600
committerDan Williams <dcbw@redhat.com>2016-02-11 12:40:18 -0600
commit1fd91056d4a0ed5ab8b52be0917b4301d740e059 (patch)
treecf701c48322cfe6c693a159733f09259e697a64d /shared/nm-glib.h
parentdc394a6537c60991bc50e57144b7d08d73d04777 (diff)
downloadNetworkManager-1fd91056d4a0ed5ab8b52be0917b4301d740e059.tar.gz
build: define g_assert_cmpmem() for glib < 2.46
Fixes: b73c0e2f6ddf1d5d25efca3b2910d53848055701
Diffstat (limited to 'shared/nm-glib.h')
-rw-r--r--shared/nm-glib.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/shared/nm-glib.h b/shared/nm-glib.h
index c75e91ba51..201b6d33bb 100644
--- a/shared/nm-glib.h
+++ b/shared/nm-glib.h
@@ -116,6 +116,20 @@ __g_type_ensure (GType type)
#define g_test_initialized() (g_test_config_vars->test_initialized)
#endif
+/* g_assert_cmpmem() is only available since glib 2.46. */
+#if !GLIB_CHECK_VERSION (2, 45, 7)
+#define g_assert_cmpmem(m1, l1, m2, l2) G_STMT_START {\
+ gconstpointer __m1 = m1, __m2 = m2; \
+ int __l1 = l1, __l2 = l2; \
+ if (__l1 != __l2) \
+ g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
+ #l1 " (len(" #m1 ")) == " #l2 " (len(" #m2 "))", __l1, "==", __l2, 'i'); \
+ else if (memcmp (__m1, __m2, __l1) != 0) \
+ g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
+ "assertion failed (" #m1 " == " #m2 ")"); \
+ } G_STMT_END
+#endif
+
/* Rumtime check for glib version. First do a compile time check which
* (if satisfied) shortcuts the runtime check. */
#define nm_glib_check_version(major, minor, micro) \