Changeset 3ecfa13


Ignore:
Timestamp:
Feb 8, 2020, 3:21:45 PM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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:
8c9da33
Parents:
0f5da65 (diff), 74330e7 (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

Files:
41 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/assert.cfa

    r0f5da65 r3ecfa13  
    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

    r0f5da65 r3ecfa13  
    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

    r0f5da65 r3ecfa13  
    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

    r0f5da65 r3ecfa13  
    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/CtxSwitch-x86_64.S

    r0f5da65 r3ecfa13  
    8787CtxInvokeStub:
    8888        movq %rbx, %rdi
    89         jmp *%r12
     89        movq %r12, %rsi
     90        jmp *%r13
    9091        .size  CtxInvokeStub, .-CtxInvokeStub
    9192
  • libcfa/src/concurrency/coroutine.cfa

    r0f5da65 r3ecfa13  
    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};
     
    187187// is not inline (We can't inline Cforall in C)
    188188extern "C" {
    189         void __suspend_internal(void) {
    190                 suspend();
    191         }
    192 
    193         void __leave_coroutine( coroutine_desc * src ) {
     189        void __leave_coroutine( struct coroutine_desc * src ) {
    194190                coroutine_desc * starter = src->cancellation != 0 ? src->last : src->starter;
    195191
     
    207203                CoroutineCtxSwitch( src, starter );
    208204        }
     205
     206        struct coroutine_desc * __finish_coroutine(void) {
     207                struct coroutine_desc * cor = kernelTLS.this_thread->curr_cor;
     208
     209                if(cor->state == Primed) {
     210                        suspend();
     211                }
     212
     213                cor->state = Active;
     214
     215                return cor;
     216        }
    209217}
    210218
  • libcfa/src/concurrency/coroutine.hfa

    r0f5da65 r3ecfa13  
    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//-----------------------------------------------------------------------------
     
    6161// Start coroutine routines
    6262extern "C" {
    63       forall(dtype T | is_coroutine(T))
    64       void CtxInvokeCoroutine(T * this);
     63        void CtxInvokeCoroutine(void (*main)(void *), void * this);
    6564
    66       forall(dtype T | is_coroutine(T))
    67       void CtxStart(T * this, void ( *invoke)(T *));
     65        forall(dtype T)
     66        void CtxStart(void (*main)(T &), struct coroutine_desc * cor, T & this, void (*invoke)(void (*main)(void *), void *));
    6867
    6968        extern void _CtxCoroutine_Unwind(struct _Unwind_Exception * storage, struct coroutine_desc *) __attribute__ ((__noreturn__));
     
    129128
    130129        if( unlikely(dst->context.SP == 0p) ) {
     130                TL_GET( this_thread )->curr_cor = dst;
    131131                __stack_prepare(&dst->stack, 65000);
    132                 CtxStart(&cor, CtxInvokeCoroutine);
     132                CtxStart(main, dst, cor, CtxInvokeCoroutine);
     133                TL_GET( this_thread )->curr_cor = src;
    133134        }
    134135
  • libcfa/src/concurrency/invoke.c

    r0f5da65 r3ecfa13  
    2929// Called from the kernel when starting a coroutine or task so must switch back to user mode.
    3030
    31 extern void __suspend_internal(void);
    32 extern void __leave_coroutine( struct coroutine_desc * );
    33 extern void __finish_creation( struct thread_desc * );
    34 extern void __leave_thread_monitor( struct thread_desc * this );
     31extern void __leave_coroutine ( struct coroutine_desc * );
     32extern struct coroutine_desc * __finish_coroutine(void);
     33extern void __leave_thread_monitor();
    3534extern void disable_interrupts() OPTIONAL_THREAD;
    3635extern void enable_interrupts( __cfaabi_dbg_ctx_param );
     
    3837void CtxInvokeCoroutine(
    3938        void (*main)(void *),
    40         struct coroutine_desc *(*get_coroutine)(void *),
    4139        void *this
    4240) {
    43         struct coroutine_desc* cor = get_coroutine( this );
     41        // Finish setting up the coroutine by setting its state
     42        struct coroutine_desc * cor = __finish_coroutine();
    4443
    45         if(cor->state == Primed) {
    46                 __suspend_internal();
    47         }
    48 
    49         cor->state = Active;
    50 
     44        // Call the main of the coroutine
    5145        main( this );
    5246
     
    8377
    8478void CtxInvokeThread(
    85         void (*dtor)(void *),
    8679        void (*main)(void *),
    87         struct thread_desc *(*get_thread)(void *),
    8880        void *this
    8981) {
    90         // Fetch the thread handle from the user defined thread structure
    91         struct thread_desc* thrd = get_thread( this );
    92 
    93         // First suspend, once the thread arrives here,
    94         // the function pointer to main can be invalidated without risk
    95         __finish_creation( thrd );
    96 
    9782        // Officially start the thread by enabling preemption
    9883        enable_interrupts( __cfaabi_dbg_ctx );
     
    10893        // The order of these 4 operations is very important
    10994        //Final suspend, should never return
    110         __leave_thread_monitor( thrd );
     95        __leave_thread_monitor();
    11196        __cabi_abort( "Resumed dead thread" );
    11297}
    11398
    114 
    11599void CtxStart(
    116100        void (*main)(void *),
    117         struct coroutine_desc *(*get_coroutine)(void *),
     101        struct coroutine_desc * cor,
    118102        void *this,
    119103        void (*invoke)(void *)
    120104) {
    121         struct coroutine_desc * cor = get_coroutine( this );
    122105        struct __stack_t * stack = cor->stack.storage;
    123106
     
    138121
    139122        fs->dummyReturn = NULL;
    140         fs->argument[0] = this;     // argument to invoke
     123        fs->argument[0] = main;     // argument to invoke
     124        fs->argument[1] = this;     // argument to invoke
    141125        fs->rturn = invoke;
    142126
     
    156140        fs->dummyReturn = NULL;
    157141        fs->rturn = CtxInvokeStub;
    158         fs->fixedRegisters[0] = this;
    159         fs->fixedRegisters[1] = invoke;
     142        fs->fixedRegisters[0] = main;
     143        fs->fixedRegisters[1] = this;
     144        fs->fixedRegisters[2] = invoke;
    160145
    161146#elif defined( __ARM_ARCH )
    162 
     147#error ARM needs to be upgrade to use to parameters like X86/X64 (A.K.A. : I broke this and do not know how to fix it)
    163148        struct FakeStack {
    164149                float fpRegs[16];                       // floating point registers
  • libcfa/src/concurrency/kernel.cfa

    r0f5da65 r3ecfa13  
    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
     
    209209
    210210static void start(processor * this);
    211 void ?{}(processor & this, const char * name, cluster & cltr) with( this ) {
     211void ?{}(processor & this, const char name[], cluster & cltr) with( this ) {
    212212        this.name = name;
    213213        this.cltr = &cltr;
     
    238238}
    239239
    240 void ?{}(cluster & this, const char * name, Duration preemption_rate) with( this ) {
     240void ?{}(cluster & this, const char name[], Duration preemption_rate) with( this ) {
    241241        this.name = name;
    242242        this.preemption_rate = preemption_rate;
     
    441441}
    442442
    443 static void Abort( int ret, const char * func ) {
     443static void Abort( int ret, const char func[] ) {
    444444        if ( ret ) {                                                                            // pthread routines return errno values
    445445                abort( "%s : internal error, error(%d) %s.", func, ret, strerror( ret ) );
     
    469469        );
    470470
    471         Abort( pthread_attr_setstack( &attr, stack, stacksize ), "pthread_attr_setstack" ); 
     471        Abort( pthread_attr_setstack( &attr, stack, stacksize ), "pthread_attr_setstack" );
    472472
    473473        Abort( pthread_create( pthread, &attr, start, arg ), "pthread_create" );
     
    490490        verify( ! kernelTLS.preemption_state.enabled );
    491491
     492        kernelTLS.this_thread->curr_cor = dst;
    492493        __stack_prepare( &dst->stack, 65000 );
    493         CtxStart(&this->runner, CtxInvokeCoroutine);
     494        CtxStart(main, dst, this->runner, CtxInvokeCoroutine);
    494495
    495496        verify( ! kernelTLS.preemption_state.enabled );
     
    505506        CtxSwitch( &src->context, &dst->context );
    506507        // when CtxSwitch returns we are back in the src coroutine
     508
     509        mainThread->curr_cor = &mainThread->self_cor;
    507510
    508511        // set state of new coroutine to active
     
    978981__cfaabi_dbg_debug_do(
    979982        extern "C" {
    980                 void __cfaabi_dbg_record(__spinlock_t & this, const char * prev_name) {
     983                void __cfaabi_dbg_record(__spinlock_t & this, const char prev_name[]) {
    981984                        this.prev_name = prev_name;
    982985                        this.prev_thrd = kernelTLS.this_thread;
  • libcfa/src/concurrency/kernel.hfa

    r0f5da65 r3ecfa13  
    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
     
    150150};
    151151
    152 void  ?{}(processor & this, const char * name, struct cluster & cltr);
     152void  ?{}(processor & this, const char name[], struct cluster & cltr);
    153153void ^?{}(processor & this);
    154154
    155155static inline void  ?{}(processor & this)                    { this{ "Anonymous Processor", *mainCluster}; }
    156156static inline void  ?{}(processor & this, struct cluster & cltr)    { this{ "Anonymous Processor", cltr}; }
    157 static inline void  ?{}(processor & this, const char * name) { this{name, *mainCluster }; }
     157static inline void  ?{}(processor & this, const char name[]) { this{name, *mainCluster }; }
    158158
    159159static inline [processor *&, processor *& ] __get( processor & this ) {
     
    195195extern Duration default_preemption();
    196196
    197 void ?{} (cluster & this, const char * name, Duration preemption_rate);
     197void ?{} (cluster & this, const char name[], Duration preemption_rate);
    198198void ^?{}(cluster & this);
    199199
    200200static inline void ?{} (cluster & this)                           { this{"Anonymous Cluster", default_preemption()}; }
    201201static inline void ?{} (cluster & this, Duration preemption_rate) { this{"Anonymous Cluster", preemption_rate}; }
    202 static inline void ?{} (cluster & this, const char * name)        { this{name, default_preemption()}; }
     202static inline void ?{} (cluster & this, const char name[])        { this{name, default_preemption()}; }
    203203
    204204static inline [cluster *&, cluster *& ] __get( cluster & this ) {
  • libcfa/src/concurrency/kernel_private.hfa

    r0f5da65 r3ecfa13  
    8888// Threads
    8989extern "C" {
    90       forall(dtype T | is_thread(T))
    91       void CtxInvokeThread(T * this);
     90      void CtxInvokeThread(void (*main)(void *), void * this);
    9291}
    9392
  • libcfa/src/concurrency/monitor.cfa

    r0f5da65 r3ecfa13  
    243243        // last routine called by a thread.
    244244        // Should never return
    245         void __leave_thread_monitor( thread_desc * thrd ) {
     245        void __leave_thread_monitor() {
     246                thread_desc * thrd = TL_GET( this_thread );
    246247                monitor_desc * this = &thrd->self_mon;
    247248
  • libcfa/src/concurrency/thread.cfa

    r0f5da65 r3ecfa13  
    5858void ?{}( scoped(T)& this ) with( this ) {
    5959        handle{};
    60         __thrd_start(handle);
     60        __thrd_start(handle, main);
    6161}
    6262
     
    6464void ?{}( scoped(T)& this, P params ) with( this ) {
    6565        handle{ params };
    66         __thrd_start(handle);
     66        __thrd_start(handle, main);
    6767}
    6868
     
    7575// Starting and stopping threads
    7676forall( dtype T | is_thread(T) )
    77 void __thrd_start( T& this ) {
     77void __thrd_start( T & this, void (*main_p)(T &) ) {
    7878        thread_desc * this_thrd = get_thread(this);
    7979        thread_desc * curr_thrd = TL_GET( this_thread );
    8080
    8181        disable_interrupts();
    82         CtxStart(&this, CtxInvokeThread);
     82        CtxStart(main_p, get_coroutine(this), this, CtxInvokeThread);
     83
    8384        this_thrd->context.[SP, FP] = this_thrd->self_cor.context.[SP, FP];
    8485        verify( this_thrd->context.SP );
    85         CtxSwitch( &curr_thrd->context, &this_thrd->context );
     86        // CtxSwitch( &curr_thrd->context, &this_thrd->context );
    8687
    8788        ScheduleThread(this_thrd);
    8889        enable_interrupts( __cfaabi_dbg_ctx );
    89 }
    90 
    91 extern "C" {
    92         // KERNEL ONLY
    93         void __finish_creation(thread_desc * this) {
    94                 // set new coroutine that the processor is executing
    95                 // and context switch to it
    96                 verify( kernelTLS.this_thread != this );
    97                 verify( kernelTLS.this_thread->context.SP );
    98                 CtxSwitch( &this->context, &kernelTLS.this_thread->context );
    99         }
    10090}
    10191
  • libcfa/src/concurrency/thread.hfa

    r0f5da65 r3ecfa13  
    5454
    5555forall( dtype T | is_thread(T) )
    56 void __thrd_start( T & this );
     56void __thrd_start( T & this, void (*)(T &) );
    5757
    5858//-----------------------------------------------------------------------------
  • libcfa/src/fstream.cfa

    r0f5da65 r3ecfa13  
    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

    r0f5da65 r3ecfa13  
    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 : Fri Feb  7 19:00:51 2020
     13// Update Count     : 174
    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 );
     68ofstream & write( ofstream &, const char data[], size_t size );
    6969int fmt( ofstream &, const char format[], ... );
    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 );
     
    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

    r0f5da65 r3ecfa13  
    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 : Fri Feb  7 22:10:30 2020
     13// Update Count     : 29
    1414//
    1515
     
    3131        void ?{}( Int & this, signed long int init ) { mpz_init_set_si( this.mpz, init ); }
    3232        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(); }
     33        void ?{}( Int & this, const char val[] ) { if ( mpz_init_set_str( this.mpz, val, 0 ) ) abort(); }
    3434        void ^?{}( Int & this ) { mpz_clear( this.mpz ); }
    3535
     
    3737        Int ?`mp( signed long int init ) { return (Int){ init }; }
    3838        Int ?`mp( unsigned long int init ) { return (Int){ init }; }
    39         Int ?`mp( const char * init ) { return (Int){ init }; }
     39        Int ?`mp( const char init[] ) { return (Int){ init }; }
    4040
    4141        // assignment
     
    4343        Int ?=?( Int & lhs, long int rhs ) { mpz_set_si( lhs.mpz, rhs ); return lhs; }
    4444        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; }
     45        Int ?=?( Int & lhs, const char rhs[] ) { if ( mpz_set_str( lhs.mpz, rhs, 0 ) ) { abort | "invalid string conversion"; } return lhs; }
    4646
    4747        char ?=?( char & lhs, Int rhs ) { char val = mpz_get_si( rhs.mpz ); lhs = val; return lhs; }
     
    265265        forall( dtype ostype | ostream( ostype ) ) {
    266266                ostype & ?|?( ostype & os, Int mp ) {
    267                         if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     267                        if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    268268                        gmp_printf( "%Zd", mp.mpz );
    269269                        sepOn( os );
  • libcfa/src/heap.cfa

    r0f5da65 r3ecfa13  
    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

    r0f5da65 r3ecfa13  
    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 : Sat Feb  8 08:40:34 2020
     13// Update Count     : 163
    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                 }
     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 );
    241239        }
    242240
  • libcfa/src/iostream.cfa

    r0f5da65 r3ecfa13  
    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 : Fri Feb  7 18:48:38 2020
     13// Update Count     : 825
    1414//
    1515
     
    3535forall( dtype ostype | ostream( ostype ) ) {
    3636        ostype & ?|?( ostype & os, zero_t ) {
    37                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     37                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    3838                fmt( os, "%d", 0n );
    3939                return os;
     
    4444
    4545        ostype & ?|?( ostype & os, one_t ) {
    46                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     46                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    4747                fmt( os, "%d", 1n );
    4848                return os;
     
    5353
    5454        ostype & ?|?( ostype & os, bool b ) {
    55                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     55                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    5656                fmt( os, "%s", b ? "true" : "false" );
    5757                return os;
     
    6363        ostype & ?|?( ostype & os, char c ) {
    6464                fmt( os, "%c", c );
    65                 if ( c == '\n' ) setNL( os, true );
     65                if ( c == '\n' ) $setNL( os, true );
    6666                return sepOff( os );
    6767        } // ?|?
     
    7171
    7272        ostype & ?|?( ostype & os, signed char sc ) {
    73                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     73                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    7474                fmt( os, "%hhd", sc );
    7575                return os;
     
    8080
    8181        ostype & ?|?( ostype & os, unsigned char usc ) {
    82                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     82                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    8383                fmt( os, "%hhu", usc );
    8484                return os;
     
    8989
    9090        ostype & ?|?( ostype & os, short int si ) {
    91                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     91                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    9292                fmt( os, "%hd", si );
    9393                return os;
     
    9898
    9999        ostype & ?|?( ostype & os, unsigned short int usi ) {
    100                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     100                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    101101                fmt( os, "%hu", usi );
    102102                return os;
     
    107107
    108108        ostype & ?|?( ostype & os, int i ) {
    109                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     109                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    110110                fmt( os, "%d", i );
    111111                return os;
     
    116116
    117117        ostype & ?|?( ostype & os, unsigned int ui ) {
    118                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     118                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    119119                fmt( os, "%u", ui );
    120120                return os;
     
    125125
    126126        ostype & ?|?( ostype & os, long int li ) {
    127                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     127                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    128128                fmt( os, "%ld", li );
    129129                return os;
     
    134134
    135135        ostype & ?|?( ostype & os, unsigned long int uli ) {
    136                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     136                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    137137                fmt( os, "%lu", uli );
    138138                return os;
     
    143143
    144144        ostype & ?|?( ostype & os, long long int lli ) {
    145                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     145                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    146146                fmt( os, "%lld", lli );
    147147                return os;
     
    152152
    153153        ostype & ?|?( ostype & os, unsigned long long int ulli ) {
    154                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     154                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    155155                fmt( os, "%llu", ulli );
    156156                return os;
     
    175175
    176176        ostype & ?|?( ostype & os, float f ) {
    177                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     177                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    178178                PrintWithDP( os, "%g", f );
    179179                return os;
     
    184184
    185185        ostype & ?|?( ostype & os, double d ) {
    186                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     186                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    187187                PrintWithDP( os, "%.*lg", d, DBL_DIG );
    188188                return os;
     
    193193
    194194        ostype & ?|?( ostype & os, long double ld ) {
    195                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     195                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    196196                PrintWithDP( os, "%.*Lg", ld, LDBL_DIG );
    197197                return os;
     
    202202
    203203        ostype & ?|?( ostype & os, float _Complex fc ) {
    204                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     204                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    205205//              os | crealf( fc ) | nonl;
    206206                PrintWithDP( os, "%g", crealf( fc ) );
     
    214214
    215215        ostype & ?|?( ostype & os, double _Complex dc ) {
    216                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     216                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    217217//              os | creal( dc ) | nonl;
    218218                PrintWithDP( os, "%.*lg", creal( dc ), DBL_DIG );
     
    226226
    227227        ostype & ?|?( ostype & os, long double _Complex ldc ) {
    228                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     228                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    229229//              os | creall( ldc ) || nonl;
    230230                PrintWithDP( os, "%.*Lg", creall( ldc ), LDBL_DIG );
     
    237237        } // ?|?
    238238
    239         ostype & ?|?( ostype & os, const char * str ) {
     239        ostype & ?|?( ostype & os, const char str[] ) {
    240240                enum { Open = 1, Close, OpenClose };
    241241                static const unsigned char mask[256] @= {
     
    257257                // first character IS NOT spacing or closing punctuation => add left separator
    258258                unsigned char ch = str[0];                                              // must make unsigned
    259                 if ( sepPrt( os ) && mask[ ch ] != Close && mask[ ch ] != OpenClose ) {
    260                         fmt( os, "%s", sepGetCur( os ) );
     259                if ( $sepPrt( os ) && mask[ ch ] != Close && mask[ ch ] != OpenClose ) {
     260                        fmt( os, "%s", $sepGetCur( os ) );
    261261                } // if
    262262
    263263                // if string starts line, must reset to determine open state because separator is off
    264                 sepReset( os );                                                                 // reset separator
     264                $sepReset( os );                                                                // reset separator
    265265
    266266                // last character IS spacing or opening punctuation => turn off separator for next item
    267267                size_t len = strlen( str );
    268268                ch = str[len - 1];                                                              // must make unsigned
    269                 if ( sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) {
     269                if ( $sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) {
    270270                        sepOn( os );
    271271                } else {
    272272                        sepOff( os );
    273273                } // if
    274                 if ( ch == '\n' ) setNL( os, true );                    // check *AFTER* sepPrt call above as it resets NL flag
     274                if ( ch == '\n' ) $setNL( os, true );                   // check *AFTER* $sepPrt call above as it resets NL flag
    275275                return write( os, str, len );
    276276        } // ?|?
    277         void ?|?( ostype & os, const char * str ) {
     277
     278        void ?|?( ostype & os, const char str[] ) {
    278279                (ostype &)(os | str); ends( os );
    279280        } // ?|?
    280281
    281282//      ostype & ?|?( ostype & os, const char16_t * str ) {
    282 //              if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     283//              if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    283284//              fmt( os, "%ls", str );
    284285//              return os;
     
    287288// #if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous
    288289//      ostype & ?|?( ostype & os, const char32_t * str ) {
    289 //              if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     290//              if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    290291//              fmt( os, "%ls", str );
    291292//              return os;
     
    294295
    295296//      ostype & ?|?( ostype & os, const wchar_t * str ) {
    296 //              if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     297//              if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    297298//              fmt( os, "%ls", str );
    298299//              return os;
     
    300301
    301302        ostype & ?|?( ostype & os, const void * p ) {
    302                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     303                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    303304                fmt( os, "%p", p );
    304305                return os;
     
    315316        void ?|?( ostype & os, ostype & (* manip)( ostype & ) ) {
    316317                (ostype &)(manip( os ));
    317                 if ( getPrt( os ) ) ends( os );                                 // something printed ?
    318                 setPrt( os, false );                                                    // turn off
     318                if ( $getPrt( os ) ) ends( os );                                // something printed ?
     319                $setPrt( os, false );                                                   // turn off
    319320        } // ?|?
    320321
     
    329330        ostype & nl( ostype & os ) {
    330331                (ostype &)(os | '\n');
    331                 setPrt( os, false );                                                    // turn off
    332                 setNL( os, true );
     332                $setPrt( os, false );                                                   // turn off
     333                $setNL( os, true );
    333334                flush( os );
    334335                return sepOff( os );                                                    // prepare for next line
     
    336337
    337338        ostype & nonl( ostype & os ) {
    338                 setPrt( os, false );                                                    // turn off
     339                $setPrt( os, false );                                                   // turn off
    339340                return os;
    340341        } // nonl
     
    375376        ostype & ?|?( ostype & os, T arg, Params rest ) {
    376377                (ostype &)(os | arg);                                                   // print first argument
    377                 sepSetCur( os, sepGetTuple( os ) );                             // switch to tuple separator
     378                $sepSetCur( os, sepGetTuple( os ) );                    // switch to tuple separator
    378379                (ostype &)(os | rest);                                                  // print remaining arguments
    379                 sepSetCur( os, sepGet( os ) );                                  // switch to regular separator
     380                $sepSetCur( os, sepGet( os ) );                                 // switch to regular separator
    380381                return os;
    381382        } // ?|?
     
    383384                // (ostype &)(?|?( os, arg, rest )); ends( os );
    384385                (ostype &)(os | arg);                                                   // print first argument
    385                 sepSetCur( os, sepGetTuple( os ) );                             // switch to tuple separator
     386                $sepSetCur( os, sepGetTuple( os ) );                    // switch to tuple separator
    386387                (ostype &)(os | rest);                                                  // print remaining arguments
    387                 sepSetCur( os, sepGet( os ) );                                  // switch to regular separator
     388                $sepSetCur( os, sepGet( os ) );                                 // switch to regular separator
    388389                ends( os );
    389390        } // ?|?
     
    414415forall( dtype ostype | ostream( ostype ) ) { \
    415416        ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \
    416                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); \
     417                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \
    417418\
    418419                if ( f.base == 'b' || f.base == 'B' ) {                 /* bespoke binary format */ \
     
    513514forall( dtype ostype | ostream( ostype ) ) { \
    514515        ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \
    515                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); \
     516                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \
    516517                char fmtstr[sizeof(DFMTP)];                                             /* sizeof includes '\0' */ \
    517518                if ( ! f.flags.pc ) memcpy( &fmtstr, DFMTNP, sizeof(DFMTNP) ); \
     
    536537                return os; \
    537538        } /* ?|? */ \
     539\
    538540        void ?|?( ostype & os, _Ostream_Manip(T) f ) { (ostype &)(os | f); ends( os ); } \
    539541} // distribution
     
    555557                } // if
    556558
    557                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     559                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    558560
    559561                #define CFMTNP "% * "
     
    571573                return os;
    572574        } // ?|?
     575
    573576        void ?|?( ostype & os, _Ostream_Manip(char) f ) { (ostype &)(os | f); ends( os ); }
    574577} // distribution
     
    592595                } // if
    593596
    594                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     597                if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
    595598
    596599                #define SFMTNP "% * "
     
    616619                return os;
    617620        } // ?|?
     621
    618622        void ?|?( ostype & os, _Ostream_Manip(const char *) f ) { (ostype &)(os | f); ends( os ); }
    619623} // distribution
     
    735739        } // ?|?
    736740
    737         // istype & ?|?( istype & is, const char * fmt ) {
     741        // istype & ?|?( istype & is, const char fmt[] ) {
    738742        //      fmt( is, fmt, "" );
    739743        //      return is;
  • libcfa/src/iostream.hfa

    r0f5da65 r3ecfa13  
    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 : Fri Feb  7 17:53:52 2020
     13// Update Count     : 336
    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
     
    113113        void ?|?( ostype &, long double _Complex );
    114114
    115         ostype & ?|?( ostype &, const char * );
    116         void ?|?( ostype &, const char * );
     115        ostype & ?|?( ostype &, const char [] );
     116        void ?|?( ostype &, const char [] );
    117117        // ostype & ?|?( ostype &, const char16_t * );
    118118#if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous
     
    256256
    257257static 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 } }; }
     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 } }; }
    263263        _Ostream_Manip(const char *) & wd( unsigned int w, _Ostream_Manip(const char *) & fmt ) { fmt.wd = w; return fmt; }
    264264        _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; }
     
    281281        int fail( istype & );
    282282        int eof( istype & );
    283         void open( istype & is, const char * name );
     283        void open( istype & is, const char name[] );
    284284        void close( istype & is );
    285285        istype & read( istype &, char *, size_t );
     
    316316        istype & ?|?( istype &, long double _Complex & );
    317317
    318 //      istype & ?|?( istype &, const char * );
     318//      istype & ?|?( istype &, const char [] );
    319319        istype & ?|?( istype &, char * );
    320320
     
    343343static inline {
    344344        _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 } }; }
     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 } }; }
    351351        _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 } }; }
     352        _Istream_Cstr wdi( unsigned int w, char s[] ) { return (_Istream_Cstr)@{ s, 0p, w, { .all : 0 } }; }
    353353        _Istream_Cstr & wdi( unsigned int w, _Istream_Cstr & fmt ) { fmt.wd = w; return fmt; }
    354354} // distribution
  • libcfa/src/math.hfa

    r0f5da65 r3ecfa13  
    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/startup.cfa

    r0f5da65 r3ecfa13  
    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

    r0f5da65 r3ecfa13  
    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

    r0f5da65 r3ecfa13  
    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

    r0f5da65 r3ecfa13  
    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

    r0f5da65 r3ecfa13  
    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

    r0f5da65 r3ecfa13  
    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

    r0f5da65 r3ecfa13  
    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

    r0f5da65 r3ecfa13  
    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

    r0f5da65 r3ecfa13  
    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

    r0f5da65 r3ecfa13  
    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

    r0f5da65 r3ecfa13  
    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) -------------------------
  • src/Common/PassVisitor.impl.h

    r0f5da65 r3ecfa13  
    33023302        VISIT_START( node );
    33033303
    3304         indexerAddStruct( node->name );
     3304        indexerAddUnion( node->name );
    33053305
    33063306        {
     
    33173317        VISIT_START( node );
    33183318
    3319         indexerAddStruct( node->name );
     3319        indexerAddUnion( node->name );
    33203320
    33213321        {
     
    33323332        MUTATE_START( node );
    33333333
    3334         indexerAddStruct( node->name );
     3334        indexerAddUnion( node->name );
    33353335
    33363336        {
  • src/Concurrency/Keywords.cc

    r0f5da65 r3ecfa13  
    716716                                new UntypedExpr(
    717717                                        new NameExpr( "__thrd_start" ),
    718                                         { new VariableExpr( param ) }
     718                                        { new VariableExpr( param ), new NameExpr("main") }
    719719                                )
    720720                        )
  • src/Parser/ParseNode.h

    r0f5da65 r3ecfa13  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Dec 16 07:46:01 2019
    13 // Update Count     : 888
     12// Last Modified On : Fri Feb  7 17:56:02 2020
     13// Update Count     : 891
    1414//
    1515
     
    449449                                * out++ = result;
    450450                        } else {
    451                                 assertf(false, "buildList unknown type");
     451                                SemanticError( cur->location, "type specifier declaration in forall clause is currently unimplemented." );
    452452                        } // if
    453453                } catch( SemanticErrorException & e ) {
  • src/Parser/lex.ll

    r0f5da65 r3ecfa13  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Sat Feb  1 07:16:44 2020
    13  * Update Count     : 724
     12 * Last Modified On : Fri Feb  7 19:02:43 2020
     13 * Update Count     : 725
    1414 */
    1515
     
    330330                                /* identifier */
    331331{identifier}    { IDENTIFIER_RETURN(); }
    332 "``"{identifier}"``" {                                                                  // CFA
    333         yytext[yyleng - 2] = '\0'; yytext += 2;                         // SKULLDUGGERY: remove backquotes (ok to shorten?)
     332"``"{identifier} {                                                                              // CFA
     333        yytext[yyleng] = '\0'; yytext += 2;                                     // SKULLDUGGERY: remove backquotes (ok to shorten?)
    334334        IDENTIFIER_RETURN();
    335335}
  • src/main.cc

    r0f5da65 r3ecfa13  
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Dec 16 17:55:53 2019
    13 // Update Count     : 627
     12// Last Modified On : Sat Feb  8 08:33:50 2020
     13// Update Count     : 633
    1414//
    1515
     
    105105
    106106static void backtrace( int start ) {                                    // skip first N stack frames
    107         enum { Frames = 50 };
     107        enum { Frames = 50, };                                                          // maximum number of stack frames
    108108        void * array[Frames];
    109         int size = ::backtrace( array, Frames );
     109        size_t size = ::backtrace( array, Frames );
    110110        char ** messages = ::backtrace_symbols( array, size ); // does not demangle names
    111111
     
    114114
    115115        // skip last 2 stack frames after main
    116         for ( int i = start; i < size - 2 && messages != nullptr; i += 1 ) {
     116        for ( unsigned int i = start; i < size - 2 && messages != nullptr; i += 1 ) {
    117117                char * mangled_name = nullptr, * offset_begin = nullptr, * offset_end = nullptr;
    118118
     
    180180} // sigSegvBusHandler
    181181
     182static void sigFpeHandler( SIGPARMS ) {
     183        const char * msg;
     184
     185        switch ( sfp->si_code ) {
     186          case FPE_INTDIV: case FPE_FLTDIV: msg = "divide by zero"; break;
     187          case FPE_FLTOVF: msg = "overflow"; break;
     188          case FPE_FLTUND: msg = "underflow"; break;
     189          case FPE_FLTRES: msg = "inexact result"; break;
     190          case FPE_FLTINV: msg = "invalid operation"; break;
     191          default: msg = "unknown";
     192        } // choose
     193        cerr << "Computation error " << msg << " at location " << sfp->si_addr << endl
     194                 << "Possible cause is constant-expression evaluation invalid." << endl;
     195        backtrace( 2 );                                                                         // skip first 2 stack frames
     196        abort();                                                                                        // cause core dump for debugging
     197} // sigFpeHandler
     198
    182199static void sigAbortHandler( SIGPARMS ) {
    183200        backtrace( 6 );                                                                         // skip first 6 stack frames
     
    193210        Signal( SIGSEGV, sigSegvBusHandler, SA_SIGINFO );
    194211        Signal( SIGBUS, sigSegvBusHandler, SA_SIGINFO );
     212        Signal( SIGFPE, sigFpeHandler, SA_SIGINFO );
    195213        Signal( SIGABRT, sigAbortHandler, SA_SIGINFO );
    196214
  • tests/expression.cfa

    r0f5da65 r3ecfa13  
    11struct S { int i; };
    2 void ?{}( S & s, int i ) {}
     2void ?{}( S & s, int i ) { s.i = i; }
    33int ?`mary( int );
    44int ?`mary( S );
     
    1010    int a[3] = { 0, 0, 0 };
    1111    S s = { 3 }, * ps = &s;
    12     [int] t;
     12    [int] t = { 3 };
    1313    * [int] pt = &t;
    14     int i = 3, j = 4;
     14    int i = 1, j = 2;
    1515
    1616    // operators
    1717
    18     ! i;
     18    !i;
    1919    ~i;
    2020    +i;
     
    2626    ps--;
    2727
    28     i+j;
    29     i-j;
    30     i*j;
     28    i + j;
     29    i - j;
     30    i * j;
    3131
    32     i/j;
    33     i%j;
    34     i^j;
    35     i&j;
    36     i|j;
    37     i<j;
    38     i>j;
    39     i=j;
     32    i / j;
     33    i % j;
     34    i ^ j;
     35    i & j;
     36    i | j;
     37    i < j;
     38    i > j;
     39    i = j;
    4040
    41     i==j;
    42     i!=j;
    43     i<<j;
    44     i>>j;
    45     i<=j;
    46     i>=j;
    47     i&&j;
    48     i||j;
     41    i == j;
     42    i != j;
     43    i << j;
     44    i >> j;
     45    i <= j;
     46    i >= j;
     47    i && j;
     48    i || j;
    4949    ps->i;
    5050
    51     i*=j;
    52     i/=j;
    53     i%=j;
    54     i+=j;
    55     i-=j;
    56     i&=j;
    57     i|=j;
    58     i^=j;
    59     i<<=j;
    60     i>>=j;
     51    i *= j;
     52    i /= j;
     53    i %= j;
     54    i += j;
     55    i -= j;
     56    i &= j;
     57    i |= j;
     58    i ^= j;
     59    i <<= j;
     60    i >>= j;
    6161
    62     i?i:j;
     62    i ? i : j;
    6363
    6464    // postfix function call
  • tests/labelledExit.cfa

    r0f5da65 r3ecfa13  
    1010// Created On       : Wed Aug 10 07:29:39 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Oct 25 17:41:51 2019
    13 // Update Count     : 7
     12// Last Modified On : Wed Feb  5 16:49:48 2020
     13// Update Count     : 9
    1414//
    1515
     
    162162
    163163        // computed goto
    164         // {
    165         //      void *array[] = { &&foo, &&bar, &&hack };
    166         //   foo: bar: hack:
    167         //      &&foo;
    168         //      &&bar;
    169         //      goto *array[i];
    170         // }
     164        {
     165                void *array[] = { &&foo, &&bar, &&hack };
     166          foo: bar: hack:
     167                &&foo;
     168                &&bar;
     169                goto *array[i];
     170        }
    171171
    172172  Q: if ( i > 5 ) {
  • tests/quotedKeyword.cfa

    r0f5da65 r3ecfa13  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Feb  1 00:02:22 2020
    13 // Update Count     : 24
     12// Last Modified On : Fri Feb  7 19:07:07 2020
     13// Update Count     : 25
    1414//
    1515
     
    1717
    1818struct {
    19         int ``otype``;
    20         int ``struct``;
     19        int ``otype;
     20        int ``struct;
    2121} st = { 10, 10 };
    2222
    23 typedef int ``forall``;
    24 ``forall`` xxx = 10;
     23typedef int ``forall;
     24``forall xxx = 10;
    2525
    26 int ``_Alignas``, ``_Alignof``, ``__alignof``, ``__alignof__``, ``asm``, ``__asm``, ``__asm__``, ``_At``, ``_Atomic``, ``__attribute``,
    27         ``__attribute__``, ``auto``, ``_Bool``, ``break``, ``case``, ``catch``, ``catchResume``, ``char``, ``choose``, ``_Complex``, ``__complex``,
    28         ``__complex__``, ``const``, ``__const``, ``__const__``, ``continue``, ``default``, ``disable``, ``do``, ``double``, ``dtype``, ``else``,
    29         ``enable``, ``enum``, ``__extension__``, ``extern``, ``fallthru``, ``finally``, ``float``, ``__float128``, ``for``, ``forall``, ``fortran``,
    30         ``ftype``, ``_Generic``, ``goto``, ``if``, ``_Imaginary``, ``__imag``, ``__imag__``, ``inline``, ``__inline``, ``__inline__``, ``int``,
    31         ``__int128``, ``__label__``, ``long``, ``lvalue``, ``_Noreturn``, ``__builtin_offsetof``, ``otype``, ``register``, ``restrict``,
    32         ``__restrict``, ``__restrict__``, ``return``, ``short``, ``signed``, ``__signed``, ``__signed__``, ``sizeof``, ``static``,
    33         ``_Static_assert``, ``struct``, ``switch``, ``_Thread_local``, ``throw``, ``throwResume``, ``trait``, ``try``, ``typedef``,
    34         ``typeof``, ``__typeof``, ``__typeof__``, ``union``, ``unsigned``, ``__builtin_va_list``, ``void``, ``volatile``, ``__volatile``,
    35         ``__volatile__``, ``while``;
     26int ``_Alignas, ``_Alignof, ``__alignof, ``__alignof__, ``asm, ``__asm, ``__asm__, ``_At, ``_Atomic, ``__attribute,
     27        ``__attribute__, ``auto, ``_Bool, ``break, ``case, ``catch, ``catchResume, ``char, ``choose, ``_Complex, ``__complex,
     28        ``__complex__, ``const, ``__const, ``__const__, ``continue, ``default, ``disable, ``do, ``double, ``dtype, ``else,
     29        ``enable, ``enum, ``__extension__, ``extern, ``fallthru, ``finally, ``float, ``__float128, ``for, ``forall, ``fortran,
     30        ``ftype, ``_Generic, ``goto, ``if, ``_Imaginary, ``__imag, ``__imag__, ``inline, ``__inline, ``__inline__, ``int,
     31        ``__int128, ``__label__, ``long, ``lvalue, ``_Noreturn, ``__builtin_offsetof, ``otype, ``register, ``restrict,
     32        ``__restrict, ``__restrict__, ``return, ``short, ``signed, ``__signed, ``__signed__, ``sizeof, ``static,
     33        ``_Static_assert, ``struct, ``switch, ``_Thread_local, ``throw, ``throwResume, ``trait, ``try, ``typedef,
     34        ``typeof, ``__typeof, ``__typeof__, ``union, ``unsigned, ``__builtin_va_list, ``void, ``volatile, ``__volatile,
     35        ``__volatile__, ``while;
    3636
    3737int main() {
    38         int ``if`` = 0;
    39         ``catch`` = 1;
    40         st.``otype`` = 2;
    41         st.``struct`` = 3;
    42         ``throw`` = 4;
    43         sout | ``catch`` + st.``otype`` + st.``struct`` + ``throw``;
     38        int ``if = 0;
     39        ``catch = 1;
     40        st.``otype = 2;
     41        st.``struct = 3;
     42        ``throw = 4;
     43        sout | ``catch + st.``otype + st.``struct + ``throw;
    4444}
    4545
Note: See TracChangeset for help on using the changeset viewer.