Per-NUMA Node dynamic objects
include/smp/pernode.h View source View on GitHubStructs
Section titled “Structs”pernode_descriptor
Section titled “pernode_descriptor”struct pernode_descriptor {
const char *name;
size_t size;
size_t align;
void **pernode_ptrs;
pernode_descriptor_constructor constructor;
}; Type Aliases
Section titled “Type Aliases”pernode_descriptor_constructor
Section titled “pernode_descriptor_constructor”typedef void (*pernode_descriptor_constructor)(void * *, size_t); Functions
Section titled “Functions”pernode_obj_init
Section titled “pernode_obj_init”void pernode_obj_init(void); Macros
Section titled “Macros”PERNODE_DECLARE
Section titled “PERNODE_DECLARE”#define PERNODE_DECLARE(__n, __type, __ctor) \
extern __type __pernode_##__n; \
static void __pernode_ctor_##__n(void *inst, size_t cpu) { \
if ((__ctor) != NULL) \
__ctor((__type *) inst, cpu); \
} \
LINKER_SECTION_OBJECT(struct pernode_descriptor, pernode_desc) \
__pernode_desc_##__n = { \
.name = #__n, \
.size = sizeof(__type), \
.align = _Alignof(__type), \
.pernode_ptrs = NULL, \
.constructor = __pernode_ctor_##__n, \
}; \
__type __pernode_##__n PERNODE_PTR_FOR_NODE
Section titled “PERNODE_PTR_FOR_NODE”#define PERNODE_PTR_FOR_NODE(name, d) \
((typeof(__pernode_##name) *) __pernode_desc_##name.pernode_ptrs[d]) PERNODE_READ_FOR_NODE
Section titled “PERNODE_READ_FOR_NODE”#define PERNODE_READ_FOR_NODE(name, d) \
(*((typeof(__pernode_##name) *) PERNODE_PTR_FOR_NODE(name, d))) PERNODE_PTR
Section titled “PERNODE_PTR”#define PERNODE_PTR(name) PERNODE_PTR_FOR_NODE(name, node_local_id()) PERNODE_READ
Section titled “PERNODE_READ”#define PERNODE_READ(name) (*((typeof(__pernode_##name) *) PERNODE_PTR(name))) PERNODE_WRITE
Section titled “PERNODE_WRITE”#define PERNODE_WRITE(name, val) (PERNODE_READ(name) = (val))