Changeset a505021 for libcfa/src


Ignore:
Timestamp:
Feb 21, 2020, 3:36:36 PM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
c7a900a
Parents:
8c50aed (diff), c744563a (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' into park_unpark

Location:
libcfa/src
Files:
29 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/assert.cfa

    r8c50aed ra505021  
    1010// Created On       : Mon Nov 28 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Nov 21 17:09:26 2019
    13 // Update Count     : 5
     12// Last Modified On : Tue Feb  4 13:00:18 2020
     13// Update Count     : 6
    1414//
    1515
     
    2626
    2727        // called by macro assert in assert.h
    28         void __assert_fail( const char *assertion, const char *file, unsigned int line, const char *function ) {
     28        void __assert_fail( const char assertion[], const char file[], unsigned int line, const char function[] ) {
    2929                __cfaabi_bits_print_safe( STDERR_FILENO, CFA_ASSERT_FMT ".\n", assertion, __progname, function, line, file );
    3030                abort();
     
    3232
    3333        // called by macro assertf
    34         void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) {
     34        void __assert_fail_f( const char assertion[], const char file[], unsigned int line, const char function[], const char fmt[], ... ) {
    3535                __cfaabi_bits_acquire();
    3636                __cfaabi_bits_print_nolock( STDERR_FILENO, CFA_ASSERT_FMT ": ", assertion, __progname, function, line, file );
  • libcfa/src/bits/debug.cfa

    r8c50aed ra505021  
    1010// Created On       : Thu Mar 30 12:30:01 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Nov 21 17:16:30 2019
    13 // Update Count     : 10
     12// Last Modified On : Tue Feb  4 13:03:16 2020
     13// Update Count     : 11
    1414//
    1515
     
    2727
    2828extern "C" {
    29 
    30         void __cfaabi_bits_write( int fd, const char *in_buffer, int len ) {
     29        void __cfaabi_bits_write( int fd, const char in_buffer[], int len ) {
    3130                // ensure all data is written
    3231                for ( int count = 0, retcode; count < len; count += retcode ) {
  • libcfa/src/bits/debug.hfa

    r8c50aed ra505021  
    1010// Created On       : Mon Nov 28 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Nov 21 17:06:58 2019
    13 // Update Count     : 8
     12// Last Modified On : Tue Feb  4 12:29:21 2020
     13// Update Count     : 9
    1414//
    1515
     
    2121        #define __cfaabi_dbg_ctx __PRETTY_FUNCTION__
    2222        #define __cfaabi_dbg_ctx2 , __PRETTY_FUNCTION__
    23         #define __cfaabi_dbg_ctx_param const char * caller
    24         #define __cfaabi_dbg_ctx_param2 , const char * caller
     23        #define __cfaabi_dbg_ctx_param const char caller[]
     24        #define __cfaabi_dbg_ctx_param2 , const char caller[]
    2525#else
    2626        #define __cfaabi_dbg_debug_do(...)
     
    3838        #include <stdio.h>
    3939
    40         extern void __cfaabi_bits_write( int fd, const char *buffer, int len );
     40        extern void __cfaabi_bits_write( int fd, const char buffer[], int len );
    4141        extern void __cfaabi_bits_acquire();
    4242        extern void __cfaabi_bits_release();
  • libcfa/src/bits/locks.hfa

    r8c50aed ra505021  
    1010// Created On       : Tue Oct 31 15:14:38 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Aug 11 15:42:24 2018
    13 // Update Count     : 10
     12// Last Modified On : Tue Feb  4 13:03:19 2020
     13// Update Count     : 11
    1414//
    1515
     
    5454
    5555                #ifdef __CFA_DEBUG__
    56                         void __cfaabi_dbg_record(__spinlock_t & this, const char * prev_name);
     56                        void __cfaabi_dbg_record(__spinlock_t & this, const char prev_name[]);
    5757                #else
    5858                        #define __cfaabi_dbg_record(x, y)
  • libcfa/src/concurrency/coroutine.cfa

    r8c50aed ra505021  
    1010// Created On       : Mon Nov 28 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Dec  5 14:37:29 2019
    13 // Update Count     : 15
     12// Last Modified On : Tue Feb  4 12:29:25 2020
     13// Update Count     : 16
    1414//
    1515
     
    8989}
    9090
    91 void ?{}( coroutine_desc & this, const char * name, void * storage, size_t storageSize ) with( this ) {
     91void ?{}( coroutine_desc & this, const char name[], void * storage, size_t storageSize ) with( this ) {
    9292        (this.context){0p, 0p};
    9393        (this.stack){storage, storageSize};
  • libcfa/src/concurrency/coroutine.hfa

    r8c50aed ra505021  
    1010// Created On       : Mon Nov 28 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec  3 22:47:58 2019
    13 // Update Count     : 10
     12// Last Modified On : Tue Feb  4 12:29:26 2020
     13// Update Count     : 11
    1414//
    1515
     
    3535// void ^?{}( coStack_t & this );
    3636
    37 void ?{}( coroutine_desc & this, const char * name, void * storage, size_t storageSize );
     37void ?{}( coroutine_desc & this, const char name[], void * storage, size_t storageSize );
    3838void ^?{}( coroutine_desc & this );
    3939
     
    4141static inline void ?{}( coroutine_desc & this, size_t stackSize)                     { this{ "Anonymous Coroutine", 0p, stackSize }; }
    4242static inline void ?{}( coroutine_desc & this, void * storage, size_t storageSize )  { this{ "Anonymous Coroutine", storage, storageSize }; }
    43 static inline void ?{}( coroutine_desc & this, const char * name)                    { this{ name, 0p, 0 }; }
    44 static inline void ?{}( coroutine_desc & this, const char * name, size_t stackSize ) { this{ name, 0p, stackSize }; }
     43static inline void ?{}( coroutine_desc & this, const char name[])                    { this{ name, 0p, 0 }; }
     44static inline void ?{}( coroutine_desc & this, const char name[], size_t stackSize ) { this{ name, 0p, stackSize }; }
    4545
    4646//-----------------------------------------------------------------------------
  • libcfa/src/concurrency/kernel.cfa

    r8c50aed ra505021  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jan 30 22:55:50 2020
    13 // Update Count     : 56
     12// Last Modified On : Tue Feb  4 13:03:15 2020
     13// Update Count     : 58
    1414//
    1515
     
    210210static void * CtxInvokeProcessor(void * arg);
    211211
    212 void ?{}(processor & this, const char * name, cluster & cltr) with( this ) {
     212void ?{}(processor & this, const char name[], cluster & cltr) with( this ) {
    213213        this.name = name;
    214214        this.cltr = &cltr;
     
    244244}
    245245
    246 void ?{}(cluster & this, const char * name, Duration preemption_rate) with( this ) {
     246void ?{}(cluster & this, const char name[], Duration preemption_rate) with( this ) {
    247247        this.name = name;
    248248        this.preemption_rate = preemption_rate;
     
    459459}
    460460
    461 static void Abort( int ret, const char * func ) {
     461static void Abort( int ret, const char func[] ) {
    462462        if ( ret ) {                                                                            // pthread routines return errno values
    463463                abort( "%s : internal error, error(%d) %s.", func, ret, strerror( ret ) );
     
    960960__cfaabi_dbg_debug_do(
    961961        extern "C" {
    962                 void __cfaabi_dbg_record(__spinlock_t & this, const char * prev_name) {
     962                void __cfaabi_dbg_record(__spinlock_t & this, const char prev_name[]) {
    963963                        this.prev_name = prev_name;
    964964                        this.prev_thrd = kernelTLS.this_thread;
  • libcfa/src/concurrency/kernel.hfa

    r8c50aed ra505021  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec  4 07:54:51 2019
    13 // Update Count     : 18
     12// Last Modified On : Tue Feb  4 12:29:26 2020
     13// Update Count     : 22
    1414//
    1515
     
    101101};
    102102
    103 void  ?{}(processor & this, const char * name, struct cluster & cltr);
     103void  ?{}(processor & this, const char name[], struct cluster & cltr);
    104104void ^?{}(processor & this);
    105105
    106106static inline void  ?{}(processor & this)                    { this{ "Anonymous Processor", *mainCluster}; }
    107107static inline void  ?{}(processor & this, struct cluster & cltr)    { this{ "Anonymous Processor", cltr}; }
    108 static inline void  ?{}(processor & this, const char * name) { this{name, *mainCluster }; }
     108static inline void  ?{}(processor & this, const char name[]) { this{name, *mainCluster }; }
    109109
    110110static inline [processor *&, processor *& ] __get( processor & this ) /*__attribute__((const))*/ { return this.node.[next, prev]; }
     
    144144extern Duration default_preemption();
    145145
    146 void ?{} (cluster & this, const char * name, Duration preemption_rate);
     146void ?{} (cluster & this, const char name[], Duration preemption_rate);
    147147void ^?{}(cluster & this);
    148148
    149149static inline void ?{} (cluster & this)                           { this{"Anonymous Cluster", default_preemption()}; }
    150150static inline void ?{} (cluster & this, Duration preemption_rate) { this{"Anonymous Cluster", preemption_rate}; }
    151 static inline void ?{} (cluster & this, const char * name)        { this{name, default_preemption()}; }
     151static inline void ?{} (cluster & this, const char name[])        { this{name, default_preemption()}; }
    152152
    153153static inline [cluster *&, cluster *& ] __get( cluster & this ) /*__attribute__((const))*/ { return this.node.[next, prev]; }
  • libcfa/src/exception.c

    r8c50aed ra505021  
    248248}
    249249
    250 #if defined(PIC)
    251 #warning Exceptions not yet supported when using Position-Independent Code
    252 __attribute__((noinline))
    253 void __cfaabi_ehm__try_terminate(void (*try_block)(),
    254                 void (*catch_block)(int index, exception_t * except),
    255                 __attribute__((unused)) int (*match_block)(exception_t * except)) {
    256         abort();
    257 }
    258 #else // PIC
     250#pragma GCC push_options
     251#pragma GCC optimize("O0")
     252
    259253// This is our personality routine. For every stack frame annotated with
    260254// ".cfi_personality 0x3,__gcfa_personality_v0" this function will be called twice when unwinding.
     
    431425
    432426        // Setup the personality routine and exception table.
     427#ifdef __PIC__
     428        asm volatile (".cfi_personality 0x9b,CFA.ref.__gcfa_personality_v0");
     429        asm volatile (".cfi_lsda 0x1b, .LLSDACFA2");
     430#else
    433431        asm volatile (".cfi_personality 0x3,__gcfa_personality_v0");
    434432        asm volatile (".cfi_lsda 0x3, .LLSDACFA2");
     433#endif
    435434
    436435        // Label which defines the start of the area for which the handler is setup.
     
    464463// have a single call to the try routine.
    465464
     465#ifdef __PIC__
     466#if defined( __i386 ) || defined( __x86_64 )
     467asm (
     468        // HEADER
     469        ".LFECFA1:\n"
     470        "       .globl  __gcfa_personality_v0\n"
     471        "       .section        .gcc_except_table,\"a\",@progbits\n"
     472        // TABLE HEADER (important field is the BODY length at the end)
     473        ".LLSDACFA2:\n"
     474        "       .byte   0xff\n"
     475        "       .byte   0xff\n"
     476        "       .byte   0x1\n"
     477        "       .uleb128 .LLSDACSECFA2-.LLSDACSBCFA2\n"
     478        // BODY (language specific data)
     479        // This uses language specific data and can be modified arbitrarily
     480        // We use handled area offset, handled area length,
     481        // handler landing pad offset and 1 (action code, gcc seems to use 0).
     482        ".LLSDACSBCFA2:\n"
     483        "       .uleb128 .TRYSTART-__cfaabi_ehm__try_terminate\n"
     484        "       .uleb128 .TRYEND-.TRYSTART\n"
     485        "       .uleb128 .CATCH-__cfaabi_ehm__try_terminate\n"
     486        "       .uleb128 1\n"
     487        ".LLSDACSECFA2:\n"
     488        // TABLE FOOTER
     489        "       .text\n"
     490        "       .size   __cfaabi_ehm__try_terminate, .-__cfaabi_ehm__try_terminate\n"
     491);
     492
     493// Somehow this piece of helps with the resolution of debug symbols.
     494__attribute__((unused)) static const int dummy = 0;
     495
     496asm (
     497        // Add a hidden symbol which points at the function.
     498        "       .hidden CFA.ref.__gcfa_personality_v0\n"
     499        "       .weak   CFA.ref.__gcfa_personality_v0\n"
     500        // No clue what this does specifically
     501        "       .section        .data.rel.local.CFA.ref.__gcfa_personality_v0,\"awG\",@progbits,CFA.ref.__gcfa_personality_v0,comdat\n"
     502        "       .align 8\n"
     503        "       .type CFA.ref.__gcfa_personality_v0, @object\n"
     504        "       .size CFA.ref.__gcfa_personality_v0, 8\n"
     505        "CFA.ref.__gcfa_personality_v0:\n"
     506#if defined( __x86_64 )
     507        "       .quad __gcfa_personality_v0\n"
     508#else // then __i386
     509        "   .long __gcfa_personality_v0\n"
     510#endif
     511);
     512#else
     513#error Exception Handling: unknown architecture for position independent code.
     514#endif // __i386 || __x86_64
     515#else // __PIC__
    466516#if defined( __i386 ) || defined( __x86_64 )
    467517asm (
     
    491541        "       .size   __cfaabi_ehm__try_terminate, .-__cfaabi_ehm__try_terminate\n"
    492542        "       .ident  \"GCC: (Ubuntu 6.2.0-3ubuntu11~16.04) 6.2.0 20160901\"\n"
    493 //      "       .section        .note.GNU-stack,\"x\",@progbits\n"
     543        "       .section        .note.GNU-stack,\"x\",@progbits\n"
    494544);
     545#else
     546#error Exception Handling: unknown architecture for position dependent code.
    495547#endif // __i386 || __x86_64
    496 #endif // PIC
     548#endif // __PIC__
     549
     550#pragma GCC pop_options
  • libcfa/src/fstream.cfa

    r8c50aed ra505021  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Nov 29 06:56:46 2019
    13 // Update Count     : 355
     12// Last Modified On : Fri Feb  7 19:01:01 2020
     13// Update Count     : 363
    1414//
    1515
     
    3232
    3333void ?{}( ofstream & os, void * file ) {
    34         os.file = file;
    35         os.sepDefault = true;
    36         os.sepOnOff = false;
    37         os.nlOnOff = true;
    38         os.prt = false;
    39         os.sawNL = false;
     34        os.$file = file;
     35        os.$sepDefault = true;
     36        os.$sepOnOff = false;
     37        os.$nlOnOff = true;
     38        os.$prt = false;
     39        os.$sawNL = false;
     40        $sepSetCur( os, sepGet( os ) );
    4041        sepSet( os, " " );
    41         sepSetCur( os, sepGet( os ) );
    4242        sepSetTuple( os, ", " );
    4343} // ?{}
    4444
    4545// private
    46 bool sepPrt( ofstream & os ) { setNL( os, false ); return os.sepOnOff; }
    47 void sepReset( ofstream & os ) { os.sepOnOff = os.sepDefault; }
    48 void sepReset( ofstream & os, bool reset ) { os.sepDefault = reset; os.sepOnOff = os.sepDefault; }
    49 const char * sepGetCur( ofstream & os ) { return os.sepCur; }
    50 void sepSetCur( ofstream & os, const char * sepCur ) { os.sepCur = sepCur; }
    51 bool getNL( ofstream & os ) { return os.sawNL; }
    52 void setNL( ofstream & os, bool state ) { os.sawNL = state; }
    53 bool getANL( ofstream & os ) { return os.nlOnOff; }
    54 bool getPrt( ofstream & os ) { return os.prt; }
    55 void setPrt( ofstream & os, bool state ) { os.prt = state; }
     46bool $sepPrt( ofstream & os ) { $setNL( os, false ); return os.$sepOnOff; }
     47void $sepReset( ofstream & os ) { os.$sepOnOff = os.$sepDefault; }
     48void $sepReset( ofstream & os, bool reset ) { os.$sepDefault = reset; os.$sepOnOff = os.$sepDefault; }
     49const char * $sepGetCur( ofstream & os ) { return os.$sepCur; }
     50void $sepSetCur( ofstream & os, const char sepCur[] ) { os.$sepCur = sepCur; }
     51bool $getNL( ofstream & os ) { return os.$sawNL; }
     52void $setNL( ofstream & os, bool state ) { os.$sawNL = state; }
     53bool $getANL( ofstream & os ) { return os.$nlOnOff; }
     54bool $getPrt( ofstream & os ) { return os.$prt; }
     55void $setPrt( ofstream & os, bool state ) { os.$prt = state; }
    5656
    5757// public
    58 void ?{}( ofstream & os ) { os.file = 0; }
    59 
    60 void ?{}( ofstream & os, const char * name, const char * mode ) {
     58void ?{}( ofstream & os ) { os.$file = 0p; }
     59
     60void ?{}( ofstream & os, const char name[], const char mode[] ) {
    6161        open( os, name, mode );
    6262} // ?{}
    6363
    64 void ?{}( ofstream & os, const char * name ) {
     64void ?{}( ofstream & os, const char name[] ) {
    6565        open( os, name, "w" );
    6666} // ?{}
     
    7070} // ^?{}
    7171
    72 void sepOn( ofstream & os ) { os.sepOnOff = ! getNL( os ); }
    73 void sepOff( ofstream & os ) { os.sepOnOff = false; }
     72void sepOn( ofstream & os ) { os.$sepOnOff = ! $getNL( os ); }
     73void sepOff( ofstream & os ) { os.$sepOnOff = false; }
    7474
    7575bool sepDisable( ofstream & os ) {
    76         bool temp = os.sepDefault;
    77         os.sepDefault = false;
    78         sepReset( os );
     76        bool temp = os.$sepDefault;
     77        os.$sepDefault = false;
     78        $sepReset( os );
    7979        return temp;
    8080} // sepDisable
    8181
    8282bool sepEnable( ofstream & os ) {
    83         bool temp = os.sepDefault;
    84         os.sepDefault = true;
    85         if ( os.sepOnOff ) sepReset( os );                                      // start of line ?
     83        bool temp = os.$sepDefault;
     84        os.$sepDefault = true;
     85        if ( os.$sepOnOff ) $sepReset( os );                            // start of line ?
    8686        return temp;
    8787} // sepEnable
    8888
    89 void nlOn( ofstream & os ) { os.nlOnOff = true; }
    90 void nlOff( ofstream & os ) { os.nlOnOff = false; }
    91 
    92 const char * sepGet( ofstream & os ) { return os.separator; }
    93 void sepSet( ofstream & os, const char * s ) {
     89void nlOn( ofstream & os ) { os.$nlOnOff = true; }
     90void nlOff( ofstream & os ) { os.$nlOnOff = false; }
     91
     92const char * sepGet( ofstream & os ) { return os.$separator; }
     93void sepSet( ofstream & os, const char s[] ) {
    9494        assert( s );
    95         strncpy( os.separator, s, sepSize - 1 );
    96         os.separator[sepSize - 1] = '\0';
     95        strncpy( os.$separator, s, sepSize - 1 );
     96        os.$separator[sepSize - 1] = '\0';
    9797} // sepSet
    9898
    99 const char * sepGetTuple( ofstream & os ) { return os.tupleSeparator; }
    100 void sepSetTuple( ofstream & os, const char * s ) {
     99const char * sepGetTuple( ofstream & os ) { return os.$tupleSeparator; }
     100void sepSetTuple( ofstream & os, const char s[] ) {
    101101        assert( s );
    102         strncpy( os.tupleSeparator, s, sepSize - 1 );
    103         os.tupleSeparator[sepSize - 1] = '\0';
     102        strncpy( os.$tupleSeparator, s, sepSize - 1 );
     103        os.$tupleSeparator[sepSize - 1] = '\0';
    104104} // sepSet
    105105
    106106void ends( ofstream & os ) {
    107         if ( getANL( os ) ) nl( os );
    108         else setPrt( os, false );                                                       // turn off
     107        if ( $getANL( os ) ) nl( os );
     108        else $setPrt( os, false );                                                      // turn off
    109109        if ( &os == &exit ) exit( EXIT_FAILURE );
    110110        if ( &os == &abort ) abort();
     
    112112
    113113int fail( ofstream & os ) {
    114         return os.file == 0 || ferror( (FILE *)(os.file) );
     114        return os.$file == 0 || ferror( (FILE *)(os.$file) );
    115115} // fail
    116116
    117117int flush( ofstream & os ) {
    118         return fflush( (FILE *)(os.file) );
     118        return fflush( (FILE *)(os.$file) );
    119119} // flush
    120120
    121 void open( ofstream & os, const char * name, const char * mode ) {
     121void open( ofstream & os, const char name[], const char mode[] ) {
    122122        FILE * file = fopen( name, mode );
    123123        #ifdef __CFA_DEBUG__
    124         if ( file == 0 ) {
     124        if ( file == 0p ) {
    125125                abort | IO_MSG "open output file \"" | name | "\"" | nl | strerror( errno );
    126126        } // if
     
    129129} // open
    130130
    131 void open( ofstream & os, const char * name ) {
     131void open( ofstream & os, const char name[] ) {
    132132        open( os, name, "w" );
    133133} // open
    134134
    135135void close( ofstream & os ) {
    136         if ( (FILE *)(os.file) == stdout || (FILE *)(os.file) == stderr ) return;
    137 
    138         if ( fclose( (FILE *)(os.file) ) == EOF ) {
     136        if ( (FILE *)(os.$file) == stdout || (FILE *)(os.$file) == stderr ) return;
     137
     138        if ( fclose( (FILE *)(os.$file) ) == EOF ) {
    139139                abort | IO_MSG "close output" | nl | strerror( errno );
    140140        } // if
    141141} // close
    142142
    143 ofstream & write( ofstream & os, const char * data, size_t size ) {
     143ofstream & write( ofstream & os, const char data[], size_t size ) {
    144144        if ( fail( os ) ) {
    145145                abort | IO_MSG "attempt write I/O on failed stream";
    146146        } // if
    147147
    148         if ( fwrite( data, 1, size, (FILE *)(os.file) ) != size ) {
     148        if ( fwrite( data, 1, size, (FILE *)(os.$file) ) != size ) {
    149149                abort | IO_MSG "write" | nl | strerror( errno );
    150150        } // if
     
    155155        va_list args;
    156156        va_start( args, format );
    157         int len = vfprintf( (FILE *)(os.file), format, args );
     157        int len = vfprintf( (FILE *)(os.$file), format, args );
    158158        if ( len == EOF ) {
    159                 if ( ferror( (FILE *)(os.file) ) ) {
     159                if ( ferror( (FILE *)(os.$file) ) ) {
    160160                        abort | IO_MSG "invalid write";
    161161                } // if
     
    163163        va_end( args );
    164164
    165         setPrt( os, true );                                                                     // called in output cascade
    166         sepReset( os );                                                                         // reset separator
     165        $setPrt( os, true );                                                            // called in output cascade
     166        $sepReset( os );                                                                        // reset separator
    167167        return len;
    168168} // fmt
     
    184184// private
    185185void ?{}( ifstream & is, void * file ) {
    186         is.file = file;
    187         is.nlOnOff = false;
     186        is.$file = file;
     187        is.$nlOnOff = false;
    188188} // ?{}
    189189
    190190// public
    191 void ?{}( ifstream & is ) {     is.file = 0; }
    192 
    193 void ?{}( ifstream & is, const char * name, const char * mode ) {
     191void ?{}( ifstream & is ) { is.$file = 0p; }
     192
     193void ?{}( ifstream & is, const char name[], const char mode[] ) {
    194194        open( is, name, mode );
    195195} // ?{}
    196196
    197 void ?{}( ifstream & is, const char * name ) {
     197void ?{}( ifstream & is, const char name[] ) {
    198198        open( is, name, "r" );
    199199} // ?{}
     
    203203} // ^?{}
    204204
    205 void nlOn( ifstream & os ) { os.nlOnOff = true; }
    206 void nlOff( ifstream & os ) { os.nlOnOff = false; }
    207 bool getANL( ifstream & os ) { return os.nlOnOff; }
     205void nlOn( ifstream & os ) { os.$nlOnOff = true; }
     206void nlOff( ifstream & os ) { os.$nlOnOff = false; }
     207bool getANL( ifstream & os ) { return os.$nlOnOff; }
    208208
    209209int fail( ifstream & is ) {
    210         return is.file == 0 || ferror( (FILE *)(is.file) );
     210        return is.$file == 0p || ferror( (FILE *)(is.$file) );
    211211} // fail
    212212
    213213int eof( ifstream & is ) {
    214         return feof( (FILE *)(is.file) );
     214        return feof( (FILE *)(is.$file) );
    215215} // eof
    216216
    217 void open( ifstream & is, const char * name, const char * mode ) {
     217void open( ifstream & is, const char name[], const char mode[] ) {
    218218        FILE * file = fopen( name, mode );
    219219        #ifdef __CFA_DEBUG__
    220         if ( file == 0 ) {
     220        if ( file == 0p ) {
    221221                abort | IO_MSG "open input file \"" | name | "\"" | nl | strerror( errno );
    222222        } // if
    223223        #endif // __CFA_DEBUG__
    224         is.file = file;
    225 } // open
    226 
    227 void open( ifstream & is, const char * name ) {
     224        is.$file = file;
     225} // open
     226
     227void open( ifstream & is, const char name[] ) {
    228228        open( is, name, "r" );
    229229} // open
    230230
    231231void close( ifstream & is ) {
    232         if ( (FILE *)(is.file) == stdin ) return;
    233 
    234         if ( fclose( (FILE *)(is.file) ) == EOF ) {
     232        if ( (FILE *)(is.$file) == stdin ) return;
     233
     234        if ( fclose( (FILE *)(is.$file) ) == EOF ) {
    235235                abort | IO_MSG "close input" | nl | strerror( errno );
    236236        } // if
     
    242242        } // if
    243243
    244         if ( fread( data, size, 1, (FILE *)(is.file) ) == 0 ) {
     244        if ( fread( data, size, 1, (FILE *)(is.$file) ) == 0 ) {
    245245                abort | IO_MSG "read" | nl | strerror( errno );
    246246        } // if
     
    253253        } // if
    254254
    255         if ( ungetc( c, (FILE *)(is.file) ) == EOF ) {
     255        if ( ungetc( c, (FILE *)(is.$file) ) == EOF ) {
    256256                abort | IO_MSG "ungetc" | nl | strerror( errno );
    257257        } // if
     
    263263
    264264        va_start( args, format );
    265         int len = vfscanf( (FILE *)(is.file), format, args );
     265        int len = vfscanf( (FILE *)(is.$file), format, args );
    266266        if ( len == EOF ) {
    267                 if ( ferror( (FILE *)(is.file) ) ) {
     267                if ( ferror( (FILE *)(is.$file) ) ) {
    268268                        abort | IO_MSG "invalid read";
    269269                } // if
  • libcfa/src/fstream.hfa

    r8c50aed ra505021  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Nov 29 06:56:02 2019
    13 // Update Count     : 168
     12// Last Modified On : Mon Feb 17 08:29:23 2020
     13// Update Count     : 175
    1414//
    1515
     
    2424enum { sepSize = 16 };
    2525struct ofstream {
    26         void * file;
    27         bool sepDefault;
    28         bool sepOnOff;
    29         bool nlOnOff;
    30         bool prt;                                                                                       // print text
    31         bool sawNL;
    32         const char * sepCur;
    33         char separator[sepSize];
    34         char tupleSeparator[sepSize];
     26        void * $file;
     27        bool $sepDefault;
     28        bool $sepOnOff;
     29        bool $nlOnOff;
     30        bool $prt;                                                                                      // print text
     31        bool $sawNL;
     32        const char * $sepCur;
     33        char $separator[sepSize];
     34        char $tupleSeparator[sepSize];
    3535}; // ofstream
    3636
    3737// private
    38 bool sepPrt( ofstream & );
    39 void sepReset( ofstream & );
    40 void sepReset( ofstream &, bool );
    41 const char * sepGetCur( ofstream & );
    42 void sepSetCur( ofstream &, const char * );
    43 bool getNL( ofstream & );
    44 void setNL( ofstream &, bool );
    45 bool getANL( ofstream & );
    46 bool getPrt( ofstream & );
    47 void setPrt( ofstream &, bool );
     38bool $sepPrt( ofstream & );
     39void $sepReset( ofstream & );
     40void $sepReset( ofstream &, bool );
     41const char * $sepGetCur( ofstream & );
     42void $sepSetCur( ofstream &, const char [] );
     43bool $getNL( ofstream & );
     44void $setNL( ofstream &, bool );
     45bool $getANL( ofstream & );
     46bool $getPrt( ofstream & );
     47void $setPrt( ofstream &, bool );
    4848
    4949// public
     
    5656
    5757const char * sepGet( ofstream & );
    58 void sepSet( ofstream &, const char * );
     58void sepSet( ofstream &, const char [] );
    5959const char * sepGetTuple( ofstream & );
    60 void sepSetTuple( ofstream &, const char * );
     60void sepSetTuple( ofstream &, const char [] );
    6161
    6262void ends( ofstream & os );
    6363int fail( ofstream & );
    6464int flush( ofstream & );
    65 void open( ofstream &, const char * name, const char * mode );
    66 void open( ofstream &, const char * name );
     65void open( ofstream &, const char name[], const char mode[] );
     66void open( ofstream &, const char name[] );
    6767void close( ofstream & );
    68 ofstream & write( ofstream &, const char * data, size_t size );
    69 int fmt( ofstream &, const char format[], ... );
     68ofstream & write( ofstream &, const char data[], size_t size );
     69int fmt( ofstream &, const char format[], ... ) __attribute__(( format(printf, 2, 3) ));
    7070
    7171void ?{}( ofstream & os );
    72 void ?{}( ofstream & os, const char * name, const char * mode );
    73 void ?{}( ofstream & os, const char * name );
     72void ?{}( ofstream & os, const char name[], const char mode[] );
     73void ?{}( ofstream & os, const char name[] );
    7474void ^?{}( ofstream & os );
    7575
     
    8282
    8383struct ifstream {
    84         void * file;
    85         bool nlOnOff;
     84        void * $file;
     85        bool $nlOnOff;
    8686}; // ifstream
    8787
     
    9292int fail( ifstream & is );
    9393int eof( ifstream & is );
    94 void open( ifstream & is, const char * name, const char * mode );
    95 void open( ifstream & is, const char * name );
     94void open( ifstream & is, const char name[], const char mode[] );
     95void open( ifstream & is, const char name[] );
    9696void close( ifstream & is );
    9797ifstream & read( ifstream & is, char * data, size_t size );
    9898ifstream & ungetc( ifstream & is, char c );
    99 int fmt( ifstream &, const char format[], ... );
     99int fmt( ifstream &, const char format[], ... ) __attribute__(( format(scanf, 2, 3) ));
    100100
    101101void ?{}( ifstream & is );
    102 void ?{}( ifstream & is, const char * name, const char * mode );
    103 void ?{}( ifstream & is, const char * name );
     102void ?{}( ifstream & is, const char name[], const char mode[] );
     103void ?{}( ifstream & is, const char name[] );
    104104void ^?{}( ifstream & is );
    105105
  • libcfa/src/gmp.hfa

    r8c50aed ra505021  
    1010// Created On       : Tue Apr 19 08:43:43 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 13 15:25:05 2019
    13 // Update Count     : 27
     12// Last Modified On : Sun Feb  9 09:56:54 2020
     13// Update Count     : 31
    1414//
    1515
     
    2424
    2525static inline {
    26         // constructor
     26        // constructor, zero_t/one_t are unnecessary because of relationship with signed/unsigned int
    2727        void ?{}( Int & this ) { mpz_init( this.mpz ); }
    2828        void ?{}( Int & this, Int init ) { mpz_init_set( this.mpz, init.mpz ); }
    29         void ?{}( Int & this, zero_t ) { mpz_init_set_si( this.mpz, 0 ); }
    30         void ?{}( Int & this, one_t ) { mpz_init_set_si( this.mpz, 1 ); }
    3129        void ?{}( Int & this, signed long int init ) { mpz_init_set_si( this.mpz, init ); }
    3230        void ?{}( Int & this, unsigned long int init ) { mpz_init_set_ui( this.mpz, init ); }
    33         void ?{}( Int & this, const char * val ) { if ( mpz_init_set_str( this.mpz, val, 0 ) ) abort(); }
     31        void ?{}( Int & this, const char val[] ) { if ( mpz_init_set_str( this.mpz, val, 0 ) ) abort(); }
    3432        void ^?{}( Int & this ) { mpz_clear( this.mpz ); }
    3533
     
    3735        Int ?`mp( signed long int init ) { return (Int){ init }; }
    3836        Int ?`mp( unsigned long int init ) { return (Int){ init }; }
    39         Int ?`mp( const char * init ) { return (Int){ init }; }
     37        Int ?`mp( const char init[] ) { return (Int){ init }; }
    4038
    4139        // assignment
     
    4341        Int ?=?( Int & lhs, long int rhs ) { mpz_set_si( lhs.mpz, rhs ); return lhs; }
    4442        Int ?=?( Int & lhs, unsigned long int rhs ) { mpz_set_ui( lhs.mpz, rhs ); return lhs; }
    45         Int ?=?( Int & lhs, const char * rhs ) { if ( mpz_set_str( lhs.mpz, rhs, 0 ) ) { abort | "invalid string conversion"; } return lhs; }
     43        Int ?=?( Int & lhs, const char rhs[] ) { if ( mpz_set_str( lhs.mpz, rhs, 0 ) ) { abort | "invalid string conversion"; } return lhs; }
    4644
    4745        char ?=?( char & lhs, Int rhs ) { char val = mpz_get_si( rhs.mpz ); lhs = val; return lhs; }
     
    265263        forall( dtype ostype | ostream( ostype ) ) {
    266264                ostype & ?|?( ostype & os, Int mp ) {
    267                         if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     265                        if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    268266                        gmp_printf( "%Zd", mp.mpz );
    269267                        sepOn( os );
  • libcfa/src/heap.cfa

    r8c50aed ra505021  
    1010// Created On       : Tue Dec 19 21:58:35 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Dec  8 21:01:31 2019
    13 // Update Count     : 647
     12// Last Modified On : Tue Feb  4 10:04:51 2020
     13// Update Count     : 648
    1414//
    1515
     
    380380
    381381
    382 static inline void checkHeader( bool check, const char * name, void * addr ) {
     382static inline void checkHeader( bool check, const char name[], void * addr ) {
    383383        if ( unlikely( check ) ) {                                                      // bad address ?
    384384                abort( "Attempt to %s storage %p with address outside the heap.\n"
     
    418418
    419419
    420 static inline bool headers( const char * name __attribute__(( unused )), void * addr, HeapManager.Storage.Header *& header, HeapManager.FreeHeader *& freeElem, size_t & size, size_t & alignment ) with ( heapManager ) {
     420static inline bool headers( const char name[] __attribute__(( unused )), void * addr, HeapManager.Storage.Header *& header, HeapManager.FreeHeader *& freeElem, size_t & size, size_t & alignment ) with ( heapManager ) {
    421421        header = headerAddr( addr );
    422422
  • libcfa/src/interpose.cfa

    r8c50aed ra505021  
    1010// Created On       : Wed Mar 29 16:10:31 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jan 30 17:47:32 2020
    13 // Update Count     : 156
     12// Last Modified On : Mon Feb 17 10:18:53 2020
     13// Update Count     : 166
    1414//
    1515
     
    2929#include "bits/signal.hfa"                                                              // sigHandler_?
    3030#include "startup.hfa"                                                                  // STARTUP_PRIORITY_CORE
     31#include <assert.h>
    3132
    3233//=============================================================================================
     
    4041
    4142typedef void (* generic_fptr_t)(void);
    42 generic_fptr_t interpose_symbol( const char * symbol, const char * version ) {
     43generic_fptr_t interpose_symbol( const char symbol[], const char version[] ) {
    4344        const char * error;
    4445
     
    145146extern "C" {
    146147        void abort( void ) __attribute__(( __nothrow__, __leaf__, __noreturn__ )) {
    147                 abort( false, NULL ); // FIX ME: 0p does not work
     148                abort( false, "%s", "" );
    148149        }
    149150
     
    161162
    162163void * kernel_abort( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return 0p; }
    163 void kernel_abort_msg( void * data, char * buffer, int size ) __attribute__(( __nothrow__, __leaf__, __weak__ )) {}
     164void kernel_abort_msg( void * data, char buffer[], int size ) __attribute__(( __nothrow__, __leaf__, __weak__ )) {}
    164165// See concurrency/kernel.cfa for strong definition used in multi-processor mode.
    165166int kernel_abort_lastframe( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return 4; }
     
    169170
    170171static void __cfaabi_backtrace( int start ) {
    171         enum {
    172                 Frames = 50,                                                                    // maximum number of stack frames
    173         };
     172        enum { Frames = 50, };                                                          // maximum number of stack frames
    174173        int last = kernel_abort_lastframe();                            // skip last N stack frames
    175174
    176175        void * array[Frames];
    177176        size_t size = backtrace( array, Frames );
    178         char ** messages = backtrace_symbols( array, size );
     177        char ** messages = backtrace_symbols( array, size ); // does not demangle names
    179178
    180179        *index( messages[0], '(' ) = '\0';                                      // find executable name
     
    184183                char * name = 0p, * offset_begin = 0p, * offset_end = 0p;
    185184
    186                 for ( char * p = messages[i]; *p; ++p ) {               // find parantheses and +offset
     185                for ( char * p = messages[i]; *p; p += 1 ) {    // find parantheses and +offset
    187186                        //__cfaabi_bits_print_nolock( "X %s\n", p);
    188187                        if ( *p == '(' ) {
     
    228227        __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
    229228
    230         if ( fmt ) {
    231                 va_list args;
    232                 va_start( args, fmt );
    233 
    234                 len = vsnprintf( abort_text, abort_text_size, fmt, args );
    235                 va_end( args );
    236                 __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
    237 
    238                 if ( fmt[strlen( fmt ) - 1] != '\n' ) {                 // add optional newline if missing at the end of the format text
    239                         __cfaabi_dbg_write( "\n", 1 );
    240                 }
    241         }
    242 
     229        assert( fmt );
     230        va_list args;
     231        va_start( args, fmt );
     232
     233        len = vsnprintf( abort_text, abort_text_size, fmt, args );
     234        va_end( args );
     235        __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
     236
     237        if ( fmt[strlen( fmt ) - 1] != '\n' ) {                         // add optional newline if missing at the end of the format text
     238                __cfaabi_dbg_write( "\n", 1 );
     239        } // if
    243240        kernel_abort_msg( kernel_data, abort_text, abort_text_size );
    244         __cfaabi_backtrace( signalAbort ? 4 : 3 );
     241
     242        __cfaabi_backtrace( signalAbort ? 4 : 2 );
    245243
    246244        __cabi_libc.abort();                                                            // print stack trace in handler
  • libcfa/src/iostream.cfa

    r8c50aed ra505021  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 13 08:07:59 2019
    13 // Update Count     : 821
     12// Last Modified On : Thu Feb 20 15:53:23 2020
     13// Update Count     : 829
    1414//
    1515
     
    1919#include <stdio.h>
    2020#include <stdbool.h>                                                                    // true/false
     21#include <stdint.h>                                                                             // UINT64_MAX
    2122//#include <string.h>                                                                   // strlen, strcmp
    2223extern size_t strlen (const char *__s) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
     
    3536forall( dtype ostype | ostream( ostype ) ) {
    3637        ostype & ?|?( ostype & os, zero_t ) {
    37                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     38                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    3839                fmt( os, "%d", 0n );
    3940                return os;
     
    4445
    4546        ostype & ?|?( ostype & os, one_t ) {
    46                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     47                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    4748                fmt( os, "%d", 1n );
    4849                return os;
     
    5354
    5455        ostype & ?|?( ostype & os, bool b ) {
    55                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     56                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    5657                fmt( os, "%s", b ? "true" : "false" );
    5758                return os;
     
    6364        ostype & ?|?( ostype & os, char c ) {
    6465                fmt( os, "%c", c );
    65                 if ( c == '\n' ) setNL( os, true );
     66                if ( c == '\n' ) $setNL( os, true );
    6667                return sepOff( os );
    6768        } // ?|?
     
    7172
    7273        ostype & ?|?( ostype & os, signed char sc ) {
    73                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     74                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    7475                fmt( os, "%hhd", sc );
    7576                return os;
     
    8081
    8182        ostype & ?|?( ostype & os, unsigned char usc ) {
    82                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     83                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    8384                fmt( os, "%hhu", usc );
    8485                return os;
     
    8990
    9091        ostype & ?|?( ostype & os, short int si ) {
    91                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     92                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    9293                fmt( os, "%hd", si );
    9394                return os;
     
    9899
    99100        ostype & ?|?( ostype & os, unsigned short int usi ) {
    100                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     101                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    101102                fmt( os, "%hu", usi );
    102103                return os;
     
    107108
    108109        ostype & ?|?( ostype & os, int i ) {
    109                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     110                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    110111                fmt( os, "%d", i );
    111112                return os;
     
    116117
    117118        ostype & ?|?( ostype & os, unsigned int ui ) {
    118                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     119                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    119120                fmt( os, "%u", ui );
    120121                return os;
     
    125126
    126127        ostype & ?|?( ostype & os, long int li ) {
    127                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     128                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    128129                fmt( os, "%ld", li );
    129130                return os;
     
    134135
    135136        ostype & ?|?( ostype & os, unsigned long int uli ) {
    136                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     137                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    137138                fmt( os, "%lu", uli );
    138139                return os;
     
    143144
    144145        ostype & ?|?( ostype & os, long long int lli ) {
    145                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     146                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    146147                fmt( os, "%lld", lli );
    147148                return os;
     
    152153
    153154        ostype & ?|?( ostype & os, unsigned long long int ulli ) {
    154                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     155                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    155156                fmt( os, "%llu", ulli );
    156157                return os;
     
    159160                (ostype &)(os | ulli); ends( os );
    160161        } // ?|?
     162
     163#if defined( __SIZEOF_INT128__ )
     164        //      UINT64_MAX 18_446_744_073_709_551_615_ULL
     165        #define P10_UINT64 10_000_000_000_000_000_000_ULL       // 19 zeroes
     166
     167        static void base10_128( ostype & os, unsigned int128 val ) {
     168                if ( val > UINT64_MAX ) {
     169                        base10_128( os, val / P10_UINT64 );                     // recursive
     170                        fmt( os, "%.19lu", (uint64_t)(val % P10_UINT64) );
     171                } else {
     172                        fmt( os, "%lu", (uint64_t)val );
     173                } // if
     174        } // base10_128
     175
     176        static void base10_128( ostype & os, int128 val ) {
     177                if ( val < 0 ) {
     178                        fmt( os, "-" );                                                         // leading negative sign
     179                        val = -val;
     180                } // if
     181                base10_128( os, (unsigned int128)val );                 // print zero/positive value
     182        } // base10_128
     183
     184        ostype & ?|?( ostype & os, int128 llli ) {
     185                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
     186                base10_128( os, llli );
     187                return os;
     188        } // ?|?
     189        void & ?|?( ostype & os, int128 llli ) {
     190                (ostype &)(os | llli); ends( os );
     191        } // ?|?
     192
     193        ostype & ?|?( ostype & os, unsigned int128 ullli ) {
     194                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
     195                base10_128( os, ullli );
     196                return os;
     197        } // ?|?
     198        void & ?|?( ostype & os, unsigned int128 ullli ) {
     199                (ostype &)(os | ullli); ends( os );
     200        } // ?|?
     201#endif // __SIZEOF_INT128__
    161202
    162203        #define PrintWithDP( os, format, val, ... ) \
     
    175216
    176217        ostype & ?|?( ostype & os, float f ) {
    177                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     218                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    178219                PrintWithDP( os, "%g", f );
    179220                return os;
     
    184225
    185226        ostype & ?|?( ostype & os, double d ) {
    186                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     227                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    187228                PrintWithDP( os, "%.*lg", d, DBL_DIG );
    188229                return os;
     
    193234
    194235        ostype & ?|?( ostype & os, long double ld ) {
    195                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     236                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    196237                PrintWithDP( os, "%.*Lg", ld, LDBL_DIG );
    197238                return os;
     
    202243
    203244        ostype & ?|?( ostype & os, float _Complex fc ) {
    204                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     245                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    205246//              os | crealf( fc ) | nonl;
    206247                PrintWithDP( os, "%g", crealf( fc ) );
     
    214255
    215256        ostype & ?|?( ostype & os, double _Complex dc ) {
    216                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     257                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    217258//              os | creal( dc ) | nonl;
    218259                PrintWithDP( os, "%.*lg", creal( dc ), DBL_DIG );
     
    226267
    227268        ostype & ?|?( ostype & os, long double _Complex ldc ) {
    228                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     269                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    229270//              os | creall( ldc ) || nonl;
    230271                PrintWithDP( os, "%.*Lg", creall( ldc ), LDBL_DIG );
     
    237278        } // ?|?
    238279
    239         ostype & ?|?( ostype & os, const char * str ) {
     280        ostype & ?|?( ostype & os, const char str[] ) {
    240281                enum { Open = 1, Close, OpenClose };
    241282                static const unsigned char mask[256] @= {
     
    257298                // first character IS NOT spacing or closing punctuation => add left separator
    258299                unsigned char ch = str[0];                                              // must make unsigned
    259                 if ( sepPrt( os ) && mask[ ch ] != Close && mask[ ch ] != OpenClose ) {
    260                         fmt( os, "%s", sepGetCur( os ) );
     300                if ( $sepPrt( os ) && mask[ ch ] != Close && mask[ ch ] != OpenClose ) {
     301                        fmt( os, "%s", $sepGetCur( os ) );
    261302                } // if
    262303
    263304                // if string starts line, must reset to determine open state because separator is off
    264                 sepReset( os );                                                                 // reset separator
     305                $sepReset( os );                                                                // reset separator
    265306
    266307                // last character IS spacing or opening punctuation => turn off separator for next item
    267308                size_t len = strlen( str );
    268309                ch = str[len - 1];                                                              // must make unsigned
    269                 if ( sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) {
     310                if ( $sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) {
    270311                        sepOn( os );
    271312                } else {
    272313                        sepOff( os );
    273314                } // if
    274                 if ( ch == '\n' ) setNL( os, true );                    // check *AFTER* sepPrt call above as it resets NL flag
     315                if ( ch == '\n' ) $setNL( os, true );                   // check *AFTER* $sepPrt call above as it resets NL flag
    275316                return write( os, str, len );
    276317        } // ?|?
    277         void ?|?( ostype & os, const char * str ) {
     318
     319        void ?|?( ostype & os, const char str[] ) {
    278320                (ostype &)(os | str); ends( os );
    279321        } // ?|?
    280322
    281323//      ostype & ?|?( ostype & os, const char16_t * str ) {
    282 //              if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     324//              if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    283325//              fmt( os, "%ls", str );
    284326//              return os;
     
    287329// #if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous
    288330//      ostype & ?|?( ostype & os, const char32_t * str ) {
    289 //              if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     331//              if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    290332//              fmt( os, "%ls", str );
    291333//              return os;
     
    294336
    295337//      ostype & ?|?( ostype & os, const wchar_t * str ) {
    296 //              if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     338//              if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    297339//              fmt( os, "%ls", str );
    298340//              return os;
     
    300342
    301343        ostype & ?|?( ostype & os, const void * p ) {
    302                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     344                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    303345                fmt( os, "%p", p );
    304346                return os;
     
    315357        void ?|?( ostype & os, ostype & (* manip)( ostype & ) ) {
    316358                (ostype &)(manip( os ));
    317                 if ( getPrt( os ) ) ends( os );                                 // something printed ?
    318                 setPrt( os, false );                                                    // turn off
     359                if ( $getPrt( os ) ) ends( os );                                // something printed ?
     360                $setPrt( os, false );                                                   // turn off
    319361        } // ?|?
    320362
     
    329371        ostype & nl( ostype & os ) {
    330372                (ostype &)(os | '\n');
    331                 setPrt( os, false );                                                    // turn off
    332                 setNL( os, true );
     373                $setPrt( os, false );                                                   // turn off
     374                $setNL( os, true );
    333375                flush( os );
    334376                return sepOff( os );                                                    // prepare for next line
     
    336378
    337379        ostype & nonl( ostype & os ) {
    338                 setPrt( os, false );                                                    // turn off
     380                $setPrt( os, false );                                                   // turn off
    339381                return os;
    340382        } // nonl
     
    375417        ostype & ?|?( ostype & os, T arg, Params rest ) {
    376418                (ostype &)(os | arg);                                                   // print first argument
    377                 sepSetCur( os, sepGetTuple( os ) );                             // switch to tuple separator
     419                $sepSetCur( os, sepGetTuple( os ) );                    // switch to tuple separator
    378420                (ostype &)(os | rest);                                                  // print remaining arguments
    379                 sepSetCur( os, sepGet( os ) );                                  // switch to regular separator
     421                $sepSetCur( os, sepGet( os ) );                                 // switch to regular separator
    380422                return os;
    381423        } // ?|?
     
    383425                // (ostype &)(?|?( os, arg, rest )); ends( os );
    384426                (ostype &)(os | arg);                                                   // print first argument
    385                 sepSetCur( os, sepGetTuple( os ) );                             // switch to tuple separator
     427                $sepSetCur( os, sepGetTuple( os ) );                    // switch to tuple separator
    386428                (ostype &)(os | rest);                                                  // print remaining arguments
    387                 sepSetCur( os, sepGet( os ) );                                  // switch to regular separator
     429                $sepSetCur( os, sepGet( os ) );                                 // switch to regular separator
    388430                ends( os );
    389431        } // ?|?
     
    414456forall( dtype ostype | ostream( ostype ) ) { \
    415457        ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \
    416                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); \
     458                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \
    417459\
    418460                if ( f.base == 'b' || f.base == 'B' ) {                 /* bespoke binary format */ \
     
    463505\
    464506                if ( ! f.flags.pc ) {                                                   /* no precision */ \
    465                         /* printf( "%s\n", &fmtstr[star] ); */ \
    466507                        fmtstr[sizeof(IFMTNP)-2] = f.base;                      /* sizeof includes '\0' */ \
     508                        /* printf( "%s %c %c\n", &fmtstr[star], f.base, CODE ); */ \
    467509                        fmt( os, &fmtstr[star], f.wd, f.val ); \
    468510                } else {                                                                                /* precision */ \
    469511                        fmtstr[sizeof(IFMTP)-2] = f.base;                       /* sizeof includes '\0' */ \
    470                         /* printf( "%s\n", &fmtstr[star] ); */ \
     512                        /* printf( "%s %c %c\n", &fmtstr[star], f.base, CODE ); */ \
    471513                        fmt( os, &fmtstr[star], f.wd, f.pc, f.val ); \
    472514                } /* if */ \
     
    486528IntegralFMTImpl( signed long long int, 'd', "%    *ll ", "%    *.*ll " )
    487529IntegralFMTImpl( unsigned long long int, 'u', "%    *ll ", "%    *.*ll " )
     530
     531
     532#if defined( __SIZEOF_INT128__ )
     533// Default prefix for non-decimal prints is 0b, 0, 0x.
     534#define IntegralFMTImpl128( T, SIGNED, CODE, IFMTNP, IFMTP ) \
     535forall( dtype ostype | ostream( ostype ) ) \
     536static void base10_128( ostype & os, _Ostream_Manip(T) fmt ) { \
     537        if ( fmt.val > UINT64_MAX ) { \
     538                fmt.val /= P10_UINT64; \
     539                base10_128( os, fmt ); /* recursive */ \
     540                _Ostream_Manip(unsigned long long int) fmt2 @= { (uint64_t)(fmt.val % P10_UINT64), 0, 19, 'u', { .all : 0 } }; \
     541                fmt2.flags.nobsdp = true; \
     542                printf( "fmt2 %c %lld %d\n", fmt2.base, fmt2.val, fmt2.all );   \
     543                sepOff( os ); \
     544                (ostype &)(os | fmt2); \
     545        } else { \
     546                printf( "fmt %c %lld %d\n", fmt.base, fmt.val, fmt.all ); \
     547                (ostype &)(os | fmt); \
     548        } /* if */ \
     549} /* base10_128 */                                                 \
     550forall( dtype ostype | ostream( ostype ) ) { \
     551        ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \
     552                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \
     553\
     554                if ( f.base == 'b' | f.base == 'o' | f.base == 'x' | f.base == 'X' ) { \
     555                        unsigned long long int msig = (unsigned long long int)(f.val >> 64); \
     556                        unsigned long long int lsig = (unsigned long long int)(f.val); \
     557                        _Ostream_Manip(SIGNED long long int) fmt @= { msig, f.wd, f.pc, f.base, { .all : f.all } }; \
     558                        _Ostream_Manip(unsigned long long int) fmt2 @= { lsig, 0, 0, f.base, { .all : 0 } }; \
     559                        if ( msig == 0 ) { \
     560                                fmt.val = lsig; \
     561                                (ostype &)(os | fmt); \
     562                        } else { \
     563                                fmt2.flags.pad0 = fmt2.flags.nobsdp = true;     \
     564                                if ( f.base == 'b' ) { \
     565                                        if ( f.wd > 64 ) fmt.wd = f.wd - 64; \
     566                                        fmt2.wd = 64; \
     567                                        (ostype &)(os | fmt | "" | fmt2); \
     568                                } else if ( f.base == 'o' ) { \
     569                                        fmt.val = (unsigned long long int)fmt.val >> 2; \
     570                                        if ( f.wd > 21 ) fmt.wd = f.wd - 21; \
     571                                        fmt2.wd = 1; \
     572                                        fmt2.val = ((msig & 0x3) << 1) + 1; \
     573                                        (ostype &)(os | fmt | "" | fmt2); \
     574                                        sepOff( os ); \
     575                                        fmt2.wd = 21; \
     576                                        fmt2.val = lsig & 0x7fffffffffffffff; \
     577                                        (ostype &)(os | fmt2); \
     578                                } else { \
     579                                        if ( f.flags.left ) { \
     580                                                if ( f.wd > 16 ) fmt2.wd = f.wd - 16;   \
     581                                                fmt.wd = 16;                                                    \
     582                                        } else { \
     583                                                if ( f.wd > 16 ) fmt.wd = f.wd - 16;    \
     584                                                fmt2.wd = 16;                                                   \
     585                                        } /* if */ \
     586                                        (ostype &)(os | fmt | "" | fmt2); \
     587                                } /* if */ \
     588                        } /* if */ \
     589                } else { \
     590                        base10_128( os, f ); \
     591                } /* if */ \
     592                return os; \
     593        } /* ?|? */ \
     594        void ?|?( ostype & os, _Ostream_Manip(T) f ) { (ostype &)(os | f); ends( os ); } \
     595} // distribution
     596
     597IntegralFMTImpl128( int128, signed, 'd', "%    *ll ", "%    *.*ll " )
     598IntegralFMTImpl128( unsigned int128, unsigned, 'u', "%    *ll ", "%    *.*ll " )
     599#endif // __SIZEOF_INT128__
    488600
    489601//*********************************** floating point ***********************************
     
    513625forall( dtype ostype | ostream( ostype ) ) { \
    514626        ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \
    515                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); \
     627                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \
    516628                char fmtstr[sizeof(DFMTP)];                                             /* sizeof includes '\0' */ \
    517629                if ( ! f.flags.pc ) memcpy( &fmtstr, DFMTNP, sizeof(DFMTNP) ); \
     
    536648                return os; \
    537649        } /* ?|? */ \
     650\
    538651        void ?|?( ostype & os, _Ostream_Manip(T) f ) { (ostype &)(os | f); ends( os ); } \
    539652} // distribution
     
    555668                } // if
    556669
    557                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     670                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    558671
    559672                #define CFMTNP "% * "
     
    571684                return os;
    572685        } // ?|?
     686
    573687        void ?|?( ostype & os, _Ostream_Manip(char) f ) { (ostype &)(os | f); ends( os ); }
    574688} // distribution
     
    592706                } // if
    593707
    594                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     708                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    595709
    596710                #define SFMTNP "% * "
     
    616730                return os;
    617731        } // ?|?
     732
    618733        void ?|?( ostype & os, _Ostream_Manip(const char *) f ) { (ostype &)(os | f); ends( os ); }
    619734} // distribution
     
    735850        } // ?|?
    736851
    737         // istype & ?|?( istype & is, const char * fmt ) {
     852        // istype & ?|?( istype & is, const char fmt[] ) {
    738853        //      fmt( is, fmt, "" );
    739854        //      return is;
  • libcfa/src/iostream.hfa

    r8c50aed ra505021  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 12 12:08:38 2019
    13 // Update Count     : 334
     12// Last Modified On : Thu Feb 20 15:30:56 2020
     13// Update Count     : 337
    1414//
    1515
     
    2424trait ostream( dtype ostype ) {
    2525        // private
    26         bool sepPrt( ostype & );                                                        // get separator state (on/off)
    27         void sepReset( ostype & );                                                      // set separator state to default state
    28         void sepReset( ostype &, bool );                                        // set separator and default state
    29         const char * sepGetCur( ostype & );                                     // get current separator string
    30         void sepSetCur( ostype &, const char * );                       // set current separator string
    31         bool getNL( ostype & );                                                         // check newline
    32         void setNL( ostype &, bool );                                           // saw newline
    33         bool getANL( ostype & );                                                        // get auto newline (on/off)
    34         bool getPrt( ostype & );                                                        // get fmt called in output cascade
    35         void setPrt( ostype &, bool );                                          // set fmt called in output cascade
     26        bool $sepPrt( ostype & );                                                       // get separator state (on/off)
     27        void $sepReset( ostype & );                                                     // set separator state to default state
     28        void $sepReset( ostype &, bool );                                       // set separator and default state
     29        const char * $sepGetCur( ostype & );                            // get current separator string
     30        void $sepSetCur( ostype &, const char [] );                     // set current separator string
     31        bool $getNL( ostype & );                                                        // check newline
     32        void $setNL( ostype &, bool );                                          // saw newline
     33        bool $getANL( ostype & );                                                       // get auto newline (on/off)
     34        bool $getPrt( ostype & );                                                       // get fmt called in output cascade
     35        void $setPrt( ostype &, bool );                                         // set fmt called in output cascade
    3636        // public
    3737        void sepOn( ostype & );                                                         // turn separator state on
     
    4343
    4444        const char * sepGet( ostype & );                                        // get separator string
    45         void sepSet( ostype &, const char * );                          // set separator to string (15 character maximum)
     45        void sepSet( ostype &, const char [] );                         // set separator to string (15 character maximum)
    4646        const char * sepGetTuple( ostype & );                           // get tuple separator string
    47         void sepSetTuple( ostype &, const char * );                     // set tuple separator to string (15 character maximum)
     47        void sepSetTuple( ostype &, const char [] );            // set tuple separator to string (15 character maximum)
    4848
    4949        void ends( ostype & os );                                                       // end of output statement
    5050        int fail( ostype & );
    5151        int flush( ostype & );
    52         void open( ostype & os, const char * name, const char * mode );
     52        void open( ostype & os, const char name[], const char mode[] );
    5353        void close( ostype & os );
    54         ostype & write( ostype &, const char *, size_t );
     54        ostype & write( ostype &, const char [], size_t );
    5555        int fmt( ostype &, const char format[], ... ) __attribute__(( format(printf, 2, 3) ));
    5656}; // ostream
     
    9898        ostype & ?|?( ostype &, unsigned long long int );
    9999        void ?|?( ostype &, unsigned long long int );
     100#if defined( __SIZEOF_INT128__ )
     101        ostype & ?|?( ostype &, int128 );
     102        void ?|?( ostype &, int128 );
     103        ostype & ?|?( ostype &, unsigned int128 );
     104        void ?|?( ostype &, unsigned int128 );
     105#endif // __SIZEOF_INT128__
    100106
    101107        ostype & ?|?( ostype &, float );
     
    113119        void ?|?( ostype &, long double _Complex );
    114120
    115         ostype & ?|?( ostype &, const char * );
    116         void ?|?( ostype &, const char * );
     121        ostype & ?|?( ostype &, const char [] );
     122        void ?|?( ostype &, const char [] );
    117123        // ostype & ?|?( ostype &, const char16_t * );
    118124#if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous
     
    206212IntegralFMTDecl( signed long long int, 'd' )
    207213IntegralFMTDecl( unsigned long long int, 'u' )
     214#if defined( __SIZEOF_INT128__ )
     215IntegralFMTDecl( int128, 'd' )
     216IntegralFMTDecl( unsigned int128, 'u' )
     217#endif
    208218
    209219//*********************************** floating point ***********************************
     
    256266
    257267static inline {
    258         _Ostream_Manip(const char *) bin( const char * s ) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'b', { .all : 0 } }; }
    259         _Ostream_Manip(const char *) oct( const char * s ) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'o', { .all : 0 } }; }
    260         _Ostream_Manip(const char *) hex( const char * s ) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'x', { .all : 0 } }; }
    261         _Ostream_Manip(const char *) wd( unsigned int w, const char * s ) { return (_Ostream_Manip(const char *))@{ s, w, 0, 's', { .all : 0 } }; }
    262         _Ostream_Manip(const char *) wd( unsigned int w, unsigned char pc, const char * s ) { return (_Ostream_Manip(const char *))@{ s, w, pc, 's', { .flags.pc : true } }; }
     268        _Ostream_Manip(const char *) bin( const char s[] ) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'b', { .all : 0 } }; }
     269        _Ostream_Manip(const char *) oct( const char s[] ) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'o', { .all : 0 } }; }
     270        _Ostream_Manip(const char *) hex( const char s[] ) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'x', { .all : 0 } }; }
     271        _Ostream_Manip(const char *) wd( unsigned int w, const char s[] ) { return (_Ostream_Manip(const char *))@{ s, w, 0, 's', { .all : 0 } }; }
     272        _Ostream_Manip(const char *) wd( unsigned int w, unsigned char pc, const char s[] ) { return (_Ostream_Manip(const char *))@{ s, w, pc, 's', { .flags.pc : true } }; }
    263273        _Ostream_Manip(const char *) & wd( unsigned int w, _Ostream_Manip(const char *) & fmt ) { fmt.wd = w; return fmt; }
    264274        _Ostream_Manip(const char *) & wd( unsigned int w, unsigned char pc, _Ostream_Manip(const char *) & fmt ) { fmt.wd = w; fmt.pc = pc; fmt.flags.pc = true; return fmt; }
     
    281291        int fail( istype & );
    282292        int eof( istype & );
    283         void open( istype & is, const char * name );
     293        void open( istype & is, const char name[] );
    284294        void close( istype & is );
    285295        istype & read( istype &, char *, size_t );
     
    316326        istype & ?|?( istype &, long double _Complex & );
    317327
    318 //      istype & ?|?( istype &, const char * );
     328//      istype & ?|?( istype &, const char [] );
    319329        istype & ?|?( istype &, char * );
    320330
     
    343353static inline {
    344354        _Istream_Cstr skip( unsigned int n ) { return (_Istream_Cstr){ 0p, 0p, n, { .all : 0 } }; }
    345         _Istream_Cstr skip( const char * scanset ) { return (_Istream_Cstr){ 0p, scanset, -1, { .all : 0 } }; }
    346         _Istream_Cstr incl( const char * scanset, char * s ) { return (_Istream_Cstr){ s, scanset, -1, { .flags.inex : false } }; }
    347         _Istream_Cstr & incl( const char * scanset, _Istream_Cstr & fmt ) { fmt.scanset = scanset; fmt.flags.inex = false; return fmt; }
    348         _Istream_Cstr excl( const char * scanset, char * s ) { return (_Istream_Cstr){ s, scanset, -1, { .flags.inex : true } }; }
    349         _Istream_Cstr & excl( const char * scanset, _Istream_Cstr & fmt ) { fmt.scanset = scanset; fmt.flags.inex = true; return fmt; }
    350         _Istream_Cstr ignore( const char * s ) { return (_Istream_Cstr)@{ s, 0p, -1, { .flags.ignore : true } }; }
     355        _Istream_Cstr skip( const char scanset[] ) { return (_Istream_Cstr){ 0p, scanset, -1, { .all : 0 } }; }
     356        _Istream_Cstr incl( const char scanset[], char * s ) { return (_Istream_Cstr){ s, scanset, -1, { .flags.inex : false } }; }
     357        _Istream_Cstr & incl( const char scanset[], _Istream_Cstr & fmt ) { fmt.scanset = scanset; fmt.flags.inex = false; return fmt; }
     358        _Istream_Cstr excl( const char scanset[], char * s ) { return (_Istream_Cstr){ s, scanset, -1, { .flags.inex : true } }; }
     359        _Istream_Cstr & excl( const char scanset[], _Istream_Cstr & fmt ) { fmt.scanset = scanset; fmt.flags.inex = true; return fmt; }
     360        _Istream_Cstr ignore( const char s[] ) { return (_Istream_Cstr)@{ s, 0p, -1, { .flags.ignore : true } }; }
    351361        _Istream_Cstr & ignore( _Istream_Cstr & fmt ) { fmt.flags.ignore = true; return fmt; }
    352         _Istream_Cstr wdi( unsigned int w, char * s ) { return (_Istream_Cstr)@{ s, 0p, w, { .all : 0 } }; }
     362        _Istream_Cstr wdi( unsigned int w, char s[] ) { return (_Istream_Cstr)@{ s, 0p, w, { .all : 0 } }; }
    353363        _Istream_Cstr & wdi( unsigned int w, _Istream_Cstr & fmt ) { fmt.wd = w; return fmt; }
    354364} // distribution
  • libcfa/src/math.hfa

    r8c50aed ra505021  
    1010// Created On       : Mon Apr 18 23:37:04 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 13 11:02:15 2018
    13 // Update Count     : 116
     12// Last Modified On : Tue Feb  4 10:27:11 2020
     13// Update Count     : 117
    1414//
    1515
     
    5151static inline long double fdim( long double x, long double y ) { return fdiml( x, y ); }
    5252
    53 static inline float nan( const char * tag ) { return nanf( tag ); }
    54 // extern "C" { double nan( const char * ); }
    55 static inline long double nan( const char * tag ) { return nanl( tag ); }
     53static inline float nan( const char tag[] ) { return nanf( tag ); }
     54// extern "C" { double nan( const char [] ); }
     55static inline long double nan( const char tag[] ) { return nanl( tag ); }
    5656
    5757//---------------------- Exponential ----------------------
  • libcfa/src/rational.cfa

    r8c50aed ra505021  
    1010// Created On       : Wed Apr  6 17:54:28 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 12 18:12:08 2019
    13 // Update Count     : 184
     12// Last Modified On : Sat Feb  8 17:56:36 2020
     13// Update Count     : 187
    1414//
    1515
     
    5656        } // rational
    5757
     58        void ?{}( Rational(RationalImpl) & r, zero_t ) {
     59                r{ (RationalImpl){0}, (RationalImpl){1} };
     60        } // rational
     61
     62        void ?{}( Rational(RationalImpl) & r, one_t ) {
     63                r{ (RationalImpl){1}, (RationalImpl){1} };
     64        } // rational
    5865
    5966        // getter for numerator/denominator
  • libcfa/src/startup.cfa

    r8c50aed ra505021  
    1010// Created On       : Tue Jul 24 16:21:57 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Dec 13 13:16:45 2019
    13 // Update Count     : 29
     12// Last Modified On : Tue Feb  4 13:03:18 2020
     13// Update Count     : 30
    1414//
    1515
     
    4141struct __spinlock_t;
    4242extern "C" {
    43         void __cfaabi_dbg_record(struct __spinlock_t & this, const char * prev_name) __attribute__(( weak )) {}
     43        void __cfaabi_dbg_record(struct __spinlock_t & this, const char prev_name[]) __attribute__(( weak )) {}
    4444}
    4545
  • libcfa/src/stdhdr/assert.h

    r8c50aed ra505021  
    1010// Created On       : Mon Jul  4 23:25:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jul 31 23:09:32 2017
    13 // Update Count     : 13
     12// Last Modified On : Tue Feb  4 12:58:49 2020
     13// Update Count     : 15
    1414//
    1515
     
    2727        #define assertf( expr, fmt, ... ) ((expr) ? ((void)0) : __assert_fail_f(__VSTRINGIFY__(expr), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, ## __VA_ARGS__ ))
    2828
    29         void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) __attribute__((noreturn, format( printf, 5, 6) ));
     29        void __assert_fail_f( const char assertion[], const char file[], unsigned int line, const char function[], const char fmt[], ... ) __attribute__((noreturn, format( printf, 5, 6) ));
    3030#endif
    3131
  • libcfa/src/stdhdr/bfdlink.h

    r8c50aed ra505021  
    1010// Created On       : Tue Jul 18 07:26:04 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Feb  1 07:15:29 2020
    13 // Update Count     : 5
     12// Last Modified On : Fri Feb  7 19:05:08 2020
     13// Update Count     : 6
    1414//
    1515
    1616// include file uses the CFA keyword "with".
    1717#if ! defined( with )                                                                   // nesting ?
    18 #define with ``with``                                                                   // make keyword an identifier
     18#define with ``with                                                                             // make keyword an identifier
    1919#define __CFA_BFDLINK_H__
    2020#endif
  • libcfa/src/stdhdr/hwloc.h

    r8c50aed ra505021  
    1010// Created On       : Tue Jul 18 07:45:00 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Feb  1 07:15:39 2020
    13 // Update Count     : 5
     12// Last Modified On : Fri Feb  7 19:05:18 2020
     13// Update Count     : 6
    1414//
    1515
    1616// include file uses the CFA keyword "thread".
    1717#if ! defined( thread )                                                                 // nesting ?
    18 #define thread ``thread``                                                               // make keyword an identifier
     18#define thread ``thread                                                                 // make keyword an identifier
    1919#define __CFA_HWLOC_H__
    2020#endif
  • libcfa/src/stdhdr/krb5.h

    r8c50aed ra505021  
    1010// Created On       : Tue Jul 18 07:55:44 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Feb  1 07:15:47 2020
    13 // Update Count     : 5
     12// Last Modified On : Fri Feb  7 19:05:35 2020
     13// Update Count     : 6
    1414//
    1515
    1616// include file uses the CFA keyword "enable".
    1717#if ! defined( enable )                                                                 // nesting ?
    18 #define enable ``enable``                                                               // make keyword an identifier
     18#define enable ``enable                                                                 // make keyword an identifier
    1919#define __CFA_KRB5_H__
    2020#endif
  • libcfa/src/stdhdr/math.h

    r8c50aed ra505021  
    1010// Created On       : Mon Jul  4 23:25:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Feb  1 07:15:58 2020
    13 // Update Count     : 14
     12// Last Modified On : Fri Feb  7 19:05:27 2020
     13// Update Count     : 15
    1414//
    1515
    1616extern "C" {
    1717#if ! defined( exception )                                                              // nesting ?
    18 #define exception ``exception``                                                 // make keyword an identifier
     18#define exception ``exception                                                   // make keyword an identifier
    1919#define __CFA_MATH_H__
    2020#endif
  • libcfa/src/stdhdr/sys/ucontext.h

    r8c50aed ra505021  
    1010// Created On       : Thu Feb  8 23:48:16 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Feb  1 07:16:05 2020
    13 // Update Count     : 5
     12// Last Modified On : Fri Feb  7 19:05:41 2020
     13// Update Count     : 6
    1414//
    1515
    1616#if ! defined( ftype )                                                                  // nesting ?
    17 #define ftype ``ftype``                                                                 // make keyword an identifier
     17#define ftype ``ftype                                                                   // make keyword an identifier
    1818#define __CFA_UCONTEXT_H__
    1919#endif
  • libcfa/src/stdlib.cfa

    r8c50aed ra505021  
    1010// Created On       : Thu Jan 28 17:10:29 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Nov 20 17:22:47 2019
    13 // Update Count     : 485
     12// Last Modified On : Tue Feb  4 08:27:08 2020
     13// Update Count     : 486
    1414//
    1515
     
    107107//---------------------------------------
    108108
    109 float _Complex strto( const char * sptr, char ** eptr ) {
     109float _Complex strto( const char sptr[], char ** eptr ) {
    110110        float re, im;
    111111        char * eeptr;
     
    118118} // strto
    119119
    120 double _Complex strto( const char * sptr, char ** eptr ) {
     120double _Complex strto( const char sptr[], char ** eptr ) {
    121121        double re, im;
    122122        char * eeptr;
     
    129129} // strto
    130130
    131 long double _Complex strto( const char * sptr, char ** eptr ) {
     131long double _Complex strto( const char sptr[], char ** eptr ) {
    132132        long double re, im;
    133133        char * eeptr;
  • libcfa/src/stdlib.hfa

    r8c50aed ra505021  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Nov 29 23:08:02 2019
    13 // Update Count     : 400
     12// Last Modified On : Tue Feb  4 08:27:01 2020
     13// Update Count     : 401
    1414//
    1515
     
    193193
    194194static inline {
    195         int strto( const char * sptr, char ** eptr, int base ) { return (int)strtol( sptr, eptr, base ); }
    196         unsigned int strto( const char * sptr, char ** eptr, int base ) { return (unsigned int)strtoul( sptr, eptr, base ); }
    197         long int strto( const char * sptr, char ** eptr, int base ) { return strtol( sptr, eptr, base ); }
    198         unsigned long int strto( const char * sptr, char ** eptr, int base ) { return strtoul( sptr, eptr, base ); }
    199         long long int strto( const char * sptr, char ** eptr, int base ) { return strtoll( sptr, eptr, base ); }
    200         unsigned long long int strto( const char * sptr, char ** eptr, int base ) { return strtoull( sptr, eptr, base ); }
    201 
    202         float strto( const char * sptr, char ** eptr ) { return strtof( sptr, eptr ); }
    203         double strto( const char * sptr, char ** eptr ) { return strtod( sptr, eptr ); }
    204         long double strto( const char * sptr, char ** eptr ) { return strtold( sptr, eptr ); }
    205 } // distribution
    206 
    207 float _Complex strto( const char * sptr, char ** eptr );
    208 double _Complex strto( const char * sptr, char ** eptr );
    209 long double _Complex strto( const char * sptr, char ** eptr );
     195        int strto( const char sptr[], char ** eptr, int base ) { return (int)strtol( sptr, eptr, base ); }
     196        unsigned int strto( const char sptr[], char ** eptr, int base ) { return (unsigned int)strtoul( sptr, eptr, base ); }
     197        long int strto( const char sptr[], char ** eptr, int base ) { return strtol( sptr, eptr, base ); }
     198        unsigned long int strto( const char sptr[], char ** eptr, int base ) { return strtoul( sptr, eptr, base ); }
     199        long long int strto( const char sptr[], char ** eptr, int base ) { return strtoll( sptr, eptr, base ); }
     200        unsigned long long int strto( const char sptr[], char ** eptr, int base ) { return strtoull( sptr, eptr, base ); }
     201
     202        float strto( const char sptr[], char ** eptr ) { return strtof( sptr, eptr ); }
     203        double strto( const char sptr[], char ** eptr ) { return strtod( sptr, eptr ); }
     204        long double strto( const char sptr[], char ** eptr ) { return strtold( sptr, eptr ); }
     205} // distribution
     206
     207float _Complex strto( const char sptr[], char ** eptr );
     208double _Complex strto( const char sptr[], char ** eptr );
     209long double _Complex strto( const char sptr[], char ** eptr );
    210210
    211211static inline {
    212         int ato( const char * sptr ) { return (int)strtol( sptr, 0p, 10 ); }
    213         unsigned int ato( const char * sptr ) { return (unsigned int)strtoul( sptr, 0p, 10 ); }
    214         long int ato( const char * sptr ) { return strtol( sptr, 0p, 10 ); }
    215         unsigned long int ato( const char * sptr ) { return strtoul( sptr, 0p, 10 ); }
    216         long long int ato( const char * sptr ) { return strtoll( sptr, 0p, 10 ); }
    217         unsigned long long int ato( const char * sptr ) { return strtoull( sptr, 0p, 10 ); }
    218 
    219         float ato( const char * sptr ) { return strtof( sptr, 0p ); }
    220         double ato( const char * sptr ) { return strtod( sptr, 0p ); }
    221         long double ato( const char * sptr ) { return strtold( sptr, 0p ); }
    222 
    223         float _Complex ato( const char * sptr ) { return strto( sptr, 0p ); }
    224         double _Complex ato( const char * sptr ) { return strto( sptr, 0p ); }
    225         long double _Complex ato( const char * sptr ) { return strto( sptr, 0p ); }
     212        int ato( const char sptr[] ) { return (int)strtol( sptr, 0p, 10 ); }
     213        unsigned int ato( const char sptr[] ) { return (unsigned int)strtoul( sptr, 0p, 10 ); }
     214        long int ato( const char sptr[] ) { return strtol( sptr, 0p, 10 ); }
     215        unsigned long int ato( const char sptr[] ) { return strtoul( sptr, 0p, 10 ); }
     216        long long int ato( const char sptr[] ) { return strtoll( sptr, 0p, 10 ); }
     217        unsigned long long int ato( const char sptr[] ) { return strtoull( sptr, 0p, 10 ); }
     218
     219        float ato( const char sptr[] ) { return strtof( sptr, 0p ); }
     220        double ato( const char sptr[] ) { return strtod( sptr, 0p ); }
     221        long double ato( const char sptr[] ) { return strtold( sptr, 0p ); }
     222
     223        float _Complex ato( const char sptr[] ) { return strto( sptr, 0p ); }
     224        double _Complex ato( const char sptr[] ) { return strto( sptr, 0p ); }
     225        long double _Complex ato( const char sptr[] ) { return strto( sptr, 0p ); }
    226226} // distribution
    227227
  • libcfa/src/time.cfa

    r8c50aed ra505021  
    1010// Created On       : Tue Mar 27 13:33:14 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jan  5 17:27:40 2020
    13 // Update Count     : 69
     12// Last Modified On : Tue Feb  4 08:24:18 2020
     13// Update Count     : 70
    1414//
    1515
     
    129129} // dd_mm_yy
    130130
    131 size_t strftime( char * buf, size_t size, const char * fmt, Time time ) with( time ) {
     131size_t strftime( char buf[], size_t size, const char fmt[], Time time ) with( time ) {
    132132        time_t s = tn / TIMEGRAN;
    133133        tm tm;
  • libcfa/src/time.hfa

    r8c50aed ra505021  
    1010// Created On       : Wed Mar 14 23:18:57 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan  6 12:50:16 2020
    13 // Update Count     : 653
     12// Last Modified On : Tue Feb  4 08:24:32 2020
     13// Update Count     : 654
    1414//
    1515
     
    191191} // dmy
    192192
    193 size_t strftime( char * buf, size_t size, const char * fmt, Time time );
     193size_t strftime( char buf[], size_t size, const char fmt[], Time time );
    194194
    195195//------------------------- timeval (cont) -------------------------
Note: See TracChangeset for help on using the changeset viewer.