[evolution-data-server] Bug #608766 - Replace pthread with GLib's GThread
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug #608766 - Replace pthread with GLib's GThread
- Date: Thu, 15 Apr 2010 12:41:40 +0000 (UTC)
commit e01898bcd368cc7e96158286579d8dd419e59352
Author: Milan Crha <mcrha redhat com>
Date: Thu Apr 15 14:38:10 2010 +0200
Bug #608766 - Replace pthread with GLib's GThread
calendar/libecal/e-cal.c | 1 -
camel/camel-block-file.c | 53 ++++++++++++-------------
camel/camel-certdb.c | 11 ++---
camel/camel-data-wrapper.c | 4 +-
camel/camel-debug.c | 13 ++----
camel/camel-exception.c | 1 -
camel/camel-folder-summary.c | 7 +--
camel/camel-lock-client.c | 7 +--
camel/camel-mime-utils.c | 18 ++++----
camel/camel-object.c | 27 ++++++-------
camel/camel-object.h | 1 -
camel/camel-operation.c | 29 ++++---------
camel/camel-partition-table.c | 20 +++++-----
camel/camel-private.h | 7 +--
camel/camel-provider.c | 12 +++--
camel/camel-sasl-popb4smtp.c | 7 +--
camel/camel-service.c | 1 -
camel/camel-string-utils.c | 15 +++----
camel/providers/imapx/camel-imapx-exception.c | 19 ++++-----
camel/providers/local/camel-local-private.h | 1 -
camel/providers/nntp/camel-nntp-newsrc.c | 1 -
camel/tests/folder/test10.c | 19 ++++++---
camel/tests/folder/test11.c | 1 -
camel/tests/folder/test8.c | 24 +++++++----
camel/tests/lib/camel-test.c | 21 ++++------
configure.ac | 25 ++----------
libedataserver/e-data-server-util.c | 44 ++++-----------------
libedataserver/e-data-server-util.h | 3 +-
m4/evo_pthread_check.m4 | 16 -------
29 files changed, 163 insertions(+), 245 deletions(-)
---
diff --git a/calendar/libecal/e-cal.c b/calendar/libecal/e-cal.c
index d1dfdac..c8299d5 100644
--- a/calendar/libecal/e-cal.c
+++ b/calendar/libecal/e-cal.c
@@ -27,7 +27,6 @@
#endif
#include <unistd.h>
-#include <pthread.h>
#include <string.h>
#include <glib/gi18n-lib.h>
diff --git a/camel/camel-block-file.c b/camel/camel-block-file.c
index 15dbab1..8b4cda0 100644
--- a/camel/camel-block-file.c
+++ b/camel/camel-block-file.c
@@ -25,7 +25,6 @@
#include <errno.h>
#include <fcntl.h>
-#include <pthread.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -51,21 +50,21 @@ struct _CamelBlockFilePrivate {
struct _CamelBlockFile *base;
- pthread_mutex_t root_lock; /* for modifying the root block */
- pthread_mutex_t cache_lock; /* for refcounting, flag manip, cache manip */
- pthread_mutex_t io_lock; /* for all io ops */
+ GStaticMutex root_lock; /* for modifying the root block */
+ GStaticMutex cache_lock; /* for refcounting, flag manip, cache manip */
+ GStaticMutex io_lock; /* for all io ops */
guint deleted:1;
};
-#define CAMEL_BLOCK_FILE_LOCK(kf, lock) (pthread_mutex_lock(&(kf)->priv->lock))
-#define CAMEL_BLOCK_FILE_TRYLOCK(kf, lock) (pthread_mutex_trylock(&(kf)->priv->lock))
-#define CAMEL_BLOCK_FILE_UNLOCK(kf, lock) (pthread_mutex_unlock(&(kf)->priv->lock))
+#define CAMEL_BLOCK_FILE_LOCK(kf, lock) (g_static_mutex_lock(&(kf)->priv->lock))
+#define CAMEL_BLOCK_FILE_TRYLOCK(kf, lock) (g_static_mutex_trylock(&(kf)->priv->lock))
+#define CAMEL_BLOCK_FILE_UNLOCK(kf, lock) (g_static_mutex_unlock(&(kf)->priv->lock))
-#define LOCK(x) pthread_mutex_lock(&x)
-#define UNLOCK(x) pthread_mutex_unlock(&x)
+#define LOCK(x) g_static_mutex_lock(&x)
+#define UNLOCK(x) g_static_mutex_unlock(&x)
-static pthread_mutex_t block_file_lock = PTHREAD_MUTEX_INITIALIZER;
+static GStaticMutex block_file_lock = G_STATIC_MUTEX_INIT;
/* lru cache of block files */
static CamelDList block_file_list = CAMEL_DLIST_INITIALISER(block_file_list);
@@ -180,9 +179,9 @@ camel_block_file_finalize(CamelBlockFile *bs)
if (bs->fd != -1)
close(bs->fd);
- pthread_mutex_destroy(&p->io_lock);
- pthread_mutex_destroy(&p->cache_lock);
- pthread_mutex_destroy(&p->root_lock);
+ g_static_mutex_free (&p->io_lock);
+ g_static_mutex_free (&p->cache_lock);
+ g_static_mutex_free (&p->root_lock);
g_free(p);
}
@@ -216,9 +215,9 @@ camel_block_file_init(CamelBlockFile *bs)
p = bs->priv = g_malloc0(sizeof(*bs->priv));
p->base = bs;
- pthread_mutex_init(&p->root_lock, NULL);
- pthread_mutex_init(&p->cache_lock, NULL);
- pthread_mutex_init(&p->io_lock, NULL);
+ g_static_mutex_init (&p->root_lock);
+ g_static_mutex_init (&p->cache_lock);
+ g_static_mutex_init (&p->io_lock);
/* link into lru list */
LOCK(block_file_lock);
@@ -307,9 +306,9 @@ block_file_use(CamelBlockFile *bs)
if (bf->fd != -1) {
/* Need to trylock, as any of these lock levels might be trying
to lock the block_file_lock, so we need to check and abort if so */
- if (CAMEL_BLOCK_FILE_TRYLOCK(bf, root_lock) == 0) {
- if (CAMEL_BLOCK_FILE_TRYLOCK(bf, cache_lock) == 0) {
- if (CAMEL_BLOCK_FILE_TRYLOCK(bf, io_lock) == 0) {
+ if (CAMEL_BLOCK_FILE_TRYLOCK (bf, root_lock)) {
+ if (CAMEL_BLOCK_FILE_TRYLOCK (bf, cache_lock)) {
+ if (CAMEL_BLOCK_FILE_TRYLOCK (bf, io_lock)) {
d(printf("[%d] Turning block file offline: %s\n", block_file_count-1, bf->path));
sync_nolock(bf);
close(bf->fd);
@@ -812,15 +811,15 @@ struct _CamelKeyFilePrivate {
struct _CamelKeyFilePrivate *prev;
struct _CamelKeyFile *base;
- pthread_mutex_t lock;
+ GStaticMutex lock;
guint deleted:1;
};
-#define CAMEL_KEY_FILE_LOCK(kf, lock) (pthread_mutex_lock(&(kf)->priv->lock))
-#define CAMEL_KEY_FILE_TRYLOCK(kf, lock) (pthread_mutex_trylock(&(kf)->priv->lock))
-#define CAMEL_KEY_FILE_UNLOCK(kf, lock) (pthread_mutex_unlock(&(kf)->priv->lock))
+#define CAMEL_KEY_FILE_LOCK(kf, lock) (g_static_mutex_lock(&(kf)->priv->lock))
+#define CAMEL_KEY_FILE_TRYLOCK(kf, lock) (g_static_mutex_trylock(&(kf)->priv->lock))
+#define CAMEL_KEY_FILE_UNLOCK(kf, lock) (g_static_mutex_unlock(&(kf)->priv->lock))
-static pthread_mutex_t key_file_lock = PTHREAD_MUTEX_INITIALIZER;
+static GStaticMutex key_file_lock = G_STATIC_MUTEX_INIT;
/* lru cache of block files */
static CamelDList key_file_list = CAMEL_DLIST_INITIALISER(key_file_list);
@@ -845,7 +844,7 @@ camel_key_file_finalize(CamelKeyFile *bs)
g_free(bs->path);
- pthread_mutex_destroy(&p->lock);
+ g_static_mutex_free (&p->lock);
g_free(p);
}
@@ -863,7 +862,7 @@ camel_key_file_init(CamelKeyFile *bs)
p = bs->priv = g_malloc0(sizeof(*bs->priv));
p->base = bs;
- pthread_mutex_init(&p->lock, NULL);
+ g_static_mutex_init (&p->lock);
LOCK(key_file_lock);
camel_dlist_addhead(&key_file_list, (CamelDListNode *)p);
@@ -949,7 +948,7 @@ key_file_use(CamelKeyFile *bs)
if (bf->fp != NULL) {
/* Need to trylock, as any of these lock levels might be trying
to lock the key_file_lock, so we need to check and abort if so */
- if (CAMEL_BLOCK_FILE_TRYLOCK(bf, lock) == 0) {
+ if (CAMEL_BLOCK_FILE_TRYLOCK (bf, lock)) {
d(printf("Turning key file offline: %s\n", bf->path));
fclose(bf->fp);
bf->fp = NULL;
diff --git a/camel/camel-certdb.c b/camel/camel-certdb.c
index 5b5ab6a..4d0cda1 100644
--- a/camel/camel-certdb.c
+++ b/camel/camel-certdb.c
@@ -26,7 +26,6 @@
#include <errno.h>
#include <fcntl.h>
-#include <pthread.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
@@ -147,12 +146,12 @@ camel_certdb_new (void)
}
static CamelCertDB *default_certdb = NULL;
-static pthread_mutex_t default_certdb_lock = PTHREAD_MUTEX_INITIALIZER;
+static GStaticMutex default_certdb_lock = G_STATIC_MUTEX_INIT;
void
camel_certdb_set_default (CamelCertDB *certdb)
{
- pthread_mutex_lock (&default_certdb_lock);
+ g_static_mutex_lock (&default_certdb_lock);
if (default_certdb)
camel_object_unref (default_certdb);
@@ -162,7 +161,7 @@ camel_certdb_set_default (CamelCertDB *certdb)
default_certdb = certdb;
- pthread_mutex_unlock (&default_certdb_lock);
+ g_static_mutex_unlock (&default_certdb_lock);
}
CamelCertDB *
@@ -170,14 +169,14 @@ camel_certdb_get_default (void)
{
CamelCertDB *certdb;
- pthread_mutex_lock (&default_certdb_lock);
+ g_static_mutex_lock (&default_certdb_lock);
if (default_certdb)
camel_object_ref (default_certdb);
certdb = default_certdb;
- pthread_mutex_unlock (&default_certdb_lock);
+ g_static_mutex_unlock (&default_certdb_lock);
return certdb;
}
diff --git a/camel/camel-data-wrapper.c b/camel/camel-data-wrapper.c
index c739375..f13ff9c 100644
--- a/camel/camel-data-wrapper.c
+++ b/camel/camel-data-wrapper.c
@@ -42,7 +42,7 @@ camel_data_wrapper_finalize (CamelObject *object)
{
CamelDataWrapper *camel_data_wrapper = CAMEL_DATA_WRAPPER (object);
- pthread_mutex_destroy (&camel_data_wrapper->priv->stream_lock);
+ g_static_mutex_free (&camel_data_wrapper->priv->stream_lock);
g_free (camel_data_wrapper->priv);
@@ -190,7 +190,7 @@ camel_data_wrapper_init (CamelDataWrapper *data_wrapper)
{
data_wrapper->priv = g_malloc (sizeof (struct _CamelDataWrapperPrivate));
- pthread_mutex_init (&data_wrapper->priv->stream_lock, NULL);
+ g_static_mutex_init (&data_wrapper->priv->stream_lock);
data_wrapper->mime_type = camel_content_type_new (
"application", "octet-stream");
diff --git a/camel/camel-debug.c b/camel/camel-debug.c
index 3aa01ce..3b25db1 100644
--- a/camel/camel-debug.c
+++ b/camel/camel-debug.c
@@ -19,13 +19,10 @@
* USA
*/
-#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <libedataserver/e-data-server-util.h>
-
#include "camel-debug.h"
gint camel_verbose_debug;
@@ -112,7 +109,7 @@ gboolean camel_debug(const gchar *mode)
return FALSE;
}
-static pthread_mutex_t debug_lock = PTHREAD_MUTEX_INITIALIZER;
+static GStaticMutex debug_lock = G_STATIC_MUTEX_INIT;
/**
* camel_debug_start:
* @mode:
@@ -127,8 +124,8 @@ gboolean
camel_debug_start(const gchar *mode)
{
if (camel_debug(mode)) {
- pthread_mutex_lock(&debug_lock);
- printf("Thread %" G_GINT64_MODIFIER "x >\n", e_util_pthread_id(pthread_self()));
+ g_static_mutex_lock (&debug_lock);
+ printf ("Thread %p >\n", g_thread_self());
return TRUE;
}
@@ -144,8 +141,8 @@ camel_debug_start(const gchar *mode)
void
camel_debug_end(void)
{
- printf("< %" G_GINT64_MODIFIER "x >\n", e_util_pthread_id(pthread_self()));
- pthread_mutex_unlock(&debug_lock);
+ printf ("< %p >\n", g_thread_self());
+ g_static_mutex_unlock (&debug_lock);
}
#if 0
diff --git a/camel/camel-exception.c b/camel/camel-exception.c
index d8c2980..22db7f5 100644
--- a/camel/camel-exception.c
+++ b/camel/camel-exception.c
@@ -26,7 +26,6 @@
#endif
#include <stdio.h>
-#include <pthread.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index ac3b2c5..e91304b 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -28,7 +28,6 @@
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <pthread.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
@@ -64,11 +63,11 @@
#define SUMMARY_CACHE_DROP 300
#define dd(x) if (camel_debug("sync")) x
-static pthread_mutex_t info_lock = PTHREAD_MUTEX_INITIALIZER;
+static GStaticMutex info_lock = G_STATIC_MUTEX_INIT;
/* this lock is ONLY for the standalone messageinfo stuff */
-#define GLOBAL_INFO_LOCK(i) pthread_mutex_lock(&info_lock)
-#define GLOBAL_INFO_UNLOCK(i) pthread_mutex_unlock(&info_lock)
+#define GLOBAL_INFO_LOCK(i) g_static_mutex_lock(&info_lock)
+#define GLOBAL_INFO_UNLOCK(i) g_static_mutex_unlock(&info_lock)
/* this should probably be conditional on it existing */
#define USE_BSEARCH
diff --git a/camel/camel-lock-client.c b/camel/camel-lock-client.c
index 34cdfe9..52a4f39 100644
--- a/camel/camel-lock-client.c
+++ b/camel/camel-lock-client.c
@@ -25,7 +25,6 @@
#include <errno.h>
#include <fcntl.h>
-#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -44,9 +43,9 @@
/* see also camel-lock.c */
#define _(x) (x)
-static pthread_mutex_t lock_lock = PTHREAD_MUTEX_INITIALIZER;
-#define LOCK() pthread_mutex_lock(&lock_lock)
-#define UNLOCK() pthread_mutex_unlock(&lock_lock)
+static GStaticMutex lock_lock = G_STATIC_MUTEX_INIT;
+#define LOCK() g_static_mutex_lock(&lock_lock)
+#define UNLOCK() g_static_mutex_unlock(&lock_lock)
static gint lock_sequence;
static gint lock_helper_pid = -1;
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index d5d2093..48ac641 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -30,7 +30,6 @@
#include <sys/types.h>
#include <sys/param.h> /* for MAXHOSTNAMELEN */
#include <sys/stat.h>
-#include <pthread.h>
#include <unistd.h>
#include <regex.h>
#include <fcntl.h>
@@ -4313,9 +4312,9 @@ camel_header_raw_clear(struct _camel_header_raw **list)
gchar *
camel_header_msgid_generate (void)
{
- static pthread_mutex_t count_lock = PTHREAD_MUTEX_INITIALIZER;
-#define COUNT_LOCK() pthread_mutex_lock (&count_lock)
-#define COUNT_UNLOCK() pthread_mutex_unlock (&count_lock)
+ static GStaticMutex count_lock = G_STATIC_MUTEX_INIT;
+#define COUNT_LOCK() g_static_mutex_lock (&count_lock)
+#define COUNT_UNLOCK() g_static_mutex_unlock (&count_lock)
gchar host[MAXHOSTNAMELEN];
const gchar *name;
static gint count = 0;
@@ -4397,10 +4396,8 @@ static struct {
{ "List-Unsubscribe", "<mailto:(.+)-unsubscribe@([^ \n\t\r>]*)" },
};
-static pthread_once_t mailing_list_init_once = PTHREAD_ONCE_INIT;
-
-static void
-mailing_list_init(void)
+static gpointer
+mailing_list_init (gpointer param)
{
gint i, errcode, failed=0;
@@ -4422,16 +4419,19 @@ mailing_list_init(void)
}
g_assert(failed == 0);
+
+ return NULL;
}
gchar *
camel_header_raw_check_mailing_list(struct _camel_header_raw **list)
{
+ static GOnce once = G_ONCE_INIT;
const gchar *v;
regmatch_t match[3];
gint i, j;
- pthread_once(&mailing_list_init_once, mailing_list_init);
+ g_once (&once, mailing_list_init, NULL);
for (i = 0; i < G_N_ELEMENTS (mail_list_magic); i++) {
v = camel_header_raw_find (list, mail_list_magic[i].name, NULL);
diff --git a/camel/camel-object.c b/camel/camel-object.c
index a45dfa0..64d83d2 100644
--- a/camel/camel-object.c
+++ b/camel/camel-object.c
@@ -25,7 +25,6 @@
#endif
#include <errno.h>
-#include <pthread.h>
#include <stdio.h>
#include <string.h>
@@ -90,7 +89,7 @@ struct _CamelObjectBagKey {
gpointer key; /* the key reserved */
gint waiters; /* count of threads waiting for key */
- pthread_t owner; /* the thread that has reserved the bag for a new entry */
+ GThread *owner; /* the thread that has reserved the bag for a new entry */
gint have_owner;
GCond *cond;
};
@@ -139,8 +138,6 @@ static GHashTable *type_table;
CamelType camel_object_type = CAMEL_INVALID_TYPE;
CamelType camel_interface_type = CAMEL_INVALID_TYPE;
-#define P_LOCK(l) (pthread_mutex_lock(&l))
-#define P_UNLOCK(l) (pthread_mutex_unlock(&l))
#define CLASS_LOCK(k) (g_mutex_lock((((CamelObjectClass *)k)->lock)))
#define CLASS_UNLOCK(k) (g_mutex_unlock((((CamelObjectClass *)k)->lock)))
#define REF_LOCK() (g_mutex_lock(ref_lock))
@@ -675,7 +672,7 @@ camel_object_ref (gpointer vo)
{
register CamelObject *o = vo;
- g_return_if_fail(CAMEL_IS_OBJECT(o));
+ g_return_val_if_fail (CAMEL_IS_OBJECT (o), NULL);
REF_LOCK();
@@ -988,13 +985,13 @@ camel_object_free_hooks(CamelObject *o)
static CamelHookList *
camel_object_get_hooks(CamelObject *o)
{
- static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+ static GStaticMutex lock = G_STATIC_MUTEX_INIT;
CamelHookList *hooks;
/* if we have it, we dont have to do any other locking,
otherwise use a global lock to setup the object's hook data */
if (o->hooks == NULL) {
- pthread_mutex_lock(&lock);
+ g_static_mutex_lock(&lock);
if (o->hooks == NULL) {
hooks = hooks_alloc();
g_static_rec_mutex_init(&hooks->lock);
@@ -1004,7 +1001,7 @@ camel_object_get_hooks(CamelObject *o)
hooks->list = NULL;
o->hooks = hooks;
}
- pthread_mutex_unlock(&lock);
+ g_static_mutex_unlock(&lock);
}
g_static_rec_mutex_lock(&o->hooks->lock);
@@ -1572,7 +1569,7 @@ co_bag_unreserve(CamelObjectBag *bag, gconstpointer key)
}
g_assert(res != NULL);
- g_assert(res->have_owner && pthread_equal(res->owner, pthread_self()));
+ g_assert(res->have_owner && res->owner == g_thread_self ());
if (res->waiters > 0) {
b(printf("unreserve bag '%s', waking waiters\n", (gchar *)key));
@@ -1676,7 +1673,7 @@ camel_object_bag_get(CamelObjectBag *bag, gconstpointer key)
b(printf("object bag get '%s', reserved, waiting\n", (gchar *)key));
res->waiters++;
- g_assert(!res->have_owner || !pthread_equal(res->owner, pthread_self()));
+ g_assert(!res->have_owner || res->owner != g_thread_self ());
g_cond_wait(res->cond, ref_lock);
res->waiters--;
@@ -1688,7 +1685,7 @@ camel_object_bag_get(CamelObjectBag *bag, gconstpointer key)
b(printf("object bag get '%s', finished waiting, got %p\n", (gchar *)key, o));
/* we don't actually reserve it */
- res->owner = pthread_self();
+ res->owner = g_thread_self ();
res->have_owner = TRUE;
co_bag_unreserve(bag, key);
}
@@ -1771,7 +1768,7 @@ camel_object_bag_reserve(CamelObjectBag *bag, gconstpointer key)
if (res) {
b(printf("bag reserve %s, already reserved, waiting\n", (gchar *)key));
- g_assert(!res->have_owner || !pthread_equal(res->owner, pthread_self()));
+ g_assert(!res->have_owner || res->owner != g_thread_self ());
res->waiters++;
g_cond_wait(res->cond, ref_lock);
res->waiters--;
@@ -1781,12 +1778,12 @@ camel_object_bag_reserve(CamelObjectBag *bag, gconstpointer key)
b(printf("finished wait, someone else created '%s' = %p\n", (gchar *)key, o));
o->ref_count++;
/* in which case we dont need to reserve the bag either */
- res->owner = pthread_self();
+ res->owner = g_thread_self ();
res->have_owner = TRUE;
co_bag_unreserve(bag, key);
} else {
b(printf("finished wait, now owner of '%s'\n", (gchar *)key));
- res->owner = pthread_self();
+ res->owner = g_thread_self ();
res->have_owner = TRUE;
}
} else {
@@ -1795,7 +1792,7 @@ camel_object_bag_reserve(CamelObjectBag *bag, gconstpointer key)
res->waiters = 0;
res->key = bag->copy_key(key);
res->cond = g_cond_new();
- res->owner = pthread_self();
+ res->owner = g_thread_self ();
res->have_owner = TRUE;
res->next = bag->reserved;
bag->reserved = res;
diff --git a/camel/camel-object.h b/camel/camel-object.h
index 8b8ed08..e2e3f83 100644
--- a/camel/camel-object.h
+++ b/camel/camel-object.h
@@ -33,7 +33,6 @@
#include <stdio.h> /* FILE */
#include <stdlib.h> /* gsize */
#include <stdarg.h>
-#include <pthread.h>
#include <camel/camel-arg.h>
#include <camel/camel-exception.h>
diff --git a/camel/camel-operation.c b/camel/camel-operation.c
index e185ccb..8731ccb 100644
--- a/camel/camel-operation.c
+++ b/camel/camel-operation.c
@@ -24,7 +24,6 @@
#include <config.h>
#endif
-#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
@@ -52,7 +51,7 @@ struct _CamelOperation {
struct _CamelOperation *next;
struct _CamelOperation *prev;
- pthread_t id; /* id of running thread */
+ GThread *thread; /* running thread */
guint32 flags; /* cancelled ? */
gint blocked; /* cancellation blocked depth */
gint refcount;
@@ -78,31 +77,22 @@ struct _CamelOperation {
/* Delay before a transient operation has any effect on the status */
#define CAMEL_OPERATION_TRANSIENT_DELAY (5)
-static pthread_mutex_t operation_lock = PTHREAD_MUTEX_INITIALIZER;
-#define LOCK() pthread_mutex_lock(&operation_lock)
-#define UNLOCK() pthread_mutex_unlock(&operation_lock)
+static GStaticMutex operation_lock = G_STATIC_MUTEX_INIT;
+#define LOCK() g_static_mutex_lock(&operation_lock)
+#define UNLOCK() g_static_mutex_unlock(&operation_lock)
static guint stamp (void);
static CamelDList operation_list = CAMEL_DLIST_INITIALISER(operation_list);
-static pthread_key_t operation_key;
-static pthread_once_t operation_once = PTHREAD_ONCE_INIT;
+static GStaticPrivate operation_key = G_STATIC_PRIVATE_INIT;
typedef struct _CamelOperationMsg {
CamelMsg msg;
} CamelOperationMsg;
-static void
-co_createspecific(void)
-{
- pthread_key_create(&operation_key, NULL);
-}
-
static CamelOperation *
co_getcc(void)
{
- pthread_once(&operation_once, co_createspecific);
-
- return (CamelOperation *)pthread_getspecific(operation_key);
+ return (CamelOperation *)g_static_private_get (&operation_key);
}
/**
@@ -313,7 +303,7 @@ camel_operation_register (CamelOperation *cc)
{
CamelOperation *oldcc = co_getcc();
- pthread_setspecific(operation_key, cc);
+ g_static_private_set (&operation_key, cc, NULL);
return oldcc;
}
@@ -327,8 +317,7 @@ camel_operation_register (CamelOperation *cc)
void
camel_operation_unregister (CamelOperation *cc)
{
- pthread_once(&operation_once, co_createspecific);
- pthread_setspecific(operation_key, NULL);
+ g_static_private_set (&operation_key, NULL, NULL);
}
/**
@@ -346,7 +335,7 @@ camel_operation_cancel_check (CamelOperation *cc)
CamelOperationMsg *msg;
gint cancelled;
- d(printf("checking for cancel in thread %d\n", pthread_self()));
+ d(printf("checking for cancel in thread %p\n", g_thread_self()));
if (cc == NULL)
cc = co_getcc();
diff --git a/camel/camel-partition-table.c b/camel/camel-partition-table.c
index 9ea4bf3..62444df 100644
--- a/camel/camel-partition-table.c
+++ b/camel/camel-partition-table.c
@@ -44,11 +44,11 @@
#define k(x) /*(printf("%s(%d):%s: ", __FILE__, __LINE__, __PRETTY_FUNCTION__),(x))*/
struct _CamelPartitionTablePrivate {
- pthread_mutex_t lock; /* for locking partition */
+ GStaticMutex lock; /* for locking partition */
};
-#define CAMEL_PARTITION_TABLE_LOCK(kf, lock) (pthread_mutex_lock(&(kf)->priv->lock))
-#define CAMEL_PARTITION_TABLE_UNLOCK(kf, lock) (pthread_mutex_unlock(&(kf)->priv->lock))
+#define CAMEL_PARTITION_TABLE_LOCK(kf, lock) (g_static_mutex_lock(&(kf)->priv->lock))
+#define CAMEL_PARTITION_TABLE_UNLOCK(kf, lock) (g_static_mutex_unlock(&(kf)->priv->lock))
static void
camel_partition_table_class_init(CamelPartitionTableClass *klass)
@@ -63,7 +63,7 @@ camel_partition_table_init(CamelPartitionTable *cpi)
camel_dlist_init(&cpi->partition);
p = cpi->priv = g_malloc0(sizeof(*cpi->priv));
- pthread_mutex_init(&p->lock, NULL);
+ g_static_mutex_init (&p->lock);
}
static void
@@ -84,7 +84,7 @@ camel_partition_table_finalize(CamelPartitionTable *cpi)
camel_object_unref (cpi->blocks);
}
- pthread_mutex_destroy(&p->lock);
+ g_static_mutex_free (&p->lock);
g_free(p);
@@ -582,11 +582,11 @@ fail:
/* ********************************************************************** */
struct _CamelKeyTablePrivate {
- pthread_mutex_t lock; /* for locking key */
+ GStaticMutex lock; /* for locking key */
};
-#define CAMEL_KEY_TABLE_LOCK(kf, lock) (pthread_mutex_lock(&(kf)->priv->lock))
-#define CAMEL_KEY_TABLE_UNLOCK(kf, lock) (pthread_mutex_unlock(&(kf)->priv->lock))
+#define CAMEL_KEY_TABLE_LOCK(kf, lock) (g_static_mutex_lock(&(kf)->priv->lock))
+#define CAMEL_KEY_TABLE_UNLOCK(kf, lock) (g_static_mutex_unlock(&(kf)->priv->lock))
static void
camel_key_table_class_init(CamelKeyTableClass *klass)
@@ -599,7 +599,7 @@ camel_key_table_init(CamelKeyTable *ki)
struct _CamelKeyTablePrivate *p;
p = ki->priv = g_malloc0(sizeof(*ki->priv));
- pthread_mutex_init(&p->lock, NULL);
+ g_static_mutex_init (&p->lock);
}
static void
@@ -618,7 +618,7 @@ camel_key_table_finalize(CamelKeyTable *ki)
camel_object_unref (ki->blocks);
}
- pthread_mutex_destroy(&p->lock);
+ g_static_mutex_free (&p->lock);
g_free(p);
diff --git a/camel/camel-private.h b/camel/camel-private.h
index 9c1740b..4a5f8b6 100644
--- a/camel/camel-private.h
+++ b/camel/camel-private.h
@@ -31,7 +31,6 @@
#endif
#include <glib.h>
-#include <pthread.h>
G_BEGIN_DECLS
@@ -167,13 +166,13 @@ struct _CamelVeeFolderPrivate {
(g_mutex_unlock(((CamelVeeFolder *) (f))->priv->l))
struct _CamelDataWrapperPrivate {
- pthread_mutex_t stream_lock;
+ GStaticMutex stream_lock;
};
#define CAMEL_DATA_WRAPPER_LOCK(dw, l) \
- (pthread_mutex_lock(&((CamelDataWrapper *) (dw))->priv->l))
+ (g_static_mutex_lock(&((CamelDataWrapper *) (dw))->priv->l))
#define CAMEL_DATA_WRAPPER_UNLOCK(dw, l) \
- (pthread_mutex_unlock(&((CamelDataWrapper *) (dw))->priv->l))
+ (g_static_mutex_unlock(&((CamelDataWrapper *) (dw))->priv->l))
/* most of this stuff really is private, but the lock can be used by subordinate classes */
struct _CamelCertDBPrivate {
diff --git a/camel/camel-provider.c b/camel/camel-provider.c
index 49d270e..02fa28b 100644
--- a/camel/camel-provider.c
+++ b/camel/camel-provider.c
@@ -68,10 +68,10 @@ static CamelProvider vee_provider = {
/* ... */
};
-static pthread_once_t setup_once = PTHREAD_ONCE_INIT;
+static GOnce setup_once = G_ONCE_INIT;
-static void
-provider_setup(void)
+static gpointer
+provider_setup (gpointer param)
{
module_table = g_hash_table_new(camel_strcase_hash, camel_strcase_equal);
provider_table = g_hash_table_new(camel_strcase_hash, camel_strcase_equal);
@@ -80,6 +80,8 @@ provider_setup(void)
vee_provider.url_hash = camel_url_hash;
vee_provider.url_equal = camel_url_equal;
camel_provider_register(&vee_provider);
+
+ return NULL;
}
/**
@@ -105,7 +107,7 @@ camel_provider_init (void)
CamelProviderModule *m;
static gint loaded = 0;
- pthread_once(&setup_once, provider_setup);
+ g_once (&setup_once, provider_setup, NULL);
if (loaded)
return;
@@ -177,7 +179,7 @@ camel_provider_load (const gchar *path,
GModule *module;
CamelProvider *(*provider_module_init) (void);
- pthread_once(&setup_once, provider_setup);
+ g_once (&setup_once, provider_setup, NULL);
if (!g_module_supported ()) {
camel_exception_setv (
diff --git a/camel/camel-sasl-popb4smtp.c b/camel/camel-sasl-popb4smtp.c
index c0d0b18..442a430 100644
--- a/camel/camel-sasl-popb4smtp.c
+++ b/camel/camel-sasl-popb4smtp.c
@@ -24,7 +24,6 @@
#include <config.h>
#endif
-#include <pthread.h>
#include <string.h>
#include <time.h>
@@ -54,9 +53,9 @@ static GHashTable *poplast;
/* use 1 hour as our pop timeout */
#define POPB4SMTP_TIMEOUT (60*60)
-static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
-#define POPB4SMTP_LOCK(l) pthread_mutex_lock(&l)
-#define POPB4SMTP_UNLOCK(l) pthread_mutex_unlock(&l)
+static GStaticMutex lock = G_STATIC_MUTEX_INIT;
+#define POPB4SMTP_LOCK(l) g_static_mutex_lock(&l)
+#define POPB4SMTP_UNLOCK(l) g_static_mutex_unlock(&l)
static CamelSaslClass *parent_class = NULL;
diff --git a/camel/camel-service.c b/camel/camel-service.c
index 6b620f5..abbec77 100644
--- a/camel/camel-service.c
+++ b/camel/camel-service.c
@@ -29,7 +29,6 @@
#include <ctype.h>
#include <errno.h>
-#include <pthread.h>
#include <stdlib.h>
#include <string.h>
diff --git a/camel/camel-string-utils.c b/camel/camel-string-utils.c
index 6efe85c..0f0f11e 100644
--- a/camel/camel-string-utils.c
+++ b/camel/camel-string-utils.c
@@ -25,7 +25,6 @@
#endif
#include <string.h>
-#include <pthread.h>
#include "camel-string-utils.h"
@@ -139,7 +138,7 @@ gchar camel_toupper(gchar c)
}
/* working stuff for pstrings */
-static pthread_mutex_t pstring_lock = PTHREAD_MUTEX_INITIALIZER;
+static GStaticMutex pstring_lock = G_STATIC_MUTEX_INIT;
static GHashTable *pstring_table = NULL;
/**
@@ -170,7 +169,7 @@ camel_pstring_add (gchar *str, gboolean own)
return "";
}
- pthread_mutex_lock (&pstring_lock);
+ g_static_mutex_lock (&pstring_lock);
if (pstring_table == NULL)
pstring_table = g_hash_table_new (g_str_hash, g_str_equal);
@@ -184,7 +183,7 @@ camel_pstring_add (gchar *str, gboolean own)
g_hash_table_insert (pstring_table, pstr, GINT_TO_POINTER (1));
}
- pthread_mutex_unlock (&pstring_lock);
+ g_static_mutex_unlock (&pstring_lock);
return pstr;
}
@@ -215,7 +214,7 @@ camel_pstring_peek (const gchar *str)
return "";
}
- pthread_mutex_lock (&pstring_lock);
+ g_static_mutex_lock (&pstring_lock);
if (pstring_table == NULL)
pstring_table = g_hash_table_new (g_str_hash, g_str_equal);
@@ -224,7 +223,7 @@ camel_pstring_peek (const gchar *str)
g_hash_table_insert (pstring_table, pstr, GINT_TO_POINTER (1));
}
- pthread_mutex_unlock (&pstring_lock);
+ g_static_mutex_unlock (&pstring_lock);
return pstr;
}
@@ -268,7 +267,7 @@ camel_pstring_free(const gchar *s)
if (s == NULL || s[0] == 0)
return;
- pthread_mutex_lock(&pstring_lock);
+ g_static_mutex_lock (&pstring_lock);
if (g_hash_table_lookup_extended(pstring_table, s, (gpointer *)&p, &pcount)) {
count = GPOINTER_TO_INT(pcount)-1;
if (count == 0) {
@@ -288,5 +287,5 @@ camel_pstring_free(const gchar *s)
g_assert (0);
}
}
- pthread_mutex_unlock(&pstring_lock);
+ g_static_mutex_unlock (&pstring_lock);
}
diff --git a/camel/providers/imapx/camel-imapx-exception.c b/camel/providers/imapx/camel-imapx-exception.c
index e031baf..b13e8bf 100644
--- a/camel/providers/imapx/camel-imapx-exception.c
+++ b/camel/providers/imapx/camel-imapx-exception.c
@@ -7,13 +7,12 @@
#include "camel-imapx-exception.h"
-#include <pthread.h>
-
-static pthread_key_t handler_key = 0;
+static GStaticPrivate handler_key = G_STATIC_PRIVATE_INIT;
void camel_exception_setup(void)
{
- pthread_key_create(&handler_key, NULL);
+ /* No need for 'new' with GStaticPrivate */
+ /* g_static_private_new (&handler_key); */
}
void
@@ -21,12 +20,12 @@ camel_exception_try(struct _CamelExceptionEnv *env)
{
struct _CamelExceptionEnv *handler;
- handler = pthread_getspecific(handler_key);
+ handler = g_static_private_get (&handler_key);
env->parent = handler;
handler = env;
env->ex = NULL;
- pthread_setspecific(handler_key, handler);
+ g_static_private_set (&handler_key, handler, NULL);
}
void
@@ -36,10 +35,10 @@ camel_exception_throw_ex(CamelException *ex)
printf("throwing exception '%s'\n", ex->desc);
- env = pthread_getspecific(handler_key);
+ env = g_static_private_get (&handler_key);
if (env != NULL) {
env->ex = ex;
- pthread_setspecific(handler_key, env->parent);
+ g_static_private_set (&handler_key, env->parent, NULL);
longjmp(env->env, ex->id);
} else {
fprintf(stderr, "\nUncaught exception: %s\n", ex->desc);
@@ -67,13 +66,13 @@ camel_exception_throw(gint id, gchar *fmt, ...)
void
camel_exception_drop(struct _CamelExceptionEnv *env)
{
- pthread_setspecific(handler_key, env->parent);
+ g_static_private_set (&handler_key, env->parent, NULL);
}
void
camel_exception_done(struct _CamelExceptionEnv *env)
{
- pthread_setspecific(handler_key, env->parent);
+ g_static_private_set (&handler_key, env->parent, NULL);
if (env->ex != NULL) {
camel_exception_free(env->ex);
}
diff --git a/camel/providers/local/camel-local-private.h b/camel/providers/local/camel-local-private.h
index c958e92..2b3f7db 100644
--- a/camel/providers/local/camel-local-private.h
+++ b/camel/providers/local/camel-local-private.h
@@ -31,7 +31,6 @@
#endif
#include <glib.h>
-#include <pthread.h>
G_BEGIN_DECLS
diff --git a/camel/providers/nntp/camel-nntp-newsrc.c b/camel/providers/nntp/camel-nntp-newsrc.c
index 0167ea4..3be4004 100644
--- a/camel/providers/nntp/camel-nntp-newsrc.c
+++ b/camel/providers/nntp/camel-nntp-newsrc.c
@@ -26,7 +26,6 @@
#include <errno.h>
#include <fcntl.h>
-#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/camel/tests/folder/test10.c b/camel/tests/folder/test10.c
index 1cc00e1..ad41cad 100644
--- a/camel/tests/folder/test10.c
+++ b/camel/tests/folder/test10.c
@@ -1,7 +1,6 @@
/* threaded folder testing */
#include <string.h>
-#include <pthread.h>
#include "camel-test.h"
#include "camel-test-provider.h"
@@ -56,7 +55,7 @@ gint main(gint argc, gchar **argv)
{
CamelException *ex;
gint i, j;
- pthread_t threads[MAX_THREADS];
+ GThread *threads[MAX_THREADS];
camel_test_init(argc, argv);
camel_test_provider_init(1, local_drivers);
@@ -79,11 +78,19 @@ gint main(gint argc, gchar **argv)
camel_test_push("provider %s", local_providers[j]);
path = g_strdup_printf("%s:///tmp/camel-test/%s", local_providers[j], local_providers[j]);
- for (i=0;i<MAX_THREADS;i++)
- pthread_create(&threads[i], 0, worker, NULL);
+ for (i = 0; i < MAX_THREADS; i++) {
+ GError *error = NULL;
- for (i=0;i<MAX_THREADS;i++)
- pthread_join(threads[i], NULL);
+ threads[i] = g_thread_create (worker, NULL, TRUE, &error);
+ if (error) {
+ fprintf (stderr, "%s: Failed to create a thread: %s\n", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
+ }
+
+ for (i = 0; i < MAX_THREADS; i++) {
+ if (threads[i])
+ g_thread_join (threads[i]);
test_free(path);
diff --git a/camel/tests/folder/test11.c b/camel/tests/folder/test11.c
index 8ef40f9..9875667 100644
--- a/camel/tests/folder/test11.c
+++ b/camel/tests/folder/test11.c
@@ -2,7 +2,6 @@
/* threaded folder testing */
#include <string.h>
-#include <pthread.h>
#include "camel-test.h"
#include "camel-test-provider.h"
diff --git a/camel/tests/folder/test8.c b/camel/tests/folder/test8.c
index 1368d18..e50ae24 100644
--- a/camel/tests/folder/test8.c
+++ b/camel/tests/folder/test8.c
@@ -1,7 +1,6 @@
/* threaded folder testing */
#include <string.h>
-#include <pthread.h>
#include "camel-test.h"
#include "camel-test-provider.h"
@@ -68,7 +67,7 @@ worker(gpointer d)
/* we add a message, search for it, twiddle some flags, delete it */
/* and flat out */
for (i=0;i<MAX_MESSAGES;i++) {
- d(printf("Thread %ld message %i\n", pthread_self(), i));
+ d(printf ("Thread %p message %i\n", g_thread_self (), i));
test_add_message(info->folder, id+i);
sub = g_strdup_printf("(match-all (header-contains \"subject\" \"message %08x subject\"))", id+i);
@@ -126,7 +125,7 @@ gint main(gint argc, gchar **argv)
gint i, j, index;
gchar *path;
CamelStore *store;
- pthread_t threads[MAX_THREADS];
+ GThread *threads[MAX_THREADS];
struct _threadinfo *info;
CamelFolder *folder;
GPtrArray *uids;
@@ -160,16 +159,25 @@ gint main(gint argc, gchar **argv)
CAMEL_STORE_FOLDER_CREATE|CAMEL_STORE_FOLDER_BODY_INDEX, ex);
check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
- for (i=0;i<MAX_THREADS;i++) {
+ for (i = 0; i < MAX_THREADS; i++) {
+ GError *error = NULL;
+
info = g_malloc(sizeof(*info));
info->id = i*MAX_MESSAGES;
info->folder = folder;
- pthread_create(&threads[i], 0, worker, info);
+
+ threads[i] = g_thread_create (worker, info, TRUE, &error);
+ if (error) {
+ fprintf (stderr, "%s: Failed to create a thread: %s\n", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
}
- for (i=0;i<MAX_THREADS;i++) {
- pthread_join(threads[i], (gpointer *)&info);
- g_free(info);
+ for (i = 0; i < MAX_THREADS; i++) {
+ if (threads[i]) {
+ info = g_thread_join (threads[i]);
+ g_free (info);
+ }
}
pull();
diff --git a/camel/tests/lib/camel-test.c b/camel/tests/lib/camel-test.c
index fa0aaa8..e289bf4 100644
--- a/camel/tests/lib/camel-test.c
+++ b/camel/tests/lib/camel-test.c
@@ -5,7 +5,6 @@
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <pthread.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
@@ -13,14 +12,10 @@
/* well i dunno, doesn't seem to be in the headers but hte manpage mentions it */
/* a nonportable checking mutex for glibc, not really needed, just validates
the test harness really */
-# ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
-static pthread_mutex_t lock = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
-# else
-static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
-# endif
-#define CAMEL_TEST_LOCK pthread_mutex_lock(&lock)
-#define CAMEL_TEST_UNLOCK pthread_mutex_unlock(&lock)
-#define CAMEL_TEST_ID (pthread_self())
+static GStaticMutex lock = G_STATIC_MUTEX_INIT;
+#define CAMEL_TEST_LOCK g_static_mutex_lock(&lock)
+#define CAMEL_TEST_UNLOCK g_static_mutex_unlock(&lock)
+#define CAMEL_TEST_ID (g_thread_self())
static gint setup;
static gint ok;
@@ -43,11 +38,11 @@ static GHashTable *info_table;
gint camel_test_verbose;
static void
-dump_action(gint id, struct _state *s, gpointer d)
+dump_action (GThread *thread, struct _state *s, gpointer d)
{
struct _stack *node;
- printf("\nThread %d:\n", id);
+ printf("\nThread %p:\n", thread);
node = s->state;
if (node) {
@@ -86,10 +81,10 @@ current_state(void)
if (info_table == NULL)
info_table = g_hash_table_new(0, 0);
- info = g_hash_table_lookup(info_table, (gpointer)CAMEL_TEST_ID);
+ info = g_hash_table_lookup(info_table, CAMEL_TEST_ID);
if (info == NULL) {
info = g_malloc0(sizeof(*info));
- g_hash_table_insert(info_table, (gpointer)CAMEL_TEST_ID, info);
+ g_hash_table_insert(info_table, CAMEL_TEST_ID, info);
}
return info;
}
diff --git a/configure.ac b/configure.ac
index cf26184..898c0f4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -597,7 +597,7 @@ dnl check if pkg-config files exist (which are only shipped by distributions, no
CFLAGS_save="$CFLAGS"
LDFLAGS_save="$LDFLAGS"
LIBS_save="$LIBS"
- nsprlibs="$DL_LIB -lplc4 -lplds4 -lnspr4 $PTHREAD_LIB"
+ nsprlibs="$DL_LIB -lplc4 -lplds4 -lnspr4"
CFLAGS="$CFLAGS $MANUAL_NSPR_CFLAGS"
LIBS="$nsprlibs"
@@ -1119,23 +1119,6 @@ dnl ******************************
dnl Posix thread support
dnl ******************************
-dnl GLIB_CONFIG=${GLIB_CONFIG-glib-config}
-dnl GNOME_PTHREAD_CHECK
-
-dnl if test "x$PTHREAD_LIB" = "x" ; then
-dnl AC_MSG_ERROR([POSIX threads are currently required for Evolution])
-dnl fi
-
-dnl Notice that this is a hack, and we wont be able to use this forever, but
-dnl at least for some time
-
-EVO_PTHREAD_CHECK
-
-THREADS_LIBS="$PTHREAD_LIB"
-THREADS_CFLAGS="$PTHREAD_CFLAGS"
-
-AC_SUBST(THREADS_LIBS)
-AC_SUBST(THREADS_CFLAGS)
AC_DEFINE(ENABLE_THREADS,1,[Required])
dnl ******************************
@@ -1183,7 +1166,7 @@ dnl libedataserver flags
dnl ******************************
E_DATA_SERVER_DEPS="libxml-2.0 gthread-2.0 libsoup-2.4 gconf-2.0 $mozilla_nspr"
-EVO_SET_COMPILE_FLAGS(E_DATA_SERVER, $E_DATA_SERVER_DEPS, $THREADS_CFLAGS $MANUAL_NSPR_CFLAGS, $THREADS_LIBS $MANUAL_NSPR_LIBS)
+EVO_SET_COMPILE_FLAGS(E_DATA_SERVER, $E_DATA_SERVER_DEPS, $MANUAL_NSPR_CFLAGS, $MANUAL_NSPR_LIBS)
AC_SUBST(E_DATA_SERVER_CFLAGS)
AC_SUBST(E_DATA_SERVER_LIBS)
@@ -1192,7 +1175,7 @@ dnl libedataserverui
dnl ******************************
E_DATA_SERVER_UI_DEPS="gtk+-2.0 libxml-2.0 gobject-2.0 gthread-2.0 gconf-2.0 $GNOME_KEYRING_REQUIREMENT"
-EVO_SET_COMPILE_FLAGS(E_DATA_SERVER_UI, $E_DATA_SERVER_UI_DEPS, $THREADS_CFLAGS, $THREADS_LIBS)
+EVO_SET_COMPILE_FLAGS(E_DATA_SERVER_UI, $E_DATA_SERVER_UI_DEPS, , )
AC_SUBST(E_DATA_SERVER_UI_CFLAGS)
AC_SUBST(E_DATA_SERVER_UI_LIBS)
@@ -1322,7 +1305,7 @@ fi
AM_CONDITIONAL(ENABLE_LARGEFILE, [test "x$enable_largefile" = "xyes"])
-EVO_SET_COMPILE_FLAGS(CAMEL, $mozilla_nss gio-2.0 sqlite3 >= sqlite_minimum_version gthread-2.0, $THREADS_CFLAGS $KRB5_CFLAGS $MANUAL_NSS_CFLAGS $LARGEFILE_CFLAGS, -lz $THREADS_LIBS $KRB5_LIBS $MANUAL_NSS_LIBS)
+EVO_SET_COMPILE_FLAGS(CAMEL, $mozilla_nss gio-2.0 sqlite3 >= sqlite_minimum_version gthread-2.0, $KRB5_CFLAGS $MANUAL_NSS_CFLAGS $LARGEFILE_CFLAGS, -lz $KRB5_LIBS $MANUAL_NSS_LIBS)
AC_SUBST(CAMEL_CFLAGS)
AC_SUBST(CAMEL_LIBS)
AC_SUBST(CAMEL_GROUPWISE_CFLAGS)
diff --git a/libedataserver/e-data-server-util.c b/libedataserver/e-data-server-util.c
index cb2f780..f4a95f1 100644
--- a/libedataserver/e-data-server-util.c
+++ b/libedataserver/e-data-server-util.c
@@ -398,23 +398,17 @@ e_utf8_strftime(gchar *s, gsize max, const gchar *fmt, const struct tm *tm)
}
/**
- * e_util_pthread_id:
- * @t: A pthread_t value
+ * e_util_gthread_id:
+ * @thread: A #GThread pointer
*
* Returns a 64-bit integer hopefully uniquely identifying the
- * thread. To be used in debugging output and logging only. To test
- * whether two pthread_t values refer to the same thread, use
- * pthread_equal().
+ * thread. To be used in debugging output and logging only.
+ * The returned value is just a cast of a pointer to the 64-bit integer.
*
- * There is no guarantee that calling e_util_pthread_id() on one
+ * There is no guarantee that calling e_util_gthread_id() on one
* thread first and later after that thread has dies on another won't
* return the same integer.
*
- * On some platforms it might even be that when called two times on
- * the same thread's pthread_t (with some pthread API calls inbetween)
- * we will return different values (this of course makes this function
- * rather useless on such platforms).
- *
* On Linux and Win32, known to really return a unique id for each
* thread existing at a certain time. No guarantee that ids won't be
* reused after a thread has terminated, though.
@@ -422,35 +416,13 @@ e_utf8_strftime(gchar *s, gsize max, const gchar *fmt, const struct tm *tm)
* Returns: A 64-bit integer.
*/
guint64
-e_util_pthread_id (pthread_t t)
+e_util_gthread_id (GThread *thread)
{
-#ifdef HAVE_GUINT64_CASTABLE_PTHREAD_T
- /* We know that pthread_t is an integral type, or at least
- * castable to such without loss of precision.
- */
- return (guint64) t;
-#elif defined (PTW32_VERSION)
- /* pthreads-win32 implementation on Windows: Return the
- * pointer to the "actual object" (see pthread.h)
- */
#if GLIB_SIZEOF_VOID_P == 8
/* 64-bit Windows */
- return (guint64) t.p;
-#else
- return (gint) t.p;
-#endif
+ return (guint64) thread;
#else
- /* Just return a checksum of the contents of the pthread_t */
- {
- guint64 retval = 0;
- guchar *const tend = (guchar *) ((&t)+1);
- guchar *tp = (guchar *) &t;
-
- while (tp < tend)
- retval = (retval << 5) - retval * *tp++;
-
- return retval;
- }
+ return (gint) thread;
#endif
}
diff --git a/libedataserver/e-data-server-util.h b/libedataserver/e-data-server-util.h
index 45eed67..8c1139f 100644
--- a/libedataserver/e-data-server-util.h
+++ b/libedataserver/e-data-server-util.h
@@ -22,7 +22,6 @@
#ifndef __E_DATA_SERVER_UTIL_H__
#define __E_DATA_SERVER_UTIL_H__
-#include <pthread.h>
#include <sys/types.h>
#include <glib.h>
@@ -36,7 +35,7 @@ const gchar *e_util_utf8_strstrcase (const gchar *haystack, const gchar *needle)
const gchar *e_util_utf8_strstrcasedecomp (const gchar *haystack, const gchar *needle);
gint e_util_utf8_strcasecmp (const gchar *s1, const gchar *s2);
gchar *e_util_utf8_remove_accents (const gchar *str);
-guint64 e_util_pthread_id (pthread_t t);
+guint64 e_util_gthread_id (GThread *thread);
void e_filename_make_safe (gchar *string);
gsize e_utf8_strftime(gchar *s, gsize max, const gchar *fmt, const struct tm *tm);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]