This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

Re: [Patch] Tweak gthr-posix.h for pthread_create() Interceptors


On Thu, Oct 28, 2004 at 11:55:11AM -0700, Boehm, Hans wrote:
> Ranjit -
> 
> Thanks for pursuing this.  I'd obviously really like to see this fixed.
> And I haven't been able to come up with a better solution.
> 
> I'm mildly concerned that pthread_once would have a weakly-defined
> stub in glibc which would do the easy thing for a single-threaded
> world.  This would allow thread-safe libraries using pthread_once
> to run in a single-threaded executable.
> 
> Your testing suggests that this isn't currently the case.  But I
> wonder whether it might become true in the future.
> 
> Can some glibc experts comment?  Does it make sense to test
> pthread_cond_wait instead, since that probably can't be usefully stubbed
> in a single-threaded world, and is much less likely to be intercepted?

Current GLIBC libc.so has following pthread stubs:

pthread_attr_destroy
pthread_attr_getdetachstate
pthread_attr_getinheritsched
pthread_attr_getschedparam
pthread_attr_getschedpolicy
pthread_attr_getscope
pthread_attr_init
pthread_attr_setdetachstate
pthread_attr_setinheritsched
pthread_attr_setschedparam
pthread_attr_setschedpolicy
pthread_attr_setscope
pthread_cond_broadcast
pthread_cond_destroy
pthread_cond_init
pthread_cond_signal
pthread_cond_timedwait
pthread_cond_wait
pthread_condattr_destroy
pthread_condattr_init
pthread_equal
pthread_exit
pthread_getschedparam
pthread_mutex_destroy
pthread_mutex_init
pthread_mutex_lock
pthread_mutex_unlock
pthread_self
pthread_setcancelstate
pthread_setcanceltype
pthread_setschedparam

so pthread_cond_wait is not a good test, as for glibc
#pragma weak pthread_cond_wait
pthread_cond_wait != NULL
will be always true, no matter whether libpthread.so has been
loaded or not.
If you don't like testing for pthread_once, test say pthread_cancel.

	Jakub


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