Skip to content

Commit

Permalink
* Cmake: use gnu++c14 dialect on mac os in order to compile with rece…
Browse files Browse the repository at this point in the history
…nt boost version.

* Eliminate compiling warnings and deprecated by new c++ standard routines.
  • Loading branch information
mikeov committed Jun 10, 2021
1 parent a960dd1 commit 42e61d3
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ if(ENABLE_COVERAGE)
set(CMAKE_C_FLAGS "-coverage")
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14")
endif()

if(ENABLE_PROFILING)
message(STATUS "Enabling profiling with gprof")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
Expand Down
5 changes: 2 additions & 3 deletions src/cc/common/KfsTraceNew.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,10 @@ KfsTraceNew::MallocFailed(
}

void*
operator new(std::size_t inSize) throw (
operator new(std::size_t inSize)
#if __cplusplus <= 201103L
std::bad_alloc
(throw std::bad_alloc)
#endif
)
{
return KfsTraceNew::Instance().Allocate(inSize, true);
}
Expand Down
2 changes: 1 addition & 1 deletion src/cc/kfsio/isaac64.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ ub8 aa, bb, cc;

void isaac64()
{
register ub8 a,b,x,y,*m,*m2,*r,*mend;
ub8 a,b,x,y,*m,*m2,*r,*mend;
/* m=mm; */ r=randrsl;
a = aa; b = bb + (++cc);
for (m = mm, mend = m2 = m+(RANDSIZ/2); m<mend; )
Expand Down
25 changes: 23 additions & 2 deletions src/cc/libclient/Reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
#include <limits>
#include <string.h>

#if __cplusplus >= 201103L
#include <random>
#endif

namespace KFS
{
namespace client
Expand All @@ -63,10 +67,16 @@ using std::max;
using std::string;
using std::ostream;
using std::ostringstream;
using std::random_shuffle;
using std::vector;
using std::pair;
using std::make_pair;
#if __cplusplus < 201103L
using std::random_shuffle;
#else
using std::shuffle;
using std::random_device;
using std::mt19937;
#endif

// Kfs client read state machine implementation.
class Reader::Impl : public QCRefCountedObj
Expand Down Expand Up @@ -1039,11 +1049,22 @@ class Reader::Impl : public QCRefCountedObj
HandleError(inOp);
return;
}
if (! mGetAllocOp.serversOrderedFlag) {
if (! mGetAllocOp.serversOrderedFlag &&
1 < mGetAllocOp.chunkServers.size()) {
#if __cplusplus < 201103L
random_shuffle(
mGetAllocOp.chunkServers.begin(),
mGetAllocOp.chunkServers.end()
);
#else
random_device theRandDev;
mt19937 theRandGen(theRandDev());
shuffle(
mGetAllocOp.chunkServers.begin(),
mGetAllocOp.chunkServers.end(),
theRandGen
);
#endif
}
mChunkServerIdx = 0;
StartRead();
Expand Down
9 changes: 5 additions & 4 deletions src/cc/meta/kfsops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@
#include "common/MsgLogger.h"
#include "common/time.h"
#include "kfsio/Globals.h"
#include <boost/bind.hpp>

namespace KFS
{

using std::mem_fun;
using boost::bind;
using std::for_each;
using std::lower_bound;
using std::set;
Expand Down Expand Up @@ -427,7 +428,7 @@ Tree::removeFromDumpster(fid_t fid, const string& name, int64_t mtime,
UpdateNumChunks(-cnt);
// fire-away...
for_each(chunkInfo.begin(), chunkInfo.end(),
mem_fun(&MetaChunkInfo::DeleteChunk));
bind(&MetaChunkInfo::DeleteChunk, _1));
if (0 < fa->chunkcount()) {
// Update modification time and set file size to 0 in order
// to signal not to start recovery, not report file as abandoned,
Expand Down Expand Up @@ -510,7 +511,7 @@ Tree::remove(fid_t dir, const string& fname, const string& pathname,
UpdateNumChunks(-fa->chunkcount());
// fire-away...
for_each(chunkInfo.begin(), chunkInfo.end(),
mem_fun(&MetaChunkInfo::DeleteChunk));
bind(&MetaChunkInfo::DeleteChunk, _1));
} else if (0 == fa->numReplicas) {
gLayoutManager.DeleteFile(*fa);
}
Expand Down Expand Up @@ -2600,7 +2601,7 @@ Tree::removeFiles(fid_t dir, vector<MetaDentry*>& entries)
assert(fa->chunkcount() == (int64_t)chunkInfo.size());
UpdateNumChunks(-fa->chunkcount());
for_each(chunkInfo.begin(), chunkInfo.end(),
mem_fun(&MetaChunkInfo::DeleteChunk));
bind(&MetaChunkInfo::DeleteChunk, _1));
} else if (0 == fa->numReplicas) {
gLayoutManager.DeleteFile(*fa);
}
Expand Down

0 comments on commit 42e61d3

Please sign in to comment.