Address Matt's review comments.

This commit is contained in:
David Chisnall
2019-04-11 17:08:16 +01:00
parent 785766b129
commit 9b3641df91
3 changed files with 12 additions and 5 deletions

View File

@@ -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()

View File

@@ -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>))
{

View File

@@ -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);