From 42d79b75c81f6d25293c02eab71e3437d9d892b5 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 23 Jul 2014 15:43:47 +1200 Subject: Finally fixed issue --- getcore.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/getcore.c b/getcore.c index 23bf946..51ac0e4 100644 --- a/getcore.c +++ b/getcore.c @@ -23,6 +23,7 @@ #include #include #include +#include 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); } -- cgit v1.1