Address Matt's review comments.
This commit is contained in:
@@ -101,7 +101,7 @@ namespace snmalloc
|
||||
|
||||
public:
|
||||
/**
|
||||
* Construtor. Accesses the pagemap via the C ABI accessor and casts it to
|
||||
* Constructor. Accesses the pagemap via the C ABI accessor and casts it to
|
||||
* the expected type, failing in cases of ABI mismatch.
|
||||
*/
|
||||
ExternalGlobalPagemap()
|
||||
|
||||
@@ -30,6 +30,10 @@ namespace snmalloc
|
||||
* hierarchical structure.
|
||||
*/
|
||||
bool is_flat_pagemap;
|
||||
/**
|
||||
* Number of bytes in a pointer.
|
||||
*/
|
||||
uint8_t sizeof_pointer;
|
||||
/**
|
||||
* The number of bits of the address used to index into the pagemap.
|
||||
*/
|
||||
@@ -202,7 +206,7 @@ namespace snmalloc
|
||||
* The pagemap configuration describing this instantiation of the template.
|
||||
*/
|
||||
static constexpr PagemapConfig config = {
|
||||
1, false, GRANULARITY_BITS, sizeof(T)};
|
||||
1, false, sizeof(void*), GRANULARITY_BITS, sizeof(T)};
|
||||
|
||||
/**
|
||||
* Cast a `void*` to a pointer to this template instantiation, given a
|
||||
@@ -216,6 +220,7 @@ namespace snmalloc
|
||||
{
|
||||
if (
|
||||
(c->version != 1) || (c->is_flat_pagemap) ||
|
||||
(c->sizeof_pointer == sizeof(void*)) ||
|
||||
(c->pagemap_bits != GRANULARITY_BITS) ||
|
||||
(c->size_of_entry != sizeof(T)) || (!std::is_integral_v<T>))
|
||||
{
|
||||
@@ -306,7 +311,7 @@ namespace snmalloc
|
||||
* The pagemap configuration describing this instantiation of the template.
|
||||
*/
|
||||
static constexpr PagemapConfig config = {
|
||||
1, true, GRANULARITY_BITS, sizeof(T)};
|
||||
1, true, sizeof(void*), GRANULARITY_BITS, sizeof(T)};
|
||||
|
||||
/**
|
||||
* Cast a `void*` to a pointer to this template instantiation, given a
|
||||
@@ -320,6 +325,7 @@ namespace snmalloc
|
||||
{
|
||||
if (
|
||||
(c->version != 1) || (!c->is_flat_pagemap) ||
|
||||
(c->sizeof_pointer == sizeof(void*)) ||
|
||||
(c->pagemap_bits != GRANULARITY_BITS) ||
|
||||
(c->size_of_entry != sizeof(T)) || (!std::is_integral_v<T>))
|
||||
{
|
||||
|
||||
@@ -48,8 +48,9 @@ int main()
|
||||
std::cout << "Allocated region " << oe_base << " - " << oe_end << std::endl;
|
||||
|
||||
// Call these functions to trigger asserts if the cast-to-self doesn't work.
|
||||
enclave_snmalloc_pagemap_global_get(nullptr);
|
||||
host_snmalloc_pagemap_global_get(nullptr);
|
||||
PagemapConfig *c;
|
||||
enclave_snmalloc_pagemap_global_get(&c);
|
||||
host_snmalloc_pagemap_global_get(&c);
|
||||
|
||||
auto a = host_malloc(128);
|
||||
auto b = enclave_malloc(128);
|
||||
|
||||
Reference in New Issue
Block a user