ruby-changes:30637
From: nobu <ko1@a...>
Date: Wed, 28 Aug 2013 17:20:21 +0900 (JST)
Subject: [ruby-changes:30637] nobu:r42716 (trunk): thread_pthread.c: get_stack on HP-UX
nobu 2013-08-28 17:20:13 +0900 (Wed, 28 Aug 2013) New Revision: 42716 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42716 Log: thread_pthread.c: get_stack on HP-UX * thread_pthread.c (hpux_attr_getstackaddr): basic support for the get_stack() under HP-UX. based on the patch by michal@r... (Michal Rokos) at [ruby-core:56645]. [Feature #8793] Modified files: trunk/ChangeLog trunk/thread_pthread.c Index: ChangeLog =================================================================== --- ChangeLog (revision 42715) +++ ChangeLog (revision 42716) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Aug 28 17:20:07 2013 Nobuyoshi Nakada <nobu@r...> + + * thread_pthread.c (hpux_attr_getstackaddr): basic support for the + get_stack() under HP-UX. based on the patch by michal@r... + (Michal Rokos) at [ruby-core:56645]. [Feature #8793] + Wed Aug 28 11:24:20 2013 Michal Rokos <michal@r...> * configure.in (sys/pstat.h): fix missing header check for Index: thread_pthread.c =================================================================== --- thread_pthread.c (revision 42715) +++ thread_pthread.c (revision 42716) @@ -492,6 +492,48 @@ size_t pthread_get_stacksize_np(pthread_ https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L492 #define STACKADDR_AVAILABLE 1 #elif defined HAVE_PTHREAD_GETTHRDS_NP #define STACKADDR_AVAILABLE 1 +#elif defined __ia64 && defined _HPUX_SOURCE +#define STACKADDR_AVAILABLE 1 + +/* + * Do not lower the thread's stack to PTHREAD_STACK_MIN, + * otherwise one would receive a 'sendsig: useracc failed.' + * and a coredump. + */ +#undef PTHREAD_STACK_MIN + +#define HAVE_PTHREAD_ATTR_GET_NP 1 +#undef HAVE_PTHREAD_ATTR_GETSTACK + +/* + * As the PTHREAD_STACK_MIN is undefined and + * noone touches the default stacksize, + * it is just fine to use the default. + */ +#define pthread_attr_get_np(thid, attr) 0 + +/* + * Using value of sp is very rough... To make it more real, + * addr would need to be aligned to vps_pagesize. + * The vps_pagesize is 'Default user page size (kBytes)' + * and could be retrieved by gettune(). + */ + +static int hpux_attr_getstackaddr(const pthread_attr_t *attr, void *addr) +{ + static uint64_t pagesize; + size_t size; + + if (!pagesize) { + if (gettune("vps_pagesize", &pagesize)) { + pagesize = 1024; + } + } + pthread_attr_getstacksize(attr, &size); + *addr = (void *)((size_t)((char *)_Asm_get_sp() - size) & ~(pagesize - 1)); + return 0; +} +#define pthread_attr_getstackaddr(attr, addr) hpux_attr_getstackaddr(attr, addr) #endif #ifndef MAINSTACKADDR_AVAILABLE -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/