summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Unix/Watchdog.inc
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2013-03-26 01:27:52 +0000
committerNick Lewycky <nicholas@mxc.ca>2013-03-26 01:27:52 +0000
commit4e06def851a32cbe1a7d18562462850cb9ca2a1e (patch)
tree4e75b9aa7f52a0b25360659790d546171270bf92 /llvm/lib/Support/Unix/Watchdog.inc
parent2f59302ce804c0886ccc4dcdd5e51789981d4bc3 (diff)
downloadbcm5719-llvm-4e06def851a32cbe1a7d18562462850cb9ca2a1e.tar.gz
bcm5719-llvm-4e06def851a32cbe1a7d18562462850cb9ca2a1e.zip
Add a new watchdog timer interface. The interface does not permit handling timeouts, so
it's only really useful if you're going to crash anyways. Use it in the pretty stack trace printer to kill the compiler if we hang while printing the stack trace. llvm-svn: 177962
Diffstat (limited to 'llvm/lib/Support/Unix/Watchdog.inc')
-rw-r--r--llvm/lib/Support/Unix/Watchdog.inc32
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/lib/Support/Unix/Watchdog.inc b/llvm/lib/Support/Unix/Watchdog.inc
new file mode 100644
index 00000000000..5d89c0e51b1
--- /dev/null
+++ b/llvm/lib/Support/Unix/Watchdog.inc
@@ -0,0 +1,32 @@
+//===--- Unix/Watchdog.inc - Unix Watchdog Implementation -------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file provides the generic Unix implementation of the Watchdog class.
+//
+//===----------------------------------------------------------------------===//
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+namespace llvm {
+ namespace sys {
+ Watchdog::Watchdog(unsigned int seconds) {
+#ifdef HAVE_UNISTD_H
+ alarm(seconds);
+#endif
+ }
+
+ Watchdog::~Watchdog() {
+#ifdef HAVE_UNISTD_H
+ alarm(0);
+#endif
+ }
+ }
+}
OpenPOWER on IntegriCloud