summaryrefslogtreecommitdiff
path: root/darwin_stop_world.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2015-07-27 10:34:35 +0300
committerIvan Maidanski <ivmai@mail.ru>2015-07-27 10:34:35 +0300
commit11601b978a7abfdc7ecc3d0ee5e2fb5b3e0b73f2 (patch)
tree38ba4992faec4c9d8ca504fc898c88125bd4843f /darwin_stop_world.c
parent4ceae609d3e20822d7818cdef732348053227e1a (diff)
downloadbdwgc-11601b978a7abfdc7ecc3d0ee5e2fb5b3e0b73f2.tar.gz
Code refactoring of 'alt-stack registration support'
* darwin_stop_world.c (GC_stack_range_for, GC_push_all_stacks): Reformat code dealing with alt-stack. * pthread_stop_world.c (GC_push_all_stacks): Likewise. * darwin_stop_world.c (GC_stack_range_for): Cast pointers to word when compared. * GC_push_all_stacks (GC_push_all_stacks): Likewise. * include/gc.h (GC_register_altstack): Reformat comment; decorate with GC_CALL; comment out argument names; change type of altstack_size and stack_size to word. * include/private/pthread_support.h (altstack, altstack_size, stack, stack_size): Refine and reformat comment. * include/private/pthread_support.h (altstack_size, stack_size): Change type from int to word. * pthread_support.c (main_stack_size, main_altstack_size): Likewise. * pthread_support.c (main_pthread_self): Rename to main_pthread_id. * pthread_support.c (GC_register_altstack): Decorate with GC_API and GC_CALL. * win32_threads.c (GC_register_altstack): Likewise. * pthread_support.c (GC_register_altstack): Rename "thread" local variable to "me"; new local variable "self"; use DCL_LOCK_STATE; reformat code. * pthread_support.c (GC_thr_init): New local variable "self"; compare thread id using THREAD_EQUAL; reformat code. * win32_threads.c (GC_register_altstack): Add GC_ATTR_UNUSED to all arguments to avoid compiler warning (while the function is unimplemented); add TODO.
Diffstat (limited to 'darwin_stop_world.c')
-rw-r--r--darwin_stop_world.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/darwin_stop_world.c b/darwin_stop_world.c
index 23979035..21e7e1ce 100644
--- a/darwin_stop_world.c
+++ b/darwin_stop_world.c
@@ -303,16 +303,15 @@ STATIC ptr_t GC_stack_range_for(ptr_t *phi, thread_act_t thread, GC_thread p,
/* p is guaranteed to be non-NULL regardless of GC_query_task_threads. */
*phi = (p->flags & MAIN_THREAD) != 0 ? GC_stackbottom : p->stack_end;
# endif
-
- if (p->altstack && lo >= p->altstack && lo <= p->altstack + p->altstack_size) {
- *paltstack_lo = lo;
- *paltstack_hi = p->altstack + p->altstack_size;
- lo = (char*)p->stack;
- *phi = (char*)p->stack + p->stack_size;
- } else {
- *paltstack_lo = NULL;
- }
-
+ if (p->altstack != NULL && (word)p->altstack <= (word)lo
+ && (word)lo <= (word)p->altstack + p->altstack_size) {
+ *paltstack_lo = lo;
+ *paltstack_hi = p->altstack + p->altstack_size;
+ lo = p->stack;
+ *phi = p->stack + p->stack_size;
+ } else {
+ *paltstack_lo = NULL;
+ }
# ifdef DEBUG_THREADS
GC_log_printf("Darwin: Stack for thread %p = [%p,%p)\n",
(void *)thread, lo, *phi);
@@ -350,11 +349,11 @@ GC_INNER void GC_push_all_stacks(void)
if (lo) {
GC_ASSERT((word)lo <= (word)hi);
total_size += hi - lo;
- GC_push_all_stack(lo,hi);
+ GC_push_all_stack(lo, hi);
}
if (altstack_lo) {
total_size += altstack_hi - altstack_lo;
- GC_push_all_stack(altstack_lo,altstack_hi);
+ GC_push_all_stack(altstack_lo, altstack_hi);
}
nthreads++;
if (thread == my_thread)