weaks.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* classes: h_files */
  2. #ifndef SCM_WEAKS_H
  3. #define SCM_WEAKS_H
  4. /* Copyright (C) 1995,1996,2000,2001, 2003, 2006 Free Software Foundation, Inc.
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include "libguile/__scm.h"
  21. #define SCM_WVECTF_WEAK_KEY 1
  22. #define SCM_WVECTF_WEAK_VALUE 2
  23. #define SCM_WVECT_WEAK_KEY_P(x) (SCM_I_WVECT_EXTRA(x) & SCM_WVECTF_WEAK_KEY)
  24. #define SCM_WVECT_WEAK_VALUE_P(x) (SCM_I_WVECT_EXTRA(x) & SCM_WVECTF_WEAK_VALUE)
  25. /* The DELTA field is used by the abstract hash tables. During GC,
  26. this field will be set to the number of items that have been
  27. dropped. The abstract hash table will then use it to update its
  28. item count. DELTA is unsigned.
  29. */
  30. #define SCM_I_WVECT_DELTA(x) (SCM_I_WVECT_EXTRA(x) >> 3)
  31. #define SCM_I_SET_WVECT_DELTA(x,n) (SCM_I_SET_WVECT_EXTRA \
  32. ((x), ((SCM_I_WVECT_EXTRA (x) & 7) \
  33. | ((n) << 3))))
  34. #define SCM_I_WVECT_TYPE(x) (SCM_I_WVECT_EXTRA(x) & 7)
  35. #define SCM_I_SET_WVECT_TYPE(x,t) (SCM_I_SET_WVECT_EXTRA \
  36. ((x), (SCM_I_WVECT_EXTRA (x) & ~7) | (t)))
  37. #define SCM_IS_WHVEC(X) (SCM_I_WVECT_TYPE (X) == 1)
  38. #define SCM_IS_WHVEC_V(X) (SCM_I_WVECT_TYPE (X) == 2)
  39. #define SCM_IS_WHVEC_B(X) (SCM_I_WVECT_TYPE (X) == 3)
  40. #define SCM_IS_WHVEC_ANY(X) (SCM_I_WVECT_TYPE (X) != 0)
  41. SCM_API SCM scm_make_weak_vector (SCM k, SCM fill);
  42. SCM_API SCM scm_weak_vector (SCM l);
  43. SCM_API SCM scm_weak_vector_p (SCM x);
  44. SCM_API SCM scm_make_weak_key_alist_vector (SCM k);
  45. SCM_API SCM scm_make_weak_value_alist_vector (SCM k);
  46. SCM_API SCM scm_make_doubly_weak_alist_vector (SCM k);
  47. SCM_API SCM scm_weak_key_alist_vector_p (SCM x);
  48. SCM_API SCM scm_weak_value_alist_vector_p (SCM x);
  49. SCM_API SCM scm_doubly_weak_alist_vector_p (SCM x);
  50. SCM_API SCM scm_init_weaks_builtins (void);
  51. SCM_API void scm_init_weaks (void);
  52. SCM_API void scm_i_init_weak_vectors_for_gc (void);
  53. SCM_API void scm_i_mark_weak_vector (SCM w);
  54. SCM_API int scm_i_mark_weak_vectors_non_weaks (void);
  55. SCM_API void scm_i_remove_weaks_from_weak_vectors (void);
  56. #endif /* SCM_WEAKS_H */
  57. /*
  58. Local Variables:
  59. c-file-style: "gnu"
  60. End:
  61. */