Compile fixes
- OSX and Windows compile fixes
This commit is contained in:
parent
5a681068fe
commit
0a8fdd7eff
|
@ -11,6 +11,10 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef __APPLE__
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
#include "openssl/sha.h"
|
||||
|
||||
|
@ -23,7 +27,9 @@
|
|||
#define EXPORT __declspec(dllexport)
|
||||
#endif
|
||||
|
||||
#ifndef __APPLE__
|
||||
#define ntohll(x) ( ( (uint64_t)(ntohl( (unsigned int)((x << 32) >> 32) )) << 32) | ntohl( ((unsigned int)(x >> 32)) ) )
|
||||
#endif
|
||||
|
||||
unsigned long long max_val;
|
||||
unsigned char *initialHash;
|
||||
|
@ -73,7 +79,7 @@ void getnumthreads()
|
|||
int dwProcessAffinity = 0;
|
||||
int32_t core_count = 0;
|
||||
#endif
|
||||
unsigned int len = sizeof(dwProcessAffinity);
|
||||
size_t len = sizeof(dwProcessAffinity);
|
||||
if (numthreads > 0)
|
||||
return;
|
||||
#ifdef _WIN32
|
||||
|
@ -81,14 +87,16 @@ void getnumthreads()
|
|||
#elif __linux__
|
||||
sched_getaffinity(0, len, &dwProcessAffinity);
|
||||
#else
|
||||
if (sysctlbyname("hw.logicalcpu", &core_count, &len, 0, 0))
|
||||
if (sysctlbyname("hw.logicalcpu", &core_count, &len, 0, 0) == 0)
|
||||
numthreads = core_count;
|
||||
#endif
|
||||
for (unsigned int i = 0; i < len * 8; i++)
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
if (dwProcessAffinity & (1i64 << i)) {
|
||||
#else
|
||||
#elif defined __linux__
|
||||
if (CPU_ISSET(i, &dwProcessAffinity)) {
|
||||
#else
|
||||
if (dwProcessAffinity & (1 << i)) {
|
||||
#endif
|
||||
numthreads++;
|
||||
printf("Detected core on: %u\n", i);
|
||||
|
@ -107,11 +115,7 @@ extern "C" EXPORT unsigned long long BitmessagePOW(unsigned char * starthash, un
|
|||
# else
|
||||
pthread_t* threads = (pthread_t*)calloc(sizeof(pthread_t), numthreads);
|
||||
struct sched_param schparam;
|
||||
# ifdef __linux__
|
||||
schparam.sched_priority = 0;
|
||||
# else
|
||||
schparam.sched_priority = PTHREAD_MIN_PRIORITY;
|
||||
# endif
|
||||
# endif
|
||||
unsigned int *threaddata = (unsigned int *)calloc(sizeof(unsigned int), numthreads);
|
||||
for (unsigned int i = 0; i < numthreads; i++) {
|
||||
|
@ -124,7 +128,7 @@ extern "C" EXPORT unsigned long long BitmessagePOW(unsigned char * starthash, un
|
|||
# ifdef __linux__
|
||||
pthread_setschedparam(threads[i], SCHED_IDLE, &schparam);
|
||||
# else
|
||||
pthread_setschedparam(threads[i], SCHED_RR, &schparam)
|
||||
pthread_setschedparam(threads[i], SCHED_RR, &schparam);
|
||||
# endif
|
||||
# endif
|
||||
}
|
||||
|
|
Reference in New Issue
Block a user