]> granicus.if.org Git - gc/commitdiff
2009-05-27 Hans Boehm <Hans.Boehm@hp.com> (Really Ivan Maidanski)
authorhboehm <hboehm>
Wed, 27 May 2009 23:09:53 +0000 (23:09 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 26 Jul 2011 17:06:45 +0000 (21:06 +0400)
(diff86_cvs, resembling diff28, diff32, diff33, diff38, diff68 partly)
* test.c (fork_a_thread, reverse_test, alloc8bytes, tree_test,
        typed_test, run_one_test, check_heap_stats, main, test): Replace
        all K&R-style function definitions with ANSI C ones.
        * trace_test.c (main): Ditto.
        * test.c (GC_COND_INIT): Define as GC_INIT() also in case of
        THREAD_LOCAL_ALLOC.
        * test.c (reverse_test): Call fork_a_thread() only if GC_PTHREADS
        or GC_WIN32_THREADS; remove fork_a_thread() macros definition.
        * test.c (reverse_test): Use "volatile" when clearing "b" and "c"
        local variables (to suppress "assigned value is never used"
        compiler warning).
        * test.c (tree_test): Use public GC_noop1() instead of private
        GC_noop().
        * test.c (typed_test): Ditto.
        * test.c (check_heap_stats): Define and assign value to
        "late_finalize_count" local variable only if its value is used
        (if FINALIZE_ON_DEMAND defined).
        * test.c (main): Remove DJGPP-specific initialization of
        GC_stackbottom (not needed anymore, handled in gcconfig.h).
        * trace_test.c: Guard #define GC_DEBUG with #ifndef.
        * trace_test.c: Include "gc_backptr.h".
        * trace_test.c (main): Call GC_INIT().
        * trace_test.c (main): Add "return 0" statement.

ChangeLog
tests/test.c
tests/trace_test.c

index d44a13eec2fb67d3490f0185fbd413a0dc7268c1..5c22072bb1dedadfdfc4ff1db8f831a52ccb1921 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2009-05-27  Hans Boehm <Hans.Boehm@hp.com> (Really Ivan Maidanski)
+       (diff86_cvs, resembling diff28, diff32, diff33, diff38, diff68 partly)
+       * test.c (fork_a_thread, reverse_test, alloc8bytes, tree_test,
+        typed_test, run_one_test, check_heap_stats, main, test): Replace
+        all K&R-style function definitions with ANSI C ones.
+        * trace_test.c (main): Ditto.
+        * test.c (GC_COND_INIT): Define as GC_INIT() also in case of
+        THREAD_LOCAL_ALLOC.
+        * test.c (reverse_test): Call fork_a_thread() only if GC_PTHREADS
+        or GC_WIN32_THREADS; remove fork_a_thread() macros definition.
+        * test.c (reverse_test): Use "volatile" when clearing "b" and "c"
+        local variables (to suppress "assigned value is never used"
+        compiler warning).
+        * test.c (tree_test): Use public GC_noop1() instead of private
+        GC_noop().
+        * test.c (typed_test): Ditto.
+        * test.c (check_heap_stats): Define and assign value to
+        "late_finalize_count" local variable only if its value is used
+        (if FINALIZE_ON_DEMAND defined).
+        * test.c (main): Remove DJGPP-specific initialization of
+        GC_stackbottom (not needed anymore, handled in gcconfig.h).
+        * trace_test.c: Guard #define GC_DEBUG with #ifndef.
+        * trace_test.c: Include "gc_backptr.h".
+        * trace_test.c (main): Call GC_INIT().
+        * trace_test.c (main): Add "return 0" statement.
+
 2009-05-25  Hans Boehm <Hans.Boehm@hp.com> (Really Petter Urkedal)
        * dyn_load.c (GC_register_dynlib_callback): Use new index j
        instead of i in the inner loop.
index 604f814f25852d1106707e62e3631c78a0ee929e..385c421b91188c9349df4d08cc3f4d466746d139 100644 (file)
@@ -72,7 +72,8 @@
 
 /* Call GC_INIT only on platforms on which we think we really need it, */
 /* so that we can test automatic initialization on the rest.           */
-#if defined(CYGWIN32) || defined (AIX) || defined(DARWIN)
+#if defined(CYGWIN32) || defined (AIX) || defined(DARWIN) \
+       || defined(THREAD_LOCAL_ALLOC)
 #  define GC_COND_INIT() GC_INIT()
 #else
 #  define GC_COND_INIT()
@@ -459,7 +460,7 @@ void check_marks_int_list(sexpr x)
 }
 
 # if defined(GC_PTHREADS)
-    void fork_a_thread()
+    void fork_a_thread(void)
     {
       pthread_t t;
       int code;
@@ -474,7 +475,7 @@ void check_marks_int_list(sexpr x)
     }
 
 # elif defined(GC_WIN32_THREADS)
-    void fork_a_thread()
+    void fork_a_thread(void)
     {
        DWORD thread_id;
        HANDLE h;
@@ -491,16 +492,8 @@ void check_marks_int_list(sexpr x)
        }
     }
 
-# else
-
-#   define fork_a_thread()
-
 # endif
 
-#else
-
-# define fork_a_thread()
-
 #endif 
 
 /* Try to force a to be strangely aligned */
@@ -514,7 +507,7 @@ struct {
  * Repeatedly reverse lists built out of very different sized cons cells.
  * Check that we didn't lose anything.
  */
-void reverse_test()
+void reverse_test(void)
 {
     int i;
     sexpr b;
@@ -592,7 +585,9 @@ void reverse_test()
     check_ints(b,1,50);
     check_ints(a,1,49);
     for (i = 0; i < 60; i++) {
-       if (i % 10 == 0) fork_a_thread();
+#      if defined(GC_PTHREADS) || defined(GC_WIN32_THREADS)
+           if (i % 10 == 0) fork_a_thread();
+#      endif
        /* This maintains the invariant that a always points to a list of */
        /* 49 integers.  Thus this is thread safe without locks,          */
        /* assuming atomic pointer assignments.                           */
@@ -621,7 +616,8 @@ void reverse_test()
 #   ifndef THREADS
        a = 0;
 #   endif  
-    b = c = 0;
+    *(volatile void **)&b = 0;
+    *(volatile void **)&c = 0;
 }
 
 #undef a
@@ -794,7 +790,7 @@ void chktree(tn *t, int n)
 #if defined(GC_PTHREADS)
 pthread_key_t fl_key;
 
-void * alloc8bytes()
+void * alloc8bytes(void)
 {
 # if defined(SMALL_CONFIG) || defined(GC_DEBUG)
     collectable_count++;
@@ -857,7 +853,7 @@ void alloc_small(int n)
 #     define TREE_HEIGHT 16
 #   endif
 # endif
-void tree_test()
+void tree_test(void)
 {
     tn * root;
     int i;
@@ -872,8 +868,8 @@ void tree_test()
         FAIL;
     }
     dropped_something = 1;
-    GC_noop(root);     /* Root needs to remain live until      */
-                       /* dropped_something is set.            */
+    GC_noop1((word)root);      /* Root needs to remain live until      */
+                               /* dropped_something is set.            */
     root = mktree(TREE_HEIGHT);
     chktree(root, TREE_HEIGHT);
     for (i = TREE_HEIGHT; i >= 0; i--) {
@@ -905,7 +901,7 @@ GC_word bm_huge[10] = {
 };
 
 /* A very simple test of explicitly typed allocation   */
-void typed_test()
+void typed_test(void)
 {
     GC_word * old, * new;
     GC_word bm3 = 0x3;
@@ -977,7 +973,7 @@ void typed_test()
         new = (GC_word *)(old[1]);
     }
     GC_gcollect();
-    GC_noop(x);
+    GC_noop1((word)x);
 }
 
 int fail_count = 0;
@@ -1013,7 +1009,7 @@ static void uniq(void *p, ...) {
 #   define TEST_FAIL_COUNT(n) (fail_count >= (n))
 #endif
 
-void run_one_test()
+void run_one_test(void)
 {
 #   ifndef DBG_HDRS_ALL
        char *x;
@@ -1225,12 +1221,14 @@ void run_one_test()
       GC_log_printf("Finished %p\n", &start_time);
 }
 
-void check_heap_stats()
+void check_heap_stats(void)
 {
     size_t max_heap_sz;
     int i;
     int still_live;
-    int late_finalize_count = 0;
+#   ifdef FINALIZE_ON_DEMAND
+       int late_finalize_count = 0;
+#   endif
     
 #   ifdef VERY_SMALL_CONFIG
     /* The upper bounds are a guess, which has been empirically        */
@@ -1264,7 +1262,10 @@ void check_heap_stats()
       while (GC_collect_a_little()) { }
       for (i = 0; i < 16; i++) {
         GC_gcollect();
-        late_finalize_count += GC_invoke_finalizers();
+#   ifdef FINALIZE_ON_DEMAND
+          late_finalize_count +=
+#   endif
+               GC_invoke_finalizers();
       }
     (void)GC_printf("Completed %u tests\n", (unsigned) n_tests);
     (void)GC_printf("Allocated %d collectable objects\n", collectable_count);
@@ -1356,19 +1357,10 @@ void GC_CALLBACK warn_proc(char *msg, GC_word p)
 #if defined(MSWIN32) && !defined(__MINGW32__)
   int APIENTRY WinMain(HINSTANCE instance, HINSTANCE prev, LPTSTR cmd, int n)
 #else
-  int main()
+  int main(void)
 #endif
 {
-#   if defined(DJGPP)
-       int dummy;
-#   endif
     n_tests = 0;
-    
-#   if defined(DJGPP)
-       /* No good way to determine stack base from library; do it */
-       /* manually on this platform.                              */
-       GC_stackbottom = (void *)(&dummy);
-#   endif
 #   if defined(MACOS)
        /* Make sure we have lots and lots of stack space.      */
        SetMinimumStack(cMinStackSpace);
@@ -1572,7 +1564,7 @@ int APIENTRY WinMain(HINSTANCE instance, HINSTANCE prev, LPSTR cmd, int n)
 
 
 #ifdef PCR
-test()
+int test(void)
 {
     PCR_Th_T * th1;
     PCR_Th_T * th2;
index 870e38723a8dc4aa7dc34abe2ff5d9f7296ff8d3..bb8b813a16d0c462d529964ab33329d41f250b3e 100644 (file)
@@ -1,6 +1,11 @@
 #include <stdio.h>
-#define GC_DEBUG
+
+#ifndef GC_DEBUG
+# define GC_DEBUG
+#endif
+
 #include "gc.h"
+#include "gc_backptr.h"
 
 struct treenode {
     struct treenode *x;
@@ -16,9 +21,10 @@ struct treenode * mktree(int i) {
   return r;
 }
 
-main()
+int main(void)
 {
   int i;
+  GC_INIT();
   for (i = 0; i < 10; ++i) {
     root[i] = mktree(12);
   }
@@ -26,4 +32,5 @@ main()
   GC_generate_random_backtrace();
   GC_generate_random_backtrace();
   GC_generate_random_backtrace();
+  return 0;
 }