Skip to content

[lldb][AIX] AIX Changes for MainLoop polling #120378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions lldb/source/Host/posix/MainLoopPosix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class MainLoopPosix::RunImpl {
~RunImpl() = default;

Status Poll();

void ProcessReadEvents();

private:
Expand Down Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that HAVE_PPOLL is always defined but only its value will either be 0 or 1, so added accordingly.

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();

Expand All @@ -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();
Expand Down
Loading