(__objc_add_handler, __objc_remove_handler,
authorKresten Krab Thorup <krab@gcc.gnu.org>
Wed, 5 May 1993 13:52:15 +0000 (13:52 +0000)
committerKresten Krab Thorup <krab@gcc.gnu.org>
Wed, 5 May 1993 13:52:15 +0000 (13:52 +0000)
__objc_raise_error): New functions.
(__ex_last_handler): New variable

From-SVN: r4333

gcc/objc/misc.c

index 6b6b3429822586cfc408b0ccced9cd34bb3e1ddc..ec42c2cfe1942edd5f7d03bd597c8643ae6e0071 100644 (file)
@@ -25,6 +25,7 @@ You should have received a copy of the GNU General Public License along with
    covered by the GNU General Public License.  */
 
 #include "runtime.h"
+#include "error.h"
 
 void objc_error(id object, const char* fmt, va_list);
 
@@ -70,3 +71,46 @@ __objc_xcalloc(size_t nelem, size_t size)
     objc_fatal("Virtual memory exhausted\n");
   return res;
 }
+
+struct objc_ex_handler __ex_base_handler = {0, 0, 0, 0, 0 };
+struct objc_ex_handler* __ex_last_handler = &__ex_base_handler;
+
+objc_uncaught_exception_handler _objc_uncaught_exception_handler = 0;
+
+void
+__objc_add_handler(struct objc_ex_handler* hdlr)
+{
+  hdlr->ex_prev = __ex_last_handler;
+  __ex_last_handler = hdlr;
+}
+
+void 
+__objc_remove_handler(struct objc_ex_handler* hdlr)
+{
+  __ex_last_handler = hdlr->ex_prev;
+}
+
+#ifndef __STRICT_ANSI__
+__volatile
+#endif
+extern void __objc_raise_error(int code, const void* data1, const void* data2)
+{
+  if (__ex_last_handler->ex_prev) 
+    {
+      __ex_last_handler->code = code;       
+      __ex_last_handler->data1 = data1;     
+      __ex_last_handler->data2 = data2;     
+      longjmp (__ex_last_handler->ex_env, 1);
+    } 
+  else
+    {
+      if (_objc_uncaught_exception_handler)
+       (*_objc_uncaught_exception_handler)(code, data1, data2);
+      else
+       {
+         printf ("uncaught exception: code=%d, data1=%x, data2=%x\n",
+                 code, data1, data2);
+         abort();
+       }
+    }
+}