Lower our glib requirement to 2.22, as we claim

Required to build on RHEL, even upcoming 6.3
This commit is contained in:
Marc-André Lureau 2012-01-12 13:41:09 +01:00
parent 6f37c55b5b
commit 2c61fd3d80
8 changed files with 99 additions and 0 deletions

View File

@ -185,6 +185,7 @@ USB_ACL_HELPER_SRCS =
endif
libspice_client_glib_2_0_la_SOURCES = \
glib-compat.c \
glib-compat.h \
spice-audio.c \
spice-audio-priv.h \
@ -366,6 +367,8 @@ spicy_CPPFLAGS = \
if WITH_POLKIT
spice_client_glib_usb_acl_helper_SOURCES = \
glib-compat.c \
glib-compat.h \
spice-client-glib-usb-acl-helper.c \
$(NULL)

View File

@ -34,6 +34,7 @@
#include "spice-common.h"
#include "spice-channel-priv.h"
#include "glib-compat.h"
/**
* SECTION:channel-usbredir

49
gtk/glib-compat.c Normal file
View File

@ -0,0 +1,49 @@
/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
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, see <http://www.gnu.org/licenses/>.
*/
#include "glib-compat.h"
#if !GLIB_CHECK_VERSION(2,26,0)
G_DEFINE_BOXED_TYPE (GError, spice_error, g_error_copy, g_error_free)
#endif
#if !GLIB_CHECK_VERSION(2,28,0)
/**
* spice_simple_async_result_take_error: (skip)
* @simple: a #GSimpleAsyncResult
* @error: a #GError
*
* Sets the result from @error, and takes over the caller's ownership
* of @error, so the caller does not need to free it any more.
*
* Since: 2.28
**/
G_GNUC_INTERNAL void
g_simple_async_result_take_error (GSimpleAsyncResult *simple,
GError *error)
{
/* this code is different from upstream */
/* we can't avoid extra copy/free, since the simple struct is
opaque */
g_simple_async_result_set_from_error (simple, error);
g_error_free (error);
}
#endif
#if !GLIB_CHECK_VERSION(2,30,0)
G_DEFINE_BOXED_TYPE (GMainContext, spice_main_context, g_main_context_ref, g_main_context_unref)
#endif

View File

@ -17,6 +17,7 @@
#define GLIB_COMPAT_H
#include <glib-object.h>
#include <gio/gio.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, {})
@ -60,8 +61,47 @@ type_name##_get_type (void) \
(GBoxedFreeFunc) free_func); \
{ /* custom code follows */
#endif /* __GNUC__ */
#define g_source_set_name(source, name) G_STMT_START { } G_STMT_END
#define G_TYPE_ERROR (spice_error_get_type ())
GType spice_error_get_type (void) G_GNUC_CONST;
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
#define G_GNUC_DEPRECATED_FOR(f) \
__attribute__((deprecated("Use " #f " instead")))
#else
#define G_GNUC_DEPRECATED_FOR(f) G_GNUC_DEPRECATED
#endif /* __GNUC__ */
#define G_PARAM_DEPRECATED (1 << 31)
#endif /* glib 2.26 */
#if !GLIB_CHECK_VERSION(2,28,0)
#define g_clear_object(object_ptr) \
G_STMT_START { \
/* Only one access, please */ \
gpointer *_p = (gpointer) (object_ptr); \
gpointer _o; \
\
do \
_o = g_atomic_pointer_get (_p); \
while G_UNLIKELY (!g_atomic_pointer_compare_and_exchange (_p, _o, NULL));\
\
if (_o) \
g_object_unref (_o); \
} G_STMT_END
void
g_simple_async_result_take_error(GSimpleAsyncResult *simple,
GError *error);
#endif /* glib 2.28 */
#if !GLIB_CHECK_VERSION(2,30,0)
#define G_TYPE_MAIN_CONTEXT (spice_main_context_get_type ())
GType spice_main_context_get_type (void) G_GNUC_CONST;
#endif
#if !GLIB_CHECK_VERSION(2,32,0)
# define G_SIGNAL_DEPRECATED (1 << 9)
#endif

View File

@ -51,6 +51,8 @@
#include "spice-gstaudio.h"
#endif
#include "glib-compat.h"
#define SPICE_AUDIO_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), SPICE_TYPE_AUDIO, SpiceAudioPrivate))

View File

@ -33,6 +33,8 @@
#include <polkit/polkit.h>
#include <acl/libacl.h>
#include "glib-compat.h"
#define FATAL_ERROR(...) \
do { \
/* We print the error both to stdout, for the app invoking us and \

View File

@ -28,6 +28,7 @@
#include "ring.h"
#include "gio-coroutine.h"
#include "glib-compat.h"
struct channel {
SpiceChannel *channel;

View File

@ -26,6 +26,7 @@
#include <string.h>
#include "usb-acl-helper.h"
#include "glib-compat.h"
/* ------------------------------------------------------------------ */
/* gobject glue */