|
@@ -35,13 +35,14 @@
|
|
#endif
|
|
#endif
|
|
|
|
|
|
PmdkLibLoader * pmdkLoader;
|
|
PmdkLibLoader * pmdkLoader;
|
|
|
|
+// 1 represents loaded. Otherwise, not loaded.
|
|
|
|
+int pmdkLoaded;
|
|
|
|
|
|
/**
|
|
/**
|
|
* pmdk_load.c
|
|
* pmdk_load.c
|
|
* Utility of loading the libpmem library and the required functions.
|
|
* Utility of loading the libpmem library and the required functions.
|
|
* Building of this codes won't rely on any libpmem source codes, but running
|
|
* Building of this codes won't rely on any libpmem source codes, but running
|
|
* into this will rely on successfully loading of the dynamic library.
|
|
* into this will rely on successfully loading of the dynamic library.
|
|
- *
|
|
|
|
*/
|
|
*/
|
|
|
|
|
|
static const char* load_functions() {
|
|
static const char* load_functions() {
|
|
@@ -56,6 +57,10 @@ static const char* load_functions() {
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * It should be idempotent to call this function for checking
|
|
|
|
+ * whether PMDK lib is successfully loaded.
|
|
|
|
+ */
|
|
void load_pmdk_lib(char* err, size_t err_len) {
|
|
void load_pmdk_lib(char* err, size_t err_len) {
|
|
const char* errMsg;
|
|
const char* errMsg;
|
|
const char* library = NULL;
|
|
const char* library = NULL;
|
|
@@ -67,10 +72,13 @@ void load_pmdk_lib(char* err, size_t err_len) {
|
|
|
|
|
|
err[0] = '\0';
|
|
err[0] = '\0';
|
|
|
|
|
|
- if (pmdkLoader != NULL) {
|
|
|
|
|
|
+ if (pmdkLoaded == 1) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- pmdkLoader = calloc(1, sizeof(PmdkLibLoader));
|
|
|
|
|
|
+
|
|
|
|
+ if (pmdkLoader == NULL) {
|
|
|
|
+ pmdkLoader = calloc(1, sizeof(PmdkLibLoader));
|
|
|
|
+ }
|
|
|
|
|
|
// Load PMDK library
|
|
// Load PMDK library
|
|
#ifdef UNIX
|
|
#ifdef UNIX
|
|
@@ -103,4 +111,5 @@ void load_pmdk_lib(char* err, size_t err_len) {
|
|
}
|
|
}
|
|
|
|
|
|
pmdkLoader->libname = strdup(library);
|
|
pmdkLoader->libname = strdup(library);
|
|
|
|
+ pmdkLoaded = 1;
|
|
}
|
|
}
|