In _pthread_key_create() ensure that libthr is initialized. This

fixes a NULL-dereference of curthread when libstdc+ initializes
the exception handling globals on archs we can't use GNU TLS due
to lack of support in binutils 2.15 (i.e. arm and sparc64), yet,
thus making threaded C++ programs compiled with GCC 4.2.1 work
again on these archs.

Reviewed by:	davidxu
MFC after:	3 days
This commit is contained in:
Marius Strobl 2007-11-06 21:50:43 +00:00
parent ee8f97394e
commit 9a2706abcc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=173394

View File

@ -51,9 +51,13 @@ __weak_reference(_pthread_setspecific, pthread_setspecific);
int
_pthread_key_create(pthread_key_t *key, void (*destructor) (void *))
{
struct pthread *curthread = _get_curthread();
struct pthread *curthread;
int i;
_thr_check_init();
curthread = _get_curthread();
/* Lock the key table: */
THR_LOCK_ACQUIRE(curthread, &_keytable_lock);
for (i = 0; i < PTHREAD_KEYS_MAX; i++) {