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.
This commit is contained in:
parent
24a2b5def0
commit
709d8474bc
11 changed files with 35 additions and 26 deletions
|
@ -22,6 +22,7 @@
|
||||||
#include <testsuite_hooks.h>
|
#include <testsuite_hooks.h>
|
||||||
#include <testsuite_allocator.h>
|
#include <testsuite_allocator.h>
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
#include <ext/aligned_buffer.h>
|
#include <ext/aligned_buffer.h>
|
||||||
|
|
||||||
using T = int;
|
using T = int;
|
||||||
|
@ -34,7 +35,7 @@ void test01()
|
||||||
typedef std::deque<T, alloc_type> test_type;
|
typedef std::deque<T, alloc_type> test_type;
|
||||||
|
|
||||||
__gnu_cxx::__aligned_buffer<test_type> buf;
|
__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;
|
test_type *tmp = ::new(buf._M_addr()) test_type;
|
||||||
|
|
||||||
|
@ -49,7 +50,7 @@ void test02()
|
||||||
typedef std::deque<T, alloc_type> test_type;
|
typedef std::deque<T, alloc_type> test_type;
|
||||||
|
|
||||||
__gnu_cxx::__aligned_buffer<test_type> buf;
|
__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();
|
test_type *tmp = ::new(buf._M_addr()) test_type();
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <testsuite_hooks.h>
|
#include <testsuite_hooks.h>
|
||||||
#include <testsuite_allocator.h>
|
#include <testsuite_allocator.h>
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
#include <ext/aligned_buffer.h>
|
#include <ext/aligned_buffer.h>
|
||||||
|
|
||||||
using T = int;
|
using T = int;
|
||||||
|
@ -34,7 +35,7 @@ void test01()
|
||||||
typedef std::forward_list<T, alloc_type> test_type;
|
typedef std::forward_list<T, alloc_type> test_type;
|
||||||
|
|
||||||
__gnu_cxx::__aligned_buffer<test_type> buf;
|
__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;
|
test_type *tmp = ::new(buf._M_addr()) test_type;
|
||||||
|
|
||||||
|
@ -49,7 +50,7 @@ void test02()
|
||||||
typedef std::forward_list<T, alloc_type> test_type;
|
typedef std::forward_list<T, alloc_type> test_type;
|
||||||
|
|
||||||
__gnu_cxx::__aligned_buffer<test_type> buf;
|
__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();
|
test_type *tmp = ::new(buf._M_addr()) test_type();
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <testsuite_hooks.h>
|
#include <testsuite_hooks.h>
|
||||||
#include <testsuite_allocator.h>
|
#include <testsuite_allocator.h>
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
#include <ext/aligned_buffer.h>
|
#include <ext/aligned_buffer.h>
|
||||||
|
|
||||||
using T = int;
|
using T = int;
|
||||||
|
@ -34,7 +35,7 @@ void test01()
|
||||||
typedef std::list<T, alloc_type> test_type;
|
typedef std::list<T, alloc_type> test_type;
|
||||||
|
|
||||||
__gnu_cxx::__aligned_buffer<test_type> buf;
|
__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 );
|
VERIFY( buf._M_ptr()->get_allocator().state != 0 );
|
||||||
|
|
||||||
|
@ -51,7 +52,7 @@ void test02()
|
||||||
typedef std::list<T, alloc_type> test_type;
|
typedef std::list<T, alloc_type> test_type;
|
||||||
|
|
||||||
__gnu_cxx::__aligned_buffer<test_type> buf;
|
__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 );
|
VERIFY( buf._M_ptr()->get_allocator().state != 0 );
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <testsuite_hooks.h>
|
#include <testsuite_hooks.h>
|
||||||
#include <testsuite_allocator.h>
|
#include <testsuite_allocator.h>
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
#include <ext/aligned_buffer.h>
|
#include <ext/aligned_buffer.h>
|
||||||
|
|
||||||
using T = int;
|
using T = int;
|
||||||
|
@ -34,7 +35,7 @@ void test01()
|
||||||
typedef std::map<T, T, std::less<T>, alloc_type> test_type;
|
typedef std::map<T, T, std::less<T>, alloc_type> test_type;
|
||||||
|
|
||||||
__gnu_cxx::__aligned_buffer<test_type> buf;
|
__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;
|
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;
|
typedef std::map<T, T, std::less<T>, alloc_type> test_type;
|
||||||
|
|
||||||
__gnu_cxx::__aligned_buffer<test_type> buf;
|
__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();
|
test_type *tmp = ::new(buf._M_addr()) test_type();
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <testsuite_hooks.h>
|
#include <testsuite_hooks.h>
|
||||||
#include <testsuite_allocator.h>
|
#include <testsuite_allocator.h>
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
#include <ext/aligned_buffer.h>
|
#include <ext/aligned_buffer.h>
|
||||||
|
|
||||||
using T = int;
|
using T = int;
|
||||||
|
@ -34,7 +35,7 @@ void test01()
|
||||||
typedef std::set<T, std::less<T>, alloc_type> test_type;
|
typedef std::set<T, std::less<T>, alloc_type> test_type;
|
||||||
|
|
||||||
__gnu_cxx::__aligned_buffer<test_type> buf;
|
__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;
|
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;
|
typedef std::set<T, std::less<T>, alloc_type> test_type;
|
||||||
|
|
||||||
__gnu_cxx::__aligned_buffer<test_type> buf;
|
__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();
|
test_type *tmp = ::new(buf._M_addr()) test_type();
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <testsuite_hooks.h>
|
#include <testsuite_hooks.h>
|
||||||
#include <testsuite_allocator.h>
|
#include <testsuite_allocator.h>
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
#include <ext/aligned_buffer.h>
|
#include <ext/aligned_buffer.h>
|
||||||
|
|
||||||
using T = int;
|
using T = int;
|
||||||
|
@ -35,7 +36,7 @@ void test01()
|
||||||
alloc_type> test_type;
|
alloc_type> test_type;
|
||||||
|
|
||||||
__gnu_cxx::__aligned_buffer<test_type> buf;
|
__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;
|
test_type *tmp = ::new(buf._M_addr()) test_type;
|
||||||
|
|
||||||
|
@ -51,7 +52,7 @@ void test02()
|
||||||
alloc_type> test_type;
|
alloc_type> test_type;
|
||||||
|
|
||||||
__gnu_cxx::__aligned_buffer<test_type> buf;
|
__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();
|
test_type *tmp = ::new(buf._M_addr()) test_type();
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <testsuite_hooks.h>
|
#include <testsuite_hooks.h>
|
||||||
#include <testsuite_allocator.h>
|
#include <testsuite_allocator.h>
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
#include <ext/aligned_buffer.h>
|
#include <ext/aligned_buffer.h>
|
||||||
|
|
||||||
using T = int;
|
using T = int;
|
||||||
|
@ -35,7 +36,7 @@ void test01()
|
||||||
alloc_type> test_type;
|
alloc_type> test_type;
|
||||||
|
|
||||||
__gnu_cxx::__aligned_buffer<test_type> buf;
|
__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;
|
test_type *tmp = ::new(buf._M_addr()) test_type;
|
||||||
|
|
||||||
|
@ -51,7 +52,7 @@ void test02()
|
||||||
alloc_type> test_type;
|
alloc_type> test_type;
|
||||||
|
|
||||||
__gnu_cxx::__aligned_buffer<test_type> buf;
|
__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();
|
test_type *tmp = ::new(buf._M_addr()) test_type();
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <testsuite_hooks.h>
|
#include <testsuite_hooks.h>
|
||||||
#include <testsuite_allocator.h>
|
#include <testsuite_allocator.h>
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
#include <ext/aligned_buffer.h>
|
#include <ext/aligned_buffer.h>
|
||||||
|
|
||||||
using T = int;
|
using T = int;
|
||||||
|
@ -34,7 +35,7 @@ void test01()
|
||||||
typedef std::vector<T, alloc_type> test_type;
|
typedef std::vector<T, alloc_type> test_type;
|
||||||
|
|
||||||
__gnu_cxx::__aligned_buffer<test_type> buf;
|
__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;
|
test_type *tmp = ::new(buf._M_addr()) test_type;
|
||||||
|
|
||||||
|
@ -49,7 +50,7 @@ void test02()
|
||||||
typedef std::vector<T, alloc_type> test_type;
|
typedef std::vector<T, alloc_type> test_type;
|
||||||
|
|
||||||
__gnu_cxx::__aligned_buffer<test_type> buf;
|
__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();
|
test_type *tmp = ::new(buf._M_addr()) test_type();
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <testsuite_hooks.h>
|
#include <testsuite_hooks.h>
|
||||||
#include <testsuite_allocator.h>
|
#include <testsuite_allocator.h>
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
#include <ext/aligned_buffer.h>
|
#include <ext/aligned_buffer.h>
|
||||||
|
|
||||||
using T = bool;
|
using T = bool;
|
||||||
|
@ -34,7 +35,7 @@ void test01()
|
||||||
typedef std::vector<T, alloc_type> test_type;
|
typedef std::vector<T, alloc_type> test_type;
|
||||||
|
|
||||||
__gnu_cxx::__aligned_buffer<test_type> buf;
|
__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;
|
test_type *tmp = ::new(buf._M_addr()) test_type;
|
||||||
|
|
||||||
|
@ -49,7 +50,7 @@ void test02()
|
||||||
typedef std::vector<T, alloc_type> test_type;
|
typedef std::vector<T, alloc_type> test_type;
|
||||||
|
|
||||||
__gnu_cxx::__aligned_buffer<test_type> buf;
|
__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();
|
test_type *tmp = ::new(buf._M_addr()) test_type();
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
// { dg-add-options libatomic }
|
// { dg-add-options libatomic }
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
#include <testsuite_hooks.h>
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
@ -10,11 +11,11 @@ struct S { char c; short s; };
|
||||||
|
|
||||||
void __attribute__((noinline,noipa))
|
void __attribute__((noinline,noipa))
|
||||||
fill_struct(S& s)
|
fill_struct(S& s)
|
||||||
{ __builtin_memset(&s, 0xff, sizeof(S)); }
|
{ std::memset(&s, 0xff, sizeof(S)); }
|
||||||
|
|
||||||
bool
|
bool
|
||||||
compare_struct(const S& a, const S& b)
|
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
|
int
|
||||||
main ()
|
main ()
|
||||||
|
|
|
@ -21,11 +21,10 @@
|
||||||
#include <concepts>
|
#include <concepts>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
#include <testsuite_hooks.h>
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
template<typename Tp>
|
template<typename Tp>
|
||||||
Tp check_wait_notify(Tp val1, Tp val2)
|
Tp check_wait_notify(Tp val1, Tp val2)
|
||||||
requires std::equality_comparable<Tp>
|
requires std::equality_comparable<Tp>
|
||||||
|
@ -76,7 +75,7 @@ Tp check_wait_notify(Tp val1, Tp val2)
|
||||||
a.wait(val1);
|
a.wait(val1);
|
||||||
auto v = a.load();
|
auto v = a.load();
|
||||||
// TODO this needs to zero padding bits when we can do that
|
// 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;
|
a = val1;
|
||||||
});
|
});
|
||||||
cv.wait(l);
|
cv.wait(l);
|
||||||
|
@ -137,7 +136,7 @@ Tp check_atomic_wait_notify(Tp val1, Tp val2)
|
||||||
std::atomic_wait(&a, val1);
|
std::atomic_wait(&a, val1);
|
||||||
auto v = a.load();
|
auto v = a.load();
|
||||||
// TODO this needs to zero padding bits when we can do that
|
// 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;
|
a = val1;
|
||||||
});
|
});
|
||||||
cv.wait(l);
|
cv.wait(l);
|
||||||
|
@ -163,13 +162,13 @@ struct check
|
||||||
{
|
{
|
||||||
// TODO this needs to zero padding bits when we can do that
|
// TODO this needs to zero padding bits when we can do that
|
||||||
auto v = check_wait_notify(a, b);
|
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
|
// TODO this needs to zero padding bits when we can do that
|
||||||
auto v = check_atomic_wait_notify(a, b);
|
auto v = check_atomic_wait_notify(a, b);
|
||||||
VERIFY( __builtin_memcmp(&v, &b, sizeof(Tp)) == 0);
|
VERIFY( std::memcmp(&v, &b, sizeof(Tp)) == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue