зеркало из https://github.com/github/ruby.git
* 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
This commit is contained in:
Родитель
eb35bb0b35
Коммит
948f01a865
|
@ -1,3 +1,8 @@
|
|||
Mon Jul 4 07:14:12 2011 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* thread_pthread.c (get_stack): the return address of get_stack
|
||||
must be the highest address of the current thread's stack.
|
||||
|
||||
Mon Jul 4 06:37:22 2011 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* include/ruby/intern.h, thread_pthread.c (rb_reserved_fd_p,
|
||||
|
|
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче