2004-08-30 03:22:48 +08:00
|
|
|
//===- Signals.cpp - Signal Handling support --------------------*- C++ -*-===//
|
2005-04-22 06:55:34 +08:00
|
|
|
//
|
2004-08-30 03:22:48 +08:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 04:36:04 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-22 06:55:34 +08:00
|
|
|
//
|
2004-08-30 03:22:48 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines some helpful functions for dealing with the possibility of
|
2011-04-15 13:18:47 +08:00
|
|
|
// Unix signals occurring while your program is running.
|
2004-08-30 03:22:48 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2004-12-27 14:16:11 +08:00
|
|
|
#include "llvm/Config/config.h"
|
2015-07-23 03:01:14 +08:00
|
|
|
#include "llvm/Support/ManagedStatic.h"
|
|
|
|
#include "llvm/Support/Signals.h"
|
|
|
|
|
|
|
|
#include <vector>
|
2004-08-30 03:22:48 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
using namespace sys;
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//=== WARNING: Implementation here must contain only TRULY operating system
|
2005-04-22 06:55:34 +08:00
|
|
|
//=== independent code.
|
2004-08-30 03:22:48 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-07-23 03:01:14 +08:00
|
|
|
static ManagedStatic<std::vector<std::pair<void (*)(void *), void *>>>
|
|
|
|
CallBacksToRun;
|
2015-07-23 05:11:17 +08:00
|
|
|
void sys::RunSignalHandlers() {
|
2015-07-23 03:01:14 +08:00
|
|
|
if (!CallBacksToRun.isConstructed())
|
|
|
|
return;
|
|
|
|
for (auto &I : *CallBacksToRun)
|
|
|
|
I.first(I.second);
|
|
|
|
CallBacksToRun->clear();
|
|
|
|
}
|
2004-08-30 03:22:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Include the platform-specific parts of this class.
|
2004-12-27 14:16:11 +08:00
|
|
|
#ifdef LLVM_ON_UNIX
|
2005-01-10 07:29:00 +08:00
|
|
|
#include "Unix/Signals.inc"
|
2004-12-27 14:16:11 +08:00
|
|
|
#endif
|
|
|
|
#ifdef LLVM_ON_WIN32
|
2010-11-30 02:16:10 +08:00
|
|
|
#include "Windows/Signals.inc"
|
2004-12-27 14:16:11 +08:00
|
|
|
#endif
|