Add some type safety to other pagemap accesses.

Introduce a descriptor for the pagemap config and check that the source
descriptor is compatible with the destination type.
This commit is contained in:
David Chisnall
2019-04-09 14:59:09 +01:00
parent 51fbdf3a44
commit a93f43fd2f
5 changed files with 79 additions and 2 deletions

View File

@@ -206,8 +206,16 @@ extern "C"
}
#ifdef SNMALLOC_EXPOSE_PAGEMAP
SNMALLOC_EXPORT void* SNMALLOC_NAME_MANGLE(snmalloc_get_global_pagemap)(void)
SNMALLOC_EXPORT void* SNMALLOC_NAME_MANGLE(snmalloc_get_global_pagemap)(
PagemapConfig const** config)
{
if (config)
{
*config = &decltype(snmalloc::global_pagemap)::config;
assert(
decltype(snmalloc::global_pagemap)::cast_to_pagemap(
&snmalloc::global_pagemap, *config) == &snmalloc::global_pagemap);
}
return &snmalloc::global_pagemap;
}
#endif