Changeset 73530d9


Ignore:
Timestamp:
Apr 3, 2020, 1:46:32 PM (4 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
057298e, 23ecea4
Parents:
0f3d844
Message:

Set up the public fields in _Unwind_Exception. Helps with cross language compatability.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/exception.c

    r0f3d844 r73530d9  
    1010// Created On       : Mon Jun 26 15:13:00 2017
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Thr Apr 02 14:47:00 2020
    13 // Update Count     : 13
     12// Last Modified On : Fri Apr 03 11:57:00 2020
     13// Update Count     : 14
    1414//
    1515
     
    3131// FIX ME: temporary hack to keep ARM build working
    3232#ifndef _URC_FATAL_PHASE1_ERROR
    33 #define _URC_FATAL_PHASE1_ERROR 2
     33#define _URC_FATAL_PHASE1_ERROR 3
    3434#endif // ! _URC_FATAL_PHASE1_ERROR
    3535#ifndef _URC_FATAL_PHASE2_ERROR
     
    3939#include "lsda.h"
    4040
     41/* The exception class for our exceptions. Because of the vendor component
     42 * its value would not be standard.
     43 * Vendor: UWPL
     44 * Language: CFA\0
     45 */
     46const _Unwind_Exception_Class __cfaehm_exception_class = 0x4c50575500414643;
    4147
    4248// Base exception vtable is abstract, you should not have base exceptions.
     
    116122// May have to move to cfa for constructors and destructors (references).
    117123
     124// How to clean up an exception in various situations.
     125static void __cfaehm_exception_cleanup(
     126                _Unwind_Reason_Code reason,
     127                struct _Unwind_Exception * exception) {
     128        switch (reason) {
     129        case _URC_FOREIGN_EXCEPTION_CAUGHT:
     130                // This one we could clean-up to allow cross-language exceptions.
     131        case _URC_FATAL_PHASE1_ERROR:
     132        case _URC_FATAL_PHASE2_ERROR:
     133        default:
     134                abort();
     135        }
     136}
     137
     138// We need a piece of storage to raise the exception, for now its a single
     139// piece.
     140static struct _Unwind_Exception this_exception_storage;
     141
    118142struct __cfaehm_node {
    119143        struct __cfaehm_node * next;
     
    142166        // Copy the exception to storage.
    143167        except->virtual_table->copy( context->current_exception, except );
     168
     169        // Set up the exception storage.
     170        this_exception_storage.exception_class = __cfaehm_exception_class;
     171        this_exception_storage.exception_cleanup = __cfaehm_exception_cleanup;
    144172}
    145173
     
    175203        if ( *(void**)except ) __cfaehm_delete_exception( *(exception_t **)except );
    176204}
    177 
    178 
    179 // We need a piece of storage to raise the exception
    180 struct _Unwind_Exception this_exception_storage;
    181205
    182206// Function needed by force unwind
     
    201225                abort();
    202226        }
    203 
    204227
    205228        // Call stdlibc to raise the exception
Note: See TracChangeset for help on using the changeset viewer.