summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2012-08-01 23:36:16 +0400
committerIvan Maidanski <ivmai@mail.ru>2012-08-01 23:36:16 +0400
commit57b94a38df8026868010ec2ea0f47cd1f94f0c60 (patch)
tree892427991e3845d03aa40309a1bbbc20e54a7af6 /tools
parent20616f1fce6d901e9bd79b797fce63f807651000 (diff)
downloadbdwgc-57b94a38df8026868010ec2ea0f47cd1f94f0c60.tar.gz
Fix all address-of-dummy operations by using GC_approx_sp() instead
(previous commit 'd6acbda' has not solved this problem) * alloc.c (min_bytes_allocd, GC_stopped_mark): Use GC_approx_sp() instead of "&dummy"; remove 'dummy' local variable. * dyn_load.c (GC_cond_add_roots): Likewise. * misc.c (GC_init): Likewise. * os_dep.c (GC_get_stack_base, GC_get_main_stack_base): Likewise. * pthread_stop_world.c (GC_suspend_handler_inner, nacl_pre_syscall_hook, __nacl_suspend_thread_if_needed): Likewise. * pthread_support.c (GC_thr_init): Likewise. * ptr_chck.c (GC_on_stack): Likewise. * win32_threads.c (GC_push_stack_for): Likewise. * misc.c (GC_clear_stack_inner): Store address of volatile 'dummy' local array (i.e. 'sp' value) to its first element (and use it in the comparison of addresses) to prevent any harmful optimizations as C officially disallows comparisons of pointers to different objects (e.g., some Mac OS X clang releases might turn a conditional expression that uses 'dummy' address into a constant); update comment. * misc.c (GC_call_with_stack_base): Use "&base" instead of "&dummy" (it is safe to use address of base here); remove dummy variable. * os_dep.c (currently_updating): Change type from "word" to "int*". * os_dep.c (async_set_pht_entry_from_index): Remove volatile and casts for 'update_dummy' local variable. * tools/setjmp_t.c (main): Define volatile 'sp' local variable, store its address to it and use it instead of "&dummy"; remove 'dummy' local variable.
Diffstat (limited to 'tools')
-rw-r--r--tools/setjmp_t.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/tools/setjmp_t.c b/tools/setjmp_t.c
index 801e6a58..1d9a1ad0 100644
--- a/tools/setjmp_t.c
+++ b/tools/setjmp_t.c
@@ -69,22 +69,23 @@ int * nested_sp(void)
int main(void)
{
- volatile int dummy;
+ volatile word sp;
long ps = GETPAGESIZE();
jmp_buf b;
register int x = (int)strlen("a"); /* 1, slightly disguised */
static int y = 0;
+ sp = (word)(&sp);
printf("This appears to be a %s running %s\n", MACH_TYPE, OS_TYPE);
- if ((word)nested_sp() < (word)(&dummy)) {
+ if ((word)nested_sp() < sp) {
printf("Stack appears to grow down, which is the default.\n");
printf("A good guess for STACKBOTTOM on this machine is 0x%lx.\n",
- ((unsigned long)(word)(&dummy) + ps) & ~(ps-1));
+ ((unsigned long)sp + ps) & ~(ps-1));
} else {
printf("Stack appears to grow up.\n");
printf("Define STACK_GROWS_UP in gc_private.h\n");
printf("A good guess for STACKBOTTOM on this machine is 0x%lx.\n",
- ((unsigned long)(word)(&dummy) + ps) & ~(ps-1));
+ ((unsigned long)sp + ps) & ~(ps-1));
}
printf("Note that this may vary between machines of ostensibly\n");
printf("the same architecture (e.g. Sun 3/50s and 3/80s).\n");