bdw-gc.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef SCM_BDW_GC_H
  2. #define SCM_BDW_GC_H
  3. /* Copyright 2006,2008-2009,2011-2014,2018
  4. Free Software Foundation, Inc.
  5. This file is part of Guile.
  6. Guile is free software: you can redistribute it and/or modify it
  7. under the terms of the GNU Lesser General Public License as published
  8. by the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Guile is distributed in the hope that it will be useful, but WITHOUT
  11. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  13. License for more details.
  14. You should have received a copy of the GNU Lesser General Public
  15. License along with Guile. If not, see
  16. <https://www.gnu.org/licenses/>. */
  17. /* Correct header inclusion. */
  18. #include "libguile/scmconfig.h"
  19. #if SCM_USE_PTHREAD_THREADS
  20. /* When pthreads are used, let `libgc' know about it and redirect allocation
  21. calls such as `GC_MALLOC ()' to (contention-free, faster) thread-local
  22. allocation. */
  23. # define GC_THREADS 1
  24. # define GC_REDIRECT_TO_LOCAL 1
  25. /* Don't #define pthread routines to their GC_pthread counterparts.
  26. Instead we will be careful inside Guile to use the GC_pthread
  27. routines. */
  28. # define GC_NO_THREAD_REDIRECTS 1
  29. #ifdef __MINGW32__
  30. /* Rely on pthreads-w32. */
  31. #define GC_WIN32_PTHREADS
  32. #endif
  33. #endif
  34. #include <gc/gc.h>
  35. /* Return true if PTR points to the heap. */
  36. #define SCM_I_IS_POINTER_TO_THE_HEAP(ptr) \
  37. (GC_base (ptr) != NULL)
  38. /* Register a disappearing link for the object pointed to by OBJ such that
  39. the pointer pointed to be LINK is cleared when OBJ is reclaimed. Do so
  40. only if OBJ actually points to the heap. See
  41. http://thread.gmane.org/gmane.comp.programming.garbage-collection.boehmgc/2563
  42. for details. */
  43. #define SCM_I_REGISTER_DISAPPEARING_LINK(link, obj) \
  44. ((SCM_I_IS_POINTER_TO_THE_HEAP (obj)) \
  45. ? GC_GENERAL_REGISTER_DISAPPEARING_LINK ((link), (obj)) \
  46. : 0)
  47. #endif /* SCM_BDW_GC_H */