On Sun, Jan 11, 2026, at 4:05 PM, Jose E. Marchesi wrote:
> Hello Pietro.
> Thanks for the patch.
>
>> 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 GC_DEBUG if the user wants and swtich all
>> `GC_` calls to the corresponding macros.
>>
>>      * configure: Regenerate.
>>      * configure.ac: Add --enable-algol68-gc-debug option and
>>      define LIBGA68_DEBUG_GC accordingly.
>>      * ga68-alloc.c (GC_DEBUG): Define macro if LIBGA68_DEBUG_GC is
>>      true.
>
>
> Why not defining GC_DEBUG directly instead of going through
> LIBGA_DEBUG_GC?

I thought that would be nice to have more flexibility in case we want
to do other things when debugging allocation functions.

pietro

>>      (_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    | 31 +++++++++++++++++++++++++++++--
>>  libga68/configure.ac | 20 ++++++++++++++++++++
>>  libga68/ga68-alloc.c | 11 ++++++++---
>>  3 files changed, 57 insertions(+), 5 deletions(-)
>>
>> diff --git a/libga68/configure b/libga68/configure
>> index 63c27939e14..2ecee900035 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,21 @@ case $host in
>>  esac
>>  
>>  
>> +case "$enable_algol68_gc_debug" in
>> +  no)
>> +    if test "$use_bdw_gc" = yes; then
>> +      LIBGA68_GCFLAGS="$LIBGA68_GCFLAGS -DLIBGA68_DEBUG_GC=0"
>> +    fi
>> +    ;;
>> +  *)
>> +    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 -DLIBGA68_DEBUG_GC=1"
>> +    fi
>> +    ;;
>> +esac
>> +
>>  # Subst some variables used in Makefile.am
>>  
>>  
>> diff --git a/libga68/configure.ac b/libga68/configure.ac
>> index 20a903ad8d9..c8aa032fba4 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,21 @@ case $host in
>>  esac
>>  AC_SUBST(extra_darwin_ldflags_libga68)
>>  
>> +case "$enable_algol68_gc_debug" in
>> +  no)
>> +    if test "$use_bdw_gc" = yes; then
>> +      LIBGA68_GCFLAGS="$LIBGA68_GCFLAGS -DLIBGA68_DEBUG_GC=0"
>> +    fi
>> +    ;;
>> +  *)
>> +    if test "$use_bdw_gc" = no; then
>> +      AC_MSG_ERROR([GC debugging enabled but GC is not being used])
>> +    else
>> +      LIBGA68_GCFLAGS="$LIBGA68_GCFLAGS -DLIBGA68_DEBUG_GC=1"
>> +    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..77abf592b8f 100644
>> --- a/libga68/ga68-alloc.c
>> +++ b/libga68/ga68-alloc.c
>> @@ -43,6 +43,11 @@ _libga68_malloc_internal (size_t size)
>>  }
>>  
>>  #if LIBGA68_WITH_GC
>> +
>> +# if LIBGA68_DEBUG_GC
>> +#  define GC_DEBUG 1
>> +#endif
>> +
>>  #include <gc/gc.h>
>>  
>>  void
>> @@ -58,7 +63,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 +72,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

Reply via email to