Skip to content

Commit bca055f

Browse files
[lldb] AIX Changes for MainLoop polling (#120378)
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. #101657 The complete changes for porting are present in this draft PR: #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
1 parent 5807d0e commit bca055f

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

lldb/source/Host/posix/MainLoopPosix.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class MainLoopPosix::RunImpl {
9999
~RunImpl() = default;
100100

101101
Status Poll();
102+
102103
void ProcessReadEvents();
103104

104105
private:
@@ -159,6 +160,22 @@ MainLoopPosix::RunImpl::RunImpl(MainLoopPosix &loop) : loop(loop) {
159160
read_fds.reserve(loop.m_read_fds.size());
160161
}
161162

163+
static int StartPoll(llvm::MutableArrayRef<struct pollfd> fds,
164+
std::optional<MainLoopPosix::TimePoint> point) {
165+
#if HAVE_PPOLL
166+
return ppoll(fds.data(), fds.size(), ToTimeSpec(point),
167+
/*sigmask=*/nullptr);
168+
#else
169+
using namespace std::chrono;
170+
int timeout = -1;
171+
if (point) {
172+
nanoseconds dur = std::max(*point - steady_clock::now(), nanoseconds(0));
173+
timeout = ceil<milliseconds>(dur).count();
174+
}
175+
return poll(fds.data(), fds.size(), timeout);
176+
#endif
177+
}
178+
162179
Status MainLoopPosix::RunImpl::Poll() {
163180
read_fds.clear();
164181

@@ -169,11 +186,9 @@ Status MainLoopPosix::RunImpl::Poll() {
169186
pfd.revents = 0;
170187
read_fds.push_back(pfd);
171188
}
189+
int ready = StartPoll(read_fds, loop.GetNextWakeupTime());
172190

173-
if (ppoll(read_fds.data(), read_fds.size(),
174-
ToTimeSpec(loop.GetNextWakeupTime()),
175-
/*sigmask=*/nullptr) == -1 &&
176-
errno != EINTR)
191+
if (ready == -1 && errno != EINTR)
177192
return Status(errno, eErrorTypePOSIX);
178193

179194
return Status();

0 commit comments

Comments
 (0)