mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-07-01 23:30:28 +02:00
scm_gc_object_address pins its referent
* libguile/gc.h: * libguile/gc.c (scm_gc_pin_object): New function. (scm_gc_object_address): New function, to be used instead of SCM_UNPACK when an object's address is exposed, for example via hashq. * libguile/atomic.c: * libguile/cache-internal.h: * libguile/continuations.c: * libguile/dynstack.c: * libguile/dynstack.h: * libguile/ephemerons.c: * libguile/exceptions.c: * libguile/finalizers.c: * libguile/fluids-internal.h: * libguile/fluids.c: * libguile/foreign.c: * libguile/frames.c: * libguile/hash.c: * libguile/hashtab.c: * libguile/intrinsics.c: * libguile/memoize.c: * libguile/print.c: * libguile/programs.c: * libguile/smob.c: * libguile/struct.c: * libguile/struct.h: * libguile/variable.c: * libguile/vm.c: Use the new functions everywhere that is needed. Because they take a thread, sometimes we have to do some extra plumbing.
This commit is contained in:
parent
b0ce014801
commit
a7d7ff5019
25 changed files with 133 additions and 117 deletions
|
@ -242,6 +242,8 @@ scm_i_struct_inherit_vtable_magic (SCM vtable, SCM obj)
|
|||
}
|
||||
|
||||
SCM_SET_VTABLE_FLAGS (obj, SCM_VTABLE_FLAG_VALIDATED);
|
||||
|
||||
scm_gc_pin_object (SCM_I_CURRENT_THREAD, obj);
|
||||
}
|
||||
#undef FUNC_NAME
|
||||
|
||||
|
@ -536,6 +538,8 @@ scm_i_make_vtable_vtable (SCM fields)
|
|||
else
|
||||
SCM_STRUCT_SLOT_SET (obj, n, SCM_BOOL_F);
|
||||
|
||||
scm_gc_pin_object (SCM_I_CURRENT_THREAD, obj);
|
||||
|
||||
return obj;
|
||||
}
|
||||
#undef FUNC_NAME
|
||||
|
@ -727,14 +731,6 @@ SCM_DEFINE (scm_struct_vtable, "struct-vtable", 1, 0, 0,
|
|||
* how to associate names with vtables.
|
||||
*/
|
||||
|
||||
unsigned long
|
||||
scm_struct_ihashq (SCM obj, unsigned long n, void *closure)
|
||||
{
|
||||
/* The length of the hash table should be a relative prime it's not
|
||||
necessary to shift down the address. */
|
||||
return SCM_UNPACK (obj) % n;
|
||||
}
|
||||
|
||||
SCM_DEFINE (scm_struct_vtable_name, "struct-vtable-name", 1, 0, 0,
|
||||
(SCM vtable),
|
||||
"Return the name of the vtable @var{vtable}.")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue