diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-03 22:16:02 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-03 22:16:02 +0000 |
commit | 948f01a865a0dec8e7edf3e71eb72f055ea3ebba (patch) | |
tree | 25e5808b5092107b504e3c6209c07d9f7a305aa6 /thread_pthread.c | |
parent | eb35bb0b351f55459fdfce7198e8756e37141dff (diff) | |
download | ruby-948f01a865a0dec8e7edf3e71eb72f055ea3ebba.tar.gz |
* thread_pthread.c (get_stack): the return address of get_stack
must be the highest address of the current thread's stack.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_pthread.c')
-rw-r--r-- | thread_pthread.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/thread_pthread.c b/thread_pthread.c index bde5d1cc77..af1ddca78c 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -453,6 +453,9 @@ static rb_thread_t *register_cached_thread_and_wait(void); #endif #ifdef STACKADDR_AVAILABLE +/* + * Get the highest address and size of current thread's stack + */ static int get_stack(void **addr, size_t *size) { @@ -478,6 +481,7 @@ get_stack(void **addr, size_t *size) CHECK_ERR(pthread_attr_get_np(pthread_self(), &attr)); CHECK_ERR(pthread_attr_getstackaddr(&attr, addr)); CHECK_ERR(pthread_attr_getstacksize(&attr, size)); + *addr = (char *)*addr + *size; # else /* MacOS X */ pthread_t th = pthread_self(); *addr = pthread_get_stackaddr_np(th); @@ -489,14 +493,14 @@ get_stack(void **addr, size_t *size) pthread_attr_destroy(&attr); #elif defined HAVE_THR_STKSEGMENT || defined HAVE_PTHREAD_STACKSEG_NP stack_t stk; -# if defined HAVE_THR_STKSEGMENT +# if defined HAVE_THR_STKSEGMENT /* Solaris */ CHECK_ERR(thr_stksegment(&stk)); -# else +# else /* OpenBSD */ CHECK_ERR(pthread_stackseg_np(pthread_self(), &stk)); # endif *addr = stk.ss_sp; *size = stk.ss_size; -#elif defined HAVE_PTHREAD_GETTHRDS_NP +#elif defined HAVE_PTHREAD_GETTHRDS_NP /* AIX */ pthread_t th = pthread_self(); struct __pthrdsinfo thinfo; char reg[256]; @@ -506,6 +510,8 @@ get_stack(void **addr, size_t *size) ®, ®siz)); *addr = thinfo.__pi_stackaddr; *size = thinfo.__pi_stacksize; +#else +#error STACKADDR_AVAILABLE is defined but not implemented. #endif return 0; #undef CHECK_ERR |