Skip to content

Commit

Permalink
Automerge: [lldb] AIX Changes for MainLoop polling (#120378)
Browse files Browse the repository at this point in the history
This PR is in reference to porting LLDB on AIX.

Link to discussions on llvm discourse and github:

1. https://discourse.llvm.org/t/port-lldb-to-ibm-aix/80640
2. llvm/llvm-project#101657
The complete changes for porting are present in this draft PR:
llvm/llvm-project#102601

Dropping changes for MainLoop polling in AIX, as `ppoll` is not
supported in AIX currently.
This change is part of the couple of minimal changes required to build a
minimal `lldb` binary on AIX
  • Loading branch information
DhruvSrivastavaX authored and github-actions[bot] committed Jan 10, 2025
2 parents beda637 + bca055f commit 95a4b74
Showing 1 changed file with 19 additions and 4 deletions.
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
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

0 comments on commit 95a4b74

Please sign in to comment.