Add an interface for unregistering a file from the FilesToRemove list.
authorDan Gohman <gohman@apple.com>
Wed, 1 Sep 2010 14:17:34 +0000 (14:17 +0000)
committerDan Gohman <gohman@apple.com>
Wed, 1 Sep 2010 14:17:34 +0000 (14:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112705 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/System/Signals.h
lib/System/Unix/Signals.inc
lib/System/Win32/Signals.inc

index 504420cd402dd5a49d9568fa84d1cdad3b2fbd7f..7f1c87c3d55a3659a734c5b98e26e2f6516dfdfa 100644 (file)
@@ -29,6 +29,10 @@ namespace sys {
   /// @brief Remove a file if a fatal signal occurs.
   bool RemoveFileOnSignal(const Path &Filename, std::string* ErrMsg = 0);
 
+  /// This function removes a file from the list of files to be removed on
+  /// signal delivery.
+  void DontRemoveFileOnSignal(const Path &Filename);
+
   /// When an error signal (such as SIBABRT or SIGSEGV) is delivered to the
   /// process, print a stack trace and then exit.
   /// @brief Print a stack trace if a fatal signal occurs.
index 3e0de66b5d71e0f2f104bf8fbe91c81f501f9e6a..7b7c43efc78648ece431c89eae5fb2ffe942dcc1 100644 (file)
@@ -182,6 +182,16 @@ bool llvm::sys::RemoveFileOnSignal(const sys::Path &Filename,
   return false;
 }
 
+// DontRemoveFileOnSignal - The public API
+void llvm::sys::DontRemoveFileOnSignal(const sys::Path &Filename) {
+  SignalsMutex.acquire();
+  std::vector<sys::Path>::reverse_iterator I =
+    std::find(FilesToRemove.rbegin(), FilesToRemove.rend(), Filename);
+  if (I != FilesToRemove.rend())
+    FilesToRemove.erase(I.base()-1);
+  SignalsMutex.release();
+}
+
 /// AddSignalHandler - Add a function to be called when a signal is delivered
 /// to the process.  The handler can have a cookie passed to it to identify
 /// what instance of the handler it is.
index d6db71ba4f359e6d1219091815df5023d6da4133..2498a26ea99c5c766d1d8159b9d444ba526c63de 100644 (file)
@@ -140,6 +140,20 @@ bool sys::RemoveFileOnSignal(const sys::Path &Filename, std::string* ErrMsg) {
   return false;
 }
 
+// DontRemoveFileOnSignal - The public API
+void sys::DontRemoveFileOnSignal(const sys::Path &Filename) {
+  if (FilesToRemove == NULL)
+    return;
+
+  FilesToRemove->push_back(Filename);
+  std::vector<sys::Path>::reverse_iterator I =
+  std::find(FilesToRemove->rbegin(), FilesToRemove->rend(), Filename);
+  if (I != FilesToRemove->rend())
+    FilesToRemove->erase(I.base()-1);
+
+  LeaveCriticalSection(&CriticalSection);
+}
+
 /// PrintStackTraceOnErrorSignal - When an error signal (such as SIBABRT or
 /// SIGSEGV) is delivered to the process, print a stack trace and then exit.
 void sys::PrintStackTraceOnErrorSignal() {