diff options
author | Ludovic Courtes <ludovic.courtes@laas.fr> | 2006-06-25 22:42:19 +0000 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2008-09-10 20:27:34 +0200 |
commit | 986ec82209fe327e44dc897d8f5219b1f53ed939 (patch) | |
tree | 6fe27be780eebef2a160ae1e83fa49b0fcbac93e /libguile/weaks.h | |
parent | c6a35e35f76e800bd85cb28e6ace743aedd87e61 (diff) | |
download | guile-986ec82209fe327e44dc897d8f5219b1f53ed939.tar.gz |
Moved weak pair code into `weaks.[ch]'.
* libguile/hashtab.c: Don't include <gc/gc_typed.h> and <gc/gc.h>.
Updated users of weak
(wcar_cell_descr): Removed.
(wcdr_cell_descr): Removed.
(scm_weak_car_cell): Removed.
(scm_weak_cdr_cell): Removed.
(scm_doubly_weak_cell): Removed.
(SCM_WEAK_CELL_*_DELETED_P): Removed.
(SCM_WEAK_CELL_WORD): Removed.
(SCM_WEAK_CELL_C[AD]R): Removed.
(scm_hashtab_prehistory): Don't initialize weak pairs.
* libguile/init.c (scm_i_init_guile): Invoke `scm_weaks_prehistory ()'
before `scm_hashtab_prehistory ()' in order to initialize weak pairs.
* libguile/weaks.c: Include <gc/gc.h> and <gc/gc_typed.h>.
(wc[ad]r_cell_descr): New.
(scm_weak_c[ad]r_pair): New.
(scm_doubly_weak_pair): New.
(scm_weaks_prehistory): New.
* libguile/weaks.h (scm_weak_c[ad]r_pair): New declaration.
(scm_doubly_weak_pair): New declaration.
(SCM_WEAK_PAIR_WORD_DELETED_P): New.
(SCM_WEAK_PAIR_CAR_DELETED_P): New.
(SCM_WEAK_PAIR_CDR_DELETED_P): New.
(SCM_WEAK_PAIR_DELETED_P): New.
(SCM_WEAK_PAIR_WORD): New.
(SCM_WEAK_PAIR_CAR): New.
(SCM_WEAK_PAIR_CDR): New.
git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-39
Diffstat (limited to 'libguile/weaks.h')
-rw-r--r-- | libguile/weaks.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/libguile/weaks.h b/libguile/weaks.h index ec9e7b4f9..128ee8869 100644 --- a/libguile/weaks.h +++ b/libguile/weaks.h @@ -52,6 +52,34 @@ #define SCM_IS_WHVEC_ANY(X) (SCM_I_WVECT_TYPE (X) != 0) +/* Weak pairs. */ + +SCM_API SCM scm_weak_car_pair (SCM car, SCM cdr); +SCM_API SCM scm_weak_cdr_pair (SCM car, SCM cdr); +SCM_API SCM scm_doubly_weak_pair (SCM car, SCM cdr); + +/* Testing the weak component(s) of a cell for reachability. */ +#define SCM_WEAK_PAIR_WORD_DELETED_P(_cell, _word) \ + (SCM_CELL_OBJECT ((_cell), (_word)) == SCM_PACK (NULL)) +#define SCM_WEAK_PAIR_CAR_DELETED_P(_cell) \ + (SCM_WEAK_PAIR_WORD_DELETED_P ((_cell), 0)) +#define SCM_WEAK_PAIR_CDR_DELETED_P(_cell) \ + (SCM_WEAK_PAIR_WORD_DELETED_P ((_cell), 1)) + +#define SCM_WEAK_PAIR_DELETED_P(_cell) \ + ((SCM_WEAK_PAIR_CAR_DELETED_P (_cell)) \ + || (SCM_WEAK_PAIR_CDR_DELETED_P (_cell))) + +/* Accessing the components of a weak cell. */ +#define SCM_WEAK_PAIR_WORD(_cell, _word) \ + ((SCM_WEAK_PAIR_WORD_DELETED_P ((_cell), (_word))) \ + ? SCM_BOOL_F : SCM_CAR (pair)) +#define SCM_WEAK_PAIR_CAR(_cell) (SCM_WEAK_PAIR_WORD ((_cell), 0)) +#define SCM_WEAK_PAIR_CDR(_cell) (SCM_WEAK_PAIR_WORD ((_cell), 1)) + + + +/* Weak vectors and weak hash tables. */ SCM_API SCM scm_make_weak_vector (SCM k, SCM fill); SCM_API SCM scm_weak_vector (SCM l); @@ -63,6 +91,7 @@ SCM_API SCM scm_weak_key_alist_vector_p (SCM x); SCM_API SCM scm_weak_value_alist_vector_p (SCM x); SCM_API SCM scm_doubly_weak_alist_vector_p (SCM x); SCM_API SCM scm_init_weaks_builtins (void); +SCM_API void scm_weaks_prehistory (void); SCM_API void scm_init_weaks (void); SCM_API void scm_i_init_weak_vectors_for_gc (void); |