diff --git a/vanitygen.c b/vanitygen.c index 9d88121..aae9413 100644 --- a/vanitygen.c +++ b/vanitygen.c @@ -32,6 +32,15 @@ #include "pattern.h" #include "util.h" + +#if defined(__APPLE__) + +#include +#include + +#endif + + const char *version = VANITYGEN_VERSION; @@ -241,6 +250,28 @@ vg_thread_loop(void *arg) #if !defined(_WIN32) +// define count_processors only on non Windows systems + +#if defined(__APPLE__) +// possibly *BSD goes here as well + +int +count_processors(void) +{ + int error = 0; + int value = 0; + size_t length = sizeof(value); + + error = sysctlbyname("hw.ncpu", &value, &length, NULL, 0); + if (error == 0) + return value; + + return 0; +} + +#else + +// default case is Linux int count_processors(void) { @@ -261,6 +292,8 @@ count_processors(void) } #endif +#endif + int start_threads(vg_context_t *vcp, int nthreads) {