Per-Domain dynamic objects
include/smp/perdomain.h View source View on GitHubStructs
Section titled “Structs”perdomain_descriptor
Section titled “perdomain_descriptor”struct perdomain_descriptor {
const char *name;
size_t size;
size_t align;
void **perdomain_ptrs;
perdomain_descriptor_constructor constructor;
}; Type Aliases
Section titled “Type Aliases”perdomain_descriptor_constructor
Section titled “perdomain_descriptor_constructor”typedef void (*perdomain_descriptor_constructor)(void * *, size_t); Functions
Section titled “Functions”perdomain_obj_init
Section titled “perdomain_obj_init”void perdomain_obj_init(void); Macros
Section titled “Macros”PERDOMAIN_DECLARE
Section titled “PERDOMAIN_DECLARE”#define PERDOMAIN_DECLARE(__n, __type, __ctor) \
extern __type __perdomain_##__n; \
static void __perdomain_ctor_##__n(void *inst, size_t cpu) { \
if ((__ctor) != NULL) \
__ctor((__type *) inst, cpu); \
} \
LINKER_SECTION_OBJECT(struct perdomain_descriptor, perdomain_desc) \
__perdomain_desc_##__n = { \
.name = #__n, \
.size = sizeof(__type), \
.align = _Alignof(__type), \
.perdomain_ptrs = NULL, \
.constructor = __perdomain_ctor_##__n, \
}; \
__type __perdomain_##__n PERDOMAIN_PTR_FOR_DOMAIN
Section titled “PERDOMAIN_PTR_FOR_DOMAIN”#define PERDOMAIN_PTR_FOR_DOMAIN(name, d) \
((typeof(__perdomain_##name) *) __perdomain_desc_##name.perdomain_ptrs[d]) PERDOMAIN_READ_FOR_DOMAIN
Section titled “PERDOMAIN_READ_FOR_DOMAIN”#define PERDOMAIN_READ_FOR_DOMAIN(name, d) \
(*((typeof(__perdomain_##name) *) PERDOMAIN_PTR_FOR_DOMAIN(name, d))) PERDOMAIN_PTR
Section titled “PERDOMAIN_PTR”#define PERDOMAIN_PTR(name) PERDOMAIN_PTR_FOR_DOMAIN(name, domain_local_id()) PERDOMAIN_READ
Section titled “PERDOMAIN_READ”#define PERDOMAIN_READ(name) \
(*((typeof(__perdomain_##name) *) PERDOMAIN_PTR(name))) PERDOMAIN_WRITE
Section titled “PERDOMAIN_WRITE”#define PERDOMAIN_WRITE(name, val) (PERDOMAIN_READ(name) = (val))