Changeset 9640813
- Timestamp:
- Mar 20, 2020, 4:40:54 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 7a0f1d25
- Parents:
- 8ef95679
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/exception.c
r8ef95679 r9640813 14 14 // 15 15 16 // Normally we would get this from the CFA prelude. 16 17 #include <stddef.h> // for size_t 17 18 18 19 #include "exception.h" 19 20 20 // Implementation of the secret header. 21 // Implementation of the secret header is hardware dependent. 22 #if !( defined( __x86_64 ) || defined( __i386 ) ) 23 #error Exception Handling: No known architecture detected. 24 #endif 21 25 22 26 #include <stdlib.h> … … 68 72 //} 69 73 70 71 // This macro should be the only thing that needs to change across machines.72 // Used in the personality function, way down in termination.73 // struct _Unwind_Context * -> _Unwind_Reason_Code(*)(exception_t *)74 #if defined( __x86_64 )75 #define MATCHER_FROM_CONTEXT(ptr_to_context) \76 (*(_Unwind_Reason_Code(**)(exception_t *))(_Unwind_GetCFA(ptr_to_context) + 8))77 #elif defined( __i386 )78 #define MATCHER_FROM_CONTEXT(ptr_to_context) \79 (*(_Unwind_Reason_Code(**)(exception_t *))(_Unwind_GetCFA(ptr_to_context) + 24))80 #endif81 74 82 75 // RESUMPTION ================================================================ … … 354 347 cur_ptr = read_uleb128(cur_ptr, &imatcher); 355 348 356 _Unwind_Reason_Code (*matcher)(exception_t *) = 357 MATCHER_FROM_CONTEXT(context); 349 # if defined( __x86_64 ) 350 _Unwind_Word match_pos = _Unwind_GetCFA(context) + 8; 351 # elif defined( __i386 ) 352 _Unwind_Word match_pos = _Unwind_GetCFA(context) + 24; 353 # endif 354 int (*matcher)(exception_t *) = *(int(**)(exception_t *))match_pos; 355 358 356 int index = matcher(shared_stack.current_exception); 359 357 _Unwind_Reason_Code ret = (0 == index) … … 468 466 469 467 #ifdef __PIC__ 470 #if defined( __i386 ) || defined( __x86_64 )471 468 asm ( 472 469 // HEADER … … 514 511 #endif 515 512 ); 516 #else517 #error Exception Handling: unknown architecture for position independent code.518 #endif // __i386 || __x86_64519 513 #else // __PIC__ 520 #if defined( __i386 ) || defined( __x86_64 )521 514 asm ( 522 515 // HEADER … … 547 540 " .section .note.GNU-stack,\"x\",@progbits\n" 548 541 ); 549 #else550 #error Exception Handling: unknown architecture for position dependent code.551 #endif // __i386 || __x86_64552 542 #endif // __PIC__ 553 543
Note: See TracChangeset
for help on using the changeset viewer.