2009-10-17 Ivan Maidanski <ivmai@mail.ru>
authorivmai <ivmai>
Sat, 17 Oct 2009 10:12:52 +0000 (10:12 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 26 Jul 2011 17:06:50 +0000 (21:06 +0400)
* alloc.c (GC_never_stop_func, GC_check_fl_marks,
GC_finish_collection): Reformat the code (make opening bracket
style uniform across the file).
* allchblk.c (GC_allochblk): Ditto.
* backgraph.c (add_edge): Ditto.
* dbg_mlc.c (GC_marked_for_finalization): Ditto.
* dyn_load.c (GC_register_dynamic_libraries, GC_init_dyld): Ditto.
* finalize.c (GC_null_finalize_mark_proc): Ditto.
* gc_dlopen.c (GC_dlopen): Ditto.
* mark.c (GC_push_marked1, GC_push_marked2, GC_push_marked4):
Ditto.
* misc.c (looping_handler, GC_call_with_gc_active,
GC_do_blocking_inner, GC_do_blocking): Ditto.
* os_dep.c (GC_get_main_stack_base, GC_read_dirty): Ditto.
* pthread_support.c (GC_pthread_create, GC_pthread_sigmask,
GC_pthread_join, GC_pthread_detach, GC_check_tls,
GC_do_blocking_inner, GC_call_with_gc_active): Ditto.
* reclaim.c (GC_reclaim_clear, GC_reclaim_block,
GC_print_free_list): Ditto.
* os_dep.c (GC_page_was_dirty, GC_page_was_ever_dirty,
GC_remove_protection): Reformat the code (wrap long lines).

13 files changed:
ChangeLog
allchblk.c
alloc.c
backgraph.c
dbg_mlc.c
dyn_load.c
finalize.c
gc_dlopen.c
mark.c
misc.c
os_dep.c
pthread_support.c
reclaim.c

index 60cd977..5c2d129 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2009-10-17  Ivan Maidanski <ivmai@mail.ru>
+
+       * alloc.c (GC_never_stop_func, GC_check_fl_marks,
+       GC_finish_collection): Reformat the code (make opening bracket
+       style uniform across the file).
+       * allchblk.c (GC_allochblk): Ditto.
+       * backgraph.c (add_edge): Ditto.
+       * dbg_mlc.c (GC_marked_for_finalization): Ditto.
+       * dyn_load.c (GC_register_dynamic_libraries, GC_init_dyld): Ditto.
+       * finalize.c (GC_null_finalize_mark_proc): Ditto.
+       * gc_dlopen.c (GC_dlopen): Ditto.
+       * mark.c (GC_push_marked1, GC_push_marked2, GC_push_marked4):
+       Ditto.
+       * misc.c (looping_handler, GC_call_with_gc_active,
+       GC_do_blocking_inner, GC_do_blocking): Ditto.
+       * os_dep.c (GC_get_main_stack_base, GC_read_dirty): Ditto.
+       * pthread_support.c (GC_pthread_create, GC_pthread_sigmask,
+       GC_pthread_join, GC_pthread_detach, GC_check_tls,
+       GC_do_blocking_inner, GC_call_with_gc_active): Ditto.
+       * reclaim.c (GC_reclaim_clear, GC_reclaim_block,
+       GC_print_free_list): Ditto.
+       * os_dep.c (GC_page_was_dirty, GC_page_was_ever_dirty,
+       GC_remove_protection): Reformat the code (wrap long lines).
+
 2009-10-16  Ivan Maidanski <ivmai@mail.ru>
 
        * alloc.c (GC_finish_collection): Replace getenv() with GETENV().
index 93ff551..03d494a 100644 (file)
@@ -601,7 +601,7 @@ GC_allochblk(size_t sz, int kind, unsigned flags/* IGNORE_OFF_PAGE or 0 */)
         /* avoid splitting, since that might require remapping */
         split_limit = 0;
 #     else
-        if (GC_finalizer_bytes_freed > (GC_heapsize >> 4))  {
+        if (GC_finalizer_bytes_freed > (GC_heapsize >> 4)) {
           /* If we are deallocating lots of memory from         */
           /* finalizers, fail and collect sooner rather         */
           /* than later.                                        */
diff --git a/alloc.c b/alloc.c
index 8d4dbe0..e953a0a 100644 (file)
--- a/alloc.c
+++ b/alloc.c
@@ -125,7 +125,10 @@ word GC_free_space_divisor = GC_FREE_SPACE_DIVISOR;
 GC_bool GC_collection_in_progress(void);
                 /* Collection is in progress, or was abandoned. */
 
-int GC_CALLBACK GC_never_stop_func (void) { return(0); }
+int GC_CALLBACK GC_never_stop_func(void)
+{
+  return(0);
+}
 
 #ifndef GC_TIME_LIMIT
 # define GC_TIME_LIMIT 50  /* We try to keep pause times from exceeding  */
@@ -695,12 +698,11 @@ void GC_set_fl_marks(ptr_t q)
 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)) {
-            GC_err_printf("Unmarked object %p on list %p\n", p, q);
-            ABORT("Unmarked local free list entry.");
-        }
+   for (p = q; p != 0; p = obj_link(p)) {
+       if (!GC_is_marked(p)) {
+           GC_err_printf("Unmarked object %p on list %p\n", p, q);
+           ABORT("Unmarked local free list entry.");
+       }
    }
 }
 #endif
@@ -859,7 +861,7 @@ STATIC void GC_finish_collection(void)
                         (unsigned long)GC_composite_in_use,
                         (unsigned long)GC_atomic_in_use);
         }
-        if (GC_is_full_gc)  {
+        if (GC_is_full_gc) {
             GC_used_heap_size_after_full = USED_HEAP_SIZE;
             GC_need_full_gc = FALSE;
         } else {
index 92a4135..40d6cff 100644 (file)
@@ -245,8 +245,8 @@ static void add_edge(ptr_t p, ptr_t q)
     ensure_struct(q);
     old_back_ptr = GET_OH_BG_PTR(q);
     be = (back_edges *)((word)old_back_ptr & ~FLAG_MANY);
-    for (i = be -> n_edges, be_cont = be; i > MAX_IN;
-        be_cont = be_cont -> cont, i -= MAX_IN) {}
+    for (i = be -> n_edges, be_cont = be; i > MAX_IN; i -= MAX_IN)
+        be_cont = be_cont -> cont;
     if (i == MAX_IN) {
         be_cont -> cont = new_back_edges();
         be_cont = be_cont -> cont;
index af0b509..75426da 100644 (file)
--- a/dbg_mlc.c
+++ b/dbg_mlc.c
@@ -84,7 +84,8 @@ GC_bool GC_has_other_debug_info(ptr_t p)
     }
   }
 
-  void GC_marked_for_finalization(ptr_t dest) {
+  void GC_marked_for_finalization(ptr_t dest)
+  {
     GC_store_back_pointer(MARKED_FOR_FINALIZATION, dest);
   }
 
@@ -331,7 +332,7 @@ STATIC ptr_t GC_check_annotated_obj(oh *ohdr)
 static GC_describe_type_fn GC_describe_type_fns[MAXOBJKINDS] = {0};
 
 GC_API void GC_CALL GC_register_describe_type_fn(int kind,
-                                                GC_describe_type_fn fn)
+                                                 GC_describe_type_fn fn)
 {
   GC_describe_type_fns[kind] = fn;
 }
@@ -481,7 +482,7 @@ GC_API void * GC_CALL GC_debug_malloc(size_t lb, GC_EXTRA_PARAMS)
 }
 
 GC_API void * GC_CALL GC_debug_malloc_ignore_off_page(size_t lb,
-                                                GC_EXTRA_PARAMS)
+                                                      GC_EXTRA_PARAMS)
 {
     void * result = GC_malloc_ignore_off_page(lb + DEBUG_BYTES);
 
@@ -500,7 +501,7 @@ GC_API void * GC_CALL GC_debug_malloc_ignore_off_page(size_t lb,
 }
 
 GC_API void * GC_CALL GC_debug_malloc_atomic_ignore_off_page(size_t lb,
-                                                        GC_EXTRA_PARAMS)
+                                                             GC_EXTRA_PARAMS)
 {
     void * result = GC_malloc_atomic_ignore_off_page(lb + DEBUG_BYTES);
 
@@ -958,9 +959,9 @@ void GC_CALLBACK GC_debug_invoke_finalizer(void * obj, void * data)
 #define OFN_UNSET (GC_finalization_proc)(signed_word)-1
 
 /* Set ofn and ocd to reflect the values we got back.   */
-static void store_old (void *obj, GC_finalization_proc my_old_fn,
-                       struct closure *my_old_cd, GC_finalization_proc *ofn,
-                       void **ocd)
+static void store_old(void *obj, GC_finalization_proc my_old_fn,
+                      struct closure *my_old_cd, GC_finalization_proc *ofn,
+                      void **ocd)
 {
     if (0 != my_old_fn) {
       if (my_old_fn == OFN_UNSET) {
index 498879a..93db044 100644 (file)
@@ -612,7 +612,6 @@ void GC_register_dynamic_libraries(void)
 {
   struct link_map *lm;
 
-
 # ifdef HAVE_DL_ITERATE_PHDR
     if (GC_register_dynamic_libraries_dl_iterate_phdr()) {
         return;
@@ -1224,7 +1223,8 @@ static void GC_dyld_image_remove(const struct GC_MACH_HEADER *hdr,
 #   endif
 }
 
-void GC_register_dynamic_libraries(void) {
+void GC_register_dynamic_libraries(void)
+{
     /* Currently does nothing. The callbacks are setup by GC_init_dyld()
     The dyld library takes it from there. */
 }
@@ -1235,7 +1235,8 @@ void GC_register_dynamic_libraries(void) {
    This should be called BEFORE any thread in created and WITHOUT the
    allocation lock held. */
 
-void GC_init_dyld(void) {
+void GC_init_dyld(void)
+{
   static GC_bool initialized = FALSE;
 
   if(initialized) return;
@@ -1320,7 +1321,6 @@ void GC_register_dynamic_libraries(void)
         }
 }
 
-
 #else /* !PCR */
 
 void GC_register_dynamic_libraries(void) {}
index fbd1826..aca3709 100644 (file)
@@ -279,9 +279,7 @@ STATIC void GC_ignore_self_finalize_mark_proc(ptr_t p)
 }
 
 /*ARGSUSED*/
-STATIC void GC_null_finalize_mark_proc(ptr_t p)
-{
-}
+STATIC void GC_null_finalize_mark_proc(ptr_t p) {}
 
 /* Possible finalization_marker procedures.  Note that mark stack       */
 /* overflow is handled by the caller, and is not a disaster.            */
@@ -916,7 +914,7 @@ void GC_notify_or_invoke_finalizers(void)
 }
 
 GC_API void * GC_CALL GC_call_with_alloc_lock(GC_fn_type fn,
-                                        void * client_data)
+                                              void * client_data)
 {
     void * result;
     DCL_LOCK_STATE;
index 6461984..98c699f 100644 (file)
@@ -90,7 +90,8 @@ GC_API void * WRAP_FUNC(dlopen)(const char *path, int mode)
   /* Define GC_ function as an alias for the plain one, which will be   */
   /* intercepted.  This allows files which include gc.h, and hence      */
   /* generate references to the GC_ symbol, to see the right symbol.    */
-  GC_API int GC_dlopen(const char *path, int mode) {
+  GC_API int GC_dlopen(const char *path, int mode)
+  {
     return dlopen(path, mode);
   }
 #endif /* Linker-based interception. */
diff --git a/mark.c b/mark.c
index e0b1fef..fecec5e 100644 (file)
--- a/mark.c
+++ b/mark.c
@@ -1584,7 +1584,7 @@ void GC_push_marked1(struct hblk *h, hdr *hhdr)
     plim = (word *)(((word)h) + HBLKSIZE);
 
     /* go through all words in block */
-        while( p < plim )  {
+        while (p < plim) {
             mark_word = *mark_word_addr++;
             q = p;
             while(mark_word != 0) {
@@ -1632,7 +1632,7 @@ void GC_push_marked2(struct hblk *h, hdr *hhdr)
     plim = (word *)(((word)h) + HBLKSIZE);
 
     /* go through all words in block */
-        while( p < plim )  {
+        while (p < plim) {
             mark_word = *mark_word_addr++;
             q = p;
             while(mark_word != 0) {
@@ -1680,7 +1680,7 @@ void GC_push_marked4(struct hblk *h, hdr *hhdr)
     plim = (word *)(((word)h) + HBLKSIZE);
 
     /* go through all words in block */
-        while( p < plim )  {
+        while (p < plim) {
             mark_word = *mark_word_addr++;
             q = p;
             while(mark_word != 0) {
diff --git a/misc.c b/misc.c
index 5074cd9..49c53cd 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -485,7 +485,7 @@ void GC_set_and_save_fault_handler(void (*handler)(int));
 static void looping_handler(int sig)
 {
     GC_err_printf("Caught signal %d: looping in handler\n", sig);
-    for(;;);
+    for (;;) {}
 }
 
 static GC_bool installed_looping_handler = FALSE;
@@ -1370,7 +1370,8 @@ struct GC_activation_frame_s *GC_activation_frame = NULL;
 
 /* This is nearly the same as in win32_threads.c        */
 GC_API void * GC_CALL GC_call_with_gc_active(GC_fn_type fn,
-                                        void * client_data) {
+                                             void * client_data)
+{
     struct GC_activation_frame_s frame;
     GC_ASSERT(GC_is_initialized);
 
@@ -1414,7 +1415,8 @@ GC_API void * GC_CALL GC_call_with_gc_active(GC_fn_type fn,
 
 /* This is nearly the same as in win32_threads.c        */
 /*ARGSUSED*/
-STATIC void GC_do_blocking_inner(ptr_t data, void * context) {
+STATIC void GC_do_blocking_inner(ptr_t data, void * context)
+{
     struct blocking_data * d = (struct blocking_data *) data;
     GC_ASSERT(GC_is_initialized);
     GC_ASSERT(GC_blocked_sp == NULL);
@@ -1447,7 +1449,8 @@ STATIC void GC_do_blocking_inner(ptr_t data, void * context) {
 /* more precise (i.e. scan only stack frames of functions that allocate */
 /* garbage collected memory and/or manipulate pointers to the garbage   */
 /* collected heap).                                                     */
-GC_API void * GC_CALL GC_do_blocking(GC_fn_type fn, void * client_data) {
+GC_API void * GC_CALL GC_do_blocking(GC_fn_type fn, void * client_data)
+{
     struct blocking_data my_data;
 
     my_data.fn = fn;
index 7e27dff..e51bacd 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
@@ -722,12 +722,13 @@ ptr_t GC_get_main_stack_base(void)
 # endif /* MS Windows */
 
 # ifdef BEOS
-# include <kernel/OS.h>
-ptr_t GC_get_main_stack_base(void){
-        thread_info th;
-        get_thread_info(find_thread(NULL),&th);
-        return th.stack_end;
-}
+#   include <kernel/OS.h>
+    ptr_t GC_get_main_stack_base(void)
+    {
+      thread_info th;
+      get_thread_info(find_thread(NULL),&th);
+      return th.stack_end;
+    }
 # endif /* BEOS */
 
 
@@ -2444,7 +2445,8 @@ STATIC void GC_or_pages(page_hash_table pht1, page_hash_table pht2)
     GC_bool GC_page_was_dirty(struct hblk * h)
 # endif
   {
-    return HDR(h) == 0 || get_pht_entry_from_index(GC_grungy_pages, PHT_HASH(h));
+    return HDR(h) == 0 ||
+            get_pht_entry_from_index(GC_grungy_pages, PHT_HASH(h));
   }
 
 # ifdef MPROTECT_VDB
@@ -2453,13 +2455,14 @@ STATIC void GC_or_pages(page_hash_table pht1, page_hash_table pht2)
     GC_bool GC_page_was_ever_dirty(struct hblk * h)
 # endif
   {
-    return HDR(h) == 0 || get_pht_entry_from_index(GC_written_pages, PHT_HASH(h));
+    return HDR(h) == 0 ||
+            get_pht_entry_from_index(GC_written_pages, PHT_HASH(h));
   }
 
 # ifndef MPROTECT_VDB
     /*ARGSUSED*/
-    void GC_remove_protection(struct hblk *h, word nblocks, GC_bool is_ptrfree)
-    {}
+    void GC_remove_protection(struct hblk *h, word nblocks,
+                              GC_bool is_ptrfree) {}
 # endif
 
 # endif /* GWW_VDB */
@@ -2481,8 +2484,7 @@ void GC_dirty_init(void)
 
 /* Retrieve system dirty bits for heap to a local buffer.       */
 /* Restore the systems notion of which pages are dirty.         */
-void GC_read_dirty(void)
-{}
+void GC_read_dirty(void) {}
 
 /* Is the HBLKSIZE sized page at h marked dirty in the local buffer?    */
 /* If the actual page size is different, this returns TRUE if any       */
@@ -2733,7 +2735,7 @@ STATIC GC_bool GC_old_segv_handler_used_si = FALSE;
 #endif /* !AO_HAVE_test_and_set_acquire */
 #else /* !THREADS */
 # define async_set_pht_entry_from_index(db, index) \
-        set_pht_entry_from_index(db, index)
+                        set_pht_entry_from_index(db, index)
 #endif /* !THREADS */
 
 #ifdef CHECKSUMS
@@ -3373,7 +3375,7 @@ void GC_read_dirty(void)
             limit = vaddr + ps * np;
             bufp += sizeof (struct prasmap);
             for (current_addr = vaddr;
-                 current_addr < limit; current_addr += ps){
+                 current_addr < limit; current_addr += ps) {
                 if ((*bufp++) & PG_MODIFIED) {
                     register struct hblk * h = (struct hblk *) current_addr;
 
@@ -3872,7 +3874,7 @@ static kern_return_t GC_forward_exception(mach_port_t thread, mach_port_t task,
 #define FWD() GC_forward_exception(thread, task, exception, code, code_count)
 
 /* This violates the namespace rules but there isn't anything that can be done
-   about it. The exception handling stuff is hard coded to call this */
+   about it.  The exception handling stuff is hard coded to call this. */
 kern_return_t
 catch_exception_raise(mach_port_t exception_port, mach_port_t thread,
                       mach_port_t task, exception_type_t exception,
index 02e4202..8294f7c 100644 (file)
@@ -151,17 +151,24 @@ unsigned long GC_lock_holder = NO_THREAD;
 /* be intercepted.  This allows files which include gc.h, and hence     */
 /* generate references to the GC_ symbols, to see the right symbols.    */
       GC_API int GC_pthread_create(pthread_t * t, const pthread_attr_t * a,
-                         void * (* fn)(void *), void * arg) {
+                                   void * (* fn)(void *), void * arg)
+      {
           return pthread_create(t, a, fn, arg);
       }
+
       GC_API int GC_pthread_sigmask(int how, const sigset_t *mask,
-                                sigset_t *old) {
+                                    sigset_t *old)
+      {
           return pthread_sigmask(how, mask, old);
       }
-      GC_API int GC_pthread_join(pthread_t t, void **res) {
+
+      GC_API int GC_pthread_join(pthread_t t, void **res)
+      {
           return pthread_join(t, res);
       }
-      GC_API int GC_pthread_detach(pthread_t t) {
+
+      GC_API int GC_pthread_detach(pthread_t t)
+      {
           return pthread_detach(t);
       }
 #endif /* Linker-based interception. */
@@ -245,7 +252,8 @@ void GC_mark_thread_local_free_lists(void)
 #   endif
     /* Check that all thread-local free-lists are completely marked.    */
     /* also check that thread-specific-data structures are marked.      */
-    void GC_check_tls(void) {
+    void GC_check_tls(void)
+    {
         int i;
         GC_thread p;
 
@@ -918,7 +926,7 @@ void GC_init_parallel(void)
 
 #if !defined(GC_DARWIN_THREADS)
 GC_API int WRAP_FUNC(pthread_sigmask)(int how, const sigset_t *set,
-                                        sigset_t *oset)
+                                      sigset_t *oset)
 {
     sigset_t fudged_set;
 
@@ -936,7 +944,8 @@ GC_API int WRAP_FUNC(pthread_sigmask)(int how, const sigset_t *set,
 /* length of time.                                                      */
 
 /*ARGSUSED*/
-void GC_do_blocking_inner(ptr_t data, void * context) {
+void GC_do_blocking_inner(ptr_t data, void * context)
+{
     struct blocking_data * d = (struct blocking_data *) data;
     GC_thread me;
     LOCK();
@@ -964,7 +973,8 @@ void GC_do_blocking_inner(ptr_t data, void * context) {
 /* GC_do_blocking() to temporarily back allow calling any GC function   */
 /* and/or manipulating pointers to the garbage collected heap.          */
 GC_API void * GC_CALL GC_call_with_gc_active(GC_fn_type fn,
-                                        void * client_data) {
+                                             void * client_data)
+{
     struct GC_activation_frame_s frame;
     GC_thread me;
     LOCK();   /* This will block if the world is stopped.       */
index 555c99c..efa49a5 100644 (file)
--- a/reclaim.c
+++ b/reclaim.c
@@ -124,7 +124,7 @@ STATIC ptr_t GC_reclaim_clear(struct hblk *hbp, hdr *hhdr, size_t sz,
     plim = (word *)(hbp->hb_body + HBLKSIZE - sz);
 
     /* go through all words in block */
-        while( p <= plim )  {
+        while (p <= plim) {
             if( mark_bit_from_hdr(hhdr, bit_no) ) {
                 p = (word *)((ptr_t)p + sz);
             } else {
@@ -169,7 +169,7 @@ STATIC ptr_t GC_reclaim_uninit(struct hblk *hbp, hdr *hhdr, size_t sz,
     plim = (word *)((ptr_t)hbp + HBLKSIZE - sz);
 
     /* go through all words in block */
-        while( p <= plim )  {
+        while (p <= plim) {
             if( !mark_bit_from_hdr(hhdr, bit_no) ) {
                 n_bytes_found += sz;
                 /* object is available - put on list */
@@ -194,7 +194,7 @@ STATIC void GC_reclaim_check(struct hblk *hbp, hdr *hhdr, word sz)
     plim = p + HBLKSIZE - sz;
 
     /* go through all words in block */
-        while( p <= plim )  {
+        while (p <= plim) {
             if( !mark_bit_from_hdr(hhdr, bit_no) ) {
                 GC_add_leaked(p);
             }
@@ -309,7 +309,7 @@ STATIC void GC_reclaim_block(struct hblk *hbp, word report_if_found)
         } else if (empty) {
           GC_bytes_found += HBLKSIZE;
           GC_freehblk(hbp);
-        } else if (GC_find_leak || !GC_block_nearly_full(hhdr)){
+        } else if (GC_find_leak || !GC_block_nearly_full(hhdr)) {
           /* group of smaller objects, enqueue the real work */
           rlh = &(ok -> ok_reclaim_list[BYTES_TO_GRANULES(sz)]);
           hhdr -> hb_next = *rlh;
@@ -438,9 +438,9 @@ void GC_print_free_list(int kind, size_t sz_in_granules)
     struct hblk *lastBlock = 0;
     int n = 0;
 
-    while (flh){
+    while (flh) {
         struct hblk *block = HBLKPTR(flh);
-        if (block != lastBlock){
+        if (block != lastBlock) {
             GC_printf("\nIn heap block at %p:\n\t", block);
             lastBlock = block;
         }