[gnome-keyring] Remove support code for old glib versions
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-keyring] Remove support code for old glib versions
- Date: Wed, 27 Jun 2012 09:42:12 +0000 (UTC)
commit 5e031c3f81caaf5d2ae7078af60954266ffaaa36
Author: Stef Walter <stefw gnome org>
Date: Tue Jun 26 16:00:44 2012 +0200
Remove support code for old glib versions
* Remove a bunch of #ifdefs for old glib versions prior
to 2.32.0.
* Already bumped glib dependency in a recent commit.
daemon/gpg-agent/gkd-gpg-agent.c | 14 --------
daemon/ssh-agent/gkd-ssh-agent.c | 14 --------
egg/egg-libgcrypt.c | 8 -----
egg/egg-testing.c | 58 -----------------------------------
pkcs11/gkm/gkm-timer.c | 27 ----------------
pkcs11/gkm/gkm-util.c | 4 --
pkcs11/rpc-layer/gkm-rpc-dispatch.c | 4 --
7 files changed, 0 insertions(+), 129 deletions(-)
---
diff --git a/daemon/gpg-agent/gkd-gpg-agent.c b/daemon/gpg-agent/gkd-gpg-agent.c
index 0365c21..5be617f 100644
--- a/daemon/gpg-agent/gkd-gpg-agent.c
+++ b/daemon/gpg-agent/gkd-gpg-agent.c
@@ -329,11 +329,7 @@ gkd_gpg_agent_accept (void)
client->sock = new_fd;
/* And create a new thread/process */
-#if GLIB_CHECK_VERSION(2,31,2)
client->thread = g_thread_new ("gpg-agent", run_client_thread, &client->sock);
-#else
- client->thread = g_thread_create (run_client_thread, &client->sock, TRUE, &error);
-#endif
if (!client->thread) {
g_warning ("couldn't create thread GPG agent connection: %s",
error && error->message ? error->message : "");
@@ -389,15 +385,10 @@ gkd_gpg_agent_uninitialize (void)
pkcs11_main_session = NULL;
g_mutex_unlock (pkcs11_main_mutex);
-#if GLIB_CHECK_VERSION(2,31,2)
g_mutex_clear (pkcs11_main_mutex);
g_free (pkcs11_main_mutex);
g_cond_clear (pkcs11_main_cond);
g_free (pkcs11_main_cond);
-#else
- g_mutex_free (pkcs11_main_mutex);
- g_cond_free (pkcs11_main_cond);
-#endif
g_assert (pkcs11_module);
g_object_unref (pkcs11_module);
@@ -457,15 +448,10 @@ gkd_gpg_agent_initialize_with_module (GckModule *module)
pkcs11_module = g_object_ref (module);
-#if GLIB_CHECK_VERSION(2,31,2)
pkcs11_main_mutex = g_new0 (GMutex, 1);
g_mutex_init (pkcs11_main_mutex);
pkcs11_main_cond = g_new0 (GCond, 1);
g_cond_init (pkcs11_main_cond);
-#else
- pkcs11_main_mutex = g_mutex_new ();
- pkcs11_main_cond = g_cond_new ();
-#endif
pkcs11_main_checked = FALSE;
pkcs11_main_session = session;
diff --git a/daemon/ssh-agent/gkd-ssh-agent.c b/daemon/ssh-agent/gkd-ssh-agent.c
index aa1fd54..2ef7f3b 100644
--- a/daemon/ssh-agent/gkd-ssh-agent.c
+++ b/daemon/ssh-agent/gkd-ssh-agent.c
@@ -284,11 +284,7 @@ gkd_ssh_agent_accept (void)
client->sock = new_fd;
/* And create a new thread/process */
-#if GLIB_CHECK_VERSION(2,31,3)
client->thread = g_thread_new ("ssh-agent", run_client_thread, &client->sock);
-#else
- client->thread = g_thread_create (run_client_thread, &client->sock, TRUE, &error);
-#endif
if (!client->thread) {
g_warning ("couldn't create thread SSH agent connection: %s",
egg_error_message (error));
@@ -344,15 +340,10 @@ gkd_ssh_agent_uninitialize (void)
pkcs11_main_session = NULL;
g_mutex_unlock (pkcs11_main_mutex);
-#if GLIB_CHECK_VERSION(2,31,3)
g_mutex_clear (pkcs11_main_mutex);
g_free (pkcs11_main_mutex);
g_cond_clear (pkcs11_main_cond);
g_free (pkcs11_main_cond);
-#else
- g_mutex_free (pkcs11_main_mutex);
- g_cond_free (pkcs11_main_cond);
-#endif
gck_list_unref_free (pkcs11_modules);
pkcs11_modules = NULL;
@@ -411,15 +402,10 @@ gkd_ssh_agent_initialize_with_module (GckModule *module)
g_assert (!pkcs11_modules);
pkcs11_modules = g_list_append (NULL, g_object_ref (module));
-#if GLIB_CHECK_VERSION(2,31,3)
pkcs11_main_mutex = g_new0 (GMutex, 1);
g_mutex_init (pkcs11_main_mutex);
pkcs11_main_cond = g_new0 (GCond, 1);
g_cond_init (pkcs11_main_cond);
-#else
- pkcs11_main_mutex = g_mutex_new ();
- pkcs11_main_cond = g_cond_new ();
-#endif
pkcs11_main_checked = FALSE;
pkcs11_main_session = session;
diff --git a/egg/egg-libgcrypt.c b/egg/egg-libgcrypt.c
index 6341163..efb7372 100644
--- a/egg/egg-libgcrypt.c
+++ b/egg/egg-libgcrypt.c
@@ -56,24 +56,16 @@ fatal_handler (gpointer unused, int unknown, const gchar *msg)
static int
glib_thread_mutex_init (void **lock)
{
-#if GLIB_CHECK_VERSION(2,31,3)
*lock = g_new0 (GMutex, 1);
g_mutex_init (*lock);
-#else
- *lock = g_mutex_new ();
-#endif
return 0;
}
static int
glib_thread_mutex_destroy (void **lock)
{
-#if GLIB_CHECK_VERSION(2,31,3)
g_mutex_clear (*lock);
g_free (*lock);
-#else
- g_mutex_free (*lock);
-#endif
return 0;
}
diff --git a/egg/egg-testing.c b/egg/egg-testing.c
index f99c7d8..041d6f4 100644
--- a/egg/egg-testing.c
+++ b/egg/egg-testing.c
@@ -28,15 +28,9 @@
#include <errno.h>
#include <unistd.h>
-#if GLIB_CHECK_VERSION(2,31,3)
static GCond wait_condition;
static GCond wait_start;
static GMutex wait_mutex;
-#else
-static GCond *wait_condition = NULL;
-static GCond *wait_start = NULL;
-static GMutex *wait_mutex = NULL;
-#endif
static gboolean wait_waiting = FALSE;
@@ -89,34 +83,16 @@ egg_assertion_message_cmpmem (const char *domain,
void
egg_test_wait_stop (void)
{
-#if GLIB_CHECK_VERSION(2,31,3)
g_mutex_lock (&wait_mutex);
-#else
- g_assert (wait_mutex);
- g_assert (wait_condition);
- g_mutex_lock (wait_mutex);
-#endif
if (!wait_waiting) {
-#if GLIB_CHECK_VERSION(2,31,3)
gint64 time = g_get_monotonic_time () + 1 * G_TIME_SPAN_SECOND;
g_cond_wait_until (&wait_start, &wait_mutex, time);
-#else
- GTimeVal tv;
- g_get_current_time (&tv);
- g_time_val_add (&tv, 1000);
- g_cond_timed_wait (wait_start, wait_mutex, &tv);
-#endif
}
g_assert (wait_waiting);
-#if GLIB_CHECK_VERSION(2,31,3)
g_cond_broadcast (&wait_condition);
g_mutex_unlock (&wait_mutex);
-#else
- g_cond_broadcast (wait_condition);
- g_mutex_unlock (wait_mutex);
-#endif
}
gboolean
@@ -124,38 +100,20 @@ egg_test_wait_until (int timeout)
{
gboolean ret;
-#if GLIB_CHECK_VERSION(2,31,3)
g_mutex_lock (&wait_mutex);
-#else
- g_assert (wait_mutex);
- g_assert (wait_condition);
- g_mutex_lock (wait_mutex);
-#endif
g_assert (!wait_waiting);
wait_waiting = TRUE;
{
-#if GLIB_CHECK_VERSION(2,31,3)
gint64 time = g_get_monotonic_time () + ((timeout + 1000) * G_TIME_SPAN_MILLISECOND);
g_cond_broadcast (&wait_start);
ret = g_cond_wait_until (&wait_start, &wait_mutex, time);
-#else
- GTimeVal tv;
- g_get_current_time (&tv);
- g_time_val_add (&tv, timeout * 1000);
- g_cond_broadcast (wait_start);
- ret = g_cond_timed_wait (wait_condition, wait_mutex, &tv);
-#endif
}
g_assert (wait_waiting);
wait_waiting = FALSE;
-#if GLIB_CHECK_VERSION(2,31,3)
g_mutex_unlock (&wait_mutex);
-#else
- g_mutex_unlock (wait_mutex);
-#endif
return ret;
}
@@ -176,22 +134,11 @@ egg_tests_run_in_thread_with_loop (void)
GMainLoop *loop;
gpointer ret;
-#if !GLIB_CHECK_VERSION(2,31,3)
- g_thread_init (NULL);
-#endif
-
loop = g_main_loop_new (NULL, FALSE);
-#if GLIB_CHECK_VERSION(2,31,3)
g_cond_init (&wait_condition);
g_cond_init (&wait_start);
g_mutex_init (&wait_mutex);
thread = g_thread_new ("testing", testing_thread, loop);
-#else
- wait_condition = g_cond_new ();
- wait_start = g_cond_new ();
- wait_mutex = g_mutex_new ();
- thread = g_thread_create (testing_thread, loop, TRUE, NULL);
-#endif
g_assert (thread);
@@ -199,13 +146,8 @@ egg_tests_run_in_thread_with_loop (void)
ret = g_thread_join (thread);
g_main_loop_unref (loop);
-#if GLIB_CHECK_VERSION(2,31,2)
g_cond_clear (&wait_condition);
g_mutex_clear (&wait_mutex);
-#else
- g_cond_free (wait_condition);
- g_mutex_free (wait_mutex);
-#endif
return GPOINTER_TO_INT (ret);
}
diff --git a/pkcs11/gkm/gkm-timer.c b/pkcs11/gkm/gkm-timer.c
index 1749782..2873c21 100644
--- a/pkcs11/gkm/gkm-timer.c
+++ b/pkcs11/gkm/gkm-timer.c
@@ -38,9 +38,7 @@ struct _GkmTimer {
static GStaticMutex timer_mutex = G_STATIC_MUTEX_INIT;
static GQueue *timer_queue = NULL;
static GThread *timer_thread = NULL;
-#if GLIB_CHECK_VERSION(2,31,3)
static GCond timer_condition;
-#endif
static GCond *timer_cond = NULL;
static gboolean timer_run = FALSE;
static gint timer_refs = 0;
@@ -73,25 +71,12 @@ timer_thread_func (gpointer unused)
}
if (timer->when) {
-#if GLIB_CHECK_VERSION(2,31,3)
gint64 when = ((gint64)timer->when) * G_TIME_SPAN_SECOND;
gint64 offset = when - g_get_real_time ();
if (offset > 0) {
g_cond_wait_until (timer_cond, mutex, g_get_monotonic_time () + offset);
continue;
}
-#else
- GTimeVal tv;
- g_get_current_time (&tv);
-
- /* We have to wait until the next timer? */
- if (tv.tv_sec < timer->when) {
- tv.tv_sec = timer->when;
- tv.tv_usec = 0;
- g_cond_timed_wait (timer_cond, mutex, &tv);
- continue;
- }
-#endif
}
/* Leave our thread mutex, and enter the module */
@@ -123,22 +108,14 @@ gkm_timer_initialize (void)
g_atomic_int_inc (&timer_refs);
if (!timer_thread) {
timer_run = TRUE;
-#if GLIB_CHECK_VERSION(2,31,3)
timer_thread = g_thread_new ("timer", timer_thread_func, NULL);
-#else
- timer_thread = g_thread_create (timer_thread_func, NULL, TRUE, &error);
-#endif
if (timer_thread) {
g_assert (timer_queue == NULL);
timer_queue = g_queue_new ();
g_assert (timer_cond == NULL);
-#if GLIB_CHECK_VERSION(2,31,3)
timer_cond = &timer_condition;
g_cond_init (timer_cond);
-#else
- timer_cond = g_cond_new ();
-#endif
} else {
g_warning ("could not create timer thread: %s",
egg_error_message (error));
@@ -178,11 +155,7 @@ gkm_timer_shutdown (void)
g_queue_free (timer_queue);
timer_queue = NULL;
-#if GLIB_CHECK_VERSION(2,31,3)
g_cond_clear (timer_cond);
-#else
- g_cond_free (timer_cond);
-#endif
timer_cond = NULL;
}
}
diff --git a/pkcs11/gkm/gkm-util.c b/pkcs11/gkm/gkm-util.c
index b501698..32fb722 100644
--- a/pkcs11/gkm/gkm-util.c
+++ b/pkcs11/gkm/gkm-util.c
@@ -125,11 +125,7 @@ gkm_util_return_data (CK_VOID_PTR output, CK_ULONG_PTR n_output,
CK_ULONG
gkm_util_next_handle (void)
{
-#if GLIB_CHECK_VERSION(2,29,6)
return (CK_ULONG)g_atomic_int_add (&next_handle, 1);
-#else
- return (CK_ULONG)g_atomic_int_exchange_and_add (&next_handle, 1);
-#endif
}
void
diff --git a/pkcs11/rpc-layer/gkm-rpc-dispatch.c b/pkcs11/rpc-layer/gkm-rpc-dispatch.c
index d187148..5069d53 100644
--- a/pkcs11/rpc-layer/gkm-rpc-dispatch.c
+++ b/pkcs11/rpc-layer/gkm-rpc-dispatch.c
@@ -2229,11 +2229,7 @@ gkm_rpc_layer_accept (void)
ds->socket = new_fd;
-#if GLIB_CHECK_VERSION(2,31,3)
ds->thread = g_thread_new ("dispatch", run_dispatch_thread, &(ds->socket));
-#else
- ds->thread = g_thread_create (run_dispatch_thread, &(ds->socket), TRUE, &error);
-#endif
if (!ds->thread) {
gkm_rpc_warn ("couldn't start thread: %s", egg_error_message (error));
close (new_fd);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]