mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-16 16:50:21 +02:00
* __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.
This commit is contained in:
parent
2ff4f18159
commit
28d52ebb19
10 changed files with 305 additions and 133 deletions
|
@ -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 */
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue