s/gc_mark/markedp to avoid confusion with the mark command

This commit is contained in:
Alex Shinn 2011-02-12 17:03:58 +09:00
parent 3aeef15032
commit 3804c0ecb2
3 changed files with 12 additions and 12 deletions

14
gc.c
View file

@ -107,9 +107,9 @@ void sexp_mark (sexp ctx, sexp x) {
sexp t, *p; sexp t, *p;
struct sexp_gc_var_t *saves; struct sexp_gc_var_t *saves;
loop: loop:
if (!x || !sexp_pointerp(x) || !sexp_valid_object_p(ctx, x) || sexp_gc_mark(x)) if (!x || !sexp_pointerp(x) || !sexp_valid_object_p(ctx, x) || sexp_markedp(x))
return; return;
sexp_gc_mark(x) = 1; sexp_markedp(x) = 1;
if (sexp_contextp(x)) if (sexp_contextp(x))
for (saves=sexp_context_saves(x); saves; saves=saves->next) for (saves=sexp_context_saves(x); saves; saves=saves->next)
if (saves->var) sexp_mark(ctx, *(saves->var)); if (saves->var) sexp_mark(ctx, *(saves->var));
@ -150,7 +150,7 @@ void sexp_conservative_mark (sexp ctx) {
p = (sexp) (((char*)p) + r->size); p = (sexp) (((char*)p) + r->size);
continue; continue;
} }
if (!sexp_gc_mark(p) && stack_references_pointer_p(ctx, p)) { if (!sexp_markedp(p) && stack_references_pointer_p(ctx, p)) {
#if SEXP_USE_DEBUG_GC > 3 #if SEXP_USE_DEBUG_GC > 3
if (p && sexp_pointerp(p)) { if (p && sexp_pointerp(p)) {
fprintf(stderr, SEXP_BANNER("MISS: %p: %s"), p,sexp_pointer_source(p)); fprintf(stderr, SEXP_BANNER("MISS: %p: %s"), p,sexp_pointer_source(p));
@ -189,14 +189,14 @@ void sexp_reset_weak_references(sexp ctx) {
p = (sexp) (((char*)p) + r->size); p = (sexp) (((char*)p) + r->size);
continue; continue;
} }
if (sexp_gc_mark(p)) { if (sexp_markedp(p)) {
t = sexp_object_type(ctx, p); t = sexp_object_type(ctx, p);
if (sexp_type_weak_base(t) > 0) { if (sexp_type_weak_base(t) > 0) {
all_reset_p = 1; all_reset_p = 1;
v = (sexp*) ((char*)p + sexp_type_weak_base(t)); v = (sexp*) ((char*)p + sexp_type_weak_base(t));
len = sexp_type_num_weak_slots_of_object(t, p); len = sexp_type_num_weak_slots_of_object(t, p);
for (i=0; i<len; i++) { for (i=0; i<len; i++) {
if (v[i] && sexp_pointerp(v[i]) && ! sexp_gc_mark(v[i])) { if (v[i] && sexp_pointerp(v[i]) && ! sexp_markedp(v[i])) {
v[i] = SEXP_FALSE; v[i] = SEXP_FALSE;
sexp_brokenp(p) = 1; sexp_brokenp(p) = 1;
} else { } else {
@ -243,7 +243,7 @@ sexp sexp_sweep (sexp ctx, size_t *sum_freed_ptr) {
fprintf(stderr, SEXP_BANNER("%p sweep: bad size at %p + %d > %p"), fprintf(stderr, SEXP_BANNER("%p sweep: bad size at %p + %d > %p"),
ctx, p, sexp_pointer_tag(p), r); ctx, p, sexp_pointer_tag(p), r);
#endif #endif
if (! sexp_gc_mark(p)) { if (! sexp_markedp(p)) {
/* free p */ /* free p */
finalizer = sexp_type_finalize(sexp_object_type(ctx, p)); finalizer = sexp_type_finalize(sexp_object_type(ctx, p));
if (finalizer) finalizer(ctx sexp_api_pass(NULL, 1), p); if (finalizer) finalizer(ctx sexp_api_pass(NULL, 1), p);
@ -279,7 +279,7 @@ sexp sexp_sweep (sexp ctx, size_t *sum_freed_ptr) {
if (freed > max_freed) if (freed > max_freed)
max_freed = freed; max_freed = freed;
} else { } else {
sexp_gc_mark(p) = 0; sexp_markedp(p) = 0;
p = (sexp) (((char*)p)+size); p = (sexp) (((char*)p)+size);
} }
} }

View file

@ -230,7 +230,7 @@ struct sexp_core_form_struct {
struct sexp_struct { struct sexp_struct {
sexp_tag_t tag; sexp_tag_t tag;
char gc_mark; char markedp;
unsigned int immutablep:1; unsigned int immutablep:1;
unsigned int freep:1; unsigned int freep:1;
unsigned int brokenp:1; unsigned int brokenp:1;
@ -489,7 +489,7 @@ void *sexp_realloc(sexp ctx, sexp x, size_t size);
#define sexp_booleanp(x) (((x) == SEXP_TRUE) || ((x) == SEXP_FALSE)) #define sexp_booleanp(x) (((x) == SEXP_TRUE) || ((x) == SEXP_FALSE))
#define sexp_pointer_tag(x) ((x)->tag) #define sexp_pointer_tag(x) ((x)->tag)
#define sexp_gc_mark(x) ((x)->gc_mark) #define sexp_markedp(x) ((x)->markedp)
#define sexp_flags(x) ((x)->flags) #define sexp_flags(x) ((x)->flags)
#define sexp_immutablep(x) ((x)->immutablep) #define sexp_immutablep(x) ((x)->immutablep)
#define sexp_freep(x) ((x)->freep) #define sexp_freep(x) ((x)->freep)

6
sexp.c
View file

@ -355,10 +355,10 @@ void sexp_destroy_context (sexp ctx) {
size_t sum_freed; size_t sum_freed;
if (sexp_context_heap(ctx)) { if (sexp_context_heap(ctx)) {
heap = sexp_context_heap(ctx); heap = sexp_context_heap(ctx);
sexp_gc_mark(ctx) = 1; sexp_markedp(ctx) = 1;
#if ! SEXP_USE_GLOBAL_TYPES #if ! SEXP_USE_GLOBAL_TYPES
sexp_gc_mark(sexp_context_globals(ctx)) = 1; sexp_markedp(sexp_context_globals(ctx)) = 1;
sexp_gc_mark(sexp_global(ctx, SEXP_G_TYPES)) = 1; sexp_markedp(sexp_global(ctx, SEXP_G_TYPES)) = 1;
#endif #endif
sexp_sweep(ctx, &sum_freed); /* sweep w/o mark to run finalizers */ sexp_sweep(ctx, &sum_freed); /* sweep w/o mark to run finalizers */
sexp_context_heap(ctx) = NULL; sexp_context_heap(ctx) = NULL;