Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2014-07-09 16:06:08 +0400
committerCorinna Vinschen <corinna@vinschen.de>2014-07-09 16:06:08 +0400
commit96ed53c10fc84e7ed7f9329697fac0c378932cfa (patch)
tree3a2e6787e3ff6c2ea0b030510ada1878e7110b5a
parent3dab1e488aae1787e1ada0bfbda2fb71bd449687 (diff)
* 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.
-rw-r--r--winsup/cygwin/ChangeLog13
-rw-r--r--winsup/cygwin/thread.cc23
2 files changed, 23 insertions, 13 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index d940017fe..d7266b16f 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,18 @@
2014-07-09 Corinna Vinschen <corinna@vinschen.de>
+ * 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.
+
+2014-07-09 Corinna Vinschen <corinna@vinschen.de>
+
* exceptions.cc (exception::myfault_handle): Rephrase comment.
2014-07-09 Corinna Vinschen <corinna@vinschen.de>
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index e411301cb..0a167fa4d 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
{