mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-25 07:50:40 +01:00
[v0.97] Make loop option work on ARM too
This commit is contained in:
@@ -369,6 +369,33 @@ uint32_t longest_attribute_length(struct ascii* art) {
|
|||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool run_loop_mode() {
|
||||||
|
#ifdef _WIN32
|
||||||
|
if (!SetConsoleCtrlHandler(loop_mode_handler, TRUE)) {
|
||||||
|
printErr("SetConsoleCtrlHandler failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
struct sigaction act;
|
||||||
|
memset(&act, 0, sizeof(struct sigaction));
|
||||||
|
act.sa_handler = loop_mode_handler;
|
||||||
|
if(sigaction(SIGINT, &act, NULL) == -1) {
|
||||||
|
perror("sigaction");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
while (loop) {
|
||||||
|
#ifdef _WIN32
|
||||||
|
Sleep(1000);
|
||||||
|
#else
|
||||||
|
sleep(1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef ARCH_X86
|
#ifdef ARCH_X86
|
||||||
void print_algorithm_intel(struct ascii* art, int n, bool* flag) {
|
void print_algorithm_intel(struct ascii* art, int n, bool* flag) {
|
||||||
for(int i=0; i < LINE_SIZE; i++) {
|
for(int i=0; i < LINE_SIZE; i++) {
|
||||||
@@ -432,34 +459,7 @@ void print_ascii_x86(struct ascii* art, uint32_t la, void (*callback_print_algor
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool run_loop_mode() {
|
void print_ascii(struct ascii* art) {
|
||||||
#ifdef _WIN32
|
|
||||||
if (!SetConsoleCtrlHandler(loop_mode_handler, TRUE)) {
|
|
||||||
printErr("SetConsoleCtrlHandler failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
struct sigaction act;
|
|
||||||
memset(&act, 0, sizeof(struct sigaction));
|
|
||||||
act.sa_handler = loop_mode_handler;
|
|
||||||
if(sigaction(SIGINT, &act, NULL) == -1) {
|
|
||||||
perror("sigaction");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
while (loop) {
|
|
||||||
#ifdef _WIN32
|
|
||||||
Sleep(1000);
|
|
||||||
#else
|
|
||||||
sleep(1);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool print_ascii(struct ascii* art) {
|
|
||||||
uint32_t longest_attribute = longest_attribute_length(art);
|
uint32_t longest_attribute = longest_attribute_length(art);
|
||||||
|
|
||||||
if(art->vendor == CPU_VENDOR_INTEL)
|
if(art->vendor == CPU_VENDOR_INTEL)
|
||||||
@@ -469,12 +469,6 @@ bool print_ascii(struct ascii* art) {
|
|||||||
else {
|
else {
|
||||||
printBug("Invalid CPU vendor: %d\n", art->vendor);
|
printBug("Invalid CPU vendor: %d\n", art->vendor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(loop_mode()) {
|
|
||||||
return run_loop_mode();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool print_cpufetch_x86(struct cpuInfo* cpu, STYLE s, struct colors* cs) {
|
bool print_cpufetch_x86(struct cpuInfo* cpu, STYLE s, struct colors* cs) {
|
||||||
@@ -532,6 +526,10 @@ bool print_cpufetch_x86(struct cpuInfo* cpu, STYLE s, struct colors* cs) {
|
|||||||
|
|
||||||
print_ascii(art);
|
print_ascii(art);
|
||||||
|
|
||||||
|
if(loop_mode()) {
|
||||||
|
return run_loop_mode();
|
||||||
|
}
|
||||||
|
|
||||||
free(manufacturing_process);
|
free(manufacturing_process);
|
||||||
free(max_frequency);
|
free(max_frequency);
|
||||||
free(sockets);
|
free(sockets);
|
||||||
@@ -738,6 +736,10 @@ bool print_cpufetch_arm(struct cpuInfo* cpu, STYLE s, struct colors* cs) {
|
|||||||
|
|
||||||
print_ascii(art);
|
print_ascii(art);
|
||||||
|
|
||||||
|
if(loop_mode()) {
|
||||||
|
return run_loop_mode();
|
||||||
|
}
|
||||||
|
|
||||||
free(manufacturing_process);
|
free(manufacturing_process);
|
||||||
free(pp);
|
free(pp);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user