home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / sys / gc_lib / generic.c < prev    next >
Text File  |  1999-06-05  |  1KB  |  38 lines

  1. /*
  2. -- This file is  free  software, which  comes  along  with  SmallEiffel. This
  3. -- software  is  distributed  in the hope that it will be useful, but WITHOUT 
  4. -- ANY  WARRANTY;  without  even  the  implied warranty of MERCHANTABILITY or
  5. -- FITNESS  FOR A PARTICULAR PURPOSE. You can modify it as you want, provided
  6. -- this header is kept unaltered, and a notification of the changes is added.
  7. -- You  are  allowed  to  redistribute  it and sell it, alone or as a part of 
  8. -- another product.
  9. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  10. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr 
  11. --                       http://www.loria.fr/SmallEiffel
  12. --
  13. */
  14. /* 
  15.    Generic Hazardous Garbage Collector marking code.
  16.    This is only C code (no machine code) assuming that all reachable
  17.    objects are stored in the stack or in the jmpbuf of setjmp().
  18. */
  19.  
  20. void mark_stack_and_registers(void){
  21.   void**stack_pointer;
  22.   jmp_buf stack_top;
  23.   (void)setjmp(stack_top);
  24.   stack_pointer=((void**)(&stack_top));
  25.   if (stack_pointer > stack_bottom){
  26.     /* Addresses increase as the stack grows. */
  27.     stack_pointer+=((sizeof(jmp_buf)/sizeof(void*))-1);
  28.     for(; stack_pointer >= stack_bottom; stack_pointer--)
  29.       gc_mark(*stack_pointer);
  30.   }
  31.   else {
  32.     /* Addresses decrease as the stack grows. */
  33.     for(; stack_pointer <= stack_bottom; stack_pointer++)
  34.       gc_mark(*stack_pointer);
  35.   }
  36. }
  37.  
  38.