From e50fa9e78f0deb5454474ca756aa9b98524bac38 Mon Sep 17 00:00:00 2001 From: tqchen Date: Tue, 3 Mar 2015 13:16:20 -0800 Subject: [PATCH] fix solaris --- src/io/io.cpp | 2 +- src/tree/updater_colmaker-inl.hpp | 5 +++-- src/utils/io.h | 12 ++++++------ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/io/io.cpp b/src/io/io.cpp index eb7f9fbde..e846d77bf 100644 --- a/src/io/io.cpp +++ b/src/io/io.cpp @@ -15,7 +15,7 @@ namespace xgboost { namespace io { DataMatrix* LoadDataMatrix(const char *fname, bool silent, bool savebuffer) { - if (!strcmp(fname, "stdin")) { + if (!std::strcmp(fname, "stdin")) { DMatrixSimple *dmat = new DMatrixSimple(); dmat->LoadText(fname, silent); return dmat; diff --git a/src/tree/updater_colmaker-inl.hpp b/src/tree/updater_colmaker-inl.hpp index bbf6242c5..2ad9ea979 100644 --- a/src/tree/updater_colmaker-inl.hpp +++ b/src/tree/updater_colmaker-inl.hpp @@ -6,6 +6,7 @@ * \author Tianqi Chen */ #include +#include #include #include "./param.h" #include "./updater.h" @@ -279,7 +280,7 @@ class ColMaker: public IUpdater { ThreadEntry &e = stemp[tid][nid]; float fsplit; if (tid != 0) { - if(fabsf(stemp[tid - 1][nid].last_fvalue - e.first_fvalue) > rt_2eps) { + if(std::abs(stemp[tid - 1][nid].last_fvalue - e.first_fvalue) > rt_2eps) { fsplit = (stemp[tid - 1][nid].last_fvalue - e.first_fvalue) * 0.5f; } else { continue; @@ -334,7 +335,7 @@ class ColMaker: public IUpdater { e.first_fvalue = fvalue; } else { // forward default right - if (fabsf(fvalue - e.first_fvalue) > rt_2eps){ + if (std::abs(fvalue - e.first_fvalue) > rt_2eps){ if (need_forward) { c.SetSubstract(snode[nid].stats, e.stats); if (c.sum_hess >= param.min_child_weight && e.stats.sum_hess >= param.min_child_weight) { diff --git a/src/utils/io.h b/src/utils/io.h index 810510b6d..e89cb24fd 100644 --- a/src/utils/io.h +++ b/src/utils/io.h @@ -110,7 +110,7 @@ struct MemoryFixSizeBuffer : public ISeekStream { utils::Assert(curr_ptr_ + size <= buffer_size_, "read can not have position excceed buffer length"); size_t nread = std::min(buffer_size_ - curr_ptr_, size); - if (nread != 0) memcpy(ptr, p_buffer_ + curr_ptr_, nread); + if (nread != 0) std::memcpy(ptr, p_buffer_ + curr_ptr_, nread); curr_ptr_ += nread; return nread; } @@ -118,7 +118,7 @@ struct MemoryFixSizeBuffer : public ISeekStream { if (size == 0) return; utils::Assert(curr_ptr_ + size <= buffer_size_, "write position exceed fixed buffer size"); - memcpy(p_buffer_ + curr_ptr_, ptr, size); + std::memcpy(p_buffer_ + curr_ptr_, ptr, size); curr_ptr_ += size; } virtual void Seek(size_t pos) { @@ -149,7 +149,7 @@ struct MemoryBufferStream : public ISeekStream { utils::Assert(curr_ptr_ <= p_buffer_->length(), "read can not have position excceed buffer length"); size_t nread = std::min(p_buffer_->length() - curr_ptr_, size); - if (nread != 0) memcpy(ptr, &(*p_buffer_)[0] + curr_ptr_, nread); + if (nread != 0) std::memcpy(ptr, &(*p_buffer_)[0] + curr_ptr_, nread); curr_ptr_ += nread; return nread; } @@ -158,7 +158,7 @@ struct MemoryBufferStream : public ISeekStream { if (curr_ptr_ + size > p_buffer_->length()) { p_buffer_->resize(curr_ptr_+size); } - memcpy(&(*p_buffer_)[0] + curr_ptr_, ptr, size); + std::memcpy(&(*p_buffer_)[0] + curr_ptr_, ptr, size); curr_ptr_ += size; } virtual void Seek(size_t pos) { @@ -178,7 +178,7 @@ struct MemoryBufferStream : public ISeekStream { /*! \brief implementation of file i/o stream */ class FileStream : public ISeekStream { public: - explicit FileStream(FILE *fp) : fp(fp) {} + explicit FileStream(std::FILE *fp) : fp(fp) {} explicit FileStream(void) { this->fp = NULL; } @@ -201,7 +201,7 @@ class FileStream : public ISeekStream { } private: - FILE *fp; + std::FILE *fp; }; } // namespace utils } // namespace xgboost