POBJ_LAYOUT_TOID(3)
π POBJ_LAYOUT_BEGIN(3) β the PMDK Programmer's Manual, bestie edition π
okay so you opened the POBJ_LAYOUT_BEGIN(3) page, which lives in the PMDK Programmer's Manual, and babes, it's literally all about setting up your persistent memory transactional object store layout. no cap. let's get into it π«Ά
β¨ NAME β¨
POBJ_LAYOUT_BEGIN(), POBJ_LAYOUT_TOID(), POBJ_LAYOUT_ROOT(), POBJ_LAYOUT_NAME(), POBJ_LAYOUT_END(), POBJ_LAYOUT_TYPES_NUM() β that's the whole girl squad, and together they handle the persistent memory transactional object store layout. π
πΈ SYNOPSIS πΈ
#include <libpmemobj.h>
POBJ_LAYOUT_BEGIN(layout)
POBJ_LAYOUT_TOID(layout, TYPE)
POBJ_LAYOUT_ROOT(layout, ROOT_TYPE)
POBJ_LAYOUT_NAME(layout)
POBJ_LAYOUT_END(layout)
POBJ_LAYOUT_TYPES_NUM(layout)
π DESCRIPTION π
so libpmemobj(7) gives you a whole little set of macros for conveniently declaring a pool's layout. it's giving β¨organizedβ¨. the layout declaration is made up of declarations of however many types you're using, and those declared types get assigned consecutive type numbers. you can then use the declared types together with the type safety macros (peep TOID_DECLARE(3) for that tea π).
β οΈ okay this part is serious, listen up: once you've created the layout declaration, you must not change it unless you're adding brand new types at the end of the existing layout declaration. modifying any existing declaration may lead to changes in the type numbers of declared types, which in consequence may cause data corruption. and we do NOT do data corruption in this house. ππ
now the individual macros, one by one:
POBJ_LAYOUT_BEGIN()β this one indicates the begin of declaration of the layout. theLAYOUTargument is the name of the layout, and bestie, that argument has to be passed to all the macros related to the declaration of layout. no skipping. πPOBJ_LAYOUT_TOID()β declares a typed OID for the type passed as theTYPEargument, inside the declaration of layout. all types declared using this macro get assigned consecutive type numbers. this macro must be used between thePOBJ_LAYOUT_BEGIN()andPOBJ_LAYOUT_END()macros, with the same name passed as theLAYOUTargument. periodt.POBJ_LAYOUT_ROOT()β declares a typed OID for the type passed as theROOT_TYPEargument inside the declaration of layout. that typed OID will be assigned the type number for the root object,POBJ_ROOT_TYPE_NUM. it's giving main character energy fr fr.POBJ_LAYOUT_END()β ends the declaration of layout. that's it, that's the girl. bye πPOBJ_LAYOUT_NAME()β returns the name of the layout as a null-terminated string. iconic.POBJ_LAYOUT_TYPES_NUM()β returns the number of types declared using thePOBJ_LAYOUT_TOID()macro within the layout declaration. so like, how many TOIDs did you declare? it knows. π§
π EXAMPLE π
here's a layout declaration, serving looks:
POBJ_LAYOUT_BEGIN(mylayout);
POBJ_LAYOUT_ROOT(mylayout, struct root);
POBJ_LAYOUT_TOID(mylayout, struct node);
POBJ_LAYOUT_TOID(mylayout, struct foo);
POBJ_LAYOUT_END(mylayout);
struct root
{
TOID(struct node) node;
};
struct node
{
TOID(struct node) next;
TOID(struct foo) foo;
};
and the name of the layout plus the number of declared types can be retrieved using this code right here:
const char *layout_name = POBJ_LAYOUT_NAME(mylayout);
int num_of_types = POBJ_LAYOUT_TYPES_NUM(mylayout);
look at you go. ate that. π β¨
π¦ SEE ALSO π¦
TOID_DECLARE(3)libpmemobj(7)- and https://pmem.io β go, click, slay π
okay that's the whole page bestie, we made it π this one's from PMDK, dated 2025-07-24, and you can find it chilling in the PMDK Programmer's Manual. now go declare some types (at the end only!!) and have the best day. mwah ππ«ΆπΈ
π¦ where this page comes from
- fedora 43: libpmemobj-devel 2.1.0-4.fc43 Β· BSD-3-Clause
- π the page's license: BSD-3-Clause
- Copyright 2017-2018, Intel Corporation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms