]> granicus.if.org Git - gc/commitdiff
2008-08-26 Hans Boehm <Hans.Boehm@hp.com> (with help from Marco Maggi)
authorhboehm <hboehm>
Tue, 26 Aug 2008 23:11:47 +0000 (23:11 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 26 Jul 2011 17:06:43 +0000 (21:06 +0400)
* configure.ac: Check for gc-debug earlier; replace remaining
full-debug tests.
* configure: Regenerate.
* include/gc.h, ptr_chck.c (GC_pre_incr, GC_post_incr):
Use signed offset type.  Use ptr_t internally.
* doc/gcinterface.html: Update LOCAL_MALLOC description.
* doc/README.autoconf, doc/leak.html, doc/README.DGUX386:
Fix full-debug reference.
* include/gc.h: Rewrite GC_..._INCR and friends.
* tests/test.c: Minimally test GC_..._INCR and friends.

ChangeLog
configure
configure.ac
doc/README.DGUX386
doc/README.autoconf
doc/gcinterface.html
doc/leak.html
include/gc.h
ptr_chck.c
tests/test.c

index d8a1d7660a8c6282c91e7c42e4e941d3876044fe..f6dfcec020ea387ba6a8797046a8490dde5c311b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2008-08-26  Hans Boehm <Hans.Boehm@hp.com> (with help from Marco Maggi)
+       * configure.ac: Check for gc-debug earlier; replace remaining
+       full-debug tests.
+       * configure: Regenerate.
+       * include/gc.h, ptr_chck.c (GC_pre_incr, GC_post_incr):
+       Use signed offset type.  Use ptr_t internally.
+       * doc/gcinterface.html: Update LOCAL_MALLOC description.
+       * doc/README.autoconf, doc/leak.html, doc/README.DGUX386:
+       Fix full-debug reference.
+       * include/gc.h: Rewrite GC_..._INCR and friends.
+       * tests/test.c: Minimally test GC_..._INCR and friends.
+
 2008-08-21  Hans Boehm <Hans.Boehm@hp.com>
        * mark.c: (GC_push_next_marked, GC_push_next_marked_dirty,
        GC_push_next_marked_uncollectable): Never invoke GC_push_marked
index 823cf64acb36b5767df94db1e87cd84d1d15bf44..04426cdfdae77ccefecd38c427cb2b1f59abb6a4 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac Revision: 1.38 .
+# From configure.ac Revision: 1.39 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.61 for gc 7.2alpha1.
 #
@@ -1527,6 +1527,7 @@ Optional Features:
                           optimize for fast installation [default=yes]
   --disable-libtool-lock  avoid locking (might break parallel builds)
   --disable-gcj-support   Disable support for gcj.
+  --enable-gc-debug       include full support for pointer backtracing etc.
   --disable-java-finalization
                           Disable support for java finalization.
   --disable-atomic-uncollectible
@@ -1534,7 +1535,6 @@ Optional Features:
   --enable-redirect-malloc
                           Redirect malloc and friends to GC routines
   --enable-large-config   Optimize for large (> 100 MB) heap or root set
-  --enable-gc-debug       include full support for pointer backtracing etc.
   --enable-gc-assertions  collector-internal assertion checking
   --enable-munmap=N       return page to the os if empty for N collections
 
@@ -21276,6 +21276,7 @@ LIBTOOL='$(SHELL) $(top_builddir)/libtool'
 
 #
 # Check for AViiON Machines running DGUX
+# FIXME: Should this be moved down to below the gc-debug processing?
 #
 ac_is_dgux=no
 if test "${ac_cv_header_sys_dg_sys_info_h+set}" = set; then
@@ -21416,7 +21417,7 @@ fi
 
     ## :GOTCHA: we do not check anything but sys/dg_sys_info.h
 if test $ac_is_dgux = yes; then
-    if test "$enable_full_debug" = "yes"; then
+    if test "$enable_gc_debug" = "yes"; then
       CFLAGS="-g -mstandard -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
       CXXFLAGS="-g -mstandard -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
     else
@@ -21511,93 +21512,6 @@ _ACEOF
 
 fi
 
-# Check whether --enable-java-finalization was given.
-if test "${enable_java_finalization+set}" = set; then
-  enableval=$enable_java_finalization;
-fi
-
-if test x"$enable_java_finalization" != xno; then
-    cat >>confdefs.h <<\_ACEOF
-#define JAVA_FINALIZATION 1
-_ACEOF
-
-fi
-
-# Check whether --enable-atomic-uncollectable was given.
-if test "${enable_atomic_uncollectable+set}" = set; then
-  enableval=$enable_atomic_uncollectable;
-fi
-
-if test x"$enable_atomic_uncollectible" != x"no"; then
-
-cat >>confdefs.h <<\_ACEOF
-#define ATOMIC_UNCOLLECTABLE 1
-_ACEOF
-
-fi
-
-# Check whether --enable-redirect-malloc was given.
-if test "${enable_redirect_malloc+set}" = set; then
-  enableval=$enable_redirect_malloc;
-fi
-
-
-if test "${enable_redirect_malloc}" = yes; then
-    if test "${enable_full_debug}" = yes; then
-       cat >>confdefs.h <<\_ACEOF
-#define REDIRECT_MALLOC GC_debug_malloc_replacement
-_ACEOF
-
-       cat >>confdefs.h <<\_ACEOF
-#define REDIRECT_REALLOC GC_debug_realloc_replacement
-_ACEOF
-
-       cat >>confdefs.h <<\_ACEOF
-#define REDIRECT_FREE GC_debug_free
-_ACEOF
-
-    else
-       cat >>confdefs.h <<\_ACEOF
-#define REDIRECT_MALLOC GC_malloc
-_ACEOF
-
-    fi
-    cat >>confdefs.h <<\_ACEOF
-#define GC_USE_DLOPEN_WRAP 1
-_ACEOF
-
-fi
-
-# Check whether --enable-large-config was given.
-if test "${enable_large_config+set}" = set; then
-  enableval=$enable_large_config;
-fi
-
-
-if test "${enable_large_config}" = yes; then
-
-cat >>confdefs.h <<\_ACEOF
-#define LARGE_CONFIG 1
-_ACEOF
-
-fi
-
-if test -n "${with_cross_host}"; then
-   cat >>confdefs.h <<\_ACEOF
-#define NO_CLOCK 1
-_ACEOF
-
-   cat >>confdefs.h <<\_ACEOF
-#define SMALL_CONFIG 1
-_ACEOF
-
-   cat >>confdefs.h <<\_ACEOF
-#define NO_DEBUGGING 1
-_ACEOF
-
-fi
-
-
 
 UNWINDLIBS=
 # Check whether --enable-gc-debug was given.
@@ -21720,6 +21634,93 @@ _ACEOF
 fi
 
 
+# Check whether --enable-java-finalization was given.
+if test "${enable_java_finalization+set}" = set; then
+  enableval=$enable_java_finalization;
+fi
+
+if test x"$enable_java_finalization" != xno; then
+    cat >>confdefs.h <<\_ACEOF
+#define JAVA_FINALIZATION 1
+_ACEOF
+
+fi
+
+# Check whether --enable-atomic-uncollectable was given.
+if test "${enable_atomic_uncollectable+set}" = set; then
+  enableval=$enable_atomic_uncollectable;
+fi
+
+if test x"$enable_atomic_uncollectible" != x"no"; then
+
+cat >>confdefs.h <<\_ACEOF
+#define ATOMIC_UNCOLLECTABLE 1
+_ACEOF
+
+fi
+
+# Check whether --enable-redirect-malloc was given.
+if test "${enable_redirect_malloc+set}" = set; then
+  enableval=$enable_redirect_malloc;
+fi
+
+
+if test "${enable_redirect_malloc}" = yes; then
+    if test "${enable_gc_debug}" = yes; then
+       cat >>confdefs.h <<\_ACEOF
+#define REDIRECT_MALLOC GC_debug_malloc_replacement
+_ACEOF
+
+       cat >>confdefs.h <<\_ACEOF
+#define REDIRECT_REALLOC GC_debug_realloc_replacement
+_ACEOF
+
+       cat >>confdefs.h <<\_ACEOF
+#define REDIRECT_FREE GC_debug_free
+_ACEOF
+
+    else
+       cat >>confdefs.h <<\_ACEOF
+#define REDIRECT_MALLOC GC_malloc
+_ACEOF
+
+    fi
+    cat >>confdefs.h <<\_ACEOF
+#define GC_USE_DLOPEN_WRAP 1
+_ACEOF
+
+fi
+
+# Check whether --enable-large-config was given.
+if test "${enable_large_config+set}" = set; then
+  enableval=$enable_large_config;
+fi
+
+
+if test "${enable_large_config}" = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define LARGE_CONFIG 1
+_ACEOF
+
+fi
+
+if test -n "${with_cross_host}"; then
+   cat >>confdefs.h <<\_ACEOF
+#define NO_CLOCK 1
+_ACEOF
+
+   cat >>confdefs.h <<\_ACEOF
+#define SMALL_CONFIG 1
+_ACEOF
+
+   cat >>confdefs.h <<\_ACEOF
+#define NO_DEBUGGING 1
+_ACEOF
+
+fi
+
+
 
 
 # Check whether --enable-gc-assertions was given.
index 3b20945708fe0600bff7dfa551eab5b28385874b..8dd0ba9af2e600d925addbb2a043605a582aab32 100644 (file)
@@ -22,7 +22,7 @@ AC_INIT(gc,7.2alpha1,Hans.Boehm@hp.com)
 AC_CONFIG_SRCDIR(gcj_mlc.c)
 AC_CANONICAL_TARGET 
 AC_PREREQ(2.53)
-AC_REVISION($Revision: 1.39 $)
+AC_REVISION($Revision: 1.40 $)
 GC_SET_VERSION
 AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects nostdinc])
 AM_MAINTAINER_MODE
@@ -432,6 +432,7 @@ AC_PROG_LIBTOOL
 
 #
 # Check for AViiON Machines running DGUX
+# FIXME: Should this be moved down to below the gc-debug processing?
 #
 ac_is_dgux=no
 AC_CHECK_HEADER(sys/dg_sys_info.h,
@@ -439,7 +440,7 @@ AC_CHECK_HEADER(sys/dg_sys_info.h,
 
     ## :GOTCHA: we do not check anything but sys/dg_sys_info.h
 if test $ac_is_dgux = yes; then
-    if test "$enable_full_debug" = "yes"; then
+    if test "$enable_gc_debug" = "yes"; then
       CFLAGS="-g -mstandard -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
       CXXFLAGS="-g -mstandard -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
     else
@@ -514,6 +515,38 @@ if test x"$enable_gcj_support" != xno; then
     AC_DEFINE(GC_GCJ_SUPPORT, 1, [Define to include support for gcj])
 fi
 
+dnl Debugging
+dnl ---------
+
+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)
+    case $host in
+      ia64-*-linux* )
+       AC_DEFINE(MAKE_BACK_GRAPH)
+       AC_DEFINE(SAVE_CALL_COUNT, 8)
+        AC_CHECK_LIB(unwind, backtrace, [
+         AC_DEFINE(GC_HAVE_BUILTIN_BACKTRACE)
+         UNWINDLIBS=-lunwind
+         AC_MSG_WARN("Client code may need to link against libunwind.")
+       ])
+      ;;
+      x86-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* )
+       AC_DEFINE(MAKE_BACK_GRAPH)
+       AC_MSG_WARN("Client must not use -fomit-frame-pointer.")
+       AC_DEFINE(SAVE_CALL_COUNT, 8)
+      ;;
+      i[3456]86-*-dgux*)
+       AC_DEFINE(MAKE_BACK_GRAPH)
+      ;;
+    esac ]
+  fi)
+
 AC_ARG_ENABLE(java-finalization,
     [AC_HELP_STRING([--disable-java-finalization],
        [Disable support for java finalization.])])
@@ -534,7 +567,7 @@ AC_ARG_ENABLE(redirect-malloc,
        [Redirect malloc and friends to GC routines])])
 
 if test "${enable_redirect_malloc}" = yes; then
-    if test "${enable_full_debug}" = 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)
@@ -562,38 +595,6 @@ if test -n "${with_cross_host}"; then
 fi
 
 
-dnl Debugging
-dnl ---------
-
-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)
-    case $host in
-      ia64-*-linux* )
-       AC_DEFINE(MAKE_BACK_GRAPH)
-       AC_DEFINE(SAVE_CALL_COUNT, 8)
-        AC_CHECK_LIB(unwind, backtrace, [
-         AC_DEFINE(GC_HAVE_BUILTIN_BACKTRACE)
-         UNWINDLIBS=-lunwind
-         AC_MSG_WARN("Client code may need to link against libunwind.")
-       ])
-      ;;
-      x86-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* )
-       AC_DEFINE(MAKE_BACK_GRAPH)
-       AC_MSG_WARN("Client must not use -fomit-frame-pointer.")
-       AC_DEFINE(SAVE_CALL_COUNT, 8)
-      ;;
-      i[3456]86-*-dgux*)
-       AC_DEFINE(MAKE_BACK_GRAPH)
-      ;;
-    esac ]
-  fi)
-
 AC_SUBST(UNWINDLIBS)
 
 AC_ARG_ENABLE(gc-assertions,
index 9d6d84788ef4219e8779cc4711377914962be09b..0b8785174c62db165bb51a08cc00f96ef81d70cc 100644 (file)
@@ -23,7 +23,7 @@
      to build only the static version of libgc.
   
      To enable debugging messages please do:
-     1) Add the "--enable-full-debug" flag during configuration. 
+     1) Add the "--enable-gc-debug" flag during configuration. 
      2) Edit the file linux-threads.c and uncommnect the line:
 
      /* #define DEBUG_THREADS 1 */ to ---> 
index 53fcf5a50b3f8abb71468c521590e02036d75a59..6c8ba55aa7793dc1bf79102a07861fdb1e33bd87 100644 (file)
@@ -47,7 +47,9 @@ Important options to configure:
                           [same as prefix]
   --enable-threads=TYPE   choose threading package
   --enable-parallel-mark  parallelize marking and free list construction
-  --enable-full-debug  include full support for pointer backtracing etc.
+  --enable-gc-debug (--enable-full-debug before about 7.0)
+                         include full support for pointer backtracing etc.
+
 
 Unless --prefix is set (or --exec-prefix or one of the more obscure options),
 make install will install libgc.a and libgc.so in /usr/local/bin, which
index 312d37f417f9a8734fffe6870d18468daba50a05..bd7b4a941d330f5f137ac3c91f0cd2de6ec4fb67 100644 (file)
@@ -152,8 +152,15 @@ for details.
 </dl>
 <P>
 If you are concerned with multiprocessor performance and scalability,
-you should consider enabling and using thread local allocation (<I>e.g.</i>
-<TT>GC_LOCAL_MALLOC</tt>, see <TT>gc_local_alloc.h</tt>.  If your platform
+you should consider enabling and using thread local allocation.
+For GC versions before 7.0, use <I>e.g.</i>
+<TT>GC_LOCAL_MALLOC</tt> and see <TT>gc_local_alloc.h</tt>;
+for later versions enabling thread-local allocations when the collector
+library is built changes the
+implementation of <TT>GC_MALLOC</tt>, so the client doesn't need to
+change.
+<P>
+If your platform
 supports it, you should build the collector with parallel marking support
 (<TT>-DPARALLEL_MARK</tt>, or <TT>--enable-parallel-mark</tt>).
 <P>
index 8f460c9f68c9635165b46aafa3bff55174a937e4..fc9c3eb7f159cb062402d2e735a64f78a10aea68 100644 (file)
@@ -173,7 +173,7 @@ no longer necessary to call GC_ routines explicitly, though that can also
 improve the quality of the leak reports.
 <LI> Build the collector and install it in directory <I>foo</i> as follows:
 <UL>
-<LI> <TT>configure --prefix=<I>foo</i> --enable-full-debug --enable-redirect-malloc
+<LI> <TT>configure --prefix=<I>foo</i> --enable-gc-debug --enable-redirect-malloc
 --disable-threads</tt>
 <LI> <TT>make</tt>
 <LI> <TT>make install</tt>
index 31af791431d1eeb07db0ee1793993ea9b166aa84..fcb0f3c501b6b4f7e5735f69ee3961f3ae1a66b9 100644 (file)
@@ -927,8 +927,8 @@ GC_API void * GC_same_obj (void * p, void * q);
 /* the second argument is in units of bytes, not multiples of the      */
 /* object size.  This should either be invoked from a macro, or the    */
 /* call should be automatically generated.                             */
-GC_API void * GC_pre_incr (void * *p, size_t how_much);
-GC_API void * GC_post_incr (void * *p, size_t how_much);
+GC_API void * GC_pre_incr (void * *p, ptrdiff_t how_much);
+GC_API void * GC_post_incr (void * *p, ptrdiff_t how_much);
 
 /* Check that p is visible                                             */
 /* to the collector as a possibly pointer containing location.         */
@@ -954,34 +954,36 @@ GC_API void GC_dump(void);
 
 /* Safer, but slow, pointer addition.  Probably useful mainly with     */
 /* a preprocessor.  Useful only for heap pointers.                     */
-#ifdef GC_DEBUG
+/* Only the macros without trailing digits are meant to be used                */
+/* by clients.  These are designed to model the available C pointer    */
+/* arithmetic expressions.                                             */
+/* Even then, these are probably more useful as                        */
+/* documentation than as part of the API.                              */
+/* Note that GC_PTR_ADD evaluates the first argument more than once.   */
+#if defined(GC_DEBUG) && defined(__GNUC__)
 #   define GC_PTR_ADD3(x, n, type_of_result) \
        ((type_of_result)GC_same_obj((x)+(n), (x)))
 #   define GC_PRE_INCR3(x, n, type_of_result) \
-       ((type_of_result)GC_pre_incr(&(x), (n)*sizeof(*x))
-#   define GC_POST_INCR2(x, type_of_result) \
-       ((type_of_result)GC_post_incr(&(x), sizeof(*x))
-#   ifdef __GNUC__
-#       define GC_PTR_ADD(x, n) \
+       ((type_of_result)GC_pre_incr(&(x), (n)*sizeof(*x)))
+#   define GC_POST_INCR3(x, n, type_of_result) \
+       ((type_of_result)GC_post_incr(&(x), (n)*sizeof(*x)))
+#   define GC_PTR_ADD(x, n) \
            GC_PTR_ADD3(x, n, typeof(x))
-#       define GC_PRE_INCR(x, n) \
+#   define GC_PRE_INCR(x, n) \
            GC_PRE_INCR3(x, n, typeof(x))
-#       define GC_POST_INCR(x, n) \
-           GC_POST_INCR3(x, typeof(x))
-#   else
+#   define GC_POST_INCR(x) \
+           GC_POST_INCR3(x, 1, typeof(x))
+#   define GC_POST_DECR(x) \
+           GC_POST_INCR3(x, -1, typeof(x))
+#else  /* !GC_DEBUG || !__GNUC__ */
        /* We can't do this right without typeof, which ANSI    */
-       /* decided was not sufficiently useful.  Repeatedly     */
-       /* mentioning the arguments seems too dangerous to be   */
-       /* useful.  So does not casting the result.             */
-#      define GC_PTR_ADD(x, n) ((x)+(n))
-#   endif
-#else  /* !GC_DEBUG */
-#   define GC_PTR_ADD3(x, n, type_of_result) ((x)+(n))
+       /* decided was not sufficiently useful.  Without it     */
+       /* we resort to the non-debug version.                  */
+       /* FIXME: This should eventially support C++0x decltype */
 #   define GC_PTR_ADD(x, n) ((x)+(n))
-#   define GC_PRE_INCR3(x, n, type_of_result) ((x) += (n))
 #   define GC_PRE_INCR(x, n) ((x) += (n))
-#   define GC_POST_INCR2(x, n, type_of_result) ((x)++)
-#   define GC_POST_INCR(x, n) ((x)++)
+#   define GC_POST_INCR(x) ((x)++)
+#   define GC_POST_DECR(x) ((x)--)
 #endif
 
 /* Safer assignment of a pointer to a nonstack location.       */
index 6d5637fac142315aaf1a63d96fca8b3c776a7f61..9d8faa0010a667931e5b4aaa1891229bd34ecb68 100644 (file)
@@ -255,10 +255,10 @@ fail:
 }
 
 
-GC_API void * GC_pre_incr (void **p, size_t how_much)
+GC_API void * GC_pre_incr (void **p, ptrdiff_t how_much)
 {
     void * initial = *p;
-    void * result = GC_same_obj((void *)((word)initial + how_much), initial);
+    void * result = GC_same_obj((void *)((ptr_t)initial + how_much), initial);
     
     if (!GC_all_interior_pointers) {
        (void) GC_is_valid_displacement(result);
@@ -266,10 +266,10 @@ GC_API void * GC_pre_incr (void **p, size_t how_much)
     return (*p = result);
 }
 
-GC_API void * GC_post_incr (void **p, size_t how_much)
+GC_API void * GC_post_incr (void **p, ptrdiff_t how_much)
 {
     void * initial = *p;
-    void * result = GC_same_obj((void *)((word)initial + how_much), initial);
+    void * result = GC_same_obj((void *)((ptr_t)initial + how_much), initial);
  
     if (!GC_all_interior_pointers) {
        (void) GC_is_valid_displacement(result);
index 603354145076d3377d3df9563755954d98261896..f33c9a72eabda50c64ab18e5ed64997efc51bbba 100644 (file)
@@ -1069,10 +1069,17 @@ void run_one_test()
       GC_is_visible_print_proc = fail_proc1;
       collectable_count += 1;
       x = GC_malloc(16);
-      if (GC_base(x + 13) != x) {
+      if (GC_base(GC_PTR_ADD(x, 13)) != x) {
        GC_printf("GC_base(heap ptr) produced incorrect result\n");
        FAIL;
       }
+      GC_PRE_INCR(x, 0);
+      GC_POST_INCR(x);
+      GC_POST_DECR(x);
+      if (GC_base(x) != x) {
+       GC_printf("Bad INCR/DECR result\n");
+       FAIL;
+      }
 #     ifndef PCR
         if (GC_base(y) != 0) {
          GC_printf("GC_base(fn_ptr) produced incorrect result\n");