Refactor memcpy to allow different versions. (#472)

Expose a memcpy.h that contains all of the bits of memcpy and clean up
the bounds checks header so that versions with both read and write
checks can coexist.
This commit is contained in:
David Chisnall
2022-03-04 13:33:11 +00:00
committed by GitHub
parent cf9b6290c7
commit 18ccfdecac
5 changed files with 294 additions and 285 deletions

View File

@@ -35,6 +35,8 @@ int main()
# include <stdlib.h>
# include <string.h>
using namespace snmalloc;
/**
* Jump buffer used to jump out of `abort()` for recoverable errors.
*/
@@ -84,7 +86,8 @@ void check_size(size_t size)
{
dst[i] = 0;
}
my_memcpy(dst, src, sz);
void* ret = my_memcpy(dst, src, sz);
EXPECT(ret == dst, "Return value should be {}, was {}", dst, ret);
for (size_t i = 0; i < sz; ++i)
{
if (dst[i] != static_cast<unsigned char>(i))

View File

@@ -1,11 +1,11 @@
#include "mem/memcpy.h"
#include <test/measuretime.h>
#include <test/opt.h>
#define SNMALLOC_NAME_MANGLE(a) our_##a
#include "override/memcpy.cc"
#include <vector>
using namespace snmalloc;
struct Shape
{
void* object;