summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Djurfeldt <djurfeldt@nada.kth.se>2002-12-16 20:29:18 +0000
committerMikael Djurfeldt <djurfeldt@nada.kth.se>2002-12-16 20:29:18 +0000
commit6da2dfc4e03d9aa842eadb5048bfc601f5aac23c (patch)
tree6d9366728a0d7b7290f39975329db777e74068b1
parent0b6843b1eb38ecec4d1c5711745505845a9fc809 (diff)
downloadguile-6da2dfc4e03d9aa842eadb5048bfc601f5aac23c.tar.gz
* pthread-threads.c, pthread-threads.h (SCM_DEBUG_THREADS): Added
support for debugging mutex operations.
-rw-r--r--libguile/ChangeLog3
-rw-r--r--libguile/pthread-threads.c17
-rw-r--r--libguile/pthread-threads.h11
3 files changed, 30 insertions, 1 deletions
diff --git a/libguile/ChangeLog b/libguile/ChangeLog
index b13004f3b..631ef1c4b 100644
--- a/libguile/ChangeLog
+++ b/libguile/ChangeLog
@@ -1,5 +1,8 @@
2002-12-16 Mikael Djurfeldt <mdj@kvast.blakulla.net>
+ * pthread-threads.c, pthread-threads.h (SCM_DEBUG_THREADS): Added
+ support for debugging mutex operations.
+
* threads.c (scm_thread): Removed filed joining_threads.
(thread_print): Print thread number as well as address of thread
structure.
diff --git a/libguile/pthread-threads.c b/libguile/pthread-threads.c
index 58410db16..8aa0e6fca 100644
--- a/libguile/pthread-threads.c
+++ b/libguile/pthread-threads.c
@@ -142,6 +142,23 @@ scm_i_plugin_mutex_unlock (scm_t_mutex *mx)
pthread_mutex_unlock (&mutex_mutex);
return 0;
}
+
+int
+scm_i_plugin_cond_wait (scm_t_cond *c, scm_t_mutex *mx)
+{
+ mutex *m = (mutex *) mx;
+ return pthread_cond_wait ((pthread_cond_t *) c, m->mutex);
+}
+
+int
+scm_i_plugin_cond_wait (scm_t_cond *c,
+ scm_t_mutex *mx,
+ const struct timespec *t)
+{
+ mutex *m = (mutex *) mx;
+ return pthread_cond_timedwait ((pthread_cond_t *) c, m->mutex, t);
+}
+
#endif
/* The following section belongs in threads.c, or rather
diff --git a/libguile/pthread-threads.h b/libguile/pthread-threads.h
index 8b3d4fe32..2ab3d16a0 100644
--- a/libguile/pthread-threads.h
+++ b/libguile/pthread-threads.h
@@ -80,6 +80,8 @@ typedef struct { char _[SCM_MUTEX_MAXSIZE]; } scm_t_mutex;
extern scm_t_mutexattr scm_i_plugin_mutex; /* The "fast" mutex. */
+/* This debug stuff made things a bit messy. This needs some
+ reorganization. */
#ifdef SCM_DEBUG_THREADS
int scm_i_plugin_mutex_init (scm_t_mutex *, const scm_t_mutexattr *);
int scm_i_plugin_mutex_lock (scm_t_mutex *);
@@ -134,11 +136,18 @@ int scm_i_plugin_rec_mutex_unlock (scm_t_rec_mutex *);
#define scm_t_cond pthread_cond_t
#define scm_i_plugin_cond_init pthread_cond_init
-#define scm_i_plugin_cond_destroy pthread_cond_destroy
+#define scm_i_plugin_cond_destroy pthread_cond_destroy
+#ifdef SCM_DEBUG_THREADS
+int scm_i_plugin_cond_wait (scm_t_cond *, scm_t_mutex *);
+int scm_i_plugin_cond_timedwait (scm_t_cond *,
+ scm_t_mutex *,
+ const struct timespec *);
+#else
#define scm_i_plugin_cond_wait(c, m) \
pthread_cond_wait ((c), (pthread_mutex_t *) (m))
#define scm_i_plugin_cond_timedwait(c, m, t) \
pthread_cond_timedwait ((c), (pthread_mutex_t *) (m), (t))
+#endif
#define scm_i_plugin_cond_signal pthread_cond_signal
#define scm_i_plugin_cond_broadcast pthread_cond_broadcast