#include <stdlib.h>
#include <stdint.h>
#include <fcntl.h>
Go to the source code of this file.
|
uint32_t | NVM_CreateRegion (const char *name, int flags) |
| Create a named persistent region. More...
|
|
uint32_t | NVM_FindOrCreateRegion (const char *name, int flags, int *is_created) |
| Create a persistent region with the provided name. More...
|
|
uint32_t | NVM_FindRegion (const char *name, int flags) |
| Find the id of a region when it is known to exist already. More...
|
|
void | NVM_DeleteRegion (const char *name) |
| Delete the region with the provided name. More...
|
|
void | NVM_CloseRegion (uint32_t rid) |
| Close a persistent region. More...
|
|
void * | NVM_GetRegionRoot (uint32_t rid) |
| Get the root pointer of the persistent region. More...
|
|
void | NVM_SetRegionRoot (uint32_t rid, void *root) |
| Set the root pointer of an existing persistent region. More...
|
|
int | NVM_IsInRegion (void *ptr, size_t sz) |
| Determines if a memory location is within a region. More...
|
|
int | isOnDifferentCacheLine (void *p1, void *p2) |
| Determines if the addresses are on different cache lines. More...
|
|
int | isCacheLineAligned (void *p) |
| Determines if a memory location is aligned to a cache line. More...
|
|
void * | nvm_alloc (size_t sz, uint32_t rid) |
| Malloc style interface for allocation from a persistent region. More...
|
|
void * | nvm_calloc (size_t nmemb, size_t sz, uint32_t rid) |
| Calloc style interface for allocation from a persistent region. More...
|
|
void * | nvm_realloc (void *ptr, size_t sz, uint32_t rid) |
| Realloc style interface for allocation from a persistent region. More...
|
|
void | nvm_free (void *ptr) |
| Deallocation interface for persistent data. More...
|
|
int isCacheLineAligned |
( |
void * |
p | ) |
|
Determines if a memory location is aligned to a cache line.
- Parameters
-
p | Address of memory location under consideration |
- Returns
- Indicates whether the memory location is cache line aligned
int isOnDifferentCacheLine |
( |
void * |
p1, |
|
|
void * |
p2 |
|
) |
| |
Determines if the addresses are on different cache lines.
- Parameters
-
p1 | First address |
p2 | Second address |
- Returns
- Indicates whether the addresses are on different cache lines
The objects under consideration must not cross cache lines, otherwise this interface is inadequate.
void* nvm_alloc |
( |
size_t |
sz, |
|
|
uint32_t |
rid |
|
) |
| |
Malloc style interface for allocation from a persistent region.
- Parameters
-
sz | Size of location to be allocated |
rid | Id of persistent region for allocation |
- Returns
- Address of memory location allocated
void* nvm_calloc |
( |
size_t |
nmemb, |
|
|
size_t |
sz, |
|
|
uint32_t |
rid |
|
) |
| |
Calloc style interface for allocation from a persistent region.
- Parameters
-
nmemb | Number of elements in the array to be allocated |
sz | Size of each element |
rid | Id of persistent region for allocation |
- Returns
- Pointer to allocated memory
void NVM_CloseRegion |
( |
uint32_t |
rid | ) |
|
Close a persistent region.
- Parameters
-
After closing, it won't be available to the calling process without calling NVM_FindOrCreateRegion. The region will stay in NVM even after calling this interface. This interface allows closing a region with normal bookkeeping.
uint32_t NVM_CreateRegion |
( |
const char * |
name, |
|
|
int |
flags |
|
) |
| |
Create a named persistent region.
- Parameters
-
name | Name of the persistent region |
flags | access flag (one of O_RDONLY, O_WRONLY, O_RDWR) |
- Returns
- Id of the region created
This interface does not check for an existing entry with the same name. If a region with the same name already exists, the behavior of the program is undefined.
void NVM_DeleteRegion |
( |
const char * |
name | ) |
|
Delete the region with the provided name.
- Parameters
-
name | Name of the persistent region |
Use this interface to completely destroy a region. If the region does not exist, an assertion failure will occur.
uint32_t NVM_FindOrCreateRegion |
( |
const char * |
name, |
|
|
int |
flags, |
|
|
int * |
is_created |
|
) |
| |
Create a persistent region with the provided name.
- Parameters
-
name | Name of the persistent region |
flags | access flag (one of O_RDONLY, O_WRONLY, O_RDWR) |
is_created | Indicator whether the region got created as a result of the call |
- Returns
- Id of the region found or created
If the region already exists, the existing id of the region is returned. Otherwise a region is created and its newly assigned id returned.
uint32_t NVM_FindRegion |
( |
const char * |
name, |
|
|
int |
flags |
|
) |
| |
Find the id of a region when it is known to exist already.
- Parameters
-
name | Name of the persistent region |
flags | access flag (one of O_RDONLY, O_WRONLY, O_RDWR) |
- Returns
- Id of the region found
This interface should be used over NVM_FindOrCreateRegion for efficiency reasons if the region is known to exist. If a region with the provided name does not exist, an assertion failure will occur.
void nvm_free |
( |
void * |
ptr | ) |
|
Deallocation interface for persistent data.
- Parameters
-
ptr | Address of memory location to be freed. |
Though the usual use case would be for the location to be in persistent memory, this interface will also work for transient data. The implementation is required to transparently handle this case as well.
void* NVM_GetRegionRoot |
( |
uint32_t |
rid | ) |
|
Get the root pointer of the persistent region.
- Parameters
-
- Returns
- Root pointer of the region
The region must have been created already. Currently, only one root is implemented for a given region. The idea is that anything within a region that is not reachable from the root after program termination is assumed to be garbage and can be recycled. During execution, anything within a region that is not reachable from the root or from other roots (in the GC sense) is assumed to be garbage as well.
int NVM_IsInRegion |
( |
void * |
ptr, |
|
|
size_t |
sz |
|
) |
| |
Determines if a memory location is within a region.
- Parameters
-
ptr | Queried address |
sz | Size of the location in bytes |
- Returns
- 1 if within the region, otherwise 0
void* nvm_realloc |
( |
void * |
ptr, |
|
|
size_t |
sz, |
|
|
uint32_t |
rid |
|
) |
| |
Realloc style interface for allocation from a persistent region.
- Parameters
-
ptr | Address of memory block provided |
sz | New size of allocation |
rid | Id of persistent region for allocation |
- Returns
- Pointer to re-allocated memory
void NVM_SetRegionRoot |
( |
uint32_t |
rid, |
|
|
void * |
root |
|
) |
| |
Set the root pointer of an existing persistent region.
- Parameters
-
rid | Region id |
root | The new root of the region |