From 82ab77c8f7b3f7969826ffc88c6349a5f7be9daf Mon Sep 17 00:00:00 2001 From: Sebastian Wilhelmi Date: Mon, 13 Nov 2000 12:50:16 +0000 Subject: [PATCH] Made recursive mutexes also work when the thread system is not (yet) 2000-11-13 Sebastian Wilhelmi * gthread.c (g_static_rec_mutex_*): Made recursive mutexes also work when the thread system is not (yet) initialized. --- ChangeLog | 5 +++++ ChangeLog.pre-2-0 | 5 +++++ ChangeLog.pre-2-10 | 5 +++++ ChangeLog.pre-2-12 | 5 +++++ ChangeLog.pre-2-2 | 5 +++++ ChangeLog.pre-2-4 | 5 +++++ ChangeLog.pre-2-6 | 5 +++++ ChangeLog.pre-2-8 | 5 +++++ glib/gthread.c | 19 ++++++++++++++++++- gthread.c | 19 ++++++++++++++++++- 10 files changed, 76 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 446be0f2b..465e222cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2000-11-13 Sebastian Wilhelmi + + * gthread.c (g_static_rec_mutex_*): Made recursive mutexes also + work when the thread system is not (yet) initialized. + Sun Nov 12 18:34:32 2000 Owen Taylor * gconvert.[ch]: Create wrapper functions for iconv() diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 446be0f2b..465e222cc 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,8 @@ +2000-11-13 Sebastian Wilhelmi + + * gthread.c (g_static_rec_mutex_*): Made recursive mutexes also + work when the thread system is not (yet) initialized. + Sun Nov 12 18:34:32 2000 Owen Taylor * gconvert.[ch]: Create wrapper functions for iconv() diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 446be0f2b..465e222cc 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,8 @@ +2000-11-13 Sebastian Wilhelmi + + * gthread.c (g_static_rec_mutex_*): Made recursive mutexes also + work when the thread system is not (yet) initialized. + Sun Nov 12 18:34:32 2000 Owen Taylor * gconvert.[ch]: Create wrapper functions for iconv() diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 446be0f2b..465e222cc 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,8 @@ +2000-11-13 Sebastian Wilhelmi + + * gthread.c (g_static_rec_mutex_*): Made recursive mutexes also + work when the thread system is not (yet) initialized. + Sun Nov 12 18:34:32 2000 Owen Taylor * gconvert.[ch]: Create wrapper functions for iconv() diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 446be0f2b..465e222cc 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,8 @@ +2000-11-13 Sebastian Wilhelmi + + * gthread.c (g_static_rec_mutex_*): Made recursive mutexes also + work when the thread system is not (yet) initialized. + Sun Nov 12 18:34:32 2000 Owen Taylor * gconvert.[ch]: Create wrapper functions for iconv() diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 446be0f2b..465e222cc 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,8 @@ +2000-11-13 Sebastian Wilhelmi + + * gthread.c (g_static_rec_mutex_*): Made recursive mutexes also + work when the thread system is not (yet) initialized. + Sun Nov 12 18:34:32 2000 Owen Taylor * gconvert.[ch]: Create wrapper functions for iconv() diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 446be0f2b..465e222cc 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,8 @@ +2000-11-13 Sebastian Wilhelmi + + * gthread.c (g_static_rec_mutex_*): Made recursive mutexes also + work when the thread system is not (yet) initialized. + Sun Nov 12 18:34:32 2000 Owen Taylor * gconvert.[ch]: Create wrapper functions for iconv() diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 446be0f2b..465e222cc 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,8 @@ +2000-11-13 Sebastian Wilhelmi + + * gthread.c (g_static_rec_mutex_*): Made recursive mutexes also + work when the thread system is not (yet) initialized. + Sun Nov 12 18:34:32 2000 Owen Taylor * gconvert.[ch]: Create wrapper functions for iconv() diff --git a/glib/gthread.c b/glib/gthread.c index 034e7716d..8f03a2988 100644 --- a/glib/gthread.c +++ b/glib/gthread.c @@ -166,6 +166,9 @@ g_static_rec_mutex_lock (GStaticRecMutex* mutex) g_return_if_fail (mutex); + if (!g_thread_supported ()) + return; + G_THREAD_UF (thread_self, (&self)); if (g_system_thread_equal (self, mutex->owner)) @@ -185,6 +188,9 @@ g_static_rec_mutex_trylock (GStaticRecMutex* mutex) g_return_val_if_fail (mutex, FALSE); + if (!g_thread_supported ()) + return TRUE; + G_THREAD_UF (thread_self, (&self)); if (g_system_thread_equal (self, mutex->owner)) @@ -206,6 +212,9 @@ g_static_rec_mutex_unlock (GStaticRecMutex* mutex) { g_return_if_fail (mutex); + if (!g_thread_supported ()) + return; + if (mutex->depth > 1) { mutex->depth--; @@ -221,6 +230,9 @@ g_static_rec_mutex_lock_full (GStaticRecMutex *mutex, { g_return_if_fail (mutex); + if (!g_thread_supported ()) + return; + g_static_mutex_lock (&mutex->mutex); G_THREAD_UF (thread_self, (&mutex->owner)); mutex->depth = depth; @@ -229,10 +241,15 @@ g_static_rec_mutex_lock_full (GStaticRecMutex *mutex, guint g_static_rec_mutex_unlock_full (GStaticRecMutex *mutex) { - gint depth = mutex->depth; + gint depth; g_return_val_if_fail (mutex, 0); + if (!g_thread_supported ()) + return 1; + + depth = mutex->depth; + g_system_thread_assign (mutex->owner, zero_thread); mutex->depth = 0; g_static_mutex_unlock (&mutex->mutex); diff --git a/gthread.c b/gthread.c index 034e7716d..8f03a2988 100644 --- a/gthread.c +++ b/gthread.c @@ -166,6 +166,9 @@ g_static_rec_mutex_lock (GStaticRecMutex* mutex) g_return_if_fail (mutex); + if (!g_thread_supported ()) + return; + G_THREAD_UF (thread_self, (&self)); if (g_system_thread_equal (self, mutex->owner)) @@ -185,6 +188,9 @@ g_static_rec_mutex_trylock (GStaticRecMutex* mutex) g_return_val_if_fail (mutex, FALSE); + if (!g_thread_supported ()) + return TRUE; + G_THREAD_UF (thread_self, (&self)); if (g_system_thread_equal (self, mutex->owner)) @@ -206,6 +212,9 @@ g_static_rec_mutex_unlock (GStaticRecMutex* mutex) { g_return_if_fail (mutex); + if (!g_thread_supported ()) + return; + if (mutex->depth > 1) { mutex->depth--; @@ -221,6 +230,9 @@ g_static_rec_mutex_lock_full (GStaticRecMutex *mutex, { g_return_if_fail (mutex); + if (!g_thread_supported ()) + return; + g_static_mutex_lock (&mutex->mutex); G_THREAD_UF (thread_self, (&mutex->owner)); mutex->depth = depth; @@ -229,10 +241,15 @@ g_static_rec_mutex_lock_full (GStaticRecMutex *mutex, guint g_static_rec_mutex_unlock_full (GStaticRecMutex *mutex) { - gint depth = mutex->depth; + gint depth; g_return_val_if_fail (mutex, 0); + if (!g_thread_supported ()) + return 1; + + depth = mutex->depth; + g_system_thread_assign (mutex->owner, zero_thread); mutex->depth = 0; g_static_mutex_unlock (&mutex->mutex);