Skip to content

Commit

Permalink
Windows version support for latest commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanadnan committed Aug 17, 2018
1 parent ff7aa07 commit ff4db4b
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 29 deletions.
11 changes: 8 additions & 3 deletions common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,20 @@

#include <cmath>

#ifndef _MSC_VER
#include <unistd.h>
#include <sys/time.h>

#include<sys/socket.h>
#include<netdb.h>
#include<arpa/inet.h>

#ifndef _MSC_VER
#include <unistd.h>
#include <sys/time.h>
#else

#include <WinSock2.h>
#include <WS2tcpip.h>
#include <win64_compatibility_layer.h>

#endif

#include <config.h>
Expand Down
24 changes: 19 additions & 5 deletions http/http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,23 @@ struct http_data {
};

http::http() {
#ifdef _WIN64
WSADATA wsaData;
int iResult;

// Initialize Winsock
iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
if (iResult != 0) {
LOG("WSAStartup failed:"+ to_string(iResult));
exit(1);
}
#endif
}

http::~http() {
#ifdef _WIN64
WSACleanup();
#endif
}

vector<string> http::__resolve_host(const string &hostname)
Expand Down Expand Up @@ -123,9 +137,9 @@ string http::__get_response(const string &url, const string &post_data) {
struct sockaddr_in addr;
addr.sin_family = AF_INET;
addr.sin_port = htons(query.port);
inet_aton(ips[i].c_str(), &addr.sin_addr);
inet_pton(AF_INET, ips[i].c_str(), &addr.sin_addr);

#ifdef WIN64_
#ifdef _WIN64
DWORD sock_timeout = 10000;
#else
const struct timeval sock_timeout={.tv_sec=10, .tv_usec=0};
Expand All @@ -147,7 +161,7 @@ string http::__get_response(const string &url, const string &post_data) {
char *buff = (char *)request.c_str();
int sz = request.size();
while(sz > 0) {
int n = write(sockfd, buff, sz);
int n = send(sockfd, buff, sz, 0);
if(n < 0) {
return "";
}
Expand All @@ -164,12 +178,12 @@ string http::__get_response(const string &url, const string &post_data) {
parser.data = (void *)&reply;

char buffer[2048];
int n = read(sockfd, buffer, 2048);
int n = recv(sockfd, buffer, 2048, 0);

if(n > 0)
http_parser_execute(&parser, &settings, buffer, n);

close(sockfd);
closesocket(sockfd);
if(reply != "")
break;
}
Expand Down
4 changes: 2 additions & 2 deletions miner/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ miner::~miner() {

void miner::run() {
uint64_t begin, last_update, last_report;
begin = microseconds();
begin = (uint64_t)time(NULL);
last_update = last_report = 0;

vector<hasher*> hashers = hasher::get_active_hashers();
Expand Down Expand Up @@ -101,7 +101,7 @@ void miner::run() {
last_report = microseconds();
}

__total_time = (uint64_t)((microseconds() - begin) / 1000000.0);
__total_time = (uint64_t)((uint64_t)time(NULL) - begin);
this_thread::sleep_for(chrono::milliseconds(100));
}
}
Expand Down
27 changes: 17 additions & 10 deletions win32/ariominer/ariominer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,14 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>STACK_LINE_READER_BUFFER_SIZE=1024;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(INTELOCLSDKROOT)include;../;../dlfcn;../../hash/cpu/cpu_features/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>OpenCL.lib;psapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>OpenCL.lib;psapi.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(INTELOCLSDKROOT)lib/x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalOptions> /NODEFAULTLIB:libcpmt.lib %(AdditionalOptions)</AdditionalOptions>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug_AMD|x64'">
Expand All @@ -151,13 +152,14 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>STACK_LINE_READER_BUFFER_SIZE=1024;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(INTELOCLSDKROOT)include;../;../dlfcn;../../hash/cpu/cpu_features/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>OpenCL.lib;psapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>OpenCL.lib;psapi.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(INTELOCLSDKROOT)lib/x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalOptions> /NODEFAULTLIB:libcpmt.lib %(AdditionalOptions)</AdditionalOptions>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug_NVIDIA|x64'">
Expand All @@ -173,8 +175,9 @@
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>OpenCL.lib;psapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>OpenCL.lib;psapi.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.2\lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalOptions> /NODEFAULTLIB:libcpmt.lib %(AdditionalOptions)</AdditionalOptions>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_Intel|x64'">
Expand All @@ -194,7 +197,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>OpenCL.lib;psapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>OpenCL.lib;psapi.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(INTELOCLSDKROOT)lib/x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
Expand All @@ -215,7 +218,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>OpenCL.lib;psapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>OpenCL.lib;psapi.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(INTELOCLSDKROOT)lib/x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
Expand All @@ -238,14 +241,16 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>OpenCL.lib;psapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>OpenCL.lib;psapi.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.2\lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\app\arguments.cpp" />
<ClCompile Include="..\..\app\main.cpp" />
<ClCompile Include="..\..\common\common.cpp" />
<ClCompile Include="..\..\crypt\base64.cpp" />
<ClCompile Include="..\..\crypt\random_generator.cpp" />
<ClCompile Include="..\..\crypt\sha512.cpp" />
<ClCompile Include="..\..\hash\argon2\argon2.cpp" />
<ClCompile Include="..\..\hash\argon2\argon2profile_1_1_524288.c" />
Expand All @@ -269,7 +274,7 @@
<ClCompile Include="..\..\hash\hasher.cpp" />
<ClCompile Include="..\..\http\client.cpp" />
<ClCompile Include="..\..\http\http.cpp" />
<ClCompile Include="..\..\http\mongoose\mongoose.c" />
<ClCompile Include="..\..\http\http_parser\http_parser.c" />
<ClCompile Include="..\..\http\server.cpp" />
<ClCompile Include="..\..\miner\miner.cpp" />
<ClCompile Include="..\..\miner\mini-gmp\mini-gmp.c" />
Expand All @@ -280,6 +285,8 @@
<ItemGroup>
<ClInclude Include="..\..\app\arguments.h" />
<ClInclude Include="..\..\common\common.h" />
<ClInclude Include="..\..\crypt\base64.h" />
<ClInclude Include="..\..\crypt\random_generator.h" />
<ClInclude Include="..\..\crypt\sha512.h" />
<ClInclude Include="..\..\hash\argon2\argon2.h" />
<ClInclude Include="..\..\hash\argon2\blake2\blake2-impl.h" />
Expand All @@ -304,7 +311,7 @@
<ClInclude Include="..\..\hash\hasher.h" />
<ClInclude Include="..\..\http\client.h" />
<ClInclude Include="..\..\http\http.h" />
<ClInclude Include="..\..\http\mongoose\mongoose.h" />
<ClInclude Include="..\..\http\http_parser\http_parser.h" />
<ClInclude Include="..\..\http\server.h" />
<ClInclude Include="..\..\http\simplejson\json.h" />
<ClInclude Include="..\..\miner\miner.h" />
Expand Down
30 changes: 21 additions & 9 deletions win32/ariominer/ariominer.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@
<ClCompile Include="..\..\hash\hasher.cpp">
<Filter>hash</Filter>
</ClCompile>
<ClCompile Include="..\..\http\mongoose\mongoose.c">
<Filter>http\mongoose</Filter>
</ClCompile>
<ClCompile Include="..\..\http\client.cpp">
<Filter>http</Filter>
</ClCompile>
Expand All @@ -100,6 +97,15 @@
<ClCompile Include="..\win64_compatibility_layer.c">
<Filter>win64</Filter>
</ClCompile>
<ClCompile Include="..\..\http\http_parser\http_parser.c">
<Filter>http\http_parser</Filter>
</ClCompile>
<ClCompile Include="..\..\crypt\base64.cpp">
<Filter>crypt</Filter>
</ClCompile>
<ClCompile Include="..\..\crypt\random_generator.cpp">
<Filter>crypt</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\app\arguments.h">
Expand Down Expand Up @@ -174,9 +180,6 @@
<ClInclude Include="..\..\hash\hasher.h">
<Filter>hash</Filter>
</ClInclude>
<ClInclude Include="..\..\http\mongoose\mongoose.h">
<Filter>http\mongoose</Filter>
</ClInclude>
<ClInclude Include="..\..\http\simplejson\json.h">
<Filter>http\simplejson</Filter>
</ClInclude>
Expand Down Expand Up @@ -210,6 +213,15 @@
<ClInclude Include="..\win64_compatibility_layer.h">
<Filter>win64</Filter>
</ClInclude>
<ClInclude Include="..\..\http\http_parser\http_parser.h">
<Filter>http\http_parser</Filter>
</ClInclude>
<ClInclude Include="..\..\crypt\base64.h">
<Filter>crypt</Filter>
</ClInclude>
<ClInclude Include="..\..\crypt\random_generator.h">
<Filter>crypt</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="app">
Expand Down Expand Up @@ -248,9 +260,6 @@
<Filter Include="http">
<UniqueIdentifier>{d43761d5-a7de-472c-96f7-d023a6c489c7}</UniqueIdentifier>
</Filter>
<Filter Include="http\mongoose">
<UniqueIdentifier>{8b797ada-a205-4ff4-8a07-e6b571cb63d8}</UniqueIdentifier>
</Filter>
<Filter Include="http\simplejson">
<UniqueIdentifier>{e2498988-9444-4a61-b94e-bb3eaabdc235}</UniqueIdentifier>
</Filter>
Expand All @@ -272,6 +281,9 @@
<Filter Include="win64\dlfcn">
<UniqueIdentifier>{0f4541e7-e9f8-4c09-88f9-ec41c598e07e}</UniqueIdentifier>
</Filter>
<Filter Include="http\http_parser">
<UniqueIdentifier>{afe78bb6-d5f8-42ad-9af2-1a7bb0ef3ba3}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="..\tdr_delay.reg">
Expand Down

0 comments on commit ff4db4b

Please sign in to comment.