summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cpu.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/cpu.c b/src/cpu.c
index 0e282b1..780cba1 100644
--- a/src/cpu.c
+++ b/src/cpu.c
@@ -1,11 +1,9 @@
#include "cpu.h"
#include "common.h"
-#if defined(__linux__)
#include <stdio.h>
+#if defined(__linux__)
#include <stdlib.h>
-#elif defined(__sun)
-#include <stdio.h>
#endif
const char *display_cpu() {
@@ -17,14 +15,11 @@ const char *display_cpu() {
return run_command_s("sysctl -n hw.model | sed 's/(R)//' | "
"sed 's/(TM)//' | sed 's/CPU //' | sed 's/Processor//' && "
"echo \" (\" && sysctl -n hw.ncpu && echo \" core)\"");
+#elif defined(__sun)
+ return run_command_s("psrinfo -pv | tail -1 | sed 's/(r)//g' | "
+ "sed 's/ CPU//' | sed 's/^ *//' && "
+ "echo \" (\" && psrinfo -p && echo \" core)\"");
#elif defined(__linux__)
- return run_command_s("cat /proc/cpuinfo | awk -F '\\\\s*: | @' "
- "'/model name|Hardware|Processor|^cpu model|chip type|^cpu type/ { "
- "cpu=$2; if ($1 == \"Hardware\") exit } END { print cpu }' | "
- "sed 's/(R)//' | sed 's/(TM)//' | sed 's/CPU //' | sed 's/ Processor//' | "
- "sed 's/ [0-9]-Core//'");
- printf(" @ ");
-
char buf[20];
long int val;
double fmt;
@@ -49,8 +44,13 @@ const char *display_cpu() {
}
fclose(fp);
- return run_command_s("echo \"GHz (\" && nproc && echo \" core)\"");
-#elif defined(__sun)
- return NULL;
+
+ return run_command_s("cat /proc/cpuinfo | awk -F '\\\\s*: | @' "
+ "'/model name|Hardware|Processor|^cpu model|chip type|^cpu type/ { "
+ "cpu=$2; if ($1 == \"Hardware\") exit } END { print cpu }' | "
+ "sed 's/(R)//' | sed 's/(TM)//' | sed 's/CPU //' | sed 's/ Processor//' | "
+ "sed 's/ [0-9]-Core//' && echo \" @ \" && "
+ "echo \"GHz (\" && nproc && echo \" core)\"");
#endif
+ return NULL;
}