1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

Remove tests and shims for pre-7.2 bdw-gc.

* configure.ac: Remove checks for symbols present in bdw-gc 7.2.

* libguile/finalizers.c:
* libguile/gc-malloc.c:
* libguile/gc.c:
* libguile/guardians.c:
* libguile/scmsigs.c:
* libguile/threads.c: Remove shims.
This commit is contained in:
Andy Wingo 2013-11-22 10:51:56 +01:00
parent d86682ba2c
commit 03d1294977
7 changed files with 8 additions and 278 deletions

View file

@ -1246,36 +1246,11 @@ save_LIBS="$LIBS"
LIBS="$BDW_GC_LIBS $LIBS"
CFLAGS="$BDW_GC_CFLAGS $CFLAGS"
AC_CHECK_FUNCS([GC_do_blocking GC_call_with_gc_active GC_pthread_exit \
GC_pthread_cancel GC_allow_register_threads GC_pthread_sigmask \
GC_set_start_callback GC_get_suspend_signal GC_move_disappearing_link \
GC_get_heap_usage_safe GC_get_free_space_divisor \
GC_gcollect_and_unmap GC_get_unmapped_bytes GC_set_finalizer_notifier \
GC_set_finalize_on_demand GC_set_all_interior_pointers GC_get_gc_no \
GC_set_java_finalization])
# Functions that might not be defined, depending on configuration.
AC_CHECK_FUNCS([GC_pthread_exit GC_pthread_cancel GC_pthread_sigmask])
# Though the `GC_do_blocking ()' symbol is present in GC 7.1, it is not
# declared, and has a different type (returning void instead of
# void*).
AC_CHECK_DECL([GC_do_blocking],
[AC_DEFINE([HAVE_DECL_GC_DO_BLOCKING], [1],
[Define this if the `GC_do_blocking ()' function is declared])],
[],
[#include <gc/gc.h>])
# `GC_fn_type' is not available in GC 7.1 and earlier.
AC_CHECK_TYPE([GC_fn_type],
[AC_DEFINE([HAVE_GC_FN_TYPE], [1],
[Define this if the `GC_fn_type' type is available.])],
[],
[#include <gc/gc.h>])
# `GC_stack_base' is not available in GC 7.1 and earlier.
AC_CHECK_TYPE([struct GC_stack_base],
[AC_DEFINE([HAVE_GC_STACK_BASE], [1],
[Define this if the `GC_stack_base' type is available.])],
[],
[#include <gc/gc.h>])
# Functions from GC 7.3.
AC_CHECK_FUNCS([GC_move_disappearing_link])
LIBS="$save_LIBS"

View file

@ -41,17 +41,6 @@
static size_t finalization_count;
#ifndef HAVE_GC_SET_FINALIZER_NOTIFIER
static void
GC_set_finalizer_notifier (void (*notifier) (void))
{
GC_finalizer_notifier = notifier;
}
#endif
void

View file

@ -1,5 +1,5 @@
/* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
* 2004, 2006, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
* 2004, 2006, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@ -134,11 +134,7 @@ scm_realloc (void *mem, size_t size)
return ptr;
/* Time is hard: trigger a full, ``stop-the-world'' GC, and try again. */
#ifdef HAVE_GC_GCOLLECT_AND_UNMAP
GC_gcollect_and_unmap ();
#else
GC_gcollect ();
#endif
ptr = do_realloc (mem, size);
if (ptr)

View file

@ -282,13 +282,7 @@ SCM_DEFINE (scm_gc_stats, "gc-stats", 0, 0, 0,
GC_get_heap_usage_safe (&heap_size, &free_bytes, &unmapped_bytes,
&bytes_since_gc, &total_bytes);
#ifdef HAVE_GC_GET_GC_NO
/* This function was added in 7.2alpha2 (June 2009). */
gc_times = GC_get_gc_no ();
#else
/* This symbol is deprecated as of 7.3. */
gc_times = GC_gc_no;
#endif
answer =
scm_list_n (scm_cons (sym_gc_time_taken, scm_from_long (gc_time_taken)),
@ -589,13 +583,7 @@ scm_getenv_int (const char *var, int def)
void
scm_storage_prehistory ()
{
#ifdef HAVE_GC_SET_ALL_INTERIOR_POINTERS
/* This function was added in 7.2alpha2 (June 2009). */
GC_set_all_interior_pointers (0);
#else
/* This symbol is deprecated in 7.3. */
GC_all_interior_pointers = 0;
#endif
free_space_divisor = scm_getenv_int ("GC_FREE_SPACE_DIVISOR", 3);
minimum_free_space_divisor = free_space_divisor;

View file

@ -355,13 +355,7 @@ void
scm_init_guardians ()
{
/* We use unordered finalization `a la Java. */
#ifdef HAVE_GC_SET_JAVA_FINALIZATION
/* This function was added in 7.2alpha2 (June 2009). */
GC_set_java_finalization (1);
#else
/* This symbol is deprecated as of 7.3. */
GC_java_finalization = 1;
#endif
tc16_guardian = scm_make_smob_type ("guardian", 0);

View file

@ -142,28 +142,6 @@ struct signal_pipe_data
int err;
};
#ifndef HAVE_GC_GET_SUSPEND_SIGNAL
static int
GC_get_suspend_signal (void)
{
#if defined SIG_SUSPEND
return SIG_SUSPEND;
#elif defined SIGPWR
return SIGPWR;
#elif defined SIGLOST
return SIGLOST;
#elif defined _SIGRTMIN
return _SIGRTMIN + 6;
#elif defined SIGRTMIN
return SIGRTMIN + 6;
#elif defined __GLIBC__
return 32+6;
#else
return SIGUSR1;
#endif
}
#endif /* HAVE_GC_GET_SUSPEND_SIGNAL */
static void*
read_signal_pipe_data (void * data)
{

View file

@ -69,196 +69,6 @@
#include <full-read.h>
/* First some libgc shims. */
/* Make sure GC_fn_type is defined; it is missing from the public
headers of GC 7.1 and earlier. */
#ifndef HAVE_GC_FN_TYPE
typedef void * (* GC_fn_type) (void *);
#endif
#ifndef GC_SUCCESS
#define GC_SUCCESS 0
#endif
#ifndef GC_UNIMPLEMENTED
#define GC_UNIMPLEMENTED 3
#endif
/* Likewise struct GC_stack_base is missing before 7.1. */
#ifndef HAVE_GC_STACK_BASE
struct GC_stack_base {
void * mem_base; /* Base of memory stack. */
#ifdef __ia64__
void * reg_base; /* Base of separate register stack. */
#endif
};
static int
GC_register_my_thread (struct GC_stack_base *stack_base)
{
return GC_UNIMPLEMENTED;
}
static void
GC_unregister_my_thread ()
{
}
#if !SCM_USE_PTHREAD_THREADS
/* No threads; we can just use GC_stackbottom. */
static void *
get_thread_stack_base ()
{
return GC_stackbottom;
}
#elif defined HAVE_PTHREAD_ATTR_GETSTACK && defined HAVE_PTHREAD_GETATTR_NP \
&& defined PTHREAD_ATTR_GETSTACK_WORKS
/* This method for GNU/Linux and perhaps some other systems.
It's not for MacOS X or Solaris 10, since pthread_getattr_np is not
available on them. */
static void *
get_thread_stack_base ()
{
pthread_attr_t attr;
void *start, *end;
size_t size;
pthread_getattr_np (pthread_self (), &attr);
pthread_attr_getstack (&attr, &start, &size);
end = (char *)start + size;
#if SCM_STACK_GROWS_UP
return start;
#else
return end;
#endif
}
#elif defined HAVE_PTHREAD_GET_STACKADDR_NP
/* This method for MacOS X.
It'd be nice if there was some documentation on pthread_get_stackaddr_np,
but as of 2006 there's nothing obvious at apple.com. */
static void *
get_thread_stack_base ()
{
return pthread_get_stackaddr_np (pthread_self ());
}
#elif HAVE_PTHREAD_ATTR_GET_NP
/* This one is for FreeBSD 9. */
static void *
get_thread_stack_base ()
{
pthread_attr_t attr;
void *start, *end;
size_t size;
pthread_attr_init (&attr);
pthread_attr_get_np (pthread_self (), &attr);
pthread_attr_getstack (&attr, &start, &size);
pthread_attr_destroy (&attr);
end = (char *)start + size;
#if SCM_STACK_GROWS_UP
return start;
#else
return end;
#endif
}
#else
#error Threads enabled with old BDW-GC, but missing get_thread_stack_base impl. Please upgrade to libgc >= 7.1.
#endif
static int
GC_get_stack_base (struct GC_stack_base *stack_base)
{
stack_base->mem_base = get_thread_stack_base ();
#ifdef __ia64__
/* Calculate and store off the base of this thread's register
backing store (RBS). Unfortunately our implementation(s) of
scm_ia64_register_backing_store_base are only reliable for the
main thread. For other threads, therefore, find out the current
top of the RBS, and use that as a maximum. */
stack_base->reg_base = scm_ia64_register_backing_store_base ();
{
ucontext_t ctx;
void *bsp;
getcontext (&ctx);
bsp = scm_ia64_ar_bsp (&ctx);
if (stack_base->reg_base > bsp)
stack_base->reg_base = bsp;
}
#endif
return GC_SUCCESS;
}
static void *
GC_call_with_stack_base(void * (*fn) (struct GC_stack_base*, void*), void *arg)
{
struct GC_stack_base stack_base;
stack_base.mem_base = (void*)&stack_base;
#ifdef __ia64__
/* FIXME: Untested. */
{
ucontext_t ctx;
getcontext (&ctx);
stack_base.reg_base = scm_ia64_ar_bsp (&ctx);
}
#endif
return fn (&stack_base, arg);
}
#endif /* HAVE_GC_STACK_BASE */
/* Now define with_gc_active and with_gc_inactive. */
#if (defined(HAVE_GC_DO_BLOCKING) && defined (HAVE_DECL_GC_DO_BLOCKING) && defined (HAVE_GC_CALL_WITH_GC_ACTIVE))
/* We have a sufficiently new libgc (7.2 or newer). */
static void*
with_gc_inactive (GC_fn_type func, void *data)
{
return GC_do_blocking (func, data);
}
static void*
with_gc_active (GC_fn_type func, void *data)
{
return GC_call_with_gc_active (func, data);
}
#else
/* libgc not new enough, so never actually deactivate GC.
Note that though GC 7.1 does have a GC_do_blocking, it doesn't have
GC_call_with_gc_active. */
static void*
with_gc_inactive (GC_fn_type func, void *data)
{
return func (data);
}
static void*
with_gc_active (GC_fn_type func, void *data)
{
return func (data);
}
#endif /* HAVE_GC_DO_BLOCKING */
static void
to_timespec (SCM t, scm_t_timespec *waittime)
@ -835,7 +645,7 @@ scm_i_init_thread_for_guile (struct GC_stack_base *base, SCM parent)
*/
scm_i_init_guile (base);
#if defined (HAVE_GC_ALLOW_REGISTER_THREADS) && SCM_USE_PTHREAD_THREADS
#if SCM_USE_PTHREAD_THREADS
/* Allow other threads to come in later. */
GC_allow_register_threads ();
#endif
@ -934,7 +744,7 @@ with_guile_and_parent (struct GC_stack_base *base, void *data)
#endif
t->guile_mode = 1;
res = with_gc_active (with_guile_trampoline, args);
res = GC_call_with_gc_active (with_guile_trampoline, args);
t->guile_mode = 0;
}
return res;
@ -968,7 +778,7 @@ scm_without_guile (void *(*func)(void *), void *data)
if (t->guile_mode)
{
SCM_I_CURRENT_THREAD->guile_mode = 0;
result = with_gc_inactive (func, data);
result = GC_do_blocking (func, data);
SCM_I_CURRENT_THREAD->guile_mode = 1;
}
else