From 5dcbec085671abaa3f0d8355147ddf10b34a8ae3 Mon Sep 17 00:00:00 2001 From: Perceval Faramaz Date: Mon, 13 Mar 2017 17:17:42 +0100 Subject: [PATCH] Made count_processor compatible w/ macOS --- vanitygen.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/vanitygen.c b/vanitygen.c index aadb3c6..dc81658 100644 --- a/vanitygen.c +++ b/vanitygen.c @@ -43,6 +43,10 @@ #include "custom_ec_bn.h" +#if defined(__APPLE__) +#include +#endif + const char *version = VANITYGEN_VERSION; const enum compressiontype{ @@ -425,9 +429,14 @@ vg_thread_loop(void *arg) int count_processors(void) { + int count = 0; + +#if defined(__APPLE__) + size_t count_len = sizeof(count); + sysctlbyname("hw.logicalcpu", &count, &count_len, NULL, 0); +#else FILE *fp; char buf[512]; - int count = 0; fp = fopen("/proc/cpuinfo", "r"); if (!fp) @@ -438,6 +447,8 @@ count_processors(void) count += 1; } fclose(fp); +#endif + return count; } #endif