summaryrefslogtreecommitdiffstats
path: root/Affinity.c
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2021-02-17 17:38:35 +0100
committerBenny Baumann <BenBE@geshi.org>2021-03-19 23:30:54 +0100
commita11d01568c5e7bc5570fd48fa0703d837c4bcd84 (patch)
tree3e298e81123789ed6ae288e5bd32e91ebfb3ff01 /Affinity.c
parent53bcc5cbffbdd69e0e08bd33c5e357dd5b753456 (diff)
Use unsigned types for CPU counts and associated variables
Diffstat (limited to 'Affinity.c')
-rw-r--r--Affinity.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/Affinity.c b/Affinity.c
index 6b39b399..ee6eb519 100644
--- a/Affinity.c
+++ b/Affinity.c
@@ -30,7 +30,7 @@ in the source distribution for its full text.
Affinity* Affinity_new(ProcessList* pl) {
Affinity* this = xCalloc(1, sizeof(Affinity));
this->size = 8;
- this->cpus = xCalloc(this->size, sizeof(int));
+ this->cpus = xCalloc(this->size, sizeof(unsigned int));
this->pl = pl;
return this;
}
@@ -40,10 +40,10 @@ void Affinity_delete(Affinity* this) {
free(this);
}
-void Affinity_add(Affinity* this, int id) {
+void Affinity_add(Affinity* this, unsigned int id) {
if (this->used == this->size) {
this->size *= 2;
- this->cpus = xRealloc(this->cpus, sizeof(int) * this->size);
+ this->cpus = xRealloc(this->cpus, sizeof(unsigned int) * this->size);
}
this->cpus[this->used] = id;
this->used++;
@@ -59,7 +59,7 @@ Affinity* Affinity_get(const Process* proc, ProcessList* pl) {
if (ok) {
affinity = Affinity_new(pl);
if (hwloc_bitmap_last(cpuset) == -1) {
- for (int i = 0; i < pl->cpuCount; i++) {
+ for (unsigned int i = 0; i < pl->cpuCount; i++) {
Affinity_add(affinity, i);
}
} else {
@@ -76,7 +76,7 @@ Affinity* Affinity_get(const Process* proc, ProcessList* pl) {
bool Affinity_set(Process* proc, Arg arg) {
Affinity* this = arg.v;
hwloc_cpuset_t cpuset = hwloc_bitmap_alloc();
- for (int i = 0; i < this->used; i++) {
+ for (unsigned int i = 0; i < this->used; i++) {
hwloc_bitmap_set(cpuset, this->cpus[i]);
}
bool ok = (hwloc_set_proc_cpubind(this->pl->topology, proc->pid, cpuset, HTOP_HWLOC_CPUBIND_FLAG) == 0);
@@ -93,7 +93,7 @@ Affinity* Affinity_get(const Process* proc, ProcessList* pl) {
return NULL;
Affinity* affinity = Affinity_new(pl);
- for (int i = 0; i < pl->cpuCount; i++) {
+ for (unsigned int i = 0; i < pl->cpuCount; i++) {
if (CPU_ISSET(i, &cpuset)) {
Affinity_add(affinity, i);
}
@@ -105,7 +105,7 @@ bool Affinity_set(Process* proc, Arg arg) {
Affinity* this = arg.v;
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
- for (int i = 0; i < this->used; i++) {
+ for (unsigned int i = 0; i < this->used; i++) {
CPU_SET(this->cpus[i], &cpuset);
}
bool ok = (sched_setaffinity(proc->pid, sizeof(unsigned long), &cpuset) == 0);

© 2014-2024 Faster IT GmbH | imprint | privacy policy