Changeset bbdb0c6 for libcfa


Ignore:
Timestamp:
Mar 18, 2020, 3:41:01 PM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
libcfa
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • libcfa/prelude/builtins.c

    rc4fd4ef rbbdb0c6  
    4848void exit( int status, const char fmt[], ... ) __attribute__ (( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ ));
    4949void abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
     50
     51forall(dtype T)
     52static inline T & identity(T & i) {
     53        return i;
     54}
     55
     56// generator support
     57struct $generator {
     58        inline int;
     59};
     60
     61static inline void  ?{}($generator & this) { ((int&)this) = 0; }
     62static inline void ^?{}($generator &) {}
     63
     64trait is_generator(dtype T) {
     65      void main(T & this);
     66      $generator * get_generator(T & this);
     67};
     68
     69forall(dtype T | is_generator(T))
     70static inline T & resume(T & gen) {
     71        main(gen);
     72        return gen;
     73}
    5074
    5175// implicit increment, decrement if += defined, and implicit not if != defined
  • libcfa/src/Makefile.am

    rc4fd4ef rbbdb0c6  
    1111## Created On       : Sun May 31 08:54:01 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Mon Jul 15 22:43:27 2019
    14 ## Update Count     : 241
     13## Last Modified On : Mon Mar 16 18:07:59 2020
     14## Update Count     : 242
    1515###############################################################################
    1616
     
    3939#----------------------------------------------------------------------------------------------------------------
    4040if 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.hfa
     41headers_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
    4242headers = fstream.hfa iostream.hfa iterator.hfa limits.hfa rational.hfa time.hfa stdlib.hfa common.hfa \
    4343          containers/maybe.hfa containers/pair.hfa containers/result.hfa containers/vector.hfa
  • libcfa/src/Makefile.in

    rc4fd4ef rbbdb0c6  
    237237        limits.hfa rational.hfa time.hfa stdlib.hfa common.hfa \
    238238        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 \
    240240        bits/align.hfa bits/containers.hfa bits/defs.hfa \
    241241        bits/debug.hfa bits/locks.hfa concurrency/coroutine.hfa \
     
    432432am__v_GOC_0 = @echo "  GOC     " $@;
    433433am__v_GOC_1 =
     434AM_V_PY = $(am__v_PY_@AM_V@)
     435am__v_PY_ = $(am__v_PY_@AM_DEFAULT_V@)
     436am__v_PY_0 = @echo "  PYTHON  " $@;
     437am__v_PY_1 =
    434438AM_V_RUST = $(am__v_RUST_@AM_V@)
    435439am__v_RUST_ = $(am__v_RUST_@AM_DEFAULT_V@)
    436 am__v_RUST_0 = @echo "  RUST     " $@;
     440am__v_RUST_0 = @echo "  RUST    " $@;
    437441am__v_RUST_1 =
    438442AM_V_NODEJS = $(am__v_NODEJS_@AM_V@)
    439443am__v_NODEJS_ = $(am__v_NODEJS_@AM_DEFAULT_V@)
    440 am__v_NODEJS_0 = @echo "  NODEJS     " $@;
     444am__v_NODEJS_0 = @echo "  NODEJS  " $@;
    441445am__v_NODEJS_1 =
    442446AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
     
    457461
    458462#----------------------------------------------------------------------------------------------------------------
    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.hfa
     463@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
    460464@BUILDLIB_FALSE@headers =
    461465@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  
    208208
    209209                if(cor->state == Primed) {
    210                         suspend();
     210                        __cfactx_suspend();
    211211                }
    212212
  • libcfa/src/concurrency/coroutine.hfa

    rc4fd4ef rbbdb0c6  
    4646//-----------------------------------------------------------------------------
    4747// 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 
    5348forall(dtype T | is_coroutine(T))
    5449void prime(T & cor);
     
    9691
    9792// 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;
     93extern "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;
    105101
    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 );
    114110
    115         $ctx_switch( src, src->last );
     111                $ctx_switch( src, src->last );
     112        }
    116113}
    117114
  • libcfa/src/exception.c

    rc4fd4ef rbbdb0c6  
    252252}
    253253
    254 #pragma GCC push_options
    255 #pragma GCC optimize("O0")
    256 
    257254// This is our personality routine. For every stack frame annotated with
    258255// ".cfi_personality 0x3,__gcfa_personality_v0" this function will be called twice when unwinding.
     
    413410        return _URC_CONTINUE_UNWIND;
    414411}
     412
     413#pragma GCC push_options
     414#pragma GCC optimize("O0")
    415415
    416416// Try statements are hoisted out see comments for details. While this could probably be unique
  • libcfa/src/interpose.cfa

    rc4fd4ef rbbdb0c6  
    1010// Created On       : Wed Mar 29 16:10:31 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Mar  2 17:37:00 2020
    13 // Update Count     : 176
     12// Last Modified On : Fri Mar 13 17:35:37 2020
     13// Update Count     : 178
    1414//
    1515
     
    234234
    235235        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 );
    237237        } // if
    238238        kernel_abort_msg( kernel_data, abort_text, abort_text_size );
  • libcfa/src/iostream.cfa

    rc4fd4ef rbbdb0c6  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar  5 15:56:16 2020
    13 // Update Count     : 834
     12// Last Modified On : Wed Mar 11 14:35:35 2020
     13// Update Count     : 860
    1414//
    1515
     
    534534#define IntegralFMTImpl128( T, SIGNED, CODE, IFMTNP, IFMTP ) \
    535535forall( 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 );   \
     536static 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 ); */ \
    542544                sepOff( os ); \
    543                 (ostype &)(os | fmt2); \
     545                (ostype &)(os | fmt); \
    544546        } 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); \
    548550        } /* if */ \
    549 } /* base10_128 */                                                \
     551} /* base10_128 */ \
    550552forall( dtype ostype | ostream( ostype ) ) { \
    551553        ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \
     
    564566                                if ( f.base == 'b' | f.base == 'B' ) { \
    565567                                        if ( f.wd > 64 ) fmt.wd = f.wd - 64; \
     568                                        if ( f.flags.pc && f.pc > 64 ) fmt.pc = f.pc - 64; \
    566569                                        fmt2.wd = 64; \
    567570                                        (ostype &)(os | fmt | "" | fmt2); \
     
    569572                                        fmt.val = (unsigned long long int)fmt.val >> 2; \
    570573                                        if ( f.wd > 21 ) fmt.wd = f.wd - 21; \
     574                                        if ( f.flags.pc && f.pc > 21 ) fmt.pc = f.pc - 21; \
    571575                                        fmt2.wd = 1; \
    572576                                        fmt2.val = ((msig & 0x3) << 1) + 1; \
     
    578582                                } else { \
    579583                                        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; \
    582586                                        } 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; \
    585590                                        } /* if */ \
    586591                                        (ostype &)(os | fmt | "" | fmt2); \
     
    588593                        } /* if */ \
    589594                } else { \
     595                        if ( CODE == 'd' ) { \
     596                                if ( f.val < 0 )  { fmt( os, "-" ); sepOff( os ); f.val = -f.val; f.flags.sign = false; } \
     597                        } /* if */ \
    590598                        base10_128( os, f ); \
    591599                } /* if */ \
Note: See TracChangeset for help on using the changeset viewer.