From d5ec69d3b7900b39964d0aaa7158f4aaad8d65e9 Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Sat, 7 Nov 2015 19:03:38 +0100 Subject: [PATCH] Bitmsghash linux compile fixes --- src/bitmsghash/bitmsghash.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/bitmsghash/bitmsghash.cpp b/src/bitmsghash/bitmsghash.cpp index c0a40509..e05c88ae 100644 --- a/src/bitmsghash/bitmsghash.cpp +++ b/src/bitmsghash/bitmsghash.cpp @@ -31,11 +31,11 @@ unsigned long long successval = 0; unsigned int numthreads = 0; #ifdef _WIN32 -DWORD WINAPI threadfunc(LPVOID lpParameter) { +DWORD WINAPI threadfunc(LPVOID param) { #else void * threadfunc(void* param) { #endif - unsigned int incamt = *((unsigned int*)lpParameter); + unsigned int incamt = *((unsigned int*)param); SHA512_CTX sha; unsigned char buf[HASH_SIZE + sizeof(uint64_t)] = { 0 }; unsigned char output[HASH_SIZE] = { 0 }; @@ -85,11 +85,14 @@ void getnumthreads() numthreads = core_count; #endif for (unsigned int i = 0; i < len * 8; i++) +#ifdef _WIN32 if (dwProcessAffinity & (1i64 << i)) { +#else + if (CPU_ISSET(i, &dwProcessAffinity)) { +#endif numthreads++; printf("Detected core on: %u\n", i); } - printf("Affinity: %lx\n", (unsigned long) dwProcessAffinity); printf("Number of threads: %i\n", (int)numthreads); } @@ -111,7 +114,7 @@ extern "C" EXPORT unsigned long long BitmessagePOW(unsigned char * starthash, un # endif # endif unsigned int *threaddata = (unsigned int *)calloc(sizeof(unsigned int), numthreads); - for (UINT i = 0; i < numthreads; i++) { + for (unsigned int i = 0; i < numthreads; i++) { threaddata[i] = i; # ifdef _WIN32 threads[i] = CreateThread(NULL, 0, threadfunc, (LPVOID)&threaddata[i], 0, NULL); @@ -128,7 +131,7 @@ extern "C" EXPORT unsigned long long BitmessagePOW(unsigned char * starthash, un # ifdef _WIN32 WaitForMultipleObjects(numthreads, threads, TRUE, INFINITE); # else - for (int i = 0; i < numthreads; i++) { + for (unsigned int i = 0; i < numthreads; i++) { pthread_join(threads[i], NULL); } # endif