bdw-gc.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef SCM_BDW_GC_H
  2. #define SCM_BDW_GC_H
  3. /* Copyright (C) 2006, 2008, 2009, 2011, 2012, 2013, 2014 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. #if 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. #ifdef __MINGW32__
  33. /* Rely on pthreads-w32. */
  34. #define GC_WIN32_PTHREADS
  35. #endif
  36. #endif
  37. #include <gc/gc.h>
  38. /* Return true if PTR points to the heap. */
  39. #define SCM_I_IS_POINTER_TO_THE_HEAP(ptr) \
  40. (GC_base (ptr) != NULL)
  41. /* Register a disappearing link for the object pointed to by OBJ such that
  42. the pointer pointed to be LINK is cleared when OBJ is reclaimed. Do so
  43. only if OBJ actually points to the heap. See
  44. http://thread.gmane.org/gmane.comp.programming.garbage-collection.boehmgc/2563
  45. for details. */
  46. #define SCM_I_REGISTER_DISAPPEARING_LINK(link, obj) \
  47. ((SCM_I_IS_POINTER_TO_THE_HEAP (obj)) \
  48. ? GC_GENERAL_REGISTER_DISAPPEARING_LINK ((link), (obj)) \
  49. : 0)
  50. #endif /* SCM_BDW_GC_H */