Per-Topology level dynamic objects
include/smp/pertopo.h View source View on GitHubCore per-topology macros
Structs
Section titled “Structs”pertopo_descriptor
Section titled “pertopo_descriptor” struct pertopo_descriptor (7 fields) source
§
enum topology_level level §
const char *name §
size_t size §
size_t align §
void **pertopo_ptrs §
pertopo_descriptor_constructor constructor §
atomic_bool ready Type Aliases
Section titled “Type Aliases”pertopo_descriptor_constructor
Section titled “pertopo_descriptor_constructor”typedef void (*pertopo_descriptor_constructor)(void * *, size_t) source Functions
Section titled “Functions”pertopo_desc_ready
Section titled “pertopo_desc_ready”cc_pure bool pertopo_desc_ready(const struct pertopo_descriptor *desc) source pertopo_node_local
Section titled “pertopo_node_local”size_t pertopo_node_local(
struct pertopo_descriptor *desc,
enum topology_caller c
) source pertopo_obj_init
Section titled “pertopo_obj_init”void pertopo_obj_init(void) source Macros
Section titled “Macros”PERTOPO_DEFINE_4
Section titled “PERTOPO_DEFINE_4”#define PERTOPO_DEFINE_4(type_, name_, level_, ctor_) source Expansion
#define PERTOPO_DEFINE_4(type_, name_, level_, ctor_) \
static typeof(type_) __pertopo_##name_ cc_unused; \
static struct pertopo_descriptor __pertopo_desc_##name_; \
static void __pertopo_ctor_##name_(void *inst, size_t node_id) { \
void (*const __typed_ctor)(typeof(type_) *, size_t) = (ctor_); \
if (__typed_ctor != NULL) \
__typed_ctor((typeof(type_) *) inst, node_id); \
if (node_id == (size_t) (global.topology.count[level_] - 1)) \
atomic_store(&__pertopo_desc_##name_.ready, true); \
} \
static LINKER_SECTION_OBJECT(struct pertopo_descriptor, pertopo_desc) \
__pertopo_desc_##name_ = { \
.name = #name_, \
.size = sizeof(typeof(type_)), \
.align = cc_alignof(typeof(type_)), \
.pertopo_ptrs = NULL, \
.level = level_, \
.constructor = __pertopo_ctor_##name_, \
.ready = false, \
}; \
static struct pertopo_descriptor *const __pertopo_desc_ref_##name_ \
cc_unused = &__pertopo_desc_##name_ PERTOPO_DEFINE_3
Section titled “PERTOPO_DEFINE_3”#define PERTOPO_DEFINE_3(type_, name_, level_) source Expansion
#define PERTOPO_DEFINE_3(type_, name_, level_) \
PERTOPO_DEFINE_4(type_, name_, level_, NULL) PERTOPO_DEFINE
Section titled “PERTOPO_DEFINE”#define PERTOPO_DEFINE(...) source Expansion
#define PERTOPO_DEFINE(...) PP_CALL(PERTOPO_DEFINE, __VA_ARGS__) PERTOPO_EXPORT_AS
Section titled “PERTOPO_EXPORT_AS”#define PERTOPO_EXPORT_AS(sym_name, name) source Expansion
#define PERTOPO_EXPORT_AS(sym_name, name) \
extern struct pertopo_descriptor __pertopo_desc_sym_##sym_name \
cc_alias(__pertopo_desc_##name) cc_used PERTOPO_EXPORT
Section titled “PERTOPO_EXPORT”#define PERTOPO_EXPORT(name) source Expansion
#define PERTOPO_EXPORT(name) PERTOPO_EXPORT_AS(name, name) PERTOPO_EXTERN_AS
Section titled “PERTOPO_EXTERN_AS”#define PERTOPO_EXTERN_AS(type, name, sym_name) source Expansion
#define PERTOPO_EXTERN_AS(type, name, sym_name) \
extern struct pertopo_descriptor __pertopo_desc_sym_##sym_name; \
static typeof(type) __pertopo_##name cc_unused; \
static struct pertopo_descriptor *const __pertopo_desc_ref_##name \
cc_unused = &__pertopo_desc_sym_##sym_name PERTOPO_EXTERN
Section titled “PERTOPO_EXTERN”#define PERTOPO_EXTERN(type, name) source Expansion
#define PERTOPO_EXTERN(type, name) PERTOPO_EXTERN_AS(type, name, name) PERTOPO
Section titled “PERTOPO”PERTOPO_READY
Section titled “PERTOPO_READY”#define PERTOPO_READY(name) source Expansion
#define PERTOPO_READY(name) (atomic_load(&(__pertopo_desc_ref_##name)->ready)) PERTOPO_PTR_FOR
Section titled “PERTOPO_PTR_FOR”#define PERTOPO_PTR_FOR(name, node) source Expansion
#define PERTOPO_PTR_FOR(name, node) \
({ \
assume(pertopo_desc_ready(__pertopo_desc_ref_##name)); \
((typeof(__pertopo_##name) *) (__pertopo_desc_ref_##name) \
->pertopo_ptrs[node]); \
}) PERTOPO_READ_FOR
Section titled “PERTOPO_READ_FOR”#define PERTOPO_READ_FOR(name, node) source Expansion
#define PERTOPO_READ_FOR(name, node) \
(*((typeof(__pertopo_##name) *) PERTOPO_PTR_FOR(name, node))) PERTOPO_PTR
Section titled “PERTOPO_PTR”#define PERTOPO_PTR(clr, name) source Expansion
#define PERTOPO_PTR(clr, name) \
PERTOPO_PTR_FOR(name, pertopo_node_local(&__pertopo_desc_##name, clr)) PERTOPO_READ
Section titled “PERTOPO_READ”#define PERTOPO_READ(clr, name) source Expansion
#define PERTOPO_READ(clr, name) \
(*((typeof(__pertopo_##name) *) PERTOPO_PTR(clr, name))) PERTOPO_WRITE
Section titled “PERTOPO_WRITE”#define PERTOPO_WRITE(clr, name, val) source Expansion
#define PERTOPO_WRITE(clr, name, val) (PERTOPO_READ(clr, name) = (val)) pertopo_for_each_internal_3
Section titled “pertopo_for_each_internal_3”#define pertopo_for_each_internal_3(var, node_id, name) source Expansion
#define pertopo_for_each_internal_3(var, node_id, name) \
for (node_id = 0; \
node_id < global.topology.count[__pertopo_desc_##name.level]; \
node_id++) \
for (var = PERTOPO_PTR_FOR(name, node_id); var != NULL; var = NULL) pertopo_for_each_internal_2
Section titled “pertopo_for_each_internal_2”#define pertopo_for_each_internal_2(var, name) source Expansion
#define pertopo_for_each_internal_2(var, name) \
for (size_t __pertopo_idx = 0; \
__pertopo_idx < global.topology.count[__pertopo_desc_##name.level]; \
__pertopo_idx++) \
for (var = PERTOPO_PTR_FOR(name, __pertopo_idx); var != NULL; \
var = NULL) pertopo_for_each
Section titled “pertopo_for_each”#define pertopo_for_each(...) source Expansion
#define pertopo_for_each(...) PP_CALL(pertopo_for_each_internal, __VA_ARGS__)