From 1f46d9f68f5b98262c07c2e4e15771655aad84db Mon Sep 17 00:00:00 2001 From: Sebastian Wilhelmi Date: Tue, 30 Jan 2001 09:03:22 +0000 Subject: [PATCH] Added debug information for g_mutex_free calls, if G_ERRORCHECK_MUTEXES is 2001-01-30 Sebastian Wilhelmi * gthread.h (g_cond_wait): Added debug information for g_mutex_free calls, if G_ERRORCHECK_MUTEXES is defined. * gthread/gthread-impl.c (g_mutex_free_errorcheck_impl): Fixed it for real. Sorry for this mess. It looked like a real obvious fix, so I didn't check. Bad boy. Added some casts to quiet the compiler. --- 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.h | 35 +++++++++++++++++++---------------- gthread.h | 35 +++++++++++++++++++---------------- gthread/ChangeLog | 6 ++++++ gthread/gthread-impl.c | 21 +++++++++++++++------ 12 files changed, 99 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3839b56..21b6946 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-01-30 Sebastian Wilhelmi + + * gthread.h (g_cond_wait): Added debug information for + g_mutex_free calls, if G_ERRORCHECK_MUTEXES is defined. + 2001-01-29 Tor Lillqvist * glibconfig.h.win32.in: Use the same GMutex structure as the diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 3839b56..21b6946 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,8 @@ +2001-01-30 Sebastian Wilhelmi + + * gthread.h (g_cond_wait): Added debug information for + g_mutex_free calls, if G_ERRORCHECK_MUTEXES is defined. + 2001-01-29 Tor Lillqvist * glibconfig.h.win32.in: Use the same GMutex structure as the diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 3839b56..21b6946 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,8 @@ +2001-01-30 Sebastian Wilhelmi + + * gthread.h (g_cond_wait): Added debug information for + g_mutex_free calls, if G_ERRORCHECK_MUTEXES is defined. + 2001-01-29 Tor Lillqvist * glibconfig.h.win32.in: Use the same GMutex structure as the diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 3839b56..21b6946 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,8 @@ +2001-01-30 Sebastian Wilhelmi + + * gthread.h (g_cond_wait): Added debug information for + g_mutex_free calls, if G_ERRORCHECK_MUTEXES is defined. + 2001-01-29 Tor Lillqvist * glibconfig.h.win32.in: Use the same GMutex structure as the diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 3839b56..21b6946 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,8 @@ +2001-01-30 Sebastian Wilhelmi + + * gthread.h (g_cond_wait): Added debug information for + g_mutex_free calls, if G_ERRORCHECK_MUTEXES is defined. + 2001-01-29 Tor Lillqvist * glibconfig.h.win32.in: Use the same GMutex structure as the diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 3839b56..21b6946 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,8 @@ +2001-01-30 Sebastian Wilhelmi + + * gthread.h (g_cond_wait): Added debug information for + g_mutex_free calls, if G_ERRORCHECK_MUTEXES is defined. + 2001-01-29 Tor Lillqvist * glibconfig.h.win32.in: Use the same GMutex structure as the diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 3839b56..21b6946 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,8 @@ +2001-01-30 Sebastian Wilhelmi + + * gthread.h (g_cond_wait): Added debug information for + g_mutex_free calls, if G_ERRORCHECK_MUTEXES is defined. + 2001-01-29 Tor Lillqvist * glibconfig.h.win32.in: Use the same GMutex structure as the diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 3839b56..21b6946 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,8 @@ +2001-01-30 Sebastian Wilhelmi + + * gthread.h (g_cond_wait): Added debug information for + g_mutex_free calls, if G_ERRORCHECK_MUTEXES is defined. + 2001-01-29 Tor Lillqvist * glibconfig.h.win32.in: Use the same GMutex structure as the diff --git a/glib/gthread.h b/glib/gthread.h index 1268178..d6f408b 100644 --- a/glib/gthread.h +++ b/glib/gthread.h @@ -147,7 +147,7 @@ GMutex* g_static_mutex_get_mutex_impl (GMutex **mutex); #define G_THREAD_UF(op, arglist) \ (*g_thread_functions_for_glib_use . op) arglist -#define G_THREAD_CF(op, fail, arg) \ +#define G_THREAD_CF(op, fail, arg) \ (g_thread_supported () ? G_THREAD_UF (op, arg) : (fail)) #define G_THREAD_ECF(op, fail, mutex, type) \ (g_thread_supported () ? ((type(*)(GMutex*, gulong, gchar*)) \ @@ -155,37 +155,40 @@ GMutex* g_static_mutex_get_mutex_impl (GMutex **mutex); (mutex, G_MUTEX_DEBUG_MAGIC, G_STRLOC) : (fail)) #ifndef G_ERRORCHECK_MUTEXES -# define g_mutex_lock(mutex) \ +# define g_mutex_lock(mutex) \ G_THREAD_CF (mutex_lock, (void)0, (mutex)) -# define g_mutex_trylock(mutex) \ +# define g_mutex_trylock(mutex) \ G_THREAD_CF (mutex_trylock, TRUE, (mutex)) -# define g_mutex_unlock(mutex) \ +# define g_mutex_unlock(mutex) \ G_THREAD_CF (mutex_unlock, (void)0, (mutex)) -# define g_cond_wait(cond, mutex) \ +# define g_mutex_free(mutex) \ + G_THREAD_CF (mutex_free, (void)0, (mutex)) +# define g_cond_wait(cond, mutex) \ G_THREAD_CF (cond_wait, (void)0, (cond, mutex)) -# define g_cond_timed_wait(cond, mutex, abs_time) \ +# define g_cond_timed_wait(cond, mutex, abs_time) \ G_THREAD_CF (cond_timed_wait, TRUE, (cond, mutex, abs_time)) #else /* G_ERRORCHECK_MUTEXES */ -# define g_mutex_lock(mutex) \ - G_THREAD_ECF (mutex_lock, (void)0, mutex, void) -# define g_mutex_trylock(mutex) \ - G_THREAD_ECF (mutex_trylock, TRUE, mutex, gboolean) -# define g_mutex_unlock(mutex) \ - G_THREAD_ECF (mutex_unlock, (void)0, mutex, void) +# define g_mutex_lock(mutex) \ + G_THREAD_ECF (mutex_lock, (void)0, (mutex), void) +# define g_mutex_trylock(mutex) \ + G_THREAD_ECF (mutex_trylock, TRUE, (mutex), gboolean) +# define g_mutex_unlock(mutex) \ + G_THREAD_ECF (mutex_unlock, (void)0, (mutex), void) +# define g_mutex_free(mutex) \ + G_THREAD_ECF (mutex_free, (void)0, (mutex), void) # define g_cond_wait(cond, mutex) \ (g_thread_supported () ? ((void(*)(GCond*, GMutex*, gulong, gchar*))\ g_thread_functions_for_glib_use.cond_wait) \ (cond, mutex, G_MUTEX_DEBUG_MAGIC, G_STRLOC) : (void) 0) -# define g_cond_timed_wait(cond, mutex, abs_time) \ - (g_thread_supported () ? \ +# define g_cond_timed_wait(cond, mutex, abs_time) \ + (g_thread_supported () ? \ ((gboolean(*)(GCond*, GMutex*, GTimeVal*, gulong, gchar*)) \ - g_thread_functions_for_glib_use.cond_timed_wait) \ + g_thread_functions_for_glib_use.cond_timed_wait) \ (cond, mutex, abs_time, G_MUTEX_DEBUG_MAGIC, G_STRLOC) : TRUE) #endif /* G_ERRORCHECK_MUTEXES */ #define g_thread_supported() (g_threads_got_initialized) #define g_mutex_new() G_THREAD_UF (mutex_new, ()) -#define g_mutex_free(mutex) G_THREAD_CF (mutex_free, (void)0, (mutex)) #define g_cond_new() G_THREAD_UF (cond_new, ()) #define g_cond_signal(cond) G_THREAD_CF (cond_signal, (void)0, (cond)) #define g_cond_broadcast(cond) G_THREAD_CF (cond_broadcast, (void)0, (cond)) diff --git a/gthread.h b/gthread.h index 1268178..d6f408b 100644 --- a/gthread.h +++ b/gthread.h @@ -147,7 +147,7 @@ GMutex* g_static_mutex_get_mutex_impl (GMutex **mutex); #define G_THREAD_UF(op, arglist) \ (*g_thread_functions_for_glib_use . op) arglist -#define G_THREAD_CF(op, fail, arg) \ +#define G_THREAD_CF(op, fail, arg) \ (g_thread_supported () ? G_THREAD_UF (op, arg) : (fail)) #define G_THREAD_ECF(op, fail, mutex, type) \ (g_thread_supported () ? ((type(*)(GMutex*, gulong, gchar*)) \ @@ -155,37 +155,40 @@ GMutex* g_static_mutex_get_mutex_impl (GMutex **mutex); (mutex, G_MUTEX_DEBUG_MAGIC, G_STRLOC) : (fail)) #ifndef G_ERRORCHECK_MUTEXES -# define g_mutex_lock(mutex) \ +# define g_mutex_lock(mutex) \ G_THREAD_CF (mutex_lock, (void)0, (mutex)) -# define g_mutex_trylock(mutex) \ +# define g_mutex_trylock(mutex) \ G_THREAD_CF (mutex_trylock, TRUE, (mutex)) -# define g_mutex_unlock(mutex) \ +# define g_mutex_unlock(mutex) \ G_THREAD_CF (mutex_unlock, (void)0, (mutex)) -# define g_cond_wait(cond, mutex) \ +# define g_mutex_free(mutex) \ + G_THREAD_CF (mutex_free, (void)0, (mutex)) +# define g_cond_wait(cond, mutex) \ G_THREAD_CF (cond_wait, (void)0, (cond, mutex)) -# define g_cond_timed_wait(cond, mutex, abs_time) \ +# define g_cond_timed_wait(cond, mutex, abs_time) \ G_THREAD_CF (cond_timed_wait, TRUE, (cond, mutex, abs_time)) #else /* G_ERRORCHECK_MUTEXES */ -# define g_mutex_lock(mutex) \ - G_THREAD_ECF (mutex_lock, (void)0, mutex, void) -# define g_mutex_trylock(mutex) \ - G_THREAD_ECF (mutex_trylock, TRUE, mutex, gboolean) -# define g_mutex_unlock(mutex) \ - G_THREAD_ECF (mutex_unlock, (void)0, mutex, void) +# define g_mutex_lock(mutex) \ + G_THREAD_ECF (mutex_lock, (void)0, (mutex), void) +# define g_mutex_trylock(mutex) \ + G_THREAD_ECF (mutex_trylock, TRUE, (mutex), gboolean) +# define g_mutex_unlock(mutex) \ + G_THREAD_ECF (mutex_unlock, (void)0, (mutex), void) +# define g_mutex_free(mutex) \ + G_THREAD_ECF (mutex_free, (void)0, (mutex), void) # define g_cond_wait(cond, mutex) \ (g_thread_supported () ? ((void(*)(GCond*, GMutex*, gulong, gchar*))\ g_thread_functions_for_glib_use.cond_wait) \ (cond, mutex, G_MUTEX_DEBUG_MAGIC, G_STRLOC) : (void) 0) -# define g_cond_timed_wait(cond, mutex, abs_time) \ - (g_thread_supported () ? \ +# define g_cond_timed_wait(cond, mutex, abs_time) \ + (g_thread_supported () ? \ ((gboolean(*)(GCond*, GMutex*, GTimeVal*, gulong, gchar*)) \ - g_thread_functions_for_glib_use.cond_timed_wait) \ + g_thread_functions_for_glib_use.cond_timed_wait) \ (cond, mutex, abs_time, G_MUTEX_DEBUG_MAGIC, G_STRLOC) : TRUE) #endif /* G_ERRORCHECK_MUTEXES */ #define g_thread_supported() (g_threads_got_initialized) #define g_mutex_new() G_THREAD_UF (mutex_new, ()) -#define g_mutex_free(mutex) G_THREAD_CF (mutex_free, (void)0, (mutex)) #define g_cond_new() G_THREAD_UF (cond_new, ()) #define g_cond_signal(cond) G_THREAD_CF (cond_signal, (void)0, (cond)) #define g_cond_broadcast(cond) G_THREAD_CF (cond_broadcast, (void)0, (cond)) diff --git a/gthread/ChangeLog b/gthread/ChangeLog index 7b66732..d6878da 100644 --- a/gthread/ChangeLog +++ b/gthread/ChangeLog @@ -1,3 +1,9 @@ +2001-01-30 Sebastian Wilhelmi + + * gthread-impl.c (g_mutex_free_errorcheck_impl): Fixed it for + real. Sorry for this mess. It looked like a real obvious fix, so I + didn't check. Bad boy. Added some casts to quiet the compiler. + 2001-01-29 Havoc Pennington * gthread-impl.c (g_mutex_free_errorcheck_impl): hack this so it diff --git a/gthread/gthread-impl.c b/gthread/gthread-impl.c index 5c87b08..8e5e69a 100644 --- a/gthread/gthread-impl.c +++ b/gthread/gthread-impl.c @@ -179,14 +179,19 @@ g_mutex_unlock_errorcheck_impl (GMutex *mutex, } static void -g_mutex_free_errorcheck_impl (GMutex *mutex) +g_mutex_free_errorcheck_impl (GMutex *mutex, + gulong magic, + gchar *location) { ErrorCheckInfo *info = G_MUTEX_DEBUG_INFO (mutex); + if (magic != G_MUTEX_DEBUG_MAGIC) + location = "unknown"; + if (info && info->owner != NULL) g_error ("Trying to free a locked mutex at '%s', " "which was previously locked at '%s'", - "FIXME", info->location); + location, info->location); g_free (G_MUTEX_DEBUG_INFO (mutex)); g_thread_functions_for_glib_use_default.mutex_free (mutex); @@ -259,7 +264,7 @@ g_cond_timed_wait_errorcheck_impl (GCond *cond, } -/* unshadow function declaration. See glib.h */ +/* unshadow function declaration. See gthread.h */ #undef g_thread_init void @@ -277,9 +282,13 @@ g_thread_init_with_errorcheck_mutexes (GThreadFunctions* init) (gboolean (*)(GMutex *)) g_mutex_trylock_errorcheck_impl; errorcheck_functions.mutex_unlock = (void (*)(GMutex *)) g_mutex_unlock_errorcheck_impl; - errorcheck_functions.mutex_free = g_mutex_free_errorcheck_impl; - errorcheck_functions.cond_wait = g_cond_wait_errorcheck_impl; - errorcheck_functions.cond_timed_wait = g_cond_timed_wait_errorcheck_impl; + errorcheck_functions.mutex_free = + (void (*)(GMutex *)) g_mutex_free_errorcheck_impl; + errorcheck_functions.cond_wait = + (void (*)(GCond *, GMutex *)) g_cond_wait_errorcheck_impl; + errorcheck_functions.cond_timed_wait = + (gboolean (*)(GCond *, GMutex *, GTimeVal *)) + g_cond_timed_wait_errorcheck_impl; g_thread_init (&errorcheck_functions); } -- 2.7.4