]>
git.proxmox.com Git - ceph.git/blob - ceph/src/pmdk/src/libpmemobj/libpmemobj.c
1 // SPDX-License-Identifier: BSD-3-Clause
2 /* Copyright 2014-2017, Intel Corporation */
5 * libpmemobj.c -- pmem entry points for libpmemobj
8 #include "pmemcommon.h"
12 * libpmemobj_init -- load-time initialization for obj
14 * Called automatically by the run-time loader.
20 common_init(PMEMOBJ_LOG_PREFIX
, PMEMOBJ_LOG_LEVEL_VAR
,
21 PMEMOBJ_LOG_FILE_VAR
, PMEMOBJ_MAJOR_VERSION
,
22 PMEMOBJ_MINOR_VERSION
);
28 * libpmemobj_fini -- libpmemobj cleanup routine
30 * Called automatically when the process terminates.
42 * pmemobj_check_versionU -- see if lib meets application version requirements
48 pmemobj_check_versionU(unsigned major_required
, unsigned minor_required
)
50 LOG(3, "major_required %u minor_required %u",
51 major_required
, minor_required
);
53 if (major_required
!= PMEMOBJ_MAJOR_VERSION
) {
54 ERR("libpmemobj major version mismatch (need %u, found %u)",
55 major_required
, PMEMOBJ_MAJOR_VERSION
);
56 return out_get_errormsg();
59 if (minor_required
> PMEMOBJ_MINOR_VERSION
) {
60 ERR("libpmemobj minor version mismatch (need %u, found %u)",
61 minor_required
, PMEMOBJ_MINOR_VERSION
);
62 return out_get_errormsg();
70 * pmemobj_check_version -- see if lib meets application version requirements
73 pmemobj_check_version(unsigned major_required
, unsigned minor_required
)
75 return pmemobj_check_versionU(major_required
, minor_required
);
79 * pmemobj_check_versionW -- see if lib meets application version requirements
82 pmemobj_check_versionW(unsigned major_required
, unsigned minor_required
)
84 if (pmemobj_check_versionU(major_required
, minor_required
) != NULL
)
85 return out_get_errormsgW();
92 * pmemobj_set_funcs -- allow overriding libpmemobj's call to malloc, etc.
96 void *(*malloc_func
)(size_t size
),
97 void (*free_func
)(void *ptr
),
98 void *(*realloc_func
)(void *ptr
, size_t size
),
99 char *(*strdup_func
)(const char *s
))
103 util_set_alloc_funcs(malloc_func
, free_func
, realloc_func
, strdup_func
);
107 * pmemobj_errormsgU -- return last error message
113 pmemobj_errormsgU(void)
115 return out_get_errormsg();
120 * pmemobj_errormsg -- return last error message
123 pmemobj_errormsg(void)
125 return pmemobj_errormsgU();
129 * pmemobj_errormsgW -- return last error message as wchar_t
132 pmemobj_errormsgW(void)
134 return out_get_errormsgW();