From 801455e69461f3e7cdfd546958ed4c10673a5726 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 13 Feb 2014 21:50:39 +1300 Subject: Fixes --- src/getcore.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'src/getcore.c') diff --git a/src/getcore.c b/src/getcore.c index f1eb7d7..617507c 100644 --- a/src/getcore.c +++ b/src/getcore.c @@ -25,28 +25,25 @@ int NUMBER_OF_CORES; static gboolean core_exists(int core) { - FILE* fd; - char path[80]; - char corestr[4]; + FILE* fd; + char path[80]; + char corestr[4]; - sprintf(corestr, "%i", core); + sprintf(corestr, "%i", core); + sprintf(path, "/sys/devices/system/cpu/cpu%s/cpufreq/scaling_cur_freq", corestr); - sprintf(path, "/sys/devices/system/cpu/cpu%s/cpufreq/scaling_cur_freq", corestr); - - if(!(fd = fopen(path, "r"))) - return FALSE; - - return TRUE; + return (gboolean)(fd = fopen(path, "r")); } void gc_init() { - NUMBER_OF_CORES = 0; - while(core_exists(NUMBER_OF_CORES)) - ++NUMBER_OF_CORES; + NUMBER_OF_CORES = 0; + while(core_exists(++NUMBER_OF_CORES)); } + +/* to do */ int gc_number() { - return NUMBER_OF_CORES; + return NUMBER_OF_CORES; } -- cgit v1.1