aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2024-03-01 17:40:22 +0000
committerJonathan Wakely <jwakely@redhat.com>2024-03-07 20:55:25 +0000
commit709d8474bcc50737a74f5d6d4d43462f6f125b64 (patch)
treebb272bfb1aac2b0b7ac628cfa802a67d37ef4541
parent24a2b5def06940f3f181418a439c408388f7eb56 (diff)
downloadgcc-709d8474bcc50737a74f5d6d4d43462f6f125b64.zip
gcc-709d8474bcc50737a74f5d6d4d43462f6f125b64.tar.gz
gcc-709d8474bcc50737a74f5d6d4d43462f6f125b64.tar.bz2
libstdc++: Replace unnecessary uses of built-ins in testsuite
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.
-rw-r--r--libstdc++-v3/testsuite/23_containers/deque/allocator/default_init.cc5
-rw-r--r--libstdc++-v3/testsuite/23_containers/forward_list/allocator/default_init.cc5
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/allocator/default_init.cc5
-rw-r--r--libstdc++-v3/testsuite/23_containers/map/allocator/default_init.cc5
-rw-r--r--libstdc++-v3/testsuite/23_containers/set/allocator/default_init.cc5
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_map/allocator/default_init.cc5
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_set/allocator/default_init.cc5
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/allocator/default_init.cc5
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/bool/allocator/default_init.cc5
-rw-r--r--libstdc++-v3/testsuite/29_atomics/atomic/compare_exchange_padding.cc5
-rw-r--r--libstdc++-v3/testsuite/util/atomic/wait_notify_util.h11
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 ce8c6ba..63ada98 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 1865e39..d8a8bdf 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 ab19ca7..cffad22 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 15fa1bf..6b34227 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 553a934..1976bed 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 d86d253..eb3c177 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 a86eb98..cff8d74 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 1e69f63..ae631da 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 5c4d609..1bd69f2 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 859629e..2f18d42 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 eb89011..9e96d3c 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);
}
}
}