Reid Spencer | 3d7a614 | 2004-08-29 19:22:48 +0000 | [diff] [blame] | 1 | //===- Signals.cpp - Signal Handling support --------------------*- C++ -*-===// |
Misha Brukman | 10468d8 | 2005-04-21 22:55:34 +0000 | [diff] [blame] | 2 | // |
Reid Spencer | 3d7a614 | 2004-08-29 19:22:48 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | f3ebc3f | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Misha Brukman | 10468d8 | 2005-04-21 22:55:34 +0000 | [diff] [blame] | 7 | // |
Reid Spencer | 3d7a614 | 2004-08-29 19:22:48 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines some helpful functions for dealing with the possibility of |
Chris Lattner | 0ab5e2c | 2011-04-15 05:18:47 +0000 | [diff] [blame] | 11 | // Unix signals occurring while your program is running. |
Reid Spencer | 3d7a614 | 2004-08-29 19:22:48 +0000 | [diff] [blame] | 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Reid Spencer | 844f3fe | 2004-12-27 06:16:11 +0000 | [diff] [blame] | 15 | #include "llvm/Config/config.h" |
Yaron Keren | 240bd9c | 2015-07-22 19:01:14 +0000 | [diff] [blame] | 16 | #include "llvm/Support/ManagedStatic.h" |
| 17 | #include "llvm/Support/Signals.h" |
| 18 | |
| 19 | #include <vector> |
Reid Spencer | 3d7a614 | 2004-08-29 19:22:48 +0000 | [diff] [blame] | 20 | |
| 21 | namespace llvm { |
| 22 | using namespace sys; |
| 23 | |
| 24 | //===----------------------------------------------------------------------===// |
| 25 | //=== WARNING: Implementation here must contain only TRULY operating system |
Misha Brukman | 10468d8 | 2005-04-21 22:55:34 +0000 | [diff] [blame] | 26 | //=== independent code. |
Reid Spencer | 3d7a614 | 2004-08-29 19:22:48 +0000 | [diff] [blame] | 27 | //===----------------------------------------------------------------------===// |
| 28 | |
Yaron Keren | 240bd9c | 2015-07-22 19:01:14 +0000 | [diff] [blame] | 29 | static ManagedStatic<std::vector<std::pair<void (*)(void *), void *>>> |
| 30 | CallBacksToRun; |
Yaron Keren | 2873810 | 2015-07-22 21:11:17 +0000 | [diff] [blame] | 31 | void sys::RunSignalHandlers() { |
Yaron Keren | 240bd9c | 2015-07-22 19:01:14 +0000 | [diff] [blame] | 32 | if (!CallBacksToRun.isConstructed()) |
| 33 | return; |
| 34 | for (auto &I : *CallBacksToRun) |
| 35 | I.first(I.second); |
| 36 | CallBacksToRun->clear(); |
| 37 | } |
Reid Spencer | 3d7a614 | 2004-08-29 19:22:48 +0000 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | // Include the platform-specific parts of this class. |
Reid Spencer | 844f3fe | 2004-12-27 06:16:11 +0000 | [diff] [blame] | 41 | #ifdef LLVM_ON_UNIX |
Reid Spencer | c892a0d | 2005-01-09 23:29:00 +0000 | [diff] [blame] | 42 | #include "Unix/Signals.inc" |
Reid Spencer | 844f3fe | 2004-12-27 06:16:11 +0000 | [diff] [blame] | 43 | #endif |
| 44 | #ifdef LLVM_ON_WIN32 |
Michael J. Spencer | 447762d | 2010-11-29 18:16:10 +0000 | [diff] [blame] | 45 | #include "Windows/Signals.inc" |
Reid Spencer | 844f3fe | 2004-12-27 06:16:11 +0000 | [diff] [blame] | 46 | #endif |