[LIR] Move all the helpers to be private and re-order the methods in
[oota-llvm.git] / lib / Support / Signals.cpp
1 //===- Signals.cpp - Signal Handling support --------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines some helpful functions for dealing with the possibility of
11 // Unix signals occurring while your program is running.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #include "llvm/Config/config.h"
16 #include "llvm/Support/ManagedStatic.h"
17 #include "llvm/Support/Signals.h"
18
19 #include <vector>
20
21 namespace llvm {
22 using namespace sys;
23
24 //===----------------------------------------------------------------------===//
25 //=== WARNING: Implementation here must contain only TRULY operating system
26 //===          independent code.
27 //===----------------------------------------------------------------------===//
28
29 static ManagedStatic<std::vector<std::pair<void (*)(void *), void *>>>
30     CallBacksToRun;
31 void sys::RunSignalHandlers() {
32   if (!CallBacksToRun.isConstructed())
33     return;
34   for (auto &I : *CallBacksToRun)
35     I.first(I.second);
36   CallBacksToRun->clear();
37 }
38 }
39
40 // Include the platform-specific parts of this class.
41 #ifdef LLVM_ON_UNIX
42 #include "Unix/Signals.inc"
43 #endif
44 #ifdef LLVM_ON_WIN32
45 #include "Windows/Signals.inc"
46 #endif