[Gc] Dependency tracking for configuration macros

Petter Urkedal urkedal at nbi.dk
Sat Sep 12 01:55:45 PDT 2009


On 2009-09-12, Ivan Maidanski wrote:
> Hi!
> 
> Petter Urkedal <urkedal at nbi.dk> wrote:
> > On 2009-09-11, Ivan Maidanski wrote:
> > > Petter, could you repost all your ideas and pending suggested patches regarding build scripts (including for acinclude.m4) having today's CVS shapshot? (It's now possible to have config.h at GC build.) It might be good to freshen some scripts now.
> > 
> > I can see you already added the "#include"s, so the new patch mostly
> > affects the build files.  I put config.h under private since that's how
> > they're used.
> 
> My considerations below are for .c/h files only (the script changes are for review by Hans).
> 
> 1. I don't think "config.h" -> "private/config.h" change is needed for gc_priv.h and gc_pmark.h (unless you are having a broken compiler like old BCC32).

It is needed when not building from source directory.

> 2. I'll post a standalone patch dealing with "config.h" -> "private/config.h" change in gc_cpp.cc, tests/test.c and include "private/config.h" addition in test_cpp.cc (I also add #undef GC_BUILD to it like in test.c).

Okay, I split up the changes at
http://git.eideticdew.org/cgit/~urkedal/bdwgc/log/?h=t-config_h which
contains (attached)

Patch 1

Fix/add inclusion of private/config.h.
    * include/private/gc_priv.h, include/private/gc_pmark.h, gc_cpp.cc,
    tests/test.c: Change include of config.h to private/config.h.
    * tests/test_cpp.cc: Include private/config.h.

Patch 2

Generate and use config.h instead of -D options.
    * configure.ac: Move include flag from ${INCLUDE} ...
    * Makefile.am: ... to AM_CPPFLAGS and also add the build directory.

    * configure.ac: Call AM_CONFIG_HEADER([include/private/config.h]).
    * configure.ac: Add documentation to all AC_DEFINE either directly
    or using AH_TEMPLATE.
-------------- next part --------------
diff --git a/gc_cpp.cc b/gc_cpp.cc
index eb53437..4d00130 100644
--- a/gc_cpp.cc
+++ b/gc_cpp.cc
@@ -24,7 +24,7 @@ Authors: John R. Ellis and Jesse Hull
 **************************************************************************/
 
 # ifdef HAVE_CONFIG_H
-#   include "config.h"
+#   include "private/config.h"
 # endif
 
 # ifndef GC_BUILD
diff --git a/include/private/gc_pmark.h b/include/private/gc_pmark.h
index 4b0ccd5..3dc46a8 100644
--- a/include/private/gc_pmark.h
+++ b/include/private/gc_pmark.h
@@ -26,7 +26,7 @@
 # define GC_PMARK_H
 
 # ifdef HAVE_CONFIG_H
-#   include "config.h"
+#   include "private/config.h"
 # endif
 
 # ifndef GC_BUILD
diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h
index 39eb8e5..94954c6 100644
--- a/include/private/gc_priv.h
+++ b/include/private/gc_priv.h
@@ -20,7 +20,7 @@
 # define GC_PRIVATE_H
 
 # ifdef HAVE_CONFIG_H
-#   include "config.h"
+#   include "private/config.h"
 # endif
 
 # ifndef GC_BUILD
diff --git a/tests/test.c b/tests/test.c
index b328522..01037dd 100644
--- a/tests/test.c
+++ b/tests/test.c
@@ -19,7 +19,7 @@
 /* checking for some of the tests.				*/
 
 # ifdef HAVE_CONFIG_H
-#   include "config.h"
+#   include "private/config.h"
 # endif
 
 # undef GC_BUILD
diff --git a/tests/test_cpp.cc b/tests/test_cpp.cc
index 98cb281..6847576 100644
--- a/tests/test_cpp.cc
+++ b/tests/test_cpp.cc
@@ -24,6 +24,9 @@ few minutes to complete.
 
 ***************************************************************************/
 
+#ifdef HAVE_CONFIG_H
+#  include <private/config.h>
+#endif
 #include "gc_cpp.h"
 #include <stdio.h>
 #include <stdlib.h>
-------------- next part --------------
diff --git a/Makefile.am b/Makefile.am
index fb658e2..6fb4a47 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -32,6 +32,8 @@
 # endif
 SUBDIRS =
 
+AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include
+
 # Initialize variables so that we can declare files locally.
 EXTRA_DIST = 
 lib_LTLIBRARIES =
diff --git a/acinclude.m4 b/acinclude.m4
index 72602a0..070f85d 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -37,10 +37,13 @@ AC_DEFUN(GC_SET_VERSION, [
     AC_MSG_ERROR([nonconforming PACKAGE_VERSION='$PACKAGE_VERSION'])
   fi
   
-  AC_DEFINE_UNQUOTED(GC_VERSION_MAJOR, $GC_VERSION_MAJOR)
-  AC_DEFINE_UNQUOTED(GC_VERSION_MINOR, $GC_VERSION_MINOR)
+  AC_DEFINE_UNQUOTED([GC_VERSION_MAJOR], $GC_VERSION_MAJOR,
+		     [The major version number of this GC release.])
+  AC_DEFINE_UNQUOTED([GC_VERSION_MINOR], $GC_VERSION_MINOR,
+		     [The minor version number of this GC release.])
   if test :$GC_ALPHA_VERSION: != :: ; then
-    AC_DEFINE_UNQUOTED(GC_ALPHA_VERSION, $GC_ALPHA_VERSION)
+    AC_DEFINE_UNQUOTED([GC_ALPHA_VERSION], $GC_ALPHA_VERSION,
+		       [The alpha version number, if applicable.])
   fi
   AC_MSG_RESULT(major=$GC_VERSION_MAJOR minor=$GC_VERSION_MINOR \
 ${GC_ALPHA_VERSION:+alpha=}$GC_ALPHA_VERSION)
diff --git a/configure.ac b/configure.ac
index 8bb800f..9c662f2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -25,6 +25,7 @@ AC_PREREQ(2.53)
 AC_REVISION($Revision: 1.44 $)
 GC_SET_VERSION
 AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects nostdinc])
+AM_CONFIG_HEADER([include/private/config.h])
 AM_MAINTAINER_MODE
 
 AC_SUBST(PACKAGE)
@@ -68,7 +69,30 @@ AC_ARG_ENABLE(parallel-mark,
 AC_ARG_ENABLE(cplusplus,
     [AC_HELP_STRING([--enable-cplusplus], [install C++ support])])
 
-INCLUDES=-I${srcdir}/include
+dnl Features which may be selected in the folliwng thread-detection switch.
+AH_TEMPLATE([PARALLEL_MARK], [Define to enable parallel marking.])
+AH_TEMPLATE([THREAD_LOCAL_ALLOC],
+	    [Define to enable thread-local allocation optimisation.])
+AH_TEMPLATE([USE_COMPILER_TLS],
+	    [Define to use of compiler-support for thread-local variables.])
+
+dnl Thread selection macros.
+AH_TEMPLATE([GC_AIX_THREADS],       [Define to support IBM AIX threads.])
+AH_TEMPLATE([GC_DARWIN_THREADS],    [Define to support Darwin pthreads.])
+AH_TEMPLATE([GC_FREEBSD_THREADS],   [Define to support FreeBSD pthreads.])
+AH_TEMPLATE([GC_GNU_THREADS],       [Define to support GNU pthreads.])
+AH_TEMPLATE([GC_HPUX_THREADS],      [Define to support HP/UX 11 pthreads.])
+AH_TEMPLATE([GC_IRIX_THREADS],      [Define to support Irix pthreads.])
+AH_TEMPLATE([GC_LINUX_THREADS],     [Define to support pthreads on Linux.])
+AH_TEMPLATE([GC_NETBSD_THREADS],    [Define to support NetBSD pthreads.])
+AH_TEMPLATE([GC_OSF1_THREADS],      [Define to support Tru64 pthreads.])
+AH_TEMPLATE([GC_SOLARIS_THREADS],   [Define to support Solaris pthreads.])
+AH_TEMPLATE([GC_WIN32_THREADS],     [Define to support win32 threads.])
+
+dnl System header feature requests.
+AH_TEMPLATE([_POSIX_C_SOURCE], [The POSIX feature macro.])
+AH_TEMPLATE([_PTHREADS], [Indicates the use of pthreads (NetBSD).])
+
 THREADDLLIBS=
 need_atomic_ops_asm=false
 ## Libraries needed to support dynamic loading and/or threads.
@@ -189,7 +213,7 @@ case "$THREADS" in
     AC_DEFINE(GC_WIN32_THREADS)
     win32_threads=true
     dnl Wine getenv may not return NULL for missing entry
-    AC_DEFINE(NO_GETENV)
+    AC_DEFINE([NO_GETENV], 1, [Define to remove calls to getenv.])
     ;;
  dgux386)
     THREADS=dgux386
@@ -201,8 +225,10 @@ case "$THREADS" in
     fi
     AC_DEFINE(THREAD_LOCAL_ALLOC)
     AC_MSG_WARN("Explict GC_INIT() calls may be required.");
-    AC_DEFINE(GC_DGUX386_THREADS)
-    AC_DEFINE(DGUX_THREADS)
+    AC_DEFINE([GC_DGUX386_THREADS], 1,
+	      [Define to enable support for DB/UX threads on i386.])
+    AC_DEFINE([DGUX_THREADS], 1,
+	      [Define to enable support for DB/UX threads.])
     # Enable _POSIX4A_DRAFT10_SOURCE with flag -pthread
     INCLUDES="-pthread $INCLUDES"
     ;;
@@ -289,7 +315,7 @@ AC_MSG_RESULT($compiler_xlc)
 AM_CONDITIONAL(COMPILER_XLC,test $compiler_xlc = yes)
 if test $compiler_xlc = yes -a "$powerpc_darwin" = true; then
   # the darwin stack-frame-walking code is completely broken on xlc
-  AC_DEFINE(DARWIN_DONT_PARSE_STACK)
+  AC_DEFINE([DARWIN_DONT_PARSE_STACK], 1, [See Makefile.direct])
 fi
 
 # We never want libdl on darwin. It is a fake libdl that just ends up making
@@ -340,7 +366,7 @@ case "$TARGET_ECOS" in
    no)
       ;;
    *)
-      AC_DEFINE(ECOS)
+      AC_DEFINE([ECOS], 1, [Define to enable eCos target support.])
       CXXINCLUDES="-I${TARGET_ECOS}/include"
       addobjs="$addobjs ecos.lo"
       ;;
@@ -383,12 +409,10 @@ case "$host" in
     machdep="mach_dep.lo"
     ;;
  i?86-*-solaris2.[[89]] | i?86-*-solaris2.1?)
-    AC_DEFINE(SOLARIS25_PROC_VDB_BUG_FIXED)
+    AC_DEFINE([SOLARIS25_PROC_VDB_BUG_FIXED], 1, [See gcconfig.h])
     ;;
  mipstx39-*-elf*)
     machdep="mach_dep.lo"
-    AC_DEFINE(STACKBASE, __stackbase)
-    AC_DEFINE(DATASTART_IS_ETEXT)
     ;;
  mips-dec-ultrix*)
     machdep="mach-dep.lo"
@@ -414,7 +438,8 @@ case "$host" in
     ;;
  sparc-sun-solaris2.3)
     machdep="mach_dep.lo sparc_mach_dep.lo"
-    AC_DEFINE(SUNOS53_SHARED_LIB)
+    AC_DEFINE(SUNOS53_SHARED_LIB, 1,
+	      [Define to work around a Solaris 5.3 bug (see dyn_load.c).])
     ;;
  sparc*-sun-solaris2*)
     machdep="mach_dep.lo sparc_mach_dep.lo"
@@ -500,8 +525,10 @@ esac
 
 dnl Include defines that have become de facto standard.
 dnl ALL_INTERIOR_POINTERS can be overridden in startup code.
-AC_DEFINE(NO_EXECUTE_PERMISSION)
-AC_DEFINE(ALL_INTERIOR_POINTERS)
+AC_DEFINE([NO_EXECUTE_PERMISSION], [1],
+	  [Define to allow the collector to disable execute permission of heap objects.])
+AC_DEFINE([ALL_INTERIOR_POINTERS], [1],
+	  [Define to recognise all pointers to the interior of objects.])
 
 
 dnl Interface Selection
@@ -521,14 +548,22 @@ fi
 dnl Debugging
 dnl ---------
 
+AH_TEMPLATE([GC_HAVE_BUILTIN_BACKTRACE],
+	    [Define if backtrace information is supported.])
+AH_TEMPLATE([MAKE_BACK_GRAPH], [See Makefile.direct.])
+AH_TEMPLATE([SAVE_CALL_COUNT],
+	    [The number of caller frames saved when allocating with the
+	     debugging API.])
 UNWINDLIBS=
 AC_ARG_ENABLE(gc-debug,
 [AC_HELP_STRING([--enable-gc-debug],
     [include full support for pointer backtracing etc.])],
 [ if test "$enable_gc_debug" = "yes"; then
     AC_MSG_WARN("Should define GC_DEBUG and use debug alloc. in clients.")
-    AC_DEFINE(KEEP_BACK_PTRS)
-    AC_DEFINE(DBG_HDRS_ALL)
+    AC_DEFINE([KEEP_BACK_PTRS], 1,
+	      [Define to save back-pointers in debugging headers.])
+    AC_DEFINE([DBG_HDRS_ALL], 1,
+	      [Define to force debug headers on all objects.])
     case $host in
       ia64-*-linux* )
 	AC_DEFINE(MAKE_BACK_GRAPH)
@@ -554,7 +589,7 @@ AC_ARG_ENABLE(java-finalization,
     [AC_HELP_STRING([--disable-java-finalization],
 	[Disable support for java finalization.])])
 if test x"$enable_java_finalization" != xno; then
-    AC_DEFINE(JAVA_FINALIZATION)
+    AC_DEFINE([JAVA_FINALIZATION], 1, [See Makefile.direct.])
 fi
 
 AC_ARG_ENABLE(atomic-uncollectable,
@@ -571,13 +606,16 @@ AC_ARG_ENABLE(redirect-malloc,
 
 if test "${enable_redirect_malloc}" = yes; then
     if test "${enable_gc_debug}" = yes; then
-	AC_DEFINE(REDIRECT_MALLOC, GC_debug_malloc_replacement)
-	AC_DEFINE(REDIRECT_REALLOC, GC_debug_realloc_replacement)
-	AC_DEFINE(REDIRECT_FREE, GC_debug_free)
+	AC_DEFINE([REDIRECT_MALLOC], GC_debug_malloc_replacement,
+		  [If defined, redirect malloc to this function.])
+	AC_DEFINE([REDIRECT_REALLOC], GC_debug_realloc_replacement,
+		  [If defined, redirect GC_realloc to this function.])
+	AC_DEFINE([REDIRECT_FREE], GC_debug_free,
+		  [If defined, redirect free to this function.])
     else
 	AC_DEFINE(REDIRECT_MALLOC, GC_malloc)
     fi
-    AC_DEFINE(GC_USE_DLOPEN_WRAP)
+    AC_DEFINE([GC_USE_DLOPEN_WRAP], 1, [See Makefile.direct.])
 fi
 
 AC_ARG_ENABLE(large-config,
@@ -592,9 +630,11 @@ dnl This is something of a hack.  When cross-compiling we turn off
 dnl some functionality.  We also enable the "small" configuration.
 dnl These is only correct when targetting an embedded system.  FIXME.
 if test -n "${with_cross_host}"; then
-   AC_DEFINE(NO_CLOCK)
-   AC_DEFINE(SMALL_CONFIG)
-   AC_DEFINE(NO_DEBUGGING)
+   AC_DEFINE([NO_CLOCK], 1, [Define to not use system clock (cross compiling).])
+   AC_DEFINE([SMALL_CONFIG], 1,
+	     [Define to tune the collector for small heap sizes.])
+   AC_DEFINE([NO_DEBUGGING], 1,
+	     [Disable debugging, like GC_dump and its callees.])
 fi
 
 
@@ -604,7 +644,7 @@ AC_ARG_ENABLE(gc-assertions,
     [AC_HELP_STRING([--enable-gc-assertions],
 	[collector-internal assertion checking])])
 if test "${enable_gc_assertions}" = yes; then
-    AC_DEFINE(GC_ASSERTIONS)
+    AC_DEFINE([GC_ASSERTIONS], 1, [Define to enable internal debug assertions.])
 fi
 
 AC_ARG_ENABLE(munmap,
@@ -618,12 +658,16 @@ AC_ARG_ENABLE(munmap,
     esac]
    )
 if test "${enable_munmap}" != ""; then
-    AC_DEFINE(USE_MMAP)
-    AC_DEFINE(USE_MUNMAP)
+    AC_DEFINE([USE_MMAP], 1,
+	      [Define to use mmap instead of sbrk to expand the heap.])
+    AC_DEFINE([USE_MUNMAP], 1,
+	      [Define to return memory to OS with munmap calls.
+	       See Makefile.direct.])
     if test "${MUNMAP_THRESHOLD}" = "yes"; then
       MUNMAP_THRESHOLD=6
     fi
-    AC_DEFINE_UNQUOTED(MUNMAP_THRESHOLD, ${MUNMAP_THRESHOLD})
+    AC_DEFINE_UNQUOTED([MUNMAP_THRESHOLD], [${MUNMAP_THRESHOLD}],
+	[Number of GC cycles to wait before unmapping an unused block.])
 fi
 
 AM_CONDITIONAL(USE_LIBDIR, test -z "$with_cross_host")


More information about the Gc mailing list