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 (6 fields) source
§
const char *name §
size_t size §
size_t align §
void **perdomain_ptrs §
perdomain_descriptor_constructor constructor §
atomic_bool ready Type Aliases
Section titled “Type Aliases”perdomain_descriptor_constructor
Section titled “perdomain_descriptor_constructor”typedef void (*perdomain_descriptor_constructor)(void * *, size_t) source Functions
Section titled “Functions”perdomain_desc_ready
Section titled “perdomain_desc_ready”cc_pure bool perdomain_desc_ready(const struct perdomain_descriptor *desc) source perdomain_obj_init
Section titled “perdomain_obj_init”void perdomain_obj_init(void) source perdomain_alloc_array
Section titled “perdomain_alloc_array”void * * perdomain_alloc_array(size_t size) source Macros
Section titled “Macros”PERDOMAIN_DEFINE_3
Section titled “PERDOMAIN_DEFINE_3”#define PERDOMAIN_DEFINE_3(type_, name_, ctor_) source Expansion
#define PERDOMAIN_DEFINE_3(type_, name_, ctor_) \
static typeof(type_) __perdomain_##name_ cc_unused; \
static struct perdomain_descriptor __perdomain_desc_##name_; \
static void __perdomain_ctor_##name_(void *inst, size_t domain) { \
void (*const __typed_ctor)(typeof(type_) *, size_t) = (ctor_); \
if (__typed_ctor != NULL) \
__typed_ctor((typeof(type_) *) inst, domain); \
if (domain == global.domain_count - 1) \
atomic_store(&__perdomain_desc_##name_.ready, true); \
} \
static LINKER_SECTION_OBJECT(struct perdomain_descriptor, perdomain_desc) \
__perdomain_desc_##name_ = { \
.name = #name_, \
.size = sizeof(typeof(type_)), \
.align = cc_alignof(typeof(type_)), \
.perdomain_ptrs = NULL, \
.constructor = __perdomain_ctor_##name_, \
.ready = false, \
}; \
static struct perdomain_descriptor *const __perdomain_desc_ref_##name_ \
cc_unused = &__perdomain_desc_##name_ PERDOMAIN_DEFINE_2
Section titled “PERDOMAIN_DEFINE_2”#define PERDOMAIN_DEFINE_2(type_, name_) source Expansion
#define PERDOMAIN_DEFINE_2(type_, name_) PERDOMAIN_DEFINE_3(type_, name_, NULL) PERDOMAIN_DEFINE
Section titled “PERDOMAIN_DEFINE”#define PERDOMAIN_DEFINE(...) source Expansion
#define PERDOMAIN_DEFINE(...) PP_CALL(PERDOMAIN_DEFINE, __VA_ARGS__) PERDOMAIN_EXPORT_AS
Section titled “PERDOMAIN_EXPORT_AS”#define PERDOMAIN_EXPORT_AS(sym_name, name) source Expansion
#define PERDOMAIN_EXPORT_AS(sym_name, name) \
extern struct perdomain_descriptor __perdomain_desc_sym_##sym_name \
cc_alias(__perdomain_desc_##name) cc_used PERDOMAIN_EXPORT
Section titled “PERDOMAIN_EXPORT”#define PERDOMAIN_EXPORT(name) source Expansion
#define PERDOMAIN_EXPORT(name) PERDOMAIN_EXPORT_AS(name, name) PERDOMAIN_EXTERN_AS
Section titled “PERDOMAIN_EXTERN_AS”#define PERDOMAIN_EXTERN_AS(type, name, sym_name) source Expansion
#define PERDOMAIN_EXTERN_AS(type, name, sym_name) \
extern struct perdomain_descriptor __perdomain_desc_sym_##sym_name; \
static typeof(type) __perdomain_##name cc_unused; \
static struct perdomain_descriptor *const __perdomain_desc_ref_##name \
cc_unused = &__perdomain_desc_sym_##sym_name PERDOMAIN_EXTERN
Section titled “PERDOMAIN_EXTERN”#define PERDOMAIN_EXTERN(type, name) source Expansion
#define PERDOMAIN_EXTERN(type, name) PERDOMAIN_EXTERN_AS(type, name, name) PERDOMAIN
Section titled “PERDOMAIN”PERDOMAIN_READY
Section titled “PERDOMAIN_READY”#define PERDOMAIN_READY(name) source Expansion
#define PERDOMAIN_READY(name) \
(atomic_load(&(__perdomain_desc_ref_##name)->ready)) PERDOMAIN_PTR_FOR
Section titled “PERDOMAIN_PTR_FOR”#define PERDOMAIN_PTR_FOR(name, d) source Expansion
#define PERDOMAIN_PTR_FOR(name, d) \
({ \
assume(perdomain_desc_ready(__perdomain_desc_ref_##name)); \
((typeof(__perdomain_##name) *) (__perdomain_desc_ref_##name) \
->perdomain_ptrs[d]); \
}) PERDOMAIN_READ_FOR
Section titled “PERDOMAIN_READ_FOR”#define PERDOMAIN_READ_FOR(name, d) source Expansion
#define PERDOMAIN_READ_FOR(name, d) \
(*((typeof(__perdomain_##name) *) PERDOMAIN_PTR_FOR(name, d))) PERDOMAIN_PTR
Section titled “PERDOMAIN_PTR”#define PERDOMAIN_PTR(clr, name) source Expansion
#define PERDOMAIN_PTR(clr, name) PERDOMAIN_PTR_FOR(name, domain_local_id(clr)) PERDOMAIN_READ
Section titled “PERDOMAIN_READ”#define PERDOMAIN_READ(clr, name) source Expansion
#define PERDOMAIN_READ(clr, name) \
(*((typeof(__perdomain_##name) *) PERDOMAIN_PTR(clr, name))) PERDOMAIN_WRITE
Section titled “PERDOMAIN_WRITE”#define PERDOMAIN_WRITE(clr, name, val) source Expansion
#define PERDOMAIN_WRITE(clr, name, val) (PERDOMAIN_READ(clr, name) = (val)) perdomain_for_each_internal_3
Section titled “perdomain_for_each_internal_3”Expansion
#define perdomain_for_each_internal_3(var, domain, name) \
for (domain = 0; domain < global.domain_count; domain++) \
for (var = PERDOMAIN_PTR_FOR(name, domain); var != NULL; var = NULL) perdomain_for_each_internal_2
Section titled “perdomain_for_each_internal_2”#define perdomain_for_each_internal_2(var, name) source Expansion
#define perdomain_for_each_internal_2(var, name) \
for (domain_id_t __perdomain_idx = 0; \
__perdomain_idx < global.domain_count; __perdomain_idx++) \
for (var = PERDOMAIN_PTR_FOR(name, __perdomain_idx); var != NULL; \
var = NULL) perdomain_for_each
Section titled “perdomain_for_each”#define perdomain_for_each(...) source Expansion
#define perdomain_for_each(...) \
PP_CALL(perdomain_for_each_internal, __VA_ARGS__)