diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2014-07-09 12:06:08 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2014-07-09 12:06:08 +0000 |
commit | 96ed53c10fc84e7ed7f9329697fac0c378932cfa (patch) | |
tree | 3a2e6787e3ff6c2ea0b030510ada1878e7110b5a /winsup/cygwin/thread.cc | |
parent | 3dab1e488aae1787e1ada0bfbda2fb71bd449687 (diff) | |
download | newlib-96ed53c10fc84e7ed7f9329697fac0c378932cfa.zip newlib-96ed53c10fc84e7ed7f9329697fac0c378932cfa.tar.gz newlib-96ed53c10fc84e7ed7f9329697fac0c378932cfa.tar.bz2 |
* thread.cc (pthread::create): Use PTHREAD_DEFAULT_STACKSIZE stacksize
if attr.stacksize is 0.
(pthread_attr::pthread_attr): Initialize stacksize to 0 to align more
closely to Linux.
(pthread_attr_getstack): Fix incorrect stackaddr computation. Return
stackaddr just like pthread_attr_getstackaddr. Remove slightly off
comment.
(pthread_attr_getstackaddr): Remove slightly off comment.
(pthread_getattr_np): Return stackaddr and stacksize based on the full
allocated stackarea.
Diffstat (limited to 'winsup/cygwin/thread.cc')
-rw-r--r-- | winsup/cygwin/thread.cc | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc index e411301..0a167fa 100644 --- a/winsup/cygwin/thread.cc +++ b/winsup/cygwin/thread.cc @@ -473,9 +473,9 @@ pthread::create (void *(*func) (void *), pthread_attr *newattr, arg = threadarg; mutex.lock (); - win32_obj_id = CygwinCreateThread (thread_init_wrapper, this, - attr.stackaddr, attr.stacksize, - attr.guardsize, 0, &thread_id); + win32_obj_id = CygwinCreateThread (thread_init_wrapper, this, attr.stackaddr, + attr.stacksize ?: PTHREAD_DEFAULT_STACKSIZE, + attr.guardsize, 0, &thread_id); if (!win32_obj_id) { @@ -1083,8 +1083,8 @@ pthread::resume () pthread_attr::pthread_attr ():verifyable_object (PTHREAD_ATTR_MAGIC), joinable (PTHREAD_CREATE_JOINABLE), contentionscope (PTHREAD_SCOPE_PROCESS), -inheritsched (PTHREAD_INHERIT_SCHED), stackaddr (NULL), -stacksize (PTHREAD_DEFAULT_STACKSIZE), guardsize (PTHREAD_DEFAULT_GUARDSIZE) +inheritsched (PTHREAD_INHERIT_SCHED), stackaddr (NULL), stacksize (0), +guardsize (PTHREAD_DEFAULT_GUARDSIZE) { schedparam.sched_priority = 0; } @@ -2263,8 +2263,7 @@ pthread_attr_getstack (const pthread_attr_t *attr, void **addr, size_t *size) { if (!pthread_attr::is_good_object (attr)) return EINVAL; - /* uses lowest address of stack on all platforms */ - *addr = (void *)((ptrdiff_t)(*attr)->stackaddr - (*attr)->stacksize); + *addr = (*attr)->stackaddr; *size = (*attr)->stacksize; return 0; } @@ -2285,8 +2284,6 @@ pthread_attr_getstackaddr (const pthread_attr_t *attr, void **addr) { if (!pthread_attr::is_good_object (attr)) return EINVAL; - /* uses stack address, which is the higher address on platforms - where the stack grows downwards, such as x86 */ *addr = (*attr)->stackaddr; return 0; } @@ -2488,11 +2485,11 @@ pthread_getattr_np (pthread_t thread, pthread_attr_t *attr) tbi, sizeof_tbi, NULL); if (NT_SUCCESS (status)) { - PNT_TIB tib = tbi->TebBaseAddress; - (*attr)->stackaddr = tib->StackBase; + PTEB teb = (PTEB) tbi->TebBaseAddress; + (*attr)->stackaddr = teb->DeallocationStack ?: teb->Tib.StackLimit; /* stack grows downwards on x86 systems */ - (*attr)->stacksize = (uintptr_t) tib->StackBase - - (uintptr_t) tib->StackLimit; + (*attr)->stacksize = (uintptr_t) teb->Tib.StackBase + - (uintptr_t) (*attr)->stackaddr; } else { |