+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.
/* 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()
}
# if defined(GC_PTHREADS)
- void fork_a_thread()
+ void fork_a_thread(void)
{
pthread_t t;
int code;
}
# elif defined(GC_WIN32_THREADS)
- void fork_a_thread()
+ void fork_a_thread(void)
{
DWORD thread_id;
HANDLE h;
}
}
-# else
-
-# define fork_a_thread()
-
# endif
-#else
-
-# define fork_a_thread()
-
#endif
/* Try to force a to be strangely aligned */
* 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;
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. */
# ifndef THREADS
a = 0;
# endif
- b = c = 0;
+ *(volatile void **)&b = 0;
+ *(volatile void **)&c = 0;
}
#undef a
#if defined(GC_PTHREADS)
pthread_key_t fl_key;
-void * alloc8bytes()
+void * alloc8bytes(void)
{
# if defined(SMALL_CONFIG) || defined(GC_DEBUG)
collectable_count++;
# define TREE_HEIGHT 16
# endif
# endif
-void tree_test()
+void tree_test(void)
{
tn * root;
int i;
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--) {
};
/* A very simple test of explicitly typed allocation */
-void typed_test()
+void typed_test(void)
{
GC_word * old, * new;
GC_word bm3 = 0x3;
new = (GC_word *)(old[1]);
}
GC_gcollect();
- GC_noop(x);
+ GC_noop1((word)x);
}
int fail_count = 0;
# define TEST_FAIL_COUNT(n) (fail_count >= (n))
#endif
-void run_one_test()
+void run_one_test(void)
{
# ifndef DBG_HDRS_ALL
char *x;
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 */
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);
#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);
#ifdef PCR
-test()
+int test(void)
{
PCR_Th_T * th1;
PCR_Th_T * th2;