POSIX compliant poll.h and mmap over sys/poll.h and mmap64 (#10767)
This commit is contained in:
parent
e1a2c1bbb3
commit
4503555274
@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
|
|
||||||
#include <sys/poll.h>
|
#include <poll.h>
|
||||||
|
|
||||||
using SOCKET = int;
|
using SOCKET = int;
|
||||||
using sock_size_t = size_t; // NOLINT
|
using sock_size_t = size_t; // NOLINT
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
#if defined(__unix__) || defined(__APPLE__)
|
#if defined(__unix__) || defined(__APPLE__)
|
||||||
|
|
||||||
#include <fcntl.h> // for open, O_RDONLY
|
#include <fcntl.h> // for open, O_RDONLY
|
||||||
#include <sys/mman.h> // for mmap, mmap64, munmap, madvise
|
#include <sys/mman.h> // for mmap, munmap, madvise
|
||||||
#include <unistd.h> // for close, getpagesize
|
#include <unistd.h> // for close, getpagesize
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@ -202,7 +202,7 @@ MMAPFile* detail::OpenMmap(std::string path, std::size_t offset, std::size_t len
|
|||||||
|
|
||||||
#if defined(__linux__) || defined(__GLIBC__)
|
#if defined(__linux__) || defined(__GLIBC__)
|
||||||
int prot{PROT_READ};
|
int prot{PROT_READ};
|
||||||
ptr = reinterpret_cast<std::byte*>(mmap64(nullptr, view_size, prot, MAP_PRIVATE, fd, view_start));
|
ptr = reinterpret_cast<std::byte*>(mmap(nullptr, view_size, prot, MAP_PRIVATE, fd, view_start));
|
||||||
CHECK_NE(ptr, MAP_FAILED) << "Failed to map: " << path << ". " << SystemErrorMsg();
|
CHECK_NE(ptr, MAP_FAILED) << "Failed to map: " << path << ". " << SystemErrorMsg();
|
||||||
auto handle = new MMAPFile{fd, ptr, view_size, offset - view_start, std::move(path)};
|
auto handle = new MMAPFile{fd, ptr, view_size, offset - view_start, std::move(path)};
|
||||||
#elif defined(xgboost_IS_WIN)
|
#elif defined(xgboost_IS_WIN)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user