Changeset d56ca354 for src/libcfa
- Timestamp:
- Feb 12, 2018, 11:57:55 AM (6 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:
- fd062a66
- Parents:
- c40e7c5 (diff), cfe2f0a (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:
-
- 1 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/Makefile.am
rc40e7c5 rd56ca354 10 10 ## Author : Peter A. Buhr 11 11 ## Created On : Sun May 31 08:54:01 2015 12 ## Last Modified By : Andrew Beach13 ## Last Modified On : Wed Jul 26 14:15:00 201714 ## Update Count : 22 112 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Fri Feb 9 15:51:24 2018 14 ## Update Count : 223 15 15 ############################################################################### 16 16 … … 92 92 libcfa_d_a_CFLAGS = -debug -O0 #No need for __CFA_DEBUG__ since we pass -debug 93 93 94 stdhdr = ${shell echo stdhdr/*}94 stdhdr = ${shell find stdhdr -type f -printf "%p "} 95 95 96 96 cfa_includedir = $(CFA_INCDIR) -
src/libcfa/bits/debug.c
rc40e7c5 rd56ca354 11 11 // Last Modified By : 12 12 // Last Modified On : 13 // Update Count : 013 // Update Count : 1 14 14 // 15 15 … … 47 47 void __cfaabi_dbg_bits_release() __attribute__((__weak__)) {} 48 48 49 void __cfaabi_dbg_bits_print_safe ( const char fmt[], ... ) __attribute__(( format 49 void __cfaabi_dbg_bits_print_safe ( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) )) { 50 50 va_list args; 51 51 … … 60 60 } 61 61 62 void __cfaabi_dbg_bits_print_nolock( const char fmt[], ... ) __attribute__(( format 62 void __cfaabi_dbg_bits_print_nolock( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) )) { 63 63 va_list args; 64 64 … … 76 76 } 77 77 78 void __cfaabi_dbg_bits_print_buffer( char in_buffer[], int in_buffer_size, const char fmt[], ... ) __attribute__(( format 78 void __cfaabi_dbg_bits_print_buffer( char in_buffer[], int in_buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 3, 4) )) { 79 79 va_list args; 80 80 -
src/libcfa/bits/debug.h
rc40e7c5 rd56ca354 10 10 // Created On : Mon Nov 28 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 22 10:02:24 201713 // Update Count : 112 // Last Modified On : Thu Feb 8 12:35:19 2018 13 // Update Count : 2 14 14 // 15 15 … … 41 41 extern void __cfaabi_dbg_bits_acquire(); 42 42 extern void __cfaabi_dbg_bits_release(); 43 extern void __cfaabi_dbg_bits_print_safe ( const char fmt[], ... ) __attribute__(( format 44 extern void __cfaabi_dbg_bits_print_nolock( const char fmt[], ... ) __attribute__(( format 43 extern void __cfaabi_dbg_bits_print_safe ( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) )); 44 extern void __cfaabi_dbg_bits_print_nolock( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) )); 45 45 extern void __cfaabi_dbg_bits_print_vararg( const char fmt[], va_list arg ); 46 extern void __cfaabi_dbg_bits_print_buffer( char buffer[], int buffer_size, const char fmt[], ... ) __attribute__(( format 46 extern void __cfaabi_dbg_bits_print_buffer( char buffer[], int buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 3, 4) )); 47 47 #ifdef __cforall 48 48 } -
src/libcfa/bits/defs.h
rc40e7c5 rd56ca354 10 10 // Created On : Thu Nov 9 13:24:10 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jan 2 09:17:06201813 // Update Count : 212 // Last Modified On : Thu Feb 8 16:22:41 2018 13 // Update Count : 8 14 14 // 15 15 … … 34 34 35 35 #ifdef __cforall 36 #ifndef __NO_ABORT_OVERLOAD 37 void abort ( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)); 38 #endif 36 void abort ( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )); 39 37 extern "C" { 40 38 #endif 41 void abortf( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__));39 void __cabi_abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )); 42 40 #ifdef __cforall 43 41 } -
src/libcfa/concurrency/coroutine.c
rc40e7c5 rd56ca354 10 10 // Created On : Mon Nov 28 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 21 22:34:57 201713 // Update Count : 112 // Last Modified On : Thu Feb 8 16:10:31 2018 13 // Update Count : 4 14 14 // 15 15 … … 77 77 __cfaabi_dbg_debug_do( 78 78 if ( mprotect( this.storage, pageSize, PROT_READ | PROT_WRITE ) == -1 ) { 79 abort f( "(coStack_t *)%p.^?{}() : internal error, mprotect failure, error(%d) %s.", &this, errno, strerror( errno ) );79 abort( "(coStack_t *)%p.^?{}() : internal error, mprotect failure, error(%d) %s.", &this, errno, strerror( errno ) ); 80 80 } 81 81 ); … … 99 99 // Wrapper for co 100 100 void CoroutineCtxSwitch(coroutine_desc* src, coroutine_desc* dst) { 101 // THREAD_GETMEM( This )->disableInterrupts();101 disable_interrupts(); 102 102 103 103 // set state of current coroutine to inactive … … 115 115 src->state = Active; 116 116 117 // THREAD_GETMEM( This )->enableInterrupts();117 enable_interrupts( __cfaabi_dbg_ctx ); 118 118 } //ctxSwitchDirect 119 119 … … 135 135 __cfaabi_dbg_debug_do( 136 136 if ( mprotect( storage, pageSize, PROT_NONE ) == -1 ) { 137 abort f( "(uMachContext &)%p.createContext() : internal error, mprotect failure, error(%d) %s.", this, (int)errno, strerror( (int)errno ) );137 abort( "(uMachContext &)%p.createContext() : internal error, mprotect failure, error(%d) %s.", this, (int)errno, strerror( (int)errno ) ); 138 138 } // if 139 139 ); 140 140 141 141 if ( (intptr_t)storage == 0 ) { 142 abort f( "Attempt to allocate %d bytes of storage for coroutine or task execution-state but insufficient memory available.", size );142 abort( "Attempt to allocate %zd bytes of storage for coroutine or task execution-state but insufficient memory available.", size ); 143 143 } // if 144 144 -
src/libcfa/concurrency/invoke.c
rc40e7c5 rd56ca354 10 10 // Created On : Tue Jan 17 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 6 23:00:57201813 // Update Count : 312 // Last Modified On : Fri Feb 9 16:37:42 2018 13 // Update Count : 5 14 14 // 15 15 … … 51 51 //Final suspend, should never return 52 52 __leave_coroutine(); 53 abortf( "Resumed dead coroutine" );53 __cabi_abort( "Resumed dead coroutine" ); 54 54 } 55 55 … … 81 81 //Final suspend, should never return 82 82 __leave_thread_monitor( thrd ); 83 abortf( "Resumed dead thread" );83 __cabi_abort( "Resumed dead thread" ); 84 84 } 85 85 … … 93 93 struct coStack_t* stack = &get_coroutine( this )->stack; 94 94 95 #if defined( __i386 __)95 #if defined( __i386 ) 96 96 97 97 struct FakeStack { … … 114 114 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fcw = 0x037F; //Vol. 1 8-7 115 115 116 #elif defined( __x86_64 __)116 #elif defined( __x86_64 ) 117 117 118 118 struct FakeStack { … … 150 150 fs->arg[0] = this; 151 151 fs->arg[1] = invoke; 152 152 153 #else 153 #error Only __i386__ and __x86_64__ is supported for threads in cfa154 #error uknown hardware architecture 154 155 #endif 155 156 } -
src/libcfa/concurrency/invoke.h
rc40e7c5 rd56ca354 10 10 // Created On : Tue Jan 17 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jan 23 14:55:46201813 // Update Count : 312 // Last Modified On : Fri Feb 9 14:41:55 2018 13 // Update Count : 6 14 14 // 15 15 … … 202 202 void CtxSwitch( void * from, void * to ) asm ("CtxSwitch"); 203 203 204 #if defined( __x86_64__ ) 204 #if defined( __i386 ) 205 #define CtxGet( ctx ) __asm__ ( \ 206 "movl %%esp,%0\n" \ 207 "movl %%ebp,%1\n" \ 208 : "=rm" (ctx.SP), "=rm" (ctx.FP) ) 209 #elif defined( __x86_64 ) 205 210 #define CtxGet( ctx ) __asm__ ( \ 206 211 "movq %%rsp,%0\n" \ 207 212 "movq %%rbp,%1\n" \ 208 : "=rm" (ctx.SP), "=rm" (ctx.FP) )209 #elif defined( __i386__ )210 #define CtxGet( ctx ) __asm__ ( \211 "movl %%esp,%0\n" \212 "movl %%ebp,%1\n" \213 213 : "=rm" (ctx.SP), "=rm" (ctx.FP) ) 214 214 #elif defined( __ARM_ARCH ) … … 217 217 "mov %1,%%r11\n" \ 218 218 : "=rm" (ctx.SP), "=rm" (ctx.FP) ) 219 #else 220 #error unknown hardware architecture 219 221 #endif 220 222 -
src/libcfa/concurrency/kernel.c
rc40e7c5 rd56ca354 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Feb 6 21:51:26201813 // Update Count : 412 // Last Modified On : Thu Feb 8 23:52:19 2018 13 // Update Count : 5 14 14 // 15 15 16 16 //C Includes 17 17 #include <stddef.h> 18 #define ftype `ftype`19 18 extern "C" { 20 19 #include <stdio.h> … … 24 23 #include <unistd.h> 25 24 } 26 #undef ftype27 25 28 26 //CFA Includes -
src/libcfa/concurrency/monitor.c
rc40e7c5 rd56ca354 10 10 // Created On : Thd Feb 23 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jul 31 14:59:05 201713 // Update Count : 312 // Last Modified On : Thu Feb 8 16:12:20 2018 13 // Update Count : 4 14 14 // 15 15 … … 87 87 thread_desc * thrd = this_thread; 88 88 89 __cfaabi_dbg_print_safe( "Kernel : %10p Entering mon %p (%p)\n", thrd, this, this->owner);89 __cfaabi_dbg_print_safe( "Kernel : %10p Entering mon %p (%p)\n", thrd, this, this->owner); 90 90 91 91 if( !this->owner ) { … … 93 93 set_owner( this, thrd ); 94 94 95 __cfaabi_dbg_print_safe( "Kernel : mon is free \n");95 __cfaabi_dbg_print_safe( "Kernel : mon is free \n" ); 96 96 } 97 97 else if( this->owner == thrd) { … … 99 99 this->recursion += 1; 100 100 101 __cfaabi_dbg_print_safe( "Kernel : mon already owned \n");101 __cfaabi_dbg_print_safe( "Kernel : mon already owned \n" ); 102 102 } 103 103 else if( is_accepted( this, group) ) { … … 108 108 reset_mask( this ); 109 109 110 __cfaabi_dbg_print_safe( "Kernel : mon accepts \n");110 __cfaabi_dbg_print_safe( "Kernel : mon accepts \n" ); 111 111 } 112 112 else { 113 __cfaabi_dbg_print_safe( "Kernel : blocking \n");113 __cfaabi_dbg_print_safe( "Kernel : blocking \n" ); 114 114 115 115 // Some one else has the monitor, wait in line for it … … 118 118 BlockInternal( &this->lock ); 119 119 120 __cfaabi_dbg_print_safe( "Kernel : %10p Entered mon %p\n", thrd, this);120 __cfaabi_dbg_print_safe( "Kernel : %10p Entered mon %p\n", thrd, this); 121 121 122 122 // BlockInternal will unlock spinlock, no need to unlock ourselves … … 124 124 } 125 125 126 __cfaabi_dbg_print_safe( "Kernel : %10p Entered mon %p\n", thrd, this);126 __cfaabi_dbg_print_safe( "Kernel : %10p Entered mon %p\n", thrd, this); 127 127 128 128 // Release the lock and leave … … 136 136 thread_desc * thrd = this_thread; 137 137 138 __cfaabi_dbg_print_safe( "Kernel : %10p Entering dtor for mon %p (%p)\n", thrd, this, this->owner);138 __cfaabi_dbg_print_safe( "Kernel : %10p Entering dtor for mon %p (%p)\n", thrd, this, this->owner); 139 139 140 140 141 141 if( !this->owner ) { 142 __cfaabi_dbg_print_safe( "Kernel : Destroying free mon %p\n", this);142 __cfaabi_dbg_print_safe( "Kernel : Destroying free mon %p\n", this); 143 143 144 144 // No one has the monitor, just take it … … 151 151 // We already have the monitor... but where about to destroy it so the nesting will fail 152 152 // Abort! 153 abort f("Attempt to destroy monitor %p by thread \"%.256s\" (%p) in nested mutex.");153 abort( "Attempt to destroy monitor %p by thread \"%.256s\" (%p) in nested mutex." ); 154 154 } 155 155 … … 158 158 __monitor_group_t group = { &this, 1, func }; 159 159 if( is_accepted( this, group) ) { 160 __cfaabi_dbg_print_safe( "Kernel : mon accepts dtor, block and signal it \n");160 __cfaabi_dbg_print_safe( "Kernel : mon accepts dtor, block and signal it \n" ); 161 161 162 162 // Wake the thread that is waiting for this … … 177 177 } 178 178 else { 179 __cfaabi_dbg_print_safe( "Kernel : blocking \n");179 __cfaabi_dbg_print_safe( "Kernel : blocking \n" ); 180 180 181 181 wait_ctx( this_thread, 0 ) … … 190 190 } 191 191 192 __cfaabi_dbg_print_safe( "Kernel : Destroying %p\n", this);192 __cfaabi_dbg_print_safe( "Kernel : Destroying %p\n", this); 193 193 194 194 } … … 199 199 lock( this->lock __cfaabi_dbg_ctx2 ); 200 200 201 __cfaabi_dbg_print_safe( "Kernel : %10p Leaving mon %p (%p)\n", this_thread, this, this->owner);201 __cfaabi_dbg_print_safe( "Kernel : %10p Leaving mon %p (%p)\n", this_thread, this, this->owner); 202 202 203 203 verifyf( this_thread == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", this_thread, this->owner, this->recursion, this ); … … 209 209 // it means we don't need to do anything 210 210 if( this->recursion != 0) { 211 __cfaabi_dbg_print_safe( "Kernel : recursion still %d\n", this->recursion);211 __cfaabi_dbg_print_safe( "Kernel : recursion still %d\n", this->recursion); 212 212 unlock( this->lock ); 213 213 return; … … 228 228 __cfaabi_dbg_debug_do( 229 229 if( this_thread != this->owner ) { 230 abort f("Destroyed monitor %p has inconsistent owner, expected %p got %p.\n", this, this_thread, this->owner);230 abort( "Destroyed monitor %p has inconsistent owner, expected %p got %p.\n", this, this_thread, this->owner); 231 231 } 232 232 if( this->recursion != 1 ) { 233 abort f("Destroyed monitor %p has %d outstanding nested calls.\n", this, this->recursion - 1);233 abort( "Destroyed monitor %p has %d outstanding nested calls.\n", this, this->recursion - 1); 234 234 } 235 235 ) … … 256 256 // If we haven't left the last level of recursion 257 257 // it must mean there is an error 258 if( this->recursion != 0) { abort f("Thread internal monitor has unbalanced recursion"); }258 if( this->recursion != 0) { abort( "Thread internal monitor has unbalanced recursion" ); } 259 259 260 260 // Fetch the next thread, can be null … … 302 302 (this_thread->monitors){m, count, func}; 303 303 304 // __cfaabi_dbg_print_safe( "MGUARD : enter %d\n", count);304 // __cfaabi_dbg_print_safe( "MGUARD : enter %d\n", count); 305 305 306 306 // Enter the monitors in order … … 308 308 enter( group ); 309 309 310 // __cfaabi_dbg_print_safe( "MGUARD : entered\n");310 // __cfaabi_dbg_print_safe( "MGUARD : entered\n" ); 311 311 } 312 312 … … 314 314 // Dtor for monitor guard 315 315 void ^?{}( monitor_guard_t & this ) { 316 // __cfaabi_dbg_print_safe( "MGUARD : leaving %d\n", this.count);316 // __cfaabi_dbg_print_safe( "MGUARD : leaving %d\n", this.count); 317 317 318 318 // Leave the monitors in order 319 319 leave( this.m, this.count ); 320 320 321 // __cfaabi_dbg_print_safe( "MGUARD : left\n");321 // __cfaabi_dbg_print_safe( "MGUARD : left\n" ); 322 322 323 323 // Restore thread context … … 427 427 thread_desc * this_thrd = this_thread; 428 428 if ( this.monitor_count != this_thrd->monitors.size ) { 429 abort f( "Signal on condition %p made with different number of monitor(s), expected %i got %i", &this, this.monitor_count, this_thrd->monitors.size );429 abort( "Signal on condition %p made with different number of monitor(s), expected %i got %i", &this, this.monitor_count, this_thrd->monitors.size ); 430 430 } 431 431 432 432 for(int i = 0; i < this.monitor_count; i++) { 433 433 if ( this.monitors[i] != this_thrd->monitors[i] ) { 434 abort f( "Signal on condition %p made with different monitor, expected %p got %i", &this, this.monitors[i], this_thrd->monitors[i] );434 abort( "Signal on condition %p made with different monitor, expected %p got %i", &this, this.monitors[i], this_thrd->monitors[i] ); 435 435 } 436 436 } … … 534 534 if(actual_count == 0) return; 535 535 536 __cfaabi_dbg_print_buffer_local( "Kernel : waitfor internal proceeding\n" );536 __cfaabi_dbg_print_buffer_local( "Kernel : waitfor internal proceeding\n" ); 537 537 538 538 // Create storage for monitor context … … 551 551 __acceptable_t& accepted = mask[index]; 552 552 if( accepted.is_dtor ) { 553 __cfaabi_dbg_print_buffer_local( "Kernel : dtor already there\n" );553 __cfaabi_dbg_print_buffer_local( "Kernel : dtor already there\n" ); 554 554 verifyf( accepted.size == 1, "ERROR: Accepted dtor has more than 1 mutex parameter." ); 555 555 … … 563 563 } 564 564 else { 565 __cfaabi_dbg_print_buffer_local( "Kernel : thread present, baton-passing\n" );565 __cfaabi_dbg_print_buffer_local( "Kernel : thread present, baton-passing\n" ); 566 566 567 567 // Create the node specific to this wait operation … … 577 577 } 578 578 #endif 579 __cfaabi_dbg_print_buffer_local( "\n" );579 __cfaabi_dbg_print_buffer_local( "\n" ); 580 580 581 581 // Set the owners to be the next thread … … 588 588 monitor_restore; 589 589 590 __cfaabi_dbg_print_buffer_local( "Kernel : thread present, returned\n" );590 __cfaabi_dbg_print_buffer_local( "Kernel : thread present, returned\n" ); 591 591 } 592 592 … … 598 598 599 599 if( duration == 0 ) { 600 __cfaabi_dbg_print_buffer_local( "Kernel : non-blocking, exiting\n" );600 __cfaabi_dbg_print_buffer_local( "Kernel : non-blocking, exiting\n" ); 601 601 602 602 unlock_all( locks, count ); … … 607 607 608 608 609 verifyf( duration < 0, "Timeout on waitfor statments not supported yet." );610 611 __cfaabi_dbg_print_buffer_local( "Kernel : blocking waitfor\n" );609 verifyf( duration < 0, "Timeout on waitfor statments not supported yet." ); 610 611 __cfaabi_dbg_print_buffer_local( "Kernel : blocking waitfor\n" ); 612 612 613 613 // Create the node specific to this wait operation … … 631 631 monitor_restore; 632 632 633 __cfaabi_dbg_print_buffer_local( "Kernel : exiting\n" );633 __cfaabi_dbg_print_buffer_local( "Kernel : exiting\n" ); 634 634 635 635 __cfaabi_dbg_print_buffer_local( "Kernel : accepted %d\n", *mask.accepted); … … 640 640 641 641 static inline void set_owner( monitor_desc * this, thread_desc * owner ) { 642 // __cfaabi_dbg_print_safe( "Kernal : Setting owner of %p to %p ( was %p)\n", this, owner, this->owner );642 // __cfaabi_dbg_print_safe( "Kernal : Setting owner of %p to %p ( was %p)\n", this, owner, this->owner ); 643 643 644 644 //Pass the monitor appropriately … … 672 672 static inline thread_desc * next_thread( monitor_desc * this ) { 673 673 //Check the signaller stack 674 __cfaabi_dbg_print_safe( "Kernel : mon %p AS-stack top %p\n", this, this->signal_stack.top);674 __cfaabi_dbg_print_safe( "Kernel : mon %p AS-stack top %p\n", this, this->signal_stack.top); 675 675 __condition_criterion_t * urgent = pop( this->signal_stack ); 676 676 if( urgent ) { … … 814 814 thread_desc * thrd = this_thread; 815 815 if( !this.monitors ) { 816 // __cfaabi_dbg_print_safe( "Branding\n");816 // __cfaabi_dbg_print_safe( "Branding\n" ); 817 817 assertf( thrd->monitors.data != NULL, "No current monitor to brand condition %p", thrd->monitors.data ); 818 818 this.monitor_count = thrd->monitors.size; -
src/libcfa/concurrency/preemption.c
rc40e7c5 rd56ca354 10 10 // Created On : Mon Jun 5 14:20:42 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 6 15:00:36201813 // Update Count : 1 012 // Last Modified On : Fri Feb 9 16:38:13 2018 13 // Update Count : 14 14 14 // 15 15 16 16 #include "preemption.h" 17 17 18 #define ftype `ftype`19 18 extern "C" { 20 19 #include <errno.h> … … 23 22 #include <unistd.h> 24 23 } 25 #undef ftype26 24 27 25 #include "bits/signal.h" … … 50 48 51 49 // Machine specific register name 52 #if defined(__x86_64__) 50 #if defined( __i386 ) 51 #define CFA_REG_IP gregs[REG_EIP] 52 #elif defined( __x86_64 ) 53 53 #define CFA_REG_IP gregs[REG_RIP] 54 #elif defined(__i386__) 55 #define CFA_REG_IP gregs[REG_EIP] 56 #elif defined(__ARM_ARCH__) 54 #elif defined( __ARM_ARCH ) 57 55 #define CFA_REG_IP arm_pc 56 #else 57 #error unknown hardware architecture 58 58 #endif 59 59 … … 197 197 198 198 if ( pthread_sigmask( SIG_UNBLOCK, &mask, NULL ) == -1 ) { 199 abort f( "internal error, pthread_sigmask" );199 abort( "internal error, pthread_sigmask" ); 200 200 } 201 201 } … … 208 208 209 209 if ( pthread_sigmask( SIG_BLOCK, &mask, NULL ) == -1 ) { 210 abort f( "internal error, pthread_sigmask" );210 abort( "internal error, pthread_sigmask" ); 211 211 } 212 212 } … … 247 247 // Called from kernel_startup 248 248 void kernel_start_preemption() { 249 __cfaabi_dbg_print_safe( "Kernel : Starting preemption\n");249 __cfaabi_dbg_print_safe( "Kernel : Starting preemption\n" ); 250 250 251 251 // Start with preemption disabled until ready … … 268 268 // Called from kernel_shutdown 269 269 void kernel_stop_preemption() { 270 __cfaabi_dbg_print_safe( "Kernel : Preemption stopping\n");270 __cfaabi_dbg_print_safe( "Kernel : Preemption stopping\n" ); 271 271 272 272 // Block all signals since we are already shutting down … … 284 284 // Preemption is now fully stopped 285 285 286 __cfaabi_dbg_print_safe( "Kernel : Preemption stopped\n");286 __cfaabi_dbg_print_safe( "Kernel : Preemption stopped\n" ); 287 287 } 288 288 … … 322 322 case PREEMPT_TERMINATE: verify(this_processor->do_terminate); 323 323 default: 324 abort f( "internal error, signal value is %d", sfp->si_value.sival_int );324 abort( "internal error, signal value is %d", sfp->si_value.sival_int ); 325 325 } 326 326 … … 328 328 if( !preemption_ready() ) { return; } 329 329 330 __cfaabi_dbg_print_buffer_decl( " KERNEL: preempting core %p (%p).\n", this_processor, this_thread);330 __cfaabi_dbg_print_buffer_decl( " KERNEL: preempting core %p (%p).\n", this_processor, this_thread); 331 331 332 332 preemption_in_progress = true; // Sync flag : prevent recursive calls to the signal handler … … 348 348 349 349 if ( pthread_sigmask( SIG_BLOCK, &mask, NULL ) == -1 ) { 350 abort f( "internal error, pthread_sigmask" );350 abort( "internal error, pthread_sigmask" ); 351 351 } 352 352 … … 365 365 continue; 366 366 case EINVAL : 367 abort f("Timeout was invalid.");367 abort( "Timeout was invalid." ); 368 368 default: 369 abort f("Unhandled error %d", err);369 abort( "Unhandled error %d", err); 370 370 } 371 371 } … … 374 374 assertf(sig == SIGALRM, "Kernel Internal Error, sigwait: Unexpected signal %d (%d : %d)\n", sig, info.si_code, info.si_value.sival_int); 375 375 376 // __cfaabi_dbg_print_safe( "Kernel : Caught alarm from %d with %d\n", info.si_code, info.si_value.sival_int );376 // __cfaabi_dbg_print_safe( "Kernel : Caught alarm from %d with %d\n", info.si_code, info.si_value.sival_int ); 377 377 // Switch on the code (a.k.a. the sender) to 378 378 switch( info.si_code ) … … 382 382 case SI_TIMER: 383 383 case SI_KERNEL: 384 // __cfaabi_dbg_print_safe( "Kernel : Preemption thread tick\n");384 // __cfaabi_dbg_print_safe( "Kernel : Preemption thread tick\n" ); 385 385 lock( event_kernel->lock __cfaabi_dbg_ctx2 ); 386 386 tick_preemption(); … … 396 396 397 397 EXIT: 398 __cfaabi_dbg_print_safe( "Kernel : Preemption thread stopping\n");398 __cfaabi_dbg_print_safe( "Kernel : Preemption thread stopping\n" ); 399 399 return NULL; 400 400 } -
src/libcfa/exception.c
rc40e7c5 rd56ca354 9 9 // Author : Andrew Beach 10 10 // Created On : Mon Jun 26 15:13:00 2017 11 // Last Modified By : Andrew Beach12 // Last Modified On : Thr Aug 17 15:45:00 201713 // Update Count : 711 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 9 14:41:55 2018 13 // Update Count : 8 14 14 // 15 15 … … 453 453 // match, which is no way generic. Some more works need to be done if we want to have a single call to the try routine. 454 454 455 #if defined( __ x86_64__ ) || defined( __i386__)455 #if defined( __i386 ) || defined( __x86_64 ) 456 456 asm ( 457 457 //HEADER … … 476 476 // " .section .note.GNU-stack,\"x\",@progbits\n" 477 477 ); 478 #endif // __ x86_64__ || __i386__478 #endif // __i386 || __x86_64 -
src/libcfa/interpose.c
rc40e7c5 rd56ca354 10 10 // Created On : Wed Mar 29 16:10:31 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 7 09:05:18201813 // Update Count : 5912 // Last Modified On : Thu Feb 8 16:18:09 2018 13 // Update Count : 75 14 14 // 15 15 … … 28 28 } 29 29 30 #define __NO_ABORT_OVERLOAD // no abort overload avoid ambiguities31 30 #include "bits/debug.h" 32 31 #include "bits/defs.h" … … 51 50 error = dlerror(); 52 51 if ( error ) { 53 abort f( "interpose_symbol : failed to open libc, %s\n", error );52 abort( "interpose_symbol : failed to open libc, %s\n", error ); 54 53 } 55 54 #endif … … 69 68 70 69 error = dlerror(); 71 if ( error ) abort f( "interpose_symbol : internal error, %s\n", error );70 if ( error ) abort( "interpose_symbol : internal error, %s\n", error ); 72 71 73 72 return originalFunc.fptr; … … 98 97 99 98 struct { 100 __typeof__( exit ) exit __attribute__(( noreturn));101 __typeof__( abort ) abort __attribute__(( noreturn));99 void (* exit)( int ) __attribute__ (( __noreturn__ )); 100 void (* abort)( void ) __attribute__ (( __noreturn__ )); 102 101 } __cabi_libc; 103 102 … … 123 122 124 123 // Forward declare abort after the __typeof__ call to avoid ambiguities 125 void abort ( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)); 124 void exit( int status, const char fmt[], ... ) __attribute__ (( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ )); 125 void abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )); 126 126 127 127 extern "C" { 128 void abort( void ) __attribute__ (( __nothrow__, __leaf__, __noreturn__)) {129 abort f( NULL );130 } 131 132 void abortf( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) {128 void abort( void ) __attribute__ (( __nothrow__, __leaf__, __noreturn__ )) { 129 abort( NULL ); 130 } 131 132 void __cabi_abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )) { 133 133 va_list argp; 134 134 va_start( argp, fmt ); … … 137 137 } 138 138 139 void exit( int __status ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) {140 __cabi_libc.exit( __status);141 } 142 } 143 144 void * kernel_abort ( void ) __attribute__ (( __nothrow__, __leaf__, __weak__)) { return NULL; }145 void kernel_abort_msg( void * data, char * buffer, int size ) __attribute__ (( __nothrow__, __leaf__, __weak__)) {}146 int kernel_abort_lastframe( void ) __attribute__ (( __nothrow__, __leaf__, __weak__)) { return 4; }139 void exit( int status ) __attribute__ (( __nothrow__, __leaf__, __noreturn__ )) { 140 __cabi_libc.exit( status ); 141 } 142 } 143 144 void * kernel_abort ( void ) __attribute__ (( __nothrow__, __leaf__, __weak__ )) { return NULL; } 145 void kernel_abort_msg( void * data, char * buffer, int size ) __attribute__ (( __nothrow__, __leaf__, __weak__ )) {} 146 int kernel_abort_lastframe( void ) __attribute__ (( __nothrow__, __leaf__, __weak__ )) { return 4; } 147 147 148 148 enum { abort_text_size = 1024 }; … … 150 150 static int abort_lastframe; 151 151 152 void abort( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) { 152 void exit( int status, const char fmt[], ... ) __attribute__ (( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ )) { 153 va_list args; 154 va_start( args, fmt ); 155 vfprintf( stderr, fmt, args ); 156 va_end( args ); 157 __cabi_libc.exit( status ); 158 } 159 160 void abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )) { 153 161 void * kernel_data = kernel_abort(); // must be done here to lock down kernel 154 162 int len; … … 226 234 227 235 void sigHandler_segv( __CFA_SIGPARMS__ ) { 228 abort f( "Addressing invalid memory at location %p\n"236 abort( "Addressing invalid memory at location %p\n" 229 237 "Possible cause is reading outside the address space or writing to a protected area within the address space with an invalid pointer or subscript.\n", 230 238 sfp->si_addr ); … … 232 240 233 241 void sigHandler_ill( __CFA_SIGPARMS__ ) { 234 abort f( "Executing illegal instruction at location %p.\n"242 abort( "Executing illegal instruction at location %p.\n" 235 243 "Possible cause is stack corruption.\n", 236 244 sfp->si_addr ); … … 248 256 default: msg = "unknown"; 249 257 } // choose 250 abort f( "Computation error %s at location %p.\n", msg, sfp->si_addr );258 abort( "Computation error %s at location %p.\n", msg, sfp->si_addr ); 251 259 } 252 260
Note: See TracChangeset
for help on using the changeset viewer.