e$B>.:j$G$9e(B
p26549e$B$G!"e(BFreeBSDe$B$G$Oe(Bgetrlimit()e$B$G$O%a%$%s%9%l%C%I$N%9%?%C%/%5%$%:$,<h$l$J$$LdBj$KBP$9$kBP=h$,F~$j$^$7$?$,!"e(B
thread_pthread.c
e$B$K$O!“CN$j$&$k8B$jA4e(BOSe$B$rLVMe$7$F$$$k%9%?%C%/>pJs<hF@4X?te(Bget_stack()e$B$,$”$k$N$G!“e(B
e$B$3$l$r;H$&$Y$-$8$c$J$$$+$H$$$&5?Ld$,$”$j$^$9!#e(B
e$B$J$K$+ITET9g$"$j$^$9$G$7$g$&$+!)e(B
ps
IRCe$B$GJ9$+$l$^$7$?$,e(BLinuxe$B$Ne(Bglibce$B$Oe(Bpthread_getattr_np()e$B$G%a%$%s%9%l%C%I$N%9%?%C%/$b@5$7$/$H$l$k$N$G!"e(B
get_stack()e$B$O0U?^DL$jF0$-$^$9!#e(BLinuxThrade$B$^$GAL$k$H<+?.$J$$$1$Ie(B
thread_pthread.c | 31 ++++++++++±-------------------
1 files changed, 11 insertions(+), 20 deletions(-)
diff --git a/thread_pthread.c b/thread_pthread.c
index d2d8b04…ca3ccff 100644
— a/thread_pthread.c
+++ b/thread_pthread.c
@@ -234,10 +234,10 @@ get_stack(void **addr, size_t *size)
CHECK_ERR(pthread_attr_getstacksize(&attr, size));
endif
CHECK_ERR(pthread_attr_getguardsize(&attr, &guard));
- *size -= guard;
ifndef HAVE_PTHREAD_GETATTR_NP
pthread_attr_destroy(&attr);
endif
- size -= guard;
#elif defined HAVE_PTHREAD_GET_STACKADDR_NP && defined
HAVE_PTHREAD_GET_STACKSIZE_NP
pthread_t th = pthread_self();
*addr = pthread_get_stackaddr_np(th);
@@ -296,14 +296,11 @@ ruby_init_stack(volatile VALUE *addr
}
#endif
{ - size_t size = 0, space = 0;
-#if defined(FreeBSD) || defined(__DragonFly) - pthread_attr_t attr;
- if (pthread_attr_init(&attr) == 0) {
-
if (pthread_attr_get_np(native_main_thread.id, &attr) == 0)
- pthread_attr_getstacksize(&attr, &size);
-
pthread_attr_destroy(&attr);
- }
- size_t size = 0;
- size_t space = 0;
+#ifdef STACKADDR_AVAILABLE - void* addr;
- get_stack(&addr, &size);
#elif defined(HAVE_GETRLIMIT)
struct rlimit rlim;
if (getrlimit(RLIMIT_STACK, &rlim) == 0) {
@@ -328,17 +325,11 @@ native_thread_init_stack(rb_thread_t *th)
th->machine_stack_maxsize = native_main_thread.stack_maxsize;
}
else {
-#ifdef HAVE_PTHREAD_GETATTR_NP
- pthread_attr_t attr;
- void *start;
- CHECK_ERR(pthread_getattr_np(curr, &attr));
-# if defined HAVE_PTHREAD_ATTR_GETSTACK - CHECK_ERR(pthread_attr_getstack(&attr, &start,
&th->machine_stack_maxsize));
-# elif defined HAVE_PTHREAD_ATTR_GETSTACKSIZE && defined
HAVE_PTHREAD_ATTR_GETSTACKADDR - CHECK_ERR(pthread_attr_getstackaddr(&attr, &start));
- CHECK_ERR(pthread_attr_getstacksize(&attr,
&th->machine_stack_maxsize));
-# endif - th->machine_stack_start = start;
+#ifdef STACKADDR_AVAILABLE
- if (get_stack(&start, &size) == 0) {
-
th->machine_stack_start = start;
-
th->machine_stack_maxsize = size;
- }
#else
rb_raise(rb_eNotImpError, “ruby engine can initialize only in the
main thread”);
#endif