Skip to content

Commit

Permalink
format: revert unnecessary changes
Browse files Browse the repository at this point in the history
  • Loading branch information
changlan authored and eric-haibin-lin committed Aug 18, 2019
1 parent 58aba7d commit a13e84b
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 136 deletions.
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ ifndef PROTOC
PROTOC = ${DEPS_PATH}/bin/protoc
endif


INCPATH = -I./src -I./include -I$(DEPS_PATH)/include
CFLAGS = -std=c++14 -msse2 -fPIC -O3 -ggdb -Wall -finline-functions $(INCPATH) $(ADD_CFLAGS)
LIBS = -pthread
Expand All @@ -37,7 +36,7 @@ all: ps test
include make/deps.mk

clean:
rm -rf build $(TEST) tests/*.d tests/*.dSYM
rm -rf build $(TEST) tests/*.d
find src -name "*.pb.[ch]*" -delete

lint:
Expand All @@ -51,7 +50,7 @@ build/libps.a: $(OBJS)

build/%.o: src/%.cc ${ZMQ} src/meta.pb.h
@mkdir -p $(@D)
$(CXX) $(INCPATH) -std=c++0x -MM -MT build/$*.o $< >build/$*.d
$(CXX) $(INCPATH) -std=c++14 -MM -MT build/$*.o $< >build/$*.d
$(CXX) $(CFLAGS) $(LIBS) -c $< -o $@

src/%.pb.cc src/%.pb.h : src/%.proto ${PROTOBUF}
Expand Down
37 changes: 18 additions & 19 deletions include/dmlc/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,16 @@

/*! \brief whether or not use c++11 support */
#ifndef DMLC_USE_CXX11
#define DMLC_USE_CXX11 \
(defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L || defined(_MSC_VER))
#define DMLC_USE_CXX11 (defined(__GXX_EXPERIMENTAL_CXX0X__) ||\
__cplusplus >= 201103L || defined(_MSC_VER))
#endif

/// check if g++ is before 4.6
#if DMLC_USE_CXX11 && defined(__GNUC__) && !defined(__clang_version__)
#if __GNUC__ == 4 && __GNUC_MINOR__ < 6
#pragma message( \
"Will need g++-4.6 or higher to compile all" \
"the features in dmlc-core, " \
"compile without c++0x, some features may be disabled")
#pragma message("Will need g++-4.6 or higher to compile all" \
"the features in dmlc-core, " \
"compile without c++11, some features may be disabled")
#undef DMLC_USE_CXX11
#define DMLC_USE_CXX11 0
#endif
Expand All @@ -77,17 +76,17 @@
* section if C++11 is not available.
*/
#ifndef DISALLOW_COPY_AND_ASSIGN
#if DMLC_USE_CXX11
#define DISALLOW_COPY_AND_ASSIGN(T) \
T(T const &) = delete; \
T(T &&) = delete; \
T &operator=(T const &) = delete; \
T &operator=(T &&) = delete
#else
#define DISALLOW_COPY_AND_ASSIGN(T) \
T(T const &); \
T &operator=(T const &)
#endif
# if DMLC_USE_CXX11
# define DISALLOW_COPY_AND_ASSIGN(T) \
T(T const&) = delete; \
T(T&&) = delete; \
T& operator=(T const&) = delete; \
T& operator=(T&&) = delete
# else
# define DISALLOW_COPY_AND_ASSIGN(T) \
T(T const&); \
T& operator=(T const&)
# endif
#endif

///
Expand Down Expand Up @@ -170,7 +169,7 @@ inline const T *BeginPtr(const std::vector<T> &vec) {
* \param str input string
* \return beginning address of a string
*/
inline char *BeginPtr(std::string &str) { // NOLINT(*)
inline char* BeginPtr(std::string &str) { // NOLINT(*)
if (str.length() == 0) return NULL;
return &str[0];
}
Expand All @@ -179,7 +178,7 @@ inline char *BeginPtr(std::string &str) { // NOLINT(*)
* \param str input string
* \return beginning address of a string
*/
inline const char *BeginPtr(const std::string &str) {
inline const char* BeginPtr(const std::string &str) {
if (str.length() == 0) return NULL;
return &str[0];
}
Expand Down
55 changes: 28 additions & 27 deletions include/dmlc/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,41 +51,40 @@ struct Error : public std::runtime_error {
#include <glog/logging.h>

namespace dmlc {
inline void InitLogging(const char *argv0) { google::InitGoogleLogging(argv0); }
inline void InitLogging(const char* argv0) {
google::InitGoogleLogging(argv0);
}
} // namespace dmlc

#else
// use a light version of glog
#include <assert.h>
#include <ctime>
#include <iostream>
#include <sstream>
#include <ctime>

#if defined(_MSC_VER)
#pragma warning(disable : 4722)
#endif

namespace dmlc {
inline void InitLogging(const char *argv0) {
inline void InitLogging(const char* argv0) {
// DO NOTHING
}

// Always-on checking
#define CHECK(x) \
if (!(x)) \
dmlc::LogMessageFatal(__FILE__, __LINE__).stream() << "Check " \
"failed: " #x \
<< ' '
#define CHECK(x) \
if (!(x)) \
dmlc::LogMessageFatal(__FILE__, __LINE__).stream() << "Check " \
"failed: " #x << ' '
#define CHECK_LT(x, y) CHECK((x) < (y))
#define CHECK_GT(x, y) CHECK((x) > (y))
#define CHECK_LE(x, y) CHECK((x) <= (y))
#define CHECK_GE(x, y) CHECK((x) >= (y))
#define CHECK_EQ(x, y) CHECK((x) == (y))
#define CHECK_NE(x, y) CHECK((x) != (y))
#define CHECK_NOTNULL(x) \
((x) == NULL \
? dmlc::LogMessageFatal(__FILE__, __LINE__).stream() << "Check notnull: " #x << ' ', \
(x) : (x)) // NOLINT(*)
#define CHECK_NOTNULL(x) \
((x) == NULL ? dmlc::LogMessageFatal(__FILE__, __LINE__).stream() << "Check notnull: " #x << ' ', (x) : (x)) // NOLINT(*)
// Debug-only checking.
#ifdef NDEBUG
#define DCHECK(x) \
Expand Down Expand Up @@ -149,44 +148,45 @@ class DateLogger {
_tzset();
#endif
}
const char *HumanDate() {
const char* HumanDate() {
#if defined(_MSC_VER)
_strtime_s(buffer_, sizeof(buffer_));
#else
time_t time_value = time(NULL);
struct tm now;
localtime_r(&time_value, &now);
snprintf(buffer_, sizeof(buffer_), "%02d:%02d:%02d", now.tm_hour, now.tm_min, now.tm_sec);
snprintf(buffer_, sizeof(buffer_), "%02d:%02d:%02d", now.tm_hour,
now.tm_min, now.tm_sec);
#endif
return buffer_;
}

private:
char buffer_[9];
};

class LogMessage {
public:
LogMessage(const char *file, int line)
LogMessage(const char* file, int line)
:
#ifdef __ANDROID__
log_stream_(std::cout)
#else
log_stream_(std::cerr)
#endif
{
log_stream_ << "[" << pretty_date_.HumanDate() << "] " << file << ":" << line << ": ";
log_stream_ << "[" << pretty_date_.HumanDate() << "] " << file << ":"
<< line << ": ";
}
~LogMessage() { log_stream_ << "\n"; }
std::ostream &stream() { return log_stream_; }
std::ostream& stream() { return log_stream_; }

protected:
std::ostream &log_stream_;
std::ostream& log_stream_;

private:
DateLogger pretty_date_;
LogMessage(const LogMessage &);
void operator=(const LogMessage &);
LogMessage(const LogMessage&);
void operator=(const LogMessage&);
};

#if DMLC_LOG_STACK_TRACE
Expand Down Expand Up @@ -249,21 +249,22 @@ inline std::string StackTrace() {
#if DMLC_LOG_FATAL_THROW == 0
class LogMessageFatal : public LogMessage {
public:
LogMessageFatal(const char *file, int line) : LogMessage(file, line) {}
LogMessageFatal(const char* file, int line) : LogMessage(file, line) {}
~LogMessageFatal() {
log_stream_ << "\n";
abort();
}

private:
LogMessageFatal(const LogMessageFatal &);
void operator=(const LogMessageFatal &);
LogMessageFatal(const LogMessageFatal&);
void operator=(const LogMessageFatal&);
};
#else
class LogMessageFatal {
public:
LogMessageFatal(const char *file, int line) {
log_stream_ << "[" << pretty_date_.HumanDate() << "] " << file << ":" << line << ": ";
LogMessageFatal(const char* file, int line) {
log_stream_ << "[" << pretty_date_.HumanDate() << "] " << file << ":"
<< line << ": ";
}
std::ostringstream &stream() { return log_stream_; }
~LogMessageFatal() DMLC_THROW_EXCEPTION {
Expand Down Expand Up @@ -293,7 +294,7 @@ class LogMessageVoidify {
LogMessageVoidify() {}
// This has to be an operator with a precedence lower than << but
// higher than "?:". See its usage.
void operator&(std::ostream &) {}
void operator&(std::ostream&) {}
};

} // namespace dmlc
Expand Down
3 changes: 2 additions & 1 deletion include/ps/kv_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,8 @@ int KVWorker<Val>::Pull_(
size_t total_key = 0, total_val = 0;
for (const auto& s : kvs) {
Range range = FindRange(keys, s.keys.front(), s.keys.back()+1);
CHECK_EQ(range.size(), s.keys.size()) << "unmatched keys size from one server";
CHECK_EQ(range.size(), s.keys.size())
<< "unmatched keys size from one server";
if (lens) CHECK_EQ(s.lens.size(), s.keys.size());
total_key += s.keys.size();
total_val += s.vals.size();
Expand Down
8 changes: 4 additions & 4 deletions include/ps/ps.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ inline int MyRank() { return Postoffice::Get()->my_rank(); }
* This function will block until every nodes are started.
* \param argv0 the program name, used for logging
*/
inline void Start(int customer_id, const char *argv0 = nullptr) {
inline void Start(int customer_id, const char* argv0 = nullptr) {
Postoffice::Get()->Start(customer_id, argv0, true);
}
/**
Expand All @@ -43,13 +43,13 @@ inline void Start(int customer_id, const char *argv0 = nullptr) {
* This function will NOT block.
* \param argv0 the program name, used for logging
*/
inline void StartAsync(int customer_id, const char *argv0 = nullptr) {
inline void StartAsync(int customer_id, const char* argv0 = nullptr) {
Postoffice::Get()->Start(customer_id, argv0, false);
}
/**
* \brief terminate the system
*
* All nodes should call this function before existing.
* All nodes should call this function before existing.
* \param do_barrier whether to block until every node is finalized, default true.
*/
inline void Finalize(int customer_id, const bool do_barrier = true) {
Expand All @@ -70,7 +70,7 @@ inline void Finalize(int customer_id, const bool do_barrier = true) {
* \endcode
* \param cb the callback function
*/
inline void RegisterExitCallback(const std::function<void()> &cb) {
inline void RegisterExitCallback(const std::function<void()>& cb) {
Postoffice::Get()->RegisterExitCallback(cb);
}

Expand Down
1 change: 1 addition & 0 deletions include/ps/sarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class SArray {
*/
explicit SArray(size_t size, V val = 0) { resize(size, val); }


/**
* \brief construct from another SArray.
*
Expand Down
Loading

0 comments on commit a13e84b

Please sign in to comment.