/[guile]/guile/guile-core/libguile/__scm.h
ViewVC logotype

Diff of /guile/guile-core/libguile/__scm.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.93 by mdj, Tue Dec 10 09:35:06 2002 UTC revision 1.94 by mdj, Sun Dec 15 14:24:34 2002 UTC
# Line 425  do { \ Line 425  do { \
425  #define SCM_FENCE  #define SCM_FENCE
426  #endif  #endif
427    
428  #define SCM_DEFER_INTS SCM_REC_CRITICAL_SECTION_START (scm_i_defer)  #define SCM_DEFER_INTS scm_rec_mutex_lock (&scm_i_defer_mutex);
429    
430  #define SCM_ALLOW_INTS SCM_REC_CRITICAL_SECTION_END (scm_i_defer)  #define SCM_ALLOW_INTS scm_rec_mutex_unlock (&scm_i_defer_mutex);
431    
432  #define SCM_REDEFER_INTS SCM_DEFER_INTS  #define SCM_REDEFER_INTS SCM_DEFER_INTS
433    
# Line 441  do { \ Line 441  do { \
441    
442    
443    
 /* Critical sections */  
   
 #define SCM_DECLARE_NONREC_CRITICAL_SECTION(prefix) \  
   extern scm_t_mutex prefix ## _mutex  
   
 #define SCM_NONREC_CRITICAL_SECTION_START(prefix)       \  
   do { scm_thread *t = scm_i_leave_guile ();            \  
        scm_i_plugin_mutex_lock (&prefix ## _mutex);     \  
        scm_i_enter_guile (t);                           \  
   } while (0)  
   
 #define SCM_NONREC_CRITICAL_SECTION_END(prefix)         \  
   do { scm_i_plugin_mutex_unlock (&prefix ## _mutex);   \  
   } while (0)  
   
 /* This could be replaced by a single call to scm_i_plugin_mutex_lock  
    on systems which support recursive mutecis (like LinuxThreads).  
    We should test for the presence of recursive mutecis in  
    configure.in.  
   
    Also, it is probably possible to replace recursive sections with  
    non-recursive ones, so don't worry about the complexity.  
  */  
     
 #define SCM_DECLARE_REC_CRITICAL_SECTION(prefix)        \  
   extern scm_t_mutex prefix ## _mutex;                  \  
   extern int prefix ## _count;                          \  
   extern scm_thread *prefix ## _owner  
   
 #define SCM_REC_CRITICAL_SECTION_START(prefix)                          \  
   do { scm_i_plugin_mutex_lock (&scm_i_section_mutex);                  \  
        if (prefix ## _count && prefix ## _owner == SCM_CURRENT_THREAD)  \  
          {                                                              \  
            ++prefix ## _count;                                          \  
            scm_i_plugin_mutex_unlock (&scm_i_section_mutex);            \  
          }                                                              \  
        else                                                             \  
          {                                                              \  
            scm_thread *t = scm_i_leave_guile ();                        \  
            scm_i_plugin_mutex_unlock (&scm_i_section_mutex);            \  
            scm_i_plugin_mutex_lock (&prefix ## _mutex);                 \  
            prefix ## _count = 1;                                        \  
            prefix ## _owner = t;                                        \  
            scm_i_enter_guile (t);                                       \  
          }                                                              \  
   } while (0)  
   
 #define SCM_REC_CRITICAL_SECTION_END(prefix)                    \  
   do { scm_i_plugin_mutex_lock (&scm_i_section_mutex);          \  
        if (!--prefix ## _count)                                 \  
          {                                                      \  
            prefix ## _owner = 0;                                \  
            scm_i_plugin_mutex_unlock (&prefix ## _mutex);       \  
          }                                                      \  
        scm_i_plugin_mutex_unlock (&scm_i_section_mutex);        \  
   } while (0)  
   
444  /* Note: The following needs updating. */  /* Note: The following needs updating. */
445    
446  /* Classification of critical sections  /* Classification of critical sections

Legend:
Removed from v.1.93  
changed lines
  Added in v.1.94

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26