summaryrefslogtreecommitdiff
path: root/linuxthreads
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-02-24 04:57:56 +0000
committerUlrich Drepper <drepper@redhat.com>2002-02-24 04:57:56 +0000
commitb6a0a99693379a0ceb9146bf3c38eb313b977e4c (patch)
tree7a96d234a537b8fc0e67a812191df5b06c9db7b9 /linuxthreads
parent6370466d5af09a31feb376353bf0ac307774b1bf (diff)
downloadglibc-b6a0a99693379a0ceb9146bf3c38eb313b977e4c.tar.gz
Update.
* 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>.
Diffstat (limited to 'linuxthreads')
-rw-r--r--linuxthreads/ChangeLog8
-rw-r--r--linuxthreads/attr.c17
-rw-r--r--linuxthreads/manager.c28
-rw-r--r--linuxthreads/sysdeps/i386/i686/pt-machine.h7
-rw-r--r--linuxthreads/sysdeps/i386/pt-machine.h7
-rw-r--r--linuxthreads/sysdeps/i386/tls.h2
6 files changed, 61 insertions, 8 deletions
diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog
index 2fc0a623d1..961ddf118b 100644
--- a/linuxthreads/ChangeLog
+++ b/linuxthreads/ChangeLog
@@ -1,5 +1,13 @@
2002-02-23 Ulrich Drepper <drepper@redhat.com>
+ * 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>.
+
* descr.h (struct _pthread_descr_struct): Update p_header for TLS.
Add p_stackaddr element #if USE_TLS.
* internals.c: Include <tls.h>.
diff --git a/linuxthreads/attr.c b/linuxthreads/attr.c
index 4b3a8f4342..8b7e8ce81c 100644
--- a/linuxthreads/attr.c
+++ b/linuxthreads/attr.c
@@ -283,10 +283,19 @@ int pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
attr->__inheritsched = descr->p_inheritsched;
attr->__scope = PTHREAD_SCOPE_SYSTEM;
#ifdef _STACK_GROWS_DOWN
+# ifdef USE_TLS
+ attr->__stacksize = descr->p_stackaddr - (char *)descr->p_guardaddr
+ - descr->p_guardsize;
+# else
attr->__stacksize = (char *)(descr + 1) - (char *)descr->p_guardaddr
- descr->p_guardsize;
+# endif
#else
+# ifdef USE_TLS
+ attr->__stacksize = (char *)descr->p_guardaddr - descr->p_stackaddr;
+# else
attr->__stacksize = (char *)descr->p_guardaddr - (char *)descr;
+# endif
#endif
attr->__guardsize = descr->p_guardsize;
attr->__stackaddr_set = descr->p_userstack;
@@ -298,10 +307,14 @@ int pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
otherwise the range of the stack area cannot be computed. */
attr->__stacksize += attr->__guardsize;
#endif
-#ifndef _STACK_GROWS_UP
- attr->__stackaddr = (char *)(descr + 1);
+#ifdef USE_TLS
+ attr->__stackaddr = descr->p_stackaddr;
#else
+# ifndef _STACK_GROWS_UP
+ attr->__stackaddr = (char *)(descr + 1);
+# else
attr->__stackaddr = (char *)descr;
+# endif
#endif
return 0;
diff --git a/linuxthreads/manager.c b/linuxthreads/manager.c
index efbbf51b41..c846895d19 100644
--- a/linuxthreads/manager.c
+++ b/linuxthreads/manager.c
@@ -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--;
diff --git a/linuxthreads/sysdeps/i386/i686/pt-machine.h b/linuxthreads/sysdeps/i386/i686/pt-machine.h
index c7396024bb..b38d2b7ab8 100644
--- a/linuxthreads/sysdeps/i386/i686/pt-machine.h
+++ b/linuxthreads/sysdeps/i386/i686/pt-machine.h
@@ -1,6 +1,6 @@
/* Machine-dependent pthreads configuration and inline functions.
i686 version.
- Copyright (C) 1996, 1997, 1998, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1996-2001, 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Richard Henderson <rth@tamu.edu>.
@@ -19,6 +19,9 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#ifndef _PT_MACHINE_H
+#define _PT_MACHINE_H 1
+
#ifndef PT_EI
# define PT_EI extern inline
#endif
@@ -67,3 +70,5 @@ __compare_and_swap (long int *p, long int oldval, long int newval)
/* The P4 and above really want some help to prevent overheating. */
#define BUSY_WAIT_NOP __asm__ ("rep; nop")
+
+#endif /* pt-machine.h */
diff --git a/linuxthreads/sysdeps/i386/pt-machine.h b/linuxthreads/sysdeps/i386/pt-machine.h
index 3346bcc34d..c9aa6e7778 100644
--- a/linuxthreads/sysdeps/i386/pt-machine.h
+++ b/linuxthreads/sysdeps/i386/pt-machine.h
@@ -1,6 +1,6 @@
/* Machine-dependent pthreads configuration and inline functions.
i386 version.
- Copyright (C) 1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc.
+ Copyright (C) 1996-2001, 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Richard Henderson <rth@tamu.edu>.
@@ -19,6 +19,9 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#ifndef _PT_MACHINE_H
+#define _PT_MACHINE_H 1
+
#ifndef PT_EI
# define PT_EI extern inline
#endif
@@ -96,3 +99,5 @@ compare_and_swap_is_available (void)
Otherwise, it's a 486 or above and it has cmpxchg. */
return changed != 0;
}
+
+#endif /* pt-machine.h */
diff --git a/linuxthreads/sysdeps/i386/tls.h b/linuxthreads/sysdeps/i386/tls.h
index d1975b2017..c1bfd1bca8 100644
--- a/linuxthreads/sysdeps/i386/tls.h
+++ b/linuxthreads/sysdeps/i386/tls.h
@@ -22,6 +22,8 @@
#include <stddef.h>
+#include <pt-machine.h>
+
/* Type for the dtv. */
typedef union dtv
{