[llvm] r219288 - Unix/Process: Don't use pthread_sigmask if we aren't built with threads
David Majnemer
david.majnemer at gmail.com
Wed Oct 8 01:48:43 PDT 2014
Author: majnemer
Date: Wed Oct 8 03:48:43 2014
New Revision: 219288
URL: http://llvm.org/viewvc/llvm-project?rev=219288&view=rev
Log:
Unix/Process: Don't use pthread_sigmask if we aren't built with threads
We won't link in pthreads if we weren't built with LLVM_ENABLE_THREADS
which means we won't get access to pthread_sigmask. Use sigprocmask
instead.
Modified:
llvm/trunk/lib/Support/Unix/Process.inc
Modified: llvm/trunk/lib/Support/Unix/Process.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Process.inc?rev=219288&r1=219287&r2=219288&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Unix/Process.inc (original)
+++ llvm/trunk/lib/Support/Unix/Process.inc Wed Oct 8 03:48:43 2014
@@ -268,8 +268,13 @@ std::error_code Process::SafelyCloseFile
return std::error_code(errno, std::generic_category());
// Atomically swap our current signal mask with a full mask.
sigset_t SavedSet;
+#if LLVM_ENABLE_THREADS
if (int EC = pthread_sigmask(SIG_SETMASK, &FullSet, &SavedSet))
return std::error_code(EC, std::generic_category());
+#else
+ if (sigprocmask(SIG_SETMASK, &FullSet, &SavedSet) < 0)
+ return std::error_code(errno, std::generic_category());
+#endif
// Attempt to close the file descriptor.
// We need to save the error, if one occurs, because our subsequent call to
// pthread_sigmask might tamper with errno.
@@ -277,7 +282,13 @@ std::error_code Process::SafelyCloseFile
if (::close(FD) < 0)
ErrnoFromClose = errno;
// Restore the signal mask back to what we saved earlier.
- int EC = pthread_sigmask(SIG_SETMASK, &SavedSet, nullptr);
+ int EC = 0;
+#if LLVM_ENABLE_THREADS
+ EC = pthread_sigmask(SIG_SETMASK, &SavedSet, nullptr);
+#else
+ if (sigprocmask(SIG_SETMASK, &SavedSet, nullptr) < 0)
+ EC = errno;
+#endif
// The error code from close takes precedence over the one from
// pthread_sigmask.
if (ErrnoFromClose)
More information about the llvm-commits
mailing list