This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][libstdc++-v3 parallel mode] Fix name collision PR libstdc++/37470


Uglification will continue...

Tested x86_64-unknown-linux-gnu: No regressions

Please approve for mainline.

2008-09-18  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.

Johannes

Index: include/parallel/losertree.h
===================================================================
--- include/parallel/losertree.h	(revision 140275)
+++ include/parallel/losertree.h	(working copy)
@@ -105,7 +105,7 @@
     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 @@
     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 @@
     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 @@
     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];
Index: include/parallel/multiseq_selection.h
===================================================================
--- include/parallel/multiseq_selection.h	(revision 140275)
+++ include/parallel/multiseq_selection.h	(working copy)
@@ -183,7 +183,7 @@
 	  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 @@
 	  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
Index: include/parallel/base.h
===================================================================
--- include/parallel/base.h	(revision 140275)
+++ include/parallel/base.h	(working copy)
@@ -105,14 +105,14 @@
 
 /** @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;
     }
Index: include/parallel/random_shuffle.h
===================================================================
--- include/parallel/random_shuffle.h	(revision 140275)
+++ include/parallel/random_shuffle.h	(working copy)
@@ -249,7 +249,7 @@
     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 @@
             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 @@
       }
 #endif
 
-    int num_bits = log2(num_bins);
+    int num_bits = __log2(num_bins);
 
     if (num_bins > 1)
       {

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]