diff options
author | David <dbphillipsnz@gmail.com> | 2014-06-05 17:49:36 +1200 |
---|---|---|
committer | David <dbphillipsnz@gmail.com> | 2014-06-05 17:49:36 +1200 |
commit | f33d490cc017c0a4915bb2ec175df0238702442b (patch) | |
tree | 62c19cd0b68f6d5bfd9a3105858d85b84b88b44a /getcore.c | |
parent | 66e266956c51be09cfc9a8c30c74d1ce80b834e0 (diff) | |
download | paramano-f33d490cc017c0a4915bb2ec175df0238702442b.tar.xz |
Clean-ups
Diffstat (limited to 'getcore.c')
-rw-r--r-- | getcore.c | 24 |
1 files changed, 18 insertions, 6 deletions
@@ -24,9 +24,13 @@ #include <stdlib.h> #include <glib.h> -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; } |