00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include <cstdlib>
00032 #include "unwind-cxx.h"
00033
00034 using namespace __cxxabiv1;
00035
00036
00037 extern "C" void *
00038 __cxa_begin_catch (_Unwind_Exception *exceptionObject)
00039 {
00040
00041
00042
00043 __cxa_exception *header = __get_exception_header_from_ue (exceptionObject);
00044 __cxa_eh_globals *globals = __cxa_get_globals ();
00045 __cxa_exception *prev = globals->caughtExceptions;
00046 int count = header->handlerCount;
00047
00048 if (count < 0)
00049
00050 count = -count + 1;
00051 else
00052 count += 1;
00053 header->handlerCount = count;
00054
00055 globals->uncaughtExceptions -= 1;
00056 if (header != prev)
00057 {
00058 header->nextException = prev;
00059 globals->caughtExceptions = header;
00060 }
00061
00062 return header->adjustedPtr;
00063 }
00064
00065
00066 extern "C" void
00067 __cxa_end_catch ()
00068 {
00069 __cxa_eh_globals *globals = __cxa_get_globals_fast ();
00070 __cxa_exception *header = globals->caughtExceptions;
00071 int count = header->handlerCount;
00072
00073 if (count < 0)
00074 {
00075
00076
00077 if (++count == 0)
00078 {
00079 globals->uncaughtExceptions += 1;
00080 globals->caughtExceptions = header->nextException;
00081 }
00082 }
00083 else if (--count == 0)
00084 {
00085
00086 globals->caughtExceptions = header->nextException;
00087 _Unwind_DeleteException (&header->unwindHeader);
00088 return;
00089 }
00090 else if (count < 0)
00091
00092 abort ();
00093
00094 header->handlerCount = count;
00095 }
00096
00097
00098 bool
00099 std::uncaught_exception() throw()
00100 {
00101 __cxa_eh_globals *globals = __cxa_get_globals ();
00102 return globals->uncaughtExceptions != 0;
00103 }