- Timestamp:
- Mar 18, 2020, 3:41:01 PM (6 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:
- 778452d, d658183
- Parents:
- c4fd4ef (diff), 45f4147 (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:
- libcfa
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/prelude/builtins.c
rc4fd4ef rbbdb0c6 48 48 void exit( int status, const char fmt[], ... ) __attribute__ (( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ )); 49 49 void abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )); 50 51 forall(dtype T) 52 static inline T & identity(T & i) { 53 return i; 54 } 55 56 // generator support 57 struct $generator { 58 inline int; 59 }; 60 61 static inline void ?{}($generator & this) { ((int&)this) = 0; } 62 static inline void ^?{}($generator &) {} 63 64 trait is_generator(dtype T) { 65 void main(T & this); 66 $generator * get_generator(T & this); 67 }; 68 69 forall(dtype T | is_generator(T)) 70 static inline T & resume(T & gen) { 71 main(gen); 72 return gen; 73 } 50 74 51 75 // implicit increment, decrement if += defined, and implicit not if != defined -
libcfa/src/Makefile.am
rc4fd4ef rbbdb0c6 11 11 ## Created On : Sun May 31 08:54:01 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Mon Jul 15 22:43:27 201914 ## Update Count : 24 113 ## Last Modified On : Mon Mar 16 18:07:59 2020 14 ## Update Count : 242 15 15 ############################################################################### 16 16 … … 39 39 #---------------------------------------------------------------------------------------------------------------- 40 40 if BUILDLIB 41 headers_nosrc = math.hfa gmp.hfa time_t.hfa bits/align.hfa bits/containers.hfa bits/defs.hfa bits/debug.hfa bits/locks.hfa41 headers_nosrc = bitmanip.hfa math.hfa gmp.hfa time_t.hfa bits/align.hfa bits/containers.hfa bits/defs.hfa bits/debug.hfa bits/locks.hfa 42 42 headers = fstream.hfa iostream.hfa iterator.hfa limits.hfa rational.hfa time.hfa stdlib.hfa common.hfa \ 43 43 containers/maybe.hfa containers/pair.hfa containers/result.hfa containers/vector.hfa -
libcfa/src/Makefile.in
rc4fd4ef rbbdb0c6 237 237 limits.hfa rational.hfa time.hfa stdlib.hfa common.hfa \ 238 238 containers/maybe.hfa containers/pair.hfa containers/result.hfa \ 239 containers/vector.hfa math.hfa gmp.hfa time_t.hfa \239 containers/vector.hfa bitmanip.hfa math.hfa gmp.hfa time_t.hfa \ 240 240 bits/align.hfa bits/containers.hfa bits/defs.hfa \ 241 241 bits/debug.hfa bits/locks.hfa concurrency/coroutine.hfa \ … … 432 432 am__v_GOC_0 = @echo " GOC " $@; 433 433 am__v_GOC_1 = 434 AM_V_PY = $(am__v_PY_@AM_V@) 435 am__v_PY_ = $(am__v_PY_@AM_DEFAULT_V@) 436 am__v_PY_0 = @echo " PYTHON " $@; 437 am__v_PY_1 = 434 438 AM_V_RUST = $(am__v_RUST_@AM_V@) 435 439 am__v_RUST_ = $(am__v_RUST_@AM_DEFAULT_V@) 436 am__v_RUST_0 = @echo " RUST 440 am__v_RUST_0 = @echo " RUST " $@; 437 441 am__v_RUST_1 = 438 442 AM_V_NODEJS = $(am__v_NODEJS_@AM_V@) 439 443 am__v_NODEJS_ = $(am__v_NODEJS_@AM_DEFAULT_V@) 440 am__v_NODEJS_0 = @echo " NODEJS 444 am__v_NODEJS_0 = @echo " NODEJS " $@; 441 445 am__v_NODEJS_1 = 442 446 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@) … … 457 461 458 462 #---------------------------------------------------------------------------------------------------------------- 459 @BUILDLIB_TRUE@headers_nosrc = math.hfa gmp.hfa time_t.hfa bits/align.hfa bits/containers.hfa bits/defs.hfa bits/debug.hfa bits/locks.hfa463 @BUILDLIB_TRUE@headers_nosrc = bitmanip.hfa math.hfa gmp.hfa time_t.hfa bits/align.hfa bits/containers.hfa bits/defs.hfa bits/debug.hfa bits/locks.hfa 460 464 @BUILDLIB_FALSE@headers = 461 465 @BUILDLIB_TRUE@headers = fstream.hfa iostream.hfa iterator.hfa limits.hfa rational.hfa time.hfa stdlib.hfa common.hfa \ -
libcfa/src/concurrency/coroutine.cfa
rc4fd4ef rbbdb0c6 208 208 209 209 if(cor->state == Primed) { 210 suspend();210 __cfactx_suspend(); 211 211 } 212 212 -
libcfa/src/concurrency/coroutine.hfa
rc4fd4ef rbbdb0c6 46 46 //----------------------------------------------------------------------------- 47 47 // Public coroutine API 48 static inline void suspend(void);49 50 forall(dtype T | is_coroutine(T))51 static inline T & resume(T & cor);52 53 48 forall(dtype T | is_coroutine(T)) 54 49 void prime(T & cor); … … 96 91 97 92 // Suspend implementation inlined for performance 98 static inline void suspend(void) { 99 // optimization : read TLS once and reuse it 100 // Safety note: this is preemption safe since if 101 // preemption occurs after this line, the pointer 102 // will also migrate which means this value will 103 // stay in syn with the TLS 104 $coroutine * src = TL_GET( this_thread )->curr_cor; 93 extern "C" { 94 static inline void __cfactx_suspend(void) { 95 // optimization : read TLS once and reuse it 96 // Safety note: this is preemption safe since if 97 // preemption occurs after this line, the pointer 98 // will also migrate which means this value will 99 // stay in syn with the TLS 100 $coroutine * src = TL_GET( this_thread )->curr_cor; 105 101 106 assertf( src->last != 0,107 "Attempt to suspend coroutine \"%.256s\" (%p) that has never been resumed.\n"108 "Possible cause is a suspend executed in a member called by a coroutine user rather than by the coroutine main.",109 src->name, src );110 assertf( src->last->state != Halted,111 "Attempt by coroutine \"%.256s\" (%p) to suspend back to terminated coroutine \"%.256s\" (%p).\n"112 "Possible cause is terminated coroutine's main routine has already returned.",113 src->name, src, src->last->name, src->last );102 assertf( src->last != 0, 103 "Attempt to suspend coroutine \"%.256s\" (%p) that has never been resumed.\n" 104 "Possible cause is a suspend executed in a member called by a coroutine user rather than by the coroutine main.", 105 src->name, src ); 106 assertf( src->last->state != Halted, 107 "Attempt by coroutine \"%.256s\" (%p) to suspend back to terminated coroutine \"%.256s\" (%p).\n" 108 "Possible cause is terminated coroutine's main routine has already returned.", 109 src->name, src, src->last->name, src->last ); 114 110 115 $ctx_switch( src, src->last ); 111 $ctx_switch( src, src->last ); 112 } 116 113 } 117 114 -
libcfa/src/exception.c
rc4fd4ef rbbdb0c6 252 252 } 253 253 254 #pragma GCC push_options255 #pragma GCC optimize("O0")256 257 254 // This is our personality routine. For every stack frame annotated with 258 255 // ".cfi_personality 0x3,__gcfa_personality_v0" this function will be called twice when unwinding. … … 413 410 return _URC_CONTINUE_UNWIND; 414 411 } 412 413 #pragma GCC push_options 414 #pragma GCC optimize("O0") 415 415 416 416 // Try statements are hoisted out see comments for details. While this could probably be unique -
libcfa/src/interpose.cfa
rc4fd4ef rbbdb0c6 10 10 // Created On : Wed Mar 29 16:10:31 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 2 17:37:00202013 // Update Count : 17 612 // Last Modified On : Fri Mar 13 17:35:37 2020 13 // Update Count : 178 14 14 // 15 15 … … 234 234 235 235 if ( fmt[strlen( fmt ) - 1] != '\n' ) { // add optional newline if missing at the end of the format text 236 __cfaabi_ dbg_write("\n", 1 );236 __cfaabi_bits_write( STDERR_FILENO, "\n", 1 ); 237 237 } // if 238 238 kernel_abort_msg( kernel_data, abort_text, abort_text_size ); -
libcfa/src/iostream.cfa
rc4fd4ef rbbdb0c6 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 5 15:56:16202013 // Update Count : 8 3412 // Last Modified On : Wed Mar 11 14:35:35 2020 13 // Update Count : 860 14 14 // 15 15 … … 534 534 #define IntegralFMTImpl128( T, SIGNED, CODE, IFMTNP, IFMTP ) \ 535 535 forall( dtype ostype | ostream( ostype ) ) \ 536 static void base10_128( ostype & os, _Ostream_Manip(T) fmt ) { \ 537 if ( fmt.val > UINT64_MAX ) { \ 538 base10_128( os, fmt.val / P10_UINT64 ); /* recursive */ \ 539 _Ostream_Manip(unsigned long long int) fmt2 @= { (uint64_t)(fmt.val % P10_UINT64), 0, 19, 'u', { .all : 0 } }; \ 540 fmt2.flags.nobsdp = true; \ 541 printf( "fmt2 %c %lld %d\n", fmt2.base, fmt2.val, fmt2.all ); \ 536 static void base10_128( ostype & os, _Ostream_Manip(T) f ) { \ 537 if ( f.val > UINT64_MAX ) { \ 538 unsigned long long int lsig = f.val % P10_UINT64; \ 539 f.val /= P10_UINT64; /* msig */ \ 540 base10_128( os, f ); /* recursion */ \ 541 _Ostream_Manip(unsigned long long int) fmt @= { lsig, 0, 19, 'u', { .all : 0 } }; \ 542 fmt.flags.nobsdp = true; \ 543 /* printf( "fmt1 %c %lld %d\n", fmt.base, fmt.val, fmt.all ); */ \ 542 544 sepOff( os ); \ 543 (ostype &)(os | fmt 2); \545 (ostype &)(os | fmt); \ 544 546 } else { \ 545 printf( "fmt %c %lld %d\n", fmt.base, (unsigned long long int)fmt.val, fmt.all );\546 _Ostream_Manip(SIGNED long long int) x @= { (unsigned long long int)fmt.val, fmt.wd, fmt.pc, fmt.base, { .all : fmt.all } }; \547 (ostype &)(os | x); \547 /* printf( "fmt2 %c %lld %d\n", f.base, (unsigned long long int)f.val, f.all ); */ \ 548 _Ostream_Manip(SIGNED long long int) fmt @= { (SIGNED long long int)f.val, f.wd, f.pc, f.base, { .all : f.all } }; \ 549 (ostype &)(os | fmt); \ 548 550 } /* if */ \ 549 } /* base10_128 */ 551 } /* base10_128 */ \ 550 552 forall( dtype ostype | ostream( ostype ) ) { \ 551 553 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ … … 564 566 if ( f.base == 'b' | f.base == 'B' ) { \ 565 567 if ( f.wd > 64 ) fmt.wd = f.wd - 64; \ 568 if ( f.flags.pc && f.pc > 64 ) fmt.pc = f.pc - 64; \ 566 569 fmt2.wd = 64; \ 567 570 (ostype &)(os | fmt | "" | fmt2); \ … … 569 572 fmt.val = (unsigned long long int)fmt.val >> 2; \ 570 573 if ( f.wd > 21 ) fmt.wd = f.wd - 21; \ 574 if ( f.flags.pc && f.pc > 21 ) fmt.pc = f.pc - 21; \ 571 575 fmt2.wd = 1; \ 572 576 fmt2.val = ((msig & 0x3) << 1) + 1; \ … … 578 582 } else { \ 579 583 if ( f.flags.left ) { \ 580 if ( f.wd > 16 ) fmt2.wd = f.wd - 16; 581 fmt.wd = 16; 584 if ( f.wd > 16 ) fmt2.wd = f.wd - 16; \ 585 fmt.wd = 16; \ 582 586 } else { \ 583 if ( f.wd > 16 ) fmt.wd = f.wd - 16; \ 584 fmt2.wd = 16; \ 587 if ( f.wd > 16 ) fmt.wd = f.wd - 16; \ 588 if ( f.flags.pc && f.pc > 16 ) fmt.pc = f.pc - 16; \ 589 fmt2.wd = 16; \ 585 590 } /* if */ \ 586 591 (ostype &)(os | fmt | "" | fmt2); \ … … 588 593 } /* if */ \ 589 594 } else { \ 595 if ( CODE == 'd' ) { \ 596 if ( f.val < 0 ) { fmt( os, "-" ); sepOff( os ); f.val = -f.val; f.flags.sign = false; } \ 597 } /* if */ \ 590 598 base10_128( os, f ); \ 591 599 } /* if */ \
Note:
See TracChangeset
for help on using the changeset viewer.