From f33d490cc017c0a4915bb2ec175df0238702442b Mon Sep 17 00:00:00 2001 From: David Date: Thu, 5 Jun 2014 17:49:36 +1200 Subject: Clean-ups --- getcore.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'getcore.c') diff --git a/getcore.c b/getcore.c index 39abb1c..7ef5c91 100644 --- a/getcore.c +++ b/getcore.c @@ -24,9 +24,13 @@ #include #include -unsigned int NUMBER_OF_CORES; +unsigned int cores; -static gboolean core_exists(unsigned int core) + +/*********************************************************************** + * Return true/false if specified core num exists + **********************************************************************/ +bool core_exists(unsigned int core) { FILE* fd; char path[80]; @@ -38,14 +42,22 @@ static gboolean core_exists(unsigned int core) return (gboolean)(fd = fopen(path, "r")); } + +/*********************************************************************** + * Initialise surrounding variables + **********************************************************************/ void gc_init() { - NUMBER_OF_CORES = 0; - while(core_exists(++NUMBER_OF_CORES)); - debug("Found %d cores\n",NUMBER_OF_CORES); + cores = 0; + while(core_exists(++cores)); + debug("Found %d cores\n",cores); } + +/*********************************************************************** + * Return number of cores + **********************************************************************/ int gc_number() { - return NUMBER_OF_CORES; + return cores; } -- cgit v1.1