summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2014-11-11 09:41:15 +0100
committerJiří Klimeš <jklimes@redhat.com>2014-11-11 09:47:36 +0100
commit3e3bd1ee8bf7de93460fd5fa1e897b295f2899f8 (patch)
treef6266dafd31b7a52ad7a40b3885eb592ee26a0db
parent2c633a4f2619aef96042a85963b47b6a1ec745ee (diff)
downloadnetwork-manager-applet-3e3bd1ee8bf7de93460fd5fa1e897b295f2899f8.tar.gz
build: define g_clear_pointer() in the compatibility header nm-glib-compat.h
It is needed to be able to compile with glib 2.32 that does not contain the function.
-rw-r--r--src/connection-editor/page-general.c1
-rw-r--r--src/connection-editor/page-ip4.c1
-rw-r--r--src/connection-editor/page-ip6.c1
-rw-r--r--src/connection-editor/page-ppp.c1
-rw-r--r--src/connection-editor/page-vpn.c1
-rw-r--r--src/utils/nm-glib-compat.h28
6 files changed, 33 insertions, 0 deletions
diff --git a/src/connection-editor/page-general.c b/src/connection-editor/page-general.c
index 5cece094..37fb8c28 100644
--- a/src/connection-editor/page-general.c
+++ b/src/connection-editor/page-general.c
@@ -26,6 +26,7 @@
#include <nm-setting-connection.h>
#include "page-general.h"
+#include "nm-glib-compat.h"
G_DEFINE_TYPE (CEPageGeneral, ce_page_general, CE_TYPE_PAGE)
diff --git a/src/connection-editor/page-ip4.c b/src/connection-editor/page-ip4.c
index 2dbfaa32..5559e667 100644
--- a/src/connection-editor/page-ip4.c
+++ b/src/connection-editor/page-ip4.c
@@ -46,6 +46,7 @@
#include "page-ip4.h"
#include "ip4-routes-dialog.h"
#include "connection-helpers.h"
+#include "nm-glib-compat.h"
G_DEFINE_TYPE (CEPageIP4, ce_page_ip4, CE_TYPE_PAGE)
diff --git a/src/connection-editor/page-ip6.c b/src/connection-editor/page-ip6.c
index c5d96bc2..6aa55ccb 100644
--- a/src/connection-editor/page-ip6.c
+++ b/src/connection-editor/page-ip6.c
@@ -45,6 +45,7 @@
#include "page-ip6.h"
#include "ip6-routes-dialog.h"
+#include "nm-glib-compat.h"
G_DEFINE_TYPE (CEPageIP6, ce_page_ip6, CE_TYPE_PAGE)
diff --git a/src/connection-editor/page-ppp.c b/src/connection-editor/page-ppp.c
index 7e7c1aa4..472b0752 100644
--- a/src/connection-editor/page-ppp.c
+++ b/src/connection-editor/page-ppp.c
@@ -33,6 +33,7 @@
#include "page-ppp.h"
#include "ppp-auth-methods-dialog.h"
#include "nm-connection-editor.h"
+#include "nm-glib-compat.h"
G_DEFINE_TYPE (CEPagePpp, ce_page_ppp, CE_TYPE_PAGE)
diff --git a/src/connection-editor/page-vpn.c b/src/connection-editor/page-vpn.c
index 957f35d2..004a2604 100644
--- a/src/connection-editor/page-vpn.c
+++ b/src/connection-editor/page-vpn.c
@@ -38,6 +38,7 @@
#include "connection-helpers.h"
#include "nm-connection-editor.h"
#include "vpn-helpers.h"
+#include "nm-glib-compat.h"
G_DEFINE_TYPE (CEPageVpn, ce_page_vpn, CE_TYPE_PAGE)
diff --git a/src/utils/nm-glib-compat.h b/src/utils/nm-glib-compat.h
index d88d0ffd..18454c71 100644
--- a/src/utils/nm-glib-compat.h
+++ b/src/utils/nm-glib-compat.h
@@ -122,6 +122,34 @@
G_GNUC_END_IGNORE_DEPRECATIONS \
})
+
+/*************************************************************
+ * Define g_clear_pointer() if it doesn't exist (glib < 2.34)
+ *************************************************************/
+
+#if !GLIB_CHECK_VERSION(2,34,0)
+
+#define g_clear_pointer(pp, destroy) \
+ G_STMT_START { \
+ G_STATIC_ASSERT (sizeof *(pp) == sizeof (gpointer)); \
+ /* Only one access, please */ \
+ gpointer *_pp = (gpointer *) (pp); \
+ gpointer _p; \
+ /* This assignment is needed to avoid a gcc warning */ \
+ GDestroyNotify _destroy = (GDestroyNotify) (destroy); \
+ \
+ (void) (0 ? (gpointer) *(pp) : 0); \
+ do \
+ _p = g_atomic_pointer_get (_pp); \
+ while G_UNLIKELY (!g_atomic_pointer_compare_and_exchange (_pp, _p, NULL)); \
+ \
+ if (_p) \
+ _destroy (_p); \
+ } G_STMT_END
+
+#endif
+
+
/*************************************************************/