From: ivmai Date: Sat, 17 Oct 2009 20:12:19 +0000 (+0000) Subject: 2009-10-17 Ivan Maidanski X-Git-Tag: gc7_2alpha4~44 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3b5c352965d4da78e10fbe65890e5d4af583f17e;p=gc 2009-10-17 Ivan Maidanski * backgraph.c (SET_OH_BG_PTR): Place outermost parenthesis properly. * darwin_stop_world.c: Replace "if DEBUG_THREADS" with "ifdef DEBUG_THREADS". * pthread_stop_world.c: Ditto. * pthread_support.c: Ditto. * include/gc_inline.h: Guard with GC_INLINE_H. --- diff --git a/ChangeLog b/ChangeLog index 0a5f877c..74aceac0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2009-10-17 Ivan Maidanski + + * backgraph.c (SET_OH_BG_PTR): Place outermost parenthesis + properly. + * darwin_stop_world.c: Replace "if DEBUG_THREADS" with + "ifdef DEBUG_THREADS". + * pthread_stop_world.c: Ditto. + * pthread_support.c: Ditto. + * include/gc_inline.h: Guard with GC_INLINE_H. + 2009-10-17 Ivan Maidanski * alloc.c (GC_copyright): Define as const. diff --git a/backgraph.c b/backgraph.c index 40d6cff2..a4558697 100644 --- a/backgraph.c +++ b/backgraph.c @@ -167,7 +167,7 @@ static void pop_in_progress(ptr_t p) #define GET_OH_BG_PTR(p) \ (ptr_t)REVEAL_POINTER(((oh *)(p)) -> oh_bg_ptr) -#define SET_OH_BG_PTR(p,q) (((oh *)(p)) -> oh_bg_ptr) = HIDE_POINTER(q) +#define SET_OH_BG_PTR(p,q) (((oh *)(p)) -> oh_bg_ptr = HIDE_POINTER(q)) /* Execute s once for each predecessor q of p in the points-to graph. */ /* s should be a bracketed statement. We declare q. */ diff --git a/darwin_stop_world.c b/darwin_stop_world.c index edd707f2..b39ef5fe 100644 --- a/darwin_stop_world.c +++ b/darwin_stop_world.c @@ -224,7 +224,7 @@ void GC_push_all_stacks(void) hi = GC_stackbottom; else hi = p->stack_end; -# if DEBUG_THREADS +# ifdef DEBUG_THREADS GC_printf("Darwin: Stack for thread 0x%lx = [%lx,%lx)\n", (unsigned long) p -> id, (unsigned long) lo, (unsigned long) hi); @@ -399,7 +399,7 @@ void GC_push_all_stacks(void) # error FIXME for non-x86 || ppc || arm architectures # endif } -# if DEBUG_THREADS +# ifdef DEBUG_THREADS GC_printf("Darwin: Stack for thread 0x%lx = [%p,%p)\n", (unsigned long) thread, lo, hi); # endif @@ -440,7 +440,7 @@ STATIC int GC_suspend_thread_list(thread_act_array_t act_list, int count, for(i = 0; i < count; i++) { thread_act_t thread = act_list[i]; -# if DEBUG_THREADS +# ifdef DEBUG_THREADS GC_printf("Attempting to suspend thread %p\n", thread); # endif /* find the current thread in the old list */ @@ -478,7 +478,7 @@ STATIC int GC_suspend_thread_list(thread_act_array_t act_list, int count, } continue; } -# if DEBUG_THREADS +# ifdef DEBUG_THREADS GC_printf("Thread state for 0x%lx = %d\n", (unsigned long)thread, info.run_state); # endif @@ -489,7 +489,7 @@ STATIC int GC_suspend_thread_list(thread_act_array_t act_list, int count, if (info.suspend_count) continue; -# if DEBUG_THREADS +# ifdef DEBUG_THREADS GC_printf("Suspending 0x%lx\n", (unsigned long)thread); # endif /* Suspend the thread */ @@ -526,7 +526,7 @@ void GC_stop_world(void) thread_act_array_t act_list, prev_list; mach_msg_type_number_t listcount, prevcount; -# if DEBUG_THREADS +# ifdef DEBUG_THREADS GC_printf("Stopping the world from 0x%lx\n", (unsigned long)mach_thread_self()); # endif @@ -596,7 +596,7 @@ void GC_stop_world(void) if (GC_parallel) GC_release_mark_lock(); # endif -# if DEBUG_THREADS +# ifdef DEBUG_THREADS GC_printf("World stopped from 0x%lx\n", (unsigned long)my_thread); # endif @@ -617,7 +617,7 @@ void GC_start_world(void) struct thread_basic_info info; mach_msg_type_number_t outCount = THREAD_INFO_MAX; -# if DEBUG_THREADS +# ifdef DEBUG_THREADS GC_printf("World starting\n"); # endif @@ -637,7 +637,7 @@ void GC_start_world(void) for(j = 0; j < GC_mach_threads_count; j++) { if (thread == GC_mach_threads[j].thread) { if (GC_mach_threads[j].already_suspended) { -# if DEBUG_THREADS +# ifdef DEBUG_THREADS GC_printf("Not resuming already suspended thread %p\n", thread); # endif continue; @@ -646,7 +646,7 @@ void GC_start_world(void) (thread_info_t)&info, &outCount); if(kern_result != KERN_SUCCESS) ABORT("thread_info failed"); -# if DEBUG_THREADS +# ifdef DEBUG_THREADS GC_printf("Thread state for 0x%lx = %d\n", (unsigned long)thread, info.run_state); GC_printf("Resuming 0x%lx\n", (unsigned long)thread); @@ -664,7 +664,7 @@ void GC_start_world(void) sizeof(thread_t) * listcount); mach_port_deallocate(my_task, my_thread); -# if DEBUG_THREADS +# ifdef DEBUG_THREADS GC_printf("World started\n"); # endif } diff --git a/include/gc_inline.h b/include/gc_inline.h index 2eb9472b..4b8e3b5c 100644 --- a/include/gc_inline.h +++ b/include/gc_inline.h @@ -13,6 +13,9 @@ * modified is included with the above copyright notice. */ +#ifndef GC_INLINE_H +#define GC_INLINE_H + /* WARNING: */ /* Note that for these routines, it is the clients responsibility to */ /* add the extra byte at the end to deal with one-past-the-end pointers.*/ @@ -120,7 +123,6 @@ (void)0 /* no initialization */); \ } - /* And once more for two word initialized objects: */ # define GC_CONS(result, first, second, tiny_fl) \ { \ @@ -130,3 +132,5 @@ *(void **)result = (void *)(first)); \ ((void **)(result))[1] = (void *)(second); \ } + +#endif /* !GC_INLINE_H */ diff --git a/pthread_stop_world.c b/pthread_stop_world.c index 424e90fa..fdf2157b 100644 --- a/pthread_stop_world.c +++ b/pthread_stop_world.c @@ -26,7 +26,7 @@ #include #include "atomic_ops.h" -#if DEBUG_THREADS +#ifdef DEBUG_THREADS #ifndef NSIG # if defined(MAXSIG) @@ -54,7 +54,7 @@ void GC_print_sig_mask(void) GC_printf("\n"); } -#endif +#endif /* DEBUG_THREADS */ /* Remove the signals that we want to allow in thread stopping */ /* handler from a set. */ @@ -184,7 +184,7 @@ STATIC void GC_suspend_handler_inner(ptr_t sig_arg, void *context) /* out of it. In fact, it looks to me like an async-signal-safe */ /* cancellation point is inherently a problem, unless there is */ /* some way to disable cancellation in the handler. */ -# if DEBUG_THREADS +# ifdef DEBUG_THREADS GC_printf("Suspending 0x%x\n", (unsigned)my_thread); # endif @@ -238,7 +238,7 @@ STATIC void GC_suspend_handler_inner(ptr_t sig_arg, void *context) /* Simply dropping the sigsuspend call should be safe, but is unlikely */ /* to be efficient. */ -# if DEBUG_THREADS +# ifdef DEBUG_THREADS GC_printf("Continuing 0x%x\n", (unsigned)my_thread); # endif RESTORE_CANCEL(cancel_state); @@ -260,7 +260,7 @@ STATIC void GC_restart_handler(int sig) ** will thus not interrupt the sigsuspend() above. */ -# if DEBUG_THREADS +# ifdef DEBUG_THREADS GC_printf("In GC_restart_handler for 0x%x\n", (unsigned)pthread_self()); # endif } @@ -286,8 +286,8 @@ void GC_push_all_stacks(void) pthread_t me = pthread_self(); if (!GC_thr_initialized) GC_thr_init(); -# if DEBUG_THREADS - GC_printf("Pushing stacks from thread 0x%x\n", (unsigned) me); +# ifdef DEBUG_THREADS + GC_printf("Pushing stacks from thread 0x%x\n", (unsigned) me); # endif for (i = 0; i < THREAD_TABLE_SZ; i++) { for (p = GC_threads[i]; p != 0; p = p -> next) { @@ -314,14 +314,14 @@ void GC_push_all_stacks(void) hi = GC_stackbottom; IF_IA64(bs_lo = BACKING_STORE_BASE;) } -# if DEBUG_THREADS - GC_printf("Stack for thread 0x%x = [%p,%p)\n", - (unsigned)(p -> id), lo, hi); +# ifdef DEBUG_THREADS + GC_printf("Stack for thread 0x%x = [%p,%p)\n", + (unsigned)(p -> id), lo, hi); # endif if (0 == lo) ABORT("GC_push_all_stacks: sp not set!\n"); GC_push_all_stack_frames(lo, hi, p -> activation_frame); # ifdef IA64 -# if DEBUG_THREADS +# ifdef DEBUG_THREADS GC_printf("Reg stack for thread 0x%x = [%p,%p)\n", (unsigned)p -> id, bs_lo, bs_hi); # endif @@ -341,9 +341,9 @@ void GC_push_all_stacks(void) /* There seems to be a very rare thread stopping problem. To help us */ /* debug that, we save the ids of the stopping thread. */ -#if DEBUG_THREADS -pthread_t GC_stopping_thread; -int GC_stopping_pid = 0; +#ifdef DEBUG_THREADS + pthread_t GC_stopping_thread; + int GC_stopping_pid = 0; #endif /* We hold the allocation lock. Suspend all threads that might */ @@ -357,7 +357,7 @@ STATIC int GC_suspend_all(void) int result; pthread_t my_thread = pthread_self(); -# if DEBUG_THREADS +# ifdef DEBUG_THREADS GC_stopping_thread = my_thread; GC_stopping_pid = getpid(); # endif @@ -368,7 +368,7 @@ STATIC int GC_suspend_all(void) if (p -> stop_info.last_stop_count == GC_stop_count) continue; if (p -> thread_blocked) /* Will wait */ continue; n_live_threads++; -# if DEBUG_THREADS +# ifdef DEBUG_THREADS GC_printf("Sending suspend signal to 0x%x\n", (unsigned)(p -> id)); # endif @@ -397,7 +397,7 @@ void GC_stop_world(void) int code; GC_ASSERT(I_HOLD_LOCK()); -# if DEBUG_THREADS +# ifdef DEBUG_THREADS GC_printf("Stopping the world from 0x%x\n", (unsigned)pthread_self()); # endif @@ -460,7 +460,7 @@ void GC_stop_world(void) if (GC_parallel) GC_release_mark_lock(); # endif -# if DEBUG_THREADS +# ifdef DEBUG_THREADS GC_printf("World stopped from 0x%x\n", (unsigned)pthread_self()); GC_stopping_thread = 0; # endif @@ -479,7 +479,7 @@ void GC_start_world(void) int code; # endif -# if DEBUG_THREADS +# ifdef DEBUG_THREADS GC_printf("World starting\n"); # endif @@ -490,7 +490,7 @@ void GC_start_world(void) if (p -> flags & FINISHED) continue; if (p -> thread_blocked) continue; n_live_threads++; -# if DEBUG_THREADS +# ifdef DEBUG_THREADS GC_printf("Sending restart signal to 0x%x\n", (unsigned)(p -> id)); # endif @@ -518,8 +518,8 @@ void GC_start_world(void) ABORT("sem_wait() for restart handler failed"); } # endif -# if DEBUG_THREADS - GC_printf("World started\n"); +# ifdef DEBUG_THREADS + GC_printf("World started\n"); # endif } diff --git a/pthread_support.c b/pthread_support.c index fc9aae68..12fb106f 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -43,7 +43,7 @@ /*#define DEBUG_THREADS 1*/ -# include "private/pthread_support.h" +#include "private/pthread_support.h" # if defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS) @@ -310,7 +310,7 @@ STATIC void * GC_mark_thread(void * id) my_mark_no = GC_mark_no; } # ifdef DEBUG_THREADS - GC_printf("Starting mark helper for mark number %lu\n", + GC_printf("Starting mark helper for mark number %lu\n", (unsigned long)my_mark_no); # endif GC_help_marker(my_mark_no); @@ -761,7 +761,7 @@ STATIC int GC_get_nprocs(void) numCpus = pm_sysinfo.idle_vp_count; # ifdef DEBUG_THREADS - GC_printf("Number of active CPUs in this system: %d\n", numCpus); + GC_printf("Number of active CPUs in this system: %d\n", numCpus); # endif return(numCpus); } @@ -1195,7 +1195,7 @@ GC_API int GC_CALL GC_register_my_thread(const struct GC_stack_base *sb) } STATIC void * GC_CALLBACK GC_inner_start_routine(struct GC_stack_base *sb, - void * arg) + void * arg) { struct start_info * si = arg; void * result; @@ -1226,7 +1226,7 @@ STATIC void * GC_CALLBACK GC_inner_start_routine(struct GC_stack_base *sb, /* OK to deallocate. */ pthread_cleanup_push(GC_thread_exit_proc, 0); result = (*start)(start_arg); -# if DEBUG_THREADS +# ifdef DEBUG_THREADS GC_printf("Finishing thread 0x%x\n", (unsigned)pthread_self()); # endif me -> status = result;