mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-30 07:55:51 +00:00
Fix platform and debug macros
This commit is contained in:
@@ -54,7 +54,7 @@ namespace boost
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// ByteOrder
|
||||
#ifdef WIN32
|
||||
#if BEAST_WIN32
|
||||
// (nothing)
|
||||
#elif __APPLE__
|
||||
# include <libkern/OSByteOrder.h>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifdef WIN32
|
||||
#if BEAST_WIN32
|
||||
|
||||
// from: http://stackoverflow.com/questions/3022552/is-there-any-standard-htonl-like-function-for-64-bits-integers-in-c
|
||||
// but we don't need to check the endianness
|
||||
|
||||
@@ -11,8 +11,7 @@
|
||||
|
||||
// Reference: http://www.mail-archive.com/licq-commits@googlegroups.com/msg02334.html
|
||||
|
||||
// VFALCO TODO use BEAST_* platform macros instead of hard-coded compiler specific ones
|
||||
#ifdef WIN32
|
||||
#if BEAST_WIN32
|
||||
extern uint64_t htobe64 (uint64_t value);
|
||||
extern uint64_t be64toh (uint64_t value);
|
||||
extern uint32_t htobe32 (uint32_t value);
|
||||
|
||||
@@ -67,7 +67,7 @@ inline uint160 Hash160 (Blob const& vch)
|
||||
}
|
||||
|
||||
/*
|
||||
#ifdef WIN32
|
||||
#if BEAST_WIN32
|
||||
// This is used to attempt to keep keying material out of swap
|
||||
// Note that VirtualLock does not provide this as a guarantee on Windows,
|
||||
// but, in practice, memory that has been VirtualLock'd almost never gets written to
|
||||
|
||||
@@ -63,8 +63,7 @@ RandomNumbers& RandomNumbers::getInstance ()
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// VFALCO TODO replace WIN32 macro with BEAST_WIN32
|
||||
#ifdef WIN32
|
||||
#if BEAST_WIN32
|
||||
|
||||
// Get entropy from the Windows crypto provider
|
||||
bool RandomNumbers::platformAddEntropy ()
|
||||
@@ -75,7 +74,7 @@ bool RandomNumbers::platformAddEntropy ()
|
||||
|
||||
if (!CryptGetDefaultProviderA (PROV_RSA_FULL, NULL, CRYPT_MACHINE_DEFAULT, name, &count))
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifdef BEAST_DEBUG
|
||||
std::cerr << "Unable to get default crypto provider" << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
@@ -83,7 +82,7 @@ bool RandomNumbers::platformAddEntropy ()
|
||||
|
||||
if (!CryptAcquireContextA (&cryptoHandle, NULL, name, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT))
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifdef BEAST_DEBUG
|
||||
std::cerr << "Unable to acquire crypto provider" << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
@@ -91,7 +90,7 @@ bool RandomNumbers::platformAddEntropy ()
|
||||
|
||||
if (!CryptGenRandom (cryptoHandle, 128, reinterpret_cast<BYTE*> (rand)))
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifdef BEAST_DEBUG
|
||||
std::cerr << "Unable to get entropy from crypto provider" << std::endl;
|
||||
#endif
|
||||
CryptReleaseContext (cryptoHandle, 0);
|
||||
@@ -115,7 +114,7 @@ bool RandomNumbers::platformAddEntropy ()
|
||||
|
||||
if (!reader.is_open ())
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifdef BEAST_DEBUG
|
||||
std::cerr << "Unable to open random source" << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
@@ -127,7 +126,7 @@ bool RandomNumbers::platformAddEntropy ()
|
||||
|
||||
if (bytesRead == 0)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifdef BEAST_DEBUG
|
||||
std::cerr << "Unable to read from random source" << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
@@ -170,7 +169,7 @@ void RandomNumbers::platformAddPerformanceMonitorEntropy ()
|
||||
int64 operator () () const
|
||||
{
|
||||
int64 nCounter = 0;
|
||||
#if defined(WIN32) || defined(WIN64)
|
||||
#if BEAST_WIN32
|
||||
QueryPerformanceCounter ((LARGE_INTEGER*)&nCounter);
|
||||
#else
|
||||
timeval t;
|
||||
@@ -198,7 +197,7 @@ void RandomNumbers::platformAddPerformanceMonitorEntropy ()
|
||||
|
||||
nLastPerfmon = GetTime ();
|
||||
|
||||
#ifdef WIN32
|
||||
#if BEAST_WIN32
|
||||
// Don't need this on Linux, OpenSSL automatically uses /dev/urandom
|
||||
// Seed with the entire set of perfmon data
|
||||
unsigned char pdata[250000];
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
// VFALCO TODO Repalce these with something more robust and without macros.
|
||||
// VFALCO TODO Replace these with something more robust and without macros.
|
||||
//
|
||||
#if !defined(WIN32) && !defined(WIN64)
|
||||
#if ! BEAST_MSVC
|
||||
#define _vsnprintf(a,b,c,d) vsnprintf(a,b,c,d)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ PackedMessage::PackedMessage (::google::protobuf::Message const& message, int ty
|
||||
{
|
||||
message.SerializeToArray (&mBuffer [PackedMessage::kHeaderBytes], messageBytes);
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef BEAST_DEBUG
|
||||
// std::cerr << "PackedMessage: type=" << type << ", datalen=" << msg_size << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user