mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-28 00:21:52 +03:00
Move __default_stacksize into __default_pthread_attr
Make __default_pthread_attr object to store default attribute values for threads.
This commit is contained in:
@ -1,3 +1,19 @@
|
|||||||
|
2013-03-19 Siddhesh Poyarekar <siddhesh@redhat.com>
|
||||||
|
|
||||||
|
* allocatestack.c (allocate_stack): Use __default_attr instead
|
||||||
|
of __default_stacksize.
|
||||||
|
* nptl-init.c (__pthread_initialize_minimal_internal):
|
||||||
|
Likewise. Initialize guardsize.
|
||||||
|
* pthreadP.h (__default_attr): Declare.
|
||||||
|
* pthread_attr_getstacksize.c (__pthread_attr_getstacksize):
|
||||||
|
Use __default_attr instead of __default_stacksize.
|
||||||
|
* pthread_create.c (default_attr): Remove.
|
||||||
|
(__pthread_create_2_1): Use __default_attr instead of
|
||||||
|
default_attr.
|
||||||
|
* vars.c (__default_stacksize): Remove.
|
||||||
|
(__default_attr): New static variable to store
|
||||||
|
default thread attributes.
|
||||||
|
|
||||||
2013-03-18 Siddhesh Poyarekar <siddhesh@redhat.com>
|
2013-03-18 Siddhesh Poyarekar <siddhesh@redhat.com>
|
||||||
|
|
||||||
* pthread_barrier_init.c (default_attr): Rename to
|
* pthread_barrier_init.c (default_attr): Rename to
|
||||||
|
@ -358,7 +358,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
|
|||||||
|
|
||||||
/* Get the stack size from the attribute if it is set. Otherwise we
|
/* Get the stack size from the attribute if it is set. Otherwise we
|
||||||
use the default we determined at start time. */
|
use the default we determined at start time. */
|
||||||
size = attr->stacksize ?: __default_stacksize;
|
size = attr->stacksize ?: __default_pthread_attr.stacksize;
|
||||||
|
|
||||||
/* Get memory for the stack. */
|
/* Get memory for the stack. */
|
||||||
if (__builtin_expect (attr->flags & ATTR_FLAG_STACKADDR, 0))
|
if (__builtin_expect (attr->flags & ATTR_FLAG_STACKADDR, 0))
|
||||||
|
@ -423,7 +423,8 @@ __pthread_initialize_minimal_internal (void)
|
|||||||
|
|
||||||
/* Round the resource limit up to page size. */
|
/* Round the resource limit up to page size. */
|
||||||
limit.rlim_cur = (limit.rlim_cur + pagesz - 1) & -pagesz;
|
limit.rlim_cur = (limit.rlim_cur + pagesz - 1) & -pagesz;
|
||||||
__default_stacksize = limit.rlim_cur;
|
__default_pthread_attr.stacksize = limit.rlim_cur;
|
||||||
|
__default_pthread_attr.guardsize = GLRO (dl_pagesize);
|
||||||
|
|
||||||
#ifdef SHARED
|
#ifdef SHARED
|
||||||
/* Transfer the old value from the dynamic linker's internal location. */
|
/* Transfer the old value from the dynamic linker's internal location. */
|
||||||
|
@ -147,8 +147,8 @@ enum
|
|||||||
/* Internal variables. */
|
/* Internal variables. */
|
||||||
|
|
||||||
|
|
||||||
/* Default stack size. */
|
/* Default pthread attributes. */
|
||||||
extern size_t __default_stacksize attribute_hidden;
|
extern struct pthread_attr __default_pthread_attr attribute_hidden;
|
||||||
|
|
||||||
/* Size and alignment of static TLS block. */
|
/* Size and alignment of static TLS block. */
|
||||||
extern size_t __static_tls_size attribute_hidden;
|
extern size_t __static_tls_size attribute_hidden;
|
||||||
|
@ -32,7 +32,7 @@ __pthread_attr_getstacksize (attr, stacksize)
|
|||||||
|
|
||||||
/* If the user has not set a stack size we return what the system
|
/* If the user has not set a stack size we return what the system
|
||||||
will use as the default. */
|
will use as the default. */
|
||||||
*stacksize = iattr->stacksize ?: __default_stacksize;
|
*stacksize = iattr->stacksize ?: __default_pthread_attr.stacksize;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -435,15 +435,6 @@ start_thread (void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Default thread attributes for the case when the user does not
|
|
||||||
provide any. */
|
|
||||||
static const struct pthread_attr default_attr =
|
|
||||||
{
|
|
||||||
/* Just some value > 0 which gets rounded to the nearest page size. */
|
|
||||||
.guardsize = 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
__pthread_create_2_1 (newthread, attr, start_routine, arg)
|
__pthread_create_2_1 (newthread, attr, start_routine, arg)
|
||||||
pthread_t *newthread;
|
pthread_t *newthread;
|
||||||
@ -457,7 +448,7 @@ __pthread_create_2_1 (newthread, attr, start_routine, arg)
|
|||||||
if (iattr == NULL)
|
if (iattr == NULL)
|
||||||
/* Is this the best idea? On NUMA machines this could mean
|
/* Is this the best idea? On NUMA machines this could mean
|
||||||
accessing far-away memory. */
|
accessing far-away memory. */
|
||||||
iattr = &default_attr;
|
iattr = &__default_pthread_attr;
|
||||||
|
|
||||||
struct pthread *pd = NULL;
|
struct pthread *pd = NULL;
|
||||||
int err = ALLOCATE_STACK (iattr, &pd);
|
int err = ALLOCATE_STACK (iattr, &pd);
|
||||||
|
10
nptl/vars.c
10
nptl/vars.c
@ -20,13 +20,9 @@
|
|||||||
#include <tls.h>
|
#include <tls.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
/* Default stack size. */
|
/* Default thread attributes for the case when the user does not
|
||||||
size_t __default_stacksize attribute_hidden
|
provide any. */
|
||||||
#ifdef SHARED
|
struct pthread_attr __default_pthread_attr attribute_hidden;
|
||||||
;
|
|
||||||
#else
|
|
||||||
= PTHREAD_STACK_MIN;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Flag whether the machine is SMP or not. */
|
/* Flag whether the machine is SMP or not. */
|
||||||
int __is_smp attribute_hidden;
|
int __is_smp attribute_hidden;
|
||||||
|
Reference in New Issue
Block a user