bdw-gc.h 2.2 KB

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