21#if !defined(__RLIB_H_INCLUDE_GUARD__) && !defined(RLIB_COMPILATION)
22#error "#include <rlib.h> only please."
184#define r_sys_topology_ref r_ref_ref
186#define r_sys_topology_unref r_ref_unref
188#define r_sys_node_ref r_ref_ref
190#define r_sys_node_unref r_ref_unref
192#define r_sys_cpu_ref r_ref_ref
194#define r_sys_cpu_unref r_ref_unref
204#define R_SYS_ID_UNKNOWN RSIZE_MAX
#define R_API
Public-API decoration: resolves to R_API_EXPORT while building rlib and R_API_IMPORT for consumers.
Definition rmacros.h:115
#define R_BEGIN_DECLS
Open an extern "C" block under C++ (no-op in C).
Definition rmacros.h:196
RSysCpuCacheType
What an RSysCpuCache level holds.
Definition rsys.h:207
rboolean r_sys_topology_cpu_cache(const RSysCpu *cpu, rsize idx, RSysCpuCache *cache)
Copy the idx-th cache level of cpu into cache.
rboolean r_sys_cpuset_online(RBitset *cpuset)
Fill cpuset with the currently-online CPUs.
ruint r_sys_cpu_logical_count(void)
Number of logical CPUs (hardware threads).
ruint r_sys_node_count_with_online_cpus(void)
Number of nodes that have at least one online CPU.
RBitset * r_sys_cpuset_new(void)
Allocate a RBitset sized to hold every possible CPU.
rboolean r_sys_nodeset_with_online_cpus(RBitset *nodeset)
Fill nodeset with nodes that have online CPUs.
RSysNode * r_sys_topology_node(RSysTopology *topo, rsize idx)
Return the idx-th node of topo as a new reference (caller r_sys_node_unref's), or NULL if out of rang...
struct RSysCpu RSysCpu
Opaque, refcounted CPU within a topology node.
Definition rsys.h:128
ruint r_sys_cpu_max_count(void)
Maximum possible CPU count the system can have.
rsize r_sys_topology_node_total_memory(const RSysNode *node)
Bytes of memory local to node, or 0 when the platform does not expose it.
rboolean r_sys_topology_node_cpuset(const RSysNode *node, RBitset *cpuset)
Fill cpuset with the CPUs belonging to node.
rsize r_sys_topology_cpu_package_id(const RSysCpu *cpu)
Physical package (socket) id of cpu, or R_SYS_ID_UNKNOWN.
rboolean r_sys_nodeset_with_allowed_cpus(RBitset *nodeset)
Fill nodeset with nodes that have allowed CPUs.
rboolean r_sys_topology_cpu_cache_cpuset(const RSysCpu *cpu, rsize idx, RBitset *cpuset)
Fill cpuset with the CPUs sharing cpu's idx-th cache.
rsize r_sys_topology_node_id(const RSysNode *node)
NUMA index of node, or R_SYS_ID_UNKNOWN.
rsize r_sys_topology_node_cpu_count(const RSysNode *node)
Number of CPUs in node.
rboolean r_sys_nodeset_for_cpuset(RBitset *nodeset, const RBitset *cpuset)
Fill nodeset with the nodes spanned by cpuset.
rboolean r_sys_cpuset_for_node(RBitset *cpuset, ruint node)
Fill cpuset with the CPUs belonging to NUMA node.
ruint r_sys_cpu_allowed_count(void)
Number of CPUs this process is allowed to run on.
rsize r_sys_topology_cpu_core_id(const RSysCpu *cpu)
Physical core id of cpu, or R_SYS_ID_UNKNOWN.
struct RSysNode RSysNode
Opaque, refcounted NUMA node within a topology.
Definition rsys.h:126
ruint r_sys_node_count_with_allowed_cpus(void)
Number of nodes that have at least one allowed CPU.
ruint r_sys_node_count(void)
Total number of NUMA nodes.
rboolean r_sys_nodeset_online(RBitset *nodeset)
Fill nodeset with the currently-online nodes.
rboolean r_sys_cpuset_possible(RBitset *cpuset)
Fill cpuset with all CPUs the system could ever have.
ruint r_sys_cpuset_max(void)
Highest valid CPU index + 1 (sizing hint for a cpuset).
rsize r_sys_topology_node_count(const RSysTopology *topo)
Number of NUMA nodes in topo.
ruint64 r_sys_topology_cpu_max_frequency(const RSysCpu *cpu)
Highest clock frequency cpu can be driven at, in kHz.
ruint64 r_sys_topology_cpu_min_frequency(const RSysCpu *cpu)
Lowest clock frequency cpu can be driven at, in kHz, or 0 when unknown.
rsize r_sys_topology_cpu_node_id(const RSysCpu *cpu)
Index of the NUMA node cpu belongs to.
rboolean r_sys_topology_cpu_siblings(const RSysCpu *cpu, RBitset *cpuset)
Fill cpuset with the SMT thread siblings of cpu.
rboolean r_sys_nodeset_possible(RBitset *nodeset)
Fill nodeset with all nodes the system could have.
ruint r_sys_cpu_packages(void)
Number of physical CPU packages (sockets).
rsize r_sys_topology_node_available_memory(const RSysNode *node)
Bytes of available (free) memory local to node, or 0 when the platform does not expose it.
rsize r_sys_topology_node_distance(const RSysNode *node, rsize nodeid)
Relative cost of reaching nodeid's memory from node.
rsize r_sys_topology_cpu_cache_count(const RSysCpu *cpu)
Number of cache levels reported for cpu.
RSysTopology * r_sys_topology_discover(void)
Discover the current hardware topology.
struct RSysTopology RSysTopology
Opaque, refcounted hardware-topology snapshot.
Definition rsys.h:124
rboolean r_sys_cpuset_allowed(RBitset *cpuset)
Fill cpuset with the CPUs this process may run on.
RBitset * r_sys_nodeset_new(void)
Allocate a RBitset sized to hold every possible node.
rsize r_sys_topology_cpu_id(const RSysCpu *cpu)
Logical CPU index, i.e. the bit this CPU occupies in a cpuset.
rboolean r_sys_cpuset_present(RBitset *cpuset)
Fill cpuset with the physically-present CPUs.
ruint r_sys_nodeset_max(void)
Highest valid node index + 1 (sizing hint for a nodeset).
ruint r_sys_cpu_physical_count(void)
Number of physical cores.
RSysCpu * r_sys_topology_node_cpu(RSysNode *node, rsize idx)
Return the idx-th CPU of node as a new reference (caller r_sys_cpu_unref's), or NULL if out of range.
@ R_SYS_CPU_CACHE_DATA
Definition rsys.h:209
@ R_SYS_CPU_CACHE_TRACE
Definition rsys.h:211
@ R_SYS_CPU_CACHE_INSTRUCTION
Definition rsys.h:210
@ R_SYS_CPU_CACHE_UNIFIED
Definition rsys.h:208
int rboolean
Boolean type (typedef'd to int).
Definition rtypes.h:59
unsigned int ruint
Unsigned int.
Definition rtypes.h:157
unsigned long rsize
Unsigned pointer-sized size type (like size_t).
Definition rtypes.h:290
unsigned long ruint64
Unsigned 64-bit integer.
Definition rtypes.h:193
Fixed-width bitset with bit / byte / word accessors and bitwise compound operations.
Refcount base struct shared by every refcounted type in rlib.
Foundational type aliases used by every rlib header.
Fixed-width bitset.
Definition rbitset.h:68
One level of a CPU's cache hierarchy.
Definition rsys.h:221
rsize linesize
Definition rsys.h:225
ruint level
Definition rsys.h:222
rsize size
Definition rsys.h:224
rsize sets
Definition rsys.h:227
RSysCpuCacheType type
Definition rsys.h:223
rsize ways
Definition rsys.h:226