diff options
Diffstat (limited to 'linuxthreads')
-rw-r--r-- | linuxthreads/ChangeLog | 6 | ||||
-rw-r--r-- | linuxthreads/manager.c | 5 | ||||
-rw-r--r-- | linuxthreads/pthread.c | 15 |
3 files changed, 26 insertions, 0 deletions
diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog index a7e0b46daf..3102111eff 100644 --- a/linuxthreads/ChangeLog +++ b/linuxthreads/ChangeLog @@ -1,3 +1,9 @@ +2003-10-06 Carlos O'Donell <carlos@baldric.uwo.ca> + + * pthread.c (__pthread_self_stack): _STACK_GROWS_UP case added. + (__pthread_find_self): Likewise. + * manager.c (thread_segment): _STACK_GROWS_UP case added. + 2003-10-10 Carlos O'Donell <carlos@baldric.uwo.ca> * linuxthreads/sysdeps/unix/sysv/linux/hppa/malloc-machine.h: New file. diff --git a/linuxthreads/manager.c b/linuxthreads/manager.c index f8647b47ca..462ce4a0d4 100644 --- a/linuxthreads/manager.c +++ b/linuxthreads/manager.c @@ -70,8 +70,13 @@ static pthread_descr manager_thread; #else static inline pthread_descr thread_segment(int seg) { +# ifdef _STACK_GROWS_UP + return (pthread_descr)(THREAD_STACK_START_ADDRESS + (seg - 1) * STACK_SIZE) + + 1; +# else return (pthread_descr)(THREAD_STACK_START_ADDRESS - (seg - 1) * STACK_SIZE) - 1; +# endif } #endif diff --git a/linuxthreads/pthread.c b/linuxthreads/pthread.c index b3953542e0..11d2ef7dd1 100644 --- a/linuxthreads/pthread.c +++ b/linuxthreads/pthread.c @@ -893,7 +893,11 @@ pthread_descr __pthread_find_self(void) /* __pthread_handles[0] is the initial thread, __pthread_handles[1] is the manager threads handled specially in thread_self(), so start at 2 */ h = __pthread_handles + 2; +# ifdef _STACK_GROWS_UP + while (! (sp >= (char *) h->h_descr && sp < h->h_descr->p_guardaddr)) h++; +# else while (! (sp <= (char *) h->h_descr && sp >= h->h_bottom)) h++; +# endif return h->h_descr; } @@ -908,12 +912,23 @@ pthread_descr __pthread_self_stack(void) return manager_thread; h = __pthread_handles + 2; # ifdef USE_TLS +# ifdef _STACK_GROWS_UP + while (h->h_descr == NULL + || ! (sp >= h->h_descr->p_stackaddr && sp < h->h_descr->p_guardaddr)) + h++; +# else while (h->h_descr == NULL || ! (sp <= (char *) h->h_descr->p_stackaddr && sp >= h->h_bottom)) h++; +# endif # else +# ifdef _STACK_GROWS_UP + while (! (sp >= (char *) h->h_descr && sp < h->h_descr->p_guardaddr)) + h++; +# else while (! (sp <= (char *) h->h_descr && sp >= h->h_bottom)) h++; +# endif # endif return h->h_descr; } |