|
|
ce426f |
diff -pruN glibc-2.17-c758a686/include/libc-internal.h glibc-2.17-c758a686/include/libc-internal.h
|
|
|
ce426f |
--- glibc-2.17-c758a686/include/libc-internal.h 2012-12-25 08:32:13.000000000 +0530
|
|
|
ce426f |
+++ glibc-2.17-c758a686/include/libc-internal.h 2013-07-30 11:26:37.947943710 +0530
|
|
|
ce426f |
@@ -50,4 +50,24 @@ extern void __init_misc (int, char **, c
|
|
|
ce426f |
/* Cast an integer or a pointer VAL to integer with proper type. */
|
|
|
ce426f |
# define cast_to_integer(val) ((__integer_if_pointer_type (val)) (val))
|
|
|
ce426f |
|
|
|
ce426f |
+/* Align a value by rounding down to closest size.
|
|
|
ce426f |
+ e.g. Using size of 4096, we get this behavior:
|
|
|
ce426f |
+ {4095, 4096, 4097} = {0, 4096, 4096}. */
|
|
|
ce426f |
+#define ALIGN_DOWN(base, size) ((base) & -((__typeof__ (base)) (size)))
|
|
|
ce426f |
+
|
|
|
ce426f |
+/* Align a value by rounding up to closest size.
|
|
|
ce426f |
+ e.g. Using size of 4096, we get this behavior:
|
|
|
ce426f |
+ {4095, 4096, 4097} = {4096, 4096, 8192}.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ Note: The size argument has side effects (expanded multiple times). */
|
|
|
ce426f |
+#define ALIGN_UP(base, size) ALIGN_DOWN ((base) + (size) - 1, (size))
|
|
|
ce426f |
+
|
|
|
ce426f |
+/* Same as ALIGN_DOWN(), but automatically casts when base is a pointer. */
|
|
|
ce426f |
+#define PTR_ALIGN_DOWN(base, size) \
|
|
|
ce426f |
+ ((__typeof__ (base)) ALIGN_DOWN ((uintptr_t) (base), (size)))
|
|
|
ce426f |
+
|
|
|
ce426f |
+/* Same as ALIGN_UP(), but automatically casts when base is a pointer. */
|
|
|
ce426f |
+#define PTR_ALIGN_UP(base, size) \
|
|
|
ce426f |
+ ((__typeof__ (base)) ALIGN_UP ((uintptr_t) (base), (size)))
|
|
|
ce426f |
+
|
|
|
ce426f |
#endif /* _LIBC_INTERNAL */
|
|
|
ce426f |
diff -pruN glibc-2.17-c758a686/nptl/allocatestack.c glibc-2.17-c758a686/nptl/allocatestack.c
|
|
|
ce426f |
--- glibc-2.17-c758a686/nptl/allocatestack.c 2012-12-25 08:32:13.000000000 +0530
|
|
|
ce426f |
+++ glibc-2.17-c758a686/nptl/allocatestack.c 2013-07-30 11:26:38.012943707 +0530
|
|
|
ce426f |
@@ -355,7 +355,7 @@ allocate_stack (const struct pthread_att
|
|
|
ce426f |
|
|
|
ce426f |
/* Get the stack size from the attribute if it is set. Otherwise we
|
|
|
ce426f |
use the default we determined at start time. */
|
|
|
ce426f |
- size = attr->stacksize ?: __default_stacksize;
|
|
|
ce426f |
+ size = attr->stacksize ?: __default_pthread_attr.stacksize;
|
|
|
ce426f |
|
|
|
ce426f |
/* Get memory for the stack. */
|
|
|
ce426f |
if (__builtin_expect (attr->flags & ATTR_FLAG_STACKADDR, 0))
|
|
|
ce426f |
diff -pruN glibc-2.17-c758a686/nptl/nptl-init.c glibc-2.17-c758a686/nptl/nptl-init.c
|
|
|
ce426f |
--- glibc-2.17-c758a686/nptl/nptl-init.c 2013-07-30 11:45:16.902904743 +0530
|
|
|
ce426f |
+++ glibc-2.17-c758a686/nptl/nptl-init.c 2013-07-30 11:44:59.538905347 +0530
|
|
|
ce426f |
@@ -423,7 +423,8 @@ __pthread_initialize_minimal_internal (v
|
|
|
ce426f |
|
|
|
ce426f |
/* Round the resource limit up to page size. */
|
|
|
ce426f |
limit.rlim_cur = (limit.rlim_cur + pagesz - 1) & -pagesz;
|
|
|
ce426f |
- __default_stacksize = limit.rlim_cur;
|
|
|
ce426f |
+ __default_pthread_attr.stacksize = limit.rlim_cur;
|
|
|
ce426f |
+ __default_pthread_attr.guardsize = GLRO (dl_pagesize);
|
|
|
ce426f |
|
|
|
ce426f |
#ifdef SHARED
|
|
|
ce426f |
/* Transfer the old value from the dynamic linker's internal location. */
|
|
|
ce426f |
diff -pruN glibc-2.17-c758a686/nptl/pthread_attr_getstacksize.c glibc-2.17-c758a686/nptl/pthread_attr_getstacksize.c
|
|
|
ce426f |
--- glibc-2.17-c758a686/nptl/pthread_attr_getstacksize.c 2012-12-25 08:32:13.000000000 +0530
|
|
|
ce426f |
+++ glibc-2.17-c758a686/nptl/pthread_attr_getstacksize.c 2013-07-30 11:26:39.650943650 +0530
|
|
|
ce426f |
@@ -32,7 +32,7 @@ __pthread_attr_getstacksize (attr, stack
|
|
|
ce426f |
|
|
|
ce426f |
/* If the user has not set a stack size we return what the system
|
|
|
ce426f |
will use as the default. */
|
|
|
ce426f |
- *stacksize = iattr->stacksize ?: __default_stacksize;
|
|
|
ce426f |
+ *stacksize = iattr->stacksize ?: __default_pthread_attr.stacksize;
|
|
|
ce426f |
|
|
|
ce426f |
return 0;
|
|
|
ce426f |
}
|
|
|
ce426f |
diff -pruN glibc-2.17-c758a686/nptl/pthread_barrier_init.c glibc-2.17-c758a686/nptl/pthread_barrier_init.c
|
|
|
ce426f |
--- glibc-2.17-c758a686/nptl/pthread_barrier_init.c 2012-12-25 08:32:13.000000000 +0530
|
|
|
ce426f |
+++ glibc-2.17-c758a686/nptl/pthread_barrier_init.c 2013-07-30 11:26:40.206943631 +0530
|
|
|
ce426f |
@@ -22,7 +22,7 @@
|
|
|
ce426f |
#include <kernel-features.h>
|
|
|
ce426f |
|
|
|
ce426f |
|
|
|
ce426f |
-static const struct pthread_barrierattr default_attr =
|
|
|
ce426f |
+static const struct pthread_barrierattr default_barrierattr =
|
|
|
ce426f |
{
|
|
|
ce426f |
.pshared = PTHREAD_PROCESS_PRIVATE
|
|
|
ce426f |
};
|
|
|
ce426f |
@@ -42,7 +42,7 @@ pthread_barrier_init (barrier, attr, cou
|
|
|
ce426f |
const struct pthread_barrierattr *iattr
|
|
|
ce426f |
= (attr != NULL
|
|
|
ce426f |
? iattr = (struct pthread_barrierattr *) attr
|
|
|
ce426f |
- : &default_attr);
|
|
|
ce426f |
+ : &default_barrierattr);
|
|
|
ce426f |
|
|
|
ce426f |
if (iattr->pshared != PTHREAD_PROCESS_PRIVATE
|
|
|
ce426f |
&& __builtin_expect (iattr->pshared != PTHREAD_PROCESS_SHARED, 0))
|
|
|
ce426f |
diff -pruN glibc-2.17-c758a686/nptl/pthread_create.c glibc-2.17-c758a686/nptl/pthread_create.c
|
|
|
ce426f |
--- glibc-2.17-c758a686/nptl/pthread_create.c 2012-12-25 08:32:13.000000000 +0530
|
|
|
ce426f |
+++ glibc-2.17-c758a686/nptl/pthread_create.c 2013-07-30 11:26:40.774943611 +0530
|
|
|
ce426f |
@@ -432,15 +432,6 @@ start_thread (void *arg)
|
|
|
ce426f |
}
|
|
|
ce426f |
|
|
|
ce426f |
|
|
|
ce426f |
-/* Default thread attributes for the case when the user does not
|
|
|
ce426f |
- provide any. */
|
|
|
ce426f |
-static const struct pthread_attr default_attr =
|
|
|
ce426f |
- {
|
|
|
ce426f |
- /* Just some value > 0 which gets rounded to the nearest page size. */
|
|
|
ce426f |
- .guardsize = 1,
|
|
|
ce426f |
- };
|
|
|
ce426f |
-
|
|
|
ce426f |
-
|
|
|
ce426f |
int
|
|
|
ce426f |
__pthread_create_2_1 (newthread, attr, start_routine, arg)
|
|
|
ce426f |
pthread_t *newthread;
|
|
|
ce426f |
@@ -454,7 +445,7 @@ __pthread_create_2_1 (newthread, attr, s
|
|
|
ce426f |
if (iattr == NULL)
|
|
|
ce426f |
/* Is this the best idea? On NUMA machines this could mean
|
|
|
ce426f |
accessing far-away memory. */
|
|
|
ce426f |
- iattr = &default_attr;
|
|
|
ce426f |
+ iattr = &__default_pthread_attr;
|
|
|
ce426f |
|
|
|
ce426f |
struct pthread *pd = NULL;
|
|
|
ce426f |
int err = ALLOCATE_STACK (iattr, &pd;;
|
|
|
ce426f |
diff -pruN glibc-2.17-c758a686/nptl/pthread_mutex_init.c glibc-2.17-c758a686/nptl/pthread_mutex_init.c
|
|
|
ce426f |
--- glibc-2.17-c758a686/nptl/pthread_mutex_init.c 2012-12-25 08:32:13.000000000 +0530
|
|
|
ce426f |
+++ glibc-2.17-c758a686/nptl/pthread_mutex_init.c 2013-07-30 11:26:42.079943566 +0530
|
|
|
ce426f |
@@ -24,7 +24,7 @@
|
|
|
ce426f |
|
|
|
ce426f |
#include <stap-probe.h>
|
|
|
ce426f |
|
|
|
ce426f |
-static const struct pthread_mutexattr default_attr =
|
|
|
ce426f |
+static const struct pthread_mutexattr default_mutexattr =
|
|
|
ce426f |
{
|
|
|
ce426f |
/* Default is a normal mutex, not shared between processes. */
|
|
|
ce426f |
.mutexkind = PTHREAD_MUTEX_NORMAL
|
|
|
ce426f |
@@ -45,7 +45,8 @@ __pthread_mutex_init (mutex, mutexattr)
|
|
|
ce426f |
|
|
|
ce426f |
assert (sizeof (pthread_mutex_t) <= __SIZEOF_PTHREAD_MUTEX_T);
|
|
|
ce426f |
|
|
|
ce426f |
- imutexattr = (const struct pthread_mutexattr *) mutexattr ?: &default_attr;
|
|
|
ce426f |
+ imutexattr = ((const struct pthread_mutexattr *) mutexattr
|
|
|
ce426f |
+ ?: &default_mutexattr);
|
|
|
ce426f |
|
|
|
ce426f |
/* Sanity checks. */
|
|
|
ce426f |
switch (__builtin_expect (imutexattr->mutexkind
|
|
|
ce426f |
diff -pruN glibc-2.17-c758a686/nptl/pthreadP.h glibc-2.17-c758a686/nptl/pthreadP.h
|
|
|
ce426f |
--- glibc-2.17-c758a686/nptl/pthreadP.h 2012-12-25 08:32:13.000000000 +0530
|
|
|
ce426f |
+++ glibc-2.17-c758a686/nptl/pthreadP.h 2013-07-30 11:26:43.095943530 +0530
|
|
|
ce426f |
@@ -147,8 +147,8 @@ enum
|
|
|
ce426f |
/* Internal variables. */
|
|
|
ce426f |
|
|
|
ce426f |
|
|
|
ce426f |
-/* Default stack size. */
|
|
|
ce426f |
-extern size_t __default_stacksize attribute_hidden;
|
|
|
ce426f |
+/* Default pthread attributes. */
|
|
|
ce426f |
+extern struct pthread_attr __default_pthread_attr attribute_hidden;
|
|
|
ce426f |
|
|
|
ce426f |
/* Size and alignment of static TLS block. */
|
|
|
ce426f |
extern size_t __static_tls_size attribute_hidden;
|
|
|
ce426f |
diff -pruN glibc-2.17-c758a686/nptl/pthread_rwlock_init.c glibc-2.17-c758a686/nptl/pthread_rwlock_init.c
|
|
|
ce426f |
--- glibc-2.17-c758a686/nptl/pthread_rwlock_init.c 2012-12-25 08:32:13.000000000 +0530
|
|
|
ce426f |
+++ glibc-2.17-c758a686/nptl/pthread_rwlock_init.c 2013-07-30 11:26:43.745943508 +0530
|
|
|
ce426f |
@@ -21,7 +21,7 @@
|
|
|
ce426f |
#include <kernel-features.h>
|
|
|
ce426f |
|
|
|
ce426f |
|
|
|
ce426f |
-static const struct pthread_rwlockattr default_attr =
|
|
|
ce426f |
+static const struct pthread_rwlockattr default_rwlockattr =
|
|
|
ce426f |
{
|
|
|
ce426f |
.lockkind = PTHREAD_RWLOCK_DEFAULT_NP,
|
|
|
ce426f |
.pshared = PTHREAD_PROCESS_PRIVATE
|
|
|
ce426f |
@@ -35,7 +35,7 @@ __pthread_rwlock_init (rwlock, attr)
|
|
|
ce426f |
{
|
|
|
ce426f |
const struct pthread_rwlockattr *iattr;
|
|
|
ce426f |
|
|
|
ce426f |
- iattr = ((const struct pthread_rwlockattr *) attr) ?: &default_attr;
|
|
|
ce426f |
+ iattr = ((const struct pthread_rwlockattr *) attr) ?: &default_rwlockattr;
|
|
|
ce426f |
|
|
|
ce426f |
memset (rwlock, '\0', sizeof (*rwlock));
|
|
|
ce426f |
|
|
|
ce426f |
diff -pruN glibc-2.17-c758a686/nptl/vars.c glibc-2.17-c758a686/nptl/vars.c
|
|
|
ce426f |
--- glibc-2.17-c758a686/nptl/vars.c 2012-12-25 08:32:13.000000000 +0530
|
|
|
ce426f |
+++ glibc-2.17-c758a686/nptl/vars.c 2013-07-30 11:26:43.763943507 +0530
|
|
|
ce426f |
@@ -20,13 +20,9 @@
|
|
|
ce426f |
#include <tls.h>
|
|
|
ce426f |
#include <unistd.h>
|
|
|
ce426f |
|
|
|
ce426f |
-/* Default stack size. */
|
|
|
ce426f |
-size_t __default_stacksize attribute_hidden
|
|
|
ce426f |
-#ifdef SHARED
|
|
|
ce426f |
-;
|
|
|
ce426f |
-#else
|
|
|
ce426f |
- = PTHREAD_STACK_MIN;
|
|
|
ce426f |
-#endif
|
|
|
ce426f |
+/* Default thread attributes for the case when the user does not
|
|
|
ce426f |
+ provide any. */
|
|
|
ce426f |
+struct pthread_attr __default_pthread_attr attribute_hidden;
|
|
|
ce426f |
|
|
|
ce426f |
/* Flag whether the machine is SMP or not. */
|
|
|
ce426f |
int __is_smp attribute_hidden;
|