diff --git a/CMakeLists.txt b/CMakeLists.txt index b714ee0ce..f2b6dd865 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,5 @@ -project(xmr-stak) - cmake_minimum_required(VERSION 3.4.0) +project(xmr-stak) # enforce C++11 set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -444,8 +443,13 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") endif() if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") - set(CMAKE_CXX_FLAGS "-Wl,-z,noexecstack ${CMAKE_CXX_FLAGS}") - set(CMAKE_C_FLAGS "-Wl,-z,noexecstack ${CMAKE_C_FLAGS}") + if(CMAKE_RC_COMPILER MATCHES "windres") # lame hack to detect Cygwin + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -U_WIN32 -U__USE_W32_SOCKETS -D_POSIX_C_SOURCE=200112") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -U_WIN32 -U__USE_W32_SOCKETS -D_POSIX_C_SOURCE=200112") + else() + set(CMAKE_CXX_FLAGS "-Wl,-z,noexecstack ${CMAKE_CXX_FLAGS}") + set(CMAKE_C_FLAGS "-Wl,-z,noexecstack ${CMAKE_C_FLAGS}") + endif() endif() # activate static libgcc and libstdc++ linking diff --git a/xmrstak/backend/cpu/crypto/cryptonight_common.cpp b/xmrstak/backend/cpu/crypto/cryptonight_common.cpp index ee1ff2386..04497b0d8 100644 --- a/xmrstak/backend/cpu/crypto/cryptonight_common.cpp +++ b/xmrstak/backend/cpu/crypto/cryptonight_common.cpp @@ -259,6 +259,12 @@ cryptonight_ctx* cryptonight_alloc_ctx(size_t use_fast_mem, size_t use_mlock, al ptr->long_state = (uint8_t*)mmap(NULL, hashMemSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); #else +#ifndef MAP_HUGETLB +#define MAP_HUGETLB 0 +#endif +#ifndef MAP_POPULATE +#define MAP_POPULATE 0 +#endif ptr->long_state = (uint8_t*)mmap(NULL, hashMemSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB | MAP_POPULATE, -1, 0); #endif diff --git a/xmrstak/backend/cpu/minethd.cpp b/xmrstak/backend/cpu/minethd.cpp index 975f2d4a2..65a452a40 100644 --- a/xmrstak/backend/cpu/minethd.cpp +++ b/xmrstak/backend/cpu/minethd.cpp @@ -51,6 +51,13 @@ #include #include +#ifdef __CYGWIN__ +#define _WIN32 +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif +#endif + #ifdef _WIN32 #include #else diff --git a/xmrstak/http/httpd.cpp b/xmrstak/http/httpd.cpp index ed9abc2bc..661c1ca9f 100644 --- a/xmrstak/http/httpd.cpp +++ b/xmrstak/http/httpd.cpp @@ -23,6 +23,9 @@ #ifndef CONF_NO_HTTPD +#ifdef __CYGWIN__ +#include +#endif #include "httpd.hpp" #include "webdesign.hpp" diff --git a/xmrstak/http/httpd.hpp b/xmrstak/http/httpd.hpp index fe534f038..bb9a7e8ae 100644 --- a/xmrstak/http/httpd.hpp +++ b/xmrstak/http/httpd.hpp @@ -1,6 +1,9 @@ #pragma once #include +#ifdef __CYGWIN__ +#include +#endif struct MHD_Daemon; struct MHD_Connection; diff --git a/xmrstak/jconf.cpp b/xmrstak/jconf.cpp index 2a2dc8dbc..23ee7e6ba 100644 --- a/xmrstak/jconf.cpp +++ b/xmrstak/jconf.cpp @@ -37,12 +37,17 @@ #include #include +#ifdef __CYGWIN__ +#include +#include +#else #ifdef _WIN32 #define strcasecmp _stricmp #include #else #include #endif +#endif using namespace rapidjson; diff --git a/xmrstak/misc/executor.cpp b/xmrstak/misc/executor.cpp index a303b34cd..c66f21d55 100644 --- a/xmrstak/misc/executor.cpp +++ b/xmrstak/misc/executor.cpp @@ -46,6 +46,9 @@ #include +#ifdef __CYGWIN__ +#include +#endif //__CYGWIN__ #ifdef _WIN32 #define strncasecmp _strnicmp #endif // _WIN32 @@ -470,7 +473,7 @@ void executor::on_miner_result(size_t pool_id, job_result& oResult) } } -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(__CYGWIN__) #include void disable_sigpipe()