[lldb] [MainLoop] Initialize empty sigset_t correctly
authorMichal Gorny <mgorny@gentoo.org>
Mon, 11 Feb 2019 09:18:46 +0000 (09:18 +0000)
committerMichal Gorny <mgorny@gentoo.org>
Mon, 11 Feb 2019 09:18:46 +0000 (09:18 +0000)
Fix MainLoop::RunImpl::get_sigmask() to correctly return empty sigset_t
when SIGNAL_POLLING_UNSUPPORTED is true.  On NetBSD (and probably
on some other platforms), integers are not implicitly convertible to
sigset_t, so 'return 0' is erraneous.  Instead, sigset_t should be reset
through sigemptyset().

While at it, move common parts out of the #ifdef.

Differential Revision: https://reviews.llvm.org/D57959

llvm-svn: 353675

lldb/source/Host/common/MainLoop.cpp

index f594d06..6f8d116 100644 (file)
@@ -137,18 +137,20 @@ MainLoop::RunImpl::RunImpl(MainLoop &loop) : loop(loop) {
 }
 
 sigset_t MainLoop::RunImpl::get_sigmask() {
-#if SIGNAL_POLLING_UNSUPPORTED
-  return 0;
-#else
   sigset_t sigmask;
+#if defined(_WIN32)
+  sigmask = 0;
+#elif SIGNAL_POLLING_UNSUPPORTED
+  sigemptyset(&sigmask);
+#else
   int ret = pthread_sigmask(SIG_SETMASK, nullptr, &sigmask);
   assert(ret == 0);
   (void) ret;
 
   for (const auto &sig : loop.m_signals)
     sigdelset(&sigmask, sig.first);
-  return sigmask;
 #endif
+  return sigmask;
 }
 
 #ifdef __ANDROID__