2009-10-21 Ivan Maidanski <ivmai@mail.ru>
authorivmai <ivmai>
Wed, 21 Oct 2009 09:33:39 +0000 (09:33 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 26 Jul 2011 17:06:51 +0000 (21:06 +0400)
* allchblk.c (DEBUG): Remove macro (since unused).
* allchblk.c: Include private/gc_priv.h before other includes and
definitions.
* alloc.c: Ditto.
* gc_dlopen.c: Ditto.
* headers.c: Ditto.
* mallocx.c: Ditto.
* mark_rts.c: Ditto.
* new_hblk.c: Ditto.
* reclaim.c: Ditto.
* mark.c: Include private/gc_pmark.h before other includes.
* misc.c: Ditto.
* dyn_load.c (_GNU_SOURCE): Move the definition to gc_priv.h.
* pthread_support.c (_USING_POSIX4A_DRAFT10): Ditto.
* pthread_support.c (_POSIX4A_DRAFT10_SOURCE): Remove (since
already defined in gc_config_macros.h).
* dyn_load.c (GC_init_dyld): Remove parameter cast for
_dyld_register_func_for_add_image() and
_dyld_register_func_for_remove_image(); add the comment about
possible warnings; add FIXME for the deprecated
_dyld_bind_fully_image_containing_address().
* include/private/gc_priv.h: Include gc.h before the standard
headers inclusion.
* tests/test.c: Ditto.
* include/private/gcconfig.h (DebugBreak): Update the comment.
* typd_mlc.c (ED_INITIAL_SIZE): Remove ';'.
* alloc.c: Reformat the code (partly adjust indentation).
* backgraph.c: Ditto.
* blacklst.c: Ditto.
* checksums.c: Ditto.
* finalize.c: Ditto.
* gcj_mlc.c: Ditto.
* mach_dep.c: Ditto.
* mark_rts.c: Ditto.
* obj_map.c: Ditto.
* os_dep.c: Ditto.
* ptr_chck.c: Ditto.
* stubborn.c: Ditto.
* thread_local_alloc.c: Ditto.
* typd_mlc.c: Ditto.

28 files changed:
ChangeLog
allchblk.c
alloc.c
backgraph.c
blacklst.c
checksums.c
dyn_load.c
finalize.c
gc_dlopen.c
gcj_mlc.c
headers.c
include/private/gc_priv.h
include/private/gcconfig.h
mach_dep.c
mallocx.c
mark.c
mark_rts.c
misc.c
new_hblk.c
obj_map.c
os_dep.c
pthread_support.c
ptr_chck.c
reclaim.c
stubborn.c
tests/test.c
thread_local_alloc.c
typd_mlc.c

index 5bcbcf3..0b1bae3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,46 @@
+2009-10-21  Ivan Maidanski <ivmai@mail.ru>
+
+       * allchblk.c (DEBUG): Remove macro (since unused).
+       * allchblk.c: Include private/gc_priv.h before other includes and
+       definitions.
+       * alloc.c: Ditto.
+       * gc_dlopen.c: Ditto.
+       * headers.c: Ditto.
+       * mallocx.c: Ditto.
+       * mark_rts.c: Ditto.
+       * new_hblk.c: Ditto.
+       * reclaim.c: Ditto.
+       * mark.c: Include private/gc_pmark.h before other includes.
+       * misc.c: Ditto.
+       * dyn_load.c (_GNU_SOURCE): Move the definition to gc_priv.h.
+       * pthread_support.c (_USING_POSIX4A_DRAFT10): Ditto.
+       * pthread_support.c (_POSIX4A_DRAFT10_SOURCE): Remove (since
+       already defined in gc_config_macros.h).
+       * dyn_load.c (GC_init_dyld): Remove parameter cast for
+       _dyld_register_func_for_add_image() and
+       _dyld_register_func_for_remove_image(); add the comment about
+       possible warnings; add FIXME for the deprecated
+       _dyld_bind_fully_image_containing_address().
+       * include/private/gc_priv.h: Include gc.h before the standard
+       headers inclusion.
+       * tests/test.c: Ditto.
+       * include/private/gcconfig.h (DebugBreak): Update the comment.
+       * typd_mlc.c (ED_INITIAL_SIZE): Remove ';'.
+       * alloc.c: Reformat the code (partly adjust indentation).
+       * backgraph.c: Ditto.
+       * blacklst.c: Ditto.
+       * checksums.c: Ditto.
+       * finalize.c: Ditto.
+       * gcj_mlc.c: Ditto.
+       * mach_dep.c: Ditto.
+       * mark_rts.c: Ditto.
+       * obj_map.c: Ditto.
+       * os_dep.c: Ditto.
+       * ptr_chck.c: Ditto.
+       * stubborn.c: Ditto.
+       * thread_local_alloc.c: Ditto.
+       * typd_mlc.c: Ditto.
+
 2009-10-20  Ivan Maidanski <ivmai@mail.ru> (really mostly OpenBSD contributors)
 
        * configure.ac (openbsd): Define GC_OPENBSD_THREADS.
index 84ed4d2..1c8c62d 100644 (file)
  * modified is included with the above copyright notice.
  */
 
-/* #define DEBUG */
-#include <stdio.h>
 #include "private/gc_priv.h"
 
+#include <stdio.h>
+
 GC_bool GC_use_entire_heap = 0;
 
 /*
diff --git a/alloc.c b/alloc.c
index da93a93..5756ce3 100644 (file)
--- a/alloc.c
+++ b/alloc.c
  *
  */
 
-# include "private/gc_priv.h"
+#include "private/gc_priv.h"
 
-# include <stdio.h>
-# if !defined(MACOS) && !defined(MSWINCE)
-#   include <signal.h>
-#   include <sys/types.h>
-# endif
+#include <stdio.h>
+#if !defined(MACOS) && !defined(MSWINCE)
+# include <signal.h>
+# include <sys/types.h>
+#endif
 
 /*
  * Separate free lists are maintained for different sized objects
@@ -134,7 +134,7 @@ int GC_CALLBACK GC_never_stop_func(void)
 unsigned long GC_time_limit = GC_TIME_LIMIT;
 
 #ifndef NO_CLOCK
-STATIC CLOCK_TYPE GC_start_time = 0;
+  STATIC CLOCK_TYPE GC_start_time = 0;
                                 /* Time at which we stopped world.      */
                                 /* used only in GC_timeout_stop_func.   */
 #endif
@@ -163,7 +163,7 @@ GC_API GC_stop_func GC_CALL GC_get_stop_func(void)
 }
 
 #if defined(SMALL_CONFIG) || defined(NO_CLOCK)
-#   define GC_timeout_stop_func GC_default_stop_func
+# define GC_timeout_stop_func GC_default_stop_func
 #else
   STATIC int GC_CALLBACK GC_timeout_stop_func (void)
   {
@@ -522,9 +522,10 @@ GC_API int GC_CALL GC_collect_a_little(void)
     return(result);
 }
 
-# if !defined(REDIRECT_MALLOC) && (defined(MSWIN32) || defined(MSWINCE))
+#if !defined(REDIRECT_MALLOC) && (defined(MSWIN32) || defined(MSWINCE))
   void GC_add_current_malloc_heap(void);
-# endif
+#endif
+
 #ifdef MAKE_BACK_GRAPH
   void GC_build_back_graph(void);
 #endif
@@ -689,10 +690,10 @@ void GC_set_fl_marks(ptr_t q)
 }
 
 #ifdef GC_ASSERTIONS
-/* Check that all mark bits for the free list whose first entry is q    */
-/* are set.                                                             */
-void GC_check_fl_marks(ptr_t q)
-{
+  /* Check that all mark bits for the free list whose first entry is q  */
+  /* are set.                                                           */
+  void GC_check_fl_marks(ptr_t q)
+  {
    ptr_t p;
    for (p = q; p != 0; p = obj_link(p)) {
        if (!GC_is_marked(p)) {
@@ -700,7 +701,7 @@ void GC_check_fl_marks(ptr_t q)
            ABORT("Unmarked local free list entry.");
        }
    }
-}
+  }
 #endif
 
 /* Clear all mark bits for the free list whose first entry is q */
@@ -749,11 +750,11 @@ STATIC void GC_clear_fl_marks(ptr_t q)
 }
 
 #if defined(GC_ASSERTIONS) && defined(THREADS) && defined(THREAD_LOCAL_ALLOC)
-void GC_check_tls(void);
+  void GC_check_tls(void);
 #endif
 
 #ifdef MAKE_BACK_GRAPH
-void GC_traverse_back_graph(void);
+  void GC_traverse_back_graph(void);
 #endif
 
 /* Finish up a collection.  Assumes mark bits are consistent, lock is   */
@@ -988,6 +989,7 @@ GC_INNER word GC_n_heap_sects = 0;
     GC_n_memory++;
   }
 #endif
+
 /*
  * Use the chunk of memory starting at p of size bytes as part of the heap.
  * Assumes p is HBLKSIZE aligned, and bytes is a multiple of HBLKSIZE.
@@ -1041,9 +1043,9 @@ void GC_add_to_heap(struct hblk *p, size_t bytes)
     }
 }
 
-# if !defined(NO_DEBUGGING)
-void GC_print_heap_sects(void)
-{
+#if !defined(NO_DEBUGGING)
+  void GC_print_heap_sects(void)
+  {
     unsigned i;
 
     GC_printf("Total heap size: %lu\n", (unsigned long) GC_heapsize);
@@ -1060,8 +1062,8 @@ void GC_print_heap_sects(void)
                   i, start, start + len,
                   (unsigned long)nbl, (unsigned long)(len/HBLKSIZE));
     }
-}
-# endif
+  }
+#endif
 
 void * GC_least_plausible_heap_addr = (void *)ONES;
 void * GC_greatest_plausible_heap_addr = 0;
index 97d362e..36e19dc 100644 (file)
@@ -12,6 +12,8 @@
  *
  */
 
+#include "private/dbg_mlc.h"
+
 /*
  * This implements a full, though not well-tuned, representation of the
  * backwards points-to graph.  This is used to test for non-GC-robust
@@ -24,8 +26,6 @@
  * a growing space leak.
  */
 
-#include "private/dbg_mlc.h"
-
 #ifdef MAKE_BACK_GRAPH
 
 #define MAX_IN  10      /* Maximum in-degree we handle directly */
index 3e7316d..d0dcf45 100644 (file)
@@ -11,8 +11,8 @@
  * provided the above notices are retained, and a notice that the code was
  * modified is included with the above copyright notice.
  */
-/* Boehm, August 9, 1995 6:09 pm PDT */
-# include "private/gc_priv.h"
+
+#include "private/gc_priv.h"
 
 /*
  * We maintain several hash tables of hblks that have had false hits.
index 44f7c7e..b8135af 100644 (file)
@@ -10,7 +10,6 @@
  * provided the above notices are retained, and a notice that the code was
  * modified is included with the above copyright notice.
  */
-/* Boehm, March 29, 1995 12:51 pm PST */
 
 #include "private/gc_priv.h"
 
@@ -21,9 +20,9 @@
 /* We assume that stubborn objects are changed only when they are       */
 /* enabled for writing.  (Certain kinds of writing are actually         */
 /* safe under other conditions.)                                        */
-# define NSUMS 10000
+#define NSUMS 10000
 
-# define OFFSET 0x10000
+#define OFFSET 0x10000
 
 typedef struct {
         GC_bool new_valid;
@@ -75,11 +74,11 @@ STATIC word GC_checksum(struct hblk *h)
     return(result | 0x80000000 /* doesn't look like pointer */);
 }
 
-# ifdef STUBBORN_ALLOC
-/* Check whether a stubborn object from the given block appears on      */
-/* the appropriate free list.                                           */
-STATIC GC_bool GC_on_free_list(struct hblk *h)
-{
+#ifdef STUBBORN_ALLOC
+  /* Check whether a stubborn object from the given block appears on    */
+  /* the appropriate free list.                                         */
+  STATIC GC_bool GC_on_free_list(struct hblk *h)
+  {
     hdr * hhdr = HDR(h);
     size_t sz = BYTES_TO_WORDS(hhdr -> hb_sz);
     ptr_t p;
@@ -89,8 +88,8 @@ STATIC GC_bool GC_on_free_list(struct hblk *h)
         if (HBLKPTR(p) == h) return(TRUE);
     }
     return(FALSE);
-}
-# endif
+  }
+#endif
 
 int GC_n_dirty_errors = 0;
 int GC_n_faulted_dirty_errors = 0;
@@ -212,7 +211,7 @@ out:
                   (unsigned long)GC_n_changed_errors);
         GC_printf("These may be benign (provoked by nonpointer changes)\n");
 #       ifdef THREADS
-            GC_printf(
+          GC_printf(
             "Also expect 1 per thread currently allocating a stubborn obj.\n");
 #       endif
     }
index 49e8a35..73f9ac6 100644 (file)
@@ -15,6 +15,8 @@
  * Heavily modified by Hans Boehm and others
  */
 
+#include "private/gc_priv.h"
+
 /*
  * This is incredibly OS specific code for tracking down data sections in
  * dynamic libraries.  There appears to be no way of doing this quickly
  * But then not much of anything is safe in the presence of dlclose.
  */
 
-#if (defined(__linux__) || defined(__GLIBC__) || defined(__GNU__)) \
-     && !defined(_GNU_SOURCE)
-    /* Can't test LINUX, since this must be defined before other includes */
-# define _GNU_SOURCE
-#endif
-
-#include "private/gc_priv.h"
-
 #if !defined(MACOS) && !defined(_WIN32_WCE)
 # include <sys/types.h>
 #endif
@@ -1253,10 +1247,12 @@ void GC_init_dyld(void)
      linked in the future.
   */
 
-    _dyld_register_func_for_add_image(
-              (void (*)(struct mach_header *, intptr_t))GC_dyld_image_add);
-    _dyld_register_func_for_remove_image(
-              (void (*)(struct mach_header *, intptr_t))GC_dyld_image_remove);
+    _dyld_register_func_for_add_image(GC_dyld_image_add);
+    _dyld_register_func_for_remove_image(GC_dyld_image_remove);
+        /* Ignore 2 compiler warnings here: passing argument 1 of       */
+        /* '_dyld_register_func_for_add/remove_image' from incompatible */
+        /* pointer type.                                                */
+
 
     /* Set this early to avoid reentrancy issues. */
     initialized = TRUE;
@@ -1265,6 +1261,7 @@ void GC_init_dyld(void)
 #     ifdef DARWIN_DEBUG
         GC_printf("Forcing full bind of GC code...\n");
 #     endif
+      /* FIXME: '_dyld_bind_fully_image_containing_address' is deprecated. */
       if(!_dyld_bind_fully_image_containing_address((unsigned long*)GC_malloc))
         ABORT("_dyld_bind_fully_image_containing_address failed");
     }
index 7dae99c..0647590 100644 (file)
  * provided the above notices are retained, and a notice that the code was
  * modified is included with the above copyright notice.
  */
-/* Boehm, February 1, 1996 1:19 pm PST */
 
 #include "private/gc_pmark.h"
 
-# ifdef FINALIZE_ON_DEMAND
-    int GC_finalize_on_demand = 1;
-# else
-    int GC_finalize_on_demand = 0;
-# endif
+#ifdef FINALIZE_ON_DEMAND
+  int GC_finalize_on_demand = 1;
+#else
+  int GC_finalize_on_demand = 0;
+#endif
 
-# ifdef JAVA_FINALIZATION
-    int GC_java_finalization = 1;
-# else
-    int GC_java_finalization = 0;
-# endif
+#ifdef JAVA_FINALIZATION
+  int GC_java_finalization = 1;
+#else
+  int GC_java_finalization = 0;
+#endif
 
 /* Type of mark procedure used for marking from finalizable object.     */
 /* This procedure normally does not mark the object, only its           */
 /* descendents.                                                         */
 typedef void (* finalization_mark_proc)(ptr_t /* finalizable_obj_ptr */);
 
-# define HASH3(addr,size,log_size) \
-    ((((word)(addr) >> 3) ^ ((word)(addr) >> (3+(log_size)))) \
-    & ((size) - 1))
+#define HASH3(addr,size,log_size) \
+        ((((word)(addr) >> 3) ^ ((word)(addr) >> (3 + (log_size)))) \
+         & ((size) - 1))
 #define HASH2(addr,log_size) HASH3(addr, 1 << log_size, log_size)
 
 struct hash_chain_entry {
@@ -49,7 +48,7 @@ static struct disappearing_link {
 #   define dl_hidden_link prolog.hidden_key
                                 /* Field to be cleared.         */
 #   define dl_next(x) (struct disappearing_link *)((x) -> prolog.next)
-#   define dl_set_next(x,y) (x) -> prolog.next = (struct hash_chain_entry *)(y)
+#   define dl_set_next(x,y) (x)->prolog.next = (struct hash_chain_entry *)(y)
 
     word dl_hidden_obj;         /* Pointer to object base       */
 } **dl_head = 0;
@@ -70,7 +69,7 @@ static struct finalizable_object {
                                 /* No longer hidden once object */
                                 /* is on finalize_now queue.    */
 #   define fo_next(x) (struct finalizable_object *)((x) -> prolog.next)
-#   define fo_set_next(x,y) (x) -> prolog.next = (struct hash_chain_entry *)(y)
+#   define fo_set_next(x,y) (x)->prolog.next = (struct hash_chain_entry *)(y)
     GC_finalization_proc fo_fn; /* Finalizer.                   */
     ptr_t fo_client_data;
     word fo_object_size;        /* In bytes.                    */
@@ -461,8 +460,8 @@ GC_API void GC_CALL GC_register_finalizer_unreachable(void * obj,
 }
 
 #ifndef NO_DEBUGGING
-void GC_dump_finalization(void)
-{
+  void GC_dump_finalization(void)
+  {
     struct disappearing_link * curr_dl;
     struct finalizable_object * curr_fo;
     ptr_t real_ptr, real_link;
@@ -485,7 +484,7 @@ void GC_dump_finalization(void)
         GC_printf("Finalizable object: %p\n", real_ptr);
       }
     }
-}
+  }
 #endif
 
 #ifndef SMALL_CONFIG
@@ -704,9 +703,9 @@ void GC_finalize(void)
 
 #ifndef JAVA_FINALIZATION_NOT_NEEDED
 
-/* Enqueue all remaining finalizers to be run - Assumes lock is held.   */
-STATIC void GC_enqueue_all_finalizers(void)
-{
+  /* Enqueue all remaining finalizers to be run - Assumes lock is held. */
+  STATIC void GC_enqueue_all_finalizers(void)
+  {
     struct finalizable_object * curr_fo, * prev_fo, * next_fo;
     ptr_t real_ptr;
     register int i;
@@ -746,24 +745,24 @@ STATIC void GC_enqueue_all_finalizers(void)
     }
 
     return;
-}
+  }
 
-/* Invoke all remaining finalizers that haven't yet been run.
- * This is needed for strict compliance with the Java standard,
- * which can make the runtime guarantee that all finalizers are run.
- * Unfortunately, the Java standard implies we have to keep running
- * finalizers until there are no more left, a potential infinite loop.
- * YUCK.
- * Note that this is even more dangerous than the usual Java
- * finalizers, in that objects reachable from static variables
- * may have been finalized when these finalizers are run.
- * Finalizers run at this point must be prepared to deal with a
- * mostly broken world.
- * This routine is externally callable, so is called without
- * the allocation lock.
- */
-GC_API void GC_CALL GC_finalize_all(void)
-{
+  /* Invoke all remaining finalizers that haven't yet been run.
  * This is needed for strict compliance with the Java standard,
  * which can make the runtime guarantee that all finalizers are run.
  * Unfortunately, the Java standard implies we have to keep running
  * finalizers until there are no more left, a potential infinite loop.
  * YUCK.
  * Note that this is even more dangerous than the usual Java
  * finalizers, in that objects reachable from static variables
  * may have been finalized when these finalizers are run.
  * Finalizers run at this point must be prepared to deal with a
  * mostly broken world.
  * This routine is externally callable, so is called without
  * the allocation lock.
  */
+  GC_API void GC_CALL GC_finalize_all(void)
+  {
     DCL_LOCK_STATE;
 
     LOCK();
@@ -778,8 +777,9 @@ GC_API void GC_CALL GC_finalize_all(void)
       LOCK();
     }
     UNLOCK();
-}
-#endif
+  }
+
+#endif /* !JAVA_FINALIZATION_NOT_NEEDED */
 
 /* Returns true if it is worth calling GC_invoke_finalizers. (Useful if */
 /* finalizers can only be called from some kind of `safe state' and     */
@@ -931,9 +931,8 @@ GC_API void * GC_CALL GC_call_with_alloc_lock(GC_fn_type fn,
 }
 
 #ifndef SMALL_CONFIG
-
-void GC_print_finalization_stats(void)
-{
+  void GC_print_finalization_stats(void)
+  {
     struct finalizable_object *fo = GC_finalize_now;
     unsigned long ready = 0;
 
@@ -944,6 +943,5 @@ void GC_print_finalization_stats(void)
     GC_log_printf("%lu objects are eligible for immediate finalization; "
                   "%ld links cleared\n",
                   ready, (long)GC_old_dl_entries - (long)GC_dl_entries);
-}
-
+  }
 #endif /* SMALL_CONFIG */
index d8d6e1d..216838b 100644 (file)
@@ -16,6 +16,8 @@
  * Heavily modified by Hans Boehm and others
  */
 
+#include "private/gc_priv.h"
+
 /*
  * This used to be in dyn_load.c.  It was extracted into a separate file
  * to avoid having to link against libdl.{a,so} if the client doesn't call
@@ -23,8 +25,6 @@
  * library. -HB
  */
 
-#include "private/gc_priv.h"
-
 # if (defined(GC_PTHREADS) && !defined(GC_DARWIN_THREADS)) && !defined(GC_WIN32_PTHREADS)\
       || defined(GC_SOLARIS_THREADS)
 
index ea761cf..b9b1aa4 100644 (file)
--- a/gcj_mlc.c
+++ b/gcj_mlc.c
@@ -12,7 +12,6 @@
  * modified is included with the above copyright notice.
  *
  */
-/* Boehm, July 31, 1995 5:02 pm PDT */
 
 #include "private/gc_pmark.h"  /* includes gc_priv.h */
 
index 3f0273a..8a70852 100644 (file)
--- a/headers.c
+++ b/headers.c
@@ -13,6 +13,8 @@
  * modified is included with the above copyright notice.
  */
 
+#include "private/gc_priv.h"
+
 /*
  * This implements:
  * 1. allocation of heap block headers
@@ -22,8 +24,6 @@
  * level tree.
  */
 
-# include "private/gc_priv.h"
-
 STATIC bottom_index * GC_all_bottom_indices = 0;
                                 /* Pointer to first (lowest addr) */
                                 /* bottom_index.                  */
index 0cb6fc2..a573d5a 100644 (file)
 # define GC_BUILD
 #endif
 
+#if (defined(__linux__) || defined(__GLIBC__) || defined(__GNU__)) \
+    && !defined(_GNU_SOURCE)
+  /* Can't test LINUX, since this must be defined before other includes. */
+# define _GNU_SOURCE
+#endif
+
+#if (defined(DGUX) && defined(GC_THREADS) || defined(DGUX386_THREADS) \
+     || defined(GC_DGUX386_THREADS)) && !defined(_USING_POSIX4A_DRAFT10)
+# define _USING_POSIX4A_DRAFT10 1
+#endif
+
+#ifndef GC_H
+# define GC_I_HIDE_POINTERS /* to get GC_HIDE_POINTER() and friends */
+# include "../gc.h"
+#endif
+
 #include <stdlib.h>
 #if !defined(sony_news)
 # include <stddef.h>
 # endif
 #endif
 
-#ifndef GC_H
-# define GC_I_HIDE_POINTERS /* to get GC_HIDE_POINTER() and friends */
-# include "../gc.h"
-#endif
-
 #ifndef GC_TINY_FL_H
 # include "../gc_tiny_fl.h"
 #endif
index 484eee5..ab2243b 100644 (file)
 #   if defined(x86) || defined(__i386__)
 #     define I386
 #     if defined(__MINGW32CE__) && !defined(DebugBreak)
-        /* x86mingw32ce toolchain doesn't have proper DebugBreak() now. */
+        /* A workaround for x86mingw32ce toolchain (if it is still      */
+        /* declaring DebugBreak() instead of defining it as a macro).   */
 #       define DebugBreak() _exit(-1)
 #     endif
 #   endif
index 180ad6d..0d12d7c 100644 (file)
  * provided the above notices are retained, and a notice that the code was
  * modified is included with the above copyright notice.
  */
-/* Boehm, November 17, 1995 12:13 pm PST */
-# include "private/gc_priv.h"
-# include <stdio.h>
-# include <setjmp.h>
-# if defined(OS2) || defined(CX_UX)
-#   define _setjmp(b) setjmp(b)
-#   define _longjmp(b,v) longjmp(b,v)
-# endif
-# ifdef AMIGA
-#   ifndef __GNUC__
-#     include <dos.h>
-#   else
-#     include <machine/reg.h>
-#   endif
+
+#include "private/gc_priv.h"
+
+#include <stdio.h>
+#include <setjmp.h>
+
+#if defined(OS2) || defined(CX_UX)
+# define _setjmp(b) setjmp(b)
+# define _longjmp(b,v) longjmp(b,v)
+#endif
+
+#ifdef AMIGA
+# ifndef __GNUC__
+#   include <dos.h>
+# else
+#   include <machine/reg.h>
 # endif
+#endif
 
 #if defined(__MWERKS__) && !defined(POWERPC)
 
index 3a9e49f..f73735b 100644 (file)
--- a/mallocx.c
+++ b/mallocx.c
@@ -14,6 +14,8 @@
  * modified is included with the above copyright notice.
  */
 
+#include "private/gc_priv.h"
+
 /*
  * These are extra allocation routines which are likely to be less
  * frequently used than those in malloc.c.  They are separate in the
@@ -22,7 +24,6 @@
  */
 
 #include <stdio.h>
-#include "private/gc_priv.h"
 
 /* Some externally visible but unadvertised variables to allow access to */
 /* free lists from inlined allocators without including gc_priv.h        */
diff --git a/mark.c b/mark.c
index 0b4bb60..bf19a78 100644 (file)
--- a/mark.c
+++ b/mark.c
@@ -14,8 +14,9 @@
  *
  */
 
-# include <stdio.h>
-# include "private/gc_pmark.h"
+#include "private/gc_pmark.h"
+
+#include <stdio.h>
 
 #if defined(MSWIN32) && defined(__GNUC__)
 # include <excpt.h>
index 62bc041..b872319 100644 (file)
  * provided the above notices are retained, and a notice that the code was
  * modified is included with the above copyright notice.
  */
-# include <stdio.h>
-# include "private/gc_priv.h"
+
+#include "private/gc_priv.h"
+
+#include <stdio.h>
 
 /* Data structure for list of root sets.                                */
 /* We keep a hash table, so that we can filter out duplicate additions. */
@@ -35,13 +37,12 @@ struct roots GC_static_roots[MAX_ROOT_SETS];
 int GC_no_dls = 0;      /* Register dynamic library data segments.      */
 
 static int n_root_sets = 0;
-
         /* GC_static_roots[0..n_root_sets) contains the valid root sets. */
 
-# if !defined(NO_DEBUGGING)
-/* For debugging:       */
-void GC_print_static_roots(void)
-{
+#if !defined(NO_DEBUGGING)
+  /* For debugging:     */
+  void GC_print_static_roots(void)
+  {
     int i;
     size_t total = 0;
 
@@ -57,12 +58,11 @@ void GC_print_static_roots(void)
         GC_err_printf("GC_root_size incorrect: %ld!!\n",
                       (long) GC_root_size);
     }
-}
-# endif /* NO_DEBUGGING */
+  }
+#endif /* !NO_DEBUGGING */
 
 /* Primarily for debugging support:     */
-/* Is the address p in one of the registered static                     */
-/* root sections?                                                       */
+/* Is the address p in one of the registered static root sections?      */
 GC_bool GC_is_static_root(ptr_t p)
 {
     static int last_root_set = MAX_ROOT_SETS;
@@ -654,7 +654,8 @@ STATIC void GC_push_current_stack(ptr_t cold_gc_frame, void * context)
                   /* "activation frame" in backing store.               */
                   if (GC_activation_frame != NULL && cold_gc_bs_pointer <
                                 GC_activation_frame->backing_store_end)
-                    cold_gc_bs_pointer = GC_activation_frame->backing_store_end;
+                    cold_gc_bs_pointer =
+                                GC_activation_frame->backing_store_end;
                   GC_push_all_register_frames(BACKING_STORE_BASE,
                         cold_gc_bs_pointer, FALSE, GC_activation_frame);
                   GC_push_all_eager(cold_gc_bs_pointer, bsp);
diff --git a/misc.c b/misc.c
index 4d58e0f..0454ed8 100644 (file)
--- a/misc.c
+++ b/misc.c
  * provided the above notices are retained, and a notice that the code was
  * modified is included with the above copyright notice.
  */
-/* Boehm, July 31, 1995 5:02 pm PDT */
+
+#include "private/gc_pmark.h"
 
 #include <stdio.h>
 #include <limits.h>
 #include <stdarg.h>
 
-#include "private/gc_pmark.h"
-
 #ifndef MSWINCE
 # include <signal.h>
 #endif
index 33de645..3ff8f59 100644 (file)
  * Permission to modify the code and to distribute modified code is granted,
  * provided the above notices are retained, and a notice that the code was
  * modified is included with the above copyright notice.
- *
+ */
+
+#include "private/gc_priv.h"
+
+/*
  * This file contains the functions:
  *      ptr_t GC_build_flXXX(h, old_fl)
  *      void GC_new_hblk(size)
  */
-/* Boehm, May 19, 1994 2:09 pm PDT */
-
 
-# include <stdio.h>
-# include "private/gc_priv.h"
+#include <stdio.h>
 
 #ifndef SMALL_CONFIG
 /*
index 96a2174..542cc71 100644 (file)
--- a/obj_map.c
+++ b/obj_map.c
  * modified is included with the above copyright notice.
  */
 
+#include "private/gc_priv.h"
+
 /* Routines for maintaining maps describing heap block
  * layouts for various object sizes.  Allows fast pointer validity checks
  * and fast location of object start locations on machines (such as SPARC)
  * with slow division.
  */
 
-# include "private/gc_priv.h"
-
 /* Consider pointers that are offset bytes displaced from the beginning */
 /* of an object to be valid.                                            */
 
@@ -45,11 +45,11 @@ void GC_register_displacement_inner(size_t offset)
 }
 
 #ifdef MARK_BIT_PER_GRANULE
-/* Add a heap block map for objects of size granules to obj_map.        */
-/* Return FALSE on failure.                                             */
-/* A size of 0 granules is used for large objects.                      */
-GC_bool GC_add_map_entry(size_t granules)
-{
+  /* Add a heap block map for objects of size granules to obj_map.      */
+  /* Return FALSE on failure.                                           */
+  /* A size of 0 granules is used for large objects.                    */
+  GC_bool GC_add_map_entry(size_t granules)
+  {
     unsigned displ;
     short * new_map;
 
@@ -73,17 +73,18 @@ GC_bool GC_add_map_entry(size_t granules)
     }
     GC_obj_map[granules] = new_map;
     return(TRUE);
-}
+  }
 #endif
 
-static GC_bool offsets_initialized = FALSE;
-
 void GC_initialize_offsets(void)
 {
+    static GC_bool offsets_initialized = FALSE;
+
     if (!offsets_initialized) {
       int i;
       if (GC_all_interior_pointers) {
-        for (i = 0; i < VALID_OFFSET_SZ; ++i) GC_valid_offsets[i] = TRUE;
+        for (i = 0; i < VALID_OFFSET_SZ; ++i)
+          GC_valid_offsets[i] = TRUE;
       }
       offsets_initialized = TRUE;
     }
index 41cecf9..5b1ab04 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
  * modified is included with the above copyright notice.
  */
 
-# include "private/gc_priv.h"
+#include "private/gc_priv.h"
 
-# if defined(THREADS) && defined(MPROTECT_VDB)
-#   include "atomic_ops.h"
-# endif
+#if defined(THREADS) && defined(MPROTECT_VDB)
+# include "atomic_ops.h"
+#endif
 
-# if defined(LINUX) && !defined(POWERPC)
-#   include <linux/version.h>
-#   if (LINUX_VERSION_CODE <= 0x10400)
-      /* Ugly hack to get struct sigcontext_struct definition.  Required      */
-      /* for some early 1.3.X releases.  Will hopefully go away soon. */
-      /* in some later Linux releases, asm/sigcontext.h may have to   */
-      /* be included instead.                                         */
-#     define __KERNEL__
-#     include <asm/signal.h>
-#     undef __KERNEL__
-#   else
-      /* Kernels prior to 2.1.1 defined struct sigcontext_struct instead of */
-      /* struct sigcontext.  libc6 (glibc2) uses "struct sigcontext" in     */
-      /* prototypes, so we have to include the top-level sigcontext.h to    */
-      /* make sure the former gets defined to be the latter if appropriate. */
-#     include <features.h>
-#     if 2 <= __GLIBC__
-#       if 2 == __GLIBC__ && 0 == __GLIBC_MINOR__
-          /* glibc 2.1 no longer has sigcontext.h.  But signal.h        */
-          /* has the right declaration for glibc 2.1.                   */
-#         include <sigcontext.h>
-#       endif /* 0 == __GLIBC_MINOR__ */
-#     else /* not 2 <= __GLIBC__ */
-        /* libc5 doesn't have <sigcontext.h>: go directly with the kernel   */
-        /* one.  Check LINUX_VERSION_CODE to see which we should reference. */
-#       include <asm/sigcontext.h>
-#     endif /* 2 <= __GLIBC__ */
-#   endif
+#if defined(LINUX) && !defined(POWERPC)
+# include <linux/version.h>
+# if (LINUX_VERSION_CODE <= 0x10400)
+    /* Ugly hack to get struct sigcontext_struct definition.  Required      */
+    /* for some early 1.3.X releases.  Will hopefully go away soon. */
+    /* in some later Linux releases, asm/sigcontext.h may have to   */
+    /* be included instead.                                         */
+#   define __KERNEL__
+#   include <asm/signal.h>
+#   undef __KERNEL__
+# else
+    /* Kernels prior to 2.1.1 defined struct sigcontext_struct instead of */
+    /* struct sigcontext.  libc6 (glibc2) uses "struct sigcontext" in     */
+    /* prototypes, so we have to include the top-level sigcontext.h to    */
+    /* make sure the former gets defined to be the latter if appropriate. */
+#   include <features.h>
+#   if 2 <= __GLIBC__
+#     if 2 == __GLIBC__ && 0 == __GLIBC_MINOR__
+        /* glibc 2.1 no longer has sigcontext.h.  But signal.h        */
+        /* has the right declaration for glibc 2.1.                   */
+#       include <sigcontext.h>
+#     endif /* 0 == __GLIBC_MINOR__ */
+#   else /* not 2 <= __GLIBC__ */
+      /* libc5 doesn't have <sigcontext.h>: go directly with the kernel   */
+      /* one.  Check LINUX_VERSION_CODE to see which we should reference. */
+#     include <asm/sigcontext.h>
+#   endif /* 2 <= __GLIBC__ */
 # endif
-# if !defined(OS2) && !defined(PCR) && !defined(AMIGA) && !defined(MACOS) \
+#endif
+
+#if !defined(OS2) && !defined(PCR) && !defined(AMIGA) && !defined(MACOS) \
     && !defined(MSWINCE)
-#   include <sys/types.h>
-#   if !defined(MSWIN32)
-#       include <unistd.h>
-#   endif
+# include <sys/types.h>
+# if !defined(MSWIN32)
+#   include <unistd.h>
 # endif
+#endif
 
-# include <stdio.h>
-# if defined(MSWINCE)
-#   define SIGSEGV 0 /* value is irrelevant */
-# else
-#   include <signal.h>
-# endif
+#include <stdio.h>
+#if defined(MSWINCE)
+# define SIGSEGV 0 /* value is irrelevant */
+#else
+# include <signal.h>
+#endif
 
 #if defined(UNIX_LIKE) || defined(CYGWIN32)
 # include <fcntl.h>
 #endif
 
 #ifdef DARWIN
-/* for get_etext and friends */
-#include <mach-o/getsect.h>
+  /* for get_etext and friends */
+# include <mach-o/getsect.h>
 #endif
 
 #ifdef DJGPP
 # define OPT_PROT_EXEC 0
 #endif
 
-#if defined(LINUX) && \
-    (defined(USE_PROC_FOR_LIBRARIES) || defined(IA64) || !defined(SMALL_CONFIG))
+#if defined(LINUX) && (defined(USE_PROC_FOR_LIBRARIES) || defined(IA64) \
+                       || !defined(SMALL_CONFIG))
 # define NEED_PROC_MAPS
 #endif
 
 #ifdef NEED_PROC_MAPS
-/* We need to parse /proc/self/maps, either to find dynamic libraries,  */
-/* and/or to find the register backing store base (IA64).  Do it once   */
-/* here.                                                                */
+/* We need to parse /proc/self/maps, either to find dynamic libraries, */
+/* and/or to find the register backing store base (IA64).  Do it once  */
+/* here.                                                               */
 
 #define READ read
 
@@ -167,11 +168,11 @@ ssize_t GC_repeat_read(int fd, char *buf, size_t count)
 }
 
 #ifdef THREADS
-/* Determine the length of a file by incrementally reading it into a    */
-/* This would be silly to use on a file supporting lseek, but Linux     */
-/* /proc files usually do not.                                          */
-STATIC size_t GC_get_file_len(int f)
-{
+  /* Determine the length of a file by incrementally reading it into a  */
+  /* This would be silly to use on a file supporting lseek, but Linux   */
+  /* /proc files usually do not.                                        */
+  STATIC size_t GC_get_file_len(int f)
+  {
     size_t total = 0;
     ssize_t result;
 #   define GET_FILE_LEN_BUF_SZ 500
@@ -183,16 +184,16 @@ STATIC size_t GC_get_file_len(int f)
         total += result;
     } while (result > 0);
     return total;
-}
+  }
 
-STATIC size_t GC_get_maps_len(void)
-{
+  STATIC size_t GC_get_maps_len(void)
+  {
     int f = open("/proc/self/maps", O_RDONLY);
     size_t result = GC_get_file_len(f);
     close(f);
     return result;
-}
-#endif
+  }
+#endif /* THREADS */
 
 /*
  * Copy the contents of /proc/self/maps to a buffer in our address space.
index 904bab6..a601ab9 100644 (file)
@@ -13,6 +13,9 @@
  * provided the above notices are retained, and a notice that the code was
  * modified is included with the above copyright notice.
  */
+
+#include "private/pthread_support.h"
+
 /*
  * Support code originally for LinuxThreads, the clone()-based kernel
  * thread package for Linux which is included in libc6.
  * + #  define GC_LOCK_TAKEN GC_allocate_lock
  */
 
-/*#define DEBUG_THREADS 1*/
-
-#include "private/pthread_support.h"
+#if defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS)
 
-# if defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS)
-
-# if defined(GC_DGUX386_THREADS) && !defined(_POSIX4A_DRAFT10_SOURCE)
-#   define _POSIX4A_DRAFT10_SOURCE 1
-# endif
-
-# if defined(GC_DGUX386_THREADS) && !defined(_USING_POSIX4A_DRAFT10)
-#   define _USING_POSIX4A_DRAFT10 1
-# endif
+/*#define DEBUG_THREADS 1*/
 
 # include <stdlib.h>
 # include <pthread.h>
@@ -1652,4 +1645,4 @@ void GC_notify_all_marker(void)
 
 #endif /* PARALLEL_MARK */
 
-# endif /* GC_LINUX_THREADS and friends */
+#endif /* GC_LINUX_THREADS and friends */
index c168ff9..6195ac8 100644 (file)
  * modified is included with the above copyright notice.
  */
 
+#include "private/gc_pmark.h"
+
 /*
  * These are checking routines calls to which could be inserted by a
  * preprocessor to validate C pointer arithmetic.
  */
 
-#include "private/gc_pmark.h"
-
 STATIC void GC_CALLBACK GC_default_same_obj_print_proc(void * p, void * q)
 {
     GC_err_printf("%p and %p are not in the same object\n", p, q);
@@ -255,7 +255,6 @@ fail:
     return(p);
 }
 
-
 GC_API void * GC_CALL GC_pre_incr (void **p, ptrdiff_t how_much)
 {
     void * initial = *p;
index fe5acf8..2390ae1 100644 (file)
--- a/reclaim.c
+++ b/reclaim.c
  * modified is included with the above copyright notice.
  */
 
-#include <stdio.h>
 #include "private/gc_priv.h"
 
+#include <stdio.h>
+
 GC_INNER signed_word GC_bytes_found = 0;
                         /* Number of bytes of memory reclaimed     */
                         /* minus the number of bytes originally    */
index 9e8419e..a297dd5 100644 (file)
  * provided the above notices are retained, and a notice that the code was
  * modified is included with the above copyright notice.
  */
-/* Boehm, July 31, 1995 5:02 pm PDT */
-
 
 #include "private/gc_priv.h"
 
 #if defined(MANUAL_VDB)
-/* Stubborn object (hard to change, nearly immutable) allocation. */
-/* This interface is deprecated.  We mostly emulate it using      */
-/* MANUAL_VDB.  But that imposes the additional constraint that   */
-/* written, but not yet GC_dirty()ed objects must be referenced   */
-/* by a stack.                                                    */
-GC_API void * GC_CALL GC_malloc_stubborn(size_t lb)
-{
+
+  /* Stubborn object (hard to change, nearly immutable) allocation.     */
+  /* This interface is deprecated.  We mostly emulate it using          */
+  /* MANUAL_VDB.  But that imposes the additional constraint that       */
+  /* written, but not yet GC_dirty()ed objects must be referenced       */
+  /* by a stack.                                                        */
+
+  GC_API void * GC_CALL GC_malloc_stubborn(size_t lb)
+  {
     return(GC_malloc(lb));
-}
+  }
 
-GC_API void GC_CALL GC_end_stubborn_change(void *p)
-{
+  GC_API void GC_CALL GC_end_stubborn_change(void *p)
+  {
     GC_dirty(p);
-}
+  }
 
-/*ARGSUSED*/
-GC_API void GC_CALL GC_change_stubborn(void *p)
-{
-}
+  /*ARGSUSED*/
+  GC_API void GC_CALL GC_change_stubborn(void *p)
+  {
+  }
 
 #else /* !MANUAL_VDB */
 
-GC_API void * GC_CALL GC_malloc_stubborn(size_t lb)
-{
+  GC_API void * GC_CALL GC_malloc_stubborn(size_t lb)
+  {
     return(GC_malloc(lb));
-}
+  }
 
-/*ARGSUSED*/
-GC_API void GC_CALL GC_end_stubborn_change(void *p)
-{
-}
+  /*ARGSUSED*/
+  GC_API void GC_CALL GC_end_stubborn_change(void *p)
+  {
+  }
 
-/*ARGSUSED*/
-GC_API void GC_CALL GC_change_stubborn(void *p)
-{
-}
+  /*ARGSUSED*/
+  GC_API void GC_CALL GC_change_stubborn(void *p)
+  {
+  }
 
 #endif /* !MANUAL_VDB */
index 8bbc174..2f7022c 100644 (file)
 
 # undef GC_BUILD
 
+#if (defined(DBG_HDRS_ALL) || defined(MAKE_BACK_GRAPH)) && !defined(GC_DEBUG)
+#  define GC_DEBUG
+#endif
+
+#include "gc.h"
+
 #ifndef NTHREADS /* Number of additional threads to fork. */
 #  define NTHREADS 5 /* excludes main thread, which also runs a test. */
         /* Not respected by PCR test. */
 #endif
 
-#if (defined(DBG_HDRS_ALL) || defined(MAKE_BACK_GRAPH)) && !defined(GC_DEBUG)
-#  define GC_DEBUG
-#endif
-
 # if defined(mips) && defined(SYSTYPE_BSD43)
     /* MIPS RISCOS 4 */
 # else
@@ -45,7 +47,7 @@
 # else
 #   include <assert.h>        /* Not normally used, but handy for debugging. */
 # endif
-# include "gc.h"
+
 # include "gc_typed.h"
 # include "private/gc_priv.h"   /* For output, locking, MIN_WORDS,      */
                                 /* and some statistics, and gcconfig.h. */
index 4ef1769..fc68c83 100644 (file)
  * provided the above notices are retained, and a notice that the code was
  * modified is included with the above copyright notice.
  */
+
 #include "private/gc_priv.h"
 
-# if defined(THREAD_LOCAL_ALLOC)
+#if defined(THREAD_LOCAL_ALLOC)
 
 #ifndef THREADS
 # error "invalid config - THREAD_LOCAL_ALLOC requires GC_THREADS"
@@ -21,7 +22,7 @@
 #include "private/thread_local_alloc.h"
 #include "gc_inline.h"
 
-# include <stdlib.h>
+#include <stdlib.h>
 
 #if defined(USE_COMPILER_TLS)
   __thread
@@ -199,9 +200,9 @@ GC_API void * GC_CALL GC_malloc_atomic(size_t bytes)
 
 #ifdef GC_GCJ_SUPPORT
 
-#include "atomic_ops.h" /* for AO_compiler_barrier() */
+# include "atomic_ops.h" /* for AO_compiler_barrier() */
 
-#include "include/gc_gcj.h"
+# include "include/gc_gcj.h"
 
 /* Gcj-style allocation without locks is extremely tricky.  The         */
 /* fundamental issue is that we may end up marking a free list, which   */
@@ -307,4 +308,4 @@ void GC_mark_thread_local_fls_for(GC_tlfs p)
     }
 #endif /* GC_ASSERTIONS */
 
-# endif /* THREAD_LOCAL_ALLOC */
+#endif /* THREAD_LOCAL_ALLOC */
index 759ff82..b031f61 100644 (file)
@@ -13,6 +13,7 @@
  *
  */
 
+#include "private/gc_pmark.h"
 
 /*
  * Some simple primitives for allocation with explicit type information.
  * since they are not accessible through the current interface.
  */
 
-#include "private/gc_pmark.h"
 #include "gc_typed.h"
 
-# define TYPD_EXTRA_BYTES (sizeof(word) - EXTRA_BYTES)
+#define TYPD_EXTRA_BYTES (sizeof(word) - EXTRA_BYTES)
 
 STATIC GC_bool GC_explicit_typing_initialized = FALSE;
 
@@ -93,7 +93,7 @@ STATIC ext_descr * GC_ext_descriptors = NULL;
                                         /* descriptors.                 */
 
 STATIC size_t GC_ed_size = 0;   /* Current size of above arrays.        */
-# define ED_INITIAL_SIZE 100;
+#define ED_INITIAL_SIZE 100
 
 STATIC size_t GC_avail_descr = 0;       /* Next available slot.         */
 
@@ -199,10 +199,10 @@ GC_make_sequence_descriptor(complex_descriptor *first,
 /* The implementation knows that GC_DS_LENGTH is 0.             */
 /* *leaf, *complex_d, and *simple_d may be used as temporaries  */
 /* during the construction.                                     */
-# define COMPLEX 2
-# define LEAF 1
-# define SIMPLE 0
-# define NO_MEM (-1)
+#define COMPLEX 2
+#define LEAF    1
+#define SIMPLE  0
+#define NO_MEM  (-1)
 STATIC int GC_make_array_descriptor(size_t nelements, size_t size,
                                     GC_descr descriptor, GC_descr *simple_d,
                                     complex_descriptor **complex_d,
@@ -317,9 +317,9 @@ GC_make_sequence_descriptor(complex_descriptor *first,
 }
 
 #ifdef UNDEFINED
-complex_descriptor * GC_make_complex_array_descriptor(word nelements,
+  complex_descriptor * GC_make_complex_array_descriptor(word nelements,
                                                 complex_descriptor *descr)
-{
+  {
     struct ComplexArrayDescriptor * result =
         (struct ComplexArrayDescriptor *)
                 GC_malloc(sizeof(struct ComplexArrayDescriptor));
@@ -330,7 +330,7 @@ complex_descriptor * GC_make_complex_array_descriptor(word nelements,
         result -> ad_element_descr = descr;
     }
     return((complex_descriptor *)result);
-}
+  }
 #endif
 
 STATIC ptr_t * GC_eobjfreelist = NULL;