mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-12 06:41:13 +02:00
* guardians.c (scm_guardian_gc_init): Turned into a hook function
and added to scm_before_mark_c_hook. (scm_guardian_zombify): Turned into a hook function and added to scm_before_sweep_c_hook.
This commit is contained in:
parent
9b3e180c0d
commit
5d2565a7e7
1 changed files with 10 additions and 3 deletions
|
@ -206,11 +206,13 @@ static guardian_t **current_link_field = NULL;
|
||||||
|
|
||||||
/* called before gc mark phase begins to initialise the live guardian
|
/* called before gc mark phase begins to initialise the live guardian
|
||||||
list. */
|
list. */
|
||||||
void
|
static void *
|
||||||
scm_guardian_gc_init()
|
scm_guardian_gc_init (void *dummy1, void *dummy2, void *dummy3)
|
||||||
{
|
{
|
||||||
current_link_field = &first_live_guardian;
|
current_link_field = &first_live_guardian;
|
||||||
first_live_guardian = NULL;
|
first_live_guardian = NULL;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* mark a guardian by adding it to the live guardian list. */
|
/* mark a guardian by adding it to the live guardian list. */
|
||||||
|
@ -230,7 +232,8 @@ g_mark (SCM ptr)
|
||||||
/* this is called by the garbage collector between the mark and sweep
|
/* this is called by the garbage collector between the mark and sweep
|
||||||
phases. for each marked guardian, it moves any unmarked object in
|
phases. for each marked guardian, it moves any unmarked object in
|
||||||
its live list (tconc) to its zombie list (tconc). */
|
its live list (tconc) to its zombie list (tconc). */
|
||||||
void scm_guardian_zombify (void)
|
static void *
|
||||||
|
scm_guardian_zombify (void *dummy1, void *dummy2, void *dummy3)
|
||||||
{
|
{
|
||||||
guardian_t *first_guardian;
|
guardian_t *first_guardian;
|
||||||
guardian_t **link_field = &first_live_guardian;
|
guardian_t **link_field = &first_live_guardian;
|
||||||
|
@ -304,6 +307,8 @@ void scm_guardian_zombify (void)
|
||||||
scm_gc_mark (g->zombies.head);
|
scm_gc_mark (g->zombies.head);
|
||||||
|
|
||||||
} while (current_link_field != link_field);
|
} while (current_link_field != link_field);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* not generally used, since guardian smob is wrapped in a closure.
|
/* not generally used, since guardian smob is wrapped in a closure.
|
||||||
|
@ -326,6 +331,8 @@ scm_init_guardian()
|
||||||
scm_tc16_guardian = scm_make_smob_type_mfpe ("guardian", sizeof (guardian_t),
|
scm_tc16_guardian = scm_make_smob_type_mfpe ("guardian", sizeof (guardian_t),
|
||||||
g_mark, NULL, g_print, NULL);
|
g_mark, NULL, g_print, NULL);
|
||||||
guard1 = scm_make_subr_opt ("guardian", scm_tc7_subr_2o, guard, 0);
|
guard1 = scm_make_subr_opt ("guardian", scm_tc7_subr_2o, guard, 0);
|
||||||
|
scm_c_hook_add (&scm_before_mark_c_hook, scm_guardian_gc_init, 0, 0);
|
||||||
|
scm_c_hook_add (&scm_before_sweep_c_hook, scm_guardian_zombify, 0, 0);
|
||||||
|
|
||||||
#include "libguile/guardians.x"
|
#include "libguile/guardians.x"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue