PMEM2_SOURCE_ALIGNMENT(3)
β¨ pmem2_source_alignment() β¨
okay bestie, so this one's from the PMDK Programmer's Manual (yes, the whole PMDK era, we love her) and it's literally just one little function that tells you how your data source needs to be aligned. no cap. it's giving "small but mighty" π
π¦ NAME π¦
pmem2_source_alignment() β returns data source alignment
like, it hands you the alignment. that's the whole job. iconic behavior honestly.
πΈ SYNOPSIS πΈ
#include <libpmem2.h>
struct pmem2_source;
int pmem2_source_alignment(const struct pmem2_source *source, size_t *alignment);
yes you need the header, yes you need a struct pmem2_source forward declaration, it's all there, don't skip it π
π DESCRIPTION π
okay so listen. the pmem2_source_alignment() function retrieves the alignment of offset and length that you need for pmem2_map_new(3) to actually succeed. like, if you don't align things right, the map call is gonna be upset with you and we don't want that energy π
the alignment gets stored in *alignment. that's the out-param, she's the main character here. periodt.
β RETURN VALUE β
pmem2_source_alignment() returns 0 on success. slay. β¨
but if the function fails? then *alignment is left unmodified (so don't go reading it thinking you got something, bestie, you did not) and a negative error code is returned instead. π
π₯ ERRORS π₯
pmem2_source_alignment() can fail with the following errors, and ngl some of these are very specific:
PMEM2_E_INVALID_ALIGNMENT_VALUEβ the operating system returned an unexpected alignment value (eg. it is not a power of two). the OS is out here being chaotic, not us πPMEM2_E_INVALID_FILE_TYPEβ the file descriptor points to a character device other than Device DAX.PMEM2_E_INVALID_ALIGNMENT_FORMATβ the kernel query for Device DAX alignment returned data in an invalid format. rude of it.-errnoset by failingfstat(2), while trying to validate the file descriptor.-errnoset by failingrealpath(3), while trying to determine whetherfdpoints to a Device DAX.-errnoset by failingread(2), while trying to determine Device DAX's alignment.-errnoset by failingstrtoull(3), while trying to determine Device DAX's alignment.
okay so a lot of these are -errno situations, meaning the error number from the underlying failing call comes back negated. so if you're checking return values, yes, negative. keep that in mind π«Ά
π SEE ALSO π
errno(3)fstat(2)realpath(3)read(2)strtoull(3)pmem2_config_new(3)pmem2_source_from_fd(3)libpmem2(7)- <https://pmem.io> β well, the link, not a clickable thing, we're in a terminal bestie π
and that's the whole page! this was PMDK, dated 2025-07-24. go forth and align your sources correctly, you got this ππ§ββοΈ
π¦ where this page comes from
- fedora 43: libpmem2-devel 2.1.0-4.fc43 Β· BSD-3-Clause
- π the page's license: BSD-3-Clause
- Copyright 2019-2023, Intel Corporation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms