Atlas Runtime
atlas_alloc.h
Go to the documentation of this file.
1 /*
2  * (c) Copyright 2016 Hewlett Packard Enterprise Development LP
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as
6  * published by the Free Software Foundation, either version 3 of the
7  * License, or (at your option) any later version. This program is
8  * distributed in the hope that it will be useful, but WITHOUT ANY
9  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11  * for more details. You should have received a copy of the GNU Lesser
12  * General Public License along with this program. If not, see
13  * <http://www.gnu.org/licenses/>.
14  */
15 
16 
17 #ifndef ATLAS_ALLOC_H
18 #define ATLAS_ALLOC_H
19 
20 #include <stdlib.h>
21 #include <stdint.h>
22 #include <fcntl.h>
23 
24 //
25 // Persistent region API
26 // These are interfaces for creating and managing persistent regions,
27 // entities that contain persistent data. Once a persistent region is
28 // created, objects can be allocated out of the region, e.g. by using
29 // nvm_alloc. Any data not in a persistent region is considered
30 // transient.
31 //
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
46 uint32_t NVM_CreateRegion(const char *name, int flags);
47 
59 uint32_t NVM_FindOrCreateRegion(const char *name, int flags, int *is_created);
60 
72 uint32_t NVM_FindRegion(const char *name, int flags);
73 
81 void NVM_DeleteRegion(const char *name);
82 
92 void NVM_CloseRegion(uint32_t rid);
93 
107 void *NVM_GetRegionRoot(uint32_t rid);
108 
114 void NVM_SetRegionRoot(uint32_t rid, void *root);
115 
122 int NVM_IsInRegion(void *ptr, size_t sz);
123 
135 int isOnDifferentCacheLine(void *p1, void *p2);
136 
144 int isCacheLineAligned(void *p);
145 
154 void *nvm_alloc(size_t sz, uint32_t rid);
155 
165 void *nvm_calloc(size_t nmemb, size_t sz, uint32_t rid);
166 
176 void *nvm_realloc(void *ptr, size_t sz, uint32_t rid);
177 
188 void nvm_free(void *ptr);
189 
190 #ifdef __cplusplus
191 }
192 #endif
193 
194 #endif
void NVM_CloseRegion(uint32_t rid)
Close a persistent region.
Definition: pregion_mgr_api.cpp:40
int isCacheLineAligned(void *p)
Determines if a memory location is aligned to a cache line.
Definition: pregion_mgr_api.cpp:106
uint32_t NVM_CreateRegion(const char *name, int flags)
Create a named persistent region.
Definition: pregion_mgr_api.cpp:35
int NVM_IsInRegion(void *ptr, size_t sz)
Determines if a memory location is within a region.
Definition: pregion_mgr_api.cpp:111
uint32_t NVM_FindOrCreateRegion(const char *name, int flags, int *is_created)
Create a persistent region with the provided name.
Definition: pregion_mgr_api.cpp:23
node * root
Definition: region_test.h:36
void NVM_SetRegionRoot(uint32_t rid, void *root)
Set the root pointer of an existing persistent region.
Definition: pregion_mgr_api.cpp:55
int isOnDifferentCacheLine(void *p1, void *p2)
Determines if the addresses are on different cache lines.
Definition: pregion_mgr_api.cpp:101
uint32_t NVM_FindRegion(const char *name, int flags)
Find the id of a region when it is known to exist already.
Definition: pregion_mgr_api.cpp:29
void * nvm_calloc(size_t nmemb, size_t sz, uint32_t rid)
Calloc style interface for allocation from a persistent region.
Definition: pregion_mgr_api.cpp:68
void * nvm_alloc(size_t sz, uint32_t rid)
Malloc style interface for allocation from a persistent region.
Definition: pregion_mgr_api.cpp:60
void nvm_free(void *ptr)
Deallocation interface for persistent data.
Definition: pregion_mgr_api.cpp:78
void * NVM_GetRegionRoot(uint32_t rid)
Get the root pointer of the persistent region.
Definition: pregion_mgr_api.cpp:50
void * nvm_realloc(void *ptr, size_t sz, uint32_t rid)
Realloc style interface for allocation from a persistent region.
Definition: pregion_mgr_api.cpp:73
void NVM_DeleteRegion(const char *name)
Delete the region with the provided name.
Definition: pregion_mgr_api.cpp:45