1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-05 19:50:23 +02:00
guile/libguile/ephemerons.h
Andy Wingo 2463a0741f Rework fluids to use ephemeron hash tables
* libguile/ephemerons.c (scm_from_ephemeron, scm_to_ephemeron):
(scm_from_ephemeron_table, scm_to_ephemeron_table): New interfaces.
(scm_c_ephemeron_table_copy): Rename from
scm_c_ephemeron_hash_table_copy, as it's not specific to hash tables.

* libguile/fluids.h:
* libguile/fluids.c (restore_dynamic_state, save_dynamic_state)
(saved_dynamic_state_ref, fluid_set_x, fluid_ref)
(scm_fluid_ref_star, scm_i_make_initial_dynamic_state): Use ephemeron
hash tables.
2025-05-12 13:45:21 +02:00

70 lines
3 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_EPHEMERONS_H
#define SCM_EPHEMERONS_H
/* Copyright 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/scm.h"
struct gc_ephemeron;
struct scm_ephemeron_table;
SCM_INTERNAL struct gc_ephemeron* scm_c_make_ephemeron (SCM k, SCM v);
SCM_INTERNAL SCM scm_c_ephemeron_key (struct gc_ephemeron *e);
SCM_INTERNAL SCM scm_c_ephemeron_value (struct gc_ephemeron *e);
SCM_INTERNAL struct gc_ephemeron* scm_c_ephemeron_next (struct gc_ephemeron *e);
SCM_INTERNAL SCM scm_c_ephemeron_swap_x (struct gc_ephemeron *e, SCM new_val);
SCM_INTERNAL void scm_c_ephemeron_mark_dead_x (struct gc_ephemeron *e);
SCM_INTERNAL int scm_i_print_ephemeron (SCM exp, SCM port,
scm_print_state *pstate SCM_UNUSED);
SCM_INTERNAL struct gc_ephemeron* scm_to_ephemeron (SCM e);
SCM_INTERNAL SCM scm_from_ephemeron (struct gc_ephemeron *e);
SCM_INTERNAL struct scm_ephemeron_table* scm_c_make_ephemeron_table (size_t count);
SCM_INTERNAL size_t scm_c_ephemeron_table_length (struct scm_ephemeron_table *et);
SCM_INTERNAL struct gc_ephemeron*
scm_c_ephemeron_table_ref (struct scm_ephemeron_table *et, size_t idx);
SCM_INTERNAL void scm_c_ephemeron_table_push_x (struct scm_ephemeron_table *et,
size_t idx,
struct gc_ephemeron * e);
SCM_INTERNAL struct gc_ephemeron*
scm_c_ephemeron_table_try_push_x (struct scm_ephemeron_table *et,
size_t idx,
struct gc_ephemeron * e,
struct gc_ephemeron *prev);
SCM_INTERNAL struct scm_ephemeron_table*
scm_c_ephemeron_table_copy (struct scm_ephemeron_table *et);
SCM_INTERNAL int scm_i_print_ephemeron_table (SCM exp, SCM port,
scm_print_state *pstate SCM_UNUSED);
SCM_INTERNAL struct scm_ephemeron_table* scm_to_ephemeron_table (SCM e);
SCM_INTERNAL SCM scm_from_ephemeron_table (struct scm_ephemeron_table *e);
SCM_INTERNAL SCM
scm_c_ephemeron_hash_table_refq (struct scm_ephemeron_table *et, SCM k,
SCM default_value);
SCM_INTERNAL void
scm_c_ephemeron_hash_table_setq_x (struct scm_ephemeron_table *et, SCM k, SCM v);
SCM_INTERNAL void scm_register_ephemerons (void);
#endif /* SCM_EPHEMERONS_H */