add missing gc.c

parent 9052bab4
#include <pthread.h>
int gp_gc_p = 0;
pthread_mutex_t gp_gc_lock = PTHREAD_MUTEX_INITIALIZER;
void gp_no_gc()
{
pthread_mutex_lock(&gp_gc_lock);
gp_gc_p ++;
pthread_mutex_unlock(&gp_gc_lock);
}
void gp_do_gc()
{
pthread_mutex_lock(&gp_gc_lock);
gp_gc_p --;
pthread_mutex_unlock(&gp_gc_lock);
}
void *gp_after_mark_hook(void *hook_data, void *fn_data, void *data)
{
SCM pt = scm_fluid_ref(gp_stacks);
pthread_mutex_lock(&gp_gc_lock);
if(gp_gc_p)
{
pthread_mutex_unlock(&gp_gc_lock);
return (void *)0;
}
while(SCM_CONSP(pt))
{
gp_sweep_handle(SCM_CAR(pt));
pt = SCM_CDR(pt);
}
pthread_mutex_unlock(&gp_gc_lock);
return (void *)0;
}
void init_gpgc()
{
const int appendp = 0;
void *data = (void *) 0;
scm_c_hook_add(&scm_after_gc_c_hook, gp_after_mark_hook, data, appendp);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment