https://github.com/DhruvSrivastavaX updated https://github.com/llvm/llvm-project/pull/120378
>From cf6a863b6da6bdaf474d2abc4524960b6436f645 Mon Sep 17 00:00:00 2001 From: Dhruv-Srivastava <dhruv.srivast...@ibm.com> Date: Wed, 18 Dec 2024 02:17:04 -0600 Subject: [PATCH 1/3] AIX Changes for MainLoop --- lldb/source/Host/posix/MainLoopPosix.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lldb/source/Host/posix/MainLoopPosix.cpp b/lldb/source/Host/posix/MainLoopPosix.cpp index 1715610e0f84f1..a1d697e10a04ed 100644 --- a/lldb/source/Host/posix/MainLoopPosix.cpp +++ b/lldb/source/Host/posix/MainLoopPosix.cpp @@ -170,11 +170,23 @@ Status MainLoopPosix::RunImpl::Poll() { read_fds.push_back(pfd); } +#if defined(_AIX) + sigset_t origmask; + int timeout; + + timeout = -1; + pthread_sigmask(SIG_SETMASK, nullptr, &origmask); + int ready = poll(read_fds.data(), read_fds.size(), timeout); + pthread_sigmask(SIG_SETMASK, &origmask, nullptr); + if (ready == -1 && errno != EINTR) + return Status(errno, eErrorTypePOSIX); +#else if (ppoll(read_fds.data(), read_fds.size(), ToTimeSpec(loop.GetNextWakeupTime()), /*sigmask=*/nullptr) == -1 && errno != EINTR) return Status(errno, eErrorTypePOSIX); +#endif return Status(); } @@ -226,13 +238,13 @@ MainLoopPosix::~MainLoopPosix() { #endif m_read_fds.erase(m_interrupt_pipe.GetReadFileDescriptor()); m_interrupt_pipe.Close(); - assert(m_read_fds.size() == 0); + assert(m_read_fds.size() == 0); assert(m_signals.size() == 0); } MainLoopPosix::ReadHandleUP MainLoopPosix::RegisterReadObject(const IOObjectSP &object_sp, - const Callback &callback, Status &error) { + const Callback &callback, Status &error) { if (!object_sp || !object_sp->IsValid()) { error = Status::FromErrorString("IO object is not valid."); return nullptr; >From 7dc11e353e8420858adad3e58867727ef53f715f Mon Sep 17 00:00:00 2001 From: Dhruv-Srivastava <dhruv.srivast...@ibm.com> Date: Mon, 23 Dec 2024 08:11:11 -0600 Subject: [PATCH 2/3] Implemented Wrapper with HAVE_PPOLL --- lldb/source/Host/posix/MainLoopPosix.cpp | 33 +++++++++++++----------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/lldb/source/Host/posix/MainLoopPosix.cpp b/lldb/source/Host/posix/MainLoopPosix.cpp index a1d697e10a04ed..9b904ba2aa16ba 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(); + int StartPoll(std::optional<MainLoopPosix::TimePoint> point); void ProcessReadEvents(); private: @@ -159,6 +160,22 @@ MainLoopPosix::RunImpl::RunImpl(MainLoopPosix &loop) : loop(loop) { read_fds.reserve(loop.m_read_fds.size()); } +int MainLoopPosix::RunImpl::StartPoll( + std::optional<MainLoopPosix::TimePoint> point) { +#if HAVE_PPOLL + return ppoll(read_fds.data(), read_fds.size(), ToTimeSpec(point), + /*sigmask=*/nullptr); +#else + using namespace std::chrono; + int timeout = -1; + if (point) { + nanosecond dur = std::max(*point - steady_clock::now(), nanoseconds(0)); + timeout = ceil<milliseconds>(dur).count(); + } + return poll(read_fds.data(), read_fds.size(), timeout); +#endif +} + Status MainLoopPosix::RunImpl::Poll() { read_fds.clear(); @@ -169,24 +186,10 @@ Status MainLoopPosix::RunImpl::Poll() { pfd.revents = 0; read_fds.push_back(pfd); } + int ready = StartPoll(loop.GetNextWakeupTime()); -#if defined(_AIX) - sigset_t origmask; - int timeout; - - timeout = -1; - pthread_sigmask(SIG_SETMASK, nullptr, &origmask); - int ready = poll(read_fds.data(), read_fds.size(), timeout); - pthread_sigmask(SIG_SETMASK, &origmask, nullptr); if (ready == -1 && errno != EINTR) return Status(errno, eErrorTypePOSIX); -#else - if (ppoll(read_fds.data(), read_fds.size(), - ToTimeSpec(loop.GetNextWakeupTime()), - /*sigmask=*/nullptr) == -1 && - errno != EINTR) - return Status(errno, eErrorTypePOSIX); -#endif return Status(); } >From b9ceb61abfe2d29cae7d5e4778de385653057439 Mon Sep 17 00:00:00 2001 From: Dhruv-Srivastava <dhruv.srivast...@ibm.com> Date: Mon, 23 Dec 2024 08:54:19 -0600 Subject: [PATCH 3/3] blunder --- lldb/source/Host/posix/MainLoopPosix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Host/posix/MainLoopPosix.cpp b/lldb/source/Host/posix/MainLoopPosix.cpp index 9b904ba2aa16ba..d7c99dbd877ded 100644 --- a/lldb/source/Host/posix/MainLoopPosix.cpp +++ b/lldb/source/Host/posix/MainLoopPosix.cpp @@ -169,7 +169,7 @@ int MainLoopPosix::RunImpl::StartPoll( using namespace std::chrono; int timeout = -1; if (point) { - nanosecond dur = std::max(*point - steady_clock::now(), nanoseconds(0)); + nanoseconds dur = std::max(*point - steady_clock::now(), nanoseconds(0)); timeout = ceil<milliseconds>(dur).count(); } return poll(read_fds.data(), read_fds.size(), timeout); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits