aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsirius-m <sirius-m@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2009-10-31 09:11:43 +0000
committersirius-m <sirius-m@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2009-10-31 09:11:43 +0000
commitfe9f3d626d79f71d819caf43878299fa5e6af83e (patch)
tree6f8b6bdd3a53a58371dacb507d06ae6aaa18daf3
parent32d490313b21d5cea64f99ca9db4388591bb3ab9 (diff)
Linux alternatives for the Windows headers and PerformanceCounter. Some typedefs and #defines for the Linux build. Fixed GetDataDir.
git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@23 1a98c847-1fd6-4fd8-948a-caf3550aa51b
-rw-r--r--headers.h27
-rw-r--r--irc.h5
-rw-r--r--main.cpp2
-rw-r--r--net.h6
-rw-r--r--util.h12
5 files changed, 40 insertions, 12 deletions
diff --git a/headers.h b/headers.h
index 29b16fb780..16238f89b7 100644
--- a/headers.h
+++ b/headers.h
@@ -25,20 +25,13 @@
#include <openssl/evp.h>
#include <openssl/rand.h>
#include <openssl/sha.h>
-#include <openssl/ripemd.h>
-#include <windows.h>
-#include <winsock2.h>
-#include <mswsock.h>
-#include <shlobj.h>
-#include <shlwapi.h>
+#include <openssl/ripemd.h>
#include <stdio.h>
#include <stdlib.h>
-#include <io.h>
#include <math.h>
#include <limits.h>
#include <float.h>
#include <assert.h>
-#include <process.h>
#include <malloc.h>
#include <memory>
#define BOUNDSCHECK 1
@@ -56,7 +49,23 @@
#include <boost/tuple/tuple.hpp>
#include <boost/tuple/tuple_comparison.hpp>
#include <boost/tuple/tuple_io.hpp>
-#include <boost/array.hpp>
+#include <boost/array.hpp>
+
+#ifdef __WXMSW__
+#include <windows.h>
+#include <winsock2.h>
+#include <mswsock.h>
+#include <shlobj.h>
+#include <shlwapi.h>
+#include <io.h>
+#include <process.h>
+#else
+#include <sys/time.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <unistd.h>
+#endif
+
#pragma hdrstop
using namespace std;
using namespace boost;
diff --git a/irc.h b/irc.h
index 91c3ffe686..1dc348a8be 100644
--- a/irc.h
+++ b/irc.h
@@ -1,6 +1,11 @@
// Copyright (c) 2009 Satoshi Nakamoto
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
+
+#ifndef __WXMSW__
+#define closesocket(s) close(s)
+typedef u_int SOCKET;
+#endif
extern bool RecvLine(SOCKET hSocket, string& strLine);
extern void ThreadIRCSeed(void* parg);
diff --git a/main.cpp b/main.cpp
index b98477b033..156267771c 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1399,7 +1399,7 @@ string GetAppDir()
bool CheckDiskSpace(int64 nAdditionalBytes)
{
wxLongLong nFreeBytesAvailable = 0;
- if (!wxGetDiskSpace(GetDataDir(), NULL, &nFreeBytesAvailable))
+ if (!wxGetDiskSpace(wxStandardPaths::Get().GetDataDir(), NULL, &nFreeBytesAvailable))
{
printf("ERROR: wxGetDiskSpace() failed\n");
return true;
diff --git a/net.h b/net.h
index 4011a3ef75..2eece2c061 100644
--- a/net.h
+++ b/net.h
@@ -1,6 +1,12 @@
// Copyright (c) 2009 Satoshi Nakamoto
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
+
+#ifndef __WXMSW__
+#define closesocket(s) close(s)
+#define INVALID_SOCKET (SOCKET)(~0)
+typedef u_int SOCKET;
+#endif
class CMessageHeader;
class CAddress;
diff --git a/util.h b/util.h
index 1c7215d29d..5d18776002 100644
--- a/util.h
+++ b/util.h
@@ -321,11 +321,19 @@ inline void PrintHex(vector<unsigned char> vch, const char* pszFormat="%s", bool
{
printf(pszFormat, HexStr(vch, fSpaces).c_str());
}
+
inline int64 PerformanceCounter()
{
- int64 nCounter = 0;
- QueryPerformanceCounter((LARGE_INTEGER*)&nCounter);
+ int64 nCounter = 0;
+#ifdef __WXMSW__
+ QueryPerformanceCounter((LARGE_INTEGER*)&nCounter);
+#else
+ // this could be changed to reading /dev/urandom
+ timeval t;
+ gettimeofday(&t, NULL);
+ nCounter += t.tv_sec * 1000000 + t.tv_usec;
+#endif
return nCounter;
}