summaryrefslogtreecommitdiff
path: root/libguile/pthread-threads.h
diff options
context:
space:
mode:
authorMikael Djurfeldt <djurfeldt@nada.kth.se>2002-12-15 14:24:34 +0000
committerMikael Djurfeldt <djurfeldt@nada.kth.se>2002-12-15 14:24:34 +0000
commit28d52ebb1945223db0df88cc33e4a88d860dafbb (patch)
tree41e93008606708a69c3d3f0a7065abca21a477ad /libguile/pthread-threads.h
parent2ff4f1815955aa0c6b759d3c160658fe576ba5ee (diff)
downloadguile-28d52ebb1945223db0df88cc33e4a88d860dafbb.tar.gz
* __scm.h (SCM_DEFER_INTS, SCM_ALLOW_INTS): New definitions.
Simply lock a thread C API recursive mutex. (SCM_NONREC_CRITICAL_SECTION_START, SCM_NONREC_CRITICAL_SECTION_END, SCM_REC_CRITICAL_SECTION_START, SCM_REC_CRITICAL_SECTION_END): Removed. * eval.c: Replaced SOURCE_SECTION_START / SOURCE_SECTION_END with direct calls to scm_rec_mutex_lock / unlock around the three calls to scm_m_expand_body. * eval.c, eval.h (promise_free): New function. (scm_force): Rewritten; Now thread-safe; Removed SCM_DEFER/ALLOW_INTS. * pthread-threads.h: Added partially implemented plugin interface for recursive mutexes. These are, for now, only intended to be used internally within the Guile implementation. * pthread-threads.c: New file. * threads.c: Conditionally #include "pthread-threads.c". * eval.c, eval.h (scm_makprom, scm_force): Rewritten to be thread-safe; * snarf.h (SCM_MUTEX, SCM_GLOBAL_MUTEX, SCM_REC_MUTEX, SCM_GLOBAL_REC_MUTEX): New macros. * eval.c, threads.c, threads.h, snarf.h: Rewrote critical section macros---use mutexes instead. * tags.h (SCM_IM_FUTURE): New tag. * eval.c (scm_m_future): New primitive macro. (SCM_CEVAL): Support futures. (unmemocopy): Support unmemoization of futures. * print.c (scm_isymnames): Name of future isym.
Diffstat (limited to 'libguile/pthread-threads.h')
-rw-r--r--libguile/pthread-threads.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/libguile/pthread-threads.h b/libguile/pthread-threads.h
index 6e7e1d678..1dd7e5bc4 100644
--- a/libguile/pthread-threads.h
+++ b/libguile/pthread-threads.h
@@ -68,6 +68,9 @@
#define scm_i_plugin_thread_self pthread_self
#define scm_t_mutex pthread_mutex_t
+#define scm_t_mutexattr pthread_mutexattr_t
+
+extern scm_t_mutexattr scm_i_plugin_mutex; /* The "fast" mutex. */
#define scm_i_plugin_mutex_init pthread_mutex_init
#define scm_i_plugin_mutex_destroy pthread_mutex_destroy
@@ -75,6 +78,25 @@
#define scm_i_plugin_mutex_trylock pthread_mutex_trylock
#define scm_i_plugin_mutex_unlock pthread_mutex_unlock
+#define SCM_REC_MUTEX_MAXSIZE (8 * sizeof (long))
+typedef struct { char _[SCM_REC_MUTEX_MAXSIZE]; } scm_t_rec_mutex;
+
+extern scm_t_mutexattr scm_i_plugin_rec_mutex;
+
+#ifdef PTHREAD_MUTEX_RECURSIVE /* pthreads has recursive mutexes! */
+#define scm_i_plugin_rec_mutex_init pthread_mutex_init
+#define scm_i_plugin_rec_mutex_destroy pthread_mutex_destroy
+#define scm_i_plugin_rec_mutex_lock pthread_mutex_lock
+#define scm_i_plugin_rec_mutex_trylock pthread_mutex_trylock
+#define scm_i_plugin_rec_mutex_unlock pthread_mutex_unlock
+#else
+int scm_i_plugin_rec_mutex_init (scm_t_rec_mutex *, const scm_t_mutexattr *);
+#define scm_i_plugin_rec_mutex_destroy(mx) do { (void) (mx); } while (0)
+int scm_i_plugin_rec_mutex_lock (scm_t_rec_mutex *);
+int scm_i_plugin_rec_mutex_trylock (scm_t_rec_mutex *);
+int scm_i_plugin_rec_mutex_unlock (scm_t_rec_mutex *);
+#endif
+
#define scm_t_cond pthread_cond_t
#define scm_i_plugin_cond_init pthread_cond_init
@@ -93,6 +115,8 @@
#define scm_i_plugin_select select
+void scm_init_pthread_threads (void);
+
#endif /* SCM_THREADS_NULL_H */
/*