mirror of https://github.com/bitcoin/bitcoin
In glib 2.13 memcpy was changed such that the way it copied bytes was reversed. This caused all sorts of issues for existing software, which depended on the existing behavior (when they should have been using memmove). See: https://sourceware.org/bugzilla/show_bug.cgi?id=12518 https://bugzilla.redhat.com/show_bug.cgi?id=638477 Now that we require glibc 2.17+ (#17538), we should be well clear of having to maintain our memcpy -> memmove aliasing, which was introduced in #4339.pull/21405/head
parent
bca5ee6f38
commit
52f0be3a93
@ -1,45 +0,0 @@
|
||||
// Copyright (c) 2009-2020 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include <config/bitcoin-config.h>
|
||||
#endif
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
extern "C" void* memcpy(void* a, const void* b, size_t c);
|
||||
void* memcpy_int(void* a, const void* b, size_t c)
|
||||
{
|
||||
return memcpy(a, b, c);
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
// trigger: Use the memcpy_int wrapper which calls our internal memcpy.
|
||||
// A direct call to memcpy may be optimized away by the compiler.
|
||||
// test: Fill an array with a sequence of integers. memcpy to a new empty array.
|
||||
// Verify that the arrays are equal. Use an odd size to decrease the odds of
|
||||
// the call being optimized away.
|
||||
template <unsigned int T>
|
||||
bool sanity_test_memcpy()
|
||||
{
|
||||
unsigned int memcpy_test[T];
|
||||
unsigned int memcpy_verify[T] = {};
|
||||
for (unsigned int i = 0; i != T; ++i)
|
||||
memcpy_test[i] = i;
|
||||
|
||||
memcpy_int(memcpy_verify, memcpy_test, sizeof(memcpy_test));
|
||||
|
||||
for (unsigned int i = 0; i != T; ++i) {
|
||||
if (memcpy_verify[i] != i)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool glibc_sanity_test()
|
||||
{
|
||||
return sanity_test_memcpy<1025>();
|
||||
}
|
Loading…
Reference in new issue