Minor update to clangformat file. (#694)

This commit is contained in:
Matthew Parkinson
2024-11-22 12:40:16 +00:00
committed by GitHub
parent 45dbdb00af
commit 69e280c331
33 changed files with 60 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ namespace snmalloc
using Alloc = snmalloc::LocalAllocator<snmalloc::StandardConfigClientMeta<
ArrayClientMetaDataProvider<std::atomic<size_t>>>>;
}
#define SNMALLOC_PROVIDE_OWN_CONFIG
#include <snmalloc/snmalloc.h>

View File

@@ -17,6 +17,7 @@ int main()
// Specify type of allocator
# define SNMALLOC_PROVIDE_OWN_CONFIG
namespace snmalloc
{
class CustomConfig : public CommonConfig

View File

@@ -27,6 +27,7 @@ namespace snmalloc
using Alloc = snmalloc::LocalAllocator<snmalloc::StandardConfigClientMeta<
ArrayClientMetaDataProvider<std::atomic<size_t>>>>;
}
# define SNMALLOC_PROVIDE_OWN_CONFIG
# include <snmalloc/snmalloc.h>

View File

@@ -12,10 +12,13 @@
using namespace snmalloc;
static constexpr size_t GRANULARITY_BITS = 20;
struct T
{
size_t v = 99;
T(size_t v) : v(v) {}
T() {}
};

View File

@@ -22,28 +22,36 @@ struct NodeRef
static constexpr size_t offset = 10000;
size_t* ptr;
constexpr NodeRef(size_t* p) : ptr(p) {}
constexpr NodeRef() : ptr(nullptr) {}
constexpr NodeRef(const NodeRef& other) : ptr(other.ptr) {}
constexpr NodeRef(NodeRef&& other) : ptr(other.ptr) {}
bool operator!=(const NodeRef& other) const
{
return ptr != other.ptr;
}
NodeRef& operator=(const NodeRef& other)
{
ptr = other.ptr;
return *this;
}
void set(uint16_t val)
{
*ptr = ((size_t(val) + offset) << 1) + (*ptr & 1);
}
explicit operator uint16_t()
{
return uint16_t((*ptr >> 1) - offset);
}
explicit operator size_t*()
{
return ptr;

View File

@@ -25,6 +25,7 @@ namespace
{
SNMALLOC_CHECK(0 && "Should never be called!");
}
/**
* Sandbox class. Allocates a memory region and an allocator that can
* allocate into this from the outside.

View File

@@ -10,6 +10,7 @@
// Specify type of allocator
#define SNMALLOC_PROVIDE_OWN_CONFIG
namespace snmalloc
{
using CustomGlobals = FixedRangeConfig<PALNoAlloc<DefaultPal>>;

View File

@@ -30,6 +30,7 @@ extern "C" void* enclave_malloc(size_t);
extern "C" void enclave_free(void*);
using namespace snmalloc;
int main()
{
setup();

View File

@@ -46,10 +46,12 @@ void chatty(const char* p, ...)
struct MyAlloc
{
MyAlloc() {}
void* alloc(size_t sz)
{
return malloc(sz);
}
void dealloc(void* p)
{
free(p);
@@ -59,11 +61,14 @@ struct MyAlloc
struct MyAlloc
{
snmalloc::Alloc& a;
MyAlloc() : a(ThreadAlloc::get()) {}
void* alloc(size_t sz)
{
return a.alloc(sz);
}
void dealloc(void* p)
{
a.dealloc(p);

View File

@@ -97,12 +97,14 @@ void setup()
}
# else
# include <signal.h>
void error_handle(int signal)
{
snmalloc::UNUSED(signal);
snmalloc::error("Seg Fault");
_exit(1);
}
void setup()
{
signal(SIGSEGV, error_handle);