2009-09-13 15:59:31 +02:00
|
|
|
#ifndef SCM_BDW_GC_H
|
|
|
|
|
#define SCM_BDW_GC_H
|
2006-12-03 21:59:02 +00:00
|
|
|
|
2014-02-02 16:04:58 +01:00
|
|
|
/* Copyright (C) 2006, 2008, 2009, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
|
2006-12-03 21:59:02 +00:00
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2009-09-13 15:59:31 +02:00
|
|
|
* modify it under the terms of the GNU Lesser General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 3 of
|
|
|
|
|
* the License, or (at your option) any later version.
|
2006-12-03 21:59:02 +00:00
|
|
|
*
|
2009-09-13 15:59:31 +02:00
|
|
|
* This library is distributed in the hope that it will be useful, but
|
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
2006-12-03 21:59:02 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2009-09-13 15:59:31 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
|
* 02110-1301 USA
|
2006-12-03 21:59:02 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* Correct header inclusion. */
|
|
|
|
|
|
2009-08-20 01:14:14 +02:00
|
|
|
#include "libguile/scmconfig.h"
|
2006-12-03 21:59:02 +00:00
|
|
|
|
2014-03-13 23:21:48 -04:00
|
|
|
#if SCM_USE_PTHREAD_THREADS
|
2006-12-03 21:59:02 +00:00
|
|
|
|
|
|
|
|
/* When pthreads are used, let `libgc' know about it and redirect allocation
|
|
|
|
|
calls such as `GC_MALLOC ()' to (contention-free, faster) thread-local
|
|
|
|
|
allocation. */
|
|
|
|
|
|
|
|
|
|
# define GC_THREADS 1
|
|
|
|
|
# define GC_REDIRECT_TO_LOCAL 1
|
|
|
|
|
|
2011-03-25 13:01:51 +01:00
|
|
|
/* Don't #define pthread routines to their GC_pthread counterparts.
|
|
|
|
|
Instead we will be careful inside Guile to use the GC_pthread
|
|
|
|
|
routines. */
|
|
|
|
|
# define GC_NO_THREAD_REDIRECTS 1
|
|
|
|
|
|
2013-03-09 22:27:59 +01:00
|
|
|
#ifdef __MINGW32__
|
|
|
|
|
/* Rely on pthreads-w32. */
|
|
|
|
|
#define GC_WIN32_PTHREADS
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-12-03 21:59:02 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <gc/gc.h>
|
2008-09-11 00:44:13 +02:00
|
|
|
|
2009-01-31 19:14:56 +01:00
|
|
|
/* Return true if PTR points to the heap. */
|
2009-02-01 21:59:32 +01:00
|
|
|
#define SCM_I_IS_POINTER_TO_THE_HEAP(ptr) \
|
|
|
|
|
(GC_base (ptr) != NULL)
|
2009-01-31 19:14:56 +01:00
|
|
|
|
|
|
|
|
/* Register a disappearing link for the object pointed to by OBJ such that
|
|
|
|
|
the pointer pointed to be LINK is cleared when OBJ is reclaimed. Do so
|
|
|
|
|
only if OBJ actually points to the heap. See
|
|
|
|
|
http://thread.gmane.org/gmane.comp.programming.garbage-collection.boehmgc/2563
|
|
|
|
|
for details. */
|
|
|
|
|
#define SCM_I_REGISTER_DISAPPEARING_LINK(link, obj) \
|
|
|
|
|
((SCM_I_IS_POINTER_TO_THE_HEAP (obj)) \
|
|
|
|
|
? GC_GENERAL_REGISTER_DISAPPEARING_LINK ((link), (obj)) \
|
|
|
|
|
: 0)
|
|
|
|
|
|
|
|
|
|
|
2009-09-13 15:59:31 +02:00
|
|
|
#endif /* SCM_BDW_GC_H */
|