home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mitsch75.zip / scheme-7_5_17-src.zip / scheme-7.5.17 / src / microcode / critsec.h < prev    next >
C/C++ Source or Header  |  1999-01-02  |  2KB  |  63 lines

  1. /* -*-C-*-
  2.  
  3. $Id: critsec.h,v 1.4 1999/01/02 06:11:34 cph Exp $
  4.  
  5. Copyright (c) 1990-1999 Massachusetts Institute of Technology
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or (at
  10. your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful, but
  13. WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15. General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21.  
  22. /* Critical sections.
  23.    There should be a stack of critical sections, each with a
  24.    queue of hooks. */
  25.  
  26. extern char * critical_section_name;
  27. extern int critical_section_hook_p;
  28. extern void EXFUN ((*critical_section_hook), (char *));
  29.  
  30. #define DECLARE_CRITICAL_SECTION()                    \
  31.   char * critical_section_name = 0;                    \
  32.   int critical_section_hook_p;                        \
  33.   void (*critical_section_hook) ()
  34.  
  35. #define ENTER_CRITICAL_SECTION(name) critical_section_name = (name)
  36. #define RENAME_CRITICAL_SECTION(name) critical_section_name = (name)
  37.  
  38. #define EXIT_CRITICAL_SECTION(code_if_hook)                \
  39. {                                    \
  40.   if (critical_section_hook_p)                        \
  41.     {                                    \
  42.       code_if_hook;                            \
  43.       {                                    \
  44.     char * name = critical_section_name;                \
  45.     critical_section_hook_p = 0;                    \
  46.     critical_section_name = 0;                    \
  47.     (*critical_section_hook) (name);                \
  48.       }                                    \
  49.     }                                    \
  50.   else                                    \
  51.     critical_section_name = 0;                        \
  52. }
  53.  
  54. #define SET_CRITICAL_SECTION_HOOK(hook)                    \
  55. {                                    \
  56.   critical_section_hook = (hook);                    \
  57.   critical_section_hook_p = 1;                        \
  58. }
  59.  
  60. #define CLEAR_CRITICAL_SECTION_HOOK() critical_section_hook_p = 0
  61. #define WITHIN_CRITICAL_SECTION_P() (critical_section_name != 0)
  62. #define CRITICAL_SECTION_NAME() (critical_section_name)
  63.