This is the mail archive of the mailing list for the libc-ports project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

thread_self() and STACK_GROWS_UP


Is thread_self() correct for the case where STACK_GROWS_UP is defined?
It does not work correctly for me.

static inline pthread_descr thread_self (void)
 return THREAD_SELF;
 if (sp >= __pthread_initial_thread_bos)
   return &__pthread_initial_thread;
 else if (sp >= __pthread_manager_thread_bos
          && sp < __pthread_manager_thread_tos)
   return &__pthread_manager_thread;
 else if (__pthread_nonstandard_stacks)
   return __pthread_find_self();
   return (pthread_descr)(((unsigned long)sp | (STACK_SIZE-1))+1) - 1;
   return (pthread_descr)((unsigned long)sp &~ (STACK_SIZE-1));

On our processor the address space looks like:

0x40000000 - top of user space
0x3f800000 - bottom of stack
- code, heap etc.
0x10000000 - bottom of userspace (approx.)

As such __pthread_initial_thread_bos has the lowest address of our
stacks so all stacks other than the malloced manager thread stack are
greater than __pthread_initial_thread_bos. Because of this
thread_self() will always return &__pthread_initial_thread or
&__pthread_manager_thread, which is obviously not correct.

The attached patch seems to work better for me but may not be correct.
Are there any ports other than hppa that have such an, er, interesting


Attachment: linuxthreads-descr-h.patch
Description: Binary data

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]