summaryrefslogtreecommitdiff
path: root/runtime/GCCLibraries
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-09-15 15:07:22 +0000
committerChris Lattner <sabre@nondot.org>2003-09-15 15:07:22 +0000
commit6d4e4f85ddd0db366fd39c45d5044a46d8e26859 (patch)
tree1b6b43be6628b81dcaafd18b8b8ccdc3a7a05440 /runtime/GCCLibraries
parent22c83280584a63548563bb88db3b536c157d41cf (diff)
Remove dead library, it is now folded into crtend
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8532 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'runtime/GCCLibraries')
-rw-r--r--runtime/GCCLibraries/libexception/C++-Exception.cpp362
-rw-r--r--runtime/GCCLibraries/libexception/C++-Exception.h84
-rw-r--r--runtime/GCCLibraries/libexception/Exception.cpp57
-rw-r--r--runtime/GCCLibraries/libexception/Exception.h61
-rw-r--r--runtime/GCCLibraries/libexception/SJLJ-Exception.cpp134
-rw-r--r--runtime/GCCLibraries/libexception/SJLJ-Exception.h73
6 files changed, 0 insertions, 771 deletions
diff --git a/runtime/GCCLibraries/libexception/C++-Exception.cpp b/runtime/GCCLibraries/libexception/C++-Exception.cpp
deleted file mode 100644
index b6ebb2292e8..00000000000
--- a/runtime/GCCLibraries/libexception/C++-Exception.cpp
+++ /dev/null
@@ -1,362 +0,0 @@
-//===- C++-Exception.cpp - Exception handling support for C++ exceptions --===//
-//
-// This file defines the methods used to implement C++ exception handling in
-// terms of the invoke and %llvm.unwind intrinsic. These primitives implement
-// an exception handling ABI similar (but simpler and more efficient than) the
-// Itanium C++ ABI exception handling standard.
-//
-//===----------------------------------------------------------------------===//
-
-#include "C++-Exception.h"
-#include <cstdlib>
-#include <cstdarg>
-
-//#define DEBUG
-
-#ifdef DEBUG
-#include <stdio.h>
-#endif
-
-// LastCaughtException - The last exception caught by this handler. This is for
-// implementation of _rethrow and _get_last_caught.
-//
-// FIXME: This should be thread-local!
-//
-static llvm_exception *LastCaughtException = 0;
-
-
-using namespace __cxxabiv1;
-
-// __llvm_cxxeh_allocate_exception - This function allocates space for the
-// specified number of bytes, plus a C++ exception object header.
-//
-void *__llvm_cxxeh_allocate_exception(unsigned NumBytes) throw() {
- // FIXME: This should eventually have back-up buffers for out-of-memory
- // situations.
- //
- llvm_cxx_exception *E =
- (llvm_cxx_exception *)malloc(NumBytes+sizeof(llvm_cxx_exception));
- E->BaseException.ExceptionType = 0; // intialize to invalid
-
- return E+1; // return the pointer after the header
-}
-
-// __llvm_cxxeh_free_exception - Low-level function to free an exception. This
-// is called directly from generated C++ code if evaluating the exception value
-// into the exception location throws. Otherwise it is called from the C++
-// exception object destructor.
-//
-void __llvm_cxxeh_free_exception(void *ObjectPtr) throw() {
- llvm_cxx_exception *E = (llvm_cxx_exception *)ObjectPtr - 1;
- free(E);
-}
-
-// cxx_destructor - This function is called through the generic
-// exception->ExceptionDestructor function pointer to destroy a caught
-// exception.
-//
-static void cxx_destructor(llvm_exception *LE) /* might throw */{
- assert(LE->Next == 0 && "On the uncaught stack??");
- llvm_cxx_exception *E = get_cxx_exception(LE);
-
- struct ExceptionFreer {
- void *Ptr;
- ExceptionFreer(void *P) : Ptr(P) {}
- ~ExceptionFreer() {
- // Free the memory for the exception, when the function is left, even if
- // the exception object dtor throws its own exception!
- __llvm_cxxeh_free_exception(Ptr);
- }
- } EF(E+1);
-
- // Run the exception object dtor if it exists. */
- if (E->ExceptionObjectDestructor)
- E->ExceptionObjectDestructor(E);
-}
-
-// __llvm_cxxeh_throw - Given a pointer to memory which has an exception object
-// evaluated into it, this sets up all of the fields of the exception allowing
-// it to be thrown. After calling this, the code should call %llvm.unwind
-//
-void __llvm_cxxeh_throw(void *ObjectPtr, void *TypeInfoPtr,
- void (*DtorPtr)(void*)) throw() {
- llvm_cxx_exception *E = (llvm_cxx_exception *)ObjectPtr - 1;
- E->BaseException.ExceptionDestructor = cxx_destructor;
- E->BaseException.ExceptionType = CXXException;
- E->BaseException.HandlerCount = 0;
- E->BaseException.isRethrown = 0;
-
- E->TypeInfo = (const std::type_info*)TypeInfoPtr;
- E->ExceptionObjectDestructor = DtorPtr;
- E->UnexpectedHandler = __unexpected_handler;
- E->TerminateHandler = __terminate_handler;
-
- __llvm_eh_add_uncaught_exception(&E->BaseException);
-}
-
-
-// CXXExceptionISA - use the type info object stored in the exception to see if
-// TypeID matches and, if so, to adjust the exception object pointer.
-//
-static void *CXXExceptionISA(llvm_cxx_exception *E,
- const std::type_info *Type) throw() {
- // ThrownPtr is a pointer to the object being thrown...
- void *ThrownPtr = E+1;
- const std::type_info *ThrownType = E->TypeInfo;
-
-#if 0
- // FIXME: this code exists in the GCC exception handling library: I haven't
- // thought about this yet, so it should be verified at some point!
-
- // Pointer types need to adjust the actual pointer, not
- // the pointer to pointer that is the exception object.
- // This also has the effect of passing pointer types
- // "by value" through the __cxa_begin_catch return value.
- if (ThrownType->__is_pointer_p())
- ThrownPtr = *(void **)ThrownPtr;
-#endif
-
- if (Type->__do_catch(ThrownType, &ThrownPtr, 1)) {
-#ifdef DEBUG
- printf("isa<%s>(%s): 0x%p -> 0x%p\n", Type->name(), ThrownType->name(),
- E+1, ThrownPtr);
-#endif
- return ThrownPtr;
- }
-
- return 0;
-}
-
-// __llvm_cxxeh_current_uncaught_exception_isa - This function checks to see if
-// the current uncaught exception is a C++ exception, and if it is of the
-// specified type id. If so, it returns a pointer to the object adjusted as
-// appropriate, otherwise it returns null.
-//
-void *__llvm_cxxeh_current_uncaught_exception_isa(void *CatchType) throw() {
- void *EPtr = __llvm_eh_current_uncaught_exception_type(CXXException);
- if (EPtr == 0) return 0; // If it's not a c++ exception, it doesn't match!
-
- // If it is a C++ exception, use the type info object stored in the exception
- // to see if TypeID matches and, if so, to adjust the exception object
- // pointer.
- //
- const std::type_info *Info = (const std::type_info *)CatchType;
- return CXXExceptionISA((llvm_cxx_exception*)EPtr - 1, Info);
-}
-
-
-// __llvm_cxxeh_begin_catch - This function is called by "exception handlers",
-// which transition an exception from being uncaught to being caught. It
-// returns a pointer to the exception object portion of the exception. This
-// function must work with foreign exceptions.
-//
-void *__llvm_cxxeh_begin_catch() throw() {
- llvm_exception *E = __llvm_eh_pop_from_uncaught_stack();
-
- // The exception is now caught.
- LastCaughtException = E;
- E->Next = 0;
- E->isRethrown = 0;
-
- // Increment the handler count for this exception.
- E->HandlerCount++;
-
-#ifdef DEBUG
- printf("Exiting begin_catch Ex=0x%p HandlerCount=%d!\n", E+1,
- E->HandlerCount);
-#endif
-
- // Return a pointer to the raw exception object.
- return E+1;
-}
-
-// __llvm_cxxeh_begin_catch_if_isa - This function checks to see if the current
-// uncaught exception is of the specified type. If not, it returns a null
-// pointer, otherwise it 'catches' the exception and returns a pointer to the
-// object of the specified type. This function does never succeeds with foreign
-// exceptions (because they can never be of type CatchType).
-//
-void *__llvm_cxxeh_begin_catch_if_isa(void *CatchType) throw() {
- void *ObjPtr = __llvm_cxxeh_current_uncaught_exception_isa(CatchType);
- if (!ObjPtr) return 0;
-
- // begin_catch, meaning that the object is now "caught", not "uncaught"
- __llvm_cxxeh_begin_catch();
- return ObjPtr;
-}
-
-// __llvm_cxxeh_get_last_caught - Return the last exception that was caught by
-// ...begin_catch.
-//
-void *__llvm_cxxeh_get_last_caught() throw() {
- assert(LastCaughtException && "No exception caught!!");
- return LastCaughtException+1;
-}
-
-// __llvm_cxxeh_end_catch - This function decrements the HandlerCount of the
-// top-level caught exception, destroying it if this is the last handler for the
-// exception.
-//
-void __llvm_cxxeh_end_catch(void *Ex) /* might throw */ {
- llvm_exception *E = (llvm_exception*)Ex - 1;
- assert(E && "There are no caught exceptions!");
-
- // If this is the last handler using the exception, destroy it now!
- if (--E->HandlerCount == 0 && !E->isRethrown) {
-#ifdef DEBUG
- printf("Destroying exception!\n");
-#endif
- E->ExceptionDestructor(E); // Release memory for the exception
- }
-#ifdef DEBUG
- printf("Exiting end_catch Ex=0x%p HandlerCount=%d!\n", Ex, E->HandlerCount);
-#endif
-}
-
-// __llvm_cxxeh_call_terminate - This function is called when the dtor for an
-// object being destroyed due to an exception throw throws an exception. This
-// is illegal because it would cause multiple exceptions to be active at one
-// time.
-void __llvm_cxxeh_call_terminate() throw() {
- void (*Handler)(void) = __terminate_handler;
- if (__llvm_eh_has_uncaught_exception())
- if (void *EPtr = __llvm_eh_current_uncaught_exception_type(CXXException))
- Handler = ((llvm_cxx_exception*)EPtr - 1)->TerminateHandler;
- __terminate(Handler);
-}
-
-
-// __llvm_cxxeh_rethrow - This function turns the top-level caught exception
-// into an uncaught exception, in preparation for an llvm.unwind, which should
-// follow immediately after the call to this function. This function must be
-// prepared to deal with foreign exceptions.
-//
-void __llvm_cxxeh_rethrow() throw() {
- llvm_exception *E = LastCaughtException;
- if (E == 0)
- // 15.1.8 - If there are no exceptions being thrown, 'throw;' should call
- // terminate.
- //
- __terminate(__terminate_handler);
-
- // Otherwise we have an exception to rethrow. Mark the exception as such.
- E->isRethrown = 1;
-
- // Add the exception to the top of the uncaught stack, to preserve the
- // invariant that the top of the uncaught stack is the current exception.
- __llvm_eh_add_uncaught_exception(E);
-
- // Return to the caller, which should perform the unwind now.
-}
-
-static bool ExceptionSpecificationPermitsException(llvm_exception *E,
- const std::type_info *Info,
- va_list Args) {
- // The only way it could match one of the types is if it is a C++ exception.
- if (E->ExceptionType != CXXException) return false;
-
- llvm_cxx_exception *Ex = get_cxx_exception(E);
-
- // Scan the list of accepted types, checking to see if the uncaught
- // exception is any of them.
- do {
- // Check to see if the exception matches one of the types allowed by the
- // exception specification. If so, return to the caller to have the
- // exception rethrown.
- if (CXXExceptionISA(Ex, Info))
- return true;
-
- Info = va_arg(Args, std::type_info *);
- } while (Info);
- return false;
-}
-
-
-// __llvm_cxxeh_check_eh_spec - If a function with an exception specification is
-// throwing an exception, this function gets called with the list of type_info
-// objects that it is allowing to propagate. Check to see if the current
-// uncaught exception is one of these types, and if so, allow it to be thrown by
-// returning to the caller, which should immediately follow this call with
-// llvm.unwind.
-//
-// Note that this function does not throw any exceptions, but we can't put an
-// exception specification on it or else we'll get infinite loops!
-//
-void __llvm_cxxeh_check_eh_spec(void *Info, ...) {
- const std::type_info *TypeInfo = (const std::type_info *)Info;
-
- if (TypeInfo == 0) { // Empty exception specification
- // Whatever exception this is, it is not allowed by the (empty) spec, call
- // unexpected, according to 15.4.8.
- try {
- void *Ex = __llvm_cxxeh_begin_catch(); // Start the catch
- __llvm_cxxeh_end_catch(Ex); // Free the exception
- __unexpected(__unexpected_handler);
- } catch (...) {
- // Any exception thrown by unexpected cannot match the ehspec. Call
- // terminate, according to 15.4.9.
- __terminate(__terminate_handler);
- }
- }
-
- llvm_exception *E = __llvm_eh_get_uncaught_exception();
- assert(E && "No uncaught exceptions!");
-
- // Check to see if the exception matches one of the types allowed by the
- // exception specification. If so, return to the caller to have the
- // exception rethrown.
-
- va_list Args;
- va_start(Args, Info);
- bool Ok = ExceptionSpecificationPermitsException(E, TypeInfo, Args);
- va_end(Args);
- if (Ok) return;
-
- // Ok, now we know that the exception is either not a C++ exception (thus not
- // permitted to pass through) or not a C++ exception that is allowed. Kill
- // the exception and call the unexpected handler.
- try {
- void *Ex = __llvm_cxxeh_begin_catch(); // Start the catch
- __llvm_cxxeh_end_catch(Ex); // Free the exception
- } catch (...) {
- __terminate(__terminate_handler); // Exception dtor threw
- }
-
- try {
- __unexpected(__unexpected_handler);
- } catch (...) {
- // If the unexpected handler threw an exception, we will get here. Since
- // entering the try block calls ..._begin_catch, we need to "rethrow" the
- // exception to make it uncaught again. Exiting the catch will then leave
- // it in the uncaught state.
- __llvm_cxxeh_rethrow();
- }
-
- // Grab the newly caught exception. If this exception is permitted by the
- // specification, allow it to be thrown.
- E = __llvm_eh_get_uncaught_exception();
-
- va_start(Args, Info);
- Ok = ExceptionSpecificationPermitsException(E, TypeInfo, Args);
- va_end(Args);
- if (Ok) return;
-
- // Final case, check to see if we can throw an std::bad_exception.
- try {
- throw std::bad_exception();
- } catch (...) {
- __llvm_cxxeh_rethrow();
- }
-
- // Grab the new bad_exception...
- E = __llvm_eh_get_uncaught_exception();
-
- // If it's permitted, allow it to be thrown instead.
- va_start(Args, Info);
- Ok = ExceptionSpecificationPermitsException(E, TypeInfo, Args);
- va_end(Args);
- if (Ok) return;
-
- // Otherwise, we are out of options, terminate, according to 15.5.2.2.
- __terminate(__terminate_handler);
-}
diff --git a/runtime/GCCLibraries/libexception/C++-Exception.h b/runtime/GCCLibraries/libexception/C++-Exception.h
deleted file mode 100644
index 133f43a58ec..00000000000
--- a/runtime/GCCLibraries/libexception/C++-Exception.h
+++ /dev/null
@@ -1,84 +0,0 @@
-//===- C++-Exception.h - C++ Specific Exception Handling --------*- C++ -*-===//
-//
-// This file defines the data structures and API used by the C++ exception
-// handling runtime library.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef CXX_EXCEPTION_H
-#define CXX_EXCEPTION_H
-
-#include "Exception.h"
-#include <typeinfo>
-#include <cassert>
-
-struct llvm_cxx_exception {
- // TypeInfo - A pointer to the C++ std::type_info object for this exception
- // class. This is required because the class may not be polymorphic.
- //
- const std::type_info *TypeInfo;
-
- // ExceptionObjectDestructor - A pointer to the function which destroys the
- // object represented by this exception. This is required because the class
- // may not be polymorphic. This may be null if there is no cleanup required.
- //
- void (*ExceptionObjectDestructor)(void *);
-
- // UnexpectedHandler - This contains a pointer to the "unexpected" handler
- // which may be registered by the user program with set_unexpected. Calls to
- // unexpected which are a result of an exception throw are supposed to use the
- // value of the handler at the time of the throw, not the currently set value.
- //
- void (*UnexpectedHandler)();
-
- // TerminateHandler - This contains a pointer to the "terminate" handler which
- // may be registered by the user program with set_terminate. Calls to
- // unexpected which are a result of an exception throw are supposed to use the
- // value of the handler at the time of the throw, not the currently set value.
- //
- void (*TerminateHandler)();
-
- // BaseException - The language independent portion of the exception state.
- // This is at the end of the record so that we can add additional members to
- // this structure without breaking binary compatibility.
- //
- llvm_exception BaseException;
-};
-
-inline llvm_cxx_exception *get_cxx_exception(llvm_exception *E) throw() {
- assert(E->ExceptionType == CXXException && "Not a C++ exception?");
- return (llvm_cxx_exception*)(E+1)-1;
-}
-
-// Interface to the C++ standard library to get to the terminate and unexpected
-// handler stuff.
-namespace __cxxabiv1 {
- // Invokes given handler, dying appropriately if the user handler was
- // so inconsiderate as to return.
- extern void __terminate(std::terminate_handler) throw() __attribute__((noreturn));
- extern void __unexpected(std::unexpected_handler) __attribute__((noreturn));
-
- // The current installed user handlers.
- extern std::terminate_handler __terminate_handler;
- extern std::unexpected_handler __unexpected_handler;
-}
-
-extern "C" {
- void *__llvm_cxxeh_allocate_exception(unsigned NumBytes) throw();
- void __llvm_cxxeh_free_exception(void *ObjectPtr) throw();
- void __llvm_cxxeh_throw(void *ObjectPtr, void *TypeInfoPtr,
- void (*DtorPtr)(void*)) throw();
-
- void __llvm_cxxeh_call_terminate() throw() __attribute__((noreturn));
- void * __llvm_cxxeh_current_uncaught_exception_isa(void *Ty)
- throw();
- void *__llvm_cxxeh_begin_catch() throw();
- void *__llvm_cxxeh_begin_catch_if_isa(void *CatchType) throw();
- void __llvm_cxxeh_end_catch(void *Exception) /* might throw */;
- void __llvm_cxxeh_rethrow() throw();
- void *__llvm_cxxeh_get_last_caught() throw();
-
- void __llvm_cxxeh_check_eh_spec(void *Info, ...);
-}
-
-#endif
diff --git a/runtime/GCCLibraries/libexception/Exception.cpp b/runtime/GCCLibraries/libexception/Exception.cpp
deleted file mode 100644
index 156b714cb1a..00000000000
--- a/runtime/GCCLibraries/libexception/Exception.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-//===- 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"
-#include <cassert>
-
-// 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() {
- assert(UncaughtExceptionStack && "No uncaught exception!");
- 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() {
- assert(UncaughtExceptionStack && "There are no uncaught exceptions!?!?");
- 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;
-}
diff --git a/runtime/GCCLibraries/libexception/Exception.h b/runtime/GCCLibraries/libexception/Exception.h
deleted file mode 100644
index d3f95e77b0e..00000000000
--- a/runtime/GCCLibraries/libexception/Exception.h
+++ /dev/null
@@ -1,61 +0,0 @@
-//===- Exception.h - Generic language-independent exceptions ----*- C++ -*-===//
-//
-// This file defines the the shared data structures used by all language
-// specific exception handling runtime libraries.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef EXCEPTION_H
-#define EXCEPTION_H
-
-struct llvm_exception {
- // ExceptionDestructor - This call-back function is used to destroy the
- // current exception, without requiring the caller to know what the concrete
- // exception type is.
- //
- void (*ExceptionDestructor)(llvm_exception *);
-
- // ExceptionType - This field identifies what runtime library this exception
- // came from. Currently defined values are:
- // 0 - Error
- // 1 - longjmp exception (see longjmp-exception.c)
- // 2 - C++ exception (see c++-exception.c)
- //
- unsigned ExceptionType;
-
- // Next - This points to the next exception in the current stack.
- llvm_exception *Next;
-
- // HandlerCount - This is a count of the number of handlers which have
- // currently caught this exception. If the handler is caught and this number
- // falls to zero, the exception is destroyed.
- //
- unsigned HandlerCount;
-
- // isRethrown - This field is set on an exception if it has been 'throw;'n.
- // This is needed because the exception might exit through a number of the
- // end_catch statements matching the number of begin_catch statements that
- // have been processed. When this happens, the exception should become
- // uncaught, not dead.
- //
- int isRethrown;
-};
-
-enum {
- ErrorException = 0,
- SJLJException = 1,
- CXXException = 2,
-};
-
-// Language independent exception handling API...
-//
-extern "C" {
- bool __llvm_eh_has_uncaught_exception() throw();
- void *__llvm_eh_current_uncaught_exception_type(unsigned HandlerType) throw();
- void __llvm_eh_add_uncaught_exception(llvm_exception *E) throw();
-
- llvm_exception *__llvm_eh_get_uncaught_exception() throw();
- llvm_exception *__llvm_eh_pop_from_uncaught_stack() throw();
-}
-
-#endif
diff --git a/runtime/GCCLibraries/libexception/SJLJ-Exception.cpp b/runtime/GCCLibraries/libexception/SJLJ-Exception.cpp
deleted file mode 100644
index 8bc13e7659f..00000000000
--- a/runtime/GCCLibraries/libexception/SJLJ-Exception.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-//===- SJLJ-Exception.cpp - SetJmp/LongJmp Exception Handling -------------===//
-//
-// This file implements the API used by the Setjmp/Longjmp exception handling
-// runtime library.
-//
-//===----------------------------------------------------------------------===//
-
-#include "SJLJ-Exception.h"
-#include <cstdlib>
-#include <cassert>
-
-// get_sjlj_exception - Adjust the llvm_exception pointer to be an appropriate
-// llvm_sjlj_exception pointer.
-inline llvm_sjlj_exception *get_sjlj_exception(llvm_exception *E) {
- assert(E->ExceptionType == SJLJException);
- return (llvm_sjlj_exception*)(E+1) - 1;
-}
-
-// SetJmpMapEntry - One entry in a linked list of setjmps for the current
-// function.
-struct SetJmpMapEntry {
- void *JmpBuf;
- unsigned SetJmpID;
- SetJmpMapEntry *Next;
-};
-
-// SJLJDestructor - This function is used to free the exception when
-// language-indent code needs to destroy the exception without knowing exactly
-// what type it is.
-static void SJLJDestructor(llvm_exception *E) {
- free(get_sjlj_exception(E));
-}
-
-
-// __llvm_sjljeh_throw_longjmp - This function creates the longjmp exception and
-// returns. It takes care of mapping the longjmp value from 0 -> 1 as
-// appropriate. The caller should immediately call llvm.unwind after this
-// function call.
-void __llvm_sjljeh_throw_longjmp(void *JmpBuffer, int Val) throw() {
- llvm_sjlj_exception *E =
- (llvm_sjlj_exception *)malloc(sizeof(llvm_sjlj_exception));
- E->BaseException.ExceptionDestructor = SJLJDestructor;
- E->BaseException.ExceptionType = SJLJException;
- E->BaseException.HandlerCount = 0;
- E->BaseException.isRethrown = 0;
- E->JmpBuffer = JmpBuffer;
- E->LongJmpValue = Val ? Val : 1;
-
- __llvm_eh_add_uncaught_exception(&E->BaseException);
-}
-
-// __llvm_sjljeh_init_setjmpmap - This funciton initializes the pointer provided
-// to an empty setjmp map, and should be called on entry to a function which
-// calls setjmp.
-void __llvm_sjljeh_init_setjmpmap(void **SetJmpMap) throw() {
- *SetJmpMap = 0;
-}
-
-// __llvm_sjljeh_destroy_setjmpmap - This function frees all memory associated
-// with the specified setjmpmap structure. It should be called on all exits
-// (returns or unwinds) from the function which calls ...init_setjmpmap.
-void __llvm_sjljeh_destroy_setjmpmap(void **SetJmpMap) throw() {
- SetJmpMapEntry *Next;
- for (SetJmpMapEntry *SJE = *(SetJmpMapEntry**)SetJmpMap; SJE; SJE = Next) {
- Next = SJE->Next;
- free(SJE);
- }
-}
-
-// __llvm_sjljeh_add_setjmp_to_map - This function adds or updates an entry to
-// the map, to indicate which setjmp should be returned to if a longjmp happens.
-void __llvm_sjljeh_add_setjmp_to_map(void **SetJmpMap, void *JmpBuf,
- unsigned SetJmpID) throw() {
- SetJmpMapEntry **SJE = (SetJmpMapEntry**)SetJmpMap;
-
- // Scan for a pre-existing entry...
- for (; *SJE; SJE = &(*SJE)->Next)
- if ((*SJE)->JmpBuf == JmpBuf) {
- (*SJE)->SetJmpID = SetJmpID;
- return;
- }
-
- // No prexisting entry found, append to the end of the list...
- SetJmpMapEntry *New = (SetJmpMapEntry *)malloc(sizeof(SetJmpMapEntry));
- *SJE = New;
- New->JmpBuf = JmpBuf;
- New->SetJmpID = SetJmpID;
- New->Next = 0;
-}
-
-// __llvm_sjljeh_is_longjmp_exception - This function returns true if the
-// current uncaught exception is a longjmp exception. This is the first step of
-// catching a sjlj exception.
-bool __llvm_sjljeh_is_longjmp_exception() throw() {
- return __llvm_eh_current_uncaught_exception_type(SJLJException) != 0;
-}
-
-// __llvm_sjljeh_get_longjmp_value - This function returns the value that the
-// setjmp call should "return". This requires that the current uncaught
-// exception be a sjlj exception, though it does not require the exception to be
-// caught by this function.
-int __llvm_sjljeh_get_longjmp_value() throw() {
- llvm_sjlj_exception *E =
- get_sjlj_exception(__llvm_eh_get_uncaught_exception());
- return E->LongJmpValue;
-}
-
-// __llvm_sjljeh_try_catching_longjmp_exception - This function checks to see if
-// the current uncaught longjmp exception matches any of the setjmps collected
-// in the setjmpmap structure. If so, it catches and destroys the exception,
-// returning the index of the setjmp which caught the exception. If not, it
-// leaves the exception uncaught and returns a value of ~0.
-unsigned __llvm_sjljeh_try_catching_longjmp_exception(void **SetJmpMap) throw(){
- llvm_sjlj_exception *E =
- get_sjlj_exception(__llvm_eh_get_uncaught_exception());
-
- // Scan for a matching entry in the SetJmpMap...
- SetJmpMapEntry *SJE = *(SetJmpMapEntry**)SetJmpMap;
- for (; SJE; SJE = SJE->Next)
- if (SJE->JmpBuf == E->JmpBuffer) {
- // "Catch" and destroy the exception...
- __llvm_eh_pop_from_uncaught_stack();
-
- // We know it's a longjmp exception, so we can just free it instead of
- // calling the destructor.
- free(E);
-
- // Return the setjmp ID which we should branch to...
- return SJE->SetJmpID;
- }
-
- // No setjmp in this function catches the exception!
- return ~0;
-}
diff --git a/runtime/GCCLibraries/libexception/SJLJ-Exception.h b/runtime/GCCLibraries/libexception/SJLJ-Exception.h
deleted file mode 100644
index 05960025fa0..00000000000
--- a/runtime/GCCLibraries/libexception/SJLJ-Exception.h
+++ /dev/null
@@ -1,73 +0,0 @@
-//===- SJLJ-Exception.h - SetJmp/LongJmp Exception Handling -----*- C++ -*-===//
-//
-// This file defines the data structures and API used by the Setjmp/Longjmp
-// exception handling runtime library.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef SJLJ_EXCEPTION_H
-#define SJLJ_EXCEPTION_H
-
-#include "Exception.h"
-
-struct llvm_sjlj_exception {
- // JmpBuffer - This is the buffer which was longjmp'd with.
- //
- void *JmpBuffer;
-
- // LongJmpValue - The value passed into longjmp, which the corresponding
- // setjmp should return. Note that this value will never be equal to 0.
- //
- int LongJmpValue;
-
- // BaseException - The language independent portion of the exception state.
- // This is at the end of the record so that we can add additional members to
- // this structure without breaking binary compatibility.
- //
- llvm_exception BaseException;
-};
-
-extern "C" {
- // __llvm_sjljeh_throw_longjmp - This function creates the longjmp exception
- // and returns. It takes care of mapping the longjmp value from 0 -> 1 as
- // appropriate. The caller should immediately call llvm.unwind after this
- // function call.
- void __llvm_sjljeh_throw_longjmp(void *JmpBuffer, int Val) throw();
-
- // __llvm_sjljeh_init_setjmpmap - This funciton initializes the pointer
- // provided to an empty setjmp map, and should be called on entry to a
- // function which calls setjmp.
- void __llvm_sjljeh_init_setjmpmap(void **SetJmpMap) throw();
-
- // __llvm_sjljeh_destroy_setjmpmap - This function frees all memory associated
- // with the specified setjmpmap structure. It should be called on all exits
- // (returns or unwinds) from the function which calls ...init_setjmpmap.
- void __llvm_sjljeh_destroy_setjmpmap(void **SetJmpMap) throw();
-
- // __llvm_sjljeh_add_setjmp_to_map - This function adds or updates an entry to
- // the map, to indicate which setjmp should be returned to if a longjmp
- // happens.
- void __llvm_sjljeh_add_setjmp_to_map(void **SetJmpMap, void *JmpBuf,
- unsigned SetJmpID) throw();
-
- // __llvm_sjljeh_is_longjmp_exception - This function returns true if the
- // current uncaught exception is a longjmp exception. This is the first step
- // of catching a sjlj exception.
- bool __llvm_sjljeh_is_longjmp_exception() throw();
-
- // __llvm_sjljeh_get_longjmp_value - This function returns the value that the
- // setjmp call should "return". This requires that the current uncaught
- // exception be a sjlj exception, though it does not require the exception to
- // be caught by this function.
- int __llvm_sjljeh_get_longjmp_value() throw();
-
- // __llvm_sjljeh_try_catching_longjmp_exception - This function checks to see
- // if the current uncaught longjmp exception matches any of the setjmps
- // collected in the setjmpmap structure. If so, it catches and destroys the
- // exception, returning the index of the setjmp which caught the exception.
- // If not, it leaves the exception uncaught and returns a value of ~0.
- unsigned __llvm_sjljeh_try_catching_longjmp_exception(void **SetJmpMap)
- throw();
-}
-
-#endif