From b24cc115fa02733e62f1e622535f8ec3aed138bc Mon Sep 17 00:00:00 2001 From: celso Date: Tue, 22 Nov 2022 18:32:12 -0300 Subject: [PATCH] automatically detect threads and prompt user for polling time at build time --- Makefile | 5 ++++- src/homemade_speedstep.c | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 7b81d36..3e0f78a 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,8 @@ CC = gcc -CFLAGS = -Wall -Wpedantic -Wextra -O2 -march=native +CFLAGS = -Wall -Wpedantic -Wextra -O2 -march=native\ + -DTHREADS=$(shell grep processor /proc/cpuinfo | wc -l)\ + -DPOLLING_TIME=$(shell read -p "type seconds between temp checks >" P;\ + echo $$P) SRC = src BINDIR = bin BIN = homemade_speedstep diff --git a/src/homemade_speedstep.c b/src/homemade_speedstep.c index 06c20ef..4bdb366 100644 --- a/src/homemade_speedstep.c +++ b/src/homemade_speedstep.c @@ -3,8 +3,6 @@ #include #define VERSION "1.1" -#define POLLING_TIME 1 -#define THREADS 4 /* TODO: automatically figure out how many threads host system has */ #define FREQS "/sys/devices/system/cpu/cpufreq/policy0/scaling_available_frequencies" #define MAXSPDPREFIX "/sys/devices/system/cpu/cpu" #define MAXSPDSUFFIX "/cpufreq/scaling_max_freq"