.\" Automatically generated by Pandoc 2.9.2.1 .\" .TH "" "" "2023-05-26" "PMDK - " "PMDK Programmer's Manual" .hy .\" SPDX-License-Identifier: BSD-3-Clause .\" Copyright 2016-2020, Intel Corporation .SH NAME .PP \f[B]libpmemobj\f[R] - persistent memory transactional object store .RS .PP NOTE: Support for Windows and FreeBSD deprecated since PMDK 1.13.0 release and will be removed in the PMDK 1.14.0 release. .RE .SH SYNOPSIS .IP .nf \f[C] #include cc -std=gnu99 ... -lpmemobj -lpmem \f[R] .fi .SS Library API versioning: .IP .nf \f[C] const char *pmemobj_check_version( unsigned major_required, unsigned minor_required); \f[R] .fi .SS Managing library behavior: .IP .nf \f[C] void pmemobj_set_funcs( void *(*malloc_func)(size_t size), void (*free_func)(void *ptr), void *(*realloc_func)(void *ptr, size_t size), char *(*strdup_func)(const char *s)); \f[R] .fi .SS Error handling: .IP .nf \f[C] const char *pmemobj_errormsg(void); \f[R] .fi .SS Other library functions: .PP A description of other \f[B]libpmemobj\f[R] functions can be found on the following manual pages: .IP \[bu] 2 control and statistics: \f[B]pmemobj_ctl_get\f[R](3) .IP \[bu] 2 create, open, close and validate: \f[B]pmemobj_open\f[R](3) .IP \[bu] 2 low-level memory manipulation: \f[B]pmemobj_memcpy_persist\f[R](3) .IP \[bu] 2 locking: \f[B]pmemobj_mutex_zero\f[R](3) .IP \[bu] 2 persistent object identifier: \f[B]OID_IS_NULL\f[R](3) .IP \[bu] 2 type-safety: \f[B]TOID_DECLARE\f[R](3) .IP \[bu] 2 layout declaration: \f[B]POBJ_LAYOUT_BEGIN\f[R](3) .IP \[bu] 2 non-transactional atomic allocations: \f[B]pmemobj_alloc\f[R](3) .IP \[bu] 2 root object management: \f[B]pmemobj_root\f[R](3) .IP \[bu] 2 object containers: \f[B]pmemobj_first\f[R](3) .IP \[bu] 2 non-transactional persistent atomic circular doubly-linked list: \f[B]pmemobj_list_insert\f[R](3), \f[B]POBJ_LIST_HEAD\f[R](3) .IP \[bu] 2 transactional object manipulation: \f[B]pmemobj_tx_begin\f[R](3), \f[B]pmemobj_tx_add_range\f[R](3), \f[B]pmemobj_tx_alloc\f[R](3) .IP \[bu] 2 delayed atomicity actions: \f[B]pmemobj_action\f[R](3) (EXPERIMENTAL) .SH DESCRIPTION .PP \f[B]libpmemobj\f[R] provides a transactional object store in \f[I]persistent memory\f[R] (pmem) for applications that require transactions and persistent memory management using direct access storage (DAX), which is storage that supports load/store access without paging blocks from a block storage device. Some types of \f[I]non-volatile memory DIMMs\f[R] (NVDIMMs) provide this type of byte addressable access to storage. A \f[I]persistent memory aware file system\f[R] is typically used to expose the direct access to applications. Memory mapping a file from this type of file system results in load/store, non-paged access to pmem. \f[B]libpmemobj\f[R] builds on this type of memory mapped file using the low-level pmem support provided by \f[B]libpmem\f[R](7), handling the transactional updates, flushing changes to persistence, and managing recovery for the application. .PP \f[B]libpmemobj\f[R] requires the \f[B]-std=gnu99\f[R] compilation flag to build properly. .PP \f[B]libpmemobj\f[R] is one of a collection of persistent memory libraries available. The others are: .IP \[bu] 2 \f[B]libpmemblk\f[R](7), providing pmem-resident arrays of fixed-sized blocks with atomic updates. .IP \[bu] 2 \f[B]libpmemlog\f[R](7), providing a pmem-resident log file. .IP \[bu] 2 \f[B]libpmem\f[R](7), low-level persistent memory support. .PP Under normal usage, \f[B]libpmemobj\f[R] will never print messages or intentionally cause the process to exit. The only exception to this is the debugging information, when enabled, as described under \f[B]DEBUGGING AND ERROR HANDLING\f[R], below. .SH LIBRARY API VERSIONING .PP This section describes how the library API is versioned, allowing applications to work with an evolving API. .PP The \f[B]pmemobj_check_version\f[R]() function is used to see if the installed \f[B]libpmemobj\f[R] supports the version of the library API required by an application. The easiest way to do this is for the application to supply the compile-time version information, supplied by defines in \f[B]\f[R], like this: .IP .nf \f[C] reason = pmemobj_check_version(PMEMOBJ_MAJOR_VERSION, PMEMOBJ_MINOR_VERSION); if (reason != NULL) { /* version check failed, reason string tells you why */ } \f[R] .fi .PP Any mismatch in the major version number is considered a failure, but a library with a newer minor version number will pass this check since increasing minor versions imply backwards compatibility. .PP An application can also check specifically for the existence of an interface by checking for the version where that interface was introduced. These versions are documented in this man page as follows: unless otherwise specified, all interfaces described here are available in version 1.0 of the library. Interfaces added after version 1.0 will contain the text \f[I]introduced in version x.y\f[R] in the section of this manual describing the feature. .PP On success, \f[B]pmemobj_check_version\f[R]() returns NULL. Otherwise, the return value is a static string describing the reason the version check failed. The string returned by \f[B]pmemobj_check_version\f[R]() must not be modified or freed. .SH MANAGING LIBRARY BEHAVIOR .PP The \f[B]pmemobj_set_funcs\f[R]() function allows an application to override memory allocation calls used internally by \f[B]libpmemobj\f[R]. Passing in NULL for any of the handlers will cause the \f[B]libpmemobj\f[R] default function to be used. The library does not make heavy use of the system malloc functions, but it does allocate approximately 4-8 kilobytes for each memory pool in use. .PP By default, \f[B]libpmemobj\f[R] supports up to 1024 parallel transactions/allocations. For debugging purposes it is possible to decrease this value by setting the \f[B]PMEMOBJ_NLANES\f[R] environment variable to the desired limit. .SH DEBUGGING AND ERROR HANDLING .PP If an error is detected during the call to a \f[B]libpmemobj\f[R] function, the application may retrieve an error message describing the reason for the failure from \f[B]pmemobj_errormsg\f[R](). This function returns a pointer to a static buffer containing the last error message logged for the current thread. If \f[I]errno\f[R] was set, the error message may include a description of the corresponding error code as returned by \f[B]strerror\f[R](3). The error message buffer is thread-local; errors encountered in one thread do not affect its value in other threads. The buffer is never cleared by any library function; its content is significant only when the return value of the immediately preceding call to a \f[B]libpmemobj\f[R] function indicated an error, or if \f[I]errno\f[R] was set. The application must not modify or free the error message string, but it may be modified by subsequent calls to other library functions. .PP Two versions of \f[B]libpmemobj\f[R] are typically available on a development system. The normal version, accessed when a program is linked using the \f[B]-lpmemobj\f[R] option, is optimized for performance. That version skips checks that impact performance and never logs any trace information or performs any run-time assertions. .PP A second version of \f[B]libpmemobj\f[R], accessed when a program uses the libraries under \f[B]/usr/lib/pmdk_debug\f[R], contains run-time assertions and trace points. The typical way to access the debug version is to set the environment variable \f[B]LD_LIBRARY_PATH\f[R] to \f[B]/usr/lib/pmdk_debug\f[R] or \f[B]/usr/lib64/pmdk_debug\f[R], as appropriate. Debugging output is controlled using the following environment variables. These variables have no effect on the non-debug version of the library. .RS .PP NOTE: On Debian/Ubuntu systems, this extra debug version of the library is shipped in the respective \f[B]-debug\f[R] Debian package and placed in the \f[B]/usr/lib/$ARCH/pmdk_dbg/\f[R] directory. .RE .IP \[bu] 2 \f[B]PMEMOBJ_LOG_LEVEL\f[R] .PP The value of \f[B]PMEMOBJ_LOG_LEVEL\f[R] enables trace points in the debug version of the library, as follows: .IP \[bu] 2 \f[B]0\f[R] - This is the default level when \f[B]PMEMOBJ_LOG_LEVEL\f[R] is not set. No log messages are emitted at this level. .IP \[bu] 2 \f[B]1\f[R] - Additional details on any errors detected are logged, in addition to returning the \f[I]errno\f[R]-based errors as usual. The same information may be retrieved using \f[B]pmemobj_errormsg\f[R](). .IP \[bu] 2 \f[B]2\f[R] - A trace of basic operations is logged. .IP \[bu] 2 \f[B]3\f[R] - Enables a very verbose amount of function call tracing in the library. .IP \[bu] 2 \f[B]4\f[R] - Enables voluminous and fairly obscure tracing information that is likely only useful to the \f[B]libpmemobj\f[R] developers. .PP Unless \f[B]PMEMOBJ_LOG_FILE\f[R] is set, debugging output is written to \f[I]stderr\f[R]. .IP \[bu] 2 \f[B]PMEMOBJ_LOG_FILE\f[R] .PP Specifies the name of a file where all logging information should be written. If the last character in the name is \[lq]-\[rq], the \f[I]PID\f[R] of the current process will be appended to the file name when the log file is created. If \f[B]PMEMOBJ_LOG_FILE\f[R] is not set, logging output is written to \f[I]stderr\f[R]. .PP See also \f[B]libpmem\f[R](7) to get information about other environment variables affecting \f[B]libpmemobj\f[R] behavior. .SH EXAMPLE .PP See for examples using the \f[B]libpmemobj\f[R] API. .SH ACKNOWLEDGEMENTS .PP \f[B]libpmemobj\f[R] builds on the persistent memory programming model recommended by the SNIA NVM Programming Technical Work Group: .SH SEE ALSO .PP \f[B]OID_IS_NULL\f[R](3), \f[B]pmemobj_alloc\f[R](3), \f[B]pmemobj_ctl_exec\f[R](3), \f[B]pmemobj_ctl_get\f[R](3), \f[B]pmemobj_ctl_set\f[R](3), \f[B]pmemobj_first\f[R](3), \f[B]pmemobj_list_insert\f[R](3), \f[B]pmemobj_memcpy_persist\f[R](3), \f[B]pmemobj_mutex_zero\f[R](3), \f[B]pmemobj_open\f[R](3), \f[B]pmemobj_root\f[R](3), \f[B]pmemobj_tx_add_range\f[R](3), \f[B]pmemobj_tx_alloc\f[R](3), \f[B]pmemobj_tx_begin\f[R](3), \f[B]POBJ_LAYOUT_BEGIN\f[R](3), \f[B]POBJ_LIST_HEAD\f[R](3), \f[B]strerror\f[R](3), \f[B]TOID_DECLARE\f[R](3), \f[B]libpmem\f[R](7), \f[B]libpmemblk\f[R](7), \f[B]libpmemlog\f[R](7) and \f[B]\f[R]