summaryrefslogtreecommitdiff
path: root/darwin_stop_world.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2016-10-14 19:22:08 +0300
committerIvan Maidanski <ivmai@mail.ru>2016-10-14 19:22:08 +0300
commit81d04a6b60b511fb5d9016b2335d1e4c3447117f (patch)
treef5a5d506a3224815ba390a820ec972f9308ba4b0 /darwin_stop_world.c
parent5f4138eb7904107bc0b145547dfceb5997b6528a (diff)
downloadbdwgc-81d04a6b60b511fb5d9016b2335d1e4c3447117f.tar.gz
Eliminate more 'scope of variable can be reduced' cppcheck style warnings
* allchblk.c [MARK_BIT_PER_GRANULE] (setup_header): Move local variable declarations to the inner scope where the variables are actually used. * alloc.c [!SMALL_CONFIG] (GC_try_to_collect_inner, GC_finish_collection): Likewise. * alloc.c (GC_stopped_mark): Likewise. * backgraph.c [MAKE_BACK_GRAPH] (add_edge): Likewise. * darwin_stop_world.c [GC_DARWIN_THREADS] (GC_push_all_stacks, GC_stop_world, GC_thread_resume): Likewise. * dyn_load.c [USE_PROC_FOR_LIBRARIES] (sort_heap_sects): Likewise. * dyn_load.c [ALPHA && OSF1 || HPUX] (GC_register_dynamic_libraries): Likewise. * dyn_load.c [DARWIN] (GC_dyld_image_add, GC_dyld_image_remove): Likewise. * extra/AmigaOS.c (GC_amiga_free_all_mem, GC_amiga_allocwrapper_any): Likewise. * extra/msvc_dbg.c (GetDescriptionFromAddress): Likewise. * gcj_mlc.c [GC_GCJ_SUPPORT] (GC_core_gcj_malloc, GC_gcj_malloc_ignore_off_page): Likewise. * include/new_gc_alloc.h (single_client_gc_alloc_template::deallocate, single_client_gc_alloc_template::ptr_free_deallocate, single_client_traceable_alloc_template::deallocate, single_client_traceable_alloc_template::ptr_free_deallocate): Likewise. * malloc.c [THREADS] (GC_free_inner): Likewise. * mark_rts.c (GC_add_roots_inner): Likewise. * misc.c (GC_clear_stack): Likewise. * os_dep.c [GWW_VDB] (GC_gww_read_dirty): Likewise. * os_dep.c [MPROTECT_VDB] (GC_protect_heap): Likewise. * os_dep.c [PROC_VDB] (GC_read_dirty): Likewise. * os_dep.c [MPROTECT_VDB && DARWIN] (catch_exception_raise): Likewise. * pthread_stop_world.c [GC_NETBSD_THREADS_WORKAROUND] (GC_start_world): Likewise. * pthread_support.c [!GC_NO_PTHREAD_SIGMASK] (pthread_sigmask): Likewise. * reclaim.c [!SMALL_CONFIG] (GC_reclaim_all): Likewise. * tests/test.c (run_one_test): Likewise. * tests/test.c [MACOS] (SetMinimumStack): Likewise. * thread_local_alloc.c [THREAD_LOCAL_ALLOC] (return_single_freelist): Likewise. * typd_mlc.c (GC_make_descriptor): Likewise. * win32_threads.c (GC_start_world, GC_CreateThread): Likewise. * win32_threads.c [!GC_PTHREADS_PARAMARK] (GC_start_mark_threads_inner): Likewise. * win32_threads.c [!MSWINCE && !CYGWIN32] (GC_beginthreadex): Likewise.
Diffstat (limited to 'darwin_stop_world.c')
-rw-r--r--darwin_stop_world.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/darwin_stop_world.c b/darwin_stop_world.c
index 921f6f57..b2f6c65a 100644
--- a/darwin_stop_world.c
+++ b/darwin_stop_world.c
@@ -323,8 +323,7 @@ STATIC ptr_t GC_stack_range_for(ptr_t *phi, thread_act_t thread, GC_thread p,
GC_INNER void GC_push_all_stacks(void)
{
- int i;
- ptr_t lo, hi, altstack_lo, altstack_hi;
+ ptr_t hi, altstack_lo, altstack_hi;
task_t my_task = current_task();
mach_port_t my_thread = mach_thread_self();
GC_bool found_me = FALSE;
@@ -336,6 +335,7 @@ GC_INNER void GC_push_all_stacks(void)
# ifndef DARWIN_DONT_PARSE_STACK
if (GC_query_task_threads) {
+ int i;
kern_return_t kern_result;
thread_act_array_t act_list = 0;
@@ -346,8 +346,9 @@ GC_INNER void GC_push_all_stacks(void)
for (i = 0; i < (int)listcount; i++) {
thread_act_t thread = act_list[i];
- lo = GC_stack_range_for(&hi, thread, NULL, FALSE, my_thread,
- &altstack_lo, &altstack_hi);
+ ptr_t lo = GC_stack_range_for(&hi, thread, NULL, FALSE, my_thread,
+ &altstack_lo, &altstack_hi);
+
if (lo) {
GC_ASSERT((word)lo <= (word)hi);
total_size += hi - lo;
@@ -368,13 +369,19 @@ GC_INNER void GC_push_all_stacks(void)
} else
# endif /* !DARWIN_DONT_PARSE_STACK */
/* else */ {
+ int i;
+
for (i = 0; i < (int)listcount; i++) {
GC_thread p;
+
for (p = GC_threads[i]; p != NULL; p = p->next)
if ((p->flags & FINISHED) == 0) {
thread_act_t thread = (thread_act_t)p->stop_info.mach_thread;
- lo = GC_stack_range_for(&hi, thread, p, (GC_bool)p->thread_blocked,
- my_thread, &altstack_lo, &altstack_hi);
+ ptr_t lo = GC_stack_range_for(&hi, thread, p,
+ (GC_bool)p->thread_blocked,
+ my_thread, &altstack_lo,
+ &altstack_hi);
+
if (lo) {
GC_ASSERT((word)lo <= (word)hi);
total_size += hi - lo;
@@ -533,7 +540,6 @@ STATIC GC_bool GC_suspend_thread_list(thread_act_array_t act_list, int count,
/* Caller holds allocation lock. */
GC_INNER void GC_stop_world(void)
{
- unsigned i;
task_t my_task = current_task();
mach_port_t my_thread = mach_thread_self();
kern_return_t kern_result;
@@ -556,6 +562,7 @@ GC_INNER void GC_stop_world(void)
if (GC_query_task_threads) {
# ifndef GC_NO_THREADS_DISCOVERY
+ unsigned i;
GC_bool changed;
thread_act_array_t act_list, prev_list;
mach_msg_type_number_t listcount, prevcount;
@@ -603,6 +610,8 @@ GC_INNER void GC_stop_world(void)
# endif /* !GC_NO_THREADS_DISCOVERY */
} else {
+ unsigned i;
+
for (i = 0; i < THREAD_TABLE_SZ; i++) {
GC_thread p;
@@ -665,7 +674,6 @@ GC_INLINE void GC_thread_resume(thread_act_t thread)
GC_INNER void GC_start_world(void)
{
task_t my_task = current_task();
- int i;
# ifdef DEBUG_THREADS
GC_log_printf("World starting\n");
# endif
@@ -677,6 +685,7 @@ GC_INNER void GC_start_world(void)
if (GC_query_task_threads) {
# ifndef GC_NO_THREADS_DISCOVERY
+ int i;
int j = GC_mach_threads_count;
kern_return_t kern_result;
thread_act_array_t act_list;
@@ -724,6 +733,7 @@ GC_INNER void GC_start_world(void)
# endif /* !GC_NO_THREADS_DISCOVERY */
} else {
+ int i;
mach_port_t my_thread = mach_thread_self();
for (i = 0; i < THREAD_TABLE_SZ; i++) {