---
 libvirt-gobject/Makefile.am              |    1 +
 libvirt-gobject/libvirt-gobject-compat.h |   72 ++++++++++++++++++++++++++++++
 2 files changed, 73 insertions(+), 0 deletions(-)
 create mode 100644 libvirt-gobject/libvirt-gobject-compat.h

diff --git a/libvirt-gobject/Makefile.am b/libvirt-gobject/Makefile.am
index 101007e..d975701 100644
--- a/libvirt-gobject/Makefile.am
+++ b/libvirt-gobject/Makefile.am
@@ -48,6 +48,7 @@ libvirt_gobject_1_0_la_HEADERS = \
                        $(GOBJECT_HEADER_FILES) \
                        libvirt-gobject-input-stream.h
 nodist_libvirt_gobject_1_0_la_HEADERS = \
+                       libvirt-gobject-compat.h \
                        libvirt-gobject-domain-device-private.h \
                        libvirt-gobject-enums.h
 libvirt_gobject_1_0_la_SOURCES = \
diff --git a/libvirt-gobject/libvirt-gobject-compat.h 
b/libvirt-gobject/libvirt-gobject-compat.h
new file mode 100644
index 0000000..7b4be45
--- /dev/null
+++ b/libvirt-gobject/libvirt-gobject-compat.h
@@ -0,0 +1,72 @@
+/*
+ * libvirt-gobject-compat.h: libvirt gobject integration
+ *
+ * Copyright (C) 2011 Red Hat
+ *
+ * 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.1 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
+ *
+ * Author: Marc-André Lureau <marcandre.lur...@redhat.com>
+ */
+
+#ifndef __LIBVIRT_GOBJECT_COMPAT_H__
+#define __LIBVIRT_GOBJECT_COMPAT_H__
+
+#include <glib-object.h>
+
+#if !GLIB_CHECK_VERSION(2,26,0)
+#define G_DEFINE_BOXED_TYPE(TypeName, type_name, copy_func, free_func) 
G_DEFINE_BOXED_TYPE_WITH_CODE (TypeName, type_name, copy_func, free_func, {})
+#define G_DEFINE_BOXED_TYPE_WITH_CODE(TypeName, type_name, copy_func, 
free_func, _C_) _G_DEFINE_BOXED_TYPE_BEGIN (TypeName, type_name, copy_func, 
free_func) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+#define _G_DEFINE_BOXED_TYPE_BEGIN(TypeName, type_name, copy_func, free_func) \
+GType \
+type_name##_get_type (void) \
+{ \
+  static volatile gsize g_define_type_id__volatile = 0; \
+  if (g_once_init_enter (&g_define_type_id__volatile))  \
+    { \
+      GType (* _g_register_boxed) \
+        (const gchar *, \
+         union \
+           { \
+             TypeName * (*do_copy_type) (TypeName *); \
+             TypeName * (*do_const_copy_type) (const TypeName *); \
+             GBoxedCopyFunc do_copy_boxed; \
+           } __attribute__((__transparent_union__)), \
+         union \
+           { \
+             void (* do_free_type) (TypeName *); \
+             GBoxedFreeFunc do_free_boxed; \
+           } __attribute__((__transparent_union__)) \
+        ) = g_boxed_type_register_static; \
+      GType g_define_type_id = \
+        _g_register_boxed (g_intern_static_string (#TypeName), copy_func, 
free_func); \
+      { /* custom code follows */
+#else
+#define _G_DEFINE_BOXED_TYPE_BEGIN(TypeName, type_name, copy_func, free_func) \
+GType \
+type_name##_get_type (void) \
+{ \
+  static volatile gsize g_define_type_id__volatile = 0; \
+  if (g_once_init_enter (&g_define_type_id__volatile))  \
+    { \
+      GType g_define_type_id = \
+        g_boxed_type_register_static (g_intern_static_string (#TypeName), \
+                                      (GBoxedCopyFunc) copy_func, \
+                                      (GBoxedFreeFunc) free_func); \
+      { /* custom code follows */
+#endif /* __GNUC__ */
+#endif /* glib 2.26 */
+
+#endif /* __LIBVIRT_GOBJECT_COMPAT_H__ */
-- 
1.7.7

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to