Adjust to GLib 2.36

Dependency since 8693e7d3f7

Remove glib-compat files and most of GLIB_CHECK_VERSION guards

Acked-by: Victor Toso <victortoso@redhat.com>
This commit is contained in:
Pavel Grunt 2016-03-17 11:19:35 +01:00
parent 23cd3e6041
commit 0a9ec4ec01
38 changed files with 1 additions and 268 deletions

View File

@ -32,7 +32,6 @@ IGNORE_HFILES= \
decode.h \
display \
gio-coroutine.h \
glib-compat.h \
smartcard-manager-priv.h \
spice-audio-priv.h \
spice-channel-cache.h \

View File

@ -1,3 +1,2 @@
spice-common/python_modules/spice_parser.py
spice-common/spice_codegen.py
src/glib-compat.c

View File

@ -122,7 +122,6 @@ SPICE_GTK_LIBADD_COMMON = \
$(NULL)
SPICE_GTK_SOURCES_COMMON = \
glib-compat.h \
gtk-compat.h \
spice-util.c \
spice-util-priv.h \
@ -214,8 +213,6 @@ endif
libspice_client_glib_2_0_la_SOURCES = \
bio-gio.c \
bio-gio.h \
glib-compat.c \
glib-compat.h \
spice-audio.c \
spice-audio-priv.h \
spice-common.h \
@ -389,8 +386,6 @@ 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

@ -17,7 +17,6 @@
*/
#include "config.h"
#include "glib-compat.h"
#include "spice-client.h"
#include "spice-common.h"

View File

@ -21,7 +21,6 @@
#include <sys/types.h>
#endif
#include "glib-compat.h"
#include "spice-client.h"
#include "spice-common.h"

View File

@ -21,7 +21,6 @@
#include <spice/vd_agent.h>
#include <glib/gstdio.h>
#include "glib-compat.h"
#include "spice-client.h"
#include "spice-common.h"
#include "spice-marshal.h"

View File

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

View File

@ -36,7 +36,6 @@
#include "spice-common.h"
#include "spice-channel-priv.h"
#include "glib-compat.h"
/**
* SECTION:channel-usbredir
@ -559,16 +558,12 @@ static int usbredir_write_callback(void *user_data, uint8_t *data, int count)
}
static void *usbredir_alloc_lock(void) {
#if GLIB_CHECK_VERSION(2,32,0)
GMutex *mutex;
mutex = g_new0(GMutex, 1);
g_mutex_init(mutex);
return mutex;
#else
return g_mutex_new();
#endif
}
static void usbredir_lock_lock(void *user_data) {
@ -586,12 +581,8 @@ static void usbredir_unlock_lock(void *user_data) {
static void usbredir_free_lock(void *user_data) {
GMutex *mutex = user_data;
#if GLIB_CHECK_VERSION(2,32,0)
g_mutex_clear(mutex);
g_free(mutex);
#else
g_mutex_free(mutex);
#endif
}
/* --------------------------------------------------------------------- */

View File

@ -22,7 +22,6 @@
#include "spice-channel-priv.h"
#include "spice-session-priv.h"
#include "spice-marshal.h"
#include "glib-compat.h"
#include "vmcstream.h"
#include "giopipe.h"

View File

@ -88,9 +88,6 @@ void connect_signals (gpointer obj)
int main (int argc, char *argv[])
{
#if !GLIB_CHECK_VERSION(2,36,0)
g_type_init ();
#endif
loop = g_main_loop_new (NULL, FALSE);
if (argc > 1 && g_str_equal(argv[1], "--menu")) {

View File

@ -212,9 +212,6 @@ int main (int argc, char *argv[])
ControllerValue msg;
ssize_t read;
#if !GLIB_CHECK_VERSION(2,36,0)
g_type_init ();
#endif
ctrl = spice_ctrl_controller_new ();
loop = g_main_loop_new (NULL, FALSE);
g_signal_connect (ctrl, "notify", G_CALLBACK (notified), NULL);

View File

@ -23,7 +23,6 @@
#include <glib-object.h>
#include "glib-compat.h"
#include "spice-session-priv.h"
#include "desktop-integration.h"

View File

@ -1,112 +0,0 @@
/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
Copyright (C) 2012-2014 Red Hat, Inc.
Copyright © 1998-2009 VLC authors and VideoLAN
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 "config.h"
#include <string.h>
#include <glib/gi18n.h>
#include "glib-compat.h"
#if !GLIB_CHECK_VERSION(2,30,0)
G_DEFINE_BOXED_TYPE (GMainContext, spice_main_context, g_main_context_ref, g_main_context_unref)
#define KILOBYTE_FACTOR (G_GOFFSET_CONSTANT (1000))
#define MEGABYTE_FACTOR (KILOBYTE_FACTOR * KILOBYTE_FACTOR)
#define GIGABYTE_FACTOR (MEGABYTE_FACTOR * KILOBYTE_FACTOR)
#define TERABYTE_FACTOR (GIGABYTE_FACTOR * KILOBYTE_FACTOR)
#define PETABYTE_FACTOR (TERABYTE_FACTOR * KILOBYTE_FACTOR)
#define EXABYTE_FACTOR (PETABYTE_FACTOR * KILOBYTE_FACTOR)
/**
* g_format_size:
* @size: a size in bytes
*
* Formats a size (for example the size of a file) into a human readable
* string. Sizes are rounded to the nearest size prefix (kB, MB, GB)
* and are displayed rounded to the nearest tenth. E.g. the file size
* 3292528 bytes will be converted into the string "3.2 MB".
*
* The prefix units base is 1000 (i.e. 1 kB is 1000 bytes).
*
* This string should be freed with g_free() when not needed any longer.
*
* See g_format_size_full() for more options about how the size might be
* formatted.
*
* Returns: a newly-allocated formatted string containing a human readable
* file size
*
* Since: 2.30
*/
gchar *
g_format_size (guint64 size)
{
GString *string;
string = g_string_new (NULL);
if (size < KILOBYTE_FACTOR)
{
g_string_printf (string,
g_dngettext(GETTEXT_PACKAGE, "%u byte", "%u bytes", (guint) size),
(guint) size);
}
else if (size < MEGABYTE_FACTOR)
g_string_printf (string, _("%.1f kB"), (gdouble) size / (gdouble) KILOBYTE_FACTOR);
else if (size < GIGABYTE_FACTOR)
g_string_printf (string, _("%.1f MB"), (gdouble) size / (gdouble) MEGABYTE_FACTOR);
else if (size < TERABYTE_FACTOR)
g_string_printf (string, _("%.1f GB"), (gdouble) size / (gdouble) GIGABYTE_FACTOR);
else if (size < PETABYTE_FACTOR)
g_string_printf (string, _("%.1f TB"), (gdouble) size / (gdouble) TERABYTE_FACTOR);
else if (size < EXABYTE_FACTOR)
g_string_printf (string, _("%.1f PB"), (gdouble) size / (gdouble) PETABYTE_FACTOR);
else
g_string_printf (string, _("%.1f EB"), (gdouble) size / (gdouble) EXABYTE_FACTOR);
return g_string_free (string, FALSE);
}
#endif
#if !GLIB_CHECK_VERSION(2,32,0)
/**
* g_queue_free_full:
* @queue: a pointer to a #GQueue
* @free_func: the function to be called to free each element's data
*
* Convenience method, which frees all the memory used by a #GQueue,
* and calls the specified destroy function on every element's data.
*
* Since: 2.32
*/
void
g_queue_free_full (GQueue *queue,
GDestroyNotify free_func)
{
g_queue_foreach (queue, (GFunc) free_func, NULL);
g_queue_free (queue);
}
#endif

View File

@ -1,65 +0,0 @@
/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
Copyright (C) 2012-2014 Red Hat, Inc.
Copyright © 1998-2009 VLC authors and VideoLAN
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/>.
*/
#ifndef GLIB_COMPAT_H
#define GLIB_COMPAT_H
#include "config.h"
#include <glib-object.h>
#include <gio/gio.h>
#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;
gchar *g_format_size (guint64 size);
#endif
#if !GLIB_CHECK_VERSION(2,32,0)
# define G_SIGNAL_DEPRECATED (1 << 9)
#define G_SOURCE_CONTINUE TRUE
#define G_SOURCE_REMOVE FALSE
void
g_queue_free_full (GQueue *queue,
GDestroyNotify free_func);
#endif
#ifndef g_clear_pointer
#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
#endif /* GLIB_COMPAT_H */

View File

@ -20,8 +20,6 @@
#include <glib-object.h>
#include <string.h>
#include "glib-compat.h"
#ifdef USE_SMARTCARD_012
#include <vcard_emul.h>
#include <vevent.h>

View File

@ -49,8 +49,6 @@
#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

@ -19,7 +19,6 @@
#include "spice-client.h"
#include "spice-common.h"
#include "glib-compat.h"
#include "spice-channel-priv.h"
#include "spice-session-priv.h"

View File

@ -34,8 +34,6 @@
#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 \
@ -335,10 +333,6 @@ int main(void)
return 1;
}
#if !GLIB_CHECK_VERSION(2,36,0)
g_type_init();
#endif
loop = g_main_loop_new(NULL, FALSE);
authority = polkit_authority_get_sync(NULL, NULL);

View File

@ -20,7 +20,6 @@
#include <stdlib.h>
#include <glib-object.h>
#include <glib/gi18n.h>
#include "glib-compat.h"
#include "spice-session.h"
#include "spice-util.h"
#include "spice-channel-priv.h"

View File

@ -22,7 +22,6 @@
#include "spice-session-priv.h"
#include "spice-channel-priv.h"
#include "spice-util-priv.h"
#include "glib-compat.h"
#include <pulse/glib-mainloop.h>
#include <pulse/pulseaudio.h>

View File

@ -30,7 +30,6 @@
#include "spice-util-priv.h"
#include "spice-session-priv.h"
#include "gio-coroutine.h"
#include "glib-compat.h"
#include "wocky-http-proxy.h"
#include "spice-uri-priv.h"
#include "channel-playback-priv.h"

View File

@ -20,7 +20,6 @@
#include <stdlib.h>
#include <string.h>
#include "glib-compat.h"
#include "spice-client.h"
#include "spice-uri.h"

View File

@ -33,19 +33,11 @@ gchar* spice_dos2unix(const gchar *str, gssize len, GError **error);
void spice_mono_edge_highlight(unsigned width, unsigned hight,
const guint8 *and, const guint8 *xor, guint8 *dest);
#if GLIB_CHECK_VERSION(2,32,0)
#define STATIC_MUTEX GMutex
#define STATIC_MUTEX_INIT(m) g_mutex_init(&(m))
#define STATIC_MUTEX_CLEAR(m) g_mutex_clear(&(m))
#define STATIC_MUTEX_LOCK(m) g_mutex_lock(&(m))
#define STATIC_MUTEX_UNLOCK(m) g_mutex_unlock(&(m))
#else
#define STATIC_MUTEX GStaticMutex
#define STATIC_MUTEX_INIT(m) g_static_mutex_init(&(m))
#define STATIC_MUTEX_CLEAR(m) g_static_mutex_free(&(m))
#define STATIC_MUTEX_LOCK(m) g_static_mutex_lock(&(m))
#define STATIC_MUTEX_UNLOCK(m) g_static_mutex_unlock(&(m))
#endif
G_END_DECLS

View File

@ -42,7 +42,6 @@ static GOnce debug_once = G_ONCE_INIT;
static void spice_util_enable_debug_messages(void)
{
#if GLIB_CHECK_VERSION(2, 31, 0)
const gchar *doms = g_getenv("G_MESSAGES_DEBUG");
if (!doms) {
g_setenv("G_MESSAGES_DEBUG", G_LOG_DOMAIN, 1);
@ -53,7 +52,6 @@ static void spice_util_enable_debug_messages(void)
g_setenv("G_MESSAGES_DEBUG", newdoms, 1);
g_free(newdoms);
}
#endif
}
/**

View File

@ -40,7 +40,7 @@ gchar* spice_uuid_to_string(const guint8 uuid[16]);
#define SPICE_RESERVED_PADDING (10 * sizeof(void*))
/* need to be in a public header, glib-compat.h is private */
/* need to be in a public header */
#ifndef SPICE_GNUC_DEPRECATED_FOR
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
#define SPICE_GNUC_DEPRECATED_FOR(f) \

View File

@ -42,7 +42,6 @@
#include "vncdisplaykeymap.h"
#include "spice-grabsequence-priv.h"
#include "glib-compat.h"
#include "gtk-compat.h"
/* Some compatibility defines to let us build on both Gtk2 and Gtk3 */

View File

@ -177,9 +177,6 @@ int main(int argc, char *argv[])
exit(0);
}
#if !GLIB_CHECK_VERSION(2,36,0)
g_type_init();
#endif
mainloop = g_main_loop_new(NULL, false);
session = spice_session_new();

View File

@ -103,9 +103,6 @@ int main(int argc, char *argv[])
exit(0);
}
#if !GLIB_CHECK_VERSION(2,36,0)
g_type_init();
#endif
mainloop = g_main_loop_new(NULL, false);
session = spice_session_new();

View File

@ -28,7 +28,6 @@
#include <vreader.h>
#endif
#include "glib-compat.h"
#include "spice-widget.h"
#include "spice-gtk-session.h"
#include "spice-audio.h"
@ -1848,9 +1847,6 @@ int main(int argc, char *argv[])
gchar *conf_file, *conf;
char *host = NULL, *port = NULL, *tls_port = NULL, *unix_path = NULL;
#if !GLIB_CHECK_VERSION(2,31,18)
g_thread_init(NULL);
#endif
keyfile = g_key_file_new();
int mode = S_IRWXU;
@ -1886,9 +1882,6 @@ int main(int argc, char *argv[])
exit(0);
}
#if !GLIB_CHECK_VERSION(2,36,0)
g_type_init();
#endif
mainloop = g_main_loop_new(NULL, false);
conn = connection_new();

View File

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

View File

@ -23,8 +23,6 @@
#include <glib-object.h>
#include "glib-compat.h"
#ifdef USE_USBREDIR
#include <errno.h>
#include <libusb.h>
@ -1234,14 +1232,9 @@ gboolean spice_usb_device_manager_start_event_listening(
priv->event_thread = NULL;
}
priv->event_thread_run = TRUE;
#if GLIB_CHECK_VERSION(2,31,19)
priv->event_thread = g_thread_new("usb_ev_thread",
spice_usb_device_manager_usb_ev_thread,
self);
#else
priv->event_thread = g_thread_create(spice_usb_device_manager_usb_ev_thread,
self, TRUE, err);
#endif
return priv->event_thread != NULL;
}

View File

@ -21,7 +21,6 @@
#include "config.h"
#include <glib/gi18n.h>
#include "glib-compat.h"
#include "spice-client.h"
#include "spice-marshal.h"
#include "usb-device-widget.h"

View File

@ -26,8 +26,6 @@
#include <ctype.h>
#include <stdlib.h>
#include "glib-compat.h"
#ifdef USE_USBREDIR
#ifdef __linux__
#include <stdio.h>

View File

@ -22,7 +22,6 @@
#include "vmcstream.h"
#include "spice-channel-priv.h"
#include "gio-coroutine.h"
#include "glib-compat.h"
struct _SpiceVmcInputStream
{

View File

@ -22,7 +22,6 @@
#include "config.h"
#include "glib-compat.h"
#include "wocky-http-proxy.h"
#include <string.h>

View File

@ -37,7 +37,6 @@ typedef struct _WockyHttpProxyClass WockyHttpProxyClass;
GType _wocky_http_proxy_get_type (void);
#if GLIB_CHECK_VERSION(2, 28, 0)
#define WOCKY_TYPE_HTTPS_PROXY (_wocky_https_proxy_get_type ())
#define WOCKY_HTTPS_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), WOCKY_TYPE_HTTPS_PROXY, WockyHttpsProxy))
#define WOCKY_HTTPS_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), WOCKY_TYPE_HTTPS_PROXY, WockyHttpsProxyClass))
@ -49,7 +48,6 @@ typedef struct _WockyHttpsProxy WockyHttpsProxy;
typedef struct _WockyHttpsProxyClass WockyHttpsProxyClass;
GType _wocky_https_proxy_get_type (void);
#endif
G_END_DECLS

View File

@ -36,11 +36,9 @@ static void test_coroutine_simple(void)
result = coroutine_yieldto(&co, GINT_TO_POINTER(42));
g_assert_cmpint(GPOINTER_TO_INT(result), ==, 0x42);
#if GLIB_CHECK_VERSION(2,34,0)
g_test_expect_message(G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*!to->exited*");
coroutine_yieldto(&co, GINT_TO_POINTER(42));
g_test_assert_expected_messages();
#endif
g_assert(self == coroutine_self());
g_assert(coroutine_self_is_main());
@ -117,11 +115,9 @@ static void test_coroutine_yield(void)
g_assert(self == coroutine_self());
g_assert(val == NULL);
#if GLIB_CHECK_VERSION(2,34,0)
g_test_expect_message(G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*!to->exited*");
coroutine_yieldto(&co, GINT_TO_POINTER(42));
g_test_assert_expected_messages();
#endif
}
int main(int argc, char* argv[])

View File

@ -71,10 +71,6 @@ int main(void)
{
GInputStream *stdin_unix_stream;
#if !GLIB_CHECK_VERSION(2,36,0)
g_type_init();
#endif
loop = g_main_loop_new(NULL, FALSE);
stdin_unix_stream = g_unix_input_stream_new(STDIN_FILENO, 0);