aboutsummaryrefslogtreecommitdiff
path: root/runtime/GCCLibraries/crtend/Exception.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-11-17 03:32:33 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-11-17 03:32:33 +0000
commit8b2e1419cf24a33df5a87c99e367528b44dc28cf (patch)
treedfa50da1818a1e9c1d0588c060051c65583821a3 /runtime/GCCLibraries/crtend/Exception.cpp
parentb2b9c20b6121a54a41ee1c583a4bff4389622da2 (diff)
Undo removal of the runtime libraries. While this may have been a bit
premature, these libraries will be going away for the 2.0 release. Other arrangements for profiling, gc, etc. should be made in the next few months. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31807 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'runtime/GCCLibraries/crtend/Exception.cpp')
-rw-r--r--runtime/GCCLibraries/crtend/Exception.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/runtime/GCCLibraries/crtend/Exception.cpp b/runtime/GCCLibraries/crtend/Exception.cpp
new file mode 100644
index 0000000000..d4ac290122
--- /dev/null
+++ b/runtime/GCCLibraries/crtend/Exception.cpp
@@ -0,0 +1,54 @@
+//===- Exception.cpp - Generic language-independent exceptions ------------===//
+//
+// This file defines the the shared data structures used by all language
+// specific exception handling runtime libraries.
+//
+//===----------------------------------------------------------------------===//
+
+#include "Exception.h"
+
+// Thread local state for exception handling. FIXME: This should really be made
+// thread-local!
+
+// UncaughtExceptionStack - The stack of exceptions currently being thrown.
+static llvm_exception *UncaughtExceptionStack = 0;
+
+// __llvm_eh_has_uncaught_exception - This is used to implement
+// std::uncaught_exception.
+//
+bool __llvm_eh_has_uncaught_exception() throw() {
+ return UncaughtExceptionStack != 0;
+}
+
+// __llvm_eh_current_uncaught_exception - This function checks to see if the
+// current uncaught exception is of the specified language type. If so, it
+// returns a pointer to the exception area data.
+//
+void *__llvm_eh_current_uncaught_exception_type(unsigned HandlerType) throw() {
+ if (UncaughtExceptionStack->ExceptionType == HandlerType)
+ return UncaughtExceptionStack+1;
+ return 0;
+}
+
+// __llvm_eh_add_uncaught_exception - This adds the specified exception to the
+// top of the uncaught exception stack. The exception should not already be on
+// the stack!
+void __llvm_eh_add_uncaught_exception(llvm_exception *E) throw() {
+ E->Next = UncaughtExceptionStack;
+ UncaughtExceptionStack = E;
+}
+
+
+// __llvm_eh_get_uncaught_exception - Returns the current uncaught exception.
+// There must be an uncaught exception for this to work!
+llvm_exception *__llvm_eh_get_uncaught_exception() throw() {
+ return UncaughtExceptionStack;
+}
+
+// __llvm_eh_pop_from_uncaught_stack - Remove the current uncaught exception
+// from the top of the stack.
+llvm_exception *__llvm_eh_pop_from_uncaught_stack() throw() {
+ llvm_exception *E = __llvm_eh_get_uncaught_exception();
+ UncaughtExceptionStack = E->Next;
+ return E;
+}