aboutsummaryrefslogtreecommitdiff
path: root/getcore.c
diff options
context:
space:
mode:
authorDavid <dbphillipsnz@gmail.com>2014-06-05 17:49:36 +1200
committerDavid <dbphillipsnz@gmail.com>2014-06-05 17:49:36 +1200
commitf33d490cc017c0a4915bb2ec175df0238702442b (patch)
tree62c19cd0b68f6d5bfd9a3105858d85b84b88b44a /getcore.c
parent66e266956c51be09cfc9a8c30c74d1ce80b834e0 (diff)
downloadparamano-f33d490cc017c0a4915bb2ec175df0238702442b.tar.xz
Clean-ups
Diffstat (limited to 'getcore.c')
-rw-r--r--getcore.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/getcore.c b/getcore.c
index 39abb1c..7ef5c91 100644
--- a/getcore.c
+++ b/getcore.c
@@ -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;
}