aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2010-11-27 03:50:52 -0500
committerJeff Garzik <jgarzik@redhat.com>2010-11-27 03:50:52 -0500
commit4c47553c856183d16d4b9a22490bc419b9036109 (patch)
tree78a8125b1c80c54f64dc2cc316d023fdd6ea5c0e
parent6288d943abe9418164da5d5e5dc97e0065e1fa82 (diff)
Clean up multi-algorithm selection and display
-rw-r--r--cpu-miner.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/cpu-miner.c b/cpu-miner.c
index 237f980..8243718 100644
--- a/cpu-miner.c
+++ b/cpu-miner.c
@@ -41,6 +41,16 @@ enum sha256_algos {
ALGO_VIA, /* VIA padlock */
};
+static const char *algo_names[] = {
+ [ALGO_C] = "c",
+#ifdef WANT_SSE2_4WAY
+ [ALGO_4WAY] = "4way",
+#endif
+#ifdef WANT_VIA_PADLOCK
+ [ALGO_VIA] = "via",
+#endif
+};
+
bool opt_debug = false;
bool opt_protocol = false;
static bool program_running = true;
@@ -359,21 +369,17 @@ static void show_usage(void)
static void parse_arg (int key, char *arg)
{
- int v;
+ int v, i;
switch(key) {
case 'a':
- if (!strcmp(arg, "c"))
- opt_algo = ALGO_C;
-#ifdef WANT_SSE2_4WAY
- else if (!strcmp(arg, "4way"))
- opt_algo = ALGO_4WAY;
-#endif
-#ifdef WANT_VIA_PADLOCK
- else if (!strcmp(arg, "via"))
- opt_algo = ALGO_VIA;
-#endif
- else
+ for (i = 0; i < ARRAY_SIZE(algo_names); i++) {
+ if (!strcmp(arg, algo_names[i])) {
+ opt_algo = i;
+ break;
+ }
+ }
+ if (i == ARRAY_SIZE(algo_names))
show_usage();
break;
case 'D':
@@ -444,7 +450,10 @@ int main (int argc, char *argv[])
sleep(1); /* don't pound RPC server all at once */
}
- fprintf(stderr, "%d miner threads started.\n", opt_n_threads);
+ fprintf(stderr, "%d miner threads started, "
+ "using SHA256 '%s' algorithm.\n",
+ opt_n_threads,
+ algo_names[opt_algo]);
/* main loop */
while (program_running) {