Author: Dhruv Srivastava Date: 2024-12-27T09:12:26+01:00 New Revision: bca055f2ac075d43f6f316927947b2a493f93bdb
URL: https://github.com/llvm/llvm-project/commit/bca055f2ac075d43f6f316927947b2a493f93bdb DIFF: https://github.com/llvm/llvm-project/commit/bca055f2ac075d43f6f316927947b2a493f93bdb.diff LOG: [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. https://github.com/llvm/llvm-project/issues/101657 The complete changes for porting are present in this draft PR: https://github.com/llvm/llvm-project/pull/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 Added: Modified: lldb/source/Host/posix/MainLoopPosix.cpp Removed: ################################################################################ diff --git a/lldb/source/Host/posix/MainLoopPosix.cpp b/lldb/source/Host/posix/MainLoopPosix.cpp index aecdeb9ba5d1c8..ce7caa3041dd06 100644 --- a/lldb/source/Host/posix/MainLoopPosix.cpp +++ b/lldb/source/Host/posix/MainLoopPosix.cpp @@ -99,6 +99,7 @@ class MainLoopPosix::RunImpl { ~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(); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits