* 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.
This commit is contained in:
parent
3dab1e488a
commit
96ed53c10f
@ -1,3 +1,16 @@
|
|||||||
|
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>
|
2014-07-09 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* exceptions.cc (exception::myfault_handle): Rephrase comment.
|
* exceptions.cc (exception::myfault_handle): Rephrase comment.
|
||||||
|
@ -473,9 +473,9 @@ pthread::create (void *(*func) (void *), pthread_attr *newattr,
|
|||||||
arg = threadarg;
|
arg = threadarg;
|
||||||
|
|
||||||
mutex.lock ();
|
mutex.lock ();
|
||||||
win32_obj_id = CygwinCreateThread (thread_init_wrapper, this,
|
win32_obj_id = CygwinCreateThread (thread_init_wrapper, this, attr.stackaddr,
|
||||||
attr.stackaddr, attr.stacksize,
|
attr.stacksize ?: PTHREAD_DEFAULT_STACKSIZE,
|
||||||
attr.guardsize, 0, &thread_id);
|
attr.guardsize, 0, &thread_id);
|
||||||
|
|
||||||
if (!win32_obj_id)
|
if (!win32_obj_id)
|
||||||
{
|
{
|
||||||
@ -1083,8 +1083,8 @@ pthread::resume ()
|
|||||||
|
|
||||||
pthread_attr::pthread_attr ():verifyable_object (PTHREAD_ATTR_MAGIC),
|
pthread_attr::pthread_attr ():verifyable_object (PTHREAD_ATTR_MAGIC),
|
||||||
joinable (PTHREAD_CREATE_JOINABLE), contentionscope (PTHREAD_SCOPE_PROCESS),
|
joinable (PTHREAD_CREATE_JOINABLE), contentionscope (PTHREAD_SCOPE_PROCESS),
|
||||||
inheritsched (PTHREAD_INHERIT_SCHED), stackaddr (NULL),
|
inheritsched (PTHREAD_INHERIT_SCHED), stackaddr (NULL), stacksize (0),
|
||||||
stacksize (PTHREAD_DEFAULT_STACKSIZE), guardsize (PTHREAD_DEFAULT_GUARDSIZE)
|
guardsize (PTHREAD_DEFAULT_GUARDSIZE)
|
||||||
{
|
{
|
||||||
schedparam.sched_priority = 0;
|
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))
|
if (!pthread_attr::is_good_object (attr))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
/* uses lowest address of stack on all platforms */
|
*addr = (*attr)->stackaddr;
|
||||||
*addr = (void *)((ptrdiff_t)(*attr)->stackaddr - (*attr)->stacksize);
|
|
||||||
*size = (*attr)->stacksize;
|
*size = (*attr)->stacksize;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2285,8 +2284,6 @@ pthread_attr_getstackaddr (const pthread_attr_t *attr, void **addr)
|
|||||||
{
|
{
|
||||||
if (!pthread_attr::is_good_object (attr))
|
if (!pthread_attr::is_good_object (attr))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
/* uses stack address, which is the higher address on platforms
|
|
||||||
where the stack grows downwards, such as x86 */
|
|
||||||
*addr = (*attr)->stackaddr;
|
*addr = (*attr)->stackaddr;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2488,11 +2485,11 @@ pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
|
|||||||
tbi, sizeof_tbi, NULL);
|
tbi, sizeof_tbi, NULL);
|
||||||
if (NT_SUCCESS (status))
|
if (NT_SUCCESS (status))
|
||||||
{
|
{
|
||||||
PNT_TIB tib = tbi->TebBaseAddress;
|
PTEB teb = (PTEB) tbi->TebBaseAddress;
|
||||||
(*attr)->stackaddr = tib->StackBase;
|
(*attr)->stackaddr = teb->DeallocationStack ?: teb->Tib.StackLimit;
|
||||||
/* stack grows downwards on x86 systems */
|
/* stack grows downwards on x86 systems */
|
||||||
(*attr)->stacksize = (uintptr_t) tib->StackBase
|
(*attr)->stacksize = (uintptr_t) teb->Tib.StackBase
|
||||||
- (uintptr_t) tib->StackLimit;
|
- (uintptr_t) (*attr)->stackaddr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user