[libgsystem] Add gsystem-glib-compat.h to support compilation with GLib 2.32
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgsystem] Add gsystem-glib-compat.h to support compilation with GLib 2.32
- Date: Tue, 21 May 2013 15:06:53 +0000 (UTC)
commit 759384420c1578bf399473440ab34af18fa46b8d
Author: Colin Walters <walters verbum org>
Date: Tue May 21 06:56:20 2013 -0400
Add gsystem-glib-compat.h to support compilation with GLib 2.32
For NetworkManager.
gsystem-file-utils.c | 1 +
gsystem-glib-compat.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 54 insertions(+), 0 deletions(-)
---
diff --git a/gsystem-file-utils.c b/gsystem-file-utils.c
index a074a5d..9422f86 100644
--- a/gsystem-file-utils.c
+++ b/gsystem-file-utils.c
@@ -29,6 +29,7 @@
#define _GSYSTEM_NO_LOCAL_ALLOC
#include "libgsystem.h"
+#include "gsystem-glib-compat.h"
#include <glib/gstdio.h>
#include <gio/gunixinputstream.h>
#include <glib-unix.h>
diff --git a/gsystem-glib-compat.h b/gsystem-glib-compat.h
new file mode 100644
index 0000000..edbdaab
--- /dev/null
+++ b/gsystem-glib-compat.h
@@ -0,0 +1,53 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2012,2013 Colin Walters <walters verbum org>.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __LIBGSYSTEM_GLIB_COMPAT__
+#define __LIBGSYSTEM_GLIB_COMPAT__
+
+#include <gio/gio.h>
+
+#if !GLIB_CHECK_VERSION(2,34,0)
+static inline void
+g_type_ensure (GType type)
+{
+ if (G_UNLIKELY (type == (GType)-1))
+ g_error ("can't happen");
+}
+
+#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
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]