diff options
author | David <dbphillipsnz@gmail.com> | 2014-07-23 15:43:47 +1200 |
---|---|---|
committer | David <dbphillipsnz@gmail.com> | 2014-07-23 15:43:47 +1200 |
commit | 7abcda22dba07c74e052e0674619cd4c0d3a8a02 (patch) | |
tree | 108f20022218845020028b3650eeb384158d5c3d | |
parent | f041e2adac49f11f1f17ca7f172a79b9f71d52ea (diff) | |
download | paramano-7abcda22dba07c74e052e0674619cd4c0d3a8a02.tar.xz |
Finally fixed issue
-rw-r--r-- | getcore.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -23,6 +23,7 @@ #include <stdio.h> #include <stdlib.h> #include <glib.h> +#include <unistd.h> unsigned int cores; @@ -33,13 +34,11 @@ unsigned int cores; bool core_exists(unsigned int core) { FILE* fd; - char path[80]; - char corestr[4]; + char path[128]; - sprintf(corestr, "%d", core); - sprintf(path, "/sys/devices/system/cpu/cpu%s/cpufreq/cpuinfo_cur_freq", corestr); + sprintf(path, "/sys/devices/system/cpu/cpu%d/cpufreq", core); debug("Checking if core %d exists by opening '%s'\n",core,path); - return (gboolean)(fd = fopen(path, "r")); + return (access(path, F_OK) != -1); } @@ -49,7 +48,9 @@ bool core_exists(unsigned int core) void gc_init() { cores = 0; - while(core_exists(++cores)); + while(core_exists(cores)) + cores++; + debug("Found %d cores\n",cores); } |