summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-11-12 10:54:37 +0100
committerThomas Haller <thaller@redhat.com>2014-11-12 11:11:41 +0100
commitdcb25a37a599c2f269228bc0060d2284a8d511ff (patch)
tree9d69dc7ad325ca80d493f4f50623202a0fcb46a3
parent12f2f09e5535ffc30cc5baeac186999269a3137e (diff)
downloadNetworkManager-dcb25a37a599c2f269228bc0060d2284a8d511ff.tar.gz
glib-compat: sync local definition of g_clear_pointer() with upstream glib and remove atomic operations
Upstream glib changed g_clear_pointer() not to use atomic functions. Update or local definition to b1dd594a22e3499caafdeccd7fa223a032b9e177 glib/gmem.h (glib 2.41.3). (fixup whitespace to match our style). See also the related bug https://bugzilla.gnome.org/show_bug.cgi?id=733969 from glib. Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--include/nm-glib-compat.h33
1 files changed, 16 insertions, 17 deletions
diff --git a/include/nm-glib-compat.h b/include/nm-glib-compat.h
index 7a9bb3160a..1dc939feac 100644
--- a/include/nm-glib-compat.h
+++ b/include/nm-glib-compat.h
@@ -59,23 +59,22 @@ __g_type_ensure (GType type)
#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
+#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); \
+ \
+ _p = *_pp; \
+ if (_p) \
+ { \
+ *_pp = NULL; \
+ _destroy (_p); \
+ } \
+ } G_STMT_END
/* These are used to clean up the output of test programs; we can just let
* them no-op in older glib.