external_markbits.c
Go to the documentation of this file.
1 /*
2  * external_markbits.c: R.Hanai
3  */
4 
5 #include <stdio.h>
6 #include "external_markbits.h"
7 #include "rgc_utils.h"
8 
9 #define bit_table_error(str)
10 
11 unsigned int hmin, hmax;
12 static char *bit_table;
13 unsigned int mingcheap, maxgcheap;
14 
15 void set_heap_range(unsigned int min, unsigned int max)
16 {
17  if(mingcheap == 0 || min < mingcheap) mingcheap = min;
18  if(maxgcheap == 0 || max > maxgcheap) maxgcheap = max;
19 }
20 
22 {
23  int size;
24 
26 
27  size = (maxgcheap-mingcheap+3)>>2;
28  //size *= 2;
29  hmin = mingcheap;
30  hmax = mingcheap + (size<<2);
31  //DPRINT2("allocate bit table [%x, %x)", hmin, hmax);
32  bit_table = (char *)malloc(size);
33 
34  ASSERT(bit_table); // "failed to allocate an external bit table")
35 }
36 
37 __inline__ void set_bit(unsigned int addr)
38 {
39  ASSERT(hmin <= addr && addr < hmax);
40 // DPRINT3("set: over the heap [%x;%x), addr=%x", hmin, hmax, addr);
41 // DPRINT3("set: under the heap. [%x;%x], addr=%x", hmin, hmax, addr);
42 
43 // ASSERT(!(addr & 0x3));
44 // DPRINT3("set: addr not word aligned, addr=%x", addr);
45 
46  bit_table[(addr - hmin) >> 2] = 1;
47 }
48 
49 __inline__ char read_bit(unsigned int addr)
50 {
51  ASSERT(hmin <= addr && addr < hmax);
52 // DPRINT3("read: over the heap [%x;%x), addr=%x", hmin, hmax, addr);
53 // DPRINT3("read: under the heap [%x;%x), addr=%x", hmin, hmax, addr);
54  /* copyobj in leo.c:619 < leo.c:632 */
55 
56 // ASSERT(!(addr & 0x3));
57 // DPRINT3("set: addr not word aligned, addr=%x", addr);
58 
59  return bit_table[(addr - hmin) >> 2];
60 }
61 
62 /*
63  * copyobj in leo.c:619 < leo.c:632
64  * SORT in sequence.c 978
65  * */
66 
68 {
69  memset(&bit_table[0], 0, (hmax-hmin+3)>>2);
70 }
71 
73 {
74  int i, size, prod;
75  size = (hmax-hmin+3)>>2;
76  prod = 0;
77  DPRINT2("bit-table size=%d", size);
78  for(i = 0; i < size; i++){
79  if(!(i&0xff)){
80  fprintf(stderr, "%d", prod);
81  prod = 0;
82  }
83  prod |= bit_table[i];
84  if(!(i%(80*256))) fprintf(stderr, "\n");
85  }
86 }
memset(serverAddr, 0, sizeof(*serverAddr))
unsigned int hmax
#define DPRINT2
Definition: rgc_utils.h:20
void print_bit_table()
unsigned int hmin
#define min(x, y)
Definition: rmflags.c:17
void set_heap_range(unsigned int min, unsigned int max)
void clear_bit_table()
unsigned int maxgcheap
static char * bit_table
#define ASSERT(condition)
Definition: rgc_utils.h:28
__inline__ char read_bit(unsigned int addr)
#define max(I1, I2)
Definition: eustags.c:134
__inline__ void set_bit(unsigned int addr)
void allocate_bit_table()
unsigned int mingcheap


euslisp
Author(s): Toshihiro Matsui
autogenerated on Mon Feb 28 2022 22:18:27