Tested x86_64-linux. Pushed to trunk.

-- >8 --

I don't see why we should rely on __builtin_memset etc. in tests. We can
just include <cstring> and use the public API.

libstdc++-v3/ChangeLog:

        * testsuite/23_containers/deque/allocator/default_init.cc: Use
        std::memset instead of __builtin_memset.
        * testsuite/23_containers/forward_list/allocator/default_init.cc:
        Likewise.
        * testsuite/23_containers/list/allocator/default_init.cc:
        Likewise.
        * testsuite/23_containers/map/allocator/default_init.cc:
        Likewise.
        * testsuite/23_containers/set/allocator/default_init.cc:
        Likewise.
        * testsuite/23_containers/unordered_map/allocator/default_init.cc:
        Likewise.
        * testsuite/23_containers/unordered_set/allocator/default_init.cc:
        Likewise.
        * testsuite/23_containers/vector/allocator/default_init.cc:
        Likewise.
        * testsuite/23_containers/vector/bool/allocator/default_init.cc:
        Likewise.
        * testsuite/29_atomics/atomic/compare_exchange_padding.cc:
        Likewise.
        * testsuite/util/atomic/wait_notify_util.h: Likewise.
---
 .../23_containers/deque/allocator/default_init.cc     |  5 +++--
 .../forward_list/allocator/default_init.cc            |  5 +++--
 .../23_containers/list/allocator/default_init.cc      |  5 +++--
 .../23_containers/map/allocator/default_init.cc       |  5 +++--
 .../23_containers/set/allocator/default_init.cc       |  5 +++--
 .../unordered_map/allocator/default_init.cc           |  5 +++--
 .../unordered_set/allocator/default_init.cc           |  5 +++--
 .../23_containers/vector/allocator/default_init.cc    |  5 +++--
 .../vector/bool/allocator/default_init.cc             |  5 +++--
 .../29_atomics/atomic/compare_exchange_padding.cc     |  5 +++--
 libstdc++-v3/testsuite/util/atomic/wait_notify_util.h | 11 +++++------
 11 files changed, 35 insertions(+), 26 deletions(-)

diff --git 
a/libstdc++-v3/testsuite/23_containers/deque/allocator/default_init.cc 
b/libstdc++-v3/testsuite/23_containers/deque/allocator/default_init.cc
index ce8c6ba8114..63ada98d048 100644
--- a/libstdc++-v3/testsuite/23_containers/deque/allocator/default_init.cc
+++ b/libstdc++-v3/testsuite/23_containers/deque/allocator/default_init.cc
@@ -22,6 +22,7 @@
 #include <testsuite_hooks.h>
 #include <testsuite_allocator.h>
 
+#include <cstring>
 #include <ext/aligned_buffer.h>
 
 using T = int;
@@ -34,7 +35,7 @@ void test01()
   typedef std::deque<T, alloc_type> test_type;
 
   __gnu_cxx::__aligned_buffer<test_type> buf;
-  __builtin_memset(buf._M_addr(), ~0, sizeof(test_type));
+  std::memset(buf._M_addr(), ~0, sizeof(test_type));
 
   test_type *tmp = ::new(buf._M_addr()) test_type;
 
@@ -49,7 +50,7 @@ void test02()
   typedef std::deque<T, alloc_type> test_type;
 
   __gnu_cxx::__aligned_buffer<test_type> buf;
-  __builtin_memset(buf._M_addr(), ~0, sizeof(test_type));
+  std::memset(buf._M_addr(), ~0, sizeof(test_type));
 
   test_type *tmp = ::new(buf._M_addr()) test_type();
 
diff --git 
a/libstdc++-v3/testsuite/23_containers/forward_list/allocator/default_init.cc 
b/libstdc++-v3/testsuite/23_containers/forward_list/allocator/default_init.cc
index 1865e39a885..d8a8bdf05a9 100644
--- 
a/libstdc++-v3/testsuite/23_containers/forward_list/allocator/default_init.cc
+++ 
b/libstdc++-v3/testsuite/23_containers/forward_list/allocator/default_init.cc
@@ -22,6 +22,7 @@
 #include <testsuite_hooks.h>
 #include <testsuite_allocator.h>
 
+#include <cstring>
 #include <ext/aligned_buffer.h>
 
 using T = int;
@@ -34,7 +35,7 @@ void test01()
   typedef std::forward_list<T, alloc_type> test_type;
 
   __gnu_cxx::__aligned_buffer<test_type> buf;
-  __builtin_memset(buf._M_addr(), ~0, sizeof(test_type));
+  std::memset(buf._M_addr(), ~0, sizeof(test_type));
 
   test_type *tmp = ::new(buf._M_addr()) test_type;
 
@@ -49,7 +50,7 @@ void test02()
   typedef std::forward_list<T, alloc_type> test_type;
 
   __gnu_cxx::__aligned_buffer<test_type> buf;
-  __builtin_memset(buf._M_addr(), ~0, sizeof(test_type));
+  std::memset(buf._M_addr(), ~0, sizeof(test_type));
 
   test_type *tmp = ::new(buf._M_addr()) test_type();
 
diff --git 
a/libstdc++-v3/testsuite/23_containers/list/allocator/default_init.cc 
b/libstdc++-v3/testsuite/23_containers/list/allocator/default_init.cc
index ab19ca7070c..cffad227bc0 100644
--- a/libstdc++-v3/testsuite/23_containers/list/allocator/default_init.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/allocator/default_init.cc
@@ -22,6 +22,7 @@
 #include <testsuite_hooks.h>
 #include <testsuite_allocator.h>
 
+#include <cstring>
 #include <ext/aligned_buffer.h>
 
 using T = int;
@@ -34,7 +35,7 @@ void test01()
   typedef std::list<T, alloc_type> test_type;
 
   __gnu_cxx::__aligned_buffer<test_type> buf;
-  __builtin_memset(buf._M_addr(), ~0, sizeof(test_type));
+  std::memset(buf._M_addr(), ~0, sizeof(test_type));
 
   VERIFY( buf._M_ptr()->get_allocator().state != 0 );
 
@@ -51,7 +52,7 @@ void test02()
   typedef std::list<T, alloc_type> test_type;
 
   __gnu_cxx::__aligned_buffer<test_type> buf;
-  __builtin_memset(buf._M_addr(), ~0, sizeof(test_type));
+  std::memset(buf._M_addr(), ~0, sizeof(test_type));
 
   VERIFY( buf._M_ptr()->get_allocator().state != 0 );
 
diff --git a/libstdc++-v3/testsuite/23_containers/map/allocator/default_init.cc 
b/libstdc++-v3/testsuite/23_containers/map/allocator/default_init.cc
index 15fa1bfcf92..6b34227a5d0 100644
--- a/libstdc++-v3/testsuite/23_containers/map/allocator/default_init.cc
+++ b/libstdc++-v3/testsuite/23_containers/map/allocator/default_init.cc
@@ -22,6 +22,7 @@
 #include <testsuite_hooks.h>
 #include <testsuite_allocator.h>
 
+#include <cstring>
 #include <ext/aligned_buffer.h>
 
 using T = int;
@@ -34,7 +35,7 @@ void test01()
   typedef std::map<T, T, std::less<T>, alloc_type> test_type;
 
   __gnu_cxx::__aligned_buffer<test_type> buf;
-  __builtin_memset(buf._M_addr(), ~0, sizeof(test_type));
+  std::memset(buf._M_addr(), ~0, sizeof(test_type));
 
   test_type *tmp = ::new(buf._M_addr()) test_type;
 
@@ -49,7 +50,7 @@ void test02()
   typedef std::map<T, T, std::less<T>, alloc_type> test_type;
 
   __gnu_cxx::__aligned_buffer<test_type> buf;
-  __builtin_memset(buf._M_addr(), ~0, sizeof(test_type));
+  std::memset(buf._M_addr(), ~0, sizeof(test_type));
 
   test_type *tmp = ::new(buf._M_addr()) test_type();
 
diff --git a/libstdc++-v3/testsuite/23_containers/set/allocator/default_init.cc 
b/libstdc++-v3/testsuite/23_containers/set/allocator/default_init.cc
index 553a93422c0..1976bed445a 100644
--- a/libstdc++-v3/testsuite/23_containers/set/allocator/default_init.cc
+++ b/libstdc++-v3/testsuite/23_containers/set/allocator/default_init.cc
@@ -22,6 +22,7 @@
 #include <testsuite_hooks.h>
 #include <testsuite_allocator.h>
 
+#include <cstring>
 #include <ext/aligned_buffer.h>
 
 using T = int;
@@ -34,7 +35,7 @@ void test01()
   typedef std::set<T, std::less<T>, alloc_type> test_type;
 
   __gnu_cxx::__aligned_buffer<test_type> buf;
-  __builtin_memset(buf._M_addr(), ~0, sizeof(test_type));
+  std::memset(buf._M_addr(), ~0, sizeof(test_type));
 
   test_type *tmp = ::new(buf._M_addr()) test_type;
 
@@ -49,7 +50,7 @@ void test02()
   typedef std::set<T, std::less<T>, alloc_type> test_type;
 
   __gnu_cxx::__aligned_buffer<test_type> buf;
-  __builtin_memset(buf._M_addr(), ~0, sizeof(test_type));
+  std::memset(buf._M_addr(), ~0, sizeof(test_type));
 
   test_type *tmp = ::new(buf._M_addr()) test_type();
 
diff --git 
a/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/default_init.cc 
b/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/default_init.cc
index d86d2537a16..eb3c177f2b4 100644
--- 
a/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/default_init.cc
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/default_init.cc
@@ -22,6 +22,7 @@
 #include <testsuite_hooks.h>
 #include <testsuite_allocator.h>
 
+#include <cstring>
 #include <ext/aligned_buffer.h>
 
 using T = int;
@@ -35,7 +36,7 @@ void test01()
                             alloc_type> test_type;
 
   __gnu_cxx::__aligned_buffer<test_type> buf;
-  __builtin_memset(buf._M_addr(), ~0, sizeof(test_type));
+  std::memset(buf._M_addr(), ~0, sizeof(test_type));
 
   test_type *tmp = ::new(buf._M_addr()) test_type;
 
@@ -51,7 +52,7 @@ void test02()
                             alloc_type> test_type;
 
   __gnu_cxx::__aligned_buffer<test_type> buf;
-  __builtin_memset(buf._M_addr(), ~0, sizeof(test_type));
+  std::memset(buf._M_addr(), ~0, sizeof(test_type));
 
   test_type *tmp = ::new(buf._M_addr()) test_type();
 
diff --git 
a/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/default_init.cc 
b/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/default_init.cc
index a86eb987e57..cff8d74a8b2 100644
--- 
a/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/default_init.cc
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/default_init.cc
@@ -22,6 +22,7 @@
 #include <testsuite_hooks.h>
 #include <testsuite_allocator.h>
 
+#include <cstring>
 #include <ext/aligned_buffer.h>
 
 using T = int;
@@ -35,7 +36,7 @@ void test01()
                             alloc_type> test_type;
 
   __gnu_cxx::__aligned_buffer<test_type> buf;
-  __builtin_memset(buf._M_addr(), ~0, sizeof(test_type));
+  std::memset(buf._M_addr(), ~0, sizeof(test_type));
 
   test_type *tmp = ::new(buf._M_addr()) test_type;
 
@@ -51,7 +52,7 @@ void test02()
                             alloc_type> test_type;
 
   __gnu_cxx::__aligned_buffer<test_type> buf;
-  __builtin_memset(buf._M_addr(), ~0, sizeof(test_type));
+  std::memset(buf._M_addr(), ~0, sizeof(test_type));
 
   test_type *tmp = ::new(buf._M_addr()) test_type();
 
diff --git 
a/libstdc++-v3/testsuite/23_containers/vector/allocator/default_init.cc 
b/libstdc++-v3/testsuite/23_containers/vector/allocator/default_init.cc
index 1e69f6382c4..ae631da13a4 100644
--- a/libstdc++-v3/testsuite/23_containers/vector/allocator/default_init.cc
+++ b/libstdc++-v3/testsuite/23_containers/vector/allocator/default_init.cc
@@ -22,6 +22,7 @@
 #include <testsuite_hooks.h>
 #include <testsuite_allocator.h>
 
+#include <cstring>
 #include <ext/aligned_buffer.h>
 
 using T = int;
@@ -34,7 +35,7 @@ void test01()
   typedef std::vector<T, alloc_type> test_type;
 
   __gnu_cxx::__aligned_buffer<test_type> buf;
-  __builtin_memset(buf._M_addr(), ~0, sizeof(test_type));
+  std::memset(buf._M_addr(), ~0, sizeof(test_type));
 
   test_type *tmp = ::new(buf._M_addr()) test_type;
 
@@ -49,7 +50,7 @@ void test02()
   typedef std::vector<T, alloc_type> test_type;
 
   __gnu_cxx::__aligned_buffer<test_type> buf;
-  __builtin_memset(buf._M_addr(), ~0, sizeof(test_type));
+  std::memset(buf._M_addr(), ~0, sizeof(test_type));
 
   test_type *tmp = ::new(buf._M_addr()) test_type();
 
diff --git 
a/libstdc++-v3/testsuite/23_containers/vector/bool/allocator/default_init.cc 
b/libstdc++-v3/testsuite/23_containers/vector/bool/allocator/default_init.cc
index 5c4d60990e1..1bd69f25685 100644
--- a/libstdc++-v3/testsuite/23_containers/vector/bool/allocator/default_init.cc
+++ b/libstdc++-v3/testsuite/23_containers/vector/bool/allocator/default_init.cc
@@ -22,6 +22,7 @@
 #include <testsuite_hooks.h>
 #include <testsuite_allocator.h>
 
+#include <cstring>
 #include <ext/aligned_buffer.h>
 
 using T = bool;
@@ -34,7 +35,7 @@ void test01()
   typedef std::vector<T, alloc_type> test_type;
 
   __gnu_cxx::__aligned_buffer<test_type> buf;
-  __builtin_memset(buf._M_addr(), ~0, sizeof(test_type));
+  std::memset(buf._M_addr(), ~0, sizeof(test_type));
 
   test_type *tmp = ::new(buf._M_addr()) test_type;
 
@@ -49,7 +50,7 @@ void test02()
   typedef std::vector<T, alloc_type> test_type;
 
   __gnu_cxx::__aligned_buffer<test_type> buf;
-  __builtin_memset(buf._M_addr(), ~0, sizeof(test_type));
+  std::memset(buf._M_addr(), ~0, sizeof(test_type));
 
   test_type *tmp = ::new(buf._M_addr()) test_type();
 
diff --git 
a/libstdc++-v3/testsuite/29_atomics/atomic/compare_exchange_padding.cc 
b/libstdc++-v3/testsuite/29_atomics/atomic/compare_exchange_padding.cc
index 859629e625f..2f18d426e7f 100644
--- a/libstdc++-v3/testsuite/29_atomics/atomic/compare_exchange_padding.cc
+++ b/libstdc++-v3/testsuite/29_atomics/atomic/compare_exchange_padding.cc
@@ -3,6 +3,7 @@
 // { dg-add-options libatomic }
 
 #include <atomic>
+#include <cstring>
 
 #include <testsuite_hooks.h>
 
@@ -10,11 +11,11 @@ struct S { char c; short s; };
 
 void __attribute__((noinline,noipa))
 fill_struct(S& s)
-{ __builtin_memset(&s, 0xff, sizeof(S)); }
+{ std::memset(&s, 0xff, sizeof(S)); }
 
 bool
 compare_struct(const S& a, const S& b)
-{ return __builtin_memcmp(&a, &b, sizeof(S)) == 0; }
+{ return std::memcmp(&a, &b, sizeof(S)) == 0; }
 
 int
 main ()
diff --git a/libstdc++-v3/testsuite/util/atomic/wait_notify_util.h 
b/libstdc++-v3/testsuite/util/atomic/wait_notify_util.h
index eb890113713..9e96d3cd1bd 100644
--- a/libstdc++-v3/testsuite/util/atomic/wait_notify_util.h
+++ b/libstdc++-v3/testsuite/util/atomic/wait_notify_util.h
@@ -21,11 +21,10 @@
 #include <concepts>
 #include <mutex>
 #include <thread>
+#include <cstring>
 
 #include <testsuite_hooks.h>
 
-#include <iostream>
-
 template<typename Tp>
 Tp check_wait_notify(Tp val1, Tp val2)
   requires std::equality_comparable<Tp>
@@ -76,7 +75,7 @@ Tp check_wait_notify(Tp val1, Tp val2)
                  a.wait(val1);
                  auto v = a.load();
                  // TODO this needs to zero padding bits when we can do that
-                 if (__builtin_memcmp(&v, &val2, sizeof(Tp)) != 0)
+                 if (std::memcmp(&v, &val2, sizeof(Tp)) != 0)
                    a = val1;
                });
   cv.wait(l);
@@ -137,7 +136,7 @@ Tp check_atomic_wait_notify(Tp val1, Tp val2)
                  std::atomic_wait(&a, val1);
                  auto v = a.load();
                  // TODO this needs to zero padding bits when we can do that
-                 if (__builtin_memcmp(&v, &val2, sizeof(Tp)) != 0)
+                 if (std::memcmp(&v, &val2, sizeof(Tp)) != 0)
                    a = val1;
                });
   cv.wait(l);
@@ -163,13 +162,13 @@ struct check
       {
        // TODO this needs to zero padding bits when we can do that
        auto v = check_wait_notify(a, b);
-       VERIFY( __builtin_memcmp(&v, &b, sizeof(Tp)) == 0 );
+       VERIFY( std::memcmp(&v, &b, sizeof(Tp)) == 0 );
       }
 
       {
        // TODO this needs to zero padding bits when we can do that
        auto v = check_atomic_wait_notify(a, b);
-       VERIFY( __builtin_memcmp(&v, &b, sizeof(Tp)) == 0);
+       VERIFY( std::memcmp(&v, &b, sizeof(Tp)) == 0);
       }
     }
   }
-- 
2.43.2

Reply via email to