1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-07-01 07:20:20 +02:00
guile/libguile/fluids-internal.h
Andy Wingo fbbe5fa873 Move dynamic states off of scm_cell
* libguile/fluids-internal.h: Add struct scm_dynamic_state_snapshot
definition.
* libguile/fluids.h (scm_is_dynamic_state): Inline.
* libguile/fluids.c: Use "struct scm_dynamic_state_snapshot".
2025-06-20 14:56:28 +02:00

93 lines
2.4 KiB
C
Raw 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 fluid, SCM value_box,
scm_t_dynamic_state *dynamic_state);
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 */