From 9774b3e5518dc1e5e9b3eab15bc43e710bd783d2 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Fri, 2 May 2025 15:12:19 +0200 Subject: [PATCH] Prepare structs for new finalization API * libguile/struct.h: * libguile/struct.c (scm_i_finalize_struct): New helper. (struct_finalizer_trampoline): Implement as shim. --- libguile/struct.c | 11 ++++++++--- libguile/struct.h | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/libguile/struct.c b/libguile/struct.c index 3e220d9d0..671f7e14b 100644 --- a/libguile/struct.c +++ b/libguile/struct.c @@ -310,16 +310,21 @@ SCM_DEFINE (scm_struct_vtable_p, "struct-vtable?", 1, 0, 0, /* Finalization: invoke the finalizer of the struct pointed to by PTR. */ -static void -struct_finalizer_trampoline (void *ptr, void *unused_data) +void +scm_i_finalize_struct (struct scm_thread *thread, SCM obj) { - SCM obj = PTR2SCM (ptr); scm_t_struct_finalize finalize = SCM_STRUCT_FINALIZER (obj); if (finalize) finalize (obj); } +static void +struct_finalizer_trampoline (void *ptr, void *data) +{ + scm_i_finalize_struct (SCM_I_CURRENT_THREAD, PTR2SCM (ptr)); +} + /* A struct is a sequence of words preceded by a pointer to the struct's vtable. The vtable reference is tagged with the struct tc3. */ static SCM diff --git a/libguile/struct.h b/libguile/struct.h index c9533518b..f616680bd 100644 --- a/libguile/struct.h +++ b/libguile/struct.h @@ -1,7 +1,7 @@ #ifndef SCM_STRUCT_H #define SCM_STRUCT_H -/* Copyright 1995,1997,1999-2001,2006-2013,2015,2017-2018 +/* Copyright 1995,1997,1999-2001,2006-2013,2015,2017-2018,2025 Free Software Foundation, Inc. This file is part of Guile. @@ -188,6 +188,7 @@ SCM_API void scm_print_struct (SCM exp, SCM port, scm_print_state *); SCM_INTERNAL SCM scm_i_struct_equalp (SCM s1, SCM s2); SCM_INTERNAL unsigned long scm_struct_ihashq (SCM, unsigned long, void *); SCM_INTERNAL void scm_i_struct_inherit_vtable_magic (SCM vtable, SCM obj); +SCM_INTERNAL void scm_i_finalize_struct (struct scm_thread *thread, SCM obj); SCM_INTERNAL void scm_init_struct (void); #endif /* SCM_STRUCT_H */