aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Singler <singler@ira.uka.de>2008-09-19 11:37:16 +0000
committerJohannes Singler <singler@gcc.gnu.org>2008-09-19 11:37:16 +0000
commitc38b84d8f108cb3317475744fcb92c41324b4291 (patch)
tree42de00f4ce674b62e3736f92e4f82d466697d3ee
parent6a7a462cbfe97638fcfe74a8c5e4b847d71f6e9d (diff)
downloadgcc-c38b84d8f108cb3317475744fcb92c41324b4291.zip
gcc-c38b84d8f108cb3317475744fcb92c41324b4291.tar.gz
gcc-c38b84d8f108cb3317475744fcb92c41324b4291.tar.bz2
re PR libstdc++/37470 (parallel/base.h log2 conflicts with math.h)
2008-09-19 Johannes Singler <singler@ira.uka.de> PR libstdc++/37470 * include/parallel/base.h: Rename log2 to __log2. (__log2) Avoid infinite loop for n <= 0, return 0. * include/parallel/losertree.h: Rename log2 to __log2. * include/parallel/multiseq_selection.h: Likewise. * include/parallel/random_shuffle.h: Likewise. From-SVN: r140490
-rw-r--r--libstdc++-v3/ChangeLog9
-rw-r--r--libstdc++-v3/include/parallel/base.h6
-rw-r--r--libstdc++-v3/include/parallel/losertree.h8
-rw-r--r--libstdc++-v3/include/parallel/multiseq_selection.h4
-rw-r--r--libstdc++-v3/include/parallel/random_shuffle.h6
5 files changed, 21 insertions, 12 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index e018ecb..99340ec 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,12 @@
+2008-09-19 Johannes Singler <singler@ira.uka.de>
+
+ PR libstdc++/37470
+ * include/parallel/base.h: Rename log2 to __log2.
+ (__log2) Avoid infinite loop for n <= 0, return 0.
+ * include/parallel/losertree.h: Rename log2 to __log2.
+ * include/parallel/multiseq_selection.h: Likewise.
+ * include/parallel/random_shuffle.h: Likewise.
+
2008-09-18 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/shared_ptr.h (__shared_count<>::
diff --git a/libstdc++-v3/include/parallel/base.h b/libstdc++-v3/include/parallel/base.h
index 45c3327..2a5dc29 100644
--- a/libstdc++-v3/include/parallel/base.h
+++ b/libstdc++-v3/include/parallel/base.h
@@ -105,14 +105,14 @@ namespace __gnu_parallel
/** @brief Calculates the rounded-down logarithm of @c n for base 2.
* @param n Argument.
- * @return Returns 0 for argument 0.
+ * @return Returns 0 for any argument <1.
*/
template<typename Size>
inline Size
- log2(Size n)
+ __log2(Size n)
{
Size k;
- for (k = 0; n != 1; n >>= 1)
+ for (k = 0; n > 1; n >>= 1)
++k;
return k;
}
diff --git a/libstdc++-v3/include/parallel/losertree.h b/libstdc++-v3/include/parallel/losertree.h
index 7e50bb1..84d5be7 100644
--- a/libstdc++-v3/include/parallel/losertree.h
+++ b/libstdc++-v3/include/parallel/losertree.h
@@ -105,7 +105,7 @@ public:
ik = _k;
// Compute log_2{k} for the Loser Tree
- _M_log_k = log2(ik - 1) + 1;
+ _M_log_k = __log2(ik - 1) + 1;
// Next greater power of 2.
k = 1 << _M_log_k;
@@ -368,7 +368,7 @@ public:
ik = _k;
// Next greater power of 2.
- k = 1 << (log2(ik - 1) + 1);
+ k = 1 << (__log2(ik - 1) + 1);
offset = k;
losers = new Loser[k * 2];
for (unsigned int i = ik - 1; i < k; i++)
@@ -579,7 +579,7 @@ public:
ik = _k;
// Next greater power of 2.
- k = 1 << (log2(ik - 1) + 1);
+ k = 1 << (__log2(ik - 1) + 1);
offset = k;
// Avoid default-constructing losers[].key
losers = static_cast<Loser*>(::operator new(2 * k * sizeof(Loser)));
@@ -815,7 +815,7 @@ public:
ik = _k;
// Next greater power of 2.
- k = 1 << (log2(ik - 1) + 1);
+ k = 1 << (__log2(ik - 1) + 1);
offset = k;
// Avoid default-constructing losers[].key
losers = new Loser[2 * k];
diff --git a/libstdc++-v3/include/parallel/multiseq_selection.h b/libstdc++-v3/include/parallel/multiseq_selection.h
index ee9214f..79078af 100644
--- a/libstdc++-v3/include/parallel/multiseq_selection.h
+++ b/libstdc++-v3/include/parallel/multiseq_selection.h
@@ -183,7 +183,7 @@ namespace __gnu_parallel
nmax = std::max(nmax, ns[i]);
}
- r = log2(nmax) + 1;
+ r = __log2(nmax) + 1;
// Pad all lists to this length, at least as long as any ns[i],
// equality iff nmax = 2^k - 1.
@@ -429,7 +429,7 @@ namespace __gnu_parallel
nmax = std::max(nmax, ns[i]);
}
- r = log2(nmax) + 1;
+ r = __log2(nmax) + 1;
// Pad all lists to this length, at least as long as any ns[i],
// equality iff nmax = 2^k - 1
diff --git a/libstdc++-v3/include/parallel/random_shuffle.h b/libstdc++-v3/include/parallel/random_shuffle.h
index e6ce95d..5e875b4 100644
--- a/libstdc++-v3/include/parallel/random_shuffle.h
+++ b/libstdc++-v3/include/parallel/random_shuffle.h
@@ -249,7 +249,7 @@ template<typename T>
if (x <= 1)
return 1;
else
- return (T)1 << (log2(x - 1) + 1);
+ return (T)1 << (__log2(x - 1) + 1);
}
/** @brief Main parallel random shuffle step.
@@ -352,7 +352,7 @@ template<typename RandomAccessIterator, typename RandomNumberGenerator>
starts = sd.starts = new difference_type[num_threads + 1];
int bin_cursor = 0;
sd.num_bins = num_bins;
- sd.num_bits = log2(num_bins);
+ sd.num_bits = __log2(num_bins);
difference_type chunk_length = n / num_threads,
split = n % num_threads, start = 0;
@@ -450,7 +450,7 @@ template<typename RandomAccessIterator, typename RandomNumberGenerator>
}
#endif
- int num_bits = log2(num_bins);
+ int num_bits = __log2(num_bins);
if (num_bins > 1)
{