summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0212-2011-05-03-Paolo-Carlini-paolo.carlini-oracle.com.patch
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2011-06-12 20:56:57 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-06-14 15:29:15 +0100
commitec9b6d061b8495b9316ae90e5a71a499ef2873ee (patch)
treedc922c9ddd98f937eb2095b07f6c3b5043e3a491 /meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0212-2011-05-03-Paolo-Carlini-paolo.carlini-oracle.com.patch
parentfbc60cc5ba2284bfcaea8c82001a49b7795cc2a2 (diff)
downloadpoky-ec9b6d061b8495b9316ae90e5a71a499ef2873ee.tar.gz
gcc-4.6.0: Bring in patches from FSF 4.6 branch
This brings in new patches from 4.6 release branch updates the comment section of existing branch to not contain patch numbers. Tested build on qemu for arm ppc mips x86 and x86_64 (From OE-Core rev: 3968f33b6542cf20cf63cf49bfbc033bd2486295) Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0212-2011-05-03-Paolo-Carlini-paolo.carlini-oracle.com.patch')
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0212-2011-05-03-Paolo-Carlini-paolo.carlini-oracle.com.patch462
1 files changed, 462 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0212-2011-05-03-Paolo-Carlini-paolo.carlini-oracle.com.patch b/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0212-2011-05-03-Paolo-Carlini-paolo.carlini-oracle.com.patch
new file mode 100644
index 0000000000..46fc3dc922
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0212-2011-05-03-Paolo-Carlini-paolo.carlini-oracle.com.patch
@@ -0,0 +1,462 @@
1From 6cc36bf90838d09b0a4899228bde2b009dd7c7dc Mon Sep 17 00:00:00 2001
2From: paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
3Date: Tue, 3 May 2011 17:54:35 +0000
4Subject: [PATCH] 2011-05-03 Paolo Carlini <paolo.carlini@oracle.com>
5
6 PR libstdc++/48750
7 * include/parallel/multiway_merge.h: Run _ValueType destructors.
8 * include/parallel/multiway_mergesort.h: Likewise.
9 * include/parallel/quicksort.h: Likewise.
10 * include/parallel/random_shuffle.h: Likewise.
11 * include/parallel/partial_sum.h: Likewise.
12 * include/parallel/losertree.h: Run destructors; minor tweaks.
13 * include/parallel/par_loop.h: Run destructors, fix memory
14 allocations and deallocations.
15 * testsuite/26_numerics/accumulate/48750.cc: New.
16
17 * testsuite/ext/profile/mutex_extensions_neg.cc: Do not run in
18 parallel-mode to avoid spurious multiple errors.
19
20
21git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@173335 138bc75d-0d04-0410-961f-82ee72b054a4
22
23index 8d7b137..cb24f7f 100644
24--- a/libstdc++-v3/include/parallel/losertree.h
25+++ b/libstdc++-v3/include/parallel/losertree.h
26@@ -1,6 +1,6 @@
27 // -*- C++ -*-
28
29-// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
30+// Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
31 //
32 // This file is part of the GNU ISO C++ Library. This library is free
33 // software; you can redistribute it and/or modify it under the terms
34@@ -116,7 +116,11 @@ namespace __gnu_parallel
35 * @brief The destructor.
36 */
37 ~_LoserTreeBase()
38- { ::operator delete(_M_losers); }
39+ {
40+ for (unsigned int __i = 0; __i < (2 * _M_k); ++__i)
41+ _M_losers[__i].~_Loser();
42+ ::operator delete(_M_losers);
43+ }
44
45 /**
46 * @brief Initializes the sequence "_M_source" with the element "__key".
47@@ -131,15 +135,15 @@ namespace __gnu_parallel
48 {
49 unsigned int __pos = _M_k + __source;
50
51- if(_M_first_insert)
52+ if (_M_first_insert)
53 {
54- // Construct all keys, so we can easily deconstruct them.
55+ // Construct all keys, so we can easily destruct them.
56 for (unsigned int __i = 0; __i < (2 * _M_k); ++__i)
57- new(&(_M_losers[__i]._M_key)) _Tp(__key);
58+ ::new(&(_M_losers[__i]._M_key)) _Tp(__key);
59 _M_first_insert = false;
60 }
61 else
62- new(&(_M_losers[__pos]._M_key)) _Tp(__key);
63+ _M_losers[__pos]._M_key = __key;
64
65 _M_losers[__pos]._M_sup = __sup;
66 _M_losers[__pos]._M_source = __source;
67@@ -379,7 +383,7 @@ namespace __gnu_parallel
68 }
69
70 ~_LoserTreePointerBase()
71- { ::operator delete[](_M_losers); }
72+ { delete[] _M_losers; }
73
74 int __get_min_source()
75 { return _M_losers[0]._M_source; }
76@@ -577,7 +581,7 @@ namespace __gnu_parallel
77 _Compare _M_comp;
78
79 public:
80- _LoserTreeUnguardedBase(unsigned int __k, const _Tp __sentinel,
81+ _LoserTreeUnguardedBase(unsigned int __k, const _Tp& __sentinel,
82 _Compare __comp = std::less<_Tp>())
83 : _M_comp(__comp)
84 {
85@@ -590,15 +594,24 @@ namespace __gnu_parallel
86 _M_losers = static_cast<_Loser*>(::operator new(2 * _M_k
87 * sizeof(_Loser)));
88
89- for (unsigned int __i = _M_k + _M_ik - 1; __i < (2 * _M_k); ++__i)
90- {
91- _M_losers[__i]._M_key = __sentinel;
92+ for (unsigned int __i = 0; __i < _M_k; ++__i)
93+ {
94+ ::new(&(_M_losers[__i]._M_key)) _Tp(__sentinel);
95+ _M_losers[__i]._M_source = -1;
96+ }
97+ for (unsigned int __i = _M_k + _M_ik - 1; __i < (2 * _M_k); ++__i)
98+ {
99+ ::new(&(_M_losers[__i]._M_key)) _Tp(__sentinel);
100 _M_losers[__i]._M_source = -1;
101 }
102 }
103
104 ~_LoserTreeUnguardedBase()
105- { ::operator delete(_M_losers); }
106+ {
107+ for (unsigned int __i = 0; __i < (2 * _M_k); ++__i)
108+ _M_losers[__i].~_Loser();
109+ ::operator delete(_M_losers);
110+ }
111
112 int
113 __get_min_source()
114@@ -615,7 +628,7 @@ namespace __gnu_parallel
115 {
116 unsigned int __pos = _M_k + __source;
117
118- new(&(_M_losers[__pos]._M_key)) _Tp(__key);
119+ ::new(&(_M_losers[__pos]._M_key)) _Tp(__key);
120 _M_losers[__pos]._M_source = __source;
121 }
122 };
123@@ -634,7 +647,7 @@ namespace __gnu_parallel
124 using _Base::_M_losers;
125
126 public:
127- _LoserTreeUnguarded(unsigned int __k, const _Tp __sentinel,
128+ _LoserTreeUnguarded(unsigned int __k, const _Tp& __sentinel,
129 _Compare __comp = std::less<_Tp>())
130 : _Base::_LoserTreeUnguardedBase(__k, __sentinel, __comp)
131 { }
132@@ -721,7 +734,7 @@ namespace __gnu_parallel
133 using _Base::_M_losers;
134
135 public:
136- _LoserTreeUnguarded(unsigned int __k, const _Tp __sentinel,
137+ _LoserTreeUnguarded(unsigned int __k, const _Tp& __sentinel,
138 _Compare __comp = std::less<_Tp>())
139 : _Base::_LoserTreeUnguardedBase(__k, __sentinel, __comp)
140 { }
141diff --git a/libstdc++-v3/include/parallel/multiway_merge.h b/libstdc++-v3/include/parallel/multiway_merge.h
142index 0fd3da2..00df31c 100644
143--- a/libstdc++-v3/include/parallel/multiway_merge.h
144+++ b/libstdc++-v3/include/parallel/multiway_merge.h
145@@ -1045,11 +1045,12 @@ namespace __gnu_parallel
146 _ValueType;
147
148 // __k sequences.
149- _SeqNumber __k = static_cast<_SeqNumber>(__seqs_end - __seqs_begin);
150+ const _SeqNumber __k
151+ = static_cast<_SeqNumber>(__seqs_end - __seqs_begin);
152
153- _ThreadIndex __num_threads = omp_get_num_threads();
154+ const _ThreadIndex __num_threads = omp_get_num_threads();
155
156- _DifferenceType __num_samples =
157+ const _DifferenceType __num_samples =
158 __gnu_parallel::_Settings::get().merge_oversampling * __num_threads;
159
160 _ValueType* __samples = static_cast<_ValueType*>
161@@ -1096,6 +1097,10 @@ namespace __gnu_parallel
162 __pieces[__slab][__seq].second =
163 _GLIBCXX_PARALLEL_LENGTH(__seqs_begin[__seq]);
164 }
165+
166+ for (_SeqNumber __s = 0; __s < __k; ++__s)
167+ for (_DifferenceType __i = 0; __i < __num_samples; ++__i)
168+ __samples[__s * __num_samples + __i].~_ValueType();
169 ::operator delete(__samples);
170 }
171
172@@ -1258,10 +1263,10 @@ namespace __gnu_parallel
173 __length = std::min<_DifferenceTp>(__length, __total_length);
174
175 if (__total_length == 0 || __k == 0)
176- {
177- delete[] __ne_seqs;
178- return __target;
179- }
180+ {
181+ delete[] __ne_seqs;
182+ return __target;
183+ }
184
185 std::vector<std::pair<_DifferenceType, _DifferenceType> >* __pieces;
186
187diff --git a/libstdc++-v3/include/parallel/multiway_mergesort.h b/libstdc++-v3/include/parallel/multiway_mergesort.h
188index c0dab63..af7c10a 100644
189--- a/libstdc++-v3/include/parallel/multiway_mergesort.h
190+++ b/libstdc++-v3/include/parallel/multiway_mergesort.h
191@@ -378,6 +378,8 @@ namespace __gnu_parallel
192
193 # pragma omp barrier
194
195+ for (_DifferenceType __i = 0; __i < __length_local; ++__i)
196+ __sd->_M_temporary[__iam][__i].~_ValueType();
197 ::operator delete(__sd->_M_temporary[__iam]);
198 }
199
200@@ -413,6 +415,7 @@ namespace __gnu_parallel
201 // shared variables
202 _PMWMSSortingData<_RAIter> __sd;
203 _DifferenceType* __starts;
204+ _DifferenceType __size;
205
206 # pragma omp parallel num_threads(__num_threads)
207 {
208@@ -427,7 +430,7 @@ namespace __gnu_parallel
209
210 if (!__exact)
211 {
212- _DifferenceType __size =
213+ __size =
214 (_Settings::get().sort_mwms_oversampling * __num_threads - 1)
215 * __num_threads;
216 __sd._M_samples = static_cast<_ValueType*>
217@@ -463,7 +466,11 @@ namespace __gnu_parallel
218 delete[] __sd._M_temporary;
219
220 if (!__exact)
221- ::operator delete(__sd._M_samples);
222+ {
223+ for (_DifferenceType __i = 0; __i < __size; ++__i)
224+ __sd._M_samples[__i].~_ValueType();
225+ ::operator delete(__sd._M_samples);
226+ }
227
228 delete[] __sd._M_offsets;
229 delete[] __sd._M_pieces;
230diff --git a/libstdc++-v3/include/parallel/par_loop.h b/libstdc++-v3/include/parallel/par_loop.h
231index 1e21d3a..b776df4 100644
232--- a/libstdc++-v3/include/parallel/par_loop.h
233+++ b/libstdc++-v3/include/parallel/par_loop.h
234@@ -91,8 +91,7 @@ namespace __gnu_parallel
235 _ThreadIndex __iam = omp_get_thread_num();
236
237 // Neutral element.
238- _Result* __reduct = static_cast<_Result*>
239- (::operator new(sizeof(_Result)));
240+ _Result* __reduct;
241
242 _DifferenceType
243 __start = equally_split_point(__length, __num_threads, __iam),
244@@ -100,7 +99,7 @@ namespace __gnu_parallel
245
246 if (__start < __stop)
247 {
248- new(__reduct) _Result(__f(__o, __begin + __start));
249+ __reduct = new _Result(__f(__o, __begin + __start));
250 ++__start;
251 __constructed[__iam] = true;
252 }
253@@ -110,18 +109,26 @@ namespace __gnu_parallel
254 for (; __start < __stop; ++__start)
255 *__reduct = __r(*__reduct, __f(__o, __begin + __start));
256
257- __thread_results[__iam] = *__reduct;
258+ if (__constructed[__iam])
259+ {
260+ ::new(&__thread_results[__iam]) _Result(*__reduct);
261+ delete __reduct;
262+ }
263 } //parallel
264
265 for (_ThreadIndex __i = 0; __i < __num_threads; ++__i)
266 if (__constructed[__i])
267- __output = __r(__output, __thread_results[__i]);
268+ {
269+ __output = __r(__output, __thread_results[__i]);
270+ __thread_results[__i].~_Result();
271+ }
272
273 // Points to last element processed (needed as return value for
274 // some algorithms like transform).
275 __f._M_finish_iterator = __begin + __length;
276
277- delete[] __thread_results;
278+ ::operator delete(__thread_results);
279+
280 delete[] __constructed;
281
282 return __o;
283diff --git a/libstdc++-v3/include/parallel/partial_sum.h b/libstdc++-v3/include/parallel/partial_sum.h
284index 5513c2f..0be9881 100644
285--- a/libstdc++-v3/include/parallel/partial_sum.h
286+++ b/libstdc++-v3/include/parallel/partial_sum.h
287@@ -184,7 +184,10 @@ namespace __gnu_parallel
288 __bin_op, __sums[__iam]);
289 } //parallel
290
291+ for (_ThreadIndex __i = 0; __i < __num_threads; ++__i)
292+ __sums[__i].~_ValueType();
293 ::operator delete(__sums);
294+
295 delete[] __borders;
296
297 return __result + __n;
298diff --git a/libstdc++-v3/include/parallel/quicksort.h b/libstdc++-v3/include/parallel/quicksort.h
299index 1884eb8..1b4d598 100644
300--- a/libstdc++-v3/include/parallel/quicksort.h
301+++ b/libstdc++-v3/include/parallel/quicksort.h
302@@ -1,6 +1,6 @@
303 // -*- C++ -*-
304
305-// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
306+// Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
307 //
308 // This file is part of the GNU ISO C++ Library. This library is free
309 // software; you can redistribute it and/or modify it under the terms
310@@ -82,6 +82,8 @@ namespace __gnu_parallel
311 _DifferenceType __split = __parallel_partition(__begin, __end,
312 __pred, __num_threads);
313
314+ for (_DifferenceType __s = 0; __s < __num_samples; ++__s)
315+ __samples[__s].~_ValueType();
316 ::operator delete(__samples);
317
318 return __split;
319diff --git a/libstdc++-v3/include/parallel/random_shuffle.h b/libstdc++-v3/include/parallel/random_shuffle.h
320index bae9572..c3967c2 100644
321--- a/libstdc++-v3/include/parallel/random_shuffle.h
322+++ b/libstdc++-v3/include/parallel/random_shuffle.h
323@@ -1,6 +1,6 @@
324 // -*- C++ -*-
325
326-// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
327+// Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
328 //
329 // This file is part of the GNU ISO C++ Library. This library is free
330 // software; you can redistribute it and/or modify it under the terms
331@@ -209,7 +209,7 @@ namespace __gnu_parallel
332 _ThreadIndex __target_p = __bin_proc[__target_bin];
333
334 // Last column [__d->_M_num_threads] stays unchanged.
335- ::new(&(__temporaries[__target_p][__dist[__target_bin + 1]++]))
336+ ::new(&(__temporaries[__target_p][__dist[__target_bin + 1]++]))
337 _ValueType(*(__source + __i + __start));
338 }
339
340@@ -227,8 +227,8 @@ namespace __gnu_parallel
341 (__sd->_M_temporaries[__iam]
342 + (__b == __d->_M_bins_begin
343 ? 0 : __sd->_M_dist[__b][__d->_M_num_threads])),
344- * __end = (__sd->_M_temporaries[__iam]
345- + __sd->_M_dist[__b + 1][__d->_M_num_threads]);
346+ *__end = (__sd->_M_temporaries[__iam]
347+ + __sd->_M_dist[__b + 1][__d->_M_num_threads]);
348
349 __sequential_random_shuffle(__begin, __end, __rng);
350 std::copy(__begin, __end, __sd->_M_source + __global_offset
351@@ -236,6 +236,8 @@ namespace __gnu_parallel
352 ? 0 : __sd->_M_dist[__b][__d->_M_num_threads]));
353 }
354
355+ for (_SequenceIndex __i = 0; __i < __offset; ++__i)
356+ __sd->_M_temporaries[__iam][__i].~_ValueType();
357 ::operator delete(__sd->_M_temporaries[__iam]);
358 }
359
360@@ -501,6 +503,9 @@ namespace __gnu_parallel
361 delete[] __dist0;
362 delete[] __dist1;
363 delete[] __oracles;
364+
365+ for (_DifferenceType __i = 0; __i < __n; ++__i)
366+ __target[__i].~_ValueType();
367 ::operator delete(__target);
368 }
369 else
370diff --git a/libstdc++-v3/testsuite/26_numerics/accumulate/48750.cc b/libstdc++-v3/testsuite/26_numerics/accumulate/48750.cc
371new file mode 100644
372index 0000000..450382c
373--- /dev/null
374+++ b/libstdc++-v3/testsuite/26_numerics/accumulate/48750.cc
375@@ -0,0 +1,70 @@
376+// Copyright (C) 2011 Free Software Foundation, Inc.
377+//
378+// This file is part of the GNU ISO C++ Library. This library is free
379+// software; you can redistribute it and/or modify it under the
380+// terms of the GNU General Public License as published by the
381+// Free Software Foundation; either version 3, or (at your option)
382+// any later version.
383+
384+// This library is distributed in the hope that it will be useful,
385+// but WITHOUT ANY WARRANTY; without even the implied warranty of
386+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
387+// GNU General Public License for more details.
388+
389+// You should have received a copy of the GNU General Public License along
390+// with this library; see the file COPYING3. If not see
391+// <http://www.gnu.org/licenses/>.
392+
393+#include <vector>
394+#include <numeric>
395+
396+class NaturalParameters
397+{
398+public:
399+
400+ NaturalParameters()
401+ : m_data(2)
402+ { }
403+
404+ std::vector<double>::const_iterator
405+ begin() const
406+ { return m_data.begin(); }
407+
408+ std::vector<double>::const_iterator
409+ end() const
410+ { return m_data.begin(); }
411+
412+ NaturalParameters&
413+ operator+=(const NaturalParameters&)
414+ { return *this; }
415+
416+private:
417+ std::vector<double> m_data;
418+};
419+
420+inline
421+NaturalParameters
422+operator+(const NaturalParameters& a, const NaturalParameters& b)
423+{
424+ NaturalParameters tmp = a;
425+ return tmp += b;
426+}
427+
428+// libstdc++/48750
429+void test01()
430+{
431+ // Used to fail in parallel-mode with a segfault.
432+ for (std::size_t i = 0; i < 1000; ++i)
433+ {
434+ std::vector<NaturalParameters> ChildrenNP(1000);
435+ NaturalParameters init;
436+ NaturalParameters NP = std::accumulate(ChildrenNP.begin(),
437+ ChildrenNP.end(), init);
438+ }
439+}
440+
441+int main()
442+{
443+ test01();
444+ return 0;
445+}
446diff --git a/libstdc++-v3/testsuite/ext/profile/mutex_extensions_neg.cc b/libstdc++-v3/testsuite/ext/profile/mutex_extensions_neg.cc
447index 174a8af..c0b1f68 100644
448--- a/libstdc++-v3/testsuite/ext/profile/mutex_extensions_neg.cc
449+++ b/libstdc++-v3/testsuite/ext/profile/mutex_extensions_neg.cc
450@@ -3,6 +3,9 @@
451
452 // -*- C++ -*-
453
454+// Otherwise we may get *multiple* errors.
455+#undef _GLIBCXX_PARALLEL
456+
457 // Copyright (C) 2006, 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
458 //
459 // This file is part of the GNU ISO C++ Library. This library is free
460--
4611.7.0.4
462