diff options
author | David Majnemer <david.majnemer@gmail.com> | 2014-10-08 08:48:43 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2014-10-08 08:48:43 +0000 |
commit | ecc177788fa7cd9487be8180a054480e144480cd (patch) | |
tree | bc4f1da052ed7ae1f486d363300d602c4f06e562 | |
parent | 000ef037d49e5bf431b5728726e0c4896fb85153 (diff) | |
download | llvm-ecc177788fa7cd9487be8180a054480e144480cd.zip llvm-ecc177788fa7cd9487be8180a054480e144480cd.tar.gz llvm-ecc177788fa7cd9487be8180a054480e144480cd.tar.bz2 |
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.
llvm-svn: 219288
-rw-r--r-- | llvm/lib/Support/Unix/Process.inc | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/Support/Unix/Process.inc b/llvm/lib/Support/Unix/Process.inc index 0d84bee..93b93ba 100644 --- a/llvm/lib/Support/Unix/Process.inc +++ b/llvm/lib/Support/Unix/Process.inc @@ -268,8 +268,13 @@ std::error_code Process::SafelyCloseFileDescriptor(int FD) { 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::SafelyCloseFileDescriptor(int FD) { 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) |