kernel: Make get_cpu_topology() return a pointer to const
The client code is not supposed to change the topology info. It would be also nice if cpu_topology_node::children was an array of pointers to const but that would require several const_casts in the topology tree generation code so it's probably not worth it.
This commit is contained in:
parent
735f67481f
commit
4fcbac58de
@ -105,7 +105,7 @@ cpu_ent *get_cpu_struct(void);
|
||||
extern inline cpu_ent *get_cpu_struct(void) { return &gCPU[smp_get_current_cpu()]; }
|
||||
|
||||
status_t cpu_build_topology_tree(void);
|
||||
cpu_topology_node* get_cpu_topology(void);
|
||||
const cpu_topology_node* get_cpu_topology(void);
|
||||
|
||||
status_t increase_cpu_performance(int delta, bool allowBoost);
|
||||
status_t decrease_cpu_performance(int delta);
|
||||
|
@ -274,7 +274,7 @@ cpu_build_topology_tree(void)
|
||||
}
|
||||
|
||||
|
||||
cpu_topology_node*
|
||||
const cpu_topology_node*
|
||||
get_cpu_topology(void)
|
||||
{
|
||||
return &sCPUTopology;
|
||||
|
@ -391,7 +391,7 @@ restore_interrupts(cpu_status status)
|
||||
static
|
||||
uint32 assign_cpu(void)
|
||||
{
|
||||
cpu_topology_node* node;
|
||||
const cpu_topology_node* node;
|
||||
do {
|
||||
int32 nextID = atomic_add(&sLastCPU, 1);
|
||||
node = get_cpu_topology();
|
||||
|
@ -751,7 +751,7 @@ scheduler_set_cpu_enabled(int32 cpuID, bool enabled)
|
||||
|
||||
|
||||
static void
|
||||
traverse_topology_tree(cpu_topology_node* node, int packageID, int coreID)
|
||||
traverse_topology_tree(const cpu_topology_node* node, int packageID, int coreID)
|
||||
{
|
||||
switch (node->level) {
|
||||
case CPU_TOPOLOGY_SMT:
|
||||
@ -805,7 +805,7 @@ build_topology_mappings(int32& cpuCount, int32& coreCount, int32& packageCount)
|
||||
}
|
||||
}
|
||||
|
||||
cpu_topology_node* root = get_cpu_topology();
|
||||
const cpu_topology_node* root = get_cpu_topology();
|
||||
traverse_topology_tree(root, 0, 0);
|
||||
|
||||
cpuToCoreDeleter.Detach();
|
||||
|
Loading…
Reference in New Issue
Block a user