Port R compatibility patches from 1.0.0 release branch (#5577)
* Don't use memset to set struct when compiling for R * Support 32-bit Solaris target for R package
This commit is contained in:
committed by
GitHub
parent
f27b6f9ba6
commit
e4f5b6c84f
@@ -831,7 +831,11 @@ void GHistIndexBlockMatrix::Init(const GHistIndexMatrix& gmat,
|
||||
* \brief fill a histogram by zeros in range [begin, end)
|
||||
*/
|
||||
void InitilizeHistByZeroes(GHistRow hist, size_t begin, size_t end) {
|
||||
#if defined(XGBOOST_STRICT_R_MODE) && XGBOOST_STRICT_R_MODE == 1
|
||||
std::fill(hist.begin() + begin, hist.begin() + end, tree::GradStats());
|
||||
#else // defined(XGBOOST_STRICT_R_MODE) && XGBOOST_STRICT_R_MODE == 1
|
||||
memset(hist.data() + begin, '\0', (end-begin)*sizeof(tree::GradStats));
|
||||
#endif // defined(XGBOOST_STRICT_R_MODE) && XGBOOST_STRICT_R_MODE == 1
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -117,14 +117,16 @@ std::string LoadSequentialFile(std::string fname) {
|
||||
size_t f_size_bytes = fs.st_size;
|
||||
buffer.resize(f_size_bytes + 1);
|
||||
int32_t fd = open(fname.c_str(), O_RDONLY);
|
||||
#if defined(__linux__)
|
||||
posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL);
|
||||
#endif // defined(__linux__)
|
||||
ssize_t bytes_read = read(fd, &buffer[0], f_size_bytes);
|
||||
if (bytes_read < 0) {
|
||||
close(fd);
|
||||
ReadErr();
|
||||
}
|
||||
close(fd);
|
||||
#else
|
||||
#else // defined(__unix__)
|
||||
FILE *f = fopen(fname.c_str(), "r");
|
||||
if (f == NULL) {
|
||||
std::string msg;
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
#define OBSERVER_PRINT LOG(INFO)
|
||||
#define OBSERVER_ENDL ""
|
||||
#define OBSERVER_NEWLINE ""
|
||||
#else
|
||||
#else // defined(XGBOOST_STRICT_R_MODE) && XGBOOST_STRICT_R_MODE == 1
|
||||
#define OBSERVER_PRINT std::cout << std::setprecision(17)
|
||||
#define OBSERVER_ENDL std::endl
|
||||
#define OBSERVER_NEWLINE "\n"
|
||||
#endif // defined(XGBOOST_STRICT_R_MODE)
|
||||
#endif // defined(XGBOOST_STRICT_R_MODE) && XGBOOST_STRICT_R_MODE == 1
|
||||
|
||||
namespace xgboost {
|
||||
/*\brief An observer for logging internal data structures.
|
||||
|
||||
Reference in New Issue
Block a user