This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Andreas Schwab <schwab@suse.de> writes: > +static pthread_descr thread_self_stack(void) > +{ > + char *sp = CURRENT_STACK_FRAME; > + pthread_handle h; > + > + 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 > + { > + h = __pthread_handles + 2; > + while (! (sp <= (char *) h->h_descr && sp >= h->h_bottom)) > + h++; > + return h->h_descr; > + } > +} > + > #endif This is overkill. You use this function to check whether the thread is the manager via the stack pointer. But the function contains a lot of tests and returns useful values for all other cases as well. All the tests except the first else are unnecessary. Instead you should introduce a function which returns a boolean value saying whether the thread is the manager or not. This can be implemented via the stack pointer, one could also simply call getpid() and compare this to the PID of the manager. -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |