[PM] Port StripDeadPrototypes to the new pass manager
[oota-llvm.git] / lib / Support / Signals.cpp
index a3af37d5fe6a305cef7c8e2aafc0c79d09f78ea0..2c3560c3be90619c3642366c3a3079504c1936df 100644 (file)
@@ -8,12 +8,15 @@
 //===----------------------------------------------------------------------===//
 //
 // This file defines some helpful functions for dealing with the possibility of
-// Unix signals occuring while your program is running.
+// Unix signals occurring while your program is running.
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Support/Signals.h"
 #include "llvm/Config/config.h"
+#include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/Signals.h"
+
+#include <vector>
 
 namespace llvm {
 using namespace sys;
@@ -23,6 +26,15 @@ using namespace sys;
 //===          independent code.
 //===----------------------------------------------------------------------===//
 
+static ManagedStatic<std::vector<std::pair<void (*)(void *), void *>>>
+    CallBacksToRun;
+void sys::RunSignalHandlers() {
+  if (!CallBacksToRun.isConstructed())
+    return;
+  for (auto &I : *CallBacksToRun)
+    I.first(I.second);
+  CallBacksToRun->clear();
+}
 }
 
 // Include the platform-specific parts of this class.