external_markbits.c
Go to the documentation of this file.
00001 /*
00002  * external_markbits.c: R.Hanai
00003  */
00004 
00005 #include <stdio.h>
00006 #include "external_markbits.h"
00007 #include "rgc_utils.h"
00008 
00009 #define bit_table_error(str)
00010 
00011 unsigned int hmin, hmax;
00012 static char *bit_table;
00013 unsigned int mingcheap, maxgcheap;
00014 
00015 void set_heap_range(unsigned int min, unsigned int max)
00016 {
00017   if(mingcheap == 0 || min < mingcheap) mingcheap = min; 
00018   if(maxgcheap == 0 || max > maxgcheap) maxgcheap = max;
00019 }
00020 
00021 void allocate_bit_table()
00022 {
00023   int size;
00024 
00025   ASSERT(mingcheap != maxgcheap);
00026 
00027   size = (maxgcheap-mingcheap+3)>>2;
00028   //size *= 2;
00029   hmin = mingcheap;
00030   hmax = mingcheap + (size<<2);
00031   //DPRINT2("allocate bit table [%x, %x)", hmin, hmax);
00032   bit_table = (char *)malloc(size);
00033 
00034   ASSERT(bit_table); // "failed to allocate an external bit table")
00035 }
00036 
00037 __inline__ void set_bit(unsigned int addr)
00038 {
00039   ASSERT(hmin <= addr && addr < hmax);
00040 //    DPRINT3("set: over the heap [%x;%x), addr=%x", hmin, hmax, addr);
00041 //    DPRINT3("set: under the heap. [%x;%x], addr=%x", hmin, hmax, addr);
00042 
00043 //  ASSERT(!(addr & 0x3));
00044 //    DPRINT3("set: addr not word aligned, addr=%x", addr);
00045   
00046   bit_table[(addr - hmin) >> 2] = 1;
00047 }
00048 
00049 __inline__ char read_bit(unsigned int addr)
00050 {
00051   ASSERT(hmin <= addr && addr < hmax);
00052 //    DPRINT3("read: over the heap [%x;%x), addr=%x", hmin, hmax, addr);
00053 //    DPRINT3("read: under the heap [%x;%x), addr=%x", hmin, hmax, addr);
00054   /* copyobj in leo.c:619 < leo.c:632 */
00055 
00056 //  ASSERT(!(addr & 0x3));
00057 //    DPRINT3("set: addr not word aligned, addr=%x", addr);
00058   
00059   return bit_table[(addr - hmin) >> 2];
00060 }
00061 
00062 /* 
00063  * copyobj in leo.c:619 < leo.c:632
00064  * SORT in sequence.c 978 
00065  * */
00066 
00067 void clear_bit_table()
00068 {
00069   memset(&bit_table[0], 0, (hmax-hmin+3)>>2);
00070 }
00071 
00072 void print_bit_table()
00073 {
00074   int i, size, prod;
00075   size = (hmax-hmin+3)>>2;
00076   prod = 0;
00077   DPRINT2("bit-table size=%d", size);
00078   for(i = 0; i < size; i++){
00079     if(!(i&0xff)){
00080       fprintf(stderr, "%d", prod);
00081       prod = 0;
00082     }
00083     prod |= bit_table[i];
00084     if(!(i%(80*256))) fprintf(stderr, "\n");
00085   }
00086 }


euslisp
Author(s): Toshihiro Matsui
autogenerated on Thu Jun 6 2019 18:05:53