mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-21 00:07:36 +08:00
* 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>
|
||||
|
||||
* exceptions.cc (exception::myfault_handle): Rephrase comment.
|
||||
|
@ -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
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user