Blame SOURCES/0016-Conditionalize-test-for-hashtable-bucket-sizes-on-__.patch

0fe1ac
From db8f53df0be1daeda3159c1413549ff40696c710 Mon Sep 17 00:00:00 2001
0fe1ac
From: David Malcolm <dmalcolm@redhat.com>
0fe1ac
Date: Thu, 2 Sep 2021 17:02:33 -0400
0fe1ac
Subject: [PATCH 16/17] Conditionalize test for hashtable bucket sizes on
0fe1ac
 __LIBSTDCXX_SO_VERSION >= 11
0fe1ac
0fe1ac
These tests were added upstream 2020-01-20 as part of:
0fe1ac
  libstdc++: Do not over-size hashtable buckets on range insertion
0fe1ac
    https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=6dcf042368012e2d7ce1626ee5d378bf3ad0ccfc
0fe1ac
0fe1ac
but fail when run in DTS against a system libstdc++.so from an older GCC.
0fe1ac
0fe1ac
In particular, _M_insert_unique_node from the header is using the older
0fe1ac
implementation of
0fe1ac
  std::__detail::_Prime_rehash_policy::_M_need_rehash
0fe1ac
from the dynamic library.
0fe1ac
0fe1ac
   23: 0000000000000000      0 FUNC    GLOBAL DEFAULT    UNDEF std::__detail::_Prime_rehash_policy::_M_need_rehash(unsigned long, unsigned long, unsigned long) const@GLIBCXX_3.4.18 (5)
0fe1ac
  412: 0000000000000000      0 FUNC    GLOBAL DEFAULT    UNDEF std::__detail::_Prime_rehash_policy::_M_need_rehash(unsigned long, unsigned long, unsigned long) const@@GLIBCXX_3.4.18
0fe1ac
---
0fe1ac
 .../23_containers/unordered_set/cons/bucket_hint.cc    | 10 ++++++++++
0fe1ac
 .../23_containers/unordered_set/modifiers/insert.cc    |  9 +++++++++
0fe1ac
 2 files changed, 19 insertions(+)
0fe1ac
0fe1ac
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/cons/bucket_hint.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/cons/bucket_hint.cc
0fe1ac
index a3b014a3a..af231e54e 100644
0fe1ac
--- a/libstdc++-v3/testsuite/23_containers/unordered_set/cons/bucket_hint.cc
0fe1ac
+++ b/libstdc++-v3/testsuite/23_containers/unordered_set/cons/bucket_hint.cc
0fe1ac
@@ -29,7 +29,11 @@ void test01()
0fe1ac
   a.reserve(2);
0fe1ac
 
0fe1ac
   std::unordered_set<int> b({ 0, 1, 0, 1, 0, 1, 0, 1 }, a.bucket_count());
0fe1ac
+
0fe1ac
+  // Fixed upstream in GCC 11
0fe1ac
+#if __LIBSTDCXX_SO_VERSION >= 11
0fe1ac
   VERIFY( b.bucket_count() == a.bucket_count() );
0fe1ac
+#endif
0fe1ac
 }
0fe1ac
 
0fe1ac
 void test02()
0fe1ac
@@ -40,7 +44,10 @@ void test02()
0fe1ac
   std::vector<int> v { 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 };
0fe1ac
 
0fe1ac
   std::unordered_set<int> b(v.begin(), v.end(), a.bucket_count());
0fe1ac
+  // Fixed upstream in GCC 11
0fe1ac
+#if __LIBSTDCXX_SO_VERSION >= 11
0fe1ac
   VERIFY( b.bucket_count() == a.bucket_count() );
0fe1ac
+#endif
0fe1ac
 }
0fe1ac
 
0fe1ac
 void test03()
0fe1ac
@@ -51,7 +58,10 @@ void test03()
0fe1ac
   std::forward_list<int> fl { 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 };
0fe1ac
 
0fe1ac
   std::unordered_set<int> b(fl.begin(), fl.end(), a.bucket_count());
0fe1ac
+  // Fixed upstream in GCC 11
0fe1ac
+#if __LIBSTDCXX_SO_VERSION >= 11
0fe1ac
   VERIFY( b.bucket_count() == a.bucket_count() );
0fe1ac
+#endif
0fe1ac
 }
0fe1ac
 
0fe1ac
 int main()
0fe1ac
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/modifiers/insert.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/modifiers/insert.cc
0fe1ac
index 015c2f872..aae8298ae 100644
0fe1ac
--- a/libstdc++-v3/testsuite/23_containers/unordered_set/modifiers/insert.cc
0fe1ac
+++ b/libstdc++-v3/testsuite/23_containers/unordered_set/modifiers/insert.cc
0fe1ac
@@ -30,7 +30,10 @@ void test01()
0fe1ac
 
0fe1ac
   auto bkt_count = a.bucket_count();
0fe1ac
   a.insert({ 0, 1, 0, 1, 0, 1, 0, 1 });
0fe1ac
+  // Fixed upstream in GCC 11
0fe1ac
+#if __LIBSTDCXX_SO_VERSION >= 11
0fe1ac
   VERIFY( a.bucket_count() == bkt_count );
0fe1ac
+#endif
0fe1ac
 }
0fe1ac
 
0fe1ac
 void test02()
0fe1ac
@@ -42,7 +45,10 @@ void test02()
0fe1ac
 
0fe1ac
   auto bkt_count = a.bucket_count();
0fe1ac
   a.insert(v.begin(), v.end());
0fe1ac
+  // Fixed upstream in GCC 11
0fe1ac
+#if __LIBSTDCXX_SO_VERSION >= 11
0fe1ac
   VERIFY( a.bucket_count() == bkt_count );
0fe1ac
+#endif
0fe1ac
 }
0fe1ac
 
0fe1ac
 void test03()
0fe1ac
@@ -54,7 +60,10 @@ void test03()
0fe1ac
 
0fe1ac
   auto bkt_count = a.bucket_count();
0fe1ac
   a.insert(fl.begin(), fl.end());
0fe1ac
+  // Fixed upstream in GCC 11
0fe1ac
+#if __LIBSTDCXX_SO_VERSION >= 11
0fe1ac
   VERIFY( a.bucket_count() == bkt_count );
0fe1ac
+#endif
0fe1ac
 }
0fe1ac
 
0fe1ac
 int main()
0fe1ac
-- 
0fe1ac
2.31.1
0fe1ac