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 / gc.h < prev    next >
C/C++ Source or Header  |  1999-01-02  |  4KB  |  121 lines

  1. /* -*-C-*-
  2.  
  3. $Id: gc.h,v 9.34 1999/01/02 06:11:34 cph Exp $
  4.  
  5. Copyright (c) 1987-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. /* 
  23.  * Garbage collection related macros of sufficient utility to be
  24.  * included in all compilations.
  25.  */
  26.  
  27. /* GC Types. */
  28.  
  29. #ifdef HAS_COMPILER_SUPPORT
  30. #ifndef BAD_TYPES_LETHAL
  31. #ifndef BAD_TYPES_INNOCUOUS
  32. #define BAD_TYPES_INNOCUOUS
  33. #endif /* BAD_TYPES_INNOCUOUS */
  34. #endif /* BAD_TYPES_LETHAL */
  35. #endif /* HAS_COMPILER_SUPPORT */
  36.  
  37. #ifdef BAD_TYPES_INNOCUOUS
  38. #ifdef BAD_TYPES_LETHAL
  39. #include "error: gc.h: BAD_TYPES both lethal and innocuous"
  40. #endif /* BAD_TYPES_LETHAL */
  41. #else /* not BAD_TYPES_INNOCUOUS */
  42. #ifndef BAD_TYPES_LETHAL
  43. #define BAD_TYPES_LETHAL
  44. #endif /* BAD_TYPES_LETHAL */
  45. #endif /* BAD_TYPES_INNOCUOUS */
  46.  
  47. #define GC_Non_Pointer             0
  48. #define GC_Cell                1
  49. #define GC_Pair                2
  50. #define GC_Triple            3
  51. #define GC_Hunk3            3
  52. #define GC_Quadruple            4
  53. #define GC_Hunk4                4
  54. #define GC_Undefined            -1 /* Undefined types */
  55. #define GC_Special            -2 /* Internal GC types */
  56. #define GC_Vector            -3
  57. #define GC_Compiled            -4
  58.  
  59. #ifdef BAD_TYPES_INNOCUOUS
  60. #define INVALID_TYPE_CODE(TC)        GC_Undefined
  61.  
  62. #else /* not BAD_TYPES_INNOCUOUS */
  63.  
  64. /* Some C compilers complain if the expression below does not yield
  65.    a value, and Microcode_Termination yields void.
  66.  */
  67.  
  68. #define INVALID_TYPE_CODE(TC)                        \
  69.   (outf_fatal  ("\nGC_Type_Code: Bad Type code = 0x%02x\n", TC),    \
  70.    Microcode_Termination(TERM_INVALID_TYPE_CODE),            \
  71.    GC_Undefined)
  72.  
  73. #endif /* BAD_TYPES_INNOCUOUS */
  74.  
  75. #define GC_Type_Code(TC)                        \
  76.  ((GC_Type_Map[TC] != GC_Undefined)    ?                \
  77.   GC_Type_Map[TC]            :                \
  78.   (INVALID_TYPE_CODE(TC)))
  79.  
  80. #define GC_Type(Object)            GC_Type_Code(OBJECT_TYPE (Object))
  81.  
  82. #define GC_Type_Non_Pointer(Object)    (GC_Type(Object) == GC_Non_Pointer)
  83. #define GC_Type_Cell(Object)        (GC_Type(Object) == GC_Cell)
  84. #define GC_Type_List(Object)        (GC_Type(Object) == GC_Pair)
  85. #define GC_Type_Triple(Object)        (GC_Type(Object) == GC_Triple)
  86. #define GC_Type_Quadruple(Object)    (GC_Type(Object) == GC_Quadruple)
  87. #define GC_Type_Undefined(Object)    (GC_Type(Object) == GC_Undefined)
  88. #define GC_Type_Special(Object)        (GC_Type(Object) == GC_Special)
  89. #define GC_Type_Vector(Object)        (GC_Type(Object) == GC_Vector)
  90. #define GC_Type_Compiled(Object)    (GC_Type(Object) == GC_Compiled)
  91.  
  92. /* Overflow detection, various cases */
  93.  
  94. #define GC_ENABLED_P() (INTERRUPT_ENABLED_P (INT_GC))
  95.  
  96. #define GC_Check(Amount)                        \
  97.   (((Amount + Free) >= MemTop) && (GC_ENABLED_P ()))
  98.  
  99. #define Space_Before_GC()                        \
  100.   ((GC_ENABLED_P ())                            \
  101.    ? ((Free <= MemTop) ? (MemTop - Free) : 0)                \
  102.    : (Heap_Top - Free))
  103.  
  104. #define Request_GC(Amount)                        \
  105. {                                    \
  106.   REQUEST_INTERRUPT (INT_GC);                        \
  107.   GC_Space_Needed = Amount;                        \
  108. }
  109.  
  110. #define SET_MEMTOP(addr)                        \
  111. {                                    \
  112.   MemTop = (addr);                            \
  113.   COMPILER_SETUP_INTERRUPT ();                        \
  114. }
  115.  
  116. #define SET_STACK_GUARD(addr)                        \
  117. {                                    \
  118.   Stack_Guard = (addr);                            \
  119.   COMPILER_SETUP_INTERRUPT ();                        \
  120. }
  121.