Add missing doc comments.

This commit is contained in:
David Chisnall
2019-04-10 12:47:14 +01:00
parent 2442dc4f3f
commit ad0a22e571
3 changed files with 39 additions and 0 deletions

View File

@@ -70,7 +70,15 @@ namespace snmalloc
*/
struct SuperslabMap
{
/**
* Reference to the pagemap that we're using, allowing it to not be the
* default pagemap.
*/
SuperslabPagemap& pagemap;
/**
* Constructor. Uses the global pagemap by default, but can use a
* different one if required.
*/
SuperslabMap(SuperslabPagemap& pm = global_pagemap) : pagemap(pm) {}
/**
* Get the pagemap entry corresponding to a specific address.

View File

@@ -198,8 +198,20 @@ namespace snmalloc
}
public:
/**
* The pagemap configuration describing this instantiation of the template.
*/
static constexpr PagemapConfig config = {
1, false, GRANULARITY_BITS, sizeof(T)};
/**
* Cast a `void*` to a pointer to this template instantiation, given a
* config describing the configuration. Return null if the configuration
* passed does not correspond to this template instantiation.
*
* This intended to allow code that depends on the pagemap having a
* specific representation to fail gracefully.
*/
static Pagemap* cast_to_pagemap(void* pm, const PagemapConfig* c)
{
if (
@@ -290,9 +302,20 @@ namespace snmalloc
std::atomic<T> top[ENTRIES];
public:
/**
* The pagemap configuration describing this instantiation of the template.
*/
static constexpr PagemapConfig config = {
1, true, GRANULARITY_BITS, sizeof(T)};
/**
* Cast a `void*` to a pointer to this template instantiation, given a
* config describing the configuration. Return null if the configuration
* passed does not correspond to this template instantiation.
*
* This intended to allow code that depends on the pagemap having a
* specific representation to fail gracefully.
*/
static FlatPagemap* cast_to_pagemap(void* pm, PagemapConfig* c)
{
if (

View File

@@ -206,6 +206,14 @@ extern "C"
}
#ifdef SNMALLOC_EXPOSE_PAGEMAP
/**
* Export the pagemap. The return value is a pointer to the pagemap
* structure. The argument is used to return a pointer to a `PagemapConfig`
* structure describing the type of the pagemap. Static methods on the
* concrete pagemap templates can then be used to safely cast the return from
* this function to the correct type. This allows us to preserve some
* semblance of ABI safety via a pure C API.
*/
SNMALLOC_EXPORT void* SNMALLOC_NAME_MANGLE(snmalloc_get_global_pagemap)(
PagemapConfig const** config)
{