Changeset 77acd07d
- Timestamp:
- Feb 7, 2018, 4:50:57 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 3f8ab8f, c659968
- Parents:
- 396fd72 (diff), 3d5f2ef1 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src/libcfa
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/bits/defs.h
r396fd72 r77acd07d 1 // 1 // 2 2 // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo 3 3 // 4 4 // The contents of this file are covered under the licence agreement in the 5 5 // file "LICENCE" distributed with Cforall. 6 // 7 // defs.h -- 8 // 6 // 7 // defs.h -- 8 // 9 9 // Author : Thierry Delisle 10 10 // Created On : Thu Nov 9 13:24:10 2017 … … 12 12 // Last Modified On : Tue Jan 2 09:17:06 2018 13 13 // Update Count : 2 14 // 14 // 15 15 16 16 #pragma once … … 34 34 35 35 #ifdef __cforall 36 #ifndef __NO_ABORT_OVERLOAD 37 void abort ( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)); 38 #endif 36 39 extern "C" { 37 40 #endif -
src/libcfa/interpose.c
r396fd72 r77acd07d 28 28 } 29 29 30 #define __NO_ABORT_OVERLOAD // no abort overload avoid ambiguities 30 31 #include "bits/debug.h" 31 32 #include "bits/defs.h" 32 33 #include "bits/signal.h" 33 34 #include "startup.h" 35 36 //============================================================================================= 37 // Interposing helpers 38 //============================================================================================= 34 39 35 40 typedef void (*generic_fptr_t)(void); … … 69 74 } 70 75 71 72 __typeof__( exit ) libc_exit __attribute__(( noreturn ));73 __typeof__( abort ) libc_abort __attribute__(( noreturn ));74 75 76 forall(dtype T) 76 static inline void assign_ptr( T** symbol_ptr, const char * symbol_name, const char * version) {77 static inline void ptr_from_symbol( T** symbol_ptr, const char * symbol_name, const char * version) { 77 78 union { 78 79 generic_fptr_t gp; … … 85 86 } 86 87 87 #define INIT_REALRTN( x, ver ) assign_ptr( (void**)&libc_##x, #x, ver) 88 #define INTERPOSE_LIBC( x, ver ) ptr_from_symbol( (void**)&__cabi_libc.x, #x, ver) 89 90 //============================================================================================= 91 // Terminating Signals logic 92 //============================================================================================= 88 93 89 94 void sigHandler_segv ( __CFA_SIGPARMS__ ); … … 92 97 void sigHandler_abort( __CFA_SIGPARMS__ ); 93 98 99 struct { 100 __typeof__( exit ) exit __attribute__(( noreturn )); 101 __typeof__( abort ) abort __attribute__(( noreturn )); 102 } __cabi_libc; 103 94 104 extern "C" { 95 105 void __cfaabi_interpose_startup(void) __attribute__(( constructor( STARTUP_PRIORITY_CORE ) )); … … 97 107 const char *version = NULL; 98 108 99 IN IT_REALRTN( abort, version );100 IN IT_REALRTN( exit, version );109 INTERPOSE_LIBC( abort, version ); 110 INTERPOSE_LIBC( exit , version ); 101 111 102 112 __cfaabi_sigaction( SIGSEGV, sigHandler_segv , SA_SIGINFO ); // Failure handler … … 112 122 //============================================================================================= 113 123 124 // Forward declare abort after the __typeof__ call to avoid ambiguities 125 void abort ( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)); 126 114 127 extern "C" { 115 128 void abort( void ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) { … … 117 130 } 118 131 132 void abortf( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) { 133 va_list argp; 134 va_start( argp, fmt ); 135 abort( fmt, argp ); 136 va_end( argp ); 137 } 138 119 139 void exit( int __status ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) { 120 libc_exit(__status); 121 } 122 } 123 124 void abort( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) { 125 va_list argp; 126 va_start( argp, fmt ); 127 abortf( fmt, argp ); 128 va_end( argp ); 140 __cabi_libc.exit(__status); 141 } 129 142 } 130 143 … … 137 150 static int abort_lastframe; 138 151 139 extern "C" { 140 void abortf( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) { 141 void * kernel_data = kernel_abort(); // must be done here to lock down kernel 142 int len; 143 144 abort_lastframe = kernel_abort_lastframe(); 145 len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid) 152 void abort( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) { 153 void * kernel_data = kernel_abort(); // must be done here to lock down kernel 154 int len; 155 156 abort_lastframe = kernel_abort_lastframe(); 157 len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid) 158 __cfaabi_dbg_bits_write( abort_text, len ); 159 160 if ( fmt ) { 161 va_list args; 162 va_start( args, fmt ); 163 164 len = vsnprintf( abort_text, abort_text_size, fmt, args ); 165 va_end( args ); 146 166 __cfaabi_dbg_bits_write( abort_text, len ); 147 167 148 if ( fmt ) { 149 va_list args; 150 va_start( args, fmt ); 151 152 len = vsnprintf( abort_text, abort_text_size, fmt, args ); 153 va_end( args ); 154 __cfaabi_dbg_bits_write( abort_text, len ); 155 156 if ( fmt[strlen( fmt ) - 1] != '\n' ) { // add optional newline if missing at the end of the format text 157 __cfaabi_dbg_bits_write( "\n", 1 ); 158 } 159 } 160 161 kernel_abort_msg( kernel_data, abort_text, abort_text_size ); 162 libc_abort(); 163 } 168 if ( fmt[strlen( fmt ) - 1] != '\n' ) { // add optional newline if missing at the end of the format text 169 __cfaabi_dbg_bits_write( "\n", 1 ); 170 } 171 } 172 173 kernel_abort_msg( kernel_data, abort_text, abort_text_size ); 174 __cabi_libc.abort(); 164 175 } 165 176
Note: See TracChangeset
for help on using the changeset viewer.