If GC_DEBUG is defined then all-upper-case macros will expand to calls
to the debug variant of collector functions.
So add the configury bit to define GC_DEBUG if the user wants and
switch all `GC_` calls to the corresponding macros.
libga68/ChangeLog:
* configure: Regenerate.
* configure.ac: Add --enable-algol68-gc-debug option and
define GC_DEBUG accordingly.
* ga68-alloc.c (_libga68_realloc): Use the C macro version of
the GC function.
(_libga68_realloc_unchecked): Likewise.
(_libga68_malloc): Likewise.
Signed-off-by: Pietro Monteiro <[email protected]>
---
libga68/configure | 27 +++++++++++++++++++++++++--
libga68/configure.ac | 16 ++++++++++++++++
libga68/ga68-alloc.c | 6 +++---
3 files changed, 44 insertions(+), 5 deletions(-)
diff --git a/libga68/configure b/libga68/configure
index 63c27939e14..5d652d6fd81 100755
--- a/libga68/configure
+++ b/libga68/configure
@@ -811,6 +811,7 @@ enable_algol68_gc
with_target_bdw_gc
with_target_bdw_gc_include
with_target_bdw_gc_lib
+enable_algol68_gc_debug
'
ac_precious_vars='build_alias
host_alias
@@ -1463,6 +1464,9 @@ Optional Features:
--disable-symvers disable symbol versioning for libga68
--enable-algol68-gc enable use of Boehm's garbage collector with the GNU
Algol runtime
+ --enable-algol68-gc-debug
+ enable use of Boehm's garbage collector debug
+ functions with the GNU Algol runtime
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -12829,7 +12833,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12832 "configure"
+#line 12836 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -12935,7 +12939,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12938 "configure"
+#line 12942 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -13532,6 +13536,14 @@ if test "${with_target_bdw_gc_lib+set}" = set; then :
fi
+# Check whether --enable-algol68-gc-debug was given.
+if test "${enable_algol68_gc_debug+set}" = set; then :
+ enableval=$enable_algol68_gc_debug;
+else
+ enable_algol68_gc_debug=no
+fi
+
+
bdw_lib_dir=
case "$enable_algol68_gc" in
no)
@@ -13719,6 +13731,17 @@ case $host in
esac
+case "$enable_algol68_gc_debug" in
+ no) ;;
+ *)
+ if test "$use_bdw_gc" = no; then
+ as_fn_error $? "GC debugging enabled but GC is not being used" "$LINENO"
5
+ else
+ LIBGA68_GCFLAGS="$LIBGA68_GCFLAGS -DGC_DEBUG"
+ fi
+ ;;
+esac
+
# Subst some variables used in Makefile.am
diff --git a/libga68/configure.ac b/libga68/configure.ac
index 20a903ad8d9..27a73b0c2ed 100644
--- a/libga68/configure.ac
+++ b/libga68/configure.ac
@@ -248,6 +248,11 @@ AC_ARG_WITH([target-bdw-gc-lib],
[AS_HELP_STRING([--with-target-bdw-gc-lib=PATHLIST],
[specify directories for installed bdw-gc library])])
+AC_ARG_ENABLE(algol68-gc-debug,
+[AS_HELP_STRING([--enable-algol68-gc-debug],
+ [enable use of Boehm's garbage collector debug functions
+ with the GNU Algol runtime])],,enable_algol68_gc_debug=no)
+
bdw_lib_dir=
case "$enable_algol68_gc" in
no)
@@ -405,6 +410,17 @@ case $host in
esac
AC_SUBST(extra_darwin_ldflags_libga68)
+case "$enable_algol68_gc_debug" in
+ no) ;;
+ *)
+ if test "$use_bdw_gc" = no; then
+ AC_MSG_ERROR([GC debugging enabled but GC is not being used])
+ else
+ LIBGA68_GCFLAGS="$LIBGA68_GCFLAGS -DGC_DEBUG"
+ fi
+ ;;
+esac
+
# Subst some variables used in Makefile.am
AC_SUBST(LIBGA68_GCFLAGS)
AC_SUBST(LIBGA68_BOEHM_GC_INCLUDES)
diff --git a/libga68/ga68-alloc.c b/libga68/ga68-alloc.c
index 5e9f7c2b920..1a0b25a098c 100644
--- a/libga68/ga68-alloc.c
+++ b/libga68/ga68-alloc.c
@@ -58,7 +58,7 @@ _libga68_init_heap (void)
void *
_libga68_realloc (void *ptr, size_t size)
{
- void *res = (void *) GC_realloc (ptr, size);
+ void *res = (void *) GC_REALLOC (ptr, size);
if (!res)
_libga68_abort ("Virtual memory exhausted\n");
return res;
@@ -67,14 +67,14 @@ _libga68_realloc (void *ptr, size_t size)
void *
_libga68_realloc_unchecked (void *ptr, size_t size)
{
- void *res = (void *) GC_realloc (ptr, size);
+ void *res = (void *) GC_REALLOC (ptr, size);
return res;
}
void *
_libga68_malloc (size_t size)
{
- void *res = (void *) GC_malloc (size);
+ void *res = (void *) GC_MALLOC (size);
if (!res)
_libga68_abort ("Virtual memory exhausted\n");
return res;
base-commit: 87222af419eb272d4b66628abda573ba8fcadc77
--
2.43.0