1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-30 22:43:12 +03:00
* attr.c (pthread_getattr_np): Don't take thread descriptor size
	into account if USE_TLS.
	* manager.c (pthread_handle_create): Free TLS data structures if call
	failed.  Pass correct stack to clone if USE_TLS.
	* sysdeps/i386/pt-machine.h: Handle multiple inclusion.
	* sysdeps/i386/i686/pt-machine.h: Likewise.
	* sysdeps/i386/tls.h: Unconditionally include <pt-machine.h>.
This commit is contained in:
Ulrich Drepper
2002-02-24 04:57:56 +00:00
parent 6370466d5a
commit b6a0a99693
6 changed files with 61 additions and 8 deletions

View File

@ -593,6 +593,9 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
new_thread = _dl_allocate_tls ();
if (new_thread == NULL)
return EAGAIN;
#else
/* Prevent warnings. */
new_thread = NULL;
#endif
/* First check whether we have to change the policy and if yes, whether
@ -605,7 +608,12 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
for (sseg = 2; ; sseg++)
{
if (sseg >= PTHREAD_THREADS_MAX)
return EAGAIN;
{
#ifdef USE_TLS
_dl_deallocate_tls (new_thread);
#endif
return EAGAIN;
}
if (__pthread_handles[sseg].h_descr != NULL)
continue;
if (pthread_allocate_stack(attr, thread_segment(sseg),
@ -741,15 +749,15 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
#ifdef NEED_SEPARATE_REGISTER_STACK
pid = __clone2(pthread_start_thread,
(void **)new_thread_bottom,
(char *)new_thread - new_thread_bottom,
(char *)stack_addr - new_thread_bottom,
CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
__pthread_sig_cancel, new_thread);
#elif _STACK_GROWS_UP
pid = __clone(pthread_start_thread, (void **) new_thread_bottom,
pid = __clone(pthread_start_thread, (void *) new_thread_bottom,
CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
__pthread_sig_cancel, new_thread);
#else
pid = __clone(pthread_start_thread, (void **) new_thread,
pid = __clone(pthread_start_thread, stack_addr,
CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
__pthread_sig_cancel, new_thread);
#endif /* !NEED_SEPARATE_REGISTER_STACK */
@ -766,13 +774,25 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
munmap((caddr_t)new_thread_bottom,
2 * stacksize + new_thread->p_guardsize);
#elif _STACK_GROWS_UP
# ifdef USE_TLS
size_t stacksize = guardaddr - stack_addr;
munmap(stack_addr, stacksize + guardsize);
# else
size_t stacksize = guardaddr - (char *)new_thread;
munmap(new_thread, stacksize + guardsize);
# endif
#else
# ifdef USE_TLS
size_t stacksize = stack_addr - new_thread_bottom;
# else
size_t stacksize = (char *)(new_thread+1) - new_thread_bottom;
# endif
munmap(new_thread_bottom - guardsize, guardsize + stacksize);
#endif
}
#ifdef USE_TLS
_dl_deallocate_tls (new_thread);
#endif
__pthread_handles[sseg].h_descr = NULL;
__pthread_handles[sseg].h_bottom = NULL;
__pthread_handles_num--;