Fix clang compile

This commit is contained in:
NATTSiM
2013-12-18 12:52:08 -08:00
committed by Vinnie Falco
parent 6527cdfa97
commit 27b771e2ba
17 changed files with 104 additions and 48 deletions

View File

@@ -27,6 +27,7 @@
#include <cstring>
#include "Config.h"
#include "Uncopyable.h"
namespace beast {

View File

@@ -256,23 +256,29 @@ std::string RelativeTime::to_string () const
}
}
namespace beast {
namespace detail {
#if BEAST_WINDOWS
#include <windows.h>
namespace beast {
namespace detail {
static double monotonicCurrentTimeInSeconds()
{
return GetTickCount64() / 1000.0;
}
}
}
#elif BEAST_MAC || BEAST_IOS
#include <time.h>
#include <mach/mach_time.h>
#include <mach/mach.h>
namespace beast {
namespace detail {
static double monotonicCurrentTimeInSeconds()
{
@@ -309,20 +315,31 @@ static double monotonicCurrentTimeInSeconds()
return mach_absolute_time() * data.ratio;
}
}
}
#else
#include <time.h>
namespace beast {
namespace detail {
static double monotonicCurrentTimeInSeconds()
{
timespec t;
clock_gettime (CLOCK_MONOTONIC, &t);
return t.tv_sec + t.tv_nsec / 1000000000.0;
}
}
}
#endif
namespace beast {
namespace detail {
// Records and returns the time from process startup
static double getStartupTime()
{

View File

@@ -174,7 +174,6 @@
#ifdef __clang__
#define BEAST_CLANG 1
#define BEAST_GCC 1
#elif defined (__GNUC__)
#define BEAST_GCC 1
#elif defined (_MSC_VER)

View File

@@ -439,9 +439,16 @@ void Thread::yield()
#if BEAST_BSD
// ???
#elif BEAST_MAC || BEAST_IOS
// Compiles fine without prctl.h
#include <Foundation/NSThread.h>
#include <Foundation/NSString.h>
#import <objc/message.h>
namespace beast{
#include "../../../modules/beast_core/native/osx_ObjCHelpers.h"
}
#else
# include <sys/prctl.h>
#endif
namespace beast {

View File

@@ -130,7 +130,7 @@ private:
/** A reference counted, abstract completion handler. */
template <typename Signature, class Allocator = std::allocator <char> >
class AbstractHandler;
struct AbstractHandler;
//------------------------------------------------------------------------------

View File

@@ -62,14 +62,7 @@ public:
virtual void operator() (error_code const&, std::size_t);
template <typename Function>
void invoke (BOOST_ASIO_MOVE_ARG(Function) f)
{
// The allocator will hold a reference to the SharedHandler
// so that we can safely destroy the function object.
invoked_type invoked (f,
SharedHandlerAllocator <char> (this));
invoke (invoked);
}
void invoke (BEAST_MOVE_ARG(Function) f);
virtual void invoke (invoked_type& invoked) = 0;
virtual void* allocate (std::size_t size) = 0;

View File

@@ -111,17 +111,13 @@ private:
};
//------------------------------------------------------------------------------
#if 0
template <typename Function>
void SharedHandler::invoke (BOOST_ASIO_MOVE_ARG(Function) f)
void SharedHandler::invoke (BEAST_MOVE_ARG(Function) f)
{
// The allocator will hold a reference to the SharedHandler
// so that we can safely destroy the function object.
invoked_type invoked (BOOST_ASIO_MOVE_CAST(Function)(f),
SharedHandlerAllocator <char> (this));
invoked_type invoked (f,SharedHandlerAllocator <char> (this));
invoke (invoked);
}
#endif
#endif

View File

@@ -25,7 +25,7 @@
*/
struct SocketBase
{
protected:
public:
typedef boost::system::error_code error_code;
/** The error returned when a pure virtual is called.

View File

@@ -24,7 +24,6 @@
#ifndef BEAST_OSX_OBJCHELPERS_H_INCLUDED
#define BEAST_OSX_OBJCHELPERS_H_INCLUDED
/* This file contains a few helper functions that are used internally but which
need to be kept away from the public headers because they use obj-C symbols.
*/

View File

@@ -29,7 +29,6 @@
# define BOOST_BIND_PLACEHOLDERS_HPP_INCLUDED
#endif
#include <boost/version.hpp>
#include <boost/bind.hpp>
#include <boost/bind/arg.hpp>

View File

@@ -1488,11 +1488,11 @@ struct DBImpl::Writer {
Writer* next;
uint64_t start_sequence;
uint64_t end_sequence;
std::tr1::shared_ptr<WritableFile> logfile;
std::tr1::shared_ptr<log::Writer> log;
std::shared_ptr<WritableFile> logfile;
std::shared_ptr<log::Writer> log;
MemTable* mem;
std::tr1::shared_ptr<WritableFile> old_logfile;
std::tr1::shared_ptr<log::Writer> old_log;
std::shared_ptr<WritableFile> old_logfile;
std::shared_ptr<log::Writer> old_log;
explicit Writer()
: mtx(),

View File

@@ -8,7 +8,7 @@
#include <deque>
#include <list>
#include <set>
#include <tr1/memory>
#include <memory>
#include "dbformat.h"
#include "log_writer.h"
@@ -161,9 +161,9 @@ class DBImpl : public DB {
MemTable* mem_;
MemTable* imm_; // Memtable being compacted
port::AtomicPointer has_imm_; // So bg thread can detect non-NULL imm_
std::tr1::shared_ptr<WritableFile> logfile_;
std::shared_ptr<WritableFile> logfile_;
uint64_t logfile_number_;
std::tr1::shared_ptr<log::Writer> log_;
std::shared_ptr<log::Writer> log_;
uint32_t seed_; // For sampling.
// Synchronize writers

View File

@@ -20,6 +20,8 @@
#ifndef RIPPLE_PEERFINDER_LEGACYENDPOINTCACHE_H_INCLUDED
#define RIPPLE_PEERFINDER_LEGACYENDPOINTCACHE_H_INCLUDED
#include <functional>
namespace ripple {
namespace PeerFinder {
@@ -30,6 +32,7 @@ public:
typedef std::vector <LegacyEndpoint const*> FlattenedList;
private:
#if 0
typedef boost::multi_index_container <
LegacyEndpoint, boost::multi_index::indexed_by <
boost::multi_index::hashed_unique <
@@ -39,6 +42,8 @@ private:
> MapType;
MapType m_map;
#endif
Store& m_store;
Journal m_journal;
int m_mutationCount;
@@ -71,10 +76,12 @@ private:
FlattenedList flatten () const
{
FlattenedList list;
#if 0
list.reserve (m_map.size());
for (MapType::iterator iter (m_map.begin());
iter != m_map.end(); ++iter)
list.push_back (&*iter);
#endif
return list;
}
@@ -116,6 +123,7 @@ private:
std::random_shuffle (list.begin(), list.end());
std::sort (list.begin(), list.end(), PruneLess());
FlattenedList::const_iterator pos (list.begin() + list.size()/2 + 1);
#if 0
std::size_t const n (m_map.size() - (pos - list.begin()));
MapType map;
for (FlattenedList::const_iterator iter (list.begin());
@@ -123,6 +131,7 @@ private:
map.insert (**iter);
std::swap (map, m_map);
m_journal.info << "Pruned " << n << " legacy endpoints";
#endif
mutate();
}
@@ -160,7 +169,11 @@ public:
std::size_t size() const
{
#if 0
return m_map.size();
#else
return 0;
#endif
}
/** Load the legacy endpoints cache from the database. */
@@ -173,16 +186,18 @@ public:
for (List::const_iterator iter (list.begin());
iter != list.end(); ++iter)
{
#if 0
std::pair <LegacyEndpoint const&, bool> result (insert (*iter, now));
if (result.second)
++n;
#endif
}
m_journal.debug << "Loaded " << n << " legacy endpoints";
m_mutationCount = 0;
}
#if 0
/** Attempt to insert the endpoint.
The caller is responsible for making sure the address is valid.
The return value provides a reference to the new or existing endpoint.
The bool indicates whether or not the insertion took place.
*/
@@ -196,13 +211,16 @@ public:
mutate();
return std::make_pair (*result.first, result.second);
}
#endif
/** Returns a pointer to the legacy endpoint if it exists, else nullptr. */
LegacyEndpoint const* find (IPAddress const& address)
{
#if 0
MapType::iterator iter (m_map.find (address));
if (iter != m_map.end())
return &*iter;
#endif
return nullptr;
}

View File

@@ -36,6 +36,7 @@ namespace PeerFinder {
//------------------------------------------------------------------------------
#if 0
typedef boost::multi_index_container <
PeerInfo, boost::multi_index::indexed_by <
boost::multi_index::hashed_unique <
@@ -46,6 +47,7 @@ typedef boost::multi_index_container <
IPAddress::hasher>
>
> Peers;
#endif
//------------------------------------------------------------------------------
@@ -109,8 +111,10 @@ public:
// The current tally of peer slot statistics
Slots m_slots;
#if 0
// Our view of the current set of connected peers.
Peers m_peers;
#endif
Cache m_cache;
@@ -278,9 +282,11 @@ public:
for (FixedPeers::const_iterator iter (m_fixedPeers.begin());
iter != m_fixedPeers.end(); ++iter)
{
#if 0
// Make sure the fixed peer is not already connected
if (m_peers.get<1>().find (*iter) == m_peers.get<1>().end())
list.push_back (*iter);
#endif
}
}
@@ -346,9 +352,11 @@ public:
{
m_cache.sweep (get_now());
#if 0
for (Peers::iterator iter (m_peers.begin());
iter != m_peers.end(); ++iter)
iter->received.cycle();
#endif
}
// Called when an outbound connection attempt is started
@@ -407,10 +415,13 @@ public:
if (! inbound)
m_legacyCache.checked (address, true);
#if 0
std::pair <Peers::iterator, bool> result (
m_peers.insert (
PeerInfo (id, address, inbound, get_now())));
bassert (result.second);
#endif
m_slots.addPeer (m_config, inbound);
// VFALCO NOTE Update fixed peers count (HACKED)
@@ -428,6 +439,7 @@ public:
//
void onPeerDisconnected (PeerID const& id)
{
#if 0
Peers::iterator iter (m_peers.find (id));
bassert (iter != m_peers.end());
PeerInfo const& peer (*iter);
@@ -444,6 +456,7 @@ public:
// Must come last
m_peers.erase (iter);
#endif
}
//--------------------------------------------------------------------------
@@ -530,6 +543,7 @@ public:
//
void sendEndpoints ()
{
#if 0
if (! m_peers.empty())
{
m_journal.trace << "Sending endpoints...";
@@ -555,6 +569,7 @@ public:
}
}
}
#endif
}
// Called when the Checker completes a connectivity test
@@ -565,6 +580,7 @@ public:
if (result.error == boost::asio::error::operation_aborted)
return;
#if 0
Peers::iterator iter (m_peers.find (id));
if (iter != m_peers.end())
{
@@ -602,12 +618,14 @@ public:
m_journal.debug << "Finished listening test for " <<
id << " but the peer disconnected. ";
}
#endif
}
// Called when a peer sends us the mtENDPOINTS message.
//
void onPeerEndpoints (PeerID const& id, std::vector <Endpoint> list)
{
#if 0
Peers::iterator iter (m_peers.find (id));
bassert (iter != m_peers.end());
@@ -700,6 +718,7 @@ public:
}
peer.whenAcceptEndpoints = now + secondsPerMessage;
#endif
}
//--------------------------------------------------------------------------
@@ -740,10 +759,12 @@ public:
for (std::vector <IPAddress>::const_iterator iter (results.list.begin());
iter != results.list.end(); ++iter)
{
#if 0
std::pair <LegacyEndpoint const&, bool> result (
m_legacyCache.insert (*iter, now));
if (result.second)
++newEntries;
#endif
}
m_journal.debug <<
@@ -787,6 +808,7 @@ public:
{
if (! validIPAddress (address))
return;
#if 0
std::pair <LegacyEndpoint const&, bool> result (
m_legacyCache.insert (address, get_now()));
if (result.second)
@@ -803,6 +825,7 @@ public:
this, address, _1));
#endif
}
#endif
}
};

View File

@@ -1367,7 +1367,7 @@ class PosixEnv : public Env {
#if (__GLIBC__ * 1000 + __GLIBC_MINOR__) >= 2012
pthread_setname_np (pthread_self(), "rocksdb:bg");
#else
prctl (PR_SET_NAME, "rocksdb:bg", 0, 0, 0);
pthread_setname_np("rocksdb:bg");
#endif
reinterpret_cast<ThreadPool*>(arg)->BGThread();
return nullptr;

View File

@@ -52,17 +52,7 @@ public:
/** Returns the LogPartition based on a type key. */
template <class Key>
static LogPartition& get ()
{
struct LogPartitionType : LogPartition
{
LogPartitionType () : LogPartition (getPartitionName <Key> ())
{ }
};
// Each LogPartition is a singleton.
return *SharedSingleton <LogPartitionType>::getInstance();
}
static LogPartition& get ();
/** Returns a Journal using the specified LogPartition type key. */
template <class Key>
@@ -110,6 +100,19 @@ private:
std::string mName;
};
template <class Key>
LogPartition& LogPartition::get ()
{
struct LogPartitionType : LogPartition
{
LogPartitionType () : LogPartition (getPartitionName <Key> ())
{ }
};
// Each LogPartition is a singleton.
return *SharedSingleton <LogPartitionType>::getInstance();
}
#define SETUP_LOG(Class) \
template <> char const* LogPartition::getPartitionName <Class> () { return #Class; } \
struct Class##Instantiator { Class##Instantiator () { LogPartition::get <Class> (); } }; \