1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-07-01 15:20:34 +02:00
guile/libguile/fluids-internal.h
Andy Wingo a7d7ff5019 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.
2025-06-26 15:00:22 +02:00

92 lines
2.3 KiB
C
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef SCM_FLUIDS_INTERNAL_H
#define SCM_FLUIDS_INTERNAL_H
/* Copyright 1996,2000-2001,2006,2008-2013,2018,2025
Free Software Foundation, Inc.
This file is part of Guile.
Guile is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Guile is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
License along with Guile. If not, see
<https://www.gnu.org/licenses/>. */
#include <libguile/fluids.h>
#include <libguile/gc.h>
#include <libguile/cache-internal.h>
struct scm_fluid
{
scm_t_bits tag_and_flags;
SCM default_value;
};
struct scm_dynamic_state_snapshot
{
scm_t_bits tag;
SCM bindings;
};
static inline struct scm_fluid*
scm_to_fluid (SCM x)
{
if (!scm_is_fluid (x))
abort ();
return (struct scm_fluid *) SCM_UNPACK_POINTER (x);
}
static inline SCM
scm_from_fluid (struct scm_fluid *fluid)
{
return SCM_PACK_POINTER (fluid);
}
static inline struct scm_dynamic_state_snapshot*
scm_to_dynamic_state (SCM x)
{
if (!scm_is_dynamic_state (x))
abort ();
return (struct scm_dynamic_state_snapshot *) SCM_UNPACK_POINTER (x);
}
static inline SCM
scm_from_dynamic_state (struct scm_dynamic_state_snapshot *dynstate)
{
return SCM_PACK_POINTER (dynstate);
}
struct scm_ephemeron_table;
struct scm_dynamic_state
{
SCM thread_local_values;
struct scm_ephemeron_table *values;
uint8_t has_aliased_values;
struct scm_cache cache;
};
SCM_INTERNAL SCM scm_i_fluid_ref (scm_thread *thread, SCM fluid);
SCM_INTERNAL void scm_swap_fluid (scm_thread *thread, SCM fluid, SCM value_box);
SCM_INTERNAL SCM scm_dynamic_state_ref (SCM state, SCM fluid, SCM dflt);
SCM_INTERNAL SCM scm_i_make_initial_dynamic_state (void);
SCM_INTERNAL void scm_i_fluid_print (SCM exp, SCM port, scm_print_state *pstate);
SCM_INTERNAL void scm_i_dynamic_state_print (SCM exp, SCM port, scm_print_state *pstate);
SCM_INTERNAL void scm_init_fluids (void);
#endif /* SCM_FLUIDS_INTERNAL_H */