Fix ssize_t definition. (#80)

* Fix linter.
This commit is contained in:
Jiaming Yuan 2019-02-18 19:25:08 +08:00 committed by GitHub
parent 0101a4719c
commit 1cc34f01db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 111 additions and 102 deletions

View File

@ -9,7 +9,7 @@
/*! \brief whether use glog for logging */ /*! \brief whether use glog for logging */
#ifndef DMLC_USE_GLOG #ifndef DMLC_USE_GLOG
#define DMLC_USE_GLOG 0 #define DMLC_USE_GLOG 0
#endif #endif // DMLC_USE_GLOG
/*! /*!
* \brief whether throw dmlc::Error instead of * \brief whether throw dmlc::Error instead of
@ -19,7 +19,7 @@
*/ */
#ifndef DMLC_LOG_FATAL_THROW #ifndef DMLC_LOG_FATAL_THROW
#define DMLC_LOG_FATAL_THROW 1 #define DMLC_LOG_FATAL_THROW 1
#endif #endif // DMLC_LOG_FATAL_THROW
/*! /*!
* \brief whether always log a message before throw * \brief whether always log a message before throw
@ -27,7 +27,7 @@
*/ */
#ifndef DMLC_LOG_BEFORE_THROW #ifndef DMLC_LOG_BEFORE_THROW
#define DMLC_LOG_BEFORE_THROW 1 #define DMLC_LOG_BEFORE_THROW 1
#endif #endif // DMLC_LOG_BEFORE_THROW
/*! /*!
* \brief Whether to use customized logger, * \brief Whether to use customized logger,
@ -35,7 +35,7 @@
*/ */
#ifndef DMLC_LOG_CUSTOMIZE #ifndef DMLC_LOG_CUSTOMIZE
#define DMLC_LOG_CUSTOMIZE 0 #define DMLC_LOG_CUSTOMIZE 0
#endif #endif // DMLC_LOG_CUSTOMIZE
/*! /*!
* \brief Wheter to print stack trace for fatal error, * \brief Wheter to print stack trace for fatal error,
@ -45,22 +45,22 @@
&& defined(__GNUC__) && !defined(__MINGW32__) \ && defined(__GNUC__) && !defined(__MINGW32__) \
&& !defined(__sun) && !defined(__SVR4)) && !defined(__sun) && !defined(__SVR4))
#define DMLC_LOG_STACK_TRACE 1 #define DMLC_LOG_STACK_TRACE 1
#endif #endif // guards
/*! \brief whether compile with hdfs support */ /*! \brief whether compile with hdfs support */
#ifndef DMLC_USE_HDFS #ifndef DMLC_USE_HDFS
#define DMLC_USE_HDFS 0 #define DMLC_USE_HDFS 0
#endif #endif // DMLC_USE_HDFS
/*! \brief whether compile with s3 support */ /*! \brief whether compile with s3 support */
#ifndef DMLC_USE_S3 #ifndef DMLC_USE_S3
#define DMLC_USE_S3 0 #define DMLC_USE_S3 0
#endif #endif // DMLC_USE_S3
/*! \brief whether or not use parameter server */ /*! \brief whether or not use parameter server */
#ifndef DMLC_USE_PS #ifndef DMLC_USE_PS
#define DMLC_USE_PS 0 #define DMLC_USE_PS 0
#endif #endif // DMLC_USE_PS
/*! \brief whether or not use c++11 support */ /*! \brief whether or not use c++11 support */
#ifndef DMLC_USE_CXX11 #ifndef DMLC_USE_CXX11
@ -68,8 +68,8 @@
#define DMLC_USE_CXX11 1 #define DMLC_USE_CXX11 1
#else #else
#define DMLC_USE_CXX11 (__cplusplus >= 201103L) #define DMLC_USE_CXX11 (__cplusplus >= 201103L)
#endif #endif // defined(__GXX_EXPERIMENTAL_CXX0X__) || defined(_MSC_VER)
#endif #endif // DMLC_USE_CXX11
/*! \brief strict CXX11 support */ /*! \brief strict CXX11 support */
#ifndef DMLC_STRICT_CXX11 #ifndef DMLC_STRICT_CXX11
@ -77,8 +77,8 @@
#define DMLC_STRICT_CXX11 1 #define DMLC_STRICT_CXX11 1
#else #else
#define DMLC_STRICT_CXX11 (__cplusplus >= 201103L) #define DMLC_STRICT_CXX11 (__cplusplus >= 201103L)
#endif #endif // defined(_MSC_VER)
#endif #endif // DMLC_STRICT_CXX11
/*! \brief Whether cxx11 thread local is supported */ /*! \brief Whether cxx11 thread local is supported */
#ifndef DMLC_CXX11_THREAD_LOCAL #ifndef DMLC_CXX11_THREAD_LOCAL
@ -87,17 +87,17 @@
#define DMLC_CXX11_THREAD_LOCAL 1 #define DMLC_CXX11_THREAD_LOCAL 1
#else #else
#define DMLC_CXX11_THREAD_LOCAL 0 #define DMLC_CXX11_THREAD_LOCAL 0
#endif #endif // (_MSC_VER >= 1900)
#else #else
#define DMLC_CXX11_THREAD_LOCAL (__cplusplus >= 201103L) #define DMLC_CXX11_THREAD_LOCAL (__cplusplus >= 201103L)
#endif #endif // defined(_MSC_VER)
#endif #endif // DMLC_CXX11_THREAD_LOCAL
/*! \brief whether RTTI is enabled */ /*! \brief whether RTTI is enabled */
#ifndef DMLC_ENABLE_RTTI #ifndef DMLC_ENABLE_RTTI
#define DMLC_ENABLE_RTTI 1 #define DMLC_ENABLE_RTTI 1
#endif #endif // DMLC_ENABLE_RTTI
/// check if g++ is before 4.6 /// check if g++ is before 4.6
#if DMLC_USE_CXX11 && defined(__GNUC__) && !defined(__clang_version__) #if DMLC_USE_CXX11 && defined(__GNUC__) && !defined(__clang_version__)
@ -107,8 +107,8 @@
"compile without c++0x, some features may be disabled") "compile without c++0x, some features may be disabled")
#undef DMLC_USE_CXX11 #undef DMLC_USE_CXX11
#define DMLC_USE_CXX11 0 #define DMLC_USE_CXX11 0
#endif #endif // __GNUC__ == 4 && __GNUC_MINOR__ < 6
#endif #endif // DMLC_USE_CXX11 && defined(__GNUC__) && !defined(__clang_version__)
/*! /*!
@ -117,19 +117,19 @@
*/ */
#ifndef DMLC_ENABLE_STD_THREAD #ifndef DMLC_ENABLE_STD_THREAD
#define DMLC_ENABLE_STD_THREAD DMLC_USE_CXX11 #define DMLC_ENABLE_STD_THREAD DMLC_USE_CXX11
#endif #endif // DMLC_ENABLE_STD_THREAD
/*! \brief whether enable regex support, actually need g++-4.9 or higher*/ /*! \brief whether enable regex support, actually need g++-4.9 or higher*/
#ifndef DMLC_USE_REGEX #ifndef DMLC_USE_REGEX
#define DMLC_USE_REGEX DMLC_STRICT_CXX11 #define DMLC_USE_REGEX DMLC_STRICT_CXX11
#endif #endif // DMLC_USE_REGEX
/*! \brief helper macro to supress unused warning */ /*! \brief helper macro to supress unused warning */
#if defined(__GNUC__) #if defined(__GNUC__)
#define DMLC_ATTRIBUTE_UNUSED __attribute__((unused)) #define DMLC_ATTRIBUTE_UNUSED __attribute__((unused))
#else #else
#define DMLC_ATTRIBUTE_UNUSED #define DMLC_ATTRIBUTE_UNUSED
#endif #endif // defined(__GNUC__)
/*! \brief helper macro to generate string concat */ /*! \brief helper macro to generate string concat */
#define DMLC_STR_CONCAT_(__x, __y) __x##__y #define DMLC_STR_CONCAT_(__x, __y) __x##__y
@ -154,41 +154,46 @@
# define DISALLOW_COPY_AND_ASSIGN(T) \ # define DISALLOW_COPY_AND_ASSIGN(T) \
T(T const&); \ T(T const&); \
T& operator=(T const&) T& operator=(T const&)
# endif # endif // DMLC_USE_CXX11
#endif #endif // DISALLOW_COPY_AND_ASSIGN
/// ///
/// code block to handle optionally loading /// code block to handle optionally loading
/// ///
#if !defined(__GNUC__) #if !defined(__GNUC__)
#define fopen64 std::fopen #define fopen64 std::fopen
#endif #endif // !defined(__GNUC__)
#if (defined __MINGW32__) && !(defined __MINGW64__) #if (defined __MINGW32__) && !(defined __MINGW64__)
#define fopen64 std::fopen #define fopen64 std::fopen
#endif #endif // (defined __MINGW32__) && !(defined __MINGW64__)
#ifdef _MSC_VER #ifdef _MSC_VER
#if _MSC_VER < 1900
# if _MSC_VER < 1900
// NOTE: sprintf_s is not equivalent to snprintf, // NOTE: sprintf_s is not equivalent to snprintf,
// they are equivalent when success, which is sufficient for our case // they are equivalent when success, which is sufficient for our case
#define snprintf sprintf_s # define snprintf sprintf_s
#define vsnprintf vsprintf_s # define vsnprintf vsprintf_s
#endif # endif // _MSC_VER < 1900
#else
#ifdef _FILE_OFFSET_BITS
#if _FILE_OFFSET_BITS == 32
#pragma message("Warning: FILE OFFSET BITS defined to be 32 bit")
#endif
#endif
#ifdef __APPLE__ #else
#define off64_t off_t
#define fopen64 std::fopen # ifdef _FILE_OFFSET_BITS
#endif # if _FILE_OFFSET_BITS == 32
# pragma message("Warning: FILE OFFSET BITS defined to be 32 bit")
# endif // _FILE_OFFSET_BITS == 32
# endif // _FILE_OFFSET_BITS
# ifdef __APPLE__
# define off64_t off_t
# define fopen64 std::fopen
# endif // __APPLE__
extern "C" { extern "C" {
#include <sys/types.h> #include <sys/types.h>
} }
#endif #endif // _MSC_VER
#ifdef _MSC_VER #ifdef _MSC_VER
//! \cond Doxygen_Suppress //! \cond Doxygen_Suppress
@ -203,7 +208,8 @@ typedef unsigned __int64 uint64_t;
//! \endcond //! \endcond
#else #else
#include <inttypes.h> #include <inttypes.h>
#endif #endif // _MSC_VER
#include <string> #include <string>
#include <vector> #include <vector>
@ -211,7 +217,7 @@ typedef unsigned __int64 uint64_t;
#define noexcept_true throw () #define noexcept_true throw ()
#define noexcept_false #define noexcept_false
#define noexcept(a) noexcept_##a #define noexcept(a) noexcept_##a
#endif #endif // defined(_MSC_VER) && _MSC_VER < 1900
#if DMLC_USE_CXX11 #if DMLC_USE_CXX11
#define DMLC_THROW_EXCEPTION noexcept(false) #define DMLC_THROW_EXCEPTION noexcept(false)
@ -219,7 +225,7 @@ typedef unsigned __int64 uint64_t;
#else #else
#define DMLC_THROW_EXCEPTION #define DMLC_THROW_EXCEPTION
#define DMLC_NO_EXCEPTION #define DMLC_NO_EXCEPTION
#endif #endif // DMLC_USE_CXX11
/*! \brief namespace for dmlc */ /*! \brief namespace for dmlc */
namespace dmlc { namespace dmlc {
@ -272,6 +278,6 @@ inline const char* BeginPtr(const std::string &str) {
#if defined(_MSC_VER) && _MSC_VER < 1900 #if defined(_MSC_VER) && _MSC_VER < 1900
#define constexpr const #define constexpr const
#define alignof __alignof #define alignof __alignof
#endif #endif // defined(_MSC_VER) && _MSC_VER < 1900
#endif // DMLC_BASE_H_ #endif // DMLC_BASE_H_

View File

@ -9,7 +9,7 @@
#include "./base.h" #include "./base.h"
#if DMLC_USE_CXX11 #if DMLC_USE_CXX11
#include <type_traits> #include <type_traits>
#endif #endif // DMLC_USE_CXX11
#include <string> #include <string>
namespace dmlc { namespace dmlc {
@ -25,7 +25,7 @@ struct is_pod {
#else #else
/*! \brief the value of the traits */ /*! \brief the value of the traits */
static const bool value = false; static const bool value = false;
#endif #endif // DMLC_USE_CXX11
}; };
@ -41,7 +41,7 @@ struct is_integral {
#else #else
/*! \brief the value of the traits */ /*! \brief the value of the traits */
static const bool value = false; static const bool value = false;
#endif #endif // DMLC_USE_CXX11
}; };
/*! /*!
@ -56,7 +56,7 @@ struct is_floating_point {
#else #else
/*! \brief the value of the traits */ /*! \brief the value of the traits */
static const bool value = false; static const bool value = false;
#endif #endif // DMLC_USE_CXX11
}; };
/*! /*!
@ -72,7 +72,7 @@ struct is_arithmetic {
/*! \brief the value of the traits */ /*! \brief the value of the traits */
static const bool value = (dmlc::is_integral<T>::value || static const bool value = (dmlc::is_integral<T>::value ||
dmlc::is_floating_point<T>::value); dmlc::is_floating_point<T>::value);
#endif #endif // DMLC_USE_CXX11
}; };
/*! /*!
@ -147,7 +147,7 @@ DMLC_DECLARE_TRAITS(is_integral, uint64_t, true);
DMLC_DECLARE_TRAITS(is_floating_point, float, true); DMLC_DECLARE_TRAITS(is_floating_point, float, true);
DMLC_DECLARE_TRAITS(is_floating_point, double, true); DMLC_DECLARE_TRAITS(is_floating_point, double, true);
#endif #endif // DMLC_USE_CXX11
DMLC_DECLARE_TYPE_NAME(float, "float"); DMLC_DECLARE_TYPE_NAME(float, "float");
DMLC_DECLARE_TYPE_NAME(double, "double"); DMLC_DECLARE_TYPE_NAME(double, "double");

View File

@ -13,13 +13,13 @@
#else #else
#define RABIT_EXTERN_C #define RABIT_EXTERN_C
#include <stdio.h> #include <stdio.h>
#endif #endif // __cplusplus
#if defined(_MSC_VER) || defined(_WIN32) #if defined(_MSC_VER) || defined(_WIN32)
#define RABIT_DLL RABIT_EXTERN_C __declspec(dllexport) #define RABIT_DLL RABIT_EXTERN_C __declspec(dllexport)
#else #else
#define RABIT_DLL RABIT_EXTERN_C #define RABIT_DLL RABIT_EXTERN_C
#endif #endif // defined(_MSC_VER) || defined(_WIN32)
/*! \brief rabit unsigned long type */ /*! \brief rabit unsigned long type */
typedef unsigned long rbt_ulong; // NOLINT(*) typedef unsigned long rbt_ulong; // NOLINT(*)

View File

@ -1,5 +1,5 @@
/*! /*!
* Copyright by Contributors * Copyright (c) 2014-2019 by Contributors
* \file rabit-inl.h * \file rabit-inl.h
* \brief implementation of inline template function for rabit interface * \brief implementation of inline template function for rabit interface
* *
@ -188,7 +188,7 @@ inline void TrackerPrintf(const char *fmt, ...) {
msg.resize(strlen(msg.c_str())); msg.resize(strlen(msg.c_str()));
TrackerPrint(msg); TrackerPrint(msg);
} }
#endif #endif // RABIT_STRICT_CXX98_
// load latest check point // load latest check point
inline int LoadCheckPoint(Serializable *global_model, inline int LoadCheckPoint(Serializable *global_model,
Serializable *local_model) { Serializable *local_model) {
@ -323,6 +323,6 @@ inline void SerializeReducer<DType>::Allreduce(DType *sendrecvobj,
std::function<void()> prepare_fun) { std::function<void()> prepare_fun) {
this->Allreduce(sendrecvobj, max_nbytes, count, InvokeLambda_, &prepare_fun); this->Allreduce(sendrecvobj, max_nbytes, count, InvokeLambda_, &prepare_fun);
} }
#endif #endif // DMLC_USE_CXX11
} // namespace rabit } // namespace rabit
#endif // RABIT_INTERNAL_RABIT_INL_H_ #endif // RABIT_INTERNAL_RABIT_INL_H_

View File

@ -1,5 +1,5 @@
/*! /*!
* Copyright by Contributors * Copyright (c) 2014-2019 by Contributors
* \file timer.h * \file timer.h
* \brief This file defines the utils for timing * \brief This file defines the utils for timing
* \author Tianqi Chen, Nacho, Tianyi * \author Tianqi Chen, Nacho, Tianyi
@ -10,7 +10,7 @@
#ifdef __MACH__ #ifdef __MACH__
#include <mach/clock.h> #include <mach/clock.h>
#include <mach/mach.h> #include <mach/mach.h>
#endif #endif // __MACH__
#include "./utils.h" #include "./utils.h"
namespace rabit { namespace rabit {
@ -19,22 +19,22 @@ namespace utils {
* \brief return time in seconds, not cross platform, avoid to use this in most places * \brief return time in seconds, not cross platform, avoid to use this in most places
*/ */
inline double GetTime(void) { inline double GetTime(void) {
#ifdef __MACH__ #ifdef __MACH__
clock_serv_t cclock; clock_serv_t cclock;
mach_timespec_t mts; mach_timespec_t mts;
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock); host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
utils::Check(clock_get_time(cclock, &mts) == 0, "failed to get time"); utils::Check(clock_get_time(cclock, &mts) == 0, "failed to get time");
mach_port_deallocate(mach_task_self(), cclock); mach_port_deallocate(mach_task_self(), cclock);
return static_cast<double>(mts.tv_sec) + static_cast<double>(mts.tv_nsec) * 1e-9; return static_cast<double>(mts.tv_sec) + static_cast<double>(mts.tv_nsec) * 1e-9;
#else #else
#if defined(__unix__) || defined(__linux__) #if defined(__unix__) || defined(__linux__)
timespec ts; timespec ts;
utils::Check(clock_gettime(CLOCK_REALTIME, &ts) == 0, "failed to get time"); utils::Check(clock_gettime(CLOCK_REALTIME, &ts) == 0, "failed to get time");
return static_cast<double>(ts.tv_sec) + static_cast<double>(ts.tv_nsec) * 1e-9; return static_cast<double>(ts.tv_sec) + static_cast<double>(ts.tv_nsec) * 1e-9;
#else #else
return static_cast<double>(time(NULL)); return static_cast<double>(time(NULL));
#endif #endif // defined(__unix__) || defined(__linux__)
#endif #endif // __MACH__
} }
} // namespace utils } // namespace utils
} // namespace rabit } // namespace rabit

View File

@ -14,32 +14,35 @@
#ifndef RABIT_STRICT_CXX98_ #ifndef RABIT_STRICT_CXX98_
#include <cstdarg> #include <cstdarg>
#endif #endif // RABIT_STRICT_CXX98_
#if !defined(__GNUC__) || defined(__FreeBSD__) #if !defined(__GNUC__) || defined(__FreeBSD__)
#define fopen64 std::fopen #define fopen64 std::fopen
#endif #endif // !defined(__GNUC__) || defined(__FreeBSD__)
#ifdef _MSC_VER #ifdef _MSC_VER
// NOTE: sprintf_s is not equivalent to snprintf, // NOTE: sprintf_s is not equivalent to snprintf,
// they are equivalent when success, which is sufficient for our case // they are equivalent when success, which is sufficient for our case
#define snprintf sprintf_s #define snprintf sprintf_s
#define vsnprintf vsprintf_s #define vsnprintf vsprintf_s
#else #else
#ifdef _FILE_OFFSET_BITS #ifdef _FILE_OFFSET_BITS
#if _FILE_OFFSET_BITS == 32 #if _FILE_OFFSET_BITS == 32
#pragma message("Warning: FILE OFFSET BITS defined to be 32 bit") #pragma message("Warning: FILE OFFSET BITS defined to be 32 bit")
#endif #endif // _FILE_OFFSET_BITS == 32
#endif #endif // _FILE_OFFSET_BITS
#ifdef __APPLE__ #ifdef __APPLE__
#define off64_t off_t #define off64_t off_t
#define fopen64 std::fopen #define fopen64 std::fopen
#endif #endif // __APPLE__
extern "C" { extern "C" {
#include <sys/types.h> #include <sys/types.h>
} }
#endif #endif // _MSC_VER
#ifdef _MSC_VER #ifdef _MSC_VER
typedef unsigned char uint8_t; typedef unsigned char uint8_t;
@ -49,7 +52,7 @@ typedef unsigned __int64 uint64_t;
typedef __int64 int64_t; typedef __int64 int64_t;
#else #else
#include <inttypes.h> #include <inttypes.h>
#endif #endif // _MSC_VER
namespace rabit { namespace rabit {
/*! \brief namespace for helper utils of the project */ /*! \brief namespace for helper utils of the project */
@ -88,8 +91,8 @@ inline void HandleLogPrint(const char *msg) {
void HandleAssertError(const char *msg); void HandleAssertError(const char *msg);
void HandleCheckError(const char *msg); void HandleCheckError(const char *msg);
void HandlePrint(const char *msg); void HandlePrint(const char *msg);
#endif #endif // RABIT_STRICT_CXX98_
#endif #endif // RABIT_CUSTOMIZE_MSG_
#ifdef RABIT_STRICT_CXX98_ #ifdef RABIT_STRICT_CXX98_
// these function pointers are to be assigned // these function pointers are to be assigned
extern "C" void (*Printf)(const char *fmt, ...); extern "C" void (*Printf)(const char *fmt, ...);
@ -151,7 +154,7 @@ inline void Error(const char *fmt, ...) {
HandleCheckError(msg.c_str()); HandleCheckError(msg.c_str());
} }
} }
#endif #endif // RABIT_STRICT_CXX98_
/*! \brief replace fopen, report error when the file open fails */ /*! \brief replace fopen, report error when the file open fails */
inline std::FILE *FopenCheck(const char *fname, const char *flag) { inline std::FILE *FopenCheck(const char *fname, const char *flag) {

View File

@ -19,8 +19,8 @@
#define DMLC_USE_CXX11 1 #define DMLC_USE_CXX11 1
#else #else
#define DMLC_USE_CXX11 (__cplusplus >= 201103L) #define DMLC_USE_CXX11 (__cplusplus >= 201103L)
#endif #endif // defined(__GXX_EXPERIMENTAL_CXX0X__) || defined(_MSC_VER)
#endif #endif // DMLC_USE_CXX11
// optionally support of lambda functions in C++11, if available // optionally support of lambda functions in C++11, if available
#if DMLC_USE_CXX11 #if DMLC_USE_CXX11
@ -108,7 +108,7 @@ inline void TrackerPrint(const std::string &msg);
* \param fmt the format string * \param fmt the format string
*/ */
inline void TrackerPrintf(const char *fmt, ...); inline void TrackerPrintf(const char *fmt, ...);
#endif #endif // RABIT_STRICT_CXX98_
/*! /*!
* \brief broadcasts a memory region to every node from the root * \brief broadcasts a memory region to every node from the root
* *
@ -297,7 +297,7 @@ class Reducer {
*/ */
inline void Allreduce(DType *sendrecvbuf, size_t count, inline void Allreduce(DType *sendrecvbuf, size_t count,
std::function<void()> prepare_fun); std::function<void()> prepare_fun);
#endif #endif // DMLC_USE_CXX11
private: private:
/*! \brief function handle to do reduce */ /*! \brief function handle to do reduce */
@ -345,7 +345,7 @@ class SerializeReducer {
inline void Allreduce(DType *sendrecvobj, inline void Allreduce(DType *sendrecvobj,
size_t max_nbyte, size_t count, size_t max_nbyte, size_t count,
std::function<void()> prepare_fun); std::function<void()> prepare_fun);
#endif #endif // DMLC_USE_CXX11
private: private:
/*! \brief function handle to do reduce */ /*! \brief function handle to do reduce */

View File

@ -240,7 +240,7 @@ class AllreduceBase : public IEngine {
#ifdef _WIN32 #ifdef _WIN32
if (errsv == WSAEWOULDBLOCK) return kSuccess; if (errsv == WSAEWOULDBLOCK) return kSuccess;
if (errsv == WSAECONNRESET) return kConnReset; if (errsv == WSAECONNRESET) return kConnReset;
#endif #endif // _WIN32
if (errsv == ECONNRESET) return kConnReset; if (errsv == ECONNRESET) return kConnReset;
return kSockError; return kSockError;
} }

View File

@ -1,5 +1,5 @@
/*! /*!
* Copyright (c) 2014-2018 by Contributors * Copyright (c) 2014-2019 by Contributors
* \file allreduce_robust.cc * \file allreduce_robust.cc
* \brief Robust implementation of Allreduce * \brief Robust implementation of Allreduce
* *
@ -55,7 +55,7 @@ void AllreduceRobust::Shutdown(void) {
// This cause rest workers checkandrecover and hang inf, https://github.com/dmlc/xgboost/pull/3818 // This cause rest workers checkandrecover and hang inf, https://github.com/dmlc/xgboost/pull/3818
// TODO(Chen Qin): a fundamental fix for this // TODO(Chen Qin): a fundamental fix for this
sleep(2); sleep(2);
#endif #endif // __APPLE__
AllreduceBase::Shutdown(); AllreduceBase::Shutdown();
} }
/*! /*!

View File

@ -24,10 +24,10 @@ namespace engine {
typedef AllreduceRobust Manager; typedef AllreduceRobust Manager;
#else #else
typedef AllreduceMock Manager; typedef AllreduceMock Manager;
#endif #endif // RABIT_USE_MOCK
#else #else
typedef AllreduceBase Manager; typedef AllreduceBase Manager;
#endif #endif // RABIT_USE_BASE
/*! \brief entry to to easily hold returning information */ /*! \brief entry to to easily hold returning information */
struct ThreadLocalEntry { struct ThreadLocalEntry {

View File

@ -1,5 +1,5 @@
/*! /*!
* Copyright (c) 2014 by Contributors * Copyright (c) 2014-2019 by Contributors
* \file socket.h * \file socket.h
* \brief this file aims to provide a wrapper of sockets * \brief this file aims to provide a wrapper of sockets
* \author Tianqi Chen * \author Tianqi Chen
@ -11,7 +11,7 @@
#include <ws2tcpip.h> #include <ws2tcpip.h>
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma comment(lib, "Ws2_32.lib") #pragma comment(lib, "Ws2_32.lib")
#endif #endif // _MSC_VER
#else #else
#include <fcntl.h> #include <fcntl.h>
#include <netdb.h> #include <netdb.h>
@ -21,16 +21,16 @@
#include <netinet/in.h> #include <netinet/in.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#endif #endif // defined(_WIN32)
#include <string> #include <string>
#include <cstring> #include <cstring>
#include <vector> #include <vector>
#include <unordered_map> #include <unordered_map>
#include "../include/rabit/internal/utils.h" #include "../include/rabit/internal/utils.h"
#if defined(_WIN32) && not defined(__MINGW32__) #if defined(_WIN32) || defined(__MINGW32__)
typedef int ssize_t; typedef int ssize_t;
#endif #endif // defined(_WIN32) || defined(__MINGW32__)
#if defined(_WIN32) #if defined(_WIN32)
typedef int sock_size_t; typedef int sock_size_t;
@ -42,7 +42,7 @@ static inline int poll(struct pollfd *pfd, int nfds,
typedef int SOCKET; typedef int SOCKET;
typedef size_t sock_size_t; typedef size_t sock_size_t;
const int INVALID_SOCKET = -1; const int INVALID_SOCKET = -1;
#endif #endif // defined(_WIN32)
namespace rabit { namespace rabit {
namespace utils { namespace utils {
@ -90,7 +90,7 @@ struct SockAddr {
#else #else
const char *s = inet_ntop(AF_INET, &addr.sin_addr, const char *s = inet_ntop(AF_INET, &addr.sin_addr,
&buf[0], buf.length()); &buf[0], buf.length());
#endif #endif // _WIN32
Assert(s != NULL, "cannot decode address"); Assert(s != NULL, "cannot decode address");
return std::string(s); return std::string(s);
} }
@ -115,7 +115,7 @@ class Socket {
return WSAGetLastError(); return WSAGetLastError();
#else #else
return errno; return errno;
#endif #endif // _WIN32
} }
/*! \return whether last error was would block */ /*! \return whether last error was would block */
inline static bool LastErrorWouldBlock(void) { inline static bool LastErrorWouldBlock(void) {
@ -124,7 +124,7 @@ class Socket {
return errsv == WSAEWOULDBLOCK; return errsv == WSAEWOULDBLOCK;
#else #else
return errsv == EAGAIN || errsv == EWOULDBLOCK; return errsv == EAGAIN || errsv == EWOULDBLOCK;
#endif #endif // _WIN32
} }
/*! /*!
* \brief start up the socket module * \brief start up the socket module
@ -140,7 +140,7 @@ class Socket {
WSACleanup(); WSACleanup();
utils::Error("Could not find a usable version of Winsock.dll\n"); utils::Error("Could not find a usable version of Winsock.dll\n");
} }
#endif #endif // _WIN32
} }
/*! /*!
* \brief shutdown the socket module after use, all sockets need to be closed * \brief shutdown the socket module after use, all sockets need to be closed
@ -148,7 +148,7 @@ class Socket {
inline static void Finalize(void) { inline static void Finalize(void) {
#ifdef _WIN32 #ifdef _WIN32
WSACleanup(); WSACleanup();
#endif #endif // _WIN32
} }
/*! /*!
* \brief set this socket to use non-blocking mode * \brief set this socket to use non-blocking mode
@ -174,7 +174,7 @@ class Socket {
if (fcntl(sockfd, F_SETFL, flag) == -1) { if (fcntl(sockfd, F_SETFL, flag) == -1) {
Socket::Error("SetNonBlock-2"); Socket::Error("SetNonBlock-2");
} }
#endif #endif // _WIN32
} }
/*! /*!
* \brief bind the socket to an address * \brief bind the socket to an address
@ -208,7 +208,7 @@ class Socket {
if (errno != EADDRINUSE) { if (errno != EADDRINUSE) {
Socket::Error("TryBindHost"); Socket::Error("TryBindHost");
} }
#endif #endif // defined(_WIN32)
} }
return -1; return -1;
@ -319,7 +319,7 @@ class TCPSocket : public Socket{
#else #else
int atmark; int atmark;
if (ioctl(sockfd, SIOCATMARK, &atmark) == -1) return -1; if (ioctl(sockfd, SIOCATMARK, &atmark) == -1) return -1;
#endif #endif // _WIN32
return static_cast<int>(atmark); return static_cast<int>(atmark);
} }
/*! /*!

View File

@ -10,7 +10,7 @@
#if DMLC_ENABLE_STD_THREAD #if DMLC_ENABLE_STD_THREAD
#include <mutex> #include <mutex>
#endif #endif // DMLC_ENABLE_STD_THREAD
#include <memory> #include <memory>
#include <vector> #include <vector>
@ -24,11 +24,11 @@ namespace rabit {
#define MX_TREAD_LOCAL _Thread_local #define MX_TREAD_LOCAL _Thread_local
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
#define MX_TREAD_LOCAL __declspec(thread) #define MX_TREAD_LOCAL __declspec(thread)
#endif #endif // __GNUC__
#ifndef MX_TREAD_LOCAL #ifndef MX_TREAD_LOCAL
#message("Warning: Threadlocal is not enabled"); #message("Warning: Threadlocal is not enabled");
#endif #endif // MX_TREAD_LOCAL
/*! /*!
* \brief A threadlocal store to store threadlocal variables. * \brief A threadlocal store to store threadlocal variables.
@ -73,13 +73,13 @@ class ThreadLocalStore {
lock.unlock(); lock.unlock();
#else #else
data_.push_back(str); data_.push_back(str);
#endif #endif // DMLC_ENABLE_STD_THREAD
} }
#if DMLC_ENABLE_STD_THREAD #if DMLC_ENABLE_STD_THREAD
/*! \brief internal mutex */ /*! \brief internal mutex */
std::mutex mutex_; std::mutex mutex_;
#endif #endif // DMLC_ENABLE_STD_THREAD
/*!\brief internal data */ /*!\brief internal data */
std::vector<T*> data_; std::vector<T*> data_;
}; };