blob: 2c3560c3be90619c3642366c3a3079504c1936df [file] [log] [blame]
Reid Spencer3d7a6142004-08-29 19:22:48 +00001//===- Signals.cpp - Signal Handling support --------------------*- C++ -*-===//
Misha Brukman10468d82005-04-21 22:55:34 +00002//
Reid Spencer3d7a6142004-08-29 19:22:48 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Misha Brukman10468d82005-04-21 22:55:34 +00007//
Reid Spencer3d7a6142004-08-29 19:22:48 +00008//===----------------------------------------------------------------------===//
9//
10// This file defines some helpful functions for dealing with the possibility of
Chris Lattner0ab5e2c2011-04-15 05:18:47 +000011// Unix signals occurring while your program is running.
Reid Spencer3d7a6142004-08-29 19:22:48 +000012//
13//===----------------------------------------------------------------------===//
14
Reid Spencer844f3fe2004-12-27 06:16:11 +000015#include "llvm/Config/config.h"
Yaron Keren240bd9c2015-07-22 19:01:14 +000016#include "llvm/Support/ManagedStatic.h"
17#include "llvm/Support/Signals.h"
18
19#include <vector>
Reid Spencer3d7a6142004-08-29 19:22:48 +000020
21namespace llvm {
22using namespace sys;
23
24//===----------------------------------------------------------------------===//
25//=== WARNING: Implementation here must contain only TRULY operating system
Misha Brukman10468d82005-04-21 22:55:34 +000026//=== independent code.
Reid Spencer3d7a6142004-08-29 19:22:48 +000027//===----------------------------------------------------------------------===//
28
Yaron Keren240bd9c2015-07-22 19:01:14 +000029static ManagedStatic<std::vector<std::pair<void (*)(void *), void *>>>
30 CallBacksToRun;
Yaron Keren28738102015-07-22 21:11:17 +000031void sys::RunSignalHandlers() {
Yaron Keren240bd9c2015-07-22 19:01:14 +000032 if (!CallBacksToRun.isConstructed())
33 return;
34 for (auto &I : *CallBacksToRun)
35 I.first(I.second);
36 CallBacksToRun->clear();
37}
Reid Spencer3d7a6142004-08-29 19:22:48 +000038}
39
40// Include the platform-specific parts of this class.
Reid Spencer844f3fe2004-12-27 06:16:11 +000041#ifdef LLVM_ON_UNIX
Reid Spencerc892a0d2005-01-09 23:29:00 +000042#include "Unix/Signals.inc"
Reid Spencer844f3fe2004-12-27 06:16:11 +000043#endif
44#ifdef LLVM_ON_WIN32
Michael J. Spencer447762d2010-11-29 18:16:10 +000045#include "Windows/Signals.inc"
Reid Spencer844f3fe2004-12-27 06:16:11 +000046#endif