mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-02 18:26:20 +02:00
* libguile/ephemerons.h: * libguile/ephemerons.c (scm_c_ephemeron_load, scm_c_ephemeron_push): New routines. * libguile/ioext.c (scm_fdes_to_ports): Rework in terms of scm_c_port_for_each. * libguile/ports-internal.h (struct scm_t_port): Add pointer to entry on weak ports list, so that we can cancel it easily. * libguile/ports.c (release_port): Mark weak ports list entry as dead. (all_ports_needing_close, for_each_port_needing_close): Rework as ephemeron chain. (scm_c_make_port_with_encoding, close_port, scm_c_port_for_each): Adapt API. (scm_init_ports): No more weak set.
74 lines
3.2 KiB
C
74 lines
3.2 KiB
C
#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 gc_ephemeron* scm_c_ephemeron_load (struct gc_ephemeron **loc);
|
||
SCM_INTERNAL void scm_c_ephemeron_push (struct gc_ephemeron **loc,
|
||
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 */
|