]>
Commit | Line | Data |
---|---|---|
bb330e25 AF |
1 | diff -pruN glibc-2.12-2-gc4ccff1/include/libc-internal.h glibc-2.12-2-gc4ccff1.fixed/include/libc-internal.h |
2 | --- glibc-2.12-2-gc4ccff1/include/libc-internal.h 2010-05-04 16:57:23.000000000 +0530 | |
3 | +++ glibc-2.12-2-gc4ccff1.fixed/include/libc-internal.h 2013-07-09 23:44:00.272833779 +0530 | |
4 | @@ -34,4 +34,24 @@ extern void __libc_thread_freeres (void) | |
5 | /* Define and initialize `__progname' et. al. */ | |
6 | extern void __init_misc (int, char **, char **); | |
7 | ||
8 | +/* Align a value by rounding down to closest size. | |
9 | + e.g. Using size of 4096, we get this behavior: | |
10 | + {4095, 4096, 4097} = {0, 4096, 4096}. */ | |
11 | +#define ALIGN_DOWN(base, size) ((base) & -((__typeof__ (base)) (size))) | |
12 | + | |
13 | +/* Align a value by rounding up to closest size. | |
14 | + e.g. Using size of 4096, we get this behavior: | |
15 | + {4095, 4096, 4097} = {4096, 4096, 8192}. | |
16 | + | |
17 | + Note: The size argument has side effects (expanded multiple times). */ | |
18 | +#define ALIGN_UP(base, size) ALIGN_DOWN ((base) + (size) - 1, (size)) | |
19 | + | |
20 | +/* Same as ALIGN_DOWN(), but automatically casts when base is a pointer. */ | |
21 | +#define PTR_ALIGN_DOWN(base, size) \ | |
22 | + ((__typeof__ (base)) ALIGN_DOWN ((uintptr_t) (base), (size))) | |
23 | + | |
24 | +/* Same as ALIGN_UP(), but automatically casts when base is a pointer. */ | |
25 | +#define PTR_ALIGN_UP(base, size) \ | |
26 | + ((__typeof__ (base)) ALIGN_UP ((uintptr_t) (base), (size))) | |
27 | + | |
28 | #endif /* _LIBC_INTERNAL */ | |
29 | diff -pruN glibc-2.12-2-gc4ccff1/nptl/allocatestack.c glibc-2.12-2-gc4ccff1.fixed/nptl/allocatestack.c | |
30 | --- glibc-2.12-2-gc4ccff1/nptl/allocatestack.c 2013-07-09 23:43:09.427836179 +0530 | |
31 | +++ glibc-2.12-2-gc4ccff1.fixed/nptl/allocatestack.c 2013-07-09 23:43:52.727834136 +0530 | |
32 | @@ -351,7 +351,7 @@ allocate_stack (const struct pthread_att | |
33 | ||
34 | /* Get the stack size from the attribute if it is set. Otherwise we | |
35 | use the default we determined at start time. */ | |
36 | - size = attr->stacksize ?: __default_stacksize; | |
37 | + size = attr->stacksize ?: __default_pthread_attr.stacksize; | |
38 | ||
39 | /* Get memory for the stack. */ | |
40 | if (__builtin_expect (attr->flags & ATTR_FLAG_STACKADDR, 0)) | |
41 | diff -pruN glibc-2.12-2-gc4ccff1/nptl/nptl-init.c glibc-2.12-2-gc4ccff1.fixed/nptl/nptl-init.c | |
42 | --- glibc-2.12-2-gc4ccff1/nptl/nptl-init.c 2013-07-09 23:43:09.553836173 +0530 | |
43 | +++ glibc-2.12-2-gc4ccff1.fixed/nptl/nptl-init.c 2013-07-09 23:43:52.728834135 +0530 | |
44 | @@ -435,7 +435,8 @@ __pthread_initialize_minimal_internal (v | |
45 | ||
46 | /* Round the resource limit up to page size. */ | |
47 | limit.rlim_cur = (limit.rlim_cur + pagesz - 1) & -pagesz; | |
48 | - __default_stacksize = limit.rlim_cur; | |
49 | + __default_pthread_attr.stacksize = limit.rlim_cur; | |
50 | + __default_pthread_attr.guardsize = GLRO (dl_pagesize); | |
51 | ||
52 | #ifdef SHARED | |
53 | /* Transfer the old value from the dynamic linker's internal location. */ | |
54 | diff -pruN glibc-2.12-2-gc4ccff1/nptl/pthread_attr_getstacksize.c glibc-2.12-2-gc4ccff1.fixed/nptl/pthread_attr_getstacksize.c | |
55 | --- glibc-2.12-2-gc4ccff1/nptl/pthread_attr_getstacksize.c 2010-05-04 16:57:23.000000000 +0530 | |
56 | +++ glibc-2.12-2-gc4ccff1.fixed/nptl/pthread_attr_getstacksize.c 2013-07-09 23:43:52.817834131 +0530 | |
57 | @@ -33,7 +33,7 @@ __pthread_attr_getstacksize (attr, stack | |
58 | ||
59 | /* If the user has not set a stack size we return what the system | |
60 | will use as the default. */ | |
61 | - *stacksize = iattr->stacksize ?: __default_stacksize; | |
62 | + *stacksize = iattr->stacksize ?: __default_pthread_attr.stacksize; | |
63 | ||
64 | return 0; | |
65 | } | |
66 | diff -pruN glibc-2.12-2-gc4ccff1/nptl/pthread_barrier_init.c glibc-2.12-2-gc4ccff1.fixed/nptl/pthread_barrier_init.c | |
67 | --- glibc-2.12-2-gc4ccff1/nptl/pthread_barrier_init.c 2010-05-04 16:57:23.000000000 +0530 | |
68 | +++ glibc-2.12-2-gc4ccff1.fixed/nptl/pthread_barrier_init.c 2013-07-09 23:43:52.821834131 +0530 | |
69 | @@ -23,7 +23,7 @@ | |
70 | #include <kernel-features.h> | |
71 | ||
72 | ||
73 | -static const struct pthread_barrierattr default_attr = | |
74 | +static const struct pthread_barrierattr default_barrierattr = | |
75 | { | |
76 | .pshared = PTHREAD_PROCESS_PRIVATE | |
77 | }; | |
78 | @@ -43,7 +43,7 @@ pthread_barrier_init (barrier, attr, cou | |
79 | const struct pthread_barrierattr *iattr | |
80 | = (attr != NULL | |
81 | ? iattr = (struct pthread_barrierattr *) attr | |
82 | - : &default_attr); | |
83 | + : &default_barrierattr); | |
84 | ||
85 | if (iattr->pshared != PTHREAD_PROCESS_PRIVATE | |
86 | && __builtin_expect (iattr->pshared != PTHREAD_PROCESS_SHARED, 0)) | |
87 | diff -pruN glibc-2.12-2-gc4ccff1/nptl/pthread_create.c glibc-2.12-2-gc4ccff1.fixed/nptl/pthread_create.c | |
88 | --- glibc-2.12-2-gc4ccff1/nptl/pthread_create.c 2013-07-09 23:43:09.542836173 +0530 | |
89 | +++ glibc-2.12-2-gc4ccff1.fixed/nptl/pthread_create.c 2013-07-09 23:43:52.822834131 +0530 | |
90 | @@ -425,15 +425,6 @@ start_thread (void *arg) | |
91 | } | |
92 | ||
93 | ||
94 | -/* Default thread attributes for the case when the user does not | |
95 | - provide any. */ | |
96 | -static const struct pthread_attr default_attr = | |
97 | - { | |
98 | - /* Just some value > 0 which gets rounded to the nearest page size. */ | |
99 | - .guardsize = 1, | |
100 | - }; | |
101 | - | |
102 | - | |
103 | int | |
104 | __pthread_create_2_1 (newthread, attr, start_routine, arg) | |
105 | pthread_t *newthread; | |
106 | @@ -447,7 +438,7 @@ __pthread_create_2_1 (newthread, attr, s | |
107 | if (iattr == NULL) | |
108 | /* Is this the best idea? On NUMA machines this could mean | |
109 | accessing far-away memory. */ | |
110 | - iattr = &default_attr; | |
111 | + iattr = &__default_pthread_attr; | |
112 | ||
113 | struct pthread *pd = NULL; | |
114 | int err = ALLOCATE_STACK (iattr, &pd); | |
115 | diff -pruN glibc-2.12-2-gc4ccff1/nptl/pthread_mutex_init.c glibc-2.12-2-gc4ccff1.fixed/nptl/pthread_mutex_init.c | |
116 | --- glibc-2.12-2-gc4ccff1/nptl/pthread_mutex_init.c 2010-05-04 16:57:23.000000000 +0530 | |
117 | +++ glibc-2.12-2-gc4ccff1.fixed/nptl/pthread_mutex_init.c 2013-07-09 23:43:52.822834131 +0530 | |
118 | @@ -24,7 +24,7 @@ | |
119 | #include <kernel-features.h> | |
120 | #include "pthreadP.h" | |
121 | ||
122 | -static const struct pthread_mutexattr default_attr = | |
123 | +static const struct pthread_mutexattr default_mutexattr = | |
124 | { | |
125 | /* Default is a normal mutex, not shared between processes. */ | |
126 | .mutexkind = PTHREAD_MUTEX_NORMAL | |
127 | @@ -45,7 +45,8 @@ __pthread_mutex_init (mutex, mutexattr) | |
128 | ||
129 | assert (sizeof (pthread_mutex_t) <= __SIZEOF_PTHREAD_MUTEX_T); | |
130 | ||
131 | - imutexattr = (const struct pthread_mutexattr *) mutexattr ?: &default_attr; | |
132 | + imutexattr = ((const struct pthread_mutexattr *) mutexattr | |
133 | + ?: &default_mutexattr); | |
134 | ||
135 | /* Sanity checks. */ | |
136 | switch (__builtin_expect (imutexattr->mutexkind | |
137 | diff -pruN glibc-2.12-2-gc4ccff1/nptl/pthreadP.h glibc-2.12-2-gc4ccff1.fixed/nptl/pthreadP.h | |
138 | --- glibc-2.12-2-gc4ccff1/nptl/pthreadP.h 2013-07-09 23:43:09.553836173 +0530 | |
139 | +++ glibc-2.12-2-gc4ccff1.fixed/nptl/pthreadP.h 2013-07-09 23:43:52.823834131 +0530 | |
140 | @@ -148,8 +148,8 @@ enum | |
141 | /* Internal variables. */ | |
142 | ||
143 | ||
144 | -/* Default stack size. */ | |
145 | -extern size_t __default_stacksize attribute_hidden; | |
146 | +/* Default pthread attributes. */ | |
147 | +extern struct pthread_attr __default_pthread_attr attribute_hidden; | |
148 | ||
149 | /* Size and alignment of static TLS block. */ | |
150 | extern size_t __static_tls_size attribute_hidden; | |
151 | diff -pruN glibc-2.12-2-gc4ccff1/nptl/pthread_rwlock_init.c glibc-2.12-2-gc4ccff1.fixed/nptl/pthread_rwlock_init.c | |
152 | --- glibc-2.12-2-gc4ccff1/nptl/pthread_rwlock_init.c 2010-05-04 16:57:23.000000000 +0530 | |
153 | +++ glibc-2.12-2-gc4ccff1.fixed/nptl/pthread_rwlock_init.c 2013-07-09 23:43:52.823834131 +0530 | |
154 | @@ -21,7 +21,7 @@ | |
155 | #include <kernel-features.h> | |
156 | ||
157 | ||
158 | -static const struct pthread_rwlockattr default_attr = | |
159 | +static const struct pthread_rwlockattr default_rwlockattr = | |
160 | { | |
161 | .lockkind = PTHREAD_RWLOCK_DEFAULT_NP, | |
162 | .pshared = PTHREAD_PROCESS_PRIVATE | |
163 | @@ -35,7 +35,7 @@ __pthread_rwlock_init (rwlock, attr) | |
164 | { | |
165 | const struct pthread_rwlockattr *iattr; | |
166 | ||
167 | - iattr = ((const struct pthread_rwlockattr *) attr) ?: &default_attr; | |
168 | + iattr = ((const struct pthread_rwlockattr *) attr) ?: &default_rwlockattr; | |
169 | ||
170 | memset (rwlock, '\0', sizeof (*rwlock)); | |
171 | ||
172 | diff -pruN glibc-2.12-2-gc4ccff1/nptl/vars.c glibc-2.12-2-gc4ccff1.fixed/nptl/vars.c | |
173 | --- glibc-2.12-2-gc4ccff1/nptl/vars.c 2010-05-04 16:57:23.000000000 +0530 | |
174 | +++ glibc-2.12-2-gc4ccff1.fixed/nptl/vars.c 2013-07-09 23:43:52.824834131 +0530 | |
175 | @@ -21,13 +21,9 @@ | |
176 | #include <tls.h> | |
177 | #include <unistd.h> | |
178 | ||
179 | -/* Default stack size. */ | |
180 | -size_t __default_stacksize attribute_hidden | |
181 | -#ifdef SHARED | |
182 | -; | |
183 | -#else | |
184 | - = PTHREAD_STACK_MIN; | |
185 | -#endif | |
186 | +/* Default thread attributes for the case when the user does not | |
187 | + provide any. */ | |
188 | +struct pthread_attr __default_pthread_attr attribute_hidden; | |
189 | ||
190 | /* Flag whether the machine is SMP or not. */ | |
191 | int __is_smp attribute_hidden; |