diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-09 17:50:40 +0900 |
---|---|---|
committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-09 17:50:40 +0900 |
commit | fea7da1b00cc97d742faede2df96c7d327950f49 (patch) | |
tree | 4de1d6b4ddc69f4f32daabb11ad5c71ab0cf895e /lldb/source/Host/posix/MainLoopPosix.cpp | |
parent | 9b99dde0d47102625d93c5d1cbbc04951025a6c9 (diff) | |
parent | 0aa930a41f2d1ebf1fa90ec42da8f96d15a4dcbb (diff) | |
download | llvm-users/chapuni/cov/single/nextcount.zip llvm-users/chapuni/cov/single/nextcount.tar.gz llvm-users/chapuni/cov/single/nextcount.tar.bz2 |
Merge branch 'users/chapuni/cov/single/nextcount-base' into users/chapuni/cov/single/nextcountusers/chapuni/cov/single/nextcount
Diffstat (limited to 'lldb/source/Host/posix/MainLoopPosix.cpp')
-rw-r--r-- | lldb/source/Host/posix/MainLoopPosix.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/lldb/source/Host/posix/MainLoopPosix.cpp b/lldb/source/Host/posix/MainLoopPosix.cpp index aecdeb9..ce7caa3 100644 --- a/lldb/source/Host/posix/MainLoopPosix.cpp +++ b/lldb/source/Host/posix/MainLoopPosix.cpp @@ -99,6 +99,7 @@ public: ~RunImpl() = default; Status Poll(); + void ProcessReadEvents(); private: @@ -159,6 +160,22 @@ MainLoopPosix::RunImpl::RunImpl(MainLoopPosix &loop) : loop(loop) { read_fds.reserve(loop.m_read_fds.size()); } +static int StartPoll(llvm::MutableArrayRef<struct pollfd> fds, + std::optional<MainLoopPosix::TimePoint> point) { +#if HAVE_PPOLL + return ppoll(fds.data(), fds.size(), ToTimeSpec(point), + /*sigmask=*/nullptr); +#else + using namespace std::chrono; + int timeout = -1; + if (point) { + nanoseconds dur = std::max(*point - steady_clock::now(), nanoseconds(0)); + timeout = ceil<milliseconds>(dur).count(); + } + return poll(fds.data(), fds.size(), timeout); +#endif +} + Status MainLoopPosix::RunImpl::Poll() { read_fds.clear(); @@ -169,11 +186,9 @@ Status MainLoopPosix::RunImpl::Poll() { pfd.revents = 0; read_fds.push_back(pfd); } + int ready = StartPoll(read_fds, loop.GetNextWakeupTime()); - if (ppoll(read_fds.data(), read_fds.size(), - ToTimeSpec(loop.GetNextWakeupTime()), - /*sigmask=*/nullptr) == -1 && - errno != EINTR) + if (ready == -1 && errno != EINTR) return Status(errno, eErrorTypePOSIX); return Status(); |