Files
termux-packages/packages/cpufetch/src-x86-freq-freq.c.patch
2025-11-02 07:05:25 +00:00

39 lines
1.1 KiB
Diff

--- a/src/x86/freq/freq.c
+++ b/src/x86/freq/freq.c
@@ -146,11 +146,6 @@
pthread_t* compute_th = malloc(sizeof(pthread_t) * cpu->topo->total_cores);
cpu_set_t cpus;
- pthread_attr_t attr;
- if ((ret = pthread_attr_init(&attr)) != 0) {
- printErr("pthread_attr_init: %s", strerror(ret));
- return -1;
- }
for(int i=0; i < cpu->topo->total_cores; i++) {
// We might have called bind_to_cpu previously, binding the threads
@@ -158,17 +153,18 @@
// on the correct core.
CPU_ZERO(&cpus);
CPU_SET(i, &cpus);
- if ((ret = pthread_attr_setaffinity_np(&attr, sizeof(cpu_set_t), &cpus)) != 0) {
- printErr("pthread_attr_setaffinity_np: %s", strerror(ret));
- return -1;
- }
- ret = pthread_create(&compute_th[i], &attr, compute_function, NULL);
+ ret = pthread_create(&compute_th[i], NULL, compute_function, NULL);
if(ret != 0) {
fprintf(stderr, "Error creating thread\n");
return -1;
}
+
+ if ((ret = sched_setaffinity(pthread_gettid_np(compute_th[i]), sizeof(cpus), &cpus)) != 0) {
+ printErr("sched_setaffinity: %s", strerror(ret));
+ return -1;
+ }
}
sleep_ms(500);