summaryrefslogtreecommitdiff
path: root/thread_pthread.c
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-02 21:18:16 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-02 21:18:16 +0000
commit70dd402cd8357097d1090972585fe23bc940ae41 (patch)
tree507a60c124501cf751dc9f87bd3f1ab38197ca2b /thread_pthread.c
parent560c1aeba991f0c0276f786e242d7bceed5fdf83 (diff)
* thread_pthread.c (get_stack): pthread_attr_getstack() doesn't
return stack start addres, but stack base address. Thus, we need to add stack size for getting stack start address. And, we don't have to decrease guard size twice. * thread_pthread.c (thread_start_func_1): don't use inaccurate stack start guess if native_thread_init_stack() can be used. [Bug #1813] [ruby-core:24540] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_pthread.c')
-rw-r--r--thread_pthread.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/thread_pthread.c b/thread_pthread.c
index 06e2b1d237..79b98a98c5 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -463,19 +463,16 @@ get_stack(void **addr, size_t *size)
pthread_attr_t attr;
size_t guard = 0;
-# ifdef HAVE_PTHREAD_GETATTR_NP
+# ifdef HAVE_PTHREAD_GETATTR_NP /* Linux */
+ STACK_GROW_DIR_DETECTION;
CHECK_ERR(pthread_getattr_np(pthread_self(), &attr));
-# ifdef HAVE_PTHREAD_ATTR_GETSTACK /* Linux */
+# ifdef HAVE_PTHREAD_ATTR_GETSTACK
CHECK_ERR(pthread_attr_getstack(&attr, addr, size));
+ STACK_DIR_UPPER((void)0, (void)(*addr = (char *)*addr + *size));
# else
CHECK_ERR(pthread_attr_getstackaddr(&attr, addr));
CHECK_ERR(pthread_attr_getstacksize(&attr, size));
# endif
- if (pthread_attr_getguardsize(&attr, &guard) == 0) {
- STACK_GROW_DIR_DETECTION;
- STACK_DIR_UPPER((void)0, (void)(*addr = (char *)*addr + guard));
- *size -= guard;
- }
# elif defined HAVE_PTHREAD_ATTR_GET_NP /* FreeBSD, DragonFly BSD, NetBSD */
CHECK_ERR(pthread_attr_init(&attr));
CHECK_ERR(pthread_attr_get_np(pthread_self(), &attr));
@@ -603,6 +600,10 @@ native_thread_init_stack(rb_thread_t *th)
return 0;
}
+#ifndef __CYGWIN__
+#define USE_NATIVE_THREAD_INIT 1
+#endif
+
static void *
thread_start_func_1(void *th_ptr)
{
@@ -613,12 +614,16 @@ thread_start_func_1(void *th_ptr)
rb_thread_t *th = th_ptr;
VALUE stack_start;
-#ifndef __CYGWIN__
+#if defined USE_NATIVE_THREAD_INIT
native_thread_init_stack(th);
#endif
native_thread_init(th);
/* run */
+#if defined USE_NATIVE_THREAD_INIT
+ thread_start_func_2(th, th->machine_stack_start, rb_ia64_bsp());
+#else
thread_start_func_2(th, &stack_start, rb_ia64_bsp());
+#endif
}
#if USE_THREAD_CACHE
if (1) {