Root Sets. More...
Go to the source code of this file.
Functions | |
int | tm_root_add (const char *name, const void *l, const void *h) |
API: Add a root set. | |
void | tm_root_remove (const char *name, const void *l, const void *h) |
int | tm_ptr_is_in_root_set (const void *ptr) |
Root Sets.
Definition in file root.h.
int tm_ptr_is_in_root_set | ( | const void * | ptr | ) |
Definition at line 274 of file root.c.
References tm_root::h, tm_root::l, tm_data::nroots, tm_data::roots, and tm.
Referenced by tm_init().
00275 { 00276 int i; 00277 00278 for ( i = 0; i < tm.nroots; ++ i ) { 00279 if ( tm.roots[i].l <= ptr && ptr < tm.roots[i].h ) { 00280 return i + 1; 00281 } 00282 } 00283 00284 return 0; 00285 }
int tm_root_add | ( | const char * | name, | |
const void * | l, | |||
const void * | h | |||
) |
API: Add a root set.
void tm_root_remove | ( | const char * | name, | |
const void * | l, | |||
const void * | h | |||
) |
Definition at line 226 of file root.c.
00227 { 00228 int i; 00229 tm_root *a, *b, c[2]; 00230 00231 /* Add to anti-roots list. */ 00232 b = &tm.aroots[i = tm.naroots ++]; 00233 b->name = name; 00234 b->l = l; 00235 b->h = h; 00236 00237 tm_msg("R A [%p,%p] %s ANTI-ROOT %d\n", 00238 tm.aroots[i].l, 00239 tm.aroots[i].h, 00240 tm.aroots[i].name, 00241 i); 00242 00243 /* Adding a anti-root might require splitting existing roots. */ 00244 /* Do not split tm.root[0], it's the machine register set! */ 00245 00246 for ( i = tm.root_datai; i < tm.nroots; ++ i ) { 00247 int j; 00248 00249 for ( j = 0; j < tm.naroots; ++ j ) { 00250 a = &tm.roots[i]; 00251 b = &tm.aroots[j]; 00252 00253 switch ( tm_root_subtract(a, b, c) ) { 00254 case -1: /* deleted */ 00255 a->l = a->h = 0; 00256 j = tm.naroots; 00257 break; 00258 00259 case 1: /* clipped */ 00260 *a = *c; 00261 break; 00262 00263 case 2: /* split */ 00264 *a = *c; 00265 _tm_root_add(&c[1]); 00266 i = 1; j = -1; /* restart */ 00267 break; 00268 } 00269 } 00270 } 00271 }