[BACK]Return to test.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / gc / tests

Diff for /OpenXM_contrib2/asir2000/gc/tests/test.c between version 1.1 and 1.2

version 1.1, 2002/07/24 08:00:21 version 1.2, 2003/06/24 05:11:43
Line 68 
Line 68 
 #   include <pthread.h>  #   include <pthread.h>
 # endif  # endif
   
 # ifdef GC_WIN32_THREADS  # if defined(GC_WIN32_THREADS) && !defined(GC_PTHREADS)
 #   ifndef MSWINCE  
 #     include <process.h>  
 #     define GC_CreateThread(a,b,c,d,e,f) ((HANDLE) _beginthreadex(a,b,c,d,e,f))  
 #   endif  
     static CRITICAL_SECTION incr_cs;      static CRITICAL_SECTION incr_cs;
 # endif  # endif
   
   #ifdef __STDC__
   # include <stdarg.h>
   #endif
   
   
 /* Allocation Statistics */  /* Allocation Statistics */
 int stubborn_count = 0;  int stubborn_count = 0;
 int uncollectable_count = 0;  int uncollectable_count = 0;
Line 376  sexpr x, y;
Line 376  sexpr x, y;
 sexpr reverse(x)  sexpr reverse(x)
 sexpr x;  sexpr x;
 {  {
   #   ifdef TEST_WITH_SYSTEM_MALLOC
         malloc(100000);
   #   endif
     return( reverse1(x, nil) );      return( reverse1(x, nil) );
 }  }
   
Line 517  sexpr x;
Line 520  sexpr x;
     }      }
 }  }
   
 /* Try to force a to be strangely aligned */  
 struct {  
   char dummy;  
   sexpr aa;  
 } A;  
 #define a A.aa  
   
 /*  /*
  * A tiny list reversal test to check thread creation.   * A tiny list reversal test to check thread creation.
  */   */
 #ifdef THREADS  #ifdef THREADS
   
 # if defined(GC_WIN32_THREADS) && !defined(CYGWIN32)  # if defined(GC_WIN32_THREADS) && !defined(CYGWIN32)
     unsigned __stdcall tiny_reverse_test(void * arg)      DWORD  __stdcall tiny_reverse_test(void * arg)
 # else  # else
     void * tiny_reverse_test(void * arg)      void * tiny_reverse_test(void * arg)
 # endif  # endif
Line 565  struct {
Line 561  struct {
 # elif defined(GC_WIN32_THREADS)  # elif defined(GC_WIN32_THREADS)
     void fork_a_thread()      void fork_a_thread()
     {      {
         unsigned thread_id;          DWORD thread_id;
         HANDLE h;          HANDLE h;
         h = GC_CreateThread(NULL, 0, tiny_reverse_test, 0, 0, &thread_id);          h = GC_CreateThread(NULL, 0, tiny_reverse_test, 0, 0, &thread_id);
         if (h == (HANDLE)NULL) {          if (h == (HANDLE)NULL) {
Line 594  struct {
Line 590  struct {
   
 #endif  #endif
   
   /* Try to force a to be strangely aligned */
   struct {
     char dummy;
     sexpr aa;
   } A;
   #define a A.aa
   
 /*  /*
  * Repeatedly reverse lists built out of very different sized cons cells.   * Repeatedly reverse lists built out of very different sized cons cells.
  * Check that we didn't lose anything.   * Check that we didn't lose anything.
Line 714  void reverse_test()
Line 717  void reverse_test()
     b = c = 0;      b = c = 0;
 }  }
   
   #undef a
   
 /*  /*
  * The rest of this builds balanced binary trees, checks that they don't   * The rest of this builds balanced binary trees, checks that they don't
  * disappear, and tests finalization.   * disappear, and tests finalization.
Line 758  VOLATILE int dropped_something = 0;
Line 763  VOLATILE int dropped_something = 0;
      FAIL;       FAIL;
   }    }
   finalized_count++;    finalized_count++;
     t -> level = -1;      /* detect duplicate finalization immediately */
 # ifdef PCR  # ifdef PCR
     PCR_ThCrSec_ExitSys();      PCR_ThCrSec_ExitSys();
 # endif  # endif
Line 1165  void fail_proc1(GC_PTR x)
Line 1171  void fail_proc1(GC_PTR x)
     fail_count++;      fail_count++;
 }  }
   
   static void uniq(void *p, ...) {
     va_list a;
     void *q[100];
     int n = 0, i, j;
     q[n++] = p;
     va_start(a,p);
     for (;(q[n] = va_arg(a,void *));n++) ;
     va_end(a);
     for (i=0; i<n; i++)
       for (j=0; j<i; j++)
         if (q[i] == q[j]) {
           GC_printf0(
                 "Apparently failed to mark form some function arguments.\n"
                 "Perhaps GC_push_regs was configured incorrectly?\n"
           );
           FAIL;
         }
   }
   
 #endif /* __STDC__ */  #endif /* __STDC__ */
   
 #ifdef THREADS  #ifdef THREADS
Line 1245  void run_one_test()
Line 1270  void run_one_test()
                 "GC_is_valid_displacement produced incorrect result\n");                  "GC_is_valid_displacement produced incorrect result\n");
         FAIL;          FAIL;
       }        }
   #     if defined(__STDC__) && !defined(MSWIN32) && !defined(MSWINCE)
           /* Harder to test under Windows without a gc.h declaration.  */
           {
             size_t i;
             extern void *GC_memalign();
   
             GC_malloc(17);
             for (i = sizeof(GC_word); i < 512; i *= 2) {
               GC_word result = (GC_word) GC_memalign(i, 17);
               if (result % i != 0 || result == 0 || *(int *)result != 0) FAIL;
             }
           }
   #     endif
 #     ifndef ALL_INTERIOR_POINTERS  #     ifndef ALL_INTERIOR_POINTERS
 #      if defined(RS6000) || defined(POWERPC)  #      if defined(RS6000) || defined(POWERPC)
         if (!TEST_FAIL_COUNT(1)) {          if (!TEST_FAIL_COUNT(1)) {
Line 1265  void run_one_test()
Line 1303  void run_one_test()
       GC_REGISTER_DISPLACEMENT(sizeof(struct fake_vtable *));        GC_REGISTER_DISPLACEMENT(sizeof(struct fake_vtable *));
       GC_init_gcj_malloc(0, (void *)fake_gcj_mark_proc);        GC_init_gcj_malloc(0, (void *)fake_gcj_mark_proc);
 #   endif  #   endif
       /* Make sure that fn arguments are visible to the collector.        */
   #   ifdef __STDC__
         uniq(
           GC_malloc(12), GC_malloc(12), GC_malloc(12),
           (GC_gcollect(),GC_malloc(12)),
           GC_malloc(12), GC_malloc(12), GC_malloc(12),
           (GC_gcollect(),GC_malloc(12)),
           GC_malloc(12), GC_malloc(12), GC_malloc(12),
           (GC_gcollect(),GC_malloc(12)),
           GC_malloc(12), GC_malloc(12), GC_malloc(12),
           (GC_gcollect(),GC_malloc(12)),
           GC_malloc(12), GC_malloc(12), GC_malloc(12),
           (GC_gcollect(),GC_malloc(12)),
           (void *)0);
   #   endif
     /* Repeated list reversal test. */      /* Repeated list reversal test. */
         reverse_test();          reverse_test();
 #   ifdef PRINTSTATS  #   ifdef PRINTSTATS
Line 1433  void SetMinimumStack(long minSize)
Line 1486  void SetMinimumStack(long minSize)
 #   endif  #   endif
     n_tests = 0;      n_tests = 0;
   
   #if defined(__APPLE__) && defined(__MACH__)
           GC_INIT();
   #endif
   
 #   if defined(DJGPP)  #   if defined(DJGPP)
         /* No good way to determine stack base from library; do it */          /* No good way to determine stack base from library; do it */
         /* manually on this platform.                              */          /* manually on this platform.                              */
Line 1446  void SetMinimumStack(long minSize)
Line 1503  void SetMinimumStack(long minSize)
 #   endif  #   endif
     GC_INIT();  /* Only needed if gc is dynamic library.        */      GC_INIT();  /* Only needed if gc is dynamic library.        */
     (void) GC_set_warn_proc(warn_proc);      (void) GC_set_warn_proc(warn_proc);
 #   if (defined(MPROTECT_VDB) || defined(PROC_VDB)) && !defined(MAKE_BACK_GRAPH)  #   if (defined(MPROTECT_VDB) || defined(PROC_VDB)) \
             && !defined(MAKE_BACK_GRAPH)
       GC_enable_incremental();        GC_enable_incremental();
       (void) GC_printf0("Switched to incremental mode\n");        (void) GC_printf0("Switched to incremental mode\n");
 #     if defined(MPROTECT_VDB)  #     if defined(MPROTECT_VDB)
         (void)GC_printf0("Emulating dirty bits with mprotect/signals\n");          (void)GC_printf0("Emulating dirty bits with mprotect/signals\n");
 #     else  #     else
   #       ifdef PROC_VDB
         (void)GC_printf0("Reading dirty bits from /proc\n");          (void)GC_printf0("Reading dirty bits from /proc\n");
   #       else
       (void)GC_printf0("Using DEFAULT_VDB dirty bit implementation\n");
   #       endif
 #      endif  #      endif
 #   endif  #   endif
     run_one_test();      run_one_test();
Line 1486  void SetMinimumStack(long minSize)
Line 1548  void SetMinimumStack(long minSize)
   
 #if defined(GC_WIN32_THREADS) && !defined(CYGWIN32)  #if defined(GC_WIN32_THREADS) && !defined(CYGWIN32)
   
 unsigned __stdcall thr_run_one_test(void *arg)  DWORD __stdcall thr_run_one_test(void *arg)
 {  {
   run_one_test();    run_one_test();
   return 0;    return 0;
Line 1518  LRESULT CALLBACK window_proc(HWND hwnd, UINT uMsg, WPA
Line 1580  LRESULT CALLBACK window_proc(HWND hwnd, UINT uMsg, WPA
   return ret;    return ret;
 }  }
   
 unsigned __stdcall thr_window(void *arg)  DWORD __stdcall thr_window(void *arg)
 {  {
   WNDCLASS win_class = {    WNDCLASS win_class = {
     CS_NOCLOSE,      CS_NOCLOSE,
Line 1580  int APIENTRY WinMain(HINSTANCE instance, HINSTANCE pre
Line 1642  int APIENTRY WinMain(HINSTANCE instance, HINSTANCE pre
 # ifdef MSWINCE  # ifdef MSWINCE
     HANDLE win_thr_h;      HANDLE win_thr_h;
 # endif  # endif
   unsigned thread_id;    DWORD thread_id;
 # if 0  # if 0
     GC_enable_incremental();      GC_enable_incremental();
 # endif  # endif
     GC_init();
   InitializeCriticalSection(&incr_cs);    InitializeCriticalSection(&incr_cs);
   (void) GC_set_warn_proc(warn_proc);    (void) GC_set_warn_proc(warn_proc);
 # ifdef MSWINCE  # ifdef MSWINCE
Line 1731  main()
Line 1794  main()
           (void)GC_printf0("pthread_default_stacksize_np failed.\n");            (void)GC_printf0("pthread_default_stacksize_np failed.\n");
         }          }
 #   endif       /* GC_HPUX_THREADS */  #   endif       /* GC_HPUX_THREADS */
   #       if defined(__APPLE__) && defined(__MACH__)
                   GC_INIT();
   #       endif
   
     pthread_attr_init(&attr);      pthread_attr_init(&attr);
 #   if defined(GC_IRIX_THREADS) || defined(GC_FREEBSD_THREADS)  #   if defined(GC_IRIX_THREADS) || defined(GC_FREEBSD_THREADS) \
           || defined(GC_DARWIN_THREADS) || defined(GC_AIX_THREADS)
         pthread_attr_setstacksize(&attr, 1000000);          pthread_attr_setstacksize(&attr, 1000000);
 #   endif  #   endif
     n_tests = 0;      n_tests = 0;
 #   if  defined(MPROTECT_VDB) && !defined(PARALLEL_MARK) &&!defined(REDIRECT_MALLOC) && !defined(MAKE_BACK_GRAPH)  #   if (defined(MPROTECT_VDB)) \
               && !defined(PARALLEL_MARK) &&!defined(REDIRECT_MALLOC) \
               && !defined(MAKE_BACK_GRAPH)
         GC_enable_incremental();          GC_enable_incremental();
         (void) GC_printf0("Switched to incremental mode\n");          (void) GC_printf0("Switched to incremental mode\n");
         (void) GC_printf0("Emulating dirty bits with mprotect/signals\n");  #     if defined(MPROTECT_VDB)
           (void)GC_printf0("Emulating dirty bits with mprotect/signals\n");
   #     else
   #       ifdef PROC_VDB
               (void)GC_printf0("Reading dirty bits from /proc\n");
   #       else
               (void)GC_printf0("Using DEFAULT_VDB dirty bit implementation\n");
   #       endif
   #     endif
 #   endif  #   endif
     (void) GC_set_warn_proc(warn_proc);      (void) GC_set_warn_proc(warn_proc);
     if ((code = pthread_key_create(&fl_key, 0)) != 0) {      if ((code = pthread_key_create(&fl_key, 0)) != 0) {

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>