Changeset 3b56166


Ignore:
Timestamp:
Feb 10, 2020, 11:17:38 AM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
3966d9a, 41efd33
Parents:
807a632 (diff), d231700 (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:
29 added
5 deleted
219 edited
8 moved

Legend:

Unmodified
Added
Removed
  • Jenkins/FullBuild

    r807a632 r3b56166  
    1717
    1818                                parallel (
     19                                        clang_x86: { trigger_build( 'gcc-8',   'x86' ) },
     20                                        gcc_5_x86: { trigger_build( 'gcc-7',   'x86' ) },
     21                                        gcc_6_x86: { trigger_build( 'gcc-6',   'x86' ) },
     22                                        gcc_9_x64: { trigger_build( 'gcc-9',   'x64' ) },
     23                                        gcc_8_x64: { trigger_build( 'gcc-8',   'x64' ) },
     24                                        gcc_7_x64: { trigger_build( 'gcc-7',   'x64' ) },
    1925                                        gcc_6_x64: { trigger_build( 'gcc-6',   'x64' ) },
    20                                         gcc_6_x86: { trigger_build( 'gcc-6',   'x86' ) },
    2126                                        gcc_5_x64: { trigger_build( 'gcc-5',   'x64' ) },
    22                                         gcc_5_x86: { trigger_build( 'gcc-5',   'x86' ) },
    2327                                        clang_x64: { trigger_build( 'clang',   'x64' ) },
    24                                         clang_x86: { trigger_build( 'clang',   'x86' ) },
    2528                                )
    2629                        }
  • Jenkinsfile

    r807a632 r3b56166  
    102102
    103103                echo GitLogMessage()
     104
     105                // This is a complete hack but it solves problems with automake thinking it needs to regenerate makefiles
     106                // We fudged automake/missing to handle that but automake stills bakes prints inside the makefiles
     107                // and these cause more problems.
     108                sh 'find . -name Makefile.in -exec touch {} +'
    104109        }
    105110}
     
    358363        BuildSettings(java.util.Collections$UnmodifiableMap param, String branch) {
    359364                switch( param.Compiler ) {
     365                        case 'gcc-9':
     366                                this.Compiler = new CC_Desc('gcc-9', 'g++-9', 'gcc-9')
     367                        break
     368                        case 'gcc-8':
     369                                this.Compiler = new CC_Desc('gcc-8', 'g++-8', 'gcc-8')
     370                        break
     371                        case 'gcc-7':
     372                                this.Compiler = new CC_Desc('gcc-7', 'g++-7', 'gcc-7')
     373                        break
    360374                        case 'gcc-6':
    361375                                this.Compiler = new CC_Desc('gcc-6', 'g++-6', 'gcc-6')
     
    368382                        break
    369383                        case 'clang':
    370                                 this.Compiler = new CC_Desc('clang', 'clang++', 'gcc-6')
     384                                this.Compiler = new CC_Desc('clang', 'clang++-6.0', 'gcc-6')
    371385                        break
    372386                        default :
     
    430444                                        description: 'Which compiler to use',                                   \
    431445                                        name: 'Compiler',                                                                       \
    432                                         choices: 'gcc-6\ngcc-5\ngcc-4.9\nclang',                                        \
    433                                         defaultValue: 'gcc-6',                                                          \
     446                                        choices: 'gcc-9\ngcc-8\ngcc-7\ngcc-6\ngcc-5\ngcc-4.9\nclang',                                   \
     447                                        defaultValue: 'gcc-8',                                                          \
    434448                                ],                                                                                              \
    435449                                [$class: 'ChoiceParameterDefinition',                                           \
  • benchmark/Makefile.am

    r807a632 r3b56166  
    1111## Created On       : Sun May 31 09:08:15 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Mon Jul 29 18:02:19 2019
    14 ## Update Count     : 54
     13## Last Modified On : Sat Jan 25 09:20:44 2020
     14## Update Count     : 255
    1515###############################################################################
    1616
     
    2828BENCH_V_CFA = $(__bench_v_CFA_$(__quiet))
    2929BENCH_V_CXX = $(__bench_v_CXX_$(__quiet))
     30BENCH_V_UPP = $(__bench_v_UPP_$(__quiet))
    3031BENCH_V_GOC = $(__bench_v_GOC_$(__quiet))
     32BENCH_V_RUSTC = $(__bench_v_RUSTC_$(__quiet))
     33BENCH_V_NODEJS = $(__bench_v_NODEJS_$(__quiet))
    3134BENCH_V_JAVAC = $(__bench_v_JAVAC_$(__quiet))
    32 BENCH_V_UPP = $(__bench_v_UPP_$(__quiet))
    3335
    3436__quiet = verbose
     
    3638__bench_v_CFA_quiet = @
    3739__bench_v_CXX_quiet = @
     40__bench_v_UPP_quiet = @
    3841__bench_v_GOC_quiet = @
     42__bench_v_RUSTC_quiet = @
    3943__bench_v_JAVAC_quiet = @
    40 __bench_v_UPP_quiet = @
    4144__bench_v_CC_verbose = $(AM_V_CC)
    4245__bench_v_CFA_verbose = $(AM_V_CFA)
    4346__bench_v_CXX_verbose = $(AM_V_CXX)
     47__bench_v_UPP_verbose = $(AM_V_UPP)
    4448__bench_v_GOC_verbose = $(AM_V_GOC)
     49__bench_v_RUSTC_verbose = $(AM_V_RUSTC)
     50__bench_v_NODEJS_verbose = $(AM_V_NODEJS)
    4551__bench_v_JAVAC_verbose = $(AM_V_JAVAC)
    46 __bench_v_UPP_verbose = $(AM_V_UPP)
    4752
    4853
     
    5156STATS    = ${abs_top_srcdir}/tools/stat.py
    5257# NEED AT LEAST 4 DATA VALUES FOR BENCHMARKS BECAUSE THE MAX AND MIN VALUES ARE REMOVED
    53 repeats  = 5 # 31 for benchmarks
     58repeats  = 13 # 31 for benchmarks
    5459arch     = x64
    5560skipcompile = no
     
    6267
    6368dummyC.c:
    64         @echo "int main() { return 0; }" > ${@}
     69        echo "int main() { return 0; }" > ${@}
    6570
    6671dummyCXX.cpp:
    67         @echo "int main() { return 0; }" > ${@}
    68 
     72        echo "int main() { return 0; }" > ${@}
     73
     74#.SILENT:               # do not print recipe
     75.ONESHELL:              # use one shell to execute recipe
    6976.NOTPARALLEL:
    70 .PHONY: compile.csv ctxswitch.csv mutex.csv signal.csv
    71 
    72 ## =========================================================================================================
    73 all : ctxswitch$(EXEEXT) mutex$(EXEEXT) signal$(EXEEXT) waitfor$(EXEEXT) creation$(EXEEXT)
     77.PHONY: compile.csv basic.csv ctxswitch.csv mutex.csv schedint.csv
     78
     79## =========================================================================================================
     80
     81all : basic$(EXEEXT) ctxswitch$(EXEEXT) mutex$(EXEEXT) schedint$(EXEEXT) schedext$(EXEEXT) creation$(EXEEXT)
     82
     83basic_loop_DURATION = 15000000000
     84basic_function_DURATION = 10000000000
     85basic_tls_fetch_add_DURATION = 10000000000
     86basic_DURATION = 250000000
     87
     88ctxswitch_pthread_DURATION = 25000000
     89ctxswitch_rust_thread_DURATION = $(ctxswitch_pthread_DURATION)
     90ctxswitch_cfa_generator_DURATION = 5000000000
     91ctxswitch_nodejs_await_DURATION = 5000000
     92ctxswitch_DURATION = 100000000
     93
     94#mutex_java_DURATION = 10000000
     95mutex_DURATION = 50000000
     96
     97schedint_pthread_DURATION = 1000000
     98schedint_java_DURATION = $(schedint_pthread_DURATION)
     99schedint_rust_DURATION = $(schedint_pthread_DURATION)
     100schedint_DURATION = 10000000
     101
     102schedext_DURATION = 10000000
     103
     104creation_pthread_DURATION = 250000
     105creation_rust_thread_DURATION = ${creation_pthread_DURATION}
     106creation_java_thread_DURATION = ${creation_pthread_DURATION}
     107creation_cfa_coroutine_DURATION = 100000000
     108creation_cfa_coroutine_eager_DURATION = 10000000
     109creation_upp_coroutine_DURATION = ${creation_cfa_coroutine_eager_DURATION}
     110creation_cfa_thread_DURATION = 10000000
     111creation_upp_thread_DURATION = ${creation_cfa_thread_DURATION}
     112creation_DURATION = 10000000
    74113
    75114%.run : %$(EXEEXT) ${REPEAT}
    76         @rm -f .result.log
    77         @echo "------------------------------------------------------"
    78         @echo $<
    79         @${REPEAT} ${repeats} ./a.out | tee -a .result.log
    80         @${STATS} .result.log
    81         @echo "------------------------------------------------------"
    82         @rm -f a.out .result.log *.class
     115        rm -f .result.log
     116        echo "------------------------------------------------------"
     117        echo $<
     118        ${REPEAT} ${repeats} -- ./a.out\
     119                $(if ${$(subst -,_,$(basename $@))_DURATION},\
     120                        ${$(subst -,_,$(basename $@))_DURATION},\
     121                        ${$(firstword $(subst -, ,$(basename $@)))_DURATION}) | tee -a .result.log
     122        ${STATS} .result.log
     123        echo "------------------------------------------------------"
     124        rm -f a.out .result.log *.class
     125
     126#       ${REPEAT} ${repeats} -- /usr/bin/time -f "%Uu %Ss %Er %Mkb" ./a.out
    83127
    84128%.runquiet :
    85         @+make $(basename $@) CFLAGS="-w" __quiet=quiet
    86         @taskset -c 1 ./a.out
    87         @rm -f a.out
     129        +make $(basename $@) CFLAGS="-w" __quiet=quiet
     130        taskset -c 1 ./a.out
     131        rm -f a.out
    88132
    89133%.make :
    90         @printf "${PRINT_FORMAT}" $(basename $(subst compile-,,$@))
    91         @+/usr/bin/time -f ${TIME_FORMAT} make $(basename $@) 2>&1
     134        printf "${PRINT_FORMAT}" $(basename $(subst compile-,,$@))
     135        +/usr/bin/time -f ${TIME_FORMAT} make $(basename $@) 2>&1
    92136
    93137${REPEAT} :
    94         @+make -C ${abs_top_builddir}/tools repeat
     138        +make -C ${abs_top_builddir}/tools repeat
    95139
    96140## =========================================================================================================
     
    100144jenkins$(EXEEXT):
    101145@DOifskipcompile@
    102         @+make compile.csv
    103         @-+make compile.diff.csv
     146        +make compile.csv
     147        -+make compile.diff.csv
    104148@DOendif@
    105         @+make ctxswitch.csv
    106         @-+make ctxswitch.diff.csv
    107         @+make mutex.csv
    108         @-+make mutex.diff.csv
    109         @+make signal.csv
    110         @-+make signal.diff.csv
     149        +make basic.csv
     150        -+make basic.diff.csv
     151        +make ctxswitch.csv
     152        -+make ctxswitch.diff.csv
     153        +make mutex.csv
     154        -+make mutex.diff.csv
     155        +make schedint.csv
     156        -+make schedint.diff.csv
    111157@DOifskipcompile@
    112158        cat compile.csv
    113159        -cat compile.diff.csv
    114160@DOendif@
     161        cat basic.csv
     162        -cat basic.diff.csv
    115163        cat ctxswitch.csv
    116164        -cat ctxswitch.diff.csv
    117165        cat mutex.csv
    118166        -cat mutex.diff.csv
    119         cat signal.csv
    120         -cat signal.diff.csv
     167        cat schedint.csv
     168        -cat schedint.diff.csv
    121169
    122170compile.csv:
    123         @echo "array,attributes,empty,expression,io,monitor,operators,typeof" > $@
    124         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-array.make >> $@
    125         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-attributes.make >> $@
    126         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-empty.make >> $@
    127         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-expression.make >> $@
    128         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-io.make >> $@
    129         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-monitor.make >> $@
    130         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-operators.make >> $@
    131         @+make TIME_FORMAT='%e' PRINT_FORMAT='' compile-typeof.make >> $@
    132         @$(srcdir)/fixcsv.sh $@
     171        echo "array,attributes,empty,expression,io,monitor,operators,typeof" > $@
     172        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-array.make >> $@
     173        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-attributes.make >> $@
     174        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-empty.make >> $@
     175        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-expression.make >> $@
     176        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-io.make >> $@
     177        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-monitor.make >> $@
     178        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-operators.make >> $@
     179        +make TIME_FORMAT='%e' PRINT_FORMAT='' compile-typeof.make >> $@
     180        $(srcdir)/fixcsv.sh $@
     181
     182basic.csv:
     183        echo "generator,coroutine,thread" > $@
     184        +make basic-cfa_generator.runquiet >> $@ && echo -n ',' >> $@
     185        +make basic-cfa_coroutine.runquiet >> $@ && echo -n ',' >> $@
     186        +make basic-cfa_thread.runquiet >> $@
     187        $(srcdir)/fixcsv.sh $@
    133188
    134189ctxswitch.csv:
    135         @echo "generator,coroutine,thread" > $@
    136         @+make ctxswitch-cfa_generator.runquiet >> $@ && echo -n ',' >> $@
    137         @+make ctxswitch-cfa_coroutine.runquiet >> $@ && echo -n ',' >> $@
    138         @+make ctxswitch-cfa_thread.runquiet >> $@
    139         @$(srcdir)/fixcsv.sh $@
     190        echo "generator,coroutine,thread" > $@
     191        +make ctxswitch-cfa_generator.runquiet >> $@ && echo -n ',' >> $@
     192        +make ctxswitch-cfa_coroutine.runquiet >> $@ && echo -n ',' >> $@
     193        +make ctxswitch-cfa_thread.runquiet >> $@
     194        $(srcdir)/fixcsv.sh $@
    140195
    141196mutex.csv:
    142         @echo "1-monitor,2-monitor" > $@
    143         @+make mutex-cfa1.runquiet >> $@ && echo -n ',' >> $@
    144         @+make mutex-cfa2.runquiet >> $@
    145         @$(srcdir)/fixcsv.sh $@
    146 
    147 signal.csv:
    148         @echo "signal-1,signal-2,waitfor-1,waitfor-2" > $@
    149         @+make signal-cfa1.runquiet >> $@ && echo -n ',' >> $@
    150         @+make signal-cfa2.runquiet >> $@ && echo -n ',' >> $@
    151         @+make waitfor-cfa1.runquiet >> $@ && echo -n ',' >> $@
    152         @+make waitfor-cfa2.runquiet >> $@
    153         @$(srcdir)/fixcsv.sh $@
     197        echo "1-monitor,2-monitor" > $@
     198        +make mutex-cfa1.runquiet >> $@ && echo -n ',' >> $@
     199        +make mutex-cfa2.runquiet >> $@
     200        $(srcdir)/fixcsv.sh $@
     201
     202schedint.csv:
     203        echo "schedint-1,schedint-2,schedext-1,schedext-2" > $@
     204        +make schedint-cfa1.runquiet >> $@ && echo -n ',' >> $@
     205        +make schedint-cfa2.runquiet >> $@ && echo -n ',' >> $@
     206        +make schedext-cfa1.runquiet >> $@ && echo -n ',' >> $@
     207        +make schedext-cfa2.runquiet >> $@
     208        $(srcdir)/fixcsv.sh $@
    154209
    155210%.diff.csv: %.csv
    156         @test -e $(srcdir)/baselines/$(arch)/$< || (echo "Error : Missing baseline for ${<}" && false)
    157         @$(srcdir)/baselines/calc.py $(srcdir)/baselines/$(arch)/$(<) $(<) > $@
    158 
    159 
    160 ## =========================================================================================================
    161 loop$(EXEEXT):
    162         $(BENCH_V_CC)$(COMPILE) -DBENCH_N=5000000000 $(srcdir)/loop.c
    163 
    164 function$(EXEEXT):
    165         $(BENCH_V_CC)$(COMPILE) -DBENCH_N=5000000000 $(srcdir)/function.c
    166 
    167 fetch_add$(EXEEXT):
    168         $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000  $(srcdir)/fetch_add.c
    169 
    170 ttst_lock$(EXEEXT):
    171         $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000  $(srcdir)/ttst_lock.c
    172 
    173 tls-fetch_add$(EXEEXT):
    174         $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000  $(srcdir)/tls-fetch_add.c
    175 
    176 ## =========================================================================================================
    177 CTXSWITCH_DEPEND  =                 \
    178         loop.run                                \
    179         function.run                    \
    180         fetch_add.run                   \
    181         ttst_lock.run                   \
    182         tls-fetch_add.run                       \
    183         ctxswitch-pthread.run           \
     211        test -e $(srcdir)/baselines/$(arch)/$< || (echo "Error : Missing baseline for ${<}" && false)
     212        $(srcdir)/baselines/calc.py $(srcdir)/baselines/$(arch)/$(<) $(<) > $@
     213
     214## =========================================================================================================
     215
     216BASIC_DEPEND  =                                 \
     217        basic-loop.run                          \
     218        basic-function.run                      \
     219        basic-fetch_add.run                     \
     220        basic-ttst_lock.run                     \
     221        basic-tls-fetch_add.run
     222
     223basic-loop$(EXEEXT):
     224        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/loop.c
     225
     226basic-function$(EXEEXT):
     227        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/function.c
     228
     229basic-fetch_add$(EXEEXT):
     230        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/fetch_add.c
     231
     232basic-ttst_lock$(EXEEXT):
     233        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/ttst_lock.c
     234
     235basic-tls-fetch_add$(EXEEXT):
     236        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/tls_fetch_add.c
     237
     238basic$(EXEEXT): $(BASIC_DEPEND)
     239
     240## =========================================================================================================
     241
     242CTXSWITCH_DEPEND  =                     \
    184243        ctxswitch-cfa_generator.run     \
    185244        ctxswitch-cfa_coroutine.run     \
     
    188247        ctxswitch-upp_coroutine.run     \
    189248        ctxswitch-upp_thread.run        \
    190         ctxswitch-goroutine.run         \
    191         ctxswitch-java_thread.run
    192 
     249        ctxswitch-python_coroutine.run  \
     250        ctxswitch-nodejs_coroutine.run  \
     251        ctxswitch-nodejs_await.run      \
     252        ctxswitch-goroutine_thread.run  \
     253        ctxswitch-rust_thread.run       \
     254        ctxswitch-nodejs_coroutine.run  \
     255        ctxswitch-java_thread.run       \
     256        ctxswitch-pthread.run
    193257
    194258if WITH_LIBFIBRE
    195 CTXSWITCH_DEPEND  +=           \
    196         ctxswitch-kos_fibre.run  \
     259CTXSWITCH_DEPEND  +=                    \
     260        ctxswitch-kos_fibre.run         \
    197261        ctxswitch-kos_fibre2.run
    198 
    199262
    200263ctxswitch-kos_fibre$(EXEEXT):
     
    207270ctxswitch$(EXEEXT): $(CTXSWITCH_DEPEND)
    208271
    209 ctxswitch-pthread$(EXEEXT):
    210         $(BENCH_V_CC)$(COMPILE)    -DBENCH_N=50000000 $(srcdir)/ctxswitch/pthreads.c
    211 
    212272ctxswitch-cfa_generator$(EXEEXT):
    213         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_gen.cfa
     273        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_gen.cfa
    214274
    215275ctxswitch-cfa_coroutine$(EXEEXT):
    216         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_cor.cfa
     276        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_cor.cfa
    217277
    218278ctxswitch-cfa_thread$(EXEEXT):
    219         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_thrd.cfa
     279        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_thrd.cfa
    220280
    221281ctxswitch-cfa_thread2$(EXEEXT):
    222         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_thrd2.cfa
     282        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_thrd2.cfa
    223283
    224284ctxswitch-upp_coroutine$(EXEEXT):
    225         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/upp_cor.cc
     285        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/ctxswitch/upp_cor.cc
    226286
    227287ctxswitch-upp_thread$(EXEEXT):
    228         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/upp_thrd.cc
    229 
    230 ctxswitch-goroutine$(EXEEXT):
     288        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/ctxswitch/upp_thrd.cc
     289
     290ctxswitch-python_coroutine$(EXEEXT):
     291        echo "#!/bin/sh" > a.out
     292        echo "python3.7 $(srcdir)/ctxswitch/python_cor.py" >> a.out
     293        chmod a+x a.out
     294
     295ctxswitch-nodejs_coroutine$(EXEEXT):
     296        echo "#!/bin/sh" > a.out
     297        echo "nodejs $(srcdir)/ctxswitch/node_cor.js" >> a.out
     298        chmod a+x a.out
     299
     300ctxswitch-nodejs_await$(EXEEXT):
     301        echo "#!/bin/sh" > a.out
     302        echo "nodejs $(srcdir)/ctxswitch/node_await.js" >> a.out
     303        chmod a+x a.out
     304
     305ctxswitch-goroutine_thread$(EXEEXT):
    231306        $(BENCH_V_GOC)go build -o a.out $(srcdir)/ctxswitch/goroutine.go
     307
     308ctxswitch-rust_thread$(EXEEXT):
     309        $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/ctxswitch/rust_thrd.rs
    232310
    233311ctxswitch-java_thread$(EXEEXT):
    234312        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/ctxswitch/JavaThread.java
    235         @echo "#!/bin/sh" > a.out
    236         @echo "java JavaThread" >> a.out
    237         @chmod a+x a.out
    238 
    239 ## =========================================================================================================
    240 mutex$(EXEEXT) :\
    241         loop.run                        \
    242         function.run            \
    243         fetch_add.run           \
    244         mutex-pthread_lock.run  \
    245         mutex-upp.run           \
     313        echo "#!/bin/sh" > a.out
     314        echo "java JavaThread" >> a.out
     315        chmod a+x a.out
     316
     317ctxswitch-pthread$(EXEEXT):
     318        $(BENCH_V_CC)$(COMPILE) $(srcdir)/ctxswitch/pthreads.c
     319
     320## =========================================================================================================
     321
     322mutex$(EXEEXT) :                \
    246323        mutex-cfa1.run          \
    247324        mutex-cfa2.run          \
    248325        mutex-cfa4.run          \
    249         mutex-java_thread.run
    250 
    251 mutex-pthread_lock$(EXEEXT):
    252         $(BENCH_V_CC)$(COMPILE)    -DBENCH_N=50000000 $(srcdir)/mutex/pthreads.c
     326        mutex-upp.run           \
     327        mutex-go.run            \
     328        mutex-rust.run          \
     329        mutex-java.run          \
     330        mutex-pthread.run
     331
     332mutex-pthread$(EXEEXT):
     333        $(BENCH_V_CC)$(COMPILE) $(srcdir)/mutex/pthreads.c
     334
     335mutex-cfa1$(EXEEXT):
     336        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa1.cfa
     337
     338mutex-cfa2$(EXEEXT):
     339        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa2.cfa
     340
     341mutex-cfa4$(EXEEXT):
     342        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa4.cfa
    253343
    254344mutex-upp$(EXEEXT):
    255         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/mutex/upp.cc
    256 
    257 mutex-cfa1$(EXEEXT):
    258         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000  $(srcdir)/mutex/cfa1.cfa
    259 
    260 mutex-cfa2$(EXEEXT):
    261         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000  $(srcdir)/mutex/cfa2.cfa
    262 
    263 mutex-cfa4$(EXEEXT):
    264         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000  $(srcdir)/mutex/cfa4.cfa
    265 
    266 mutex-java_thread$(EXEEXT):
     345        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/mutex/upp.cc
     346
     347mutex-go$(EXEEXT):
     348        $(BENCH_V_GOC)go build -o a.out $(srcdir)/mutex/goroutine.go
     349
     350mutex-rust$(EXEEXT):
     351        $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/mutex/rust.rs
     352
     353mutex-java$(EXEEXT):
    267354        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/mutex/JavaThread.java
    268         @echo "#!/bin/sh" > a.out
    269         @echo "java JavaThread" >> a.out
    270         @chmod a+x a.out
    271 
    272 ## =========================================================================================================
    273 signal$(EXEEXT) :\
    274         signal-pthread_cond.run \
    275         signal-upp.run          \
    276         signal-cfa1.run         \
    277         signal-cfa2.run         \
    278         signal-cfa4.run         \
    279         signal-java_thread.run
    280 
    281 signal-pthread_cond$(EXEEXT):
    282         $(BENCH_V_CC)$(COMPILE)    -DBENCH_N=500000  $(srcdir)/schedint/pthreads.c
    283 
    284 signal-upp$(EXEEXT):
    285         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=5000000 $(srcdir)/schedint/upp.cc
    286 
    287 signal-cfa1$(EXEEXT):
    288         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedint/cfa1.cfa
    289 
    290 signal-cfa2$(EXEEXT):
    291         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedint/cfa2.cfa
    292 
    293 signal-cfa4$(EXEEXT):
    294         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedint/cfa4.cfa
    295 
    296 signal-java_thread$(EXEEXT):
     355        echo "#!/bin/sh" > a.out
     356        echo "java JavaThread" >> a.out
     357        chmod a+x a.out
     358
     359## =========================================================================================================
     360
     361schedint$(EXEEXT) :             \
     362        schedint-cfa1.run       \
     363        schedint-cfa2.run       \
     364        schedint-cfa4.run       \
     365        schedint-upp.run        \
     366        schedint-rust.run       \
     367        schedint-java.run       \
     368        schedint-pthread.run
     369
     370schedint-cfa1$(EXEEXT):
     371        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa1.cfa
     372
     373schedint-cfa2$(EXEEXT):
     374        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa2.cfa
     375
     376schedint-cfa4$(EXEEXT):
     377        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa4.cfa
     378
     379schedint-upp$(EXEEXT):
     380        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedint/upp.cc
     381
     382schedint-rust$(EXEEXT):
     383        $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/schedint/rust.rs
     384
     385schedint-java$(EXEEXT):
    297386        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/schedint/JavaThread.java
    298         @echo "#!/bin/sh" > a.out
    299         @echo "java JavaThread" >> a.out
    300         @chmod a+x a.out
    301 
    302 
    303 ## =========================================================================================================
    304 waitfor$(EXEEXT) :\
    305         waitfor-upp.run         \
    306         waitfor-cfa1.run                \
    307         waitfor-cfa2.run                \
    308         waitfor-cfa4.run
    309 
    310 waitfor-upp$(EXEEXT):
    311         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=5000000 $(srcdir)/schedext/upp.cc
    312 
    313 waitfor-cfa1$(EXEEXT):
    314         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedext/cfa1.cfa
    315 
    316 waitfor-cfa2$(EXEEXT):
    317         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedext/cfa2.cfa
    318 
    319 waitfor-cfa4$(EXEEXT):
    320         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedext/cfa4.cfa
    321 
    322 ## =========================================================================================================
    323 creation$(EXEEXT) :\
    324         creation-pthread.run                    \
     387        echo "#!/bin/sh" > a.out
     388        echo "java JavaThread" >> a.out
     389        chmod a+x a.out
     390
     391schedint-pthread$(EXEEXT):
     392        $(BENCH_V_CC)$(COMPILE) $(srcdir)/schedint/pthreads.c
     393
     394## =========================================================================================================
     395
     396schedext$(EXEEXT) :             \
     397        schedext-cfa1.run       \
     398        schedext-cfa2.run       \
     399        schedext-cfa4.run       \
     400        schedext-upp.run        \
     401        schedext-goroutine.run
     402
     403schedext-cfa1$(EXEEXT):
     404        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa1.cfa
     405
     406schedext-cfa2$(EXEEXT):
     407        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa2.cfa
     408
     409schedext-cfa4$(EXEEXT):
     410        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa4.cfa
     411
     412schedext-upp$(EXEEXT):
     413        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedext/upp.cc
     414
     415schedext-goroutine$(EXEEXT):
     416        $(BENCH_V_GOC)go build -o a.out $(srcdir)/schedext/goroutine.go
     417
     418
     419## =========================================================================================================
     420
     421creation$(EXEEXT) :                             \
     422        creation-cfa_generator.run              \
    325423        creation-cfa_coroutine.run              \
    326424        creation-cfa_coroutine_eager.run        \
     
    328426        creation-upp_coroutine.run              \
    329427        creation-upp_thread.run                 \
    330         creation-goroutine.run                  \
    331         creation-java_thread.run
     428        creation-python_coroutine.run           \
     429        creation-nodejs_coroutine.run           \
     430        creation-goroutine_thread.run           \
     431        creation-rust_thread.run                \
     432        creation-java_thread.run                \
     433        creation-pthread.run
     434
     435creation-cfa_generator$(EXEEXT):
     436        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_gen.cfa
    332437
    333438creation-cfa_coroutine$(EXEEXT):
    334         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_cor.cfa
     439        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_cor.cfa
    335440
    336441creation-cfa_coroutine_eager$(EXEEXT):
    337         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_cor.cfa  -DEAGER
     442        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_cor.cfa  -DEAGER
    338443
    339444creation-cfa_thread$(EXEEXT):
    340         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_thrd.cfa
     445        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_thrd.cfa
    341446
    342447creation-upp_coroutine$(EXEEXT):
    343         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/creation/upp_cor.cc
     448        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/creation/upp_cor.cc
    344449
    345450creation-upp_thread$(EXEEXT):
    346         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/creation/upp_thrd.cc
    347 
    348 creation-pthread$(EXEEXT):
    349         $(BENCH_V_CC)$(COMPILE)    -DBENCH_N=250000   $(srcdir)/creation/pthreads.c
    350 
    351 creation-goroutine$(EXEEXT):
     451        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/creation/upp_thrd.cc
     452
     453creation-python_coroutine$(EXEEXT):
     454        echo "#!/bin/sh" > a.out
     455        echo "python3.7 $(srcdir)/creation/python_cor.py" >> a.out
     456        chmod a+x a.out
     457
     458creation-nodejs_coroutine$(EXEEXT):
     459        echo "#!/bin/sh" > a.out
     460        echo "nodejs $(srcdir)/creation/node_cor.js" >> a.out
     461        chmod a+x a.out
     462
     463creation-goroutine_thread$(EXEEXT):
    352464        $(BENCH_V_GOC)go build -o a.out $(srcdir)/creation/goroutine.go
     465
     466creation-rust_thread$(EXEEXT):
     467        $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/creation/rust_thrd.rs
    353468
    354469creation-java_thread$(EXEEXT):
    355470        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/creation/JavaThread.java
    356         @echo "#!/bin/sh" > a.out
    357         @echo "java JavaThread" >> a.out
    358         @chmod a+x a.out
    359 
    360 ## =========================================================================================================
    361 
    362 compile$(EXEEXT) :\
     471        echo "#!/bin/sh" > a.out
     472        echo "java JavaThread" >> a.out
     473        chmod a+x a.out
     474
     475creation-pthread$(EXEEXT):
     476        $(BENCH_V_CC)$(COMPILE) $(srcdir)/creation/pthreads.c
     477
     478## =========================================================================================================
     479
     480compile$(EXEEXT) :              \
    363481        compile-array.make      \
    364482        compile-attributes.make \
     
    370488        compile-typeof.make
    371489
    372 
    373490testdir = $(top_srcdir)/tests
    374491
    375492compile-array$(EXEEXT):
    376         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/array.cfa
     493        $(CFACOMPILE) -fsyntax-only -w $(testdir)/array.cfa
    377494
    378495compile-attributes$(EXEEXT):
    379         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa
     496        $(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa
    380497
    381498compile-empty$(EXEEXT):
    382         @$(CFACOMPILE) -fsyntax-only -w $(srcdir)/compile/empty.cfa
     499        $(CFACOMPILE) -fsyntax-only -w $(srcdir)/compile/empty.cfa
    383500
    384501compile-expression$(EXEEXT):
    385         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/expression.cfa
     502        $(CFACOMPILE) -fsyntax-only -w $(testdir)/expression.cfa
    386503
    387504compile-io$(EXEEXT):
    388         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/io1.cfa
     505        $(CFACOMPILE) -fsyntax-only -w $(testdir)/io1.cfa
    389506
    390507compile-monitor$(EXEEXT):
    391         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/monitor.cfa
     508        $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/monitor.cfa
    392509
    393510compile-operators$(EXEEXT):
    394         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/operators.cfa
     511        $(CFACOMPILE) -fsyntax-only -w $(testdir)/operators.cfa
    395512
    396513compile-thread$(EXEEXT):
    397         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/thread.cfa
     514        $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/thread.cfa
    398515
    399516compile-typeof$(EXEEXT):
    400         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/typeof.cfa
     517        $(CFACOMPILE) -fsyntax-only -w $(testdir)/typeof.cfa
  • benchmark/Makefile.in

    r807a632 r3b56166  
    9393EXTRA_PROGRAMS = dummy$(EXEEXT)
    9494@WITH_LIBFIBRE_TRUE@am__append_1 = \
    95 @WITH_LIBFIBRE_TRUE@    ctxswitch-kos_fibre.run  \
     95@WITH_LIBFIBRE_TRUE@    ctxswitch-kos_fibre.run         \
    9696@WITH_LIBFIBRE_TRUE@    ctxswitch-kos_fibre2.run
    9797
     
    352352LTCFACOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
    353353        $(LIBTOOLFLAGS) --mode=compile $(CFACC) $(DEFS) \
    354         $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) \
    355         $(AM_CFLAGS) $(CFLAGS)
     354        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(AM_CFLAGS) $(CFAFLAGS) $(CFLAGS)
    356355
    357356AM_V_CFA = $(am__v_CFA_@AM_V@)
     
    359358am__v_CFA_0 = @echo "  CFA     " $@;
    360359am__v_CFA_1 =
    361 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
    362 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
    363 am__v_JAVAC_0 = @echo "  JAVAC   " $@;
    364 am__v_JAVAC_1 =
    365 AM_V_GOC = $(am__v_GOC_@AM_V@)
    366 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)
    367 am__v_GOC_0 = @echo "  GOC     " $@;
    368 am__v_GOC_1 =
    369360UPPCC = u++
    370361UPPCOMPILE = $(UPPCC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_UPPFLAGS) $(UPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_CFLAGS) $(CFLAGS)
     
    373364am__v_UPP_0 = @echo "  UPP     " $@;
    374365am__v_UPP_1 =
     366AM_V_GOC = $(am__v_GOC_@AM_V@)
     367am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)
     368am__v_GOC_0 = @echo "  GOC     " $@;
     369am__v_GOC_1 =
     370AM_V_RUST = $(am__v_RUST_@AM_V@)
     371am__v_RUST_ = $(am__v_RUST_@AM_DEFAULT_V@)
     372am__v_RUST_0 = @echo "  RUST     " $@;
     373am__v_RUST_1 =
     374AM_V_NODEJS = $(am__v_NODEJS_@AM_V@)
     375am__v_NODEJS_ = $(am__v_NODEJS_@AM_DEFAULT_V@)
     376am__v_NODEJS_0 = @echo "  NODEJS     " $@;
     377am__v_NODEJS_1 =
     378AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
     379am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
     380am__v_JAVAC_0 = @echo "  JAVAC   " $@;
     381am__v_JAVAC_1 =
    375382
    376383# applies to both programs
     
    381388BENCH_V_CFA = $(__bench_v_CFA_$(__quiet))
    382389BENCH_V_CXX = $(__bench_v_CXX_$(__quiet))
     390BENCH_V_UPP = $(__bench_v_UPP_$(__quiet))
    383391BENCH_V_GOC = $(__bench_v_GOC_$(__quiet))
     392BENCH_V_RUSTC = $(__bench_v_RUSTC_$(__quiet))
     393BENCH_V_NODEJS = $(__bench_v_NODEJS_$(__quiet))
    384394BENCH_V_JAVAC = $(__bench_v_JAVAC_$(__quiet))
    385 BENCH_V_UPP = $(__bench_v_UPP_$(__quiet))
    386395__quiet = verbose
    387396__bench_v_CC_quiet = @
    388397__bench_v_CFA_quiet = @
    389398__bench_v_CXX_quiet = @
     399__bench_v_UPP_quiet = @
    390400__bench_v_GOC_quiet = @
     401__bench_v_RUSTC_quiet = @
    391402__bench_v_JAVAC_quiet = @
    392 __bench_v_UPP_quiet = @
    393403__bench_v_CC_verbose = $(AM_V_CC)
    394404__bench_v_CFA_verbose = $(AM_V_CFA)
    395405__bench_v_CXX_verbose = $(AM_V_CXX)
     406__bench_v_UPP_verbose = $(AM_V_UPP)
    396407__bench_v_GOC_verbose = $(AM_V_GOC)
     408__bench_v_RUSTC_verbose = $(AM_V_RUSTC)
     409__bench_v_NODEJS_verbose = $(AM_V_NODEJS)
    397410__bench_v_JAVAC_verbose = $(AM_V_JAVAC)
    398 __bench_v_UPP_verbose = $(AM_V_UPP)
    399411TOOLSDIR = ${abs_top_builddir}/tools/
    400412REPEAT = ${abs_top_builddir}/tools/repeat
    401413STATS = ${abs_top_srcdir}/tools/stat.py
    402414# NEED AT LEAST 4 DATA VALUES FOR BENCHMARKS BECAUSE THE MAX AND MIN VALUES ARE REMOVED
    403 repeats = 5 # 31 for benchmarks
     415repeats = 13 # 31 for benchmarks
    404416arch = x64
    405417skipcompile = no
     
    407419PRINT_FORMAT = %20s: #Comments needed for spacing
    408420dummy_SOURCES = dummyC.c dummyCXX.cpp
     421basic_loop_DURATION = 15000000000
     422basic_function_DURATION = 10000000000
     423basic_tls_fetch_add_DURATION = 10000000000
     424basic_DURATION = 250000000
     425ctxswitch_pthread_DURATION = 25000000
     426ctxswitch_rust_thread_DURATION = $(ctxswitch_pthread_DURATION)
     427ctxswitch_cfa_generator_DURATION = 5000000000
     428ctxswitch_nodejs_await_DURATION = 5000000
     429ctxswitch_DURATION = 100000000
     430
     431#mutex_java_DURATION = 10000000
     432mutex_DURATION = 50000000
     433schedint_pthread_DURATION = 1000000
     434schedint_java_DURATION = $(schedint_pthread_DURATION)
     435schedint_rust_DURATION = $(schedint_pthread_DURATION)
     436schedint_DURATION = 10000000
     437schedext_DURATION = 10000000
     438creation_pthread_DURATION = 250000
     439creation_rust_thread_DURATION = ${creation_pthread_DURATION}
     440creation_java_thread_DURATION = ${creation_pthread_DURATION}
     441creation_cfa_coroutine_DURATION = 100000000
     442creation_cfa_coroutine_eager_DURATION = 10000000
     443creation_upp_coroutine_DURATION = ${creation_cfa_coroutine_eager_DURATION}
     444creation_cfa_thread_DURATION = 10000000
     445creation_upp_thread_DURATION = ${creation_cfa_thread_DURATION}
     446creation_DURATION = 10000000
    409447FIX_NEW_LINES = cat $@ | tr "\n" "\t" | sed -r 's/\t,/,/' | tr "\t" "\n" > $@
    410 CTXSWITCH_DEPEND = loop.run function.run fetch_add.run ttst_lock.run \
    411         tls-fetch_add.run ctxswitch-pthread.run \
    412         ctxswitch-cfa_generator.run ctxswitch-cfa_coroutine.run \
    413         ctxswitch-cfa_thread.run ctxswitch-cfa_thread2.run \
    414         ctxswitch-upp_coroutine.run ctxswitch-upp_thread.run \
    415         ctxswitch-goroutine.run ctxswitch-java_thread.run \
    416         $(am__append_1)
     448BASIC_DEPEND = \
     449        basic-loop.run                          \
     450        basic-function.run                      \
     451        basic-fetch_add.run                     \
     452        basic-ttst_lock.run                     \
     453        basic-tls-fetch_add.run
     454
     455CTXSWITCH_DEPEND = ctxswitch-cfa_generator.run \
     456        ctxswitch-cfa_coroutine.run ctxswitch-cfa_thread.run \
     457        ctxswitch-cfa_thread2.run ctxswitch-upp_coroutine.run \
     458        ctxswitch-upp_thread.run ctxswitch-python_coroutine.run \
     459        ctxswitch-nodejs_coroutine.run ctxswitch-nodejs_await.run \
     460        ctxswitch-goroutine_thread.run ctxswitch-rust_thread.run \
     461        ctxswitch-nodejs_coroutine.run ctxswitch-java_thread.run \
     462        ctxswitch-pthread.run $(am__append_1)
    417463testdir = $(top_srcdir)/tests
    418464all: all-am
     
    733779
    734780dummyC.c:
    735         @echo "int main() { return 0; }" > ${@}
     781        echo "int main() { return 0; }" > ${@}
    736782
    737783dummyCXX.cpp:
    738         @echo "int main() { return 0; }" > ${@}
    739 
     784        echo "int main() { return 0; }" > ${@}
     785
     786#.SILENT:               # do not print recipe
     787.ONESHELL:              # use one shell to execute recipe
    740788.NOTPARALLEL:
    741 .PHONY: compile.csv ctxswitch.csv mutex.csv signal.csv
    742 
    743 all : ctxswitch$(EXEEXT) mutex$(EXEEXT) signal$(EXEEXT) waitfor$(EXEEXT) creation$(EXEEXT)
     789.PHONY: compile.csv basic.csv ctxswitch.csv mutex.csv schedint.csv
     790
     791all : basic$(EXEEXT) ctxswitch$(EXEEXT) mutex$(EXEEXT) schedint$(EXEEXT) schedext$(EXEEXT) creation$(EXEEXT)
    744792
    745793%.run : %$(EXEEXT) ${REPEAT}
    746         @rm -f .result.log
    747         @echo "------------------------------------------------------"
    748         @echo $<
    749         @${REPEAT} ${repeats} ./a.out | tee -a .result.log
    750         @${STATS} .result.log
    751         @echo "------------------------------------------------------"
    752         @rm -f a.out .result.log *.class
     794        rm -f .result.log
     795        echo "------------------------------------------------------"
     796        echo $<
     797        ${REPEAT} ${repeats} -- ./a.out\
     798                $(if ${$(subst -,_,$(basename $@))_DURATION},\
     799                        ${$(subst -,_,$(basename $@))_DURATION},\
     800                        ${$(firstword $(subst -, ,$(basename $@)))_DURATION}) | tee -a .result.log
     801        ${STATS} .result.log
     802        echo "------------------------------------------------------"
     803        rm -f a.out .result.log *.class
     804
     805#       ${REPEAT} ${repeats} -- /usr/bin/time -f "%Uu %Ss %Er %Mkb" ./a.out
    753806
    754807%.runquiet :
    755         @+make $(basename $@) CFLAGS="-w" __quiet=quiet
    756         @taskset -c 1 ./a.out
    757         @rm -f a.out
     808        +make $(basename $@) CFLAGS="-w" __quiet=quiet
     809        taskset -c 1 ./a.out
     810        rm -f a.out
    758811
    759812%.make :
    760         @printf "${PRINT_FORMAT}" $(basename $(subst compile-,,$@))
    761         @+/usr/bin/time -f ${TIME_FORMAT} make $(basename $@) 2>&1
     813        printf "${PRINT_FORMAT}" $(basename $(subst compile-,,$@))
     814        +/usr/bin/time -f ${TIME_FORMAT} make $(basename $@) 2>&1
    762815
    763816${REPEAT} :
    764         @+make -C ${abs_top_builddir}/tools repeat
     817        +make -C ${abs_top_builddir}/tools repeat
    765818
    766819jenkins$(EXEEXT):
    767820@DOifskipcompile@
    768         @+make compile.csv
    769         @-+make compile.diff.csv
     821        +make compile.csv
     822        -+make compile.diff.csv
    770823@DOendif@
    771         @+make ctxswitch.csv
    772         @-+make ctxswitch.diff.csv
    773         @+make mutex.csv
    774         @-+make mutex.diff.csv
    775         @+make signal.csv
    776         @-+make signal.diff.csv
     824        +make basic.csv
     825        -+make basic.diff.csv
     826        +make ctxswitch.csv
     827        -+make ctxswitch.diff.csv
     828        +make mutex.csv
     829        -+make mutex.diff.csv
     830        +make schedint.csv
     831        -+make schedint.diff.csv
    777832@DOifskipcompile@
    778833        cat compile.csv
    779834        -cat compile.diff.csv
    780835@DOendif@
     836        cat basic.csv
     837        -cat basic.diff.csv
    781838        cat ctxswitch.csv
    782839        -cat ctxswitch.diff.csv
    783840        cat mutex.csv
    784841        -cat mutex.diff.csv
    785         cat signal.csv
    786         -cat signal.diff.csv
     842        cat schedint.csv
     843        -cat schedint.diff.csv
    787844
    788845compile.csv:
    789         @echo "array,attributes,empty,expression,io,monitor,operators,typeof" > $@
    790         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-array.make >> $@
    791         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-attributes.make >> $@
    792         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-empty.make >> $@
    793         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-expression.make >> $@
    794         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-io.make >> $@
    795         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-monitor.make >> $@
    796         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-operators.make >> $@
    797         @+make TIME_FORMAT='%e' PRINT_FORMAT='' compile-typeof.make >> $@
    798         @$(srcdir)/fixcsv.sh $@
     846        echo "array,attributes,empty,expression,io,monitor,operators,typeof" > $@
     847        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-array.make >> $@
     848        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-attributes.make >> $@
     849        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-empty.make >> $@
     850        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-expression.make >> $@
     851        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-io.make >> $@
     852        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-monitor.make >> $@
     853        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-operators.make >> $@
     854        +make TIME_FORMAT='%e' PRINT_FORMAT='' compile-typeof.make >> $@
     855        $(srcdir)/fixcsv.sh $@
     856
     857basic.csv:
     858        echo "generator,coroutine,thread" > $@
     859        +make basic-cfa_generator.runquiet >> $@ && echo -n ',' >> $@
     860        +make basic-cfa_coroutine.runquiet >> $@ && echo -n ',' >> $@
     861        +make basic-cfa_thread.runquiet >> $@
     862        $(srcdir)/fixcsv.sh $@
    799863
    800864ctxswitch.csv:
    801         @echo "generator,coroutine,thread" > $@
    802         @+make ctxswitch-cfa_generator.runquiet >> $@ && echo -n ',' >> $@
    803         @+make ctxswitch-cfa_coroutine.runquiet >> $@ && echo -n ',' >> $@
    804         @+make ctxswitch-cfa_thread.runquiet >> $@
    805         @$(srcdir)/fixcsv.sh $@
     865        echo "generator,coroutine,thread" > $@
     866        +make ctxswitch-cfa_generator.runquiet >> $@ && echo -n ',' >> $@
     867        +make ctxswitch-cfa_coroutine.runquiet >> $@ && echo -n ',' >> $@
     868        +make ctxswitch-cfa_thread.runquiet >> $@
     869        $(srcdir)/fixcsv.sh $@
    806870
    807871mutex.csv:
    808         @echo "1-monitor,2-monitor" > $@
    809         @+make mutex-cfa1.runquiet >> $@ && echo -n ',' >> $@
    810         @+make mutex-cfa2.runquiet >> $@
    811         @$(srcdir)/fixcsv.sh $@
    812 
    813 signal.csv:
    814         @echo "signal-1,signal-2,waitfor-1,waitfor-2" > $@
    815         @+make signal-cfa1.runquiet >> $@ && echo -n ',' >> $@
    816         @+make signal-cfa2.runquiet >> $@ && echo -n ',' >> $@
    817         @+make waitfor-cfa1.runquiet >> $@ && echo -n ',' >> $@
    818         @+make waitfor-cfa2.runquiet >> $@
    819         @$(srcdir)/fixcsv.sh $@
     872        echo "1-monitor,2-monitor" > $@
     873        +make mutex-cfa1.runquiet >> $@ && echo -n ',' >> $@
     874        +make mutex-cfa2.runquiet >> $@
     875        $(srcdir)/fixcsv.sh $@
     876
     877schedint.csv:
     878        echo "schedint-1,schedint-2,schedext-1,schedext-2" > $@
     879        +make schedint-cfa1.runquiet >> $@ && echo -n ',' >> $@
     880        +make schedint-cfa2.runquiet >> $@ && echo -n ',' >> $@
     881        +make schedext-cfa1.runquiet >> $@ && echo -n ',' >> $@
     882        +make schedext-cfa2.runquiet >> $@
     883        $(srcdir)/fixcsv.sh $@
    820884
    821885%.diff.csv: %.csv
    822         @test -e $(srcdir)/baselines/$(arch)/$< || (echo "Error : Missing baseline for ${<}" && false)
    823         @$(srcdir)/baselines/calc.py $(srcdir)/baselines/$(arch)/$(<) $(<) > $@
    824 
    825 loop$(EXEEXT):
    826         $(BENCH_V_CC)$(COMPILE) -DBENCH_N=5000000000 $(srcdir)/loop.c
    827 
    828 function$(EXEEXT):
    829         $(BENCH_V_CC)$(COMPILE) -DBENCH_N=5000000000 $(srcdir)/function.c
    830 
    831 fetch_add$(EXEEXT):
    832         $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000  $(srcdir)/fetch_add.c
    833 
    834 ttst_lock$(EXEEXT):
    835         $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000  $(srcdir)/ttst_lock.c
    836 
    837 tls-fetch_add$(EXEEXT):
    838         $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000  $(srcdir)/tls-fetch_add.c
     886        test -e $(srcdir)/baselines/$(arch)/$< || (echo "Error : Missing baseline for ${<}" && false)
     887        $(srcdir)/baselines/calc.py $(srcdir)/baselines/$(arch)/$(<) $(<) > $@
     888
     889basic-loop$(EXEEXT):
     890        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/loop.c
     891
     892basic-function$(EXEEXT):
     893        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/function.c
     894
     895basic-fetch_add$(EXEEXT):
     896        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/fetch_add.c
     897
     898basic-ttst_lock$(EXEEXT):
     899        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/ttst_lock.c
     900
     901basic-tls-fetch_add$(EXEEXT):
     902        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/tls_fetch_add.c
     903
     904basic$(EXEEXT): $(BASIC_DEPEND)
    839905
    840906@WITH_LIBFIBRE_TRUE@ctxswitch-kos_fibre$(EXEEXT):
     
    846912ctxswitch$(EXEEXT): $(CTXSWITCH_DEPEND)
    847913
    848 ctxswitch-pthread$(EXEEXT):
    849         $(BENCH_V_CC)$(COMPILE)    -DBENCH_N=50000000 $(srcdir)/ctxswitch/pthreads.c
    850 
    851914ctxswitch-cfa_generator$(EXEEXT):
    852         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_gen.cfa
     915        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_gen.cfa
    853916
    854917ctxswitch-cfa_coroutine$(EXEEXT):
    855         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_cor.cfa
     918        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_cor.cfa
    856919
    857920ctxswitch-cfa_thread$(EXEEXT):
    858         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_thrd.cfa
     921        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_thrd.cfa
    859922
    860923ctxswitch-cfa_thread2$(EXEEXT):
    861         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_thrd2.cfa
     924        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_thrd2.cfa
    862925
    863926ctxswitch-upp_coroutine$(EXEEXT):
    864         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/upp_cor.cc
     927        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/ctxswitch/upp_cor.cc
    865928
    866929ctxswitch-upp_thread$(EXEEXT):
    867         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/upp_thrd.cc
    868 
    869 ctxswitch-goroutine$(EXEEXT):
     930        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/ctxswitch/upp_thrd.cc
     931
     932ctxswitch-python_coroutine$(EXEEXT):
     933        echo "#!/bin/sh" > a.out
     934        echo "python3.7 $(srcdir)/ctxswitch/python_cor.py" >> a.out
     935        chmod a+x a.out
     936
     937ctxswitch-nodejs_coroutine$(EXEEXT):
     938        echo "#!/bin/sh" > a.out
     939        echo "nodejs $(srcdir)/ctxswitch/node_cor.js" >> a.out
     940        chmod a+x a.out
     941
     942ctxswitch-nodejs_await$(EXEEXT):
     943        echo "#!/bin/sh" > a.out
     944        echo "nodejs $(srcdir)/ctxswitch/node_await.js" >> a.out
     945        chmod a+x a.out
     946
     947ctxswitch-goroutine_thread$(EXEEXT):
    870948        $(BENCH_V_GOC)go build -o a.out $(srcdir)/ctxswitch/goroutine.go
     949
     950ctxswitch-rust_thread$(EXEEXT):
     951        $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/ctxswitch/rust_thrd.rs
    871952
    872953ctxswitch-java_thread$(EXEEXT):
    873954        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/ctxswitch/JavaThread.java
    874         @echo "#!/bin/sh" > a.out
    875         @echo "java JavaThread" >> a.out
    876         @chmod a+x a.out
    877 
    878 mutex$(EXEEXT) :\
    879         loop.run                        \
    880         function.run            \
    881         fetch_add.run           \
    882         mutex-pthread_lock.run  \
    883         mutex-upp.run           \
     955        echo "#!/bin/sh" > a.out
     956        echo "java JavaThread" >> a.out
     957        chmod a+x a.out
     958
     959ctxswitch-pthread$(EXEEXT):
     960        $(BENCH_V_CC)$(COMPILE) $(srcdir)/ctxswitch/pthreads.c
     961
     962mutex$(EXEEXT) :                \
    884963        mutex-cfa1.run          \
    885964        mutex-cfa2.run          \
    886965        mutex-cfa4.run          \
    887         mutex-java_thread.run
    888 
    889 mutex-pthread_lock$(EXEEXT):
    890         $(BENCH_V_CC)$(COMPILE)    -DBENCH_N=50000000 $(srcdir)/mutex/pthreads.c
     966        mutex-upp.run           \
     967        mutex-go.run            \
     968        mutex-rust.run          \
     969        mutex-java.run          \
     970        mutex-pthread.run
     971
     972mutex-pthread$(EXEEXT):
     973        $(BENCH_V_CC)$(COMPILE) $(srcdir)/mutex/pthreads.c
     974
     975mutex-cfa1$(EXEEXT):
     976        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa1.cfa
     977
     978mutex-cfa2$(EXEEXT):
     979        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa2.cfa
     980
     981mutex-cfa4$(EXEEXT):
     982        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa4.cfa
    891983
    892984mutex-upp$(EXEEXT):
    893         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/mutex/upp.cc
    894 
    895 mutex-cfa1$(EXEEXT):
    896         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000  $(srcdir)/mutex/cfa1.cfa
    897 
    898 mutex-cfa2$(EXEEXT):
    899         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000  $(srcdir)/mutex/cfa2.cfa
    900 
    901 mutex-cfa4$(EXEEXT):
    902         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000  $(srcdir)/mutex/cfa4.cfa
    903 
    904 mutex-java_thread$(EXEEXT):
     985        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/mutex/upp.cc
     986
     987mutex-go$(EXEEXT):
     988        $(BENCH_V_GOC)go build -o a.out $(srcdir)/mutex/goroutine.go
     989
     990mutex-rust$(EXEEXT):
     991        $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/mutex/rust.rs
     992
     993mutex-java$(EXEEXT):
    905994        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/mutex/JavaThread.java
    906         @echo "#!/bin/sh" > a.out
    907         @echo "java JavaThread" >> a.out
    908         @chmod a+x a.out
    909 
    910 signal$(EXEEXT) :\
    911         signal-pthread_cond.run \
    912         signal-upp.run          \
    913         signal-cfa1.run         \
    914         signal-cfa2.run         \
    915         signal-cfa4.run         \
    916         signal-java_thread.run
    917 
    918 signal-pthread_cond$(EXEEXT):
    919         $(BENCH_V_CC)$(COMPILE)    -DBENCH_N=500000  $(srcdir)/schedint/pthreads.c
    920 
    921 signal-upp$(EXEEXT):
    922         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=5000000 $(srcdir)/schedint/upp.cc
    923 
    924 signal-cfa1$(EXEEXT):
    925         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedint/cfa1.cfa
    926 
    927 signal-cfa2$(EXEEXT):
    928         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedint/cfa2.cfa
    929 
    930 signal-cfa4$(EXEEXT):
    931         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedint/cfa4.cfa
    932 
    933 signal-java_thread$(EXEEXT):
     995        echo "#!/bin/sh" > a.out
     996        echo "java JavaThread" >> a.out
     997        chmod a+x a.out
     998
     999schedint$(EXEEXT) :             \
     1000        schedint-cfa1.run       \
     1001        schedint-cfa2.run       \
     1002        schedint-cfa4.run       \
     1003        schedint-upp.run        \
     1004        schedint-rust.run       \
     1005        schedint-java.run       \
     1006        schedint-pthread.run
     1007
     1008schedint-cfa1$(EXEEXT):
     1009        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa1.cfa
     1010
     1011schedint-cfa2$(EXEEXT):
     1012        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa2.cfa
     1013
     1014schedint-cfa4$(EXEEXT):
     1015        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa4.cfa
     1016
     1017schedint-upp$(EXEEXT):
     1018        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedint/upp.cc
     1019
     1020schedint-rust$(EXEEXT):
     1021        $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/schedint/rust.rs
     1022
     1023schedint-java$(EXEEXT):
    9341024        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/schedint/JavaThread.java
    935         @echo "#!/bin/sh" > a.out
    936         @echo "java JavaThread" >> a.out
    937         @chmod a+x a.out
    938 
    939 waitfor$(EXEEXT) :\
    940         waitfor-upp.run         \
    941         waitfor-cfa1.run                \
    942         waitfor-cfa2.run                \
    943         waitfor-cfa4.run
    944 
    945 waitfor-upp$(EXEEXT):
    946         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=5000000 $(srcdir)/schedext/upp.cc
    947 
    948 waitfor-cfa1$(EXEEXT):
    949         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedext/cfa1.cfa
    950 
    951 waitfor-cfa2$(EXEEXT):
    952         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedext/cfa2.cfa
    953 
    954 waitfor-cfa4$(EXEEXT):
    955         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedext/cfa4.cfa
    956 
    957 creation$(EXEEXT) :\
    958         creation-pthread.run                    \
     1025        echo "#!/bin/sh" > a.out
     1026        echo "java JavaThread" >> a.out
     1027        chmod a+x a.out
     1028
     1029schedint-pthread$(EXEEXT):
     1030        $(BENCH_V_CC)$(COMPILE) $(srcdir)/schedint/pthreads.c
     1031
     1032schedext$(EXEEXT) :             \
     1033        schedext-cfa1.run       \
     1034        schedext-cfa2.run       \
     1035        schedext-cfa4.run       \
     1036        schedext-upp.run        \
     1037        schedext-goroutine.run
     1038
     1039schedext-cfa1$(EXEEXT):
     1040        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa1.cfa
     1041
     1042schedext-cfa2$(EXEEXT):
     1043        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa2.cfa
     1044
     1045schedext-cfa4$(EXEEXT):
     1046        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa4.cfa
     1047
     1048schedext-upp$(EXEEXT):
     1049        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedext/upp.cc
     1050
     1051schedext-goroutine$(EXEEXT):
     1052        $(BENCH_V_GOC)go build -o a.out $(srcdir)/schedext/goroutine.go
     1053
     1054creation$(EXEEXT) :                             \
     1055        creation-cfa_generator.run              \
    9591056        creation-cfa_coroutine.run              \
    9601057        creation-cfa_coroutine_eager.run        \
     
    9621059        creation-upp_coroutine.run              \
    9631060        creation-upp_thread.run                 \
    964         creation-goroutine.run                  \
    965         creation-java_thread.run
     1061        creation-python_coroutine.run           \
     1062        creation-nodejs_coroutine.run           \
     1063        creation-goroutine_thread.run           \
     1064        creation-rust_thread.run                \
     1065        creation-java_thread.run                \
     1066        creation-pthread.run
     1067
     1068creation-cfa_generator$(EXEEXT):
     1069        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_gen.cfa
    9661070
    9671071creation-cfa_coroutine$(EXEEXT):
    968         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_cor.cfa
     1072        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_cor.cfa
    9691073
    9701074creation-cfa_coroutine_eager$(EXEEXT):
    971         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_cor.cfa  -DEAGER
     1075        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_cor.cfa  -DEAGER
    9721076
    9731077creation-cfa_thread$(EXEEXT):
    974         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_thrd.cfa
     1078        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_thrd.cfa
    9751079
    9761080creation-upp_coroutine$(EXEEXT):
    977         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/creation/upp_cor.cc
     1081        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/creation/upp_cor.cc
    9781082
    9791083creation-upp_thread$(EXEEXT):
    980         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/creation/upp_thrd.cc
    981 
    982 creation-pthread$(EXEEXT):
    983         $(BENCH_V_CC)$(COMPILE)    -DBENCH_N=250000   $(srcdir)/creation/pthreads.c
    984 
    985 creation-goroutine$(EXEEXT):
     1084        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/creation/upp_thrd.cc
     1085
     1086creation-python_coroutine$(EXEEXT):
     1087        echo "#!/bin/sh" > a.out
     1088        echo "python3.7 $(srcdir)/creation/python_cor.py" >> a.out
     1089        chmod a+x a.out
     1090
     1091creation-nodejs_coroutine$(EXEEXT):
     1092        echo "#!/bin/sh" > a.out
     1093        echo "nodejs $(srcdir)/creation/node_cor.js" >> a.out
     1094        chmod a+x a.out
     1095
     1096creation-goroutine_thread$(EXEEXT):
    9861097        $(BENCH_V_GOC)go build -o a.out $(srcdir)/creation/goroutine.go
     1098
     1099creation-rust_thread$(EXEEXT):
     1100        $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/creation/rust_thrd.rs
    9871101
    9881102creation-java_thread$(EXEEXT):
    9891103        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/creation/JavaThread.java
    990         @echo "#!/bin/sh" > a.out
    991         @echo "java JavaThread" >> a.out
    992         @chmod a+x a.out
    993 
    994 compile$(EXEEXT) :\
     1104        echo "#!/bin/sh" > a.out
     1105        echo "java JavaThread" >> a.out
     1106        chmod a+x a.out
     1107
     1108creation-pthread$(EXEEXT):
     1109        $(BENCH_V_CC)$(COMPILE) $(srcdir)/creation/pthreads.c
     1110
     1111compile$(EXEEXT) :              \
    9951112        compile-array.make      \
    9961113        compile-attributes.make \
     
    10031120
    10041121compile-array$(EXEEXT):
    1005         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/array.cfa
     1122        $(CFACOMPILE) -fsyntax-only -w $(testdir)/array.cfa
    10061123
    10071124compile-attributes$(EXEEXT):
    1008         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa
     1125        $(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa
    10091126
    10101127compile-empty$(EXEEXT):
    1011         @$(CFACOMPILE) -fsyntax-only -w $(srcdir)/compile/empty.cfa
     1128        $(CFACOMPILE) -fsyntax-only -w $(srcdir)/compile/empty.cfa
    10121129
    10131130compile-expression$(EXEEXT):
    1014         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/expression.cfa
     1131        $(CFACOMPILE) -fsyntax-only -w $(testdir)/expression.cfa
    10151132
    10161133compile-io$(EXEEXT):
    1017         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/io1.cfa
     1134        $(CFACOMPILE) -fsyntax-only -w $(testdir)/io1.cfa
    10181135
    10191136compile-monitor$(EXEEXT):
    1020         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/monitor.cfa
     1137        $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/monitor.cfa
    10211138
    10221139compile-operators$(EXEEXT):
    1023         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/operators.cfa
     1140        $(CFACOMPILE) -fsyntax-only -w $(testdir)/operators.cfa
    10241141
    10251142compile-thread$(EXEEXT):
    1026         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/thread.cfa
     1143        $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/thread.cfa
    10271144
    10281145compile-typeof$(EXEEXT):
    1029         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/typeof.cfa
     1146        $(CFACOMPILE) -fsyntax-only -w $(testdir)/typeof.cfa
    10301147
    10311148# Tell versions [3.59,3.63) of GNU make to not export all variables.
  • benchmark/basic/tls_fetch_add.c

    r807a632 r3b56166  
    33
    44#include "bench.h"
     5
     6// Does not do a fetch & add. It mimics the cfa protocol to disable interrupts locally, by writing true or false to a
     7// thread_local Boolean. This means the entire protocol is just to "mov" instructions making it extremely cheap.
    58
    69#define thread_local _Thread_local
     
    1619}
    1720
    18 int main(int argc, char* argv[]) {
     21int main( int argc, char * argv[] ) {
     22        BENCH_START()
    1923        BENCH(
    20                 for (size_t i = 0; i < n; i++) {
     24                for (size_t i = 0; i < times; i++) {
    2125                        do_call();
    2226                },
    2327                result
    2428        )
     29        printf( "%g\n", result );
     30}
    2531
    26         printf("%g\n", result);
    27 }
     32// Local Variables: //
     33// tab-width: 4 //
     34// End: //
  • benchmark/basic/ttst_lock.c

    r807a632 r3b56166  
    33
    44#include "bench.h"
     5
     6// Does a "lock xchg" on entry but a simple "mov" on exit => cheaper as 0 contention. While it has much more code, the
     7// bulk is never run.
    58
    69#define CALIGN __attribute__(( aligned (CACHE_ALIGN) ))
     
    3538}
    3639
    37 int main(int argc, char* argv[]) {
     40int main( int argc, char * argv[] ) {
     41        BENCH_START()
    3842        BENCH(
    39                 for (size_t i = 0; i < n; i++) {
     43                for (size_t i = 0; i < times; i++) {
    4044                        do_call();
    4145                },
    4246                result
    43                 )
    44 
    45                 printf("%g\n", result);
     47        )
     48        printf( "%g\n", result );
    4649}
    4750
  • benchmark/bench.h

    r807a632 r3b56166  
    55#endif
    66        #include <stdlib.h>
    7         #include <unistd.h>                                     // sysconf
     7        #include <stdint.h>                             // uint64_t
     8        #include <unistd.h>                             // sysconf
    89#if ! defined(__cforall)
    910        #include <time.h>
     
    1516
    1617
    17 static inline unsigned long long int bench_time() {
    18     struct timespec ts;
    19     clock_gettime(
    20 #if defined( __linux__ )
    21          CLOCK_THREAD_CPUTIME_ID,
    22 #elif defined( __freebsd__ )
    23          CLOCK_PROF,
    24 #elif defined( __solaris__ )
    25          CLOCK_HIGHRES,
    26 #else
    27     #error uC++ : internal error, unsupported architecture
    28 #endif
    29          &ts );
    30     return 1000000000LL * ts.tv_sec + ts.tv_nsec;
    31 } // Time
     18static inline uint64_t bench_time() {
     19        struct timespec ts;
     20        clock_gettime( CLOCK_THREAD_CPUTIME_ID, &ts );
     21        return 1000000000LL * ts.tv_sec + ts.tv_nsec;
     22} // bench_time
    3223
    3324#ifndef BENCH_N
    34 #define BENCH_N 500 //10000000
     25#define BENCH_N 10000000
    3526#endif
    3627
     28size_t times = BENCH_N;
     29
     30#define BENCH_START()                           \
     31        if ( argc > 2 ) exit( EXIT_FAILURE );   \
     32        if ( argc == 2 ) {                      \
     33                times = atoi( argv[1] );        \
     34        }
     35
    3736#define BENCH(statement, output)                \
    38         size_t n = BENCH_N;                     \
    39         if( argc > 2 ) return 1;                \
    40         if( argc == 2 ) {                               \
    41                 n = atoi(argv[1]);              \
    42         }                                               \
    43         long long int StartTime, EndTime;       \
     37        uint64_t StartTime, EndTime;            \
    4438        StartTime = bench_time();               \
    45         statement;                                      \
     39        statement;                              \
    4640        EndTime = bench_time();                 \
    47         double output =         \
    48             (double)( EndTime - StartTime ) / n;
     41        double output = (double)( EndTime - StartTime ) / times;
     42
    4943
    5044#if defined(__cforall)
     
    5347}
    5448#endif
     49#if defined(__U_CPLUSPLUS__)
     50unsigned int uDefaultPreemption() {
     51        return 0;
     52}
     53#endif
  • benchmark/creation/JavaThread.java

    r807a632 r3b56166  
    2626        static int x = 2;
    2727
    28         static private final int NoOfTimes = Integer.parseInt("10000") ;
     28        static private int times = Integer.parseInt("10000") ;
    2929
    3030        public static class MyThread extends Thread {
     
    3333        }
    3434        public static void helper() throws InterruptedException {
    35                 for(int i = 1; i <= NoOfTimes; i += 1) {
     35                for(int i = 1; i <= times; i += 1) {
    3636                        MyThread m = new MyThread();
    3737                        x = nextRandom( x );
     
    4444                helper();
    4545                long end = System.nanoTime();
    46                 System.out.println( (end - start) / NoOfTimes );
     46                System.out.println( (end - start) / times );
    4747        }
    4848        public static void main(String[] args) throws InterruptedException {
    49                 for (int n = Integer.parseInt("5"); --n >= 0 ; ) {
     49                if ( args.length > 2 ) System.exit( 1 );
     50                if ( args.length == 2 ) { times = Integer.parseInt(args[1]); }
     51
     52                for (int i = Integer.parseInt("5"); --i >= 0 ; ) {
    5053                        InnerMain();
    51                         Thread.sleep(2000);     // 2 seconds
     54                        Thread.sleep(2000);             // 2 seconds
    5255                        x = nextRandom(x);
    5356                }
     
    5558        }
    5659}
     60
     61// Local Variables: //
     62// tab-width: 4 //
     63// End: //
  • benchmark/creation/cfa_cor.cfa

    r807a632 r3b56166  
    55
    66coroutine MyCoroutine {};
    7 void ?{} (MyCoroutine & this) {
     7void ?{}( MyCoroutine & this ) {
    88#ifdef EAGER
    9         resume(this);
     9        resume( this );
    1010#endif
    1111}
    12 void main(MyCoroutine &) {}
     12void main( MyCoroutine & ) {}
    1313
    14 int main(int argc, char* argv[]) {
     14int main( int argc, char * argv[] ) {
     15        BENCH_START()
    1516        BENCH(
    16                 for ( i; n ) {
    17                         MyCoroutine m;
     17                for ( times ) {
     18                        MyCoroutine c;
    1819                },
    1920                result
    2021        )
     22        printf( "%g\n", result );
     23}
    2124
    22         printf("%g\n", result);
    23 }
     25// Local Variables: //
     26// tab-width: 4 //
     27// End: //
  • benchmark/creation/cfa_thrd.cfa

    r807a632 r3b56166  
    77void main(MyThread &) {}
    88
    9 int main(int argc, char* argv[]) {
     9int main( int argc, char * argv[] ) {
     10        BENCH_START()
    1011        BENCH(
    11                 for ( i; n ) {
     12                for ( times ) {
    1213                        MyThread m;
    1314                },
    1415                result
    1516        )
     17        printf( "%g\n", result );
     18}
    1619
    17         printf("%g\n", result);
    18 }
     20// Local Variables: //
     21// tab-width: 4 //
     22// End: //
  • benchmark/creation/goroutine.go

    r807a632 r3b56166  
    22
    33import (
    4     "fmt"
    5     "time"
     4        "fmt"
     5        "time"
     6        "os"
     7        "strconv"
    68)
    79
     
    1719
    1820func main() {
    19         const NoOfTimes = 500000
     21        var times int = 10000000
     22        if len( os.Args ) > 2 { os.Exit( 1 ) }
     23        if len( os.Args ) == 2 { times, _ = strconv.Atoi(os.Args[1]) }
     24
    2025        start := time.Now()
    21         for i := 1; i <= NoOfTimes; i += 1 {
     26        for i := 1; i <= times; i += 1 {
    2227                go noop()               // creation
     28                <- shake                // wait for completion
    2329        }
    2430        end := time.Now()
    25         fmt.Printf("%d\n", end.Sub(start) / time.Duration(NoOfTimes))
    26         <- shake
     31        fmt.Printf( "%d\n", end.Sub(start) / time.Duration(times) )
    2732}
     33
     34// Local Variables: //
     35// tab-width: 4 //
     36// End: //
  • benchmark/creation/pthreads.c

    r807a632 r3b56166  
    44#include "bench.h"
    55
    6 static void *foo(void *arg) {
     6static void * foo(void *arg) {
    77    return arg;
    88}
    99
    10 int main(int argc, char* argv[]) {
     10int main( int argc, char * argv[] ) {
     11        BENCH_START()
    1112        BENCH(
    12                 for (size_t i = 0; i < n; i++) {
     13                for (size_t i = 0; i < times; i++) {
    1314                        pthread_t thread;
    1415                        if (pthread_create(&thread, NULL, foo, NULL) < 0) {
     
    1617                                return 1;
    1718                        }
    18 
    1919                        if (pthread_join( thread, NULL) < 0) {
    2020                                perror( "failure" );
     
    2424                result
    2525        )
     26        printf( "%g\n", result );
     27}
    2628
    27         printf("%g\n", result);
    28 }
     29// Local Variables: //
     30// tab-width: 4 //
     31// End: //
  • benchmark/creation/upp_cor.cc

    r807a632 r3b56166  
    55_Coroutine MyCor {
    66        void main() {}
     7  public:
     8        MyCor() { resume(); }
    79};
    810
    9 int main(int argc, char* argv[]) {
     11int main( int argc, char * argv[] ) {
     12        BENCH_START()
    1013        BENCH(
    11                 for (size_t i = 0; i < n; i++) {
     14                for (size_t i = 0; i < times; i++) {
    1215                        MyCor m;
    1316                },
    1417                result
    1518        )
     19        printf( "%g\n", result );
     20}
    1621
    17         printf("%g\n", result);
    18 }
     22// Local Variables: //
     23// tab-width: 4 //
     24// End: //
  • benchmark/creation/upp_thrd.cc

    r807a632 r3b56166  
    77};
    88
    9 int main(int argc, char* argv[]) {
     9int main( int argc, char * argv[] ) {
     10        BENCH_START()
    1011        BENCH(
    11                 for (size_t i = 0; i < n; i++) {
     12                for (size_t i = 0; i < times; i++) {
    1213                        MyThread m;
    1314                },
    1415                result
    1516        )
     17        printf( "%g\n", result );
     18}
    1619
    17         printf("%g\n", result);
    18 }
     20// Local Variables: //
     21// tab-width: 4 //
     22// End: //
  • benchmark/ctxswitch/JavaThread.java

    r807a632 r3b56166  
    2626        static int x = 2;
    2727
    28         static private final int NoOfTimes = Integer.parseInt("1000000") ;
     28        static private int times = Integer.parseInt("100000");
    2929
    3030        public static void helper() {
    31                 for(int i = 1; i <= NoOfTimes; i += 1) {
     31                for(int i = 1; i <= times; i += 1) {
    3232                        Thread.yield();
    3333                }
     
    3737                helper();
    3838                long end = System.nanoTime();
    39                 System.out.println( (end - start) / NoOfTimes );
     39                System.out.println( (end - start) / times );
    4040        }
    4141        public static void main(String[] args) throws InterruptedException {
    42                 for (int n = Integer.parseInt("5"); --n >= 0 ; ) {
     42                if ( args.length > 2 ) System.exit( 1 );
     43                if ( args.length == 2 ) { times = Integer.parseInt(args[1]); }
     44
     45                for (int i = Integer.parseInt("5"); --i >= 0 ; ) {
    4346                        InnerMain();
    44                         Thread.sleep(2000);     // 2 seconds
     47                        Thread.sleep(2000);     // 2 seconds
    4548                        x = nextRandom(x);
    4649                }
     
    4851        }
    4952}
     53
     54// Local Variables: //
     55// tab-width: 4 //
     56// End: //
  • benchmark/ctxswitch/cfa_cor.cfa

    r807a632 r3b56166  
    44#include "bench.h"
    55
    6 coroutine GreatSuspender {};
    7 
    8 void ?{}( GreatSuspender & this ) {
    9         prime(this);
    10 }
    11 
    12 void main( __attribute__((unused)) GreatSuspender & this ) {
    13         while( true ) {
     6coroutine C {} c;
     7void main( __attribute__((unused)) C & ) {
     8        while () {
    149                suspend();
    1510        }
    1611}
    17 
    18 int main(int argc, char* argv[]) {
    19         GreatSuspender s;
    20 
     12int main( int argc, char * argv[] ) {
     13        BENCH_START()
    2114        BENCH(
    22                 for ( i; n ) {
    23                         resume( s );
     15                for ( times ) {
     16                        resume( c );
    2417                },
    2518                result
    2619        )
     20        printf( "%g\n", result );
     21}
    2722
    28         printf("%g\n", result);
    29 }
     23// Local Variables: //
     24// tab-width: 4 //
     25// End: //
  • benchmark/ctxswitch/cfa_cor_then.cfa

    r807a632 r3b56166  
    66void noOp(void) {}
    77
    8 coroutine GreatSuspender {};
     8coroutine C {} c;
    99
    10 void ?{}( GreatSuspender & this ) {
     10void ?{}( C & this ) {
    1111        prime(this);
    1212}
    1313
    14 void main( __attribute__((unused)) GreatSuspender & this ) {
    15         while( true ) {
     14void main( __attribute__((unused)) C & this ) {
     15        while () {
    1616                suspend_then(noOp);
    1717        }
    1818}
    1919
    20 int main(int argc, char* argv[]) {
    21         GreatSuspender s;
    22 
     20int main( int argc, char * argv[] ) {
     21        BENCH_START()
    2322        BENCH(
    24                 for ( i; n ) {
    25                         resume( s );
     23                for ( times ) {
     24                        resume( c );
    2625                },
    2726                result
    2827        )
     28        printf( "%g\n", result );
     29}
    2930
    30         printf("%g\n", result);
    31 }
     31// Local Variables: //
     32// tab-width: 4 //
     33// End: //
  • benchmark/ctxswitch/cfa_gen.cfa

    r807a632 r3b56166  
    33typedef struct {
    44        void * next;
    5 } GreatSuspender;
     5} C;
    66
    7 void comain( GreatSuspender * this ) {
    8     if ( __builtin_expect(this->next != 0, 1) ) goto *(this->next);
    9     this->next = &&s1;
     7void comain( C * c ) {
     8        if ( __builtin_expect(c->next != 0, 1) ) goto *(c->next);
     9        c->next = &&s1;
    1010        for () {
    11             return;
     11                return;
    1212          s1: ;
    1313        }
    1414}
    1515
    16 int main(int argc, char* argv[]) {
    17     GreatSuspender s = { 0 };
    18 
     16int main( int argc, char * argv[] ) {
     17        BENCH_START()
     18        C c = { 0 };
    1919        BENCH(
    20                 for ( i; n ) {
    21                         comain( &s );
     20                for ( times ) {
     21                        comain( &c );
    2222                },
    2323                result
    2424        )
     25        printf( "%g\n", result );
     26}
    2527
    26         printf("%g\n", result);
    27 }
     28// Local Variables: //
     29// tab-width: 4 //
     30// End: //
  • benchmark/ctxswitch/cfa_thrd.cfa

    r807a632 r3b56166  
    33#include "bench.h"
    44
    5 int main(int argc, char* argv[]) {
     5int main( int argc, char * argv[] ) {
     6        BENCH_START()
    67        BENCH(
    7                 for ( i; n ) {
     8                for ( times ) {
    89                        yield();
    910                },
    1011                result
    1112        )
     13        printf( "%g\n", result );
     14}
    1215
    13         printf("%g\n", result);
    14 }
     16// Local Variables: //
     17// tab-width: 4 //
     18// End: //
  • benchmark/ctxswitch/cfa_thrd2.cfa

    r807a632 r3b56166  
    88
    99void main(__attribute__((unused)) Fibre & this) {
    10         while(!done) {
     10        while ( ! done ) {
    1111                yield();
    1212        }
    1313}
    1414
    15 int main(int argc, char* argv[]) {
     15int main( int argc, char * argv[] ) {
     16        BENCH_START()
    1617        Fibre f1;
    1718        BENCH(
    18                 for ( i; n ) {
     19                for ( times ) {
    1920                        yield();
    2021                },
    2122                result
    2223        )
     24        printf( "%g\n", result );
     25        done = true;
     26}
    2327
    24         printf("%g\n", result);
    25         done = true;
    26         return 0;
    27 }
     28// Local Variables: //
     29// tab-width: 4 //
     30// End: //
  • benchmark/ctxswitch/goroutine.go

    r807a632 r3b56166  
    22
    33import (
    4     "fmt"
    5     "runtime"
    6     "time"
     4        "fmt"
     5        "time"
     6        "os"
     7        "strconv"
     8        "runtime"
    79)
    810
     
    2830
    2931func main() {
    30         const NoOfTimes = 10000000
    31         go ContextSwitch( NoOfTimes )           // context switch
     32        var times int = 10000000
     33        if len( os.Args ) > 2 { os.Exit( 1 ) }
     34        if len( os.Args ) == 2 { times, _ = strconv.Atoi(os.Args[1]) }
     35        go ContextSwitch( times )               // context switch
    3236        <- shake
    3337}
     38
     39// Local Variables: //
     40// tab-width: 4 //
     41// End: //
  • benchmark/ctxswitch/kos_fibre.cpp

    r807a632 r3b56166  
    33#include "bench.h"
    44
    5 int main(int argc, char* argv[]) {
     5int main( int argc, char * argv[] ) {
     6        BENCH_START()
    67        BENCH(
    7                 for (size_t i = 0; i < n; i++) {
     8                for (size_t i = 0; i < times; i++) {
    89                        Fibre::yield();
    910                },
    1011                result
    1112        )
    12         printf("%g\n", result);
    13         return 0;
     13        printf( "%g\n", result );
    1414}
     15
     16// Local Variables: //
     17// tab-width: 4 //
     18// End: //
  • benchmark/ctxswitch/kos_fibre2.cpp

    r807a632 r3b56166  
    1111}
    1212
    13 int main(int argc, char* argv[]) {
     13int main( int argc, char * argv[] ) {
     14        BENCH_START()
    1415        Fibre* f1 = (new Fibre)->run(f1main);
    1516        BENCH(
    16                 for (size_t i = 0; i < n; i++) {
     17                for (size_t i = 0; i < times; i++) {
    1718                        Fibre::yield();
    1819                },
    1920                result
    2021        )
    21         printf("%g\n", result);
     22        printf( "%g\n", result );
    2223        done = true;
    2324        Fibre::yield();
    2425        f1->join();
    25         return 0;
    2626}
     27
     28// Local Variables: //
     29// tab-width: 4 //
     30// End: //
  • benchmark/ctxswitch/pthreads.c

    r807a632 r3b56166  
    66#include "bench.h"
    77
    8 int main(int argc, char* argv[]) {
     8int main( int argc, char * argv[] ) {
     9        BENCH_START()
    910        BENCH(
    10                 for (size_t i = 0; i < n; i++) {
     11                for (size_t i = 0; i < times; i++) {
    1112                        sched_yield();
    1213                },
    1314                result
    1415        )
    15 
    16         printf("%g\n", result);
     16        printf( "%g\n", result );
    1717}
  • benchmark/ctxswitch/upp_cor.cc

    r807a632 r3b56166  
    33#include "bench.h"
    44
    5 _Coroutine GreatSuspender {
    6 public:
    7         GreatSuspender() {
    8                 resume();
    9         }
    10 
    11         void do_resume() {
    12                 resume();
    13         }
    14 private:
     5_Coroutine C {
    156        void main() {
    167                while( true ) {
     
    189                }
    1910        }
    20 };
    21 
    22 int main(int argc, char* argv[]) {
    23         GreatSuspender s;
    24 
     11  public:
     12        void do_resume() {
     13                resume();
     14        }
     15} c;
     16int main( int argc, char * argv[] ) {
     17        BENCH_START()
    2518        BENCH(
    26                 for (size_t i = 0; i < n; i++) {
    27                         s.do_resume();
     19                for (size_t i = 0; i < times; i++) {
     20                        c.do_resume();
    2821                },
    2922                result
    3023        )
     24        printf( "%g\n", result );
     25}
    3126
    32         printf("%g\n", result);
    33 }
     27// Local Variables: //
     28// tab-width: 4 //
     29// End: //
  • benchmark/ctxswitch/upp_thrd.cc

    r807a632 r3b56166  
    33#include "bench.h"
    44
    5 int main(int argc, char* argv[]) {
     5int main( int argc, char * argv[] ) {
     6        BENCH_START()
    67        BENCH(
    7                 for (size_t i = 0; i < n; i++) {
     8                for (size_t i = 0; i < times; i++) {
    89                        uThisTask().yield();
    910                },
    1011                result
    1112        )
     13        printf( "%g\n", result );
     14}
    1215
    13         printf("%g\n", result);
    14 }
     16// Local Variables: //
     17// tab-width: 4 //
     18// End: //
  • benchmark/mutex/JavaThread.java

    r807a632 r3b56166  
    2626        static int x = 2;
    2727
    28         static private final int NoOfTimes = Integer.parseInt("100000000") ;
     28        static private int times = Integer.parseInt("100000000");
    2929
    3030        public synchronized void noop() {
     
    3535                // Inhibit biased locking ...
    3636                x = (j.hashCode() ^ System.identityHashCode(j)) | 1 ;     
    37                 for(int i = 1; i <= NoOfTimes; i += 1) {
     37                for(int i = 1; i <= times; i += 1) {
    3838                        x = nextRandom(x);
    3939                        j.noop();
     
    4444                helper();
    4545                long end = System.nanoTime();
    46                 System.out.println( (end - start) / NoOfTimes );
     46                System.out.println( (end - start) / times );
    4747        }
    4848        public static void main(String[] args) throws InterruptedException {
     49                if ( args.length > 2 ) System.exit( 1 );
     50                if ( args.length == 2 ) { times = Integer.parseInt(args[1]); }
     51
    4952                for (int n = Integer.parseInt("5"); --n >= 0 ; ) {
    5053                        InnerMain();
     
    5558        }
    5659}
     60
     61// Local Variables: //
     62// tab-width: 4 //
     63// End: //
  • benchmark/mutex/cfa1.cfa

    r807a632 r3b56166  
    44#include "bench.h"
    55
    6 monitor M {};
    7 void __attribute__((noinline)) call( M & mutex m ) {}
     6monitor M {} m1;
     7void __attribute__((noinline)) call( M & mutex p1 ) {}
    88
    9 int main(int argc, char* argv[]) {
    10         M m;
     9int main( int argc, char * argv[] ) {
     10        BENCH_START()
    1111        BENCH(
    12                 for ( i; n ) {
    13                         call(m);
     12                for ( times ) {
     13                        call( m1 );
    1414                },
    1515                result
    1616        )
     17        printf( "%g\n", result );
     18}
    1719
    18         printf("%g\n", result);
    19 }
     20// Local Variables: //
     21// tab-width: 4 //
     22// End: //
  • benchmark/mutex/cfa2.cfa

    r807a632 r3b56166  
    44#include "bench.h"
    55
    6 monitor M {};
    7 void __attribute__((noinline)) call( M & mutex m1, M & mutex m2 ) {}
     6monitor M {} m1, m2;
    87
    9 int main(int argc, char* argv[]) {
    10         M m1, m2;
     8void __attribute__((noinline)) call( M & mutex p1, M & mutex p2 ) {}
     9
     10int main( int argc, char * argv[] ) {
     11        BENCH_START()
    1112        BENCH(
    12                 for ( i; n ) {
    13                         call(m1, m2);
     13                for ( times ) {
     14                        call( m1, m2 );
    1415                },
    1516                result
    1617        )
     18        printf( "%g\n", result );
     19}
    1720
    18         printf("%g\n", result);
    19 }
     21// Local Variables: //
     22// tab-width: 4 //
     23// End: //
  • benchmark/mutex/cfa4.cfa

    r807a632 r3b56166  
    55
    66
    7 monitor M {};
    8 void __attribute__((noinline)) call( M & mutex m1, M & mutex m2, M & mutex m3, M & mutex m4 ) {}
     7monitor M {} m1, m2, m3, m4;
     8void __attribute__((noinline)) call( M & mutex p1, M & mutex p2, M & mutex p3, M & mutex p4 ) {}
    99
    10 int main(int argc, char* argv[]) {
    11         M m1, m2, m3, m4;
     10int main( int argc, char * argv[] ) {
     11        BENCH_START()
    1212        BENCH(
    13                 for ( i; n ) {
    14                         call(m1, m2, m3, m4);
     13                for ( times ) {
     14                        call( m1, m2, m3, m4 );
    1515                },
    1616                result
    1717        )
     18        printf( "%g\n", result );
     19}
    1820
    19         printf("%g\n", result);
    20 }
     21// Local Variables: //
     22// tab-width: 4 //
     23// End: //
  • benchmark/mutex/pthreads.c

    r807a632 r3b56166  
    77
    88void __attribute__((noinline)) call() {
    9          pthread_mutex_lock  (&mutex);
    10          pthread_mutex_unlock(&mutex);
     9         pthread_mutex_lock( &mutex );
     10         pthread_mutex_unlock( &mutex );
    1111}
    12 
    13 int main(int argc, char* argv[]) {
     12int main( int argc, char * argv[] ) {
     13        BENCH_START()
    1414        BENCH(
    15                 for (size_t i = 0; i < n; i++) {
     15                for ( size_t i = 0; i < times; i++ ) {
    1616                        call();
    1717                },
    1818                result
    1919        )
     20        printf( "%g\n", result );
     21}
    2022
    21         printf("%g\n", result);
    22 }
     23// Local Variables: //
     24// tab-width: 4 //
     25// End: //
  • benchmark/mutex/upp.cc

    r807a632 r3b56166  
    88};
    99
    10 int main(int argc, char* argv[]) {
     10int main( int argc, char * argv[] ) {
     11        BENCH_START()
    1112        MyMonitor m;
    1213        BENCH(
    13                 for (size_t i = 0; i < n; i++) {
     14                for ( size_t i = 0; i < times; i++ ) {
    1415                        m.call();
    1516                },
    1617                result
    1718        )
     19        printf( "%g\n", result );
     20}
    1821
    19         printf("%g\n", result);
    20 }
     22// Local Variables: //
     23// tab-width: 4 //
     24// End: //
  • benchmark/schedext/cfa1.cfa

    r807a632 r3b56166  
    44#include <stdio.h>
    55
    6 #include "bench.h"
     6#include "../bench.h"
    77
    8 int argc;
    9 char** argv;
    10 volatile int go = 0;
     8monitor M {} m1;
    119
    12 monitor M {};
    13 M m1;
    14 
    15 void __attribute__((noinline)) call( M & mutex a1 ) {}
    16 
    17 int  __attribute__((noinline)) wait( M & mutex a1 ) {
    18         go = 1;
    19         BENCH(
    20                 for ( i; n ) {
    21                         waitfor(call, a1);
    22                 },
    23                 result
    24         )
    25 
    26         printf("%g\n", result);
    27         go = 0;
    28         return 0;
     10void __attribute__((noinline)) call( M & mutex p1 ) {}
     11void __attribute__((noinline)) wait( M & mutex p1 ) {
     12        for ( times ) {
     13                waitfor( call : p1 );
     14        }
    2915}
    3016
    3117thread T {};
    32 void ^?{}( T & mutex this ) {}
    3318void main( T & ) {
    34         while(go == 0) { yield(); }
    35         while(go == 1) { call(m1); }
    36 
     19        BENCH(
     20                for ( times ) { call( m1 ); },
     21                result
     22        )
     23        printf( "%g\n", result );
    3724}
    3825
    39 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) {
     26int main( int argc, char * argv[] ) {
     27        BENCH_START()
    4028        T t;
    41         return wait(m1);
     29        wait( m1 );
    4230}
     31
     32// Local Variables: //
     33// tab-width: 4 //
     34// End: //
  • benchmark/schedext/cfa2.cfa

    r807a632 r3b56166  
    44#include <stdio.h>
    55
    6 #include "bench.h"
     6#include "../bench.h"
    77
    8 int argc;
    9 char** argv;
    10 volatile int go = 0;
     8monitor M {} m1, m2;
    119
    12 monitor M {};
    13 M m1, m2;
    14 
    15 void __attribute__((noinline)) call( M & mutex a1, M & mutex a2 ) {}
    16 
    17 int  __attribute__((noinline)) wait( M & mutex a1, M & mutex a2 ) {
    18         go = 1;
     10void __attribute__((noinline)) call( M & mutex p1, M & mutex p2 ) {}
     11void __attribute__((noinline)) wait( M & mutex p1, M & mutex p2 ) {
     12        for ( times ) {
     13                waitfor( call : p1, p2 );
     14        }
     15}
     16thread T {};
     17void main( T & ) {
    1918        BENCH(
    20                 for ( i; n ) {
    21                         waitfor(call, a1, a2);
     19                for ( times ) {
     20                        call( m1, m2 );
    2221                },
    2322                result
    2423        )
    25 
    26         printf("%g\n", result);
    27         go = 0;
    28         return 0;
     24        printf( "%g\n", result );
    2925}
    3026
    31 thread T {};
    32 void ^?{}( T & mutex this ) {}
    33 void main( T & ) {
    34         while(go == 0) { yield(); }
    35         while(go == 1) { call(m1, m2); }
    36 
     27int main( int argc, char * argv[] ) {
     28        BENCH_START()
     29        T t;
     30        wait( m1, m2 );
    3731}
    3832
    39 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) {
    40         T t;
    41         return wait(m1, m2);
    42 }
     33// Local Variables: //
     34// tab-width: 4 //
     35// End: //
  • benchmark/schedext/cfa4.cfa

    r807a632 r3b56166  
    44#include <stdio.h>
    55
    6 #include "bench.h"
     6#include "../bench.h"
    77
    8 int argc;
    9 char** argv;
    10 volatile int go = 0;
     8monitor M {} m1, m2, m3, m4;
    119
    12 monitor M {};
    13 M m1, m2, m3, m4;
    14 
    15 void __attribute__((noinline)) call( M & mutex a1, M & mutex a2, M & mutex a3, M & mutex a4 ) {}
    16 
    17 int  __attribute__((noinline)) wait( M & mutex a1, M & mutex a2, M & mutex a3, M & mutex a4 ) {
    18         go = 1;
     10void __attribute__((noinline)) call( M & mutex p1, M & mutex p2, M & mutex p3, M & mutex p4 ) {}
     11void __attribute__((noinline)) wait( M & mutex p1, M & mutex p2, M & mutex p3, M & mutex p4 ) {
     12        for ( times ) {
     13                waitfor( call : p1, p2, p3, p4 );
     14        }
     15}
     16thread T {};
     17void main( T & ) {
    1918        BENCH(
    20                 for ( i; n ) {
    21                         waitfor(call, a1, a2, a3, a4);
     19                for ( times ) {
     20                        call( m1, m2, m3, m4 );
    2221                },
    2322                result
    2423        )
    25 
    26         printf("%g\n", result);
    27         go = 0;
    28         return 0;
     24        printf( "%g\n", result );
    2925}
    3026
    31 thread T {};
    32 void ^?{}( T & mutex this ) {}
    33 void main( T & ) {
    34         while(go == 0) { yield(); }
    35         while(go == 1) { call(m1, m2, m3, m4); }
    36 
     27int main( int argc, char * argv[] ) {
     28        BENCH_START()
     29        T t;
     30        wait( m1, m2, m3, m4 );
    3731}
    3832
    39 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) {
    40         T t;
    41         return wait(m1, m2, m3, m4);
    42 }
     33// Local Variables: //
     34// tab-width: 4 //
     35// End: //
  • benchmark/schedext/upp.cc

    r807a632 r3b56166  
    33#include "bench.h"
    44
    5 int argc;
    6 char** argv;
    7 volatile int go = 0;
    8 
    95_Monitor M {
    106public:
    117        void __attribute__((noinline)) call() {}
     8        void __attribute__((noinline)) wait() {
     9                for ( size_t i = 0; i < times; i++ ) {
     10                        _Accept(call);
     11                }
     12        }
     13} m;
    1214
    13         int __attribute__((noinline)) wait() {
    14                 go = 1;
     15_Task T {
     16        void main() {
    1517                BENCH(
    16                         for (size_t i = 0; i < n; i++) {
    17                                 _Accept(call);
     18                        for ( size_t i = 0; i < times; i++ ) {
     19                                m.call();
    1820                        },
    1921                        result
    2022                )
    21 
    22                 printf("%g\n", result);
    23                 go = 0;
    24                 return 0;
     23                printf( "%g\n", result );
    2524        }
    2625};
    2726
    28 M m;
     27int main( int argc, char * argv[] ) {
     28        BENCH_START()
     29        T t;
     30        m.wait();
     31}
    2932
    30 _Task T {
    31         void main() {
    32                 while(go == 0) { yield(); }
    33                 while(go == 1) { m.call(); }
    34 
    35         }
    36 };
    37 
    38 int main(int margc, char* margv[]) {
    39         argc = margc;
    40         argv = margv;
    41         T t;
    42         return m.wait();
    43 }
     33// Local Variables: //
     34// tab-width: 4 //
     35// End: //
  • benchmark/schedint/JavaThread.java

    r807a632 r3b56166  
    4949        static int x = 2;
    5050
    51         static private final int NoOfTimes = Integer.parseInt("1000000") ;
     51        static private int times = Integer.parseInt("1000000");
    5252
    5353        public static void helper( Monitor m ) throws InterruptedException {
    54                 for(int i = 1; i <= NoOfTimes; i += 1) {
     54                for(int i = 1; i <= times; i += 1) {
    5555                        m.wait();               // relase monitor lock
    5656                        m.next = true;
     
    6363                synchronized(m) {
    6464                        s.start();
    65                         while( !Monitor.go ) {
     65                        while( ! Monitor.go ) { // waiter must start first
    6666                                Thread.yield();
    6767                        }
     
    7272                Monitor.go = false;
    7373                s.join();
    74                 System.out.println( (end - start) / NoOfTimes);
     74                System.out.println( (end - start) / times);
    7575        }
    7676        public static void main(String[] args) throws InterruptedException {
     77                if ( args.length > 2 ) System.exit( 1 );
     78                if ( args.length == 2 ) { times = Integer.parseInt(args[1]); }
     79
    7780                for (int n = Integer.parseInt("5"); --n >= 0 ; ) {
    7881                        InnerMain();
     
    8386        }
    8487}
     88
     89// Local Variables: //
     90// tab-width: 4 //
     91// End: //
  • benchmark/schedint/cfa1.cfa

    r807a632 r3b56166  
    44#include <stdio.h>
    55
    6 #include "bench.h"
     6#include "../bench.h"
    77
    8 int argc;
    9 char** argv;
    108volatile int go = 0;
    119
    1210condition c;
    13 monitor M {};
    14 M m1;
     11monitor M {} m1;
    1512
    16 void __attribute__((noinline)) call( M & mutex a1 ) {
    17         signal(c);
     13void __attribute__((noinline)) call( M & mutex p1 ) {
     14        signal( c );
    1815}
    19 
    20 int  __attribute__((noinline)) wait( M & mutex a1 ) {
     16void __attribute__((noinline)) wait( M & mutex p1 ) {
    2117        go = 1;
    22         BENCH(
    23                 for ( i; n ) {
    24                         wait(c);
    25                 },
    26                 result
    27         )
    28 
    29         printf("%g\n", result);
    30         go = 0;
    31         return 0;
     18        for ( times ) {
     19                wait( c );
     20        }
    3221}
    3322
    3423thread T {};
    35 void ^?{}( T & mutex ) {}
    3624void main( T & ) {
    37         while(go == 0) { yield(); }
    38         while(go == 1) { call(m1); }
    39 
     25        while ( go == 0 ) { yield(); } // waiter must start first
     26        BENCH(
     27                for ( times ) { call( m1 ); },
     28                result
     29        )
     30        printf( "%g\n", result );
    4031}
    4132
    42 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) {
     33int main( int argc, char * argv[] ) {
     34        BENCH_START()
    4335        T t;
    44         return wait(m1);
     36        wait( m1 );
    4537}
     38
     39// Local Variables: //
     40// tab-width: 4 //
     41// End: //
  • benchmark/schedint/cfa2.cfa

    r807a632 r3b56166  
    44#include <stdio.h>
    55
    6 #include "bench.h"
     6#include "../bench.h"
    77
    8 int argc;
    9 char** argv;
    108volatile int go = 0;
    119
    1210condition c;
    13 monitor M {};
    14 M m1, m2;
     11monitor M {} m1, m2;
    1512
    16 void __attribute__((noinline)) call( M & mutex a1, M & mutex a2 ) {
    17         signal(c);
     13void __attribute__((noinline)) call( M & mutex p1, M & mutex p2 ) {
     14        signal( c );
    1815}
    19 
    20 int  __attribute__((noinline)) wait( M & mutex a1, M & mutex a2 ) {
     16void __attribute__((noinline)) wait( M & mutex p1, M & mutex p2 ) {
    2117        go = 1;
    22         BENCH(
    23                 for ( i; n ) {
    24                         wait(c);
    25                 },
    26                 result
    27         )
    28 
    29         printf("%g\n", result);
    30         go = 0;
    31         return 0;
     18        for ( times ) {
     19                wait( c );
     20        }
    3221}
    3322
    3423thread T {};
    35 void ^?{}( T & mutex this ) {}
    3624void main( T & ) {
    37         while(go == 0) { yield(); }
    38         while(go == 1) { call(m1, m2); }
    39 
     25        while ( go == 0 ) { yield(); } // waiter must start first
     26        BENCH(
     27                for ( times ) { call( m1, m2 ); },
     28                result
     29        )
     30        printf( "%g\n", result );
    4031}
    4132
    42 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) {
     33int main( int argc, char * argv[] ) {
     34        BENCH_START()
    4335        T t;
    44         return wait(m1, m2);
     36        wait( m1, m2 );
    4537}
     38
     39// Local Variables: //
     40// tab-width: 4 //
     41// End: //
  • benchmark/schedint/cfa4.cfa

    r807a632 r3b56166  
    44#include <stdio.h>
    55
    6 #include "bench.h"
     6#include "../bench.h"
    77
    8 int argc;
    9 char** argv;
    108volatile int go = 0;
    119
    1210condition c;
    13 monitor M {};
    14 M m1, m2, m3, m4;
     11monitor M {} m1, m2, m3, m4;
    1512
    16 void __attribute__((noinline)) call( M & mutex a1, M & mutex a2, M & mutex a3, M & mutex a4 ) {
    17         signal(c);
     13void __attribute__((noinline)) call( M & mutex p1, M & mutex p2, M & mutex p3, M & mutex p4 ) {
     14        signal( c );
    1815}
    19 
    20 int  __attribute__((noinline)) wait( M & mutex a1, M & mutex a2, M & mutex a3, M & mutex a4 ) {
     16void __attribute__((noinline)) wait( M & mutex p1, M & mutex p2, M & mutex p3, M & mutex p4 ) {
    2117        go = 1;
    22         BENCH(
    23                 for ( i; n ) {
    24                         wait(c);
    25                 },
    26                 result
    27         )
    28 
    29         printf("%g\n", result);
    30         go = 0;
    31         return 0;
     18        for ( times ) {
     19                wait( c );
     20        }
    3221}
    3322
    3423thread T {};
    35 void ^?{}( T & mutex this ) {}
    3624void main( T & ) {
    37         while(go == 0) { yield(); }
    38         while(go == 1) { call(m1, m2, m3, m4); }
    39 
     25        while ( go == 0 ) { yield(); } // waiter must start first
     26        BENCH(
     27                for ( times ) { call( m1, m2, m3, m4 ); },
     28                result
     29        )
     30        printf( "%g\n", result );
    4031}
    4132
    42 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) {
     33int main( int argc, char * argv[] ) {
     34        BENCH_START()
    4335        T t;
    44         return wait(m1, m2, m3, m4);
     36        wait( m1, m2, m3, m4 );
    4537}
     38
     39// Local Variables: //
     40// tab-width: 4 //
     41// End: //
  • benchmark/schedint/pthreads.c

    r807a632 r3b56166  
    44#include "bench.h"
    55
    6 int argc;
    7 char** argv;
    86volatile int go = 0;
    97
     8pthread_mutex_t m;
    109pthread_cond_t c;
    11 pthread_mutex_t m;
    1210
    1311void __attribute__((noinline)) call() {
    14         pthread_mutex_lock(&m);
    15         pthread_cond_signal(&c);
    16         pthread_mutex_unlock(&m);
     12        pthread_mutex_lock( &m );
     13        pthread_cond_signal( &c );
     14        pthread_mutex_unlock( &m );
    1715}
    1816
    19 int __attribute__((noinline)) wait() {
     17void __attribute__((noinline)) wait() {
    2018        pthread_mutex_lock(&m);
    2119        go = 1;
     20        for ( size_t i = 0; i < times; i++ ) {
     21                pthread_cond_wait( &c, &m );
     22        }
     23        go = 0;
     24        pthread_mutex_unlock( &m );
     25}
     26
     27void * thread_main( __attribute__((unused)) void * arg ) {
     28        while ( go == 0 ) { sched_yield(); } // waiter must start first
     29        // barging for lock acquire => may not execute N times
    2230        BENCH(
    23                 for (size_t i = 0; i < n; i++) {
    24                         pthread_cond_wait(&c, &m);
    25                 },
     31                while ( go == 1 ) { call(); },
    2632                result
    2733        )
    28 
    29         printf("%g\n", result);
    30         go = 0;
    31         pthread_mutex_unlock(&m);
    32         return 0;
    33 }
    34 
    35 void* thread_main(__attribute__((unused)) void * arg ) {
    36         while(go == 0) { sched_yield(); }
    37         while(go == 1) { call(); }
     34        printf( "%g\n", result );
    3835        return NULL;
    3936}
    4037
    41 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) {
     38int main( int argc, char * argv[] ) {
     39        BENCH_START()
    4240        pthread_t thread;
    43         if (pthread_create(&thread, NULL, thread_main, NULL) < 0) {
     41        if ( pthread_create( &thread, NULL, thread_main, NULL ) < 0 ) {
    4442                perror( "failure" );
    4543                return 1;
    4644        }
    4745        wait();
    48         if (pthread_join( thread, NULL) < 0) {
     46        if ( pthread_join( thread, NULL ) < 0 ) {
    4947                perror( "failure" );
    5048                return 1;
    5149        }
    52         return 0;
    5350}
     51
     52// Local Variables: //
     53// tab-width: 4 //
     54// End: //
  • benchmark/schedint/upp.cc

    r807a632 r3b56166  
    33#include "bench.h"
    44
    5 int argc;
    6 char** argv;
    75volatile int go = 0;
    86
     
    1311                cond.signal();
    1412        }
     13        void __attribute__((noinline)) wait() {
     14                go = 1;
     15                for ( size_t i = 0; i < times; i++ ) {
     16                        cond.wait();
     17                }
     18        }
     19} m;
    1520
    16         int __attribute__((noinline)) wait() {
    17                 go = 1;
     21_Task T {
     22        void main() {
     23                while ( go == 0 ) { yield(); } // waiter must start first
    1824                BENCH(
    19                         for (size_t i = 0; i < n; i++) {
    20                                 cond.wait();
     25                        for ( size_t i = 0; i < times; i++ ) {
     26                                m.call();
    2127                        },
    2228                        result
    2329                )
    24 
    25                 printf("%g\n", result);
    26                 go = 0;
    27                 return 0;
     30                printf( "%g\n", result );
    2831        }
    2932};
    3033
    31 M m;
     34int main( int argc, char * argv[] ) {
     35        BENCH_START()
     36        T t;
     37        m.wait();
     38}
    3239
    33 _Task T {
    34         void main() {
    35                 while(go == 0) { yield(); }
    36                 while(go == 1) { m.call(); }
    37 
    38         }
    39 };
    40 
    41 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) {
    42         T t;
    43         return m.wait();
    44 }
     40// Local Variables: //
     41// tab-width: 4 //
     42// End: //
  • driver/cc1.cc

    r807a632 r3b56166  
    335335        #endif // __DEBUG_H__
    336336
     337        enum {
     338                Color_Auto   = 0,
     339                Color_Always = 1,
     340                Color_Never  = 2,
     341        } color_arg = Color_Auto;
     342
     343        const char * color_names[3] = { "--colors=auto", "--colors=always", "--colors=never" };
     344
    337345        // process all the arguments
    338346
     
    341349                if ( prefix( arg, "-" ) ) {
    342350                        // strip inappropriate flags
     351
     352                        if ( prefix( arg, "-fdiagnostics-color=" ) ) {
     353                                string choice = arg.substr(20);
     354                                     if(choice == "always") color_arg = Color_Always;
     355                                else if(choice == "never" ) color_arg = Color_Never;
     356                                else if(choice == "auto"  ) color_arg = Color_Auto;
     357                        } else if ( arg == "-fno-diagnostics-color" ) {
     358                                color_arg = Color_Auto;
     359                        }
    343360
    344361                        if ( arg == "-quiet" || arg == "-version" || arg == "-fpreprocessed" ||
     
    440457                        cargs[ncargs++] = cfa_cpp_out.c_str();
    441458                } // if
     459
     460                cargs[ncargs++] = color_names[color_arg];
     461
    442462                cargs[ncargs] = nullptr;                                                // terminate argument list
    443463
  • driver/cfa.cc

    r807a632 r3b56166  
    1010// Created On       : Tue Aug 20 13:44:49 2002
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Sep 10 17:00:15 2019
    13 // Update Count     : 420
     12// Last Modified On : Fri Jan 31 16:48:03 2020
     13// Update Count     : 421
    1414//
    1515
     
    187187                        } else if ( arg == "-XCFA" ) {                          // CFA pass through
    188188                                i += 1;
     189                                if ( i == argc ) continue;                              // next argument available ?
    189190                                Putenv( argv, argv[i] );
    190191
     
    401402                args[nargs++] = "-Xlinker";
    402403                args[nargs++] = "--undefined=__cfaabi_appready_startup";
     404                args[nargs++] = "-z";
     405                args[nargs++] = "execstack";
    403406
    404407                // include the cfa library in case it is needed
     
    409412                args[nargs++] = "-Wl,--pop-state";
    410413                args[nargs++] = "-lcfa";
    411                 args[nargs++] = "-lpthread";
     414                args[nargs++] = "-pthread";
    412415                args[nargs++] = "-ldl";
    413416                args[nargs++] = "-lrt";
  • libcfa/automake/missing

    • Property mode changed from 120000 to 100644
    r807a632 r3b56166  
    1 /usr/share/automake-1.15/missing
     1#! /bin/sh
     2# Tdelisle : having the Makefiles.in automatically regenerated causes problems
     3#            when using multiple versions of automake, even if only on end user machines
     4#            therefore I am disabling that feature by commenting this script
     5exit 0
  • libcfa/configure

    r807a632 r3b56166  
    30003000case $CONFIGURATION in
    30013001        "debug"   )
    3002                 CONFIG_CFLAGS="-Og -g"
     3002                CONFIG_CFLAGS="-O0 -g"
    30033003                CONFIG_CFAFLAGS="-debug"
    30043004                CONFIG_BUILDLIB="yes"
  • libcfa/configure.ac

    r807a632 r3b56166  
    6868case $CONFIGURATION in
    6969        "debug"   )
    70                 CONFIG_CFLAGS="-Og -g"
     70                CONFIG_CFLAGS="-O0 -g"
    7171                CONFIG_CFAFLAGS="-debug"
    7272                CONFIG_BUILDLIB="yes"
  • libcfa/prelude/Makefile.am

    r807a632 r3b56166  
    1111## Created On       : Sun May 31 08:54:01 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Wed Dec 14 15:00:35 2016
    14 ## Update Count     : 205
     13## Last Modified On : Mon Feb  3 21:27:18 2020
     14## Update Count     : 208
    1515###############################################################################
    1616
     
    3636extras.cf : ${srcdir}/extras.regx ${srcdir}/extras.c
    3737        ${AM_V_GEN}gcc ${AM_CFLAGS} -E ${srcdir}/extras.c | grep -f ${srcdir}/extras.regx > extras.cf
     38        ${AM_V_GEN}gcc ${AM_CFLAGS} -E ${srcdir}/extras.c | grep -zo -f ${srcdir}/extras.regx2 | tr '\0' '\n' >> extras.cf
    3839
    3940# create forward declarations for gcc builtins
  • libcfa/prelude/Makefile.in

    r807a632 r3b56166  
    1 # Makefile.in generated by automake 1.15 from Makefile.am.
     1# Makefile.in generated by automake 1.16.1 from Makefile.am.
    22# @configure_input@
    33
    4 # Copyright (C) 1994-2014 Free Software Foundation, Inc.
     4# Copyright (C) 1994-2018 Free Software Foundation, Inc.
    55
    66# This Makefile.in is free software; the Free Software Foundation
     
    331331            cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
    332332          *) \
    333             echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
    334             cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
     333            echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
     334            cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
    335335        esac;
    336336
     
    377377
    378378
    379 distdir: $(DISTFILES)
     379distdir: $(BUILT_SOURCES)
     380        $(MAKE) $(AM_MAKEFLAGS) distdir-am
     381
     382distdir-am: $(DISTFILES)
    380383        @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
    381384        topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
     
    540543extras.cf : ${srcdir}/extras.regx ${srcdir}/extras.c
    541544        ${AM_V_GEN}gcc ${AM_CFLAGS} -E ${srcdir}/extras.c | grep -f ${srcdir}/extras.regx > extras.cf
     545        ${AM_V_GEN}gcc ${AM_CFLAGS} -E ${srcdir}/extras.c | grep -zo -f ${srcdir}/extras.regx2 | tr '\0' '\n' >> extras.cf
    542546
    543547# create forward declarations for gcc builtins
  • libcfa/prelude/builtins.c

    r807a632 r3b56166  
    1010// Created On       : Fri Jul 21 16:21:03 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jun 25 18:06:52 2019
    13 // Update Count     : 97
     12// Last Modified On : Thu Nov 21 16:31:39 2019
     13// Update Count     : 101
    1414//
    1515
     
    6969
    7070// universal typed pointer constant
    71 // Compiler issue: there is a problem with anonymous types that do not have a size.
    72 static inline forall( dtype DT | sized(DT) ) DT * intptr( uintptr_t addr ) { return (DT *)addr; }
     71static inline forall( dtype DT ) DT * intptr( uintptr_t addr ) { return (DT *)addr; }
    7372
    7473// exponentiation operator implementation
  • libcfa/prelude/extras.regx

    r807a632 r3b56166  
    2424typedef.* char32_t;
    2525typedef.* wchar_t;
    26 extern.*\*malloc\(.*\).*
    27 extern.* free\(.*\).*
    28 extern.* exit\(.*\).*
    29 extern.* atexit\(.*\).*
    30 extern.* abort\(.*\).*
    31 extern.* printf\(.*\).*
  • libcfa/prelude/prototypes.awk

    r807a632 r3b56166  
    1010# Created On       : Sat May 16 07:57:37 2015
    1111# Last Modified By : Peter A. Buhr
    12 # Last Modified On : Thu Jun  6 20:46:28 2019
    13 # Update Count     : 34
     12# Last Modified On : Sat Feb  8 09:46:58 2020
     13# Update Count     : 36
    1414#
    1515
     
    1717
    1818BEGIN {
    19   FS = "[( )]"
     19        FS = "[( )]"
    2020        # order so string search is longest string
    2121        i=-1
     
    8484
    8585/BT_FN/ {
    86         for (i = 1; i <= NF; i++) {
    87           if( match($i, "BT_FN") != 0 ) {
    88                 prototypes[$i] = $i
    89           }
     86        for (i = 1; i <= NF; i += 1 ) {
     87                if ( match($i, "BT_FN") != 0 ) {
     88                        prototypes[$i] = $i
     89                }
    9090        }
    91   }
     91}
    9292
    9393END {
     
    103103
    104104        for ( prototype in prototypes ) {
    105           # printf( "//\"%s\"\n", prototype )
    106           if ( index( "BT_LAST", prototype ) == 1 ) {
    107                 continue
    108           } # if
     105                # printf( "//\"%s\"\n", prototype )
     106                if ( index( "BT_LAST", prototype ) == 1 ) {
     107                        continue
     108                } # if
    109109
    110           printf( "#define %s(NAME) FUNC_SIMPLE(", prototype )
     110                printf( "#define %s(NAME) FUNC_SIMPLE(", prototype )
    111111
    112           if ( sub( "BT_FN_", "", prototype ) == 0 ) {
    113                 printf( "\n********** BAD MACRO NAME \"%s\" **********\n", prototype )
    114                 exit 0
    115           } # if
     112                if ( sub( "BT_FN_", "", prototype ) == 0 ) {
     113                        printf( "\n********** BAD MACRO NAME \"%s\" **********\n", prototype )
     114                        exit 0
     115                } # if
    116116
    117           # generate function return type as macro
    118           for ( t = 0; t < N; t += 1 ) {                                        # find longest match
    119                 type = types[t];
    120                 if ( index( prototype, type ) == 1 ) {          # found match
    121                   printf( "BT_%s, NAME", type )
    122                   sub( type, "", prototype )
    123                   break;
     117                # generate function return type as macro
     118                for ( t = 0; t < N; t += 1 ) {                                  # find longest match
     119                        type = types[t];
     120                        if ( index( prototype, type ) == 1 ) {          # found match
     121                                printf( "BT_%s, NAME", type )
     122                                sub( type, "", prototype )
     123                                break;
     124                        } # if
     125                } # for
     126
     127                # generate function parameter types as macro
     128                if ( index( prototype, "VAR" ) != 2 ) {                 # C-style empty parameters ?
     129                        for ( p = 0; length( prototype ) > 0; p += 1 ) { # until all parameters types are removed
     130                                sub( "_", "", prototype)                                # remove "_"
     131                                printf( ", ", type )
     132                                temp = prototype
     133                                for ( t = 0; t < N; t += 1 ) {                  # find longest match
     134                                        type = types[t];
     135                                        if ( index( prototype, type ) == 1 ) { # found match
     136                                                printf( "BT_%s", type )
     137                                                sub( type, "", prototype )
     138                                                break;
     139                                        } # if
     140                                } # for
     141                                if ( temp == prototype ) {                              # no match found for parameter in macro table
     142                                        printf( "\n********** MISSING TYPE \"%s\" **********\n", prototype )
     143                                        exit 0
     144                                } # if
     145                        } # for
    124146                } # if
    125           } # for
    126 
    127           # generate function parameter types as macro
    128           if ( index( prototype, "VAR" ) != 2 ) {                       # C-style empty parameters ?
    129                 for ( p = 0; length( prototype ) > 0; p += 1 ) { # until all parameters types are removed
    130                   sub( "_", "", prototype)                              # remove "_"
    131                   printf( ", ", type )
    132                   temp = prototype
    133                   for ( t = 0; t < N; t += 1 ) {                        # find longest match
    134                         type = types[t];
    135                         if ( index( prototype, type ) == 1 ) { # found match
    136                           printf( "BT_%s", type )
    137                           sub( type, "", prototype )
    138                           break;
    139                         } # if
    140                   } # for
    141                   if ( temp == prototype ) {                            # no match found for parameter in macro table
    142                         printf( "\n********** MISSING TYPE \"%s\" **********\n", prototype )
    143                         exit 0
    144                   } # if
    145                 } # for
    146           } # if
    147           printf( ")\n" )
     147                printf( ")\n" )
    148148        } # for
    149149
  • libcfa/prelude/sync-builtins.cf

    r807a632 r3b56166  
    11char __sync_fetch_and_add(volatile char *, char,...);
    2 char __sync_fetch_and_add_1(volatile char *, char,...);
    32signed char __sync_fetch_and_add(volatile signed char *, signed char,...);
    4 signed char __sync_fetch_and_add_1(volatile signed char *, signed char,...);
    53unsigned char __sync_fetch_and_add(volatile unsigned char *, unsigned char,...);
    6 unsigned char __sync_fetch_and_add_1(volatile unsigned char *, unsigned char,...);
    74signed short __sync_fetch_and_add(volatile signed short *, signed short,...);
    8 signed short __sync_fetch_and_add_2(volatile signed short *, signed short,...);
    95unsigned short __sync_fetch_and_add(volatile unsigned short *, unsigned short,...);
    10 unsigned short __sync_fetch_and_add_2(volatile unsigned short *, unsigned short,...);
    116signed int __sync_fetch_and_add(volatile signed int *, signed int,...);
    12 signed int __sync_fetch_and_add_4(volatile signed int *, signed int,...);
    137unsigned int __sync_fetch_and_add(volatile unsigned int *, unsigned int,...);
    14 unsigned int __sync_fetch_and_add_4(volatile unsigned int *, unsigned int,...);
     8signed long int __sync_fetch_and_add(volatile signed long int *, signed long int,...);
     9unsigned long int __sync_fetch_and_add(volatile unsigned long int *, unsigned long int,...);
    1510signed long long int __sync_fetch_and_add(volatile signed long long int *, signed long long int,...);
    16 signed long long int __sync_fetch_and_add_8(volatile signed long long int *, signed long long int,...);
    1711unsigned long long int __sync_fetch_and_add(volatile unsigned long long int *, unsigned long long int,...);
    18 unsigned long long int __sync_fetch_and_add_8(volatile unsigned long long int *, unsigned long long int,...);
    1912#if defined(__SIZEOF_INT128__)
    2013signed __int128 __sync_fetch_and_add(volatile signed __int128 *, signed __int128,...);
    21 signed __int128 __sync_fetch_and_add_16(volatile signed __int128 *, signed __int128,...);
    2214unsigned __int128 __sync_fetch_and_add(volatile unsigned __int128 *, unsigned __int128,...);
    23 unsigned __int128 __sync_fetch_and_add_16(volatile unsigned __int128 *, unsigned __int128,...);
    2415#endif
    2516
    2617char __sync_fetch_and_sub(volatile char *, char,...);
    27 char __sync_fetch_and_sub_1(volatile char *, char,...);
    2818signed char __sync_fetch_and_sub(volatile signed char *, signed char,...);
    29 signed char __sync_fetch_and_sub_1(volatile signed char *, signed char,...);
    3019unsigned char __sync_fetch_and_sub(volatile unsigned char *, unsigned char,...);
    31 unsigned char __sync_fetch_and_sub_1(volatile unsigned char *, unsigned char,...);
    3220signed short __sync_fetch_and_sub(volatile signed short *, signed short,...);
    33 signed short __sync_fetch_and_sub_2(volatile signed short *, signed short,...);
    3421unsigned short __sync_fetch_and_sub(volatile unsigned short *, unsigned short,...);
    35 unsigned short __sync_fetch_and_sub_2(volatile unsigned short *, unsigned short,...);
    3622signed int __sync_fetch_and_sub(volatile signed int *, signed int,...);
    37 signed int __sync_fetch_and_sub_4(volatile signed int *, signed int,...);
    3823unsigned int __sync_fetch_and_sub(volatile unsigned int *, unsigned int,...);
    39 unsigned int __sync_fetch_and_sub_4(volatile unsigned int *, unsigned int,...);
     24signed long int __sync_fetch_and_sub(volatile signed long int *, signed long int,...);
     25unsigned long int __sync_fetch_and_sub(volatile unsigned long int *, unsigned long int,...);
    4026signed long long int __sync_fetch_and_sub(volatile signed long long int *, signed long long int,...);
    41 signed long long int __sync_fetch_and_sub_8(volatile signed long long int *, signed long long int,...);
    4227unsigned long long int __sync_fetch_and_sub(volatile unsigned long long int *, unsigned long long int,...);
    43 unsigned long long int __sync_fetch_and_sub_8(volatile unsigned long long int *, unsigned long long int,...);
    4428#if defined(__SIZEOF_INT128__)
    4529signed __int128 __sync_fetch_and_sub(volatile signed __int128 *, signed __int128,...);
    46 signed __int128 __sync_fetch_and_sub_16(volatile signed __int128 *, signed __int128,...);
    4730unsigned __int128 __sync_fetch_and_sub(volatile unsigned __int128 *, unsigned __int128,...);
    48 unsigned __int128 __sync_fetch_and_sub_16(volatile unsigned __int128 *, unsigned __int128,...);
    4931#endif
    5032
    5133char __sync_fetch_and_or(volatile char *, char,...);
    52 char __sync_fetch_and_or_1(volatile char *, char,...);
    5334signed char __sync_fetch_and_or(volatile signed char *, signed char,...);
    54 signed char __sync_fetch_and_or_1(volatile signed char *, signed char,...);
    5535unsigned char __sync_fetch_and_or(volatile unsigned char *, unsigned char,...);
    56 unsigned char __sync_fetch_and_or_1(volatile unsigned char *, unsigned char,...);
    5736signed short __sync_fetch_and_or(volatile signed short *, signed short,...);
    58 signed short __sync_fetch_and_or_2(volatile signed short *, signed short,...);
    5937unsigned short __sync_fetch_and_or(volatile unsigned short *, unsigned short,...);
    60 unsigned short __sync_fetch_and_or_2(volatile unsigned short *, unsigned short,...);
    6138signed int __sync_fetch_and_or(volatile signed int *, signed int,...);
    62 signed int __sync_fetch_and_or_4(volatile signed int *, signed int,...);
    6339unsigned int __sync_fetch_and_or(volatile unsigned int *, unsigned int,...);
    64 unsigned int __sync_fetch_and_or_4(volatile unsigned int *, unsigned int,...);
     40signed long int __sync_fetch_and_or(volatile signed long int *, signed long int,...);
     41unsigned long int __sync_fetch_and_or(volatile unsigned long int *, unsigned long int,...);
    6542signed long long int __sync_fetch_and_or(volatile signed long long int *, signed long long int,...);
    66 signed long long int __sync_fetch_and_or_8(volatile signed long long int *, signed long long int,...);
    6743unsigned long long int __sync_fetch_and_or(volatile unsigned long long int *, unsigned long long int,...);
    68 unsigned long long int __sync_fetch_and_or_8(volatile unsigned long long int *, unsigned long long int,...);
    6944#if defined(__SIZEOF_INT128__)
    7045signed __int128 __sync_fetch_and_or(volatile signed __int128 *, signed __int128,...);
    71 signed __int128 __sync_fetch_and_or_16(volatile signed __int128 *, signed __int128,...);
    7246unsigned __int128 __sync_fetch_and_or(volatile unsigned __int128 *, unsigned __int128,...);
    73 unsigned __int128 __sync_fetch_and_or_16(volatile unsigned __int128 *, unsigned __int128,...);
    7447#endif
    7548
    7649char __sync_fetch_and_and(volatile char *, char,...);
    77 char __sync_fetch_and_and_1(volatile char *, char,...);
    7850signed char __sync_fetch_and_and(volatile signed char *, signed char,...);
    79 signed char __sync_fetch_and_and_1(volatile signed char *, signed char,...);
    8051unsigned char __sync_fetch_and_and(volatile unsigned char *, unsigned char,...);
    81 unsigned char __sync_fetch_and_and_1(volatile unsigned char *, unsigned char,...);
    8252signed short __sync_fetch_and_and(volatile signed short *, signed short,...);
    83 signed short __sync_fetch_and_and_2(volatile signed short *, signed short,...);
    8453unsigned short __sync_fetch_and_and(volatile unsigned short *, unsigned short,...);
    85 unsigned short __sync_fetch_and_and_2(volatile unsigned short *, unsigned short,...);
    8654signed int __sync_fetch_and_and(volatile signed int *, signed int,...);
    87 signed int __sync_fetch_and_and_4(volatile signed int *, signed int,...);
    8855unsigned int __sync_fetch_and_and(volatile unsigned int *, unsigned int,...);
    89 unsigned int __sync_fetch_and_and_4(volatile unsigned int *, unsigned int,...);
     56signed long int __sync_fetch_and_and(volatile signed long int *, signed long int,...);
     57unsigned long int __sync_fetch_and_and(volatile unsigned long int *, unsigned long int,...);
    9058signed long long int __sync_fetch_and_and(volatile signed long long int *, signed long long int,...);
    91 signed long long int __sync_fetch_and_and_8(volatile signed long long int *, signed long long int,...);
    9259unsigned long long int __sync_fetch_and_and(volatile unsigned long long int *, unsigned long long int,...);
    93 unsigned long long int __sync_fetch_and_and_8(volatile unsigned long long int *, unsigned long long int,...);
    9460#if defined(__SIZEOF_INT128__)
    9561signed __int128 __sync_fetch_and_and(volatile signed __int128 *, signed __int128,...);
    96 signed __int128 __sync_fetch_and_and_16(volatile signed __int128 *, signed __int128,...);
    9762unsigned __int128 __sync_fetch_and_and(volatile unsigned __int128 *, unsigned __int128,...);
    98 unsigned __int128 __sync_fetch_and_and_16(volatile unsigned __int128 *, unsigned __int128,...);
    9963#endif
    10064
    10165char __sync_fetch_and_xor(volatile char *, char,...);
    102 char __sync_fetch_and_xor_1(volatile char *, char,...);
    10366signed char __sync_fetch_and_xor(volatile signed char *, signed char,...);
    104 signed char __sync_fetch_and_xor_1(volatile signed char *, signed char,...);
    10567unsigned char __sync_fetch_and_xor(volatile unsigned char *, unsigned char,...);
    106 unsigned char __sync_fetch_and_xor_1(volatile unsigned char *, unsigned char,...);
    10768signed short __sync_fetch_and_xor(volatile signed short *, signed short,...);
    108 signed short __sync_fetch_and_xor_2(volatile signed short *, signed short,...);
    10969unsigned short __sync_fetch_and_xor(volatile unsigned short *, unsigned short,...);
    110 unsigned short __sync_fetch_and_xor_2(volatile unsigned short *, unsigned short,...);
    11170signed int __sync_fetch_and_xor(volatile signed int *, signed int,...);
    112 signed int __sync_fetch_and_xor_4(volatile signed int *, signed int,...);
    11371unsigned int __sync_fetch_and_xor(volatile unsigned int *, unsigned int,...);
    114 unsigned int __sync_fetch_and_xor_4(volatile unsigned int *, unsigned int,...);
     72signed long int __sync_fetch_and_xor(volatile signed long int *, signed long int,...);
     73unsigned long int __sync_fetch_and_xor(volatile unsigned long int *, unsigned long int,...);
    11574signed long long int __sync_fetch_and_xor(volatile signed long long int *, signed long long int,...);
    116 signed long long int __sync_fetch_and_xor_8(volatile signed long long int *, signed long long int,...);
    11775unsigned long long int __sync_fetch_and_xor(volatile unsigned long long int *, unsigned long long int,...);
    118 unsigned long long int __sync_fetch_and_xor_8(volatile unsigned long long int *, unsigned long long int,...);
    11976#if defined(__SIZEOF_INT128__)
    12077signed __int128 __sync_fetch_and_xor(volatile signed __int128 *, signed __int128,...);
    121 signed __int128 __sync_fetch_and_xor_16(volatile signed __int128 *, signed __int128,...);
    12278unsigned __int128 __sync_fetch_and_xor(volatile unsigned __int128 *, unsigned __int128,...);
    123 unsigned __int128 __sync_fetch_and_xor_16(volatile unsigned __int128 *, unsigned __int128,...);
    12479#endif
    12580
    12681char __sync_fetch_and_nand(volatile char *, char,...);
    127 char __sync_fetch_and_nand_1(volatile char *, char,...);
    12882signed char __sync_fetch_and_nand(volatile signed char *, signed char,...);
    129 signed char __sync_fetch_and_nand_1(volatile signed char *, signed char,...);
    13083unsigned char __sync_fetch_and_nand(volatile unsigned char *, unsigned char,...);
    131 unsigned char __sync_fetch_and_nand_1(volatile unsigned char *, unsigned char,...);
    13284signed short __sync_fetch_and_nand(volatile signed short *, signed short,...);
    133 signed short __sync_fetch_and_nand_2(volatile signed short *, signed short,...);
    13485unsigned short __sync_fetch_and_nand(volatile unsigned short *, unsigned short,...);
    135 unsigned short __sync_fetch_and_nand_2(volatile unsigned short *, unsigned short,...);
    13686signed int __sync_fetch_and_nand(volatile signed int *, signed int,...);
    137 signed int __sync_fetch_and_nand_4(volatile signed int *, signed int,...);
    13887unsigned int __sync_fetch_and_nand(volatile unsigned int *, unsigned int,...);
    139 unsigned int __sync_fetch_and_nand_4(volatile unsigned int *, unsigned int,...);
     88signed long int __sync_fetch_and_nand(volatile signed long int *, signed long int,...);
     89unsigned long int __sync_fetch_and_nand(volatile unsigned long int *, unsigned long int,...);
    14090signed long long int __sync_fetch_and_nand(volatile signed long long int *, signed long long int,...);
    141 signed long long int __sync_fetch_and_nand_8(volatile signed long long int *, signed long long int,...);
    14291unsigned long long int __sync_fetch_and_nand(volatile unsigned long long int *, unsigned long long int,...);
    143 unsigned long long int __sync_fetch_and_nand_8(volatile unsigned long long int *, unsigned long long int,...);
    14492#if defined(__SIZEOF_INT128__)
    14593signed __int128 __sync_fetch_and_nand(volatile signed __int128 *, signed __int128,...);
    146 signed __int128 __sync_fetch_and_nand_16(volatile signed __int128 *, signed __int128,...);
    14794unsigned __int128 __sync_fetch_and_nand(volatile unsigned __int128 *, unsigned __int128,...);
    148 unsigned __int128 __sync_fetch_and_nand_16(volatile unsigned __int128 *, unsigned __int128,...);
    14995#endif
    15096
    15197char __sync_add_and_fetch(volatile char *, char,...);
    152 char __sync_add_and_fetch_1(volatile char *, char,...);
    15398signed char __sync_add_and_fetch(volatile signed char *, signed char,...);
    154 signed char __sync_add_and_fetch_1(volatile signed char *, signed char,...);
    15599unsigned char __sync_add_and_fetch(volatile unsigned char *, unsigned char,...);
    156 unsigned char __sync_add_and_fetch_1(volatile unsigned char *, unsigned char,...);
    157100signed short __sync_add_and_fetch(volatile signed short *, signed short,...);
    158 signed short __sync_add_and_fetch_2(volatile signed short *, signed short,...);
    159101unsigned short __sync_add_and_fetch(volatile unsigned short *, unsigned short,...);
    160 unsigned short __sync_add_and_fetch_2(volatile unsigned short *, unsigned short,...);
    161102signed int __sync_add_and_fetch(volatile signed int *, signed int,...);
    162 signed int __sync_add_and_fetch_4(volatile signed int *, signed int,...);
    163103signed int __sync_add_and_fetch(volatile signed int *, signed int,...);
    164 signed int __sync_add_and_fetch_4(volatile signed int *, signed int,...);
     104signed long int __sync_add_and_fetch(volatile signed long int *, signed long int,...);
     105unsigned long int __sync_add_and_fetch(volatile unsigned long int *, unsigned long int,...);
    165106signed long long int __sync_add_and_fetch(volatile signed long long int *, signed long long int,...);
    166 signed long long int __sync_add_and_fetch_8(volatile signed long long int *, signed long long int,...);
    167107unsigned long long int __sync_add_and_fetch(volatile unsigned long long int *, unsigned long long int,...);
    168 unsigned long long int __sync_add_and_fetch_8(volatile unsigned long long int *, unsigned long long int,...);
    169108#if defined(__SIZEOF_INT128__)
    170109signed __int128 __sync_add_and_fetch(volatile signed __int128 *, signed __int128,...);
    171 signed __int128 __sync_add_and_fetch_16(volatile signed __int128 *, signed __int128,...);
    172110unsigned __int128 __sync_add_and_fetch(volatile unsigned __int128 *, unsigned __int128,...);
    173 unsigned __int128 __sync_add_and_fetch_16(volatile unsigned __int128 *, unsigned __int128,...);
    174111#endif
    175112
    176113char __sync_sub_and_fetch(volatile char *, char,...);
    177 char __sync_sub_and_fetch_1(volatile char *, char,...);
    178114signed char __sync_sub_and_fetch(volatile signed char *, signed char,...);
    179 signed char __sync_sub_and_fetch_1(volatile signed char *, signed char,...);
    180115unsigned char __sync_sub_and_fetch(volatile unsigned char *, unsigned char,...);
    181 unsigned char __sync_sub_and_fetch_1(volatile unsigned char *, unsigned char,...);
    182116signed short __sync_sub_and_fetch(volatile signed short *, signed short,...);
    183 signed short __sync_sub_and_fetch_2(volatile signed short *, signed short,...);
    184117unsigned short __sync_sub_and_fetch(volatile unsigned short *, unsigned short,...);
    185 unsigned short __sync_sub_and_fetch_2(volatile unsigned short *, unsigned short,...);
    186118signed int __sync_sub_and_fetch(volatile signed int *, signed int,...);
    187 signed int __sync_sub_and_fetch_4(volatile signed int *, signed int,...);
    188119unsigned int __sync_sub_and_fetch(volatile unsigned int *, unsigned int,...);
    189 unsigned int __sync_sub_and_fetch_4(volatile unsigned int *, unsigned int,...);
     120signed long int __sync_sub_and_fetch(volatile signed long int *, signed long int,...);
     121unsigned long int __sync_sub_and_fetch(volatile unsigned long int *, unsigned long int,...);
    190122signed long long int __sync_sub_and_fetch(volatile signed long long int *, signed long long int,...);
    191 signed long long int __sync_sub_and_fetch_8(volatile signed long long int *, signed long long int,...);
    192123unsigned long long int __sync_sub_and_fetch(volatile unsigned long long int *, unsigned long long int,...);
    193 unsigned long long int __sync_sub_and_fetch_8(volatile unsigned long long int *, unsigned long long int,...);
    194124#if defined(__SIZEOF_INT128__)
    195125signed __int128 __sync_sub_and_fetch(volatile signed __int128 *, signed __int128,...);
    196 signed __int128 __sync_sub_and_fetch_16(volatile signed __int128 *, signed __int128,...);
    197126unsigned __int128 __sync_sub_and_fetch(volatile unsigned __int128 *, unsigned __int128,...);
    198 unsigned __int128 __sync_sub_and_fetch_16(volatile unsigned __int128 *, unsigned __int128,...);
    199127#endif
    200128
    201129char __sync_or_and_fetch(volatile char *, char,...);
    202 char __sync_or_and_fetch_1(volatile char *, char,...);
    203130signed char __sync_or_and_fetch(volatile signed char *, signed char,...);
    204 signed char __sync_or_and_fetch_1(volatile signed char *, signed char,...);
    205131unsigned char __sync_or_and_fetch(volatile unsigned char *, unsigned char,...);
    206 unsigned char __sync_or_and_fetch_1(volatile unsigned char *, unsigned char,...);
    207132signed short __sync_or_and_fetch(volatile signed short *, signed short,...);
    208 signed short __sync_or_and_fetch_2(volatile signed short *, signed short,...);
    209133unsigned short __sync_or_and_fetch(volatile unsigned short *, unsigned short,...);
    210 unsigned short __sync_or_and_fetch_2(volatile unsigned short *, unsigned short,...);
    211134signed int __sync_or_and_fetch(volatile signed int *, signed int,...);
    212 signed int __sync_or_and_fetch_4(volatile signed int *, signed int,...);
    213135unsigned int __sync_or_and_fetch(volatile unsigned int *, unsigned int,...);
    214 unsigned int __sync_or_and_fetch_4(volatile unsigned int *, unsigned int,...);
     136signed long int __sync_or_and_fetch(volatile signed long int *, signed long int,...);
     137unsigned long int __sync_or_and_fetch(volatile unsigned long int *, unsigned long int,...);
    215138signed long long int __sync_or_and_fetch(volatile signed long long int *, signed long long int,...);
    216 signed long long int __sync_or_and_fetch_8(volatile signed long long int *, signed long long int,...);
    217139unsigned long long int __sync_or_and_fetch(volatile unsigned long long int *, unsigned long long int,...);
    218 unsigned long long int __sync_or_and_fetch_8(volatile unsigned long long int *, unsigned long long int,...);
    219140#if defined(__SIZEOF_INT128__)
    220141signed __int128 __sync_or_and_fetch(volatile signed __int128 *, signed __int128,...);
    221 signed __int128 __sync_or_and_fetch_16(volatile signed __int128 *, signed __int128,...);
    222142unsigned __int128 __sync_or_and_fetch(volatile unsigned __int128 *, unsigned __int128,...);
    223 unsigned __int128 __sync_or_and_fetch_16(volatile unsigned __int128 *, unsigned __int128,...);
    224143#endif
    225144
    226145char __sync_and_and_fetch(volatile char *, char,...);
    227 char __sync_and_and_fetch_1(volatile char *, char,...);
    228146signed char __sync_and_and_fetch(volatile signed char *, signed char,...);
    229 signed char __sync_and_and_fetch_1(volatile signed char *, signed char,...);
    230147unsigned char __sync_and_and_fetch(volatile unsigned char *, unsigned char,...);
    231 unsigned char __sync_and_and_fetch_1(volatile unsigned char *, unsigned char,...);
    232148signed short __sync_and_and_fetch(volatile signed short *, signed short,...);
    233 signed short __sync_and_and_fetch_2(volatile signed short *, signed short,...);
    234149unsigned short __sync_and_and_fetch(volatile unsigned short *, unsigned short,...);
    235 unsigned short __sync_and_and_fetch_2(volatile unsigned short *, unsigned short,...);
    236150signed int __sync_and_and_fetch(volatile signed int *, signed int,...);
    237 signed int __sync_and_and_fetch_4(volatile signed int *, signed int,...);
    238151unsigned int __sync_and_and_fetch(volatile unsigned int *, unsigned int,...);
    239 unsigned int __sync_and_and_fetch_4(volatile unsigned int *, unsigned int,...);
     152signed long int __sync_and_and_fetch(volatile signed long int *, signed long int,...);
     153unsigned long int __sync_and_and_fetch(volatile unsigned long int *, unsigned long int,...);
    240154signed long long int __sync_and_and_fetch(volatile signed long long int *, signed long long int,...);
    241 signed long long int __sync_and_and_fetch_8(volatile signed long long int *, signed long long int,...);
    242155unsigned long long int __sync_and_and_fetch(volatile unsigned long long int *, unsigned long long int,...);
    243 unsigned long long int __sync_and_and_fetch_8(volatile unsigned long long int *, unsigned long long int,...);
    244156#if defined(__SIZEOF_INT128__)
    245157signed __int128 __sync_and_and_fetch(volatile signed __int128 *, signed __int128,...);
    246 signed __int128 __sync_and_and_fetch_16(volatile signed __int128 *, signed __int128,...);
    247158unsigned __int128 __sync_and_and_fetch(volatile unsigned __int128 *, unsigned __int128,...);
    248 unsigned __int128 __sync_and_and_fetch_16(volatile unsigned __int128 *, unsigned __int128,...);
    249159#endif
    250160
    251161char __sync_xor_and_fetch(volatile char *, char,...);
    252 char __sync_xor_and_fetch_1(volatile char *, char,...);
    253162signed char __sync_xor_and_fetch(volatile signed char *, signed char,...);
    254 signed char __sync_xor_and_fetch_1(volatile signed char *, signed char,...);
    255163unsigned char __sync_xor_and_fetch(volatile unsigned char *, unsigned char,...);
    256 unsigned char __sync_xor_and_fetch_1(volatile unsigned char *, unsigned char,...);
    257164signed short __sync_xor_and_fetch(volatile signed short *, signed short,...);
    258 signed short __sync_xor_and_fetch_2(volatile signed short *, signed short,...);
    259165unsigned short __sync_xor_and_fetch(volatile unsigned short *, unsigned short,...);
    260 unsigned short __sync_xor_and_fetch_2(volatile unsigned short *, unsigned short,...);
    261166signed int __sync_xor_and_fetch(volatile signed int *, signed int,...);
    262 signed int __sync_xor_and_fetch_4(volatile signed int *, signed int,...);
    263167unsigned int __sync_xor_and_fetch(volatile unsigned int *, unsigned int,...);
    264 unsigned int __sync_xor_and_fetch_4(volatile unsigned int *, unsigned int,...);
     168signed long int __sync_xor_and_fetch(volatile signed long int *, signed long int,...);
     169unsigned long int __sync_xor_and_fetch(volatile unsigned long int *, unsigned long int,...);
    265170signed long long int __sync_xor_and_fetch(volatile signed long long int *, signed long long int,...);
    266 signed long long int __sync_xor_and_fetch_8(volatile signed long long int *, signed long long int,...);
    267171unsigned long long int __sync_xor_and_fetch(volatile unsigned long long int *, unsigned long long int,...);
    268 unsigned long long int __sync_xor_and_fetch_8(volatile unsigned long long int *, unsigned long long int,...);
    269172#if defined(__SIZEOF_INT128__)
    270173signed __int128 __sync_xor_and_fetch(volatile signed __int128 *, signed __int128,...);
    271 signed __int128 __sync_xor_and_fetch_16(volatile signed __int128 *, signed __int128,...);
    272174unsigned __int128 __sync_xor_and_fetch(volatile unsigned __int128 *, unsigned __int128,...);
    273 unsigned __int128 __sync_xor_and_fetch_16(volatile unsigned __int128 *, unsigned __int128,...);
    274175#endif
    275176
    276177char __sync_nand_and_fetch(volatile char *, char,...);
    277 char __sync_nand_and_fetch_1(volatile char *, char,...);
    278178signed char __sync_nand_and_fetch(volatile signed char *, signed char,...);
    279 signed char __sync_nand_and_fetch_1(volatile signed char *, signed char,...);
    280179unsigned char __sync_nand_and_fetch(volatile unsigned char *, unsigned char,...);
    281 unsigned char __sync_nand_and_fetch_1(volatile unsigned char *, unsigned char,...);
    282180signed short __sync_nand_and_fetch(volatile signed short *, signed short,...);
    283 signed short __sync_nand_and_fetch_2(volatile signed short *, signed short,...);
    284181unsigned short __sync_nand_and_fetch(volatile unsigned short *, unsigned short,...);
    285 unsigned short __sync_nand_and_fetch_2(volatile unsigned short *, unsigned short,...);
    286182signed int __sync_nand_and_fetch(volatile signed int *, signed int,...);
    287 signed int __sync_nand_and_fetch_4(volatile signed int *, signed int,...);
    288183unsigned int __sync_nand_and_fetch(volatile unsigned int *, unsigned int,...);
    289 unsigned int __sync_nand_and_fetch_4(volatile unsigned int *, unsigned int,...);
     184signed long int __sync_nand_and_fetch(volatile signed long int *, signed long int,...);
     185unsigned long int __sync_nand_and_fetch(volatile unsigned long int *, unsigned long int,...);
    290186signed long long int __sync_nand_and_fetch(volatile signed long long int *, signed long long int,...);
    291 signed long long int __sync_nand_and_fetch_8(volatile signed long long int *, signed long long int,...);
    292187unsigned long long int __sync_nand_and_fetch(volatile unsigned long long int *, unsigned long long int,...);
    293 unsigned long long int __sync_nand_and_fetch_8(volatile unsigned long long int *, unsigned long long int,...);
    294188#if defined(__SIZEOF_INT128__)
    295189signed __int128 __sync_nand_and_fetch(volatile signed __int128 *, signed __int128,...);
    296 signed __int128 __sync_nand_and_fetch_16(volatile signed __int128 *, signed __int128,...);
    297190unsigned __int128 __sync_nand_and_fetch(volatile unsigned __int128 *, unsigned __int128,...);
    298 unsigned __int128 __sync_nand_and_fetch_16(volatile unsigned __int128 *, unsigned __int128,...);
    299191#endif
    300192
    301193_Bool __sync_bool_compare_and_swap(volatile char *, char, char,...);
    302 _Bool __sync_bool_compare_and_swap_1(volatile char *, char, char,...);
    303194_Bool __sync_bool_compare_and_swap(volatile signed char *, signed char, signed char,...);
    304 _Bool __sync_bool_compare_and_swap_1(volatile signed char *, signed char, signed char,...);
    305195_Bool __sync_bool_compare_and_swap(volatile unsigned char *, unsigned char, unsigned char,...);
    306 _Bool __sync_bool_compare_and_swap_1(volatile unsigned char *, unsigned char, unsigned char,...);
    307196_Bool __sync_bool_compare_and_swap(volatile short *, signed short, signed short,...);
    308 _Bool __sync_bool_compare_and_swap_2(volatile short *, signed short, signed short,...);
    309197_Bool __sync_bool_compare_and_swap(volatile short *, unsigned short, unsigned short,...);
    310 _Bool __sync_bool_compare_and_swap_2(volatile short *, unsigned short, unsigned short,...);
    311198_Bool __sync_bool_compare_and_swap(volatile signed int *, signed int, signed int,...);
    312 _Bool __sync_bool_compare_and_swap_4(volatile signed int *, signed int, signed int,...);
    313199_Bool __sync_bool_compare_and_swap(volatile unsigned int *, unsigned int, unsigned int,...);
    314 _Bool __sync_bool_compare_and_swap_4(volatile unsigned int *, unsigned int, unsigned int,...);
     200_Bool __sync_bool_compare_and_swap(volatile signed long int *, signed long int, signed long int,...);
     201_Bool __sync_bool_compare_and_swap(volatile unsigned long int *, unsigned long int, unsigned long int,...);
    315202_Bool __sync_bool_compare_and_swap(volatile signed long long int *, signed long long int, signed long long int,...);
    316 _Bool __sync_bool_compare_and_swap_8(volatile signed long long int *, signed long long int, signed long long int,...);
    317203_Bool __sync_bool_compare_and_swap(volatile unsigned long long int *, unsigned long long int, unsigned long long int,...);
    318 _Bool __sync_bool_compare_and_swap_8(volatile unsigned long long int *, unsigned long long int, unsigned long long int,...);
    319204#if defined(__SIZEOF_INT128__)
    320205_Bool __sync_bool_compare_and_swap(volatile signed __int128 *, signed __int128, signed __int128,...);
    321 _Bool __sync_bool_compare_and_swap_16(volatile signed __int128 *, signed __int128, signed __int128,...);
    322206_Bool __sync_bool_compare_and_swap(volatile unsigned __int128 *, unsigned __int128, unsigned __int128,...);
    323 _Bool __sync_bool_compare_and_swap_16(volatile unsigned __int128 *, unsigned __int128, unsigned __int128,...);
    324207#endif
    325208forall(dtype T) _Bool __sync_bool_compare_and_swap(T * volatile *, T *, T*, ...);
    326209
    327210char __sync_val_compare_and_swap(volatile char *, char, char,...);
    328 char __sync_val_compare_and_swap_1(volatile char *, char, char,...);
    329211signed char __sync_val_compare_and_swap(volatile signed char *, signed char, signed char,...);
    330 signed char __sync_val_compare_and_swap_1(volatile signed char *, signed char, signed char,...);
    331212unsigned char __sync_val_compare_and_swap(volatile unsigned char *, unsigned char, unsigned char,...);
    332 unsigned char __sync_val_compare_and_swap_1(volatile unsigned char *, unsigned char, unsigned char,...);
    333213signed short __sync_val_compare_and_swap(volatile signed short *, signed short, signed short,...);
    334 signed short __sync_val_compare_and_swap_2(volatile signed short *, signed short, signed short,...);
    335214unsigned short __sync_val_compare_and_swap(volatile unsigned short *, unsigned short, unsigned short,...);
    336 unsigned short __sync_val_compare_and_swap_2(volatile unsigned short *, unsigned short, unsigned short,...);
    337215signed int __sync_val_compare_and_swap(volatile signed int *, signed int, signed int,...);
    338 signed int __sync_val_compare_and_swap_4(volatile signed int *, signed int, signed int,...);
    339216unsigned int __sync_val_compare_and_swap(volatile unsigned int *, unsigned int, unsigned int,...);
    340 unsigned int __sync_val_compare_and_swap_4(volatile unsigned int *, unsigned int, unsigned int,...);
     217signed long int __sync_val_compare_and_swap(volatile signed long int *, signed long int, signed long int,...);
     218unsigned long int __sync_val_compare_and_swap(volatile unsigned long int *, unsigned long int, unsigned long int,...);
    341219signed long long int __sync_val_compare_and_swap(volatile signed long long int *, signed long long int, signed long long int,...);
    342 signed long long int __sync_val_compare_and_swap_8(volatile signed long long int *, signed long long int, signed long long int,...);
    343220unsigned long long int __sync_val_compare_and_swap(volatile unsigned long long int *, unsigned long long int, unsigned long long int,...);
    344 unsigned long long int __sync_val_compare_and_swap_8(volatile unsigned long long int *, unsigned long long int, unsigned long long int,...);
    345221#if defined(__SIZEOF_INT128__)
    346222signed __int128 __sync_val_compare_and_swap(volatile signed __int128 *, signed __int128, signed __int128,...);
    347 signed __int128 __sync_val_compare_and_swap_16(volatile signed __int128 *, signed __int128, signed __int128,...);
    348223unsigned __int128 __sync_val_compare_and_swap(volatile unsigned __int128 *, unsigned __int128, unsigned __int128,...);
    349 unsigned __int128 __sync_val_compare_and_swap_16(volatile unsigned __int128 *, unsigned __int128, unsigned __int128,...);
    350224#endif
    351225forall(dtype T) T * __sync_val_compare_and_swap(T * volatile *, T *, T*,...);
    352226
    353227char __sync_lock_test_and_set(volatile char *, char,...);
    354 char __sync_lock_test_and_set_1(volatile char *, char,...);
    355228signed char __sync_lock_test_and_set(volatile signed char *, signed char,...);
    356 signed char __sync_lock_test_and_set_1(volatile signed char *, signed char,...);
    357229unsigned char __sync_lock_test_and_set(volatile unsigned char *, unsigned char,...);
    358 unsigned char __sync_lock_test_and_set_1(volatile unsigned char *, unsigned char,...);
    359230signed short __sync_lock_test_and_set(volatile signed short *, signed short,...);
    360 signed short __sync_lock_test_and_set_2(volatile signed short *, signed short,...);
    361231unsigned short __sync_lock_test_and_set(volatile unsigned short *, unsigned short,...);
    362 unsigned short __sync_lock_test_and_set_2(volatile unsigned short *, unsigned short,...);
    363232signed int __sync_lock_test_and_set(volatile signed int *, signed int,...);
    364 signed int __sync_lock_test_and_set_4(volatile signed int *, signed int,...);
    365233unsigned int __sync_lock_test_and_set(volatile unsigned int *, unsigned int,...);
    366 unsigned int __sync_lock_test_and_set_4(volatile unsigned int *, unsigned int,...);
     234signed long int __sync_lock_test_and_set(volatile signed long int *, signed long int,...);
     235unsigned long int __sync_lock_test_and_set(volatile unsigned long int *, unsigned long int,...);
    367236signed long long int __sync_lock_test_and_set(volatile signed long long int *, signed long long int,...);
    368 signed long long int __sync_lock_test_and_set_8(volatile signed long long int *, signed long long int,...);
    369237unsigned long long int __sync_lock_test_and_set(volatile unsigned long long int *, unsigned long long int,...);
    370 unsigned long long int __sync_lock_test_and_set_8(volatile unsigned long long int *, unsigned long long int,...);
    371238#if defined(__SIZEOF_INT128__)
    372239signed __int128 __sync_lock_test_and_set(volatile signed __int128 *, signed __int128,...);
    373 signed __int128 __sync_lock_test_and_set_16(volatile signed __int128 *, signed __int128,...);
    374240unsigned __int128 __sync_lock_test_and_set(volatile unsigned __int128 *, unsigned __int128,...);
    375 unsigned __int128 __sync_lock_test_and_set_16(volatile unsigned __int128 *, unsigned __int128,...);
    376241#endif
    377242
    378243void __sync_lock_release(volatile char *,...);
    379 void __sync_lock_release_1(volatile char *,...);
    380244void __sync_lock_release(volatile signed char *,...);
    381 void __sync_lock_release_1(volatile signed char *,...);
    382245void __sync_lock_release(volatile unsigned char *,...);
    383 void __sync_lock_release_1(volatile unsigned char *,...);
    384246void __sync_lock_release(volatile signed short *,...);
    385 void __sync_lock_release_2(volatile signed short *,...);
    386247void __sync_lock_release(volatile unsigned short *,...);
    387 void __sync_lock_release_2(volatile unsigned short *,...);
    388248void __sync_lock_release(volatile signed int *,...);
    389 void __sync_lock_release_4(volatile signed int *,...);
    390249void __sync_lock_release(volatile unsigned int *,...);
    391 void __sync_lock_release_4(volatile unsigned int *,...);
     250void __sync_lock_release(volatile signed long int *,...);
     251void __sync_lock_release(volatile unsigned long int *,...);
    392252void __sync_lock_release(volatile signed long long int *,...);
    393 void __sync_lock_release_8(volatile signed long long int *,...);
    394253void __sync_lock_release(volatile unsigned long long int *,...);
    395 void __sync_lock_release_8(volatile unsigned long long int *,...);
    396254#if defined(__SIZEOF_INT128__)
    397255void __sync_lock_release(volatile signed __int128 *,...);
    398 void __sync_lock_release_16(volatile signed __int128 *,...);
    399256void __sync_lock_release(volatile unsigned __int128 *,...);
    400 void __sync_lock_release_16(volatile unsigned __int128 *,...);
    401257#endif
    402258
     
    414270_Bool __atomic_test_and_set(volatile signed int *, int);
    415271_Bool __atomic_test_and_set(volatile unsigned int *, int);
     272_Bool __atomic_test_and_set(volatile signed long int *, int);
     273_Bool __atomic_test_and_set(volatile unsigned long int *, int);
    416274_Bool __atomic_test_and_set(volatile signed long long int *, int);
    417275_Bool __atomic_test_and_set(volatile unsigned long long int *, int);
     
    429287void __atomic_clear(volatile signed int *, int);
    430288void __atomic_clear(volatile unsigned int *, int);
     289void __atomic_clear(volatile signed long int *, int);
     290void __atomic_clear(volatile unsigned long int *, int);
    431291void __atomic_clear(volatile signed long long int *, int);
    432292void __atomic_clear(volatile unsigned long long int *, int);
     
    436296#endif
    437297
     298_Bool __atomic_exchange_n(volatile _Bool *, _Bool, int);
     299void __atomic_exchange(volatile _Bool *, volatile _Bool *, volatile _Bool *, int);
    438300char __atomic_exchange_n(volatile char *, char, int);
    439 char __atomic_exchange_1(volatile char *, char, int);
    440301void __atomic_exchange(volatile char *, volatile char *, volatile char *, int);
    441302signed char __atomic_exchange_n(volatile signed char *, signed char, int);
    442 signed char __atomic_exchange_1(volatile signed char *, signed char, int);
    443303void __atomic_exchange(volatile signed char *, volatile signed char *, volatile signed char *, int);
    444304unsigned char __atomic_exchange_n(volatile unsigned char *, unsigned char, int);
    445 unsigned char __atomic_exchange_1(volatile unsigned char *, unsigned char, int);
    446305void __atomic_exchange(volatile unsigned char *, volatile unsigned char *, volatile unsigned char *, int);
    447306signed short __atomic_exchange_n(volatile signed short *, signed short, int);
    448 signed short __atomic_exchange_2(volatile signed short *, signed short, int);
    449307void __atomic_exchange(volatile signed short *, volatile signed short *, volatile signed short *, int);
    450308unsigned short __atomic_exchange_n(volatile unsigned short *, unsigned short, int);
    451 unsigned short __atomic_exchange_2(volatile unsigned short *, unsigned short, int);
    452309void __atomic_exchange(volatile unsigned short *, volatile unsigned short *, volatile unsigned short *, int);
    453310signed int __atomic_exchange_n(volatile signed int *, signed int, int);
    454 signed int __atomic_exchange_4(volatile signed int *, signed int, int);
    455311void __atomic_exchange(volatile signed int *, volatile signed int *, volatile signed int *, int);
    456312unsigned int __atomic_exchange_n(volatile unsigned int *, unsigned int, int);
    457 unsigned int __atomic_exchange_4(volatile unsigned int *, unsigned int, int);
    458313void __atomic_exchange(volatile unsigned int *, volatile unsigned int *, volatile unsigned int *, int);
     314signed long int __atomic_exchange_n(volatile signed long int *, signed long int, int);
     315void __atomic_exchange(volatile signed long int *, volatile signed long int *, volatile signed long int *, int);
     316unsigned long int __atomic_exchange_n(volatile unsigned long int *, unsigned long int, int);
     317void __atomic_exchange(volatile unsigned long int *, volatile unsigned long int *, volatile unsigned long int *, int);
    459318signed long long int __atomic_exchange_n(volatile signed long long int *, signed long long int, int);
    460 signed long long int __atomic_exchange_8(volatile signed long long int *, signed long long int, int);
    461319void __atomic_exchange(volatile signed long long int *, volatile signed long long int *, volatile signed long long int *, int);
    462320unsigned long long int __atomic_exchange_n(volatile unsigned long long int *, unsigned long long int, int);
    463 unsigned long long int __atomic_exchange_8(volatile unsigned long long int *, unsigned long long int, int);
    464321void __atomic_exchange(volatile unsigned long long int *, volatile unsigned long long int *, volatile unsigned long long int *, int);
    465322#if defined(__SIZEOF_INT128__)
    466323signed __int128 __atomic_exchange_n(volatile signed __int128 *, signed __int128, int);
    467 signed __int128 __atomic_exchange_16(volatile signed __int128 *, signed __int128, int);
    468324void __atomic_exchange(volatile signed __int128 *, volatile signed __int128 *, volatile signed __int128 *, int);
    469325unsigned __int128 __atomic_exchange_n(volatile unsigned __int128 *, unsigned __int128, int);
    470 unsigned __int128 __atomic_exchange_16(volatile unsigned __int128 *, unsigned __int128, int);
    471326void __atomic_exchange(volatile unsigned __int128 *, volatile unsigned __int128 *, volatile unsigned __int128 *, int);
    472327#endif
     
    477332void __atomic_load(const volatile _Bool *, volatile _Bool *, int);
    478333char __atomic_load_n(const volatile char *, int);
    479 char __atomic_load_1(const volatile char *, int);
    480334void __atomic_load(const volatile char *, volatile char *, int);
    481335signed char __atomic_load_n(const volatile signed char *, int);
    482 signed char __atomic_load_1(const volatile signed char *, int);
    483336void __atomic_load(const volatile signed char *, volatile signed char *, int);
    484337unsigned char __atomic_load_n(const volatile unsigned char *, int);
    485 unsigned char __atomic_load_1(const volatile unsigned char *, int);
    486338void __atomic_load(const volatile unsigned char *, volatile unsigned char *, int);
    487339signed short __atomic_load_n(const volatile signed short *, int);
    488 signed short __atomic_load_2(const volatile signed short *, int);
    489340void __atomic_load(const volatile signed short *, volatile signed short *, int);
    490341unsigned short __atomic_load_n(const volatile unsigned short *, int);
    491 unsigned short __atomic_load_2(const volatile unsigned short *, int);
    492342void __atomic_load(const volatile unsigned short *, volatile unsigned short *, int);
    493343signed int __atomic_load_n(const volatile signed int *, int);
    494 signed int __atomic_load_4(const volatile signed int *, int);
    495344void __atomic_load(const volatile signed int *, volatile signed int *, int);
    496345unsigned int __atomic_load_n(const volatile unsigned int *, int);
    497 unsigned int __atomic_load_4(const volatile unsigned int *, int);
    498346void __atomic_load(const volatile unsigned int *, volatile unsigned int *, int);
     347signed long int __atomic_load_n(const volatile signed long int *, int);
     348void __atomic_load(const volatile signed long int *, volatile signed long int *, int);
     349unsigned long int __atomic_load_n(const volatile unsigned long int *, int);
     350void __atomic_load(const volatile unsigned long int *, volatile unsigned long int *, int);
    499351signed long long int __atomic_load_n(const volatile signed long long int *, int);
    500 signed long long int __atomic_load_8(const volatile signed long long int *, int);
    501352void __atomic_load(const volatile signed long long int *, volatile signed long long int *, int);
    502353unsigned long long int __atomic_load_n(const volatile unsigned long long int *, int);
    503 unsigned long long int __atomic_load_8(const volatile unsigned long long int *, int);
    504354void __atomic_load(const volatile unsigned long long int *, volatile unsigned long long int *, int);
    505355#if defined(__SIZEOF_INT128__)
    506356signed __int128 __atomic_load_n(const volatile signed __int128 *, int);
    507 signed __int128 __atomic_load_16(const volatile signed __int128 *, int);
    508357void __atomic_load(const volatile signed __int128 *, volatile signed __int128 *, int);
    509358unsigned __int128 __atomic_load_n(const volatile unsigned __int128 *, int);
    510 unsigned __int128 __atomic_load_16(const volatile unsigned __int128 *, int);
    511359void __atomic_load(const volatile unsigned __int128 *, volatile unsigned __int128 *, int);
    512360#endif
     
    515363
    516364_Bool __atomic_compare_exchange_n(volatile char *, char *, char, _Bool, int, int);
    517 _Bool __atomic_compare_exchange_1(volatile char *, char *, char, _Bool, int, int);
    518365_Bool __atomic_compare_exchange  (volatile char *, char *, char *, _Bool, int, int);
    519366_Bool __atomic_compare_exchange_n(volatile signed char *, signed char *, signed char, _Bool, int, int);
    520 _Bool __atomic_compare_exchange_1(volatile signed char *, signed char *, signed char, _Bool, int, int);
    521367_Bool __atomic_compare_exchange  (volatile signed char *, signed char *, signed char *, _Bool, int, int);
    522368_Bool __atomic_compare_exchange_n(volatile unsigned char *, unsigned char *, unsigned char, _Bool, int, int);
    523 _Bool __atomic_compare_exchange_1(volatile unsigned char *, unsigned char *, unsigned char, _Bool, int, int);
    524369_Bool __atomic_compare_exchange  (volatile unsigned char *, unsigned char *, unsigned char *, _Bool, int, int);
    525370_Bool __atomic_compare_exchange_n(volatile signed short *, signed short *, signed short, _Bool, int, int);
    526 _Bool __atomic_compare_exchange_2(volatile signed short *, signed short *, signed short, _Bool, int, int);
    527371_Bool __atomic_compare_exchange  (volatile signed short *, signed short *, signed short *, _Bool, int, int);
    528372_Bool __atomic_compare_exchange_n(volatile unsigned short *, unsigned short *, unsigned short, _Bool, int, int);
    529 _Bool __atomic_compare_exchange_2(volatile unsigned short *, unsigned short *, unsigned short, _Bool, int, int);
    530373_Bool __atomic_compare_exchange  (volatile unsigned short *, unsigned short *, unsigned short *, _Bool, int, int);
    531374_Bool __atomic_compare_exchange_n(volatile signed int *, signed int *, signed int, _Bool, int, int);
    532 _Bool __atomic_compare_exchange_4(volatile signed int *, signed int *, signed int, _Bool, int, int);
    533375_Bool __atomic_compare_exchange  (volatile signed int *, signed int *, signed int *, _Bool, int, int);
    534376_Bool __atomic_compare_exchange_n(volatile unsigned int *, unsigned int *, unsigned int, _Bool, int, int);
    535 _Bool __atomic_compare_exchange_4(volatile unsigned int *, unsigned int *, unsigned int, _Bool, int, int);
    536377_Bool __atomic_compare_exchange  (volatile unsigned int *, unsigned int *, unsigned int *, _Bool, int, int);
     378_Bool __atomic_compare_exchange_n(volatile signed long int *, signed long int *, signed long int, _Bool, int, int);
     379_Bool __atomic_compare_exchange  (volatile signed long int *, signed long int *, signed long int *, _Bool, int, int);
     380_Bool __atomic_compare_exchange_n(volatile unsigned long int *, unsigned long int *, unsigned long int, _Bool, int, int);
     381_Bool __atomic_compare_exchange  (volatile unsigned long int *, unsigned long int *, unsigned long int *, _Bool, int, int);
    537382_Bool __atomic_compare_exchange_n(volatile signed long long int *, signed long long int *, signed long long int, _Bool, int, int);
    538 _Bool __atomic_compare_exchange_8(volatile signed long long int *, signed long long int *, signed long long int, _Bool, int, int);
    539383_Bool __atomic_compare_exchange  (volatile signed long long int *, signed long long int *, signed long long int *, _Bool, int, int);
    540384_Bool __atomic_compare_exchange_n(volatile unsigned long long int *, unsigned long long int *, unsigned long long int, _Bool, int, int);
    541 _Bool __atomic_compare_exchange_8(volatile unsigned long long int *, unsigned long long int *, unsigned long long int, _Bool, int, int);
    542385_Bool __atomic_compare_exchange  (volatile unsigned long long int *, unsigned long long int *, unsigned long long int *, _Bool, int, int);
    543386#if defined(__SIZEOF_INT128__)
    544387_Bool __atomic_compare_exchange_n (volatile signed __int128 *, signed __int128 *, signed __int128, _Bool, int, int);
    545 _Bool __atomic_compare_exchange_16(volatile signed __int128 *, signed __int128 *, signed __int128, _Bool, int, int);
    546388_Bool __atomic_compare_exchange   (volatile signed __int128 *, signed __int128 *, signed __int128 *, _Bool, int, int);
    547389_Bool __atomic_compare_exchange_n (volatile unsigned __int128 *, unsigned __int128 *, unsigned __int128, _Bool, int, int);
    548 _Bool __atomic_compare_exchange_16(volatile unsigned __int128 *, unsigned __int128 *, unsigned __int128, _Bool, int, int);
    549390_Bool __atomic_compare_exchange   (volatile unsigned __int128 *, unsigned __int128 *, unsigned __int128 *, _Bool, int, int);
    550391#endif
     
    555396void __atomic_store(volatile _Bool *, _Bool *, int);
    556397void __atomic_store_n(volatile char *, char, int);
    557 void __atomic_store_1(volatile char *, char, int);
    558398void __atomic_store(volatile char *, char *, int);
    559399void __atomic_store_n(volatile signed char *, signed char, int);
    560 void __atomic_store_1(volatile signed char *, signed char, int);
    561400void __atomic_store(volatile signed char *, signed char *, int);
    562401void __atomic_store_n(volatile unsigned char *, unsigned char, int);
    563 void __atomic_store_1(volatile unsigned char *, unsigned char, int);
    564402void __atomic_store(volatile unsigned char *, unsigned char *, int);
    565403void __atomic_store_n(volatile signed short *, signed short, int);
    566 void __atomic_store_2(volatile signed short *, signed short, int);
    567404void __atomic_store(volatile signed short *, signed short *, int);
    568405void __atomic_store_n(volatile unsigned short *, unsigned short, int);
    569 void __atomic_store_2(volatile unsigned short *, unsigned short, int);
    570406void __atomic_store(volatile unsigned short *, unsigned short *, int);
    571407void __atomic_store_n(volatile signed int *, signed int, int);
    572 void __atomic_store_4(volatile signed int *, signed int, int);
    573408void __atomic_store(volatile signed int *, signed int *, int);
    574409void __atomic_store_n(volatile unsigned int *, unsigned int, int);
    575 void __atomic_store_4(volatile unsigned int *, unsigned int, int);
    576410void __atomic_store(volatile unsigned int *, unsigned int *, int);
     411void __atomic_store_n(volatile signed long int *, signed long int, int);
     412void __atomic_store(volatile signed long int *, signed long int *, int);
     413void __atomic_store_n(volatile unsigned long int *, unsigned long int, int);
     414void __atomic_store(volatile unsigned long int *, unsigned long int *, int);
    577415void __atomic_store_n(volatile signed long long int *, signed long long int, int);
    578 void __atomic_store_8(volatile signed long long int *, signed long long int, int);
    579416void __atomic_store(volatile signed long long int *, signed long long int *, int);
    580417void __atomic_store_n(volatile unsigned long long int *, unsigned long long int, int);
    581 void __atomic_store_8(volatile unsigned long long int *, unsigned long long int, int);
    582418void __atomic_store(volatile unsigned long long int *, unsigned long long int *, int);
    583419#if defined(__SIZEOF_INT128__)
    584420void __atomic_store_n(volatile signed __int128 *, signed __int128, int);
    585 void __atomic_store_16(volatile signed __int128 *, signed __int128, int);
    586421void __atomic_store(volatile signed __int128 *, signed __int128 *, int);
    587422void __atomic_store_n(volatile unsigned __int128 *, unsigned __int128, int);
    588 void __atomic_store_16(volatile unsigned __int128 *, unsigned __int128, int);
    589423void __atomic_store(volatile unsigned __int128 *, unsigned __int128 *, int);
    590424#endif
     
    593427
    594428char __atomic_add_fetch  (volatile char *, char, int);
    595 char __atomic_add_fetch_1(volatile char *, char, int);
    596429signed char __atomic_add_fetch  (volatile signed char *, signed char, int);
    597 signed char __atomic_add_fetch_1(volatile signed char *, signed char, int);
    598430unsigned char __atomic_add_fetch  (volatile unsigned char *, unsigned char, int);
    599 unsigned char __atomic_add_fetch_1(volatile unsigned char *, unsigned char, int);
    600431signed short __atomic_add_fetch  (volatile signed short *, signed short, int);
    601 signed short __atomic_add_fetch_2(volatile signed short *, signed short, int);
    602432unsigned short __atomic_add_fetch  (volatile unsigned short *, unsigned short, int);
    603 unsigned short __atomic_add_fetch_2(volatile unsigned short *, unsigned short, int);
    604433signed int __atomic_add_fetch  (volatile signed int *, signed int, int);
    605 signed int __atomic_add_fetch_4(volatile signed int *, signed int, int);
    606434unsigned int __atomic_add_fetch  (volatile unsigned int *, unsigned int, int);
    607 unsigned int __atomic_add_fetch_4(volatile unsigned int *, unsigned int, int);
     435signed long int __atomic_add_fetch  (volatile signed long int *, signed long int, int);
     436unsigned long int __atomic_add_fetch  (volatile unsigned long int *, unsigned long int, int);
    608437signed long long int __atomic_add_fetch  (volatile signed long long int *, signed long long int, int);
    609 signed long long int __atomic_add_fetch_8(volatile signed long long int *, signed long long int, int);
    610438unsigned long long int __atomic_add_fetch  (volatile unsigned long long int *, unsigned long long int, int);
    611 unsigned long long int __atomic_add_fetch_8(volatile unsigned long long int *, unsigned long long int, int);
    612439#if defined(__SIZEOF_INT128__)
    613440signed __int128 __atomic_add_fetch   (volatile signed __int128 *, signed __int128, int);
    614 signed __int128 __atomic_add_fetch_16(volatile signed __int128 *, signed __int128, int);
    615441unsigned __int128 __atomic_add_fetch   (volatile unsigned __int128 *, unsigned __int128, int);
    616 unsigned __int128 __atomic_add_fetch_16(volatile unsigned __int128 *, unsigned __int128, int);
    617442#endif
    618443
    619444char __atomic_sub_fetch  (volatile char *, char, int);
    620 char __atomic_sub_fetch_1(volatile char *, char, int);
    621445signed char __atomic_sub_fetch  (volatile signed char *, signed char, int);
    622 signed char __atomic_sub_fetch_1(volatile signed char *, signed char, int);
    623446unsigned char __atomic_sub_fetch  (volatile unsigned char *, unsigned char, int);
    624 unsigned char __atomic_sub_fetch_1(volatile unsigned char *, unsigned char, int);
    625447signed short __atomic_sub_fetch  (volatile signed short *, signed short, int);
    626 signed short __atomic_sub_fetch_2(volatile signed short *, signed short, int);
    627448unsigned short __atomic_sub_fetch  (volatile unsigned short *, unsigned short, int);
    628 unsigned short __atomic_sub_fetch_2(volatile unsigned short *, unsigned short, int);
    629449signed int __atomic_sub_fetch  (volatile signed int *, signed int, int);
    630 signed int __atomic_sub_fetch_4(volatile signed int *, signed int, int);
    631450unsigned int __atomic_sub_fetch  (volatile unsigned int *, unsigned int, int);
    632 unsigned int __atomic_sub_fetch_4(volatile unsigned int *, unsigned int, int);
     451signed long long int __atomic_sub_fetch  (volatile signed long int *, signed long int, int);
     452unsigned long long int __atomic_sub_fetch  (volatile unsigned long int *, unsigned long int, int);
    633453signed long long int __atomic_sub_fetch  (volatile signed long long int *, signed long long int, int);
    634 signed long long int __atomic_sub_fetch_8(volatile signed long long int *, signed long long int, int);
    635454unsigned long long int __atomic_sub_fetch  (volatile unsigned long long int *, unsigned long long int, int);
    636 unsigned long long int __atomic_sub_fetch_8(volatile unsigned long long int *, unsigned long long int, int);
    637455#if defined(__SIZEOF_INT128__)
    638456signed __int128 __atomic_sub_fetch   (volatile signed __int128 *, signed __int128, int);
    639 signed __int128 __atomic_sub_fetch_16(volatile signed __int128 *, signed __int128, int);
    640457unsigned __int128 __atomic_sub_fetch   (volatile unsigned __int128 *, unsigned __int128, int);
    641 unsigned __int128 __atomic_sub_fetch_16(volatile unsigned __int128 *, unsigned __int128, int);
    642458#endif
    643459
    644460char __atomic_and_fetch  (volatile char *, char, int);
    645 char __atomic_and_fetch_1(volatile char *, char, int);
    646461signed char __atomic_and_fetch  (volatile signed char *, signed char, int);
    647 signed char __atomic_and_fetch_1(volatile signed char *, signed char, int);
    648462unsigned char __atomic_and_fetch  (volatile unsigned char *, unsigned char, int);
    649 unsigned char __atomic_and_fetch_1(volatile unsigned char *, unsigned char, int);
    650463signed short __atomic_and_fetch  (volatile signed short *, signed short, int);
    651 signed short __atomic_and_fetch_2(volatile signed short *, signed short, int);
    652464unsigned short __atomic_and_fetch  (volatile unsigned short *, unsigned short, int);
    653 unsigned short __atomic_and_fetch_2(volatile unsigned short *, unsigned short, int);
    654465signed int __atomic_and_fetch  (volatile signed int *, signed int, int);
    655 signed int __atomic_and_fetch_4(volatile signed int *, signed int, int);
    656466unsigned int __atomic_and_fetch  (volatile unsigned int *, unsigned int, int);
    657 unsigned int __atomic_and_fetch_4(volatile unsigned int *, unsigned int, int);
     467signed long int __atomic_and_fetch  (volatile signed long int *, signed long int, int);
     468unsigned long int __atomic_and_fetch  (volatile unsigned long int *, unsigned long int, int);
    658469signed long long int __atomic_and_fetch  (volatile signed long long int *, signed long long int, int);
    659 signed long long int __atomic_and_fetch_8(volatile signed long long int *, signed long long int, int);
    660470unsigned long long int __atomic_and_fetch  (volatile unsigned long long int *, unsigned long long int, int);
    661 unsigned long long int __atomic_and_fetch_8(volatile unsigned long long int *, unsigned long long int, int);
    662471#if defined(__SIZEOF_INT128__)
    663472signed __int128 __atomic_and_fetch   (volatile signed __int128 *, signed __int128, int);
    664 signed __int128 __atomic_and_fetch_16(volatile signed __int128 *, signed __int128, int);
    665473unsigned __int128 __atomic_and_fetch   (volatile unsigned __int128 *, unsigned __int128, int);
    666 unsigned __int128 __atomic_and_fetch_16(volatile unsigned __int128 *, unsigned __int128, int);
    667474#endif
    668475
    669476char __atomic_nand_fetch  (volatile char *, char, int);
    670 char __atomic_nand_fetch_1(volatile char *, char, int);
    671477signed char __atomic_nand_fetch  (volatile signed char *, signed char, int);
    672 signed char __atomic_nand_fetch_1(volatile signed char *, signed char, int);
    673478unsigned char __atomic_nand_fetch  (volatile unsigned char *, unsigned char, int);
    674 unsigned char __atomic_nand_fetch_1(volatile unsigned char *, unsigned char, int);
    675479signed short __atomic_nand_fetch  (volatile signed short *, signed short, int);
    676 signed short __atomic_nand_fetch_2(volatile signed short *, signed short, int);
    677480unsigned short __atomic_nand_fetch  (volatile unsigned short *, unsigned short, int);
    678 unsigned short __atomic_nand_fetch_2(volatile unsigned short *, unsigned short, int);
    679481signed int __atomic_nand_fetch  (volatile signed int *, signed int, int);
    680 signed int __atomic_nand_fetch_4(volatile signed int *, signed int, int);
    681482unsigned int __atomic_nand_fetch  (volatile unsigned int *, unsigned int, int);
    682 unsigned int __atomic_nand_fetch_4(volatile unsigned int *, unsigned int, int);
     483signed long int __atomic_nand_fetch  (volatile signed long int *, signed long int, int);
     484unsigned long int __atomic_nand_fetch  (volatile unsigned long int *, unsigned long int, int);
    683485signed long long int __atomic_nand_fetch  (volatile signed long long int *, signed long long int, int);
    684 signed long long int __atomic_nand_fetch_8(volatile signed long long int *, signed long long int, int);
    685486unsigned long long int __atomic_nand_fetch  (volatile unsigned long long int *, unsigned long long int, int);
    686 unsigned long long int __atomic_nand_fetch_8(volatile unsigned long long int *, unsigned long long int, int);
    687487#if defined(__SIZEOF_INT128__)
    688488signed __int128 __atomic_nand_fetch   (volatile signed __int128 *, signed __int128, int);
    689 signed __int128 __atomic_nand_fetch_16(volatile signed __int128 *, signed __int128, int);
    690489unsigned __int128 __atomic_nand_fetch   (volatile unsigned __int128 *, unsigned __int128, int);
    691 unsigned __int128 __atomic_nand_fetch_16(volatile unsigned __int128 *, unsigned __int128, int);
    692490#endif
    693491
    694492char __atomic_xor_fetch  (volatile char *, char, int);
    695 char __atomic_xor_fetch_1(volatile char *, char, int);
    696493signed char __atomic_xor_fetch  (volatile signed char *, signed char, int);
    697 signed char __atomic_xor_fetch_1(volatile signed char *, signed char, int);
    698494unsigned char __atomic_xor_fetch  (volatile unsigned char *, unsigned char, int);
    699 unsigned char __atomic_xor_fetch_1(volatile unsigned char *, unsigned char, int);
    700495signed short __atomic_xor_fetch  (volatile signed short *, signed short, int);
    701 signed short __atomic_xor_fetch_2(volatile signed short *, signed short, int);
    702496unsigned short __atomic_xor_fetch  (volatile unsigned short *, unsigned short, int);
    703 unsigned short __atomic_xor_fetch_2(volatile unsigned short *, unsigned short, int);
    704497signed int __atomic_xor_fetch  (volatile signed int *, signed int, int);
    705 signed int __atomic_xor_fetch_4(volatile signed int *, signed int, int);
    706498unsigned int __atomic_xor_fetch  (volatile unsigned int *, unsigned int, int);
    707 unsigned int __atomic_xor_fetch_4(volatile unsigned int *, unsigned int, int);
     499signed long int __atomic_xor_fetch  (volatile signed long int *, signed long int, int);
     500unsigned long int __atomic_xor_fetch  (volatile unsigned long int *, unsigned long int, int);
    708501signed long long int __atomic_xor_fetch  (volatile signed long long int *, signed long long int, int);
    709 signed long long int __atomic_xor_fetch_8(volatile signed long long int *, signed long long int, int);
    710502unsigned long long int __atomic_xor_fetch  (volatile unsigned long long int *, unsigned long long int, int);
    711 unsigned long long int __atomic_xor_fetch_8(volatile unsigned long long int *, unsigned long long int, int);
    712503#if defined(__SIZEOF_INT128__)
    713504signed __int128 __atomic_xor_fetch   (volatile signed __int128 *, signed __int128, int);
    714 signed __int128 __atomic_xor_fetch_16(volatile signed __int128 *, signed __int128, int);
    715505unsigned __int128 __atomic_xor_fetch   (volatile unsigned __int128 *, unsigned __int128, int);
    716 unsigned __int128 __atomic_xor_fetch_16(volatile unsigned __int128 *, unsigned __int128, int);
    717506#endif
    718507
    719508char __atomic_or_fetch  (volatile char *, char, int);
    720 char __atomic_or_fetch_1(volatile char *, char, int);
    721509signed char __atomic_or_fetch  (volatile signed char *, signed char, int);
    722 signed char __atomic_or_fetch_1(volatile signed char *, signed char, int);
    723510unsigned char __atomic_or_fetch  (volatile unsigned char *, unsigned char, int);
    724 unsigned char __atomic_or_fetch_1(volatile unsigned char *, unsigned char, int);
    725511signed short __atomic_or_fetch  (volatile signed short *, signed short, int);
    726 signed short __atomic_or_fetch_2(volatile signed short *, signed short, int);
    727512unsigned short __atomic_or_fetch  (volatile unsigned short *, unsigned short, int);
    728 unsigned short __atomic_or_fetch_2(volatile unsigned short *, unsigned short, int);
    729513signed int __atomic_or_fetch  (volatile signed int *, signed int, int);
    730 signed int __atomic_or_fetch_4(volatile signed int *, signed int, int);
    731514unsigned int __atomic_or_fetch  (volatile unsigned int *, unsigned int, int);
    732 unsigned int __atomic_or_fetch_4(volatile unsigned int *, unsigned int, int);
     515signed long int __atomic_or_fetch  (volatile signed long int *, signed long int, int);
     516unsigned long int __atomic_or_fetch  (volatile unsigned long int *, unsigned long int, int);
    733517signed long long int __atomic_or_fetch  (volatile signed long long int *, signed long long int, int);
    734 signed long long int __atomic_or_fetch_8(volatile signed long long int *, signed long long int, int);
    735518unsigned long long int __atomic_or_fetch  (volatile unsigned long long int *, unsigned long long int, int);
    736 unsigned long long int __atomic_or_fetch_8(volatile unsigned long long int *, unsigned long long int, int);
    737519#if defined(__SIZEOF_INT128__)
    738520signed __int128 __atomic_or_fetch   (volatile signed __int128 *, signed __int128, int);
    739 signed __int128 __atomic_or_fetch_16(volatile signed __int128 *, signed __int128, int);
    740521unsigned __int128 __atomic_or_fetch   (volatile unsigned __int128 *, unsigned __int128, int);
    741 unsigned __int128 __atomic_or_fetch_16(volatile unsigned __int128 *, unsigned __int128, int);
    742522#endif
    743523
    744524char __atomic_fetch_add  (volatile char *, char, int);
    745 char __atomic_fetch_add_1(volatile char *, char, int);
    746525signed char __atomic_fetch_add  (volatile signed char *, signed char, int);
    747 signed char __atomic_fetch_add_1(volatile signed char *, signed char, int);
    748526unsigned char __atomic_fetch_add  (volatile unsigned char *, unsigned char, int);
    749 unsigned char __atomic_fetch_add_1(volatile unsigned char *, unsigned char, int);
    750527signed short __atomic_fetch_add  (volatile signed short *, signed short, int);
    751 signed short __atomic_fetch_add_2(volatile signed short *, signed short, int);
    752528unsigned short __atomic_fetch_add  (volatile unsigned short *, unsigned short, int);
    753 unsigned short __atomic_fetch_add_2(volatile unsigned short *, unsigned short, int);
    754529signed int __atomic_fetch_add  (volatile signed int *, signed int, int);
    755 signed int __atomic_fetch_add_4(volatile signed int *, signed int, int);
    756530unsigned int __atomic_fetch_add  (volatile unsigned int *, unsigned int, int);
    757 unsigned int __atomic_fetch_add_4(volatile unsigned int *, unsigned int, int);
     531signed long int __atomic_fetch_add  (volatile signed long int *, signed long int, int);
     532unsigned long int __atomic_fetch_add  (volatile unsigned long int *, unsigned long int, int);
    758533signed long long int __atomic_fetch_add  (volatile signed long long int *, signed long long int, int);
    759 signed long long int __atomic_fetch_add_8(volatile signed long long int *, signed long long int, int);
    760534unsigned long long int __atomic_fetch_add  (volatile unsigned long long int *, unsigned long long int, int);
    761 unsigned long long int __atomic_fetch_add_8(volatile unsigned long long int *, unsigned long long int, int);
    762535#if defined(__SIZEOF_INT128__)
    763536signed __int128 __atomic_fetch_add   (volatile signed __int128 *, signed __int128, int);
    764 signed __int128 __atomic_fetch_add_16(volatile signed __int128 *, signed __int128, int);
    765537unsigned __int128 __atomic_fetch_add   (volatile unsigned __int128 *, unsigned __int128, int);
    766 unsigned __int128 __atomic_fetch_add_16(volatile unsigned __int128 *, unsigned __int128, int);
    767538#endif
    768539
    769540char __atomic_fetch_sub  (volatile char *, char, int);
    770 char __atomic_fetch_sub_1(volatile char *, char, int);
    771541signed char __atomic_fetch_sub  (volatile signed char *, signed char, int);
    772 signed char __atomic_fetch_sub_1(volatile signed char *, signed char, int);
    773542unsigned char __atomic_fetch_sub  (volatile unsigned char *, unsigned char, int);
    774 unsigned char __atomic_fetch_sub_1(volatile unsigned char *, unsigned char, int);
    775543signed short __atomic_fetch_sub  (volatile signed short *, signed short, int);
    776 signed short __atomic_fetch_sub_2(volatile signed short *, signed short, int);
    777544unsigned short __atomic_fetch_sub  (volatile unsigned short *, unsigned short, int);
    778 unsigned short __atomic_fetch_sub_2(volatile unsigned short *, unsigned short, int);
    779545signed int __atomic_fetch_sub  (volatile signed int *, signed int, int);
    780 signed int __atomic_fetch_sub_4(volatile signed int *, signed int, int);
    781546unsigned int __atomic_fetch_sub  (volatile unsigned int *, unsigned int, int);
    782 unsigned int __atomic_fetch_sub_4(volatile unsigned int *, unsigned int, int);
     547signed long int __atomic_fetch_sub  (volatile signed long int *, signed long int, int);
     548unsigned long int __atomic_fetch_sub  (volatile unsigned long int *, unsigned long int, int);
    783549signed long long int __atomic_fetch_sub  (volatile signed long long int *, signed long long int, int);
    784 signed long long int __atomic_fetch_sub_8(volatile signed long long int *, signed long long int, int);
    785550unsigned long long int __atomic_fetch_sub  (volatile unsigned long long int *, unsigned long long int, int);
    786 unsigned long long int __atomic_fetch_sub_8(volatile unsigned long long int *, unsigned long long int, int);
    787551#if defined(__SIZEOF_INT128__)
    788552signed __int128 __atomic_fetch_sub   (volatile signed  __int128 *, signed __int128, int);
    789 signed __int128 __atomic_fetch_sub_16(volatile signed  __int128 *, signed __int128, int);
    790553unsigned __int128 __atomic_fetch_sub   (volatile unsigned  __int128 *, unsigned __int128, int);
    791 unsigned __int128 __atomic_fetch_sub_16(volatile unsigned  __int128 *, unsigned __int128, int);
    792554#endif
    793555
    794556char __atomic_fetch_and  (volatile char *, char, int);
    795 char __atomic_fetch_and_1(volatile char *, char, int);
    796557signed char __atomic_fetch_and  (volatile signed char *, signed char, int);
    797 signed char __atomic_fetch_and_1(volatile signed char *, signed char, int);
    798558unsigned char __atomic_fetch_and  (volatile unsigned char *, unsigned char, int);
    799 unsigned char __atomic_fetch_and_1(volatile unsigned char *, unsigned char, int);
    800559signed short __atomic_fetch_and  (volatile signed short *, signed short, int);
    801 signed short __atomic_fetch_and_2(volatile signed short *, signed short, int);
    802560unsigned short __atomic_fetch_and  (volatile unsigned short *, unsigned short, int);
    803 unsigned short __atomic_fetch_and_2(volatile unsigned short *, unsigned short, int);
    804561signed int __atomic_fetch_and  (volatile signed int *, signed int, int);
    805 signed int __atomic_fetch_and_4(volatile signed int *, signed int, int);
    806562unsigned int __atomic_fetch_and  (volatile unsigned int *, unsigned int, int);
    807 unsigned int __atomic_fetch_and_4(volatile unsigned int *, unsigned int, int);
     563signed long int __atomic_fetch_and  (volatile signed long int *, signed long int, int);
     564unsigned long int __atomic_fetch_and  (volatile unsigned long int *, unsigned long int, int);
    808565signed long long int __atomic_fetch_and  (volatile signed long long int *, signed long long int, int);
    809 signed long long int __atomic_fetch_and_8(volatile signed long long int *, signed long long int, int);
    810566unsigned long long int __atomic_fetch_and  (volatile unsigned long long int *, unsigned long long int, int);
    811 unsigned long long int __atomic_fetch_and_8(volatile unsigned long long int *, unsigned long long int, int);
    812567#if defined(__SIZEOF_INT128__)
    813568signed __int128 __atomic_fetch_and   (volatile signed __int128 *, signed __int128, int);
    814 signed __int128 __atomic_fetch_and_16(volatile signed __int128 *, signed __int128, int);
    815569unsigned __int128 __atomic_fetch_and   (volatile unsigned __int128 *, unsigned __int128, int);
    816 unsigned __int128 __atomic_fetch_and_16(volatile unsigned __int128 *, unsigned __int128, int);
    817570#endif
    818571
    819572char __atomic_fetch_nand  (volatile char *, char, int);
    820 char __atomic_fetch_nand_1(volatile char *, char, int);
    821573signed char __atomic_fetch_nand  (volatile signed char *, signed char, int);
    822 signed char __atomic_fetch_nand_1(volatile signed char *, signed char, int);
    823574unsigned char __atomic_fetch_nand  (volatile unsigned char *, unsigned char, int);
    824 unsigned char __atomic_fetch_nand_1(volatile unsigned char *, unsigned char, int);
    825575signed short __atomic_fetch_nand  (volatile signed short *, signed short, int);
    826 signed short __atomic_fetch_nand_2(volatile signed short *, signed short, int);
    827576unsigned short __atomic_fetch_nand  (volatile unsigned short *, unsigned short, int);
    828 unsigned short __atomic_fetch_nand_2(volatile unsigned short *, unsigned short, int);
    829577signed int __atomic_fetch_nand  (volatile signed int *, signed int, int);
    830 signed int __atomic_fetch_nand_4(volatile signed int *, signed int, int);
    831578unsigned int __atomic_fetch_nand  (volatile unsigned int *, unsigned int, int);
    832 unsigned int __atomic_fetch_nand_4(volatile unsigned int *, unsigned int, int);
     579signed long int __atomic_fetch_nand  (volatile signed long int *, signed long int, int);
     580unsigned long int __atomic_fetch_nand  (volatile unsigned long int *, unsigned long int, int);
    833581signed long long int __atomic_fetch_nand  (volatile signed long long int *, signed long long int, int);
    834 signed long long int __atomic_fetch_nand_8(volatile signed long long int *, signed long long int, int);
    835582unsigned long long int __atomic_fetch_nand  (volatile unsigned long long int *, unsigned long long int, int);
    836 unsigned long long int __atomic_fetch_nand_8(volatile unsigned long long int *, unsigned long long int, int);
    837583#if defined(__SIZEOF_INT128__)
    838584signed __int128 __atomic_fetch_nand   (volatile signed __int128 *, signed __int128, int);
    839 signed __int128 __atomic_fetch_nand_16(volatile signed __int128 *, signed __int128, int);
    840585unsigned __int128 __atomic_fetch_nand   (volatile unsigned __int128 *, unsigned __int128, int);
    841 unsigned __int128 __atomic_fetch_nand_16(volatile unsigned __int128 *, unsigned __int128, int);
    842586#endif
    843587
    844588char __atomic_fetch_xor  (volatile char *, char, int);
    845 char __atomic_fetch_xor_1(volatile char *, char, int);
    846589signed char __atomic_fetch_xor  (volatile signed char *, signed char, int);
    847 signed char __atomic_fetch_xor_1(volatile signed char *, signed char, int);
    848590unsigned char __atomic_fetch_xor  (volatile unsigned char *, unsigned char, int);
    849 unsigned char __atomic_fetch_xor_1(volatile unsigned char *, unsigned char, int);
    850591signed short __atomic_fetch_xor  (volatile signed short *, signed short, int);
    851 signed short __atomic_fetch_xor_2(volatile signed short *, signed short, int);
    852592unsigned short __atomic_fetch_xor  (volatile unsigned short *, unsigned short, int);
    853 unsigned short __atomic_fetch_xor_2(volatile unsigned short *, unsigned short, int);
    854593signed int __atomic_fetch_xor  (volatile signed int *, signed int, int);
    855 signed int __atomic_fetch_xor_4(volatile signed int *, signed int, int);
    856594unsigned int __atomic_fetch_xor  (volatile unsigned int *, unsigned int, int);
    857 unsigned int __atomic_fetch_xor_4(volatile unsigned int *, unsigned int, int);
     595signed long int __atomic_fetch_xor  (volatile signed long int *, signed long int, int);
     596unsigned long int __atomic_fetch_xor  (volatile unsigned long int *, unsigned long int, int);
    858597signed long long int __atomic_fetch_xor  (volatile signed long long int *, signed long long int, int);
    859 signed long long int __atomic_fetch_xor_8(volatile signed long long int *, signed long long int, int);
    860598unsigned long long int __atomic_fetch_xor  (volatile unsigned long long int *, unsigned long long int, int);
    861 unsigned long long int __atomic_fetch_xor_8(volatile unsigned long long int *, unsigned long long int, int);
    862599#if defined(__SIZEOF_INT128__)
    863600signed __int128 __atomic_fetch_xor   (volatile signed __int128 *, signed __int128, int);
    864 signed __int128 __atomic_fetch_xor_16(volatile signed __int128 *, signed __int128, int);
    865601unsigned __int128 __atomic_fetch_xor   (volatile unsigned __int128 *, unsigned __int128, int);
    866 unsigned __int128 __atomic_fetch_xor_16(volatile unsigned __int128 *, unsigned __int128, int);
    867602#endif
    868603
    869604char __atomic_fetch_or  (volatile char *, char, int);
    870 char __atomic_fetch_or_1(volatile char *, char, int);
    871605signed char __atomic_fetch_or  (volatile signed char *, signed char, int);
    872 signed char __atomic_fetch_or_1(volatile signed char *, signed char, int);
    873606unsigned char __atomic_fetch_or  (volatile unsigned char *, unsigned char, int);
    874 unsigned char __atomic_fetch_or_1(volatile unsigned char *, unsigned char, int);
    875607signed short __atomic_fetch_or  (volatile signed short *, signed short, int);
    876 signed short __atomic_fetch_or_2(volatile signed short *, signed short, int);
    877608unsigned short __atomic_fetch_or  (volatile unsigned short *, unsigned short, int);
    878 unsigned short __atomic_fetch_or_2(volatile unsigned short *, unsigned short, int);
    879609signed int __atomic_fetch_or  (volatile signed int *, signed int, int);
    880 signed int __atomic_fetch_or_4(volatile signed int *, signed int, int);
    881610unsigned int __atomic_fetch_or  (volatile unsigned int *, unsigned int, int);
    882 unsigned int __atomic_fetch_or_4(volatile unsigned int *, unsigned int, int);
     611signed long int __atomic_fetch_or  (volatile signed long int *, signed long int, int);
     612unsigned long int __atomic_fetch_or  (volatile unsigned long int *, unsigned long int, int);
    883613signed long long int __atomic_fetch_or  (volatile signed long long int *, signed long long int, int);
    884 signed long long int __atomic_fetch_or_8(volatile signed long long int *, signed long long int, int);
    885614unsigned long long int __atomic_fetch_or  (volatile unsigned long long int *, unsigned long long int, int);
    886 unsigned long long int __atomic_fetch_or_8(volatile unsigned long long int *, unsigned long long int, int);
    887615#if defined(__SIZEOF_INT128__)
    888616signed __int128 __atomic_fetch_or   (volatile signed __int128 *, signed __int128, int);
    889 signed __int128 __atomic_fetch_or_16(volatile signed __int128 *, signed __int128, int);
    890617unsigned __int128 __atomic_fetch_or   (volatile unsigned __int128 *, unsigned __int128, int);
    891 unsigned __int128 __atomic_fetch_or_16(volatile unsigned __int128 *, unsigned __int128, int);
    892618#endif
    893619
  • libcfa/src/Makefile.am

    r807a632 r3b56166  
    3333# The built sources must not depend on the installed headers
    3434AM_CFAFLAGS = -quiet -cfalib -I$(srcdir)/stdhdr $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb) @CONFIG_CFAFLAGS@
    35 AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC @ARCH_FLAGS@ @CONFIG_CFLAGS@
     35AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC -pthread @ARCH_FLAGS@ @CONFIG_CFLAGS@
    3636AM_CCASFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@
    3737CFACC = @CFACC@
  • libcfa/src/Makefile.in

    r807a632 r3b56166  
    416416LTCFACOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
    417417        $(LIBTOOLFLAGS) --mode=compile $(CFACC) $(DEFS) \
    418         $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) \
    419         $(AM_CFLAGS) $(CFLAGS)
     418        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(AM_CFLAGS) $(CFAFLAGS) $(CFLAGS)
    420419
    421420AM_V_CFA = $(am__v_CFA_@AM_V@)
     
    423422am__v_CFA_0 = @echo "  CFA     " $@;
    424423am__v_CFA_1 =
    425 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
    426 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
    427 am__v_JAVAC_0 = @echo "  JAVAC   " $@;
    428 am__v_JAVAC_1 =
    429 AM_V_GOC = $(am__v_GOC_@AM_V@)
    430 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)
    431 am__v_GOC_0 = @echo "  GOC     " $@;
    432 am__v_GOC_1 =
    433424UPPCC = u++
    434425UPPCOMPILE = $(UPPCC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_UPPFLAGS) $(UPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_CFLAGS) $(CFLAGS)
     
    437428am__v_UPP_0 = @echo "  UPP     " $@;
    438429am__v_UPP_1 =
     430AM_V_GOC = $(am__v_GOC_@AM_V@)
     431am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)
     432am__v_GOC_0 = @echo "  GOC     " $@;
     433am__v_GOC_1 =
     434AM_V_RUST = $(am__v_RUST_@AM_V@)
     435am__v_RUST_ = $(am__v_RUST_@AM_DEFAULT_V@)
     436am__v_RUST_0 = @echo "  RUST     " $@;
     437am__v_RUST_1 =
     438AM_V_NODEJS = $(am__v_NODEJS_@AM_V@)
     439am__v_NODEJS_ = $(am__v_NODEJS_@AM_DEFAULT_V@)
     440am__v_NODEJS_0 = @echo "  NODEJS     " $@;
     441am__v_NODEJS_1 =
     442AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
     443am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
     444am__v_JAVAC_0 = @echo "  JAVAC   " $@;
     445am__v_JAVAC_1 =
    439446lib_LTLIBRARIES = libcfa.la libcfathread.la
    440447gdbwaittarget = ""
     
    445452# The built sources must not depend on the installed headers
    446453AM_CFAFLAGS = -quiet -cfalib -I$(srcdir)/stdhdr $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb) @CONFIG_CFAFLAGS@
    447 AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC @ARCH_FLAGS@ @CONFIG_CFLAGS@
     454AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC -pthread @ARCH_FLAGS@ @CONFIG_CFLAGS@
    448455AM_CCASFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@
    449456@BUILDLIB_FALSE@headers_nosrc =
  • libcfa/src/assert.cfa

    r807a632 r3b56166  
    1010// Created On       : Mon Nov 28 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 20 15:10:26 2017
    13 // Update Count     : 2
     12// Last Modified On : Tue Feb  4 13:00:18 2020
     13// Update Count     : 6
    1414//
    1515
     
    1717#include <stdarg.h>                                                             // varargs
    1818#include <stdio.h>                                                              // fprintf
     19#include <unistd.h>                                                             // STDERR_FILENO
    1920#include "bits/debug.hfa"
    2021
     
    2526
    2627        // called by macro assert in assert.h
    27         void __assert_fail( const char *assertion, const char *file, unsigned int line, const char *function ) {
    28                 __cfaabi_dbg_bits_print_safe( CFA_ASSERT_FMT ".\n", assertion, __progname, function, line, file );
     28        void __assert_fail( const char assertion[], const char file[], unsigned int line, const char function[] ) {
     29                __cfaabi_bits_print_safe( STDERR_FILENO, CFA_ASSERT_FMT ".\n", assertion, __progname, function, line, file );
    2930                abort();
    3031        }
    3132
    3233        // called by macro assertf
    33         void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) {
    34                 __cfaabi_dbg_bits_acquire();
    35                 __cfaabi_dbg_bits_print_nolock( CFA_ASSERT_FMT ": ", assertion, __progname, function, line, file );
     34        void __assert_fail_f( const char assertion[], const char file[], unsigned int line, const char function[], const char fmt[], ... ) {
     35                __cfaabi_bits_acquire();
     36                __cfaabi_bits_print_nolock( STDERR_FILENO, CFA_ASSERT_FMT ": ", assertion, __progname, function, line, file );
    3637
    3738                va_list args;
    3839                va_start( args, fmt );
    39                 __cfaabi_dbg_bits_print_vararg( fmt, args );
     40                __cfaabi_bits_print_vararg( STDERR_FILENO, fmt, args );
    4041                va_end( args );
    4142
    42                 __cfaabi_dbg_bits_print_nolock( "\n" );
    43                 __cfaabi_dbg_bits_release();
     43                __cfaabi_bits_print_nolock( STDERR_FILENO, "\n" );
     44                __cfaabi_bits_release();
    4445                abort();
    4546        }
  • libcfa/src/bits/align.hfa

    r807a632 r3b56166  
    1010// Created On       : Mon Nov 28 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 23:05:35 2017
    13 // Update Count     : 2
     12// Last Modified On : Sat Nov 16 18:58:22 2019
     13// Update Count     : 3
    1414//
    1515// This  library is free  software; you  can redistribute  it and/or  modify it
     
    3333
    3434// Minimum size used to align memory boundaries for memory allocations.
    35 #define libAlign() (sizeof(double))
     35//#define libAlign() (sizeof(double))
     36// gcc-7 uses xmms instructions, which require 16 byte alignment.
     37#define libAlign() (16)
    3638
    3739// Check for power of 2
  • libcfa/src/bits/containers.hfa

    r807a632 r3b56166  
    1010// Created On       : Tue Oct 31 16:38:50 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jun 26 08:52:20 2019
    13 // Update Count     : 4
     12// Last Modified On : Wed Jan 15 07:42:35 2020
     13// Update Count     : 28
    1414
    1515#pragma once
     
    4444
    4545        forall(dtype T | sized(T))
    46         static inline T& ?[?]( __small_array(T) & this, __lock_size_t idx) {
     46        static inline T & ?[?]( __small_array(T) & this, __lock_size_t idx ) {
    4747                return ((typeof(this.data))this.data)[idx];
    4848        }
    4949
    5050        forall(dtype T | sized(T))
    51         static inline T& ?[?]( const __small_array(T) & this, __lock_size_t idx) {
     51        static inline T & ?[?]( const __small_array(T) & this, __lock_size_t idx ) {
    5252                return ((typeof(this.data))this.data)[idx];
    5353        }
    5454
     55        forall(dtype T)
     56        static inline T * begin( const __small_array(T) & this ) {
     57                return ((typeof(this.data))this.data);
     58        }
     59
    5560        forall(dtype T | sized(T))
    56         static inline T* begin( const __small_array(T) & this ) {
    57                 return ((typeof(this.data))this.data);
    58         }
    59 
    60         forall(dtype T | sized(T))
    61         static inline T* end( const __small_array(T) & this ) {
     61        static inline T * end( const __small_array(T) & this ) {
    6262                return ((typeof(this.data))this.data) + this.size;
    6363        }
     
    7070#ifdef __cforall
    7171        trait is_node(dtype T) {
    72                 T*& get_next( T& );
     72                T *& get_next( T & );
    7373        };
    7474#endif
     
    9797        forall(dtype T)
    9898        static inline void ?{}( __stack(T) & this ) {
    99                 (this.top){ NULL };
    100         }
    101 
    102         forall(dtype T | is_node(T) | sized(T))
    103         static inline void push( __stack(T) & this, T * val ) {
    104                 verify( !get_next( *val ) );
    105                 get_next( *val ) = this.top;
    106                 this.top = val;
    107         }
    108 
    109         forall(dtype T | is_node(T) | sized(T))
    110         static inline T * pop( __stack(T) & this ) {
    111                 T * top = this.top;
    112                 if( top ) {
    113                         this.top = get_next( *top );
    114                         get_next( *top ) = NULL;
    115                 }
    116                 return top;
    117         }
    118 
    119         forall(dtype T | is_node(T))
    120         static inline int ?!=?( const __stack(T) & this, __attribute__((unused)) zero_t zero ) {
    121                 return this.top != 0;
     99                (this.top){ 0p };
     100        }
     101
     102        static inline forall( dtype T | is_node(T) ) {
     103                void push( __stack(T) & this, T * val ) {
     104                        verify( !get_next( *val ) );
     105                        get_next( *val ) = this.top;
     106                        this.top = val;
     107                }
     108
     109                T * pop( __stack(T) & this ) {
     110                        T * top = this.top;
     111                        if( top ) {
     112                                this.top = get_next( *top );
     113                                get_next( *top ) = 0p;
     114                        }
     115                        return top;
     116                }
     117
     118                int ?!=?( const __stack(T) & this, __attribute__((unused)) zero_t zero ) {
     119                        return this.top != 0;
     120                }
    122121        }
    123122#endif
     
    145144
    146145#ifdef __cforall
    147 
    148         forall(dtype T)
    149         static inline void ?{}( __queue(T) & this ) with( this ) {
    150                 head{ NULL };
    151                 tail{ &head };
    152         }
    153 
    154         forall(dtype T | is_node(T) | sized(T))
    155         static inline void append( __queue(T) & this, T * val ) with( this ) {
    156                 verify(tail != NULL);
    157                 *tail = val;
    158                 tail = &get_next( *val );
    159         }
    160 
    161         forall(dtype T | is_node(T) | sized(T))
    162         static inline T * pop_head( __queue(T) & this ) {
    163                 T * head = this.head;
    164                 if( head ) {
    165                         this.head = get_next( *head );
    166                         if( !get_next( *head ) ) {
    167                                 this.tail = &this.head;
    168                         }
    169                         get_next( *head ) = NULL;
    170                 }
    171                 return head;
    172         }
    173 
    174         forall(dtype T | is_node(T) | sized(T))
    175         static inline T * remove( __queue(T) & this, T ** it ) with( this ) {
    176                 T * val = *it;
    177                 verify( val );
    178 
    179                 (*it) = get_next( *val );
    180 
    181                 if( tail == &get_next( *val ) ) {
    182                         tail = it;
    183                 }
    184 
    185                 get_next( *val ) = NULL;
    186 
    187                 verify( (head == NULL) == (&head == tail) );
    188                 verify( *tail == NULL );
    189                 return val;
    190         }
    191 
    192         forall(dtype T | is_node(T))
    193         static inline int ?!=?( const __queue(T) & this, __attribute__((unused)) zero_t zero ) {
    194                 return this.head != 0;
     146        static inline forall( dtype T | is_node(T) ) {
     147                void ?{}( __queue(T) & this ) with( this ) {
     148                        head{ 0p };
     149                        tail{ &head };
     150                }
     151
     152                void append( __queue(T) & this, T * val ) with( this ) {
     153                        verify(tail != 0p);
     154                        *tail = val;
     155                        tail = &get_next( *val );
     156                }
     157
     158                T * pop_head( __queue(T) & this ) {
     159                        T * head = this.head;
     160                        if( head ) {
     161                                this.head = get_next( *head );
     162                                if( !get_next( *head ) ) {
     163                                        this.tail = &this.head;
     164                                }
     165                                get_next( *head ) = 0p;
     166                        }
     167                        return head;
     168                }
     169
     170                T * remove( __queue(T) & this, T ** it ) with( this ) {
     171                        T * val = *it;
     172                        verify( val );
     173
     174                        (*it) = get_next( *val );
     175
     176                        if( tail == &get_next( *val ) ) {
     177                                tail = it;
     178                        }
     179
     180                        get_next( *val ) = 0p;
     181
     182                        verify( (head == 0p) == (&head == tail) );
     183                        verify( *tail == 0p );
     184                        return val;
     185                }
     186
     187                int ?!=?( const __queue(T) & this, __attribute__((unused)) zero_t zero ) {
     188                        return this.head != 0;
     189                }
    195190        }
    196191#endif
     
    223218
    224219#ifdef __cforall
    225 
    226         forall(dtype T | sized(T))
     220        forall(dtype T )
    227221        static inline [void] ?{}( __dllist(T) & this, * [T * & next, T * & prev] ( T & ) __get ) {
    228                 this.head{ NULL };
     222                this.head{ 0p };
    229223                this.__get = __get;
    230224        }
     
    232226        #define next 0
    233227        #define prev 1
    234         forall(dtype T | sized(T))
    235         static inline void push_front( __dllist(T) & this, T & node ) with( this ) {
    236                 verify(__get);
    237                 if ( head ) {
    238                         __get( node ).next = head;
    239                         __get( node ).prev = __get( *head ).prev;
    240                         // inserted node must be consistent before it is seen
     228        static inline forall(dtype T) {
     229                void push_front( __dllist(T) & this, T & node ) with( this ) {
     230                        verify(__get);
     231                        if ( head ) {
     232                                __get( node ).next = head;
     233                                __get( node ).prev = __get( *head ).prev;
     234                                // inserted node must be consistent before it is seen
     235                                // prevent code movement across barrier
     236                                asm( "" : : : "memory" );
     237                                __get( *head ).prev = &node;
     238                                T & _prev = *__get( node ).prev;
     239                                __get( _prev ).next = &node;
     240                        } else {
     241                                __get( node ).next = &node;
     242                                __get( node ).prev = &node;
     243                        }
     244
    241245                        // prevent code movement across barrier
    242246                        asm( "" : : : "memory" );
    243                         __get( *head ).prev = &node;
    244                         T & _prev = *__get( node ).prev;
    245                         __get( _prev ).next = &node;
    246                 }
    247                 else {
    248                         __get( node ).next = &node;
    249                         __get( node ).prev = &node;
    250                 }
    251 
    252                 // prevent code movement across barrier
    253                 asm( "" : : : "memory" );
    254                 head = &node;
    255         }
    256 
    257         forall(dtype T | sized(T))
    258         static inline void remove( __dllist(T) & this, T & node ) with( this ) {
    259                 verify(__get);
    260                 if ( &node == head ) {
    261                         if ( __get( *head ).next == head ) {
    262                                 head = NULL;
    263                         }
    264                         else {
    265                                 head = __get( *head ).next;
    266                         }
    267                 }
    268                 __get( *__get( node ).next ).prev = __get( node ).prev;
    269                 __get( *__get( node ).prev ).next = __get( node ).next;
    270                 __get( node ).next = NULL;
    271                 __get( node ).prev = NULL;
    272         }
    273 
    274         forall(dtype T | sized(T))
    275         static inline int ?!=?( const __dllist(T) & this, __attribute__((unused)) zero_t zero ) {
    276                 return this.head != 0;
     247                        head = &node;
     248                }
     249
     250                void remove( __dllist(T) & this, T & node ) with( this ) {
     251                        verify(__get);
     252                        if ( &node == head ) {
     253                                if ( __get( *head ).next == head ) {
     254                                        head = 0p;
     255                                } else {
     256                                        head = __get( *head ).next;
     257                                }
     258                        }
     259                        __get( *__get( node ).next ).prev = __get( node ).prev;
     260                        __get( *__get( node ).prev ).next = __get( node ).next;
     261                        __get( node ).next = 0p;
     262                        __get( node ).prev = 0p;
     263                }
     264
     265                int ?!=?( const __dllist(T) & this, __attribute__((unused)) zero_t zero ) {
     266                        return this.head != 0;
     267                }
    277268        }
    278269        #undef next
     
    286277
    287278#endif
     279
     280// Local Variables: //
     281// tab-width: 4 //
     282// End: //
  • libcfa/src/bits/debug.cfa

    r807a632 r3b56166  
    1010// Created On       : Thu Mar 30 12:30:01 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jul 14 22:17:35 2019
    13 // Update Count     : 4
     12// Last Modified On : Tue Feb  4 13:03:16 2020
     13// Update Count     : 11
    1414//
    1515
     
    2727
    2828extern "C" {
    29 
    30         void __cfaabi_dbg_bits_write( 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 ) {
     
    3433
    3534                        for ( ;; ) {
    36                                 retcode = write( STDERR_FILENO, in_buffer, len - count );
     35                                retcode = write( fd, in_buffer, len - count );
    3736
    3837                                // not a timer interrupt ?
     
    4443        }
    4544
    46         void __cfaabi_dbg_bits_acquire() __attribute__((__weak__)) {}
    47         void __cfaabi_dbg_bits_release() __attribute__((__weak__)) {}
     45        void __cfaabi_bits_acquire() __attribute__((__weak__)) {}
     46        void __cfaabi_bits_release() __attribute__((__weak__)) {}
    4847
    49         void __cfaabi_dbg_bits_print_safe  ( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) )) {
     48        void __cfaabi_bits_print_safe  ( int fd, const char fmt[], ... ) __attribute__(( format(printf, 2, 3) )) {
    5049                va_list args;
    5150
    5251                va_start( args, fmt );
    53                 __cfaabi_dbg_bits_acquire();
     52                __cfaabi_bits_acquire();
    5453
    5554                int len = vsnprintf( buffer, buffer_size, fmt, args );
    56                 __cfaabi_dbg_bits_write( buffer, len );
     55                __cfaabi_bits_write( fd, buffer, len );
    5756
    58                 __cfaabi_dbg_bits_release();
     57                __cfaabi_bits_release();
    5958                va_end( args );
    6059        }
    6160
    62         void __cfaabi_dbg_bits_print_nolock( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) )) {
     61        void __cfaabi_bits_print_nolock( int fd, const char fmt[], ... ) __attribute__(( format(printf, 2, 3) )) {
    6362                va_list args;
    6463
     
    6665
    6766                int len = vsnprintf( buffer, buffer_size, fmt, args );
    68                 __cfaabi_dbg_bits_write( buffer, len );
     67                __cfaabi_bits_write( fd, buffer, len );
    6968
    7069                va_end( args );
    7170        }
    7271
    73         void __cfaabi_dbg_bits_print_vararg( const char fmt[], va_list args ) {
     72        void __cfaabi_bits_print_vararg( int fd, const char fmt[], va_list args ) {
    7473                int len = vsnprintf( buffer, buffer_size, fmt, args );
    75                 __cfaabi_dbg_bits_write( buffer, len );
     74                __cfaabi_bits_write( fd, buffer, len );
    7675        }
    7776
    78         void __cfaabi_dbg_bits_print_buffer( char in_buffer[], int in_buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 3, 4) )) {
     77        void __cfaabi_bits_print_buffer( int fd, char in_buffer[], int in_buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 4, 5) )) {
    7978                va_list args;
    8079
     
    8281
    8382                int len = vsnprintf( in_buffer, in_buffer_size, fmt, args );
    84                 __cfaabi_dbg_bits_write( in_buffer, len );
     83                __cfaabi_bits_write( fd, in_buffer, len );
    8584
    8685                va_end( args );
  • libcfa/src/bits/debug.hfa

    r807a632 r3b56166  
    1010// Created On       : Mon Nov 28 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb  8 12:35:19 2018
    13 // Update Count     : 2
     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_dbg_bits_write( const char *buffer, int len );
    41       extern void __cfaabi_dbg_bits_acquire();
    42       extern void __cfaabi_dbg_bits_release();
    43       extern void __cfaabi_dbg_bits_print_safe  ( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) ));
    44       extern void __cfaabi_dbg_bits_print_nolock( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) ));
    45       extern void __cfaabi_dbg_bits_print_vararg( const char fmt[], va_list arg );
    46       extern void __cfaabi_dbg_bits_print_buffer( char buffer[], int buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 3, 4) ));
     40        extern void __cfaabi_bits_write( int fd, const char buffer[], int len );
     41        extern void __cfaabi_bits_acquire();
     42        extern void __cfaabi_bits_release();
     43        extern void __cfaabi_bits_print_safe  ( int fd, const char fmt[], ... ) __attribute__(( format(printf, 2, 3) ));
     44        extern void __cfaabi_bits_print_nolock( int fd, const char fmt[], ... ) __attribute__(( format(printf, 2, 3) ));
     45        extern void __cfaabi_bits_print_vararg( int fd, const char fmt[], va_list arg );
     46        extern void __cfaabi_bits_print_buffer( int fd, char buffer[], int buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 4, 5) ));
    4747#ifdef __cforall
    4848}
     
    5050
    5151#ifdef __CFA_DEBUG_PRINT__
    52         #define __cfaabi_dbg_write( buffer, len )         __cfaabi_dbg_bits_write( buffer, len )
    53         #define __cfaabi_dbg_acquire()                    __cfaabi_dbg_bits_acquire()
    54         #define __cfaabi_dbg_release()                    __cfaabi_dbg_bits_release()
    55         #define __cfaabi_dbg_print_safe(...)              __cfaabi_dbg_bits_print_safe   (__VA_ARGS__)
    56         #define __cfaabi_dbg_print_nolock(...)            __cfaabi_dbg_bits_print_nolock (__VA_ARGS__)
    57         #define __cfaabi_dbg_print_buffer(...)            __cfaabi_dbg_bits_print_buffer (__VA_ARGS__)
    58         #define __cfaabi_dbg_print_buffer_decl(...)       char __dbg_text[256]; int __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_dbg_bits_write( __dbg_text, __dbg_len );
    59         #define __cfaabi_dbg_print_buffer_local(...)      __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_dbg_bits_write( __dbg_text, __dbg_len );
     52        #define __cfaabi_dbg_write( buffer, len )         __cfaabi_bits_write( STDERR_FILENO, buffer, len )
     53        #define __cfaabi_dbg_acquire()                    __cfaabi_bits_acquire()
     54        #define __cfaabi_dbg_release()                    __cfaabi_bits_release()
     55        #define __cfaabi_dbg_print_safe(...)              __cfaabi_bits_print_safe   (__VA_ARGS__)
     56        #define __cfaabi_dbg_print_nolock(...)            __cfaabi_bits_print_nolock (__VA_ARGS__)
     57        #define __cfaabi_dbg_print_buffer(...)            __cfaabi_bits_print_buffer (__VA_ARGS__)
     58        #define __cfaabi_dbg_print_buffer_decl(...)       char __dbg_text[256]; int __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_bits_write( __dbg_text, __dbg_len );
     59        #define __cfaabi_dbg_print_buffer_local(...)      __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_dbg_write( __dbg_text, __dbg_len );
    6060#else
    6161        #define __cfaabi_dbg_write(...)               ((void)0)
  • libcfa/src/bits/defs.hfa

    r807a632 r3b56166  
    1010// Created On       : Thu Nov  9 13:24:10 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb  8 16:22:41 2018
    13 // Update Count     : 8
     12// Last Modified On : Tue Jan 28 22:38:27 2020
     13// Update Count     : 9
    1414//
    1515
     
    3434
    3535#ifdef __cforall
    36 void abort ( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
     36void abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
     37void abort( bool signalAbort, const char fmt[], ... ) __attribute__ (( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ ));
    3738extern "C" {
    3839#endif
     
    4748#define OPTIONAL_THREAD __attribute__((weak))
    4849#endif
     50
     51static inline long long rdtscl(void) {
     52    unsigned int lo, hi;
     53    __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
     54    return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 );
     55}
  • libcfa/src/bits/locks.hfa

    r807a632 r3b56166  
    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/bits/signal.hfa

    r807a632 r3b56166  
    3737
    3838        act.sa_sigaction = (void (*)(int, siginfo_t *, void *))handler;
     39        sigemptyset( &act.sa_mask );
     40        sigaddset( &act.sa_mask, SIGALRM );             // disabled during signal handler
     41        sigaddset( &act.sa_mask, SIGUSR1 );
     42        sigaddset( &act.sa_mask, SIGSEGV );
     43        sigaddset( &act.sa_mask, SIGBUS );
     44        sigaddset( &act.sa_mask, SIGILL );
     45        sigaddset( &act.sa_mask, SIGFPE );
     46        sigaddset( &act.sa_mask, SIGHUP );              // revert to default on second delivery
     47        sigaddset( &act.sa_mask, SIGTERM );
     48        sigaddset( &act.sa_mask, SIGINT );
    3949        act.sa_flags = flags;
    4050
    41         if ( sigaction( sig, &act, NULL ) == -1 ) {
     51        if ( sigaction( sig, &act, 0p ) == -1 ) {
    4252                __cfaabi_dbg_print_buffer_decl(
    4353                        " __cfaabi_sigaction( sig:%d, handler:%p, flags:%d ), problem installing signal handler, error(%d) %s.\n",
     
    4555                );
    4656                _exit( EXIT_FAILURE );
    47         }
     57        } // if
    4858}
    49 
    50 // Sigaction wrapper : restore default handler
    51 static void __cfaabi_sigdefault( int sig ) {
    52         struct sigaction act;
    53 
    54         act.sa_handler = SIG_DFL;
    55         act.sa_flags = 0;
    56         sigemptyset( &act.sa_mask );
    57 
    58         if ( sigaction( sig, &act, NULL ) == -1 ) {
    59                 __cfaabi_dbg_print_buffer_decl(
    60                         " __cfaabi_sigdefault( sig:%d ), problem reseting signal handler, error(%d) %s.\n",
    61                         sig, errno, strerror( errno )
    62                 );
    63                 _exit( EXIT_FAILURE );
    64         }
    65 }
  • libcfa/src/clock.hfa

    r807a632 r3b56166  
    1010// Created On       : Thu Apr 12 14:36:06 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun 13 21:21:13 2019
    13 // Update Count     : 8
     12// Last Modified On : Mon Jan  6 12:49:58 2020
     13// Update Count     : 9
    1414//
    1515
    1616#include <time.hfa>
    17 
    1817
    1918//######################### C time #########################
     
    2625static inline tm * localtime_r( time_t tp, tm * result ) { return localtime_r( &tp, result ); }
    2726
    28 
    2927//######################### Clock #########################
    3028
    3129struct Clock {                                                                                  // private
    3230        Duration offset;                                                                        // for virtual clock: contains offset from real-time
    33         int clocktype;                                                                          // implementation only -1 (virtual), CLOCK_REALTIME
    3431};
    3532
    3633static inline {
    37         void resetClock( Clock & clk ) with( clk ) {
    38                 clocktype = CLOCK_REALTIME_COARSE;
    39         } // Clock::resetClock
    40 
    4134        void resetClock( Clock & clk, Duration adj ) with( clk ) {
    42                 clocktype = -1;
    4335                offset = adj + __timezone`s;                                    // timezone (global) is (UTC - local time) in seconds
    4436        } // resetClock
    4537
    46         void ?{}( Clock & clk ) { resetClock( clk ); }
    4738        void ?{}( Clock & clk, Duration adj ) { resetClock( clk, adj ); }
    4839
     
    8980                return ret;
    9081        } // getTime
     82
     83        Time getCPUTime() {
     84                timespec ts;
     85                clock_gettime( CLOCK_THREAD_CPUTIME_ID, &ts );
     86                return (Time){ ts };
     87    } // getCPUTime
    9188} // distribution
    9289
  • libcfa/src/concurrency/CtxSwitch-x86_64.S

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

    r807a632 r3b56166  
    1010// Created On       : Fri Jun 2 11:31:25 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri May 25 06:25:47 2018
    13 // Update Count     : 67
     12// Last Modified On : Sun Jan  5 08:41:36 2020
     13// Update Count     : 69
    1414//
    1515
     
    3939
    4040void __kernel_set_timer( Duration alarm ) {
    41         verifyf(alarm >= 1`us || alarm == 0, "Setting timer to < 1us (%jins)", alarm.tv);
    42         setitimer( ITIMER_REAL, &(itimerval){ alarm }, NULL );
     41        verifyf(alarm >= 1`us || alarm == 0, "Setting timer to < 1us (%jins)", alarm`ns);
     42        setitimer( ITIMER_REAL, &(itimerval){ alarm }, 0p );
    4343}
    4444
     
    113113                        this->tail = &this->head;
    114114                }
    115                 head->next = NULL;
     115                head->next = 0p;
    116116        }
    117117        verify( validate( this ) );
     
    127127                this->tail = it;
    128128        }
    129         n->next = NULL;
     129        n->next = 0p;
    130130
    131131        verify( validate( this ) );
  • libcfa/src/concurrency/coroutine.cfa

    r807a632 r3b56166  
    1010// Created On       : Mon Nov 28 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 30 17:20:57 2018
    13 // Update Count     : 9
     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 ) {
    92         (this.context){NULL, NULL};
     91void ?{}( coroutine_desc & this, const char name[], void * storage, size_t storageSize ) with( this ) {
     92        (this.context){0p, 0p};
    9393        (this.stack){storage, storageSize};
    9494        this.name = name;
    9595        state = Start;
    96         starter = NULL;
    97         last = NULL;
    98         cancellation = NULL;
     96        starter = 0p;
     97        last = 0p;
     98        cancellation = 0p;
    9999}
    100100
     
    131131
    132132[void *, size_t] __stack_alloc( size_t storageSize ) {
    133         static const size_t stack_data_size = libCeiling( sizeof(__stack_t), 16 ); // minimum alignment
     133        const size_t stack_data_size = libCeiling( sizeof(__stack_t), 16 ); // minimum alignment
    134134        assert(__page_size != 0l);
    135135        size_t size = libCeiling( storageSize, 16 ) + stack_data_size;
     
    157157
    158158void __stack_prepare( __stack_info_t * this, size_t create_size ) {
    159         static const size_t stack_data_size = libCeiling( sizeof(__stack_t), 16 ); // minimum alignment
     159        const size_t stack_data_size = libCeiling( sizeof(__stack_t), 16 ); // minimum alignment
    160160        bool userStack;
    161161        void * storage;
     
    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

    r807a632 r3b56166  
    1010// Created On       : Mon Nov 28 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jun 21 17:49:39 2019
    13 // Update Count     : 9
     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
    40 static inline void ?{}( coroutine_desc & this)                                       { this{ "Anonymous Coroutine", NULL, 0 }; }
    41 static inline void ?{}( coroutine_desc & this, size_t stackSize)                     { this{ "Anonymous Coroutine", NULL, stackSize }; }
     40static inline void ?{}( coroutine_desc & this)                                       { this{ "Anonymous Coroutine", 0p, 0 }; }
     41static 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, NULL, 0 }; }
    44 static inline void ?{}( coroutine_desc & this, const char * name, size_t stackSize ) { this{ name, NULL, 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__));
     
    8988        src->state = Active;
    9089
    91         if( unlikely(src->cancellation != NULL) ) {
     90        if( unlikely(src->cancellation != 0p) ) {
    9291                _CtxCoroutine_Unwind(src->cancellation, src);
    9392        }
     
    128127        coroutine_desc * dst = get_coroutine(cor);
    129128
    130         if( unlikely(dst->context.SP == NULL) ) {
     129        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

    r807a632 r3b56166  
    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/invoke.h

    r807a632 r3b56166  
    1010// Created On       : Tue Jan 17 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jun 22 18:19:13 2019
    13 // Update Count     : 40
     12// Last Modified On : Thu Dec  5 16:26:03 2019
     13// Update Count     : 44
    1414//
    1515
     
    4646        #ifdef __cforall
    4747        extern "Cforall" {
    48                 extern thread_local struct KernelThreadData {
     48                extern __attribute__((aligned(128))) thread_local struct KernelThreadData {
    4949                        struct thread_desc    * volatile this_thread;
    5050                        struct processor      * volatile this_processor;
     
    5555                                volatile bool in_progress;
    5656                        } preemption_state;
     57
     58                        uint32_t rand_seed;
    5759                } kernelTLS __attribute__ ((tls_model ( "initial-exec" )));
    5860        }
     
    205207
    206208                static inline void ?{}(__monitor_group_t & this) {
    207                         (this.data){NULL};
     209                        (this.data){0p};
    208210                        (this.size){0};
    209211                        (this.func){NULL};
  • libcfa/src/concurrency/kernel.cfa

    r807a632 r3b56166  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun 20 17:21:23 2019
    13 // Update Count     : 25
     12// Last Modified On : Tue Feb  4 13:03:15 2020
     13// Update Count     : 58
    1414//
    1515
     
    2626#include <signal.h>
    2727#include <unistd.h>
     28#include <limits.h>                                                                             // PTHREAD_STACK_MIN
     29#include <sys/mman.h>                                                                   // mprotect
    2830}
    2931
     
    4042//-----------------------------------------------------------------------------
    4143// Some assembly required
    42 #if   defined( __i386 )
     44#if defined( __i386 )
    4345        #define CtxGet( ctx )        \
    4446                __asm__ volatile (     \
     
    123125
    124126extern "C" {
    125 struct { __dllist_t(cluster) list; __spinlock_t lock; } __cfa_dbg_global_clusters;
     127        struct { __dllist_t(cluster) list; __spinlock_t lock; } __cfa_dbg_global_clusters;
    126128}
    127129
     
    131133// Global state
    132134thread_local struct KernelThreadData kernelTLS __attribute__ ((tls_model ( "initial-exec" ))) = {
     135        NULL,                                                                                           // cannot use 0p
    133136        NULL,
    134         NULL,
    135         { 1, false, false }
     137        { 1, false, false },
     138        6u //this should be seeded better but due to a bug calling rdtsc doesn't work
    136139};
    137140
     
    139142// Struct to steal stack
    140143struct current_stack_info_t {
    141         __stack_t * storage;            // pointer to stack object
    142         void *base;                             // base of stack
    143         void *limit;                    // stack grows towards stack limit
    144         void *context;                  // address of cfa_context_t
     144        __stack_t * storage;                                                            // pointer to stack object
     145        void * base;                                                                            // base of stack
     146        void * limit;                                                                           // stack grows towards stack limit
     147        void * context;                                                                         // address of cfa_context_t
    145148};
    146149
     
    171174        name = "Main Thread";
    172175        state = Start;
    173         starter = NULL;
    174         last = NULL;
    175         cancellation = NULL;
     176        starter = 0p;
     177        last = 0p;
     178        cancellation = 0p;
    176179}
    177180
     
    184187        self_mon.recursion = 1;
    185188        self_mon_p = &self_mon;
    186         next = NULL;
    187 
    188         node.next = NULL;
    189         node.prev = NULL;
     189        next = 0p;
     190
     191        node.next = 0p;
     192        node.prev = 0p;
    190193        doregister(curr_cluster, this);
    191194
     
    206209
    207210static void start(processor * this);
    208 void ?{}(processor & this, const char * name, cluster & cltr) with( this ) {
     211void ?{}(processor & this, const char name[], cluster & cltr) with( this ) {
    209212        this.name = name;
    210213        this.cltr = &cltr;
    211214        terminated{ 0 };
    212215        do_terminate = false;
    213         preemption_alarm = NULL;
     216        preemption_alarm = 0p;
    214217        pending_preemption = false;
    215218        runner.proc = &this;
     
    231234        }
    232235
    233         pthread_join( kernel_thread, NULL );
    234 }
    235 
    236 void ?{}(cluster & this, const char * name, Duration preemption_rate) with( this ) {
     236        pthread_join( kernel_thread, 0p );
     237        free( this.stack );
     238}
     239
     240void ?{}(cluster & this, const char name[], Duration preemption_rate) with( this ) {
    237241        this.name = name;
    238242        this.preemption_rate = preemption_rate;
     
    260264//Main of the processor contexts
    261265void main(processorCtx_t & runner) {
     266        // Because of a bug, we couldn't initialized the seed on construction
     267        // Do it here
     268        kernelTLS.rand_seed ^= rdtscl();
     269
    262270        processor * this = runner.proc;
    263271        verify(this);
     
    273281                __cfaabi_dbg_print_safe("Kernel : core %p started\n", this);
    274282
    275                 thread_desc * readyThread = NULL;
    276                 for( unsigned int spin_count = 0; ! __atomic_load_n(&this->do_terminate, __ATOMIC_SEQ_CST); spin_count++ )
    277                 {
     283                thread_desc * readyThread = 0p;
     284                for( unsigned int spin_count = 0; ! __atomic_load_n(&this->do_terminate, __ATOMIC_SEQ_CST); spin_count++ ) {
    278285                        readyThread = nextThread( this->cltr );
    279286
    280                         if(readyThread)
    281                         {
     287                        if(readyThread) {
    282288                                verify( ! kernelTLS.preemption_state.enabled );
    283289
     
    290296
    291297                                spin_count = 0;
    292                         }
    293                         else
    294                         {
     298                        } else {
    295299                                // spin(this, &spin_count);
    296300                                halt(this);
     
    405409        processor * proc = (processor *) arg;
    406410        kernelTLS.this_processor = proc;
    407         kernelTLS.this_thread    = NULL;
     411        kernelTLS.this_thread    = 0p;
    408412        kernelTLS.preemption_state.[enabled, disable_count] = [false, 1];
    409413        // SKULLDUGGERY: We want to create a context for the processor coroutine
     
    418422
    419423        //Set global state
    420         kernelTLS.this_thread    = NULL;
     424        kernelTLS.this_thread = 0p;
    421425
    422426        //We now have a proper context from which to schedule threads
     
    434438        __cfaabi_dbg_print_safe("Kernel : core %p main ended (%p)\n", proc, &proc->runner);
    435439
    436         return NULL;
     440        return 0p;
     441}
     442
     443static void Abort( int ret, const char func[] ) {
     444        if ( ret ) {                                                                            // pthread routines return errno values
     445                abort( "%s : internal error, error(%d) %s.", func, ret, strerror( ret ) );
     446        } // if
     447} // Abort
     448
     449void * create_pthread( pthread_t * pthread, void * (*start)(void *), void * arg ) {
     450        pthread_attr_t attr;
     451
     452        Abort( pthread_attr_init( &attr ), "pthread_attr_init" ); // initialize attribute
     453
     454        size_t stacksize;
     455        // default stack size, normally defined by shell limit
     456        Abort( pthread_attr_getstacksize( &attr, &stacksize ), "pthread_attr_getstacksize" );
     457        assert( stacksize >= PTHREAD_STACK_MIN );
     458
     459        void * stack;
     460        __cfaabi_dbg_debug_do(
     461                stack = memalign( __page_size, stacksize + __page_size );
     462                // pthread has no mechanism to create the guard page in user supplied stack.
     463                if ( mprotect( stack, __page_size, PROT_NONE ) == -1 ) {
     464                        abort( "mprotect : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) );
     465                } // if
     466        );
     467        __cfaabi_dbg_no_debug_do(
     468                stack = malloc( stacksize );
     469        );
     470
     471        Abort( pthread_attr_setstack( &attr, stack, stacksize ), "pthread_attr_setstack" );
     472
     473        Abort( pthread_create( pthread, &attr, start, arg ), "pthread_create" );
     474        return stack;
    437475}
    438476
     
    440478        __cfaabi_dbg_print_safe("Kernel : Starting core %p\n", this);
    441479
    442         pthread_create( &this->kernel_thread, NULL, CtxInvokeProcessor, (void*)this );
     480        this->stack = create_pthread( &this->kernel_thread, CtxInvokeProcessor, (void *)this );
    443481
    444482        __cfaabi_dbg_print_safe("Kernel : core %p started\n", this);
     
    452490        verify( ! kernelTLS.preemption_state.enabled );
    453491
     492        kernelTLS.this_thread->curr_cor = dst;
    454493        __stack_prepare( &dst->stack, 65000 );
    455         CtxStart(&this->runner, CtxInvokeCoroutine);
     494        CtxStart(main, dst, this->runner, CtxInvokeCoroutine);
    456495
    457496        verify( ! kernelTLS.preemption_state.enabled );
     
    468507        // when CtxSwitch returns we are back in the src coroutine
    469508
     509        mainThread->curr_cor = &mainThread->self_cor;
     510
    470511        // set state of new coroutine to active
    471512        src->state = Active;
     
    497538        verify( ! kernelTLS.preemption_state.enabled );
    498539
    499         verifyf( thrd->next == NULL, "Expected null got %p", thrd->next );
     540        verifyf( thrd->next == 0p, "Expected null got %p", thrd->next );
    500541
    501542        with( *thrd->curr_cluster ) {
     
    676717        void ?{}(processorCtx_t & this, processor * proc) {
    677718                (this.__cor){ "Processor" };
    678                 this.__cor.starter = NULL;
     719                this.__cor.starter = 0p;
    679720                this.proc = proc;
    680721        }
     
    685726                terminated{ 0 };
    686727                do_terminate = false;
    687                 preemption_alarm = NULL;
     728                preemption_alarm = 0p;
    688729                pending_preemption = false;
    689730                kernel_thread = pthread_self();
     
    803844                sigemptyset( &mask );
    804845                sigaddset( &mask, SIGALRM );            // block SIGALRM signals
    805                 sigsuspend( &mask );                    // block the processor to prevent further damage during abort
    806                 _exit( EXIT_FAILURE );                  // if processor unblocks before it is killed, terminate it
     846                sigaddset( &mask, SIGUSR1 );            // block SIGALRM signals
     847                sigsuspend( &mask );                            // block the processor to prevent further damage during abort
     848                _exit( EXIT_FAILURE );                          // if processor unblocks before it is killed, terminate it
    807849        }
    808850        else {
     
    819861        if(thrd) {
    820862                int len = snprintf( abort_text, abort_text_size, "Error occurred while executing thread %.256s (%p)", thrd->self_cor.name, thrd );
    821                 __cfaabi_dbg_bits_write( abort_text, len );
     863                __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
    822864
    823865                if ( &thrd->self_cor != thrd->curr_cor ) {
    824866                        len = snprintf( abort_text, abort_text_size, " in coroutine %.256s (%p).\n", thrd->curr_cor->name, thrd->curr_cor );
    825                         __cfaabi_dbg_bits_write( abort_text, len );
     867                        __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
    826868                }
    827869                else {
    828                         __cfaabi_dbg_bits_write( ".\n", 2 );
     870                        __cfaabi_bits_write( STDERR_FILENO, ".\n", 2 );
    829871                }
    830872        }
    831873        else {
    832874                int len = snprintf( abort_text, abort_text_size, "Error occurred outside of any thread.\n" );
    833                 __cfaabi_dbg_bits_write( abort_text, len );
     875                __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
    834876        }
    835877}
     
    842884
    843885extern "C" {
    844         void __cfaabi_dbg_bits_acquire() {
     886        void __cfaabi_bits_acquire() {
    845887                lock( kernel_debug_lock __cfaabi_dbg_ctx2 );
    846888        }
    847889
    848         void __cfaabi_dbg_bits_release() {
     890        void __cfaabi_bits_release() {
    849891                unlock( kernel_debug_lock );
    850892        }
     
    879921
    880922void V(semaphore & this) with( this ) {
    881         thread_desc * thrd = NULL;
     923        thread_desc * thrd = 0p;
    882924        lock( lock __cfaabi_dbg_ctx2 );
    883925        count += 1;
     
    939981__cfaabi_dbg_debug_do(
    940982        extern "C" {
    941                 void __cfaabi_dbg_record(__spinlock_t & this, const char * prev_name) {
     983                void __cfaabi_dbg_record(__spinlock_t & this, const char prev_name[]) {
    942984                        this.prev_name = prev_name;
    943985                        this.prev_thrd = kernelTLS.this_thread;
  • libcfa/src/concurrency/kernel.hfa

    r807a632 r3b56166  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jun 22 11:39:17 2019
    13 // Update Count     : 16
     12// Last Modified On : Tue Feb  4 12:29:26 2020
     13// Update Count     : 22
    1414//
    1515
     
    2020#include "invoke.h"
    2121#include "time_t.hfa"
     22#include "coroutine.hfa"
    2223
    2324extern "C" {
     
    8889static inline void ?{}(FinishAction & this) {
    8990        this.action_code = No_Action;
    90         this.thrd = NULL;
    91         this.lock = NULL;
     91        this.thrd = 0p;
     92        this.lock = 0p;
    9293}
    9394static inline void ^?{}(FinishAction &) {}
     
    134135        semaphore terminated;
    135136
     137        // pthread Stack
     138        void * stack;
     139
    136140        // Link lists fields
    137141        struct __dbg_node_proc {
     
    146150};
    147151
    148 void  ?{}(processor & this, const char * name, struct cluster & cltr);
     152void  ?{}(processor & this, const char name[], struct cluster & cltr);
    149153void ^?{}(processor & this);
    150154
    151155static inline void  ?{}(processor & this)                    { this{ "Anonymous Processor", *mainCluster}; }
    152156static inline void  ?{}(processor & this, struct cluster & cltr)    { this{ "Anonymous Processor", cltr}; }
    153 static inline void  ?{}(processor & this, const char * name) { this{name, *mainCluster }; }
     157static inline void  ?{}(processor & this, const char name[]) { this{name, *mainCluster }; }
    154158
    155159static inline [processor *&, processor *& ] __get( processor & this ) {
     
    191195extern Duration default_preemption();
    192196
    193 void ?{} (cluster & this, const char * name, Duration preemption_rate);
     197void ?{} (cluster & this, const char name[], Duration preemption_rate);
    194198void ^?{}(cluster & this);
    195199
    196200static inline void ?{} (cluster & this)                           { this{"Anonymous Cluster", default_preemption()}; }
    197201static inline void ?{} (cluster & this, Duration preemption_rate) { this{"Anonymous Cluster", preemption_rate}; }
    198 static inline void ?{} (cluster & this, const char * name)        { this{name, default_preemption()}; }
     202static inline void ?{} (cluster & this, const char name[])        { this{name, default_preemption()}; }
    199203
    200204static inline [cluster *&, cluster *& ] __get( cluster & this ) {
  • libcfa/src/concurrency/kernel_private.hfa

    r807a632 r3b56166  
    1010// Created On       : Mon Feb 13 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 29 14:06:40 2018
    13 // Update Count     : 3
     12// Last Modified On : Sat Nov 30 19:25:02 2019
     13// Update Count     : 8
    1414//
    1515
     
    5757void main(processorCtx_t *);
    5858
     59void * create_pthread( pthread_t *, void * (*)(void *), void * );
     60
    5961static inline void wake_fast(processor * this) {
    6062        __cfaabi_dbg_print_safe("Kernel : Waking up processor %p\n", this);
     
    8688// Threads
    8789extern "C" {
    88       forall(dtype T | is_thread(T))
    89       void CtxInvokeThread(T * this);
     90      void CtxInvokeThread(void (*main)(void *), void * this);
    9091}
    9192
     
    100101// Utils
    101102#define KERNEL_STORAGE(T,X) static char storage_##X[sizeof(T)]
     103
     104static inline uint32_t tls_rand() {
     105        kernelTLS.rand_seed ^= kernelTLS.rand_seed << 6;
     106        kernelTLS.rand_seed ^= kernelTLS.rand_seed >> 21;
     107        kernelTLS.rand_seed ^= kernelTLS.rand_seed << 7;
     108        return kernelTLS.rand_seed;
     109}
    102110
    103111
  • libcfa/src/concurrency/monitor.cfa

    r807a632 r3b56166  
    1010// Created On       : Thd Feb 23 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 30 14:30:26 2018
    13 // Update Count     : 9
     12// Last Modified On : Wed Dec  4 07:55:14 2019
     13// Update Count     : 10
    1414//
    1515
     
    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
     
    363364        this.waiting_thread = waiting_thread;
    364365        this.count = count;
    365         this.next = NULL;
     366        this.next = 0p;
    366367        this.user_info = user_info;
    367368}
     
    369370void ?{}(__condition_criterion_t & this ) with( this ) {
    370371        ready  = false;
    371         target = NULL;
    372         owner  = NULL;
    373         next   = NULL;
     372        target = 0p;
     373        owner  = 0p;
     374        next   = 0p;
    374375}
    375376
     
    378379        this.target = target;
    379380        this.owner  = &owner;
    380         this.next   = NULL;
     381        this.next   = 0p;
    381382}
    382383
     
    387388
    388389        // Check that everything is as expected
    389         assertf( this.monitors != NULL, "Waiting with no monitors (%p)", this.monitors );
     390        assertf( this.monitors != 0p, "Waiting with no monitors (%p)", this.monitors );
    390391        verifyf( this.monitor_count != 0, "Waiting with 0 monitors (%"PRIiFAST16")", this.monitor_count );
    391392        verifyf( this.monitor_count < 32u, "Excessive monitor count (%"PRIiFAST16")", this.monitor_count );
     
    449450
    450451        // Lock all monitors
    451         lock_all( this.monitors, NULL, count );
     452        lock_all( this.monitors, 0p, count );
    452453
    453454        //Pop the head of the waiting queue
     
    471472
    472473        //Check that everything is as expected
    473         verifyf( this.monitors != NULL, "Waiting with no monitors (%p)", this.monitors );
     474        verifyf( this.monitors != 0p, "Waiting with no monitors (%p)", this.monitors );
    474475        verifyf( this.monitor_count != 0, "Waiting with 0 monitors (%"PRIiFAST16")", this.monitor_count );
    475476
     
    674675
    675676static inline void reset_mask( monitor_desc * this ) {
    676         this->mask.accepted = NULL;
    677         this->mask.data = NULL;
     677        this->mask.accepted = 0p;
     678        this->mask.data = 0p;
    678679        this->mask.size = 0;
    679680}
     
    816817        }
    817818
    818         __cfaabi_dbg_print_safe( "Kernel :  Runing %i (%p)\n", ready2run, ready2run ? node->waiting_thread : NULL );
    819         return ready2run ? node->waiting_thread : NULL;
     819        __cfaabi_dbg_print_safe( "Kernel :  Runing %i (%p)\n", ready2run, ready2run ? node->waiting_thread : 0p );
     820        return ready2run ? node->waiting_thread : 0p;
    820821}
    821822
     
    824825        if( !this.monitors ) {
    825826                // __cfaabi_dbg_print_safe( "Branding\n" );
    826                 assertf( thrd->monitors.data != NULL, "No current monitor to brand condition %p", thrd->monitors.data );
     827                assertf( thrd->monitors.data != 0p, "No current monitor to brand condition %p", thrd->monitors.data );
    827828                this.monitor_count = thrd->monitors.size;
    828829
  • libcfa/src/concurrency/monitor.hfa

    r807a632 r3b56166  
    1010// Created On       : Thd Feb 23 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Oct  7 18:06:45 2017
    13 // Update Count     : 10
     12// Last Modified On : Wed Dec  4 07:55:32 2019
     13// Update Count     : 11
    1414//
    1515
     
    3131        entry_queue{};
    3232        signal_stack{};
    33         owner         = NULL;
     33        owner         = 0p;
    3434        recursion     = 0;
    35         mask.accepted = NULL;
    36         mask.data     = NULL;
     35        mask.accepted = 0p;
     36        mask.data     = 0p;
    3737        mask.size     = 0;
    38         dtor_node     = NULL;
     38        dtor_node     = 0p;
    3939}
     40
     41static inline void ^?{}(monitor_desc & ) {}
    4042
    4143struct monitor_guard_t {
     
    120122
    121123static inline void ?{}( condition & this ) {
    122         this.monitors = NULL;
     124        this.monitors = 0p;
    123125        this.monitor_count = 0;
    124126}
  • libcfa/src/concurrency/mutex.cfa

    r807a632 r3b56166  
    1111// Author           : Thierry Delisle
    1212// Created On       : Fri May 25 01:37:11 2018
    13 // Last Modified By : Thierry Delisle
    14 // Last Modified On : Fri May 25 01:37:51 2018
    15 // Update Count     : 0
     13// Last Modified By : Peter A. Buhr
     14// Last Modified On : Wed Dec  4 09:16:39 2019
     15// Update Count     : 1
    1616//
    1717
     
    7373        this.lock{};
    7474        this.blocked_threads{};
    75         this.owner = NULL;
     75        this.owner = 0p;
    7676        this.recursion_count = 0;
    7777}
     
    8383void lock(recursive_mutex_lock & this) with(this) {
    8484        lock( lock __cfaabi_dbg_ctx2 );
    85         if( owner == NULL ) {
     85        if( owner == 0p ) {
    8686                owner = kernelTLS.this_thread;
    8787                recursion_count = 1;
     
    101101        bool ret = false;
    102102        lock( lock __cfaabi_dbg_ctx2 );
    103         if( owner == NULL ) {
     103        if( owner == 0p ) {
    104104                owner = kernelTLS.this_thread;
    105105                recursion_count = 1;
  • libcfa/src/concurrency/mutex.hfa

    r807a632 r3b56166  
    1111// Author           : Thierry Delisle
    1212// Created On       : Fri May 25 01:24:09 2018
    13 // Last Modified By : Thierry Delisle
    14 // Last Modified On : Fri May 25 01:24:12 2018
    15 // Update Count     : 0
     13// Last Modified By : Peter A. Buhr
     14// Last Modified On : Wed Dec  4 09:16:53 2019
     15// Update Count     : 1
    1616//
    1717
     
    110110
    111111        static inline void ?{}(lock_scope(L) & this) {
    112                 this.locks = NULL;
     112                this.locks = 0p;
    113113                this.count = 0;
    114114        }
  • libcfa/src/concurrency/preemption.cfa

    r807a632 r3b56166  
    1010// Created On       : Mon Jun 5 14:20:42 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jun  5 17:35:49 2018
    13 // Update Count     : 37
     12// Last Modified On : Thu Dec  5 16:34:05 2019
     13// Update Count     : 43
    1414//
    1515
     
    2424#include <string.h>
    2525#include <unistd.h>
     26#include <limits.h>                                                                             // PTHREAD_STACK_MIN
    2627}
    2728
     
    6465event_kernel_t * event_kernel;                        // kernel public handle to even kernel
    6566static pthread_t alarm_thread;                        // pthread handle to alarm thread
     67static void * alarm_stack;                                                        // pthread stack for alarm thread
    6668
    6769static void ?{}(event_kernel_t & this) with( this ) {
     
    8183// Get next expired node
    8284static inline alarm_node_t * get_expired( alarm_list_t * alarms, Time currtime ) {
    83         if( !alarms->head ) return NULL;                          // If no alarms return null
    84         if( alarms->head->alarm >= currtime ) return NULL;        // If alarms head not expired return null
    85         return pop(alarms);                                       // Otherwise just pop head
     85        if( !alarms->head ) return 0p;                                          // If no alarms return null
     86        if( alarms->head->alarm >= currtime ) return 0p;        // If alarms head not expired return null
     87        return pop(alarms);                                                                     // Otherwise just pop head
    8688}
    8789
    8890// Tick one frame of the Discrete Event Simulation for alarms
    8991static void tick_preemption() {
    90         alarm_node_t * node = NULL;                     // Used in the while loop but cannot be declared in the while condition
    91         alarm_list_t * alarms = &event_kernel->alarms;  // Local copy for ease of reading
    92         Time currtime = __kernel_get_time();                    // Check current time once so we everything "happens at once"
     92        alarm_node_t * node = 0p;                                                       // Used in the while loop but cannot be declared in the while condition
     93        alarm_list_t * alarms = &event_kernel->alarms;          // Local copy for ease of reading
     94        Time currtime = __kernel_get_time();                            // Check current time once so everything "happens at once"
    9395
    9496        //Loop throught every thing expired
     
    243245        sigaddset( &mask, sig );
    244246
    245         if ( pthread_sigmask( SIG_UNBLOCK, &mask, NULL ) == -1 ) {
     247        if ( pthread_sigmask( SIG_UNBLOCK, &mask, 0p ) == -1 ) {
    246248            abort( "internal error, pthread_sigmask" );
    247249        }
     
    254256        sigaddset( &mask, sig );
    255257
    256         if ( pthread_sigmask( SIG_BLOCK, &mask, NULL ) == -1 ) {
     258        if ( pthread_sigmask( SIG_BLOCK, &mask, 0p ) == -1 ) {
    257259            abort( "internal error, pthread_sigmask" );
    258260        }
     
    301303
    302304        // Setup proper signal handlers
    303         __cfaabi_sigaction( SIGUSR1, sigHandler_ctxSwitch, SA_SIGINFO | SA_RESTART );         // CtxSwitch handler
     305        __cfaabi_sigaction( SIGUSR1, sigHandler_ctxSwitch, SA_SIGINFO | SA_RESTART ); // CtxSwitch handler
    304306
    305307        signal_block( SIGALRM );
    306308
    307         pthread_create( &alarm_thread, NULL, alarm_loop, NULL );
     309        alarm_stack = create_pthread( &alarm_thread, alarm_loop, 0p );
    308310}
    309311
     
    316318        sigset_t mask;
    317319        sigfillset( &mask );
    318         sigprocmask( SIG_BLOCK, &mask, NULL );
     320        sigprocmask( SIG_BLOCK, &mask, 0p );
    319321
    320322        // Notify the alarm thread of the shutdown
     
    323325
    324326        // Wait for the preemption thread to finish
    325         pthread_join( alarm_thread, NULL );
     327
     328        pthread_join( alarm_thread, 0p );
     329        free( alarm_stack );
    326330
    327331        // Preemption is now fully stopped
     
    380384        static_assert( sizeof( sigset_t ) == sizeof( cxt->uc_sigmask ), "Expected cxt->uc_sigmask to be of sigset_t" );
    381385        #endif
    382         if ( pthread_sigmask( SIG_SETMASK, (sigset_t *)&(cxt->uc_sigmask), NULL ) == -1 ) {
     386        if ( pthread_sigmask( SIG_SETMASK, (sigset_t *)&(cxt->uc_sigmask), 0p ) == -1 ) {
    383387                abort( "internal error, sigprocmask" );
    384388        }
     
    399403        sigset_t mask;
    400404        sigfillset(&mask);
    401         if ( pthread_sigmask( SIG_BLOCK, &mask, NULL ) == -1 ) {
     405        if ( pthread_sigmask( SIG_BLOCK, &mask, 0p ) == -1 ) {
    402406            abort( "internal error, pthread_sigmask" );
    403407        }
     
    420424                                        {__cfaabi_dbg_print_buffer_decl( " KERNEL: Spurious wakeup %d.\n", err );}
    421425                                        continue;
    422                         case EINVAL :
     426                                case EINVAL :
    423427                                        abort( "Timeout was invalid." );
    424428                                default:
     
    453457EXIT:
    454458        __cfaabi_dbg_print_safe( "Kernel : Preemption thread stopping\n" );
    455         return NULL;
     459        return 0p;
    456460}
    457461
     
    466470        sigset_t oldset;
    467471        int ret;
    468         ret = pthread_sigmask(0, NULL, &oldset);
     472        ret = pthread_sigmask(0, 0p, &oldset);
    469473        if(ret != 0) { abort("ERROR sigprocmask returned %d", ret); }
    470474
  • libcfa/src/concurrency/thread.cfa

    r807a632 r3b56166  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 30 17:19:52 2018
    13 // Update Count     : 8
     12// Last Modified On : Wed Dec  4 09:17:49 2019
     13// Update Count     : 9
    1414//
    1515
     
    3333// Thread ctors and dtors
    3434void ?{}(thread_desc & this, const char * const name, cluster & cl, void * storage, size_t storageSize ) with( this ) {
    35         context{ NULL, NULL };
     35        context{ 0p, 0p };
    3636        self_cor{ name, storage, storageSize };
    3737        state = Start;
     
    4141        self_mon_p = &self_mon;
    4242        curr_cluster = &cl;
    43         next = NULL;
     43        next = 0p;
    4444
    45         node.next = NULL;
    46         node.prev = NULL;
     45        node.next = 0p;
     46        node.prev = 0p;
    4747        doregister(curr_cluster, this);
    4848
     
    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

    r807a632 r3b56166  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jun 21 17:51:33 2019
    13 // Update Count     : 5
     12// Last Modified On : Wed Dec  4 09:18:14 2019
     13// Update Count     : 6
    1414//
    1515
     
    5454
    5555forall( dtype T | is_thread(T) )
    56 void __thrd_start( T & this );
     56void __thrd_start( T & this, void (*)(T &) );
    5757
    5858//-----------------------------------------------------------------------------
     
    6161void ^?{}(thread_desc & this);
    6262
    63 static inline void ?{}(thread_desc & this)                                                                  { this{ "Anonymous Thread", *mainCluster, NULL, 65000 }; }
    64 static inline void ?{}(thread_desc & this, size_t stackSize )                                               { this{ "Anonymous Thread", *mainCluster, NULL, stackSize }; }
     63static inline void ?{}(thread_desc & this)                                                                  { this{ "Anonymous Thread", *mainCluster, 0p, 65000 }; }
     64static inline void ?{}(thread_desc & this, size_t stackSize )                                               { this{ "Anonymous Thread", *mainCluster, 0p, stackSize }; }
    6565static inline void ?{}(thread_desc & this, void * storage, size_t storageSize )                             { this{ "Anonymous Thread", *mainCluster, storage, storageSize }; }
    66 static inline void ?{}(thread_desc & this, struct cluster & cl )                                            { this{ "Anonymous Thread", cl, NULL, 65000 }; }
    67 static inline void ?{}(thread_desc & this, struct cluster & cl, size_t stackSize )                          { this{ "Anonymous Thread", cl, NULL, stackSize }; }
     66static inline void ?{}(thread_desc & this, struct cluster & cl )                                            { this{ "Anonymous Thread", cl, 0p, 65000 }; }
     67static inline void ?{}(thread_desc & this, struct cluster & cl, size_t stackSize )                          { this{ "Anonymous Thread", cl, 0p, stackSize }; }
    6868static inline void ?{}(thread_desc & this, struct cluster & cl, void * storage, size_t storageSize )        { this{ "Anonymous Thread", cl, storage, storageSize }; }
    69 static inline void ?{}(thread_desc & this, const char * const name)                                         { this{ name, *mainCluster, NULL, 65000 }; }
    70 static inline void ?{}(thread_desc & this, const char * const name, struct cluster & cl )                   { this{ name, cl, NULL, 65000 }; }
    71 static inline void ?{}(thread_desc & this, const char * const name, struct cluster & cl, size_t stackSize ) { this{ name, cl, NULL, stackSize }; }
     69static inline void ?{}(thread_desc & this, const char * const name)                                         { this{ name, *mainCluster, 0p, 65000 }; }
     70static inline void ?{}(thread_desc & this, const char * const name, struct cluster & cl )                   { this{ name, cl, 0p, 65000 }; }
     71static inline void ?{}(thread_desc & this, const char * const name, struct cluster & cl, size_t stackSize ) { this{ name, cl, 0p, stackSize }; }
    7272
    7373//-----------------------------------------------------------------------------
  • libcfa/src/exception.c

    r807a632 r3b56166  
    6969
    7070
    71 // This macro should be the only thing that needs to change across machines.  Used in the personality function, way down
    72 // in termination.
     71// This macro should be the only thing that needs to change across machines.
     72// Used in the personality function, way down in termination.
    7373// struct _Unwind_Context * -> _Unwind_Reason_Code(*)(exception_t *)
    7474#define MATCHER_FROM_CONTEXT(ptr_to_context) \
     
    102102}
    103103
    104 // Do we control where exceptions get thrown even with concurency?  If not these are not quite thread safe, the cleanup
    105 // hook has to be added after the node is built but before it is made the top node.
     104// Do we control where exceptions get thrown even with concurency?
     105// If not these are not quite thread safe, the cleanup hook has to
     106// be added after the node is built but before it is made the top node.
    106107
    107108void __cfaabi_ehm__try_resume_setup(struct __cfaabi_ehm__try_resume_node * node,
     
    212213        _Unwind_Reason_Code ret = _Unwind_RaiseException( &this_exception_storage );
    213214
    214         // If we reach here it means something happened.  For resumption to work we need to find a way to return back to
    215         // here.  Most of them will probably boil down to setting a global flag and making the phase 1 either stop or
    216         // fail.  Causing an error on purpose may help avoiding unnecessary work but it might have some weird side
    217         // effects.  If we just pretend no handler was found that would work but may be expensive for no reason since we
    218         // will always search the whole stack.
     215        // If we reach here it means something happened. For resumption to work we need to find a way
     216        // to return back to here. Most of them will probably boil down to setting a global flag and
     217        // making the phase 1 either stop or fail. Causing an error on purpose may help avoiding
     218        // unnecessary work but it might have some weird side effects. If we just pretend no handler
     219        // was found that would work but may be expensive for no reason since we will always search
     220        // the whole stack.
    219221
    220222        if( ret == _URC_END_OF_STACK ) {
    221                 // No proper handler was found.  This can be handled in several way.  C++ calls std::terminate Here we
    222                 // force unwind the stack, basically raising a cancellation.
     223                // No proper handler was found. This can be handled in many ways, C++ calls std::terminate.
     224                // Here we force unwind the stack, basically raising a cancellation.
    223225                printf("Uncaught exception %p\n", &this_exception_storage);
    224226
     
    228230        }
    229231
    230         // We did not simply reach the end of the stack without finding a handler.  Something wen't wrong
     232        // We did not simply reach the end of the stack without finding a handler. This is an error.
    231233        printf("UNWIND ERROR %d after raise exception\n", ret);
    232234        abort();
     
    254256        abort();
    255257}
    256 #else
    257 // This is our personality routine.  For every stack frame anotated with ".cfi_personality 0x3,__gcfa_personality_v0".
    258 // This function will be called twice when unwinding.  Once in the search phased and once in the cleanup phase.
     258#else // PIC
     259// This is our personality routine. For every stack frame annotated with
     260// ".cfi_personality 0x3,__gcfa_personality_v0" this function will be called twice when unwinding.
     261//  Once in the search phase and once in the cleanup phase.
    259262_Unwind_Reason_Code __gcfa_personality_v0 (
    260263                int version, _Unwind_Action actions, unsigned long long exceptionClass,
     
    264267
    265268        //__cfaabi_dbg_print_safe("CFA: 0x%lx\n", _Unwind_GetCFA(context));
    266         __cfaabi_dbg_print_safe("Personality function (%d, %x, %llu, %p, %p):", version, actions, exceptionClass, unwind_exception, context);
     269        __cfaabi_dbg_print_safe("Personality function (%d, %x, %llu, %p, %p):",
     270                        version, actions, exceptionClass, unwind_exception, context);
    267271
    268272        // If we've reached the end of the stack then there is nothing much we can do...
     
    291295        // Get the instuction pointer and a reading pointer into the exception table
    292296        lsda_header_info lsd_info;
    293         const unsigned char * cur_ptr = parse_lsda_header( context, lsd, &lsd_info);
     297        const unsigned char * cur_ptr = parse_lsda_header(context, lsd, &lsd_info);
    294298        _Unwind_Ptr instruction_ptr = _Unwind_GetIP( context );
    295299
     
    302306
    303307                // Decode the common stuff we have in here
    304                 cur_ptr = read_encoded_value (0, lsd_info.call_site_encoding, cur_ptr, &callsite_start);
    305                 cur_ptr = read_encoded_value (0, lsd_info.call_site_encoding, cur_ptr, &callsite_len);
    306                 cur_ptr = read_encoded_value (0, lsd_info.call_site_encoding, cur_ptr, &callsite_landing_pad);
    307                 cur_ptr = read_uleb128 (cur_ptr, &callsite_action);
     308                cur_ptr = read_encoded_value(0, lsd_info.call_site_encoding, cur_ptr, &callsite_start);
     309                cur_ptr = read_encoded_value(0, lsd_info.call_site_encoding, cur_ptr, &callsite_len);
     310                cur_ptr = read_encoded_value(0, lsd_info.call_site_encoding, cur_ptr, &callsite_landing_pad);
     311                cur_ptr = read_uleb128(cur_ptr, &callsite_action);
    308312
    309313                // Have we reach the correct frame info yet?
     
    316320                        void * ep = (void*)lsd_info.Start + callsite_start + callsite_len;
    317321                        void * ip = (void*)instruction_ptr;
    318                         __cfaabi_dbg_print_safe("\nfound %p - %p (%p, %p, %p), looking for %p\n", bp, ep, ls, cs, cl, ip);
     322                        __cfaabi_dbg_print_safe("\nfound %p - %p (%p, %p, %p), looking for %p\n",
     323                                        bp, ep, ls, cs, cl, ip);
    319324#endif // __CFA_DEBUG_PRINT__
    320325                        continue;
    321326                }
    322327
    323                 // Have we gone too far
     328                // Have we gone too far?
    324329                if( lsd_info.Start + callsite_start > instruction_ptr ) {
    325330                        printf(" gone too far");
     
    331336                        // Which phase are we in
    332337                        if (actions & _UA_SEARCH_PHASE) {
    333                                 // Search phase, this means we probably found a potential handler and must check if it is a match
    334 
    335                                 // If we have arbitrarily decided that 0 means nothing to do and 1 means there is a potential handler
    336                                 // This doesn't seem to conflict the gcc default behavior
     338                                // In search phase, these means we found a potential handler we must check.
     339
     340                                // We have arbitrarily decided that 0 means nothing to do and 1 means there is
     341                                // a potential handler. This doesn't seem to conflict the gcc default behavior.
    337342                                if (callsite_action != 0) {
    338343                                        // Now we want to run some code to see if the handler matches
     
    351356                                        // The current apprach uses one exception table entry per try block
    352357                                        _uleb128_t imatcher;
    353                                         // Get the relative offset to the
    354                                         cur_ptr = read_uleb128 (cur_ptr, &imatcher);
    355 
    356                                         // Get a function pointer from the relative offset and call it
    357                                         // _Unwind_Reason_Code (*matcher)() = (_Unwind_Reason_Code (*)())lsd_info.LPStart + imatcher;
     358                                        // Get the relative offset to the {...}?
     359                                        cur_ptr = read_uleb128(cur_ptr, &imatcher);
    358360
    359361                                        _Unwind_Reason_Code (*matcher)(exception_t *) =
     
    414416}
    415417
    416 // Try statements are hoisted out see comments for details.  With this could probably be unique and simply linked from
    417 // libcfa but there is one problem left, see the exception table for details
     418// Try statements are hoisted out see comments for details. While this could probably be unique
     419// and simply linked from libcfa but there is one problem left, see the exception table for details
    418420__attribute__((noinline))
    419421void __cfaabi_ehm__try_terminate(void (*try_block)(),
     
    428430        // assembly works.
    429431
    430         // Setup the personality routine
     432        // Setup the personality routine and exception table.
    431433        asm volatile (".cfi_personality 0x3,__gcfa_personality_v0");
    432         // Setup the exception table
    433434        asm volatile (".cfi_lsda 0x3, .LLSDACFA2");
    434435
     
    442443        asm volatile goto ("" : : : : CATCH );
    443444
    444         // Normal return
     445        // Normal return for when there is no throw.
    445446        return;
    446447
     
    459460}
    460461
    461 // Exception table data we need to generate.  While this is almost generic, the custom data refers to foo_try_match try
    462 // match, which is no way generic.  Some more works need to be done if we want to have a single call to the try routine.
     462// Exception table data we need to generate. While this is almost generic, the custom data refers
     463// to {*}try_terminate, which is no way generic. Some more works need to be done if we want to
     464// have a single call to the try routine.
    463465
    464466#if defined( __i386 ) || defined( __x86_64 )
    465467asm (
    466         //HEADER
     468        // HEADER
    467469        ".LFECFA1:\n"
    468470        "       .globl  __gcfa_personality_v0\n"
    469471        "       .section        .gcc_except_table,\"a\",@progbits\n"
    470         ".LLSDACFA2:\n"                                                 //TABLE header
     472        // TABLE HEADER (important field is the BODY length at the end)
     473        ".LLSDACFA2:\n"
    471474        "       .byte   0xff\n"
    472475        "       .byte   0xff\n"
    473476        "       .byte   0x1\n"
    474         "       .uleb128 .LLSDACSECFA2-.LLSDACSBCFA2\n"         // BODY length
    475         // Body uses language specific data and therefore could be modified arbitrarily
    476         ".LLSDACSBCFA2:\n"                                              // BODY start
    477         "       .uleb128 .TRYSTART-__cfaabi_ehm__try_terminate\n"               // Handled area start  (relative to start of function)
    478         "       .uleb128 .TRYEND-.TRYSTART\n"                           // Handled area length
    479         "       .uleb128 .CATCH-__cfaabi_ehm__try_terminate\n"                          // Hanlder landing pad adress  (relative to start of function)
    480         "       .uleb128 1\n"                                           // Action code, gcc seems to use always 0
    481         ".LLSDACSECFA2:\n"                                              // BODY end
    482         "       .text\n"                                                        // TABLE footer
     477        "       .uleb128 .LLSDACSECFA2-.LLSDACSBCFA2\n"
     478        // BODY (language specific data)
     479        ".LLSDACSBCFA2:\n"
     480        //      Handled area start (relative to start of function)
     481        "       .uleb128 .TRYSTART-__cfaabi_ehm__try_terminate\n"
     482        //      Handled area length
     483        "       .uleb128 .TRYEND-.TRYSTART\n"
     484        //      Handler landing pad address (relative to start of function)
     485        "       .uleb128 .CATCH-__cfaabi_ehm__try_terminate\n"
     486        //      Action code, gcc seems to always use 0.
     487        "       .uleb128 1\n"
     488        // TABLE FOOTER
     489        ".LLSDACSECFA2:\n"
     490        "       .text\n"
    483491        "       .size   __cfaabi_ehm__try_terminate, .-__cfaabi_ehm__try_terminate\n"
    484492        "       .ident  \"GCC: (Ubuntu 6.2.0-3ubuntu11~16.04) 6.2.0 20160901\"\n"
     
    486494);
    487495#endif // __i386 || __x86_64
    488 #endif //PIC
     496#endif // PIC
  • libcfa/src/executor.cfa

    r807a632 r3b56166  
    88#include <stdio.h>
    99
    10 forall( otype T | is_node(T) | is_monitor(T) ) {
    11     monitor Buffer {                                    // unbounded buffer
    12         __queue_t( T ) queue;                           // unbounded list of work requests
    13         condition delay;
    14     }; // Buffer
    15 
     10forall( dtype T )
     11monitor Buffer {                                        // unbounded buffer
     12    __queue_t( T ) queue;                               // unbounded list of work requests
     13    condition delay;
     14}; // Buffer
     15forall( dtype T | is_node(T) ) {
    1616    void insert( Buffer( T ) & mutex buf, T * elem ) with(buf) {
    1717        append( queue, elem );                          // insert element into buffer
     
    2020
    2121    T * remove( Buffer( T ) & mutex buf ) with(buf) {
    22         if ( ! queue ) wait( delay );                   // no request to process ? => wait
    23         return pop_head( queue );
     22        if ( queue.head != 0 ) wait( delay );                   // no request to process ? => wait
     23//      return pop_head( queue );
    2424    } // remove
    2525} // distribution
  • libcfa/src/fstream.cfa

    r807a632 r3b56166  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Sep 10 22:19:56 2019
    13 // Update Count     : 354
     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} // ?{}
    6767
    68 void sepOn( ofstream & os ) { os.sepOnOff = ! getNL( os ); }
    69 void sepOff( ofstream & os ) { os.sepOnOff = false; }
     68void ^?{}( ofstream & os ) {
     69        close( os );
     70} // ^?{}
     71
     72void sepOn( ofstream & os ) { os.$sepOnOff = ! $getNL( os ); }
     73void sepOff( ofstream & os ) { os.$sepOnOff = false; }
    7074
    7175bool sepDisable( ofstream & os ) {
    72         bool temp = os.sepDefault;
    73         os.sepDefault = false;
    74         sepReset( os );
     76        bool temp = os.$sepDefault;
     77        os.$sepDefault = false;
     78        $sepReset( os );
    7579        return temp;
    7680} // sepDisable
    7781
    7882bool sepEnable( ofstream & os ) {
    79         bool temp = os.sepDefault;
    80         os.sepDefault = true;
    81         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 ?
    8286        return temp;
    8387} // sepEnable
    8488
    85 void nlOn( ofstream & os ) { os.nlOnOff = true; }
    86 void nlOff( ofstream & os ) { os.nlOnOff = false; }
    87 
    88 const char * sepGet( ofstream & os ) { return os.separator; }
    89 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[] ) {
    9094        assert( s );
    91         strncpy( os.separator, s, sepSize - 1 );
    92         os.separator[sepSize - 1] = '\0';
     95        strncpy( os.$separator, s, sepSize - 1 );
     96        os.$separator[sepSize - 1] = '\0';
    9397} // sepSet
    9498
    95 const char * sepGetTuple( ofstream & os ) { return os.tupleSeparator; }
    96 void sepSetTuple( ofstream & os, const char * s ) {
     99const char * sepGetTuple( ofstream & os ) { return os.$tupleSeparator; }
     100void sepSetTuple( ofstream & os, const char s[] ) {
    97101        assert( s );
    98         strncpy( os.tupleSeparator, s, sepSize - 1 );
    99         os.tupleSeparator[sepSize - 1] = '\0';
     102        strncpy( os.$tupleSeparator, s, sepSize - 1 );
     103        os.$tupleSeparator[sepSize - 1] = '\0';
    100104} // sepSet
    101105
    102106void ends( ofstream & os ) {
    103         if ( getANL( os ) ) nl( os );
    104         else setPrt( os, false );                                                       // turn off
     107        if ( $getANL( os ) ) nl( os );
     108        else $setPrt( os, false );                                                      // turn off
    105109        if ( &os == &exit ) exit( EXIT_FAILURE );
    106110        if ( &os == &abort ) abort();
     
    108112
    109113int fail( ofstream & os ) {
    110         return os.file == 0 || ferror( (FILE *)(os.file) );
     114        return os.$file == 0 || ferror( (FILE *)(os.$file) );
    111115} // fail
    112116
    113117int flush( ofstream & os ) {
    114         return fflush( (FILE *)(os.file) );
     118        return fflush( (FILE *)(os.$file) );
    115119} // flush
    116120
    117 void open( ofstream & os, const char * name, const char * mode ) {
     121void open( ofstream & os, const char name[], const char mode[] ) {
    118122        FILE * file = fopen( name, mode );
    119123        #ifdef __CFA_DEBUG__
    120         if ( file == 0 ) {
     124        if ( file == 0p ) {
    121125                abort | IO_MSG "open output file \"" | name | "\"" | nl | strerror( errno );
    122126        } // if
     
    125129} // open
    126130
    127 void open( ofstream & os, const char * name ) {
     131void open( ofstream & os, const char name[] ) {
    128132        open( os, name, "w" );
    129133} // open
    130134
    131135void close( ofstream & os ) {
    132         if ( (FILE *)(os.file) == stdout || (FILE *)(os.file) == stderr ) return;
    133 
    134         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 ) {
    135139                abort | IO_MSG "close output" | nl | strerror( errno );
    136140        } // if
    137141} // close
    138142
    139 ofstream & write( ofstream & os, const char * data, size_t size ) {
     143ofstream & write( ofstream & os, const char data[], size_t size ) {
    140144        if ( fail( os ) ) {
    141145                abort | IO_MSG "attempt write I/O on failed stream";
    142146        } // if
    143147
    144         if ( fwrite( data, 1, size, (FILE *)(os.file) ) != size ) {
     148        if ( fwrite( data, 1, size, (FILE *)(os.$file) ) != size ) {
    145149                abort | IO_MSG "write" | nl | strerror( errno );
    146150        } // if
     
    151155        va_list args;
    152156        va_start( args, format );
    153         int len = vfprintf( (FILE *)(os.file), format, args );
     157        int len = vfprintf( (FILE *)(os.$file), format, args );
    154158        if ( len == EOF ) {
    155                 if ( ferror( (FILE *)(os.file) ) ) {
     159                if ( ferror( (FILE *)(os.$file) ) ) {
    156160                        abort | IO_MSG "invalid write";
    157161                } // if
     
    159163        va_end( args );
    160164
    161         setPrt( os, true );                                                                     // called in output cascade
    162         sepReset( os );                                                                         // reset separator
     165        $setPrt( os, true );                                                            // called in output cascade
     166        $sepReset( os );                                                                        // reset separator
    163167        return len;
    164168} // fmt
     
    180184// private
    181185void ?{}( ifstream & is, void * file ) {
    182         is.file = file;
    183         is.nlOnOff = false;
     186        is.$file = file;
     187        is.$nlOnOff = false;
    184188} // ?{}
    185189
    186190// public
    187 void ?{}( ifstream & is ) {     is.file = 0; }
    188 
    189 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[] ) {
    190194        open( is, name, mode );
    191195} // ?{}
    192196
    193 void ?{}( ifstream & is, const char * name ) {
     197void ?{}( ifstream & is, const char name[] ) {
    194198        open( is, name, "r" );
    195199} // ?{}
    196200
    197 void nlOn( ifstream & os ) { os.nlOnOff = true; }
    198 void nlOff( ifstream & os ) { os.nlOnOff = false; }
    199 bool getANL( ifstream & os ) { return os.nlOnOff; }
     201void ^?{}( ifstream & is ) {
     202        close( is );
     203} // ^?{}
     204
     205void nlOn( ifstream & os ) { os.$nlOnOff = true; }
     206void nlOff( ifstream & os ) { os.$nlOnOff = false; }
     207bool getANL( ifstream & os ) { return os.$nlOnOff; }
    200208
    201209int fail( ifstream & is ) {
    202         return is.file == 0 || ferror( (FILE *)(is.file) );
     210        return is.$file == 0p || ferror( (FILE *)(is.$file) );
    203211} // fail
    204212
    205213int eof( ifstream & is ) {
    206         return feof( (FILE *)(is.file) );
     214        return feof( (FILE *)(is.$file) );
    207215} // eof
    208216
    209 void open( ifstream & is, const char * name, const char * mode ) {
     217void open( ifstream & is, const char name[], const char mode[] ) {
    210218        FILE * file = fopen( name, mode );
    211219        #ifdef __CFA_DEBUG__
    212         if ( file == 0 ) {
     220        if ( file == 0p ) {
    213221                abort | IO_MSG "open input file \"" | name | "\"" | nl | strerror( errno );
    214222        } // if
    215223        #endif // __CFA_DEBUG__
    216         is.file = file;
    217 } // open
    218 
    219 void open( ifstream & is, const char * name ) {
     224        is.$file = file;
     225} // open
     226
     227void open( ifstream & is, const char name[] ) {
    220228        open( is, name, "r" );
    221229} // open
    222230
    223231void close( ifstream & is ) {
    224         if ( (FILE *)(is.file) == stdin ) return;
    225 
    226         if ( fclose( (FILE *)(is.file) ) == EOF ) {
     232        if ( (FILE *)(is.$file) == stdin ) return;
     233
     234        if ( fclose( (FILE *)(is.$file) ) == EOF ) {
    227235                abort | IO_MSG "close input" | nl | strerror( errno );
    228236        } // if
     
    234242        } // if
    235243
    236         if ( fread( data, size, 1, (FILE *)(is.file) ) == 0 ) {
     244        if ( fread( data, size, 1, (FILE *)(is.$file) ) == 0 ) {
    237245                abort | IO_MSG "read" | nl | strerror( errno );
    238246        } // if
     
    245253        } // if
    246254
    247         if ( ungetc( c, (FILE *)(is.file) ) == EOF ) {
     255        if ( ungetc( c, (FILE *)(is.$file) ) == EOF ) {
    248256                abort | IO_MSG "ungetc" | nl | strerror( errno );
    249257        } // if
     
    255263
    256264        va_start( args, format );
    257         int len = vfscanf( (FILE *)(is.file), format, args );
     265        int len = vfscanf( (FILE *)(is.$file), format, args );
    258266        if ( len == EOF ) {
    259                 if ( ferror( (FILE *)(is.file) ) ) {
     267                if ( ferror( (FILE *)(is.$file) ) ) {
    260268                        abort | IO_MSG "invalid read";
    261269                } // if
  • libcfa/src/fstream.hfa

    r807a632 r3b56166  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jul 15 18:10:23 2019
    13 // Update Count     : 167
     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[] );
     74void ^?{}( ofstream & os );
    7475
    7576extern ofstream & sout, & stdout, & serr, & stderr;             // aliases
     
    8182
    8283struct ifstream {
    83         void * file;
    84         bool nlOnOff;
     84        void * $file;
     85        bool $nlOnOff;
    8586}; // ifstream
    8687
     
    9192int fail( ifstream & is );
    9293int eof( ifstream & is );
    93 void open( ifstream & is, const char * name, const char * mode );
    94 void open( ifstream & is, const char * name );
     94void open( ifstream & is, const char name[], const char mode[] );
     95void open( ifstream & is, const char name[] );
    9596void close( ifstream & is );
    9697ifstream & read( ifstream & is, char * data, size_t size );
     
    99100
    100101void ?{}( ifstream & is );
    101 void ?{}( ifstream & is, const char * name, const char * mode );
    102 void ?{}( ifstream & is, const char * name );
     102void ?{}( ifstream & is, const char name[], const char mode[] );
     103void ?{}( ifstream & is, const char name[] );
     104void ^?{}( ifstream & is );
    103105
    104106extern ifstream & sin, & stdin;                                                 // aliases
  • libcfa/src/gmp.hfa

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

    r807a632 r3b56166  
    1010// Created On       : Tue Dec 19 21:58:35 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Oct 18 07:42:09 2019
    13 // Update Count     : 556
     12// Last Modified On : Tue Feb  4 10:04:51 2020
     13// Update Count     : 648
    1414//
    1515
     
    1818#include <stdio.h>                                                                              // snprintf, fileno
    1919#include <errno.h>                                                                              // errno
     20#include <string.h>                                                                             // memset, memcpy
    2021extern "C" {
    2122#include <sys/mman.h>                                                                   // mmap, munmap
     
    2728#include "bits/locks.hfa"                                                               // __spinlock_t
    2829#include "startup.hfa"                                                                  // STARTUP_PRIORITY_MEMORY
    29 #include "stdlib.hfa"                                                                   // bsearchl
     30//#include "stdlib.hfa"                                                                 // bsearchl
    3031#include "malloc.h"
    3132
     33#define MIN(x, y) (y > x ? x : y)
    3234
    3335static bool traceHeap = false;
    3436
    35 inline bool traceHeap() {
    36         return traceHeap;
    37 } // traceHeap
     37inline bool traceHeap() { return traceHeap; }
    3838
    3939bool traceHeapOn() {
     
    4949} // traceHeapOff
    5050
    51 
    52 static bool checkFree = false;
    53 
    54 inline bool checkFree() {
    55         return checkFree;
    56 } // checkFree
    57 
    58 bool checkFreeOn() {
    59         bool temp = checkFree;
    60         checkFree = true;
     51bool traceHeapTerm() { return false; }
     52
     53
     54static bool prtFree = false;
     55
     56inline bool prtFree() {
     57        return prtFree;
     58} // prtFree
     59
     60bool prtFreeOn() {
     61        bool temp = prtFree;
     62        prtFree = true;
    6163        return temp;
    62 } // checkFreeOn
    63 
    64 bool checkFreeOff() {
    65         bool temp = checkFree;
    66         checkFree = false;
     64} // prtFreeOn
     65
     66bool prtFreeOff() {
     67        bool temp = prtFree;
     68        prtFree = false;
    6769        return temp;
    68 } // checkFreeOff
    69 
    70 
    71 // static bool traceHeapTerm = false;
    72 
    73 // inline bool traceHeapTerm() {
    74 //      return traceHeapTerm;
    75 // } // traceHeapTerm
    76 
    77 // bool traceHeapTermOn() {
    78 //      bool temp = traceHeapTerm;
    79 //      traceHeapTerm = true;
    80 //      return temp;
    81 // } // traceHeapTermOn
    82 
    83 // bool traceHeapTermOff() {
    84 //      bool temp = traceHeapTerm;
    85 //      traceHeapTerm = false;
    86 //      return temp;
    87 // } // traceHeapTermOff
     70} // prtFreeOff
    8871
    8972
    9073enum {
     74        // Define the default extension heap amount in units of bytes. When the uC++ supplied heap reaches the brk address,
     75        // the brk address is extended by the extension amount.
     76        __CFA_DEFAULT_HEAP_EXPANSION__ = (1 * 1024 * 1024),
     77
     78        // Define the mmap crossover point during allocation. Allocations less than this amount are allocated from buckets;
     79        // values greater than or equal to this value are mmap from the operating system.
    9180        __CFA_DEFAULT_MMAP_START__ = (512 * 1024 + 1),
    92         __CFA_DEFAULT_HEAP_EXPANSION__ = (1 * 1024 * 1024),
    9381};
    9482
     
    10593static unsigned int allocFree;                                                  // running total of allocations minus frees
    10694
    107 static void checkUnfreed() {
     95static void prtUnfreed() {
    10896        if ( allocFree != 0 ) {
    10997                // DO NOT USE STREAMS AS THEY MAY BE UNAVAILABLE AT THIS POINT.
    110                 // char helpText[512];
    111                 // int len = snprintf( helpText, sizeof(helpText), "CFA warning (UNIX pid:%ld) : program terminating with %u(0x%x) bytes of storage allocated but not freed.\n"
    112                 //                                      "Possible cause is unfreed storage allocated by the program or system/library routines called from the program.\n",
    113                 //                                      (long int)getpid(), allocFree, allocFree ); // always print the UNIX pid
    114                 // __cfaabi_dbg_bits_write( helpText, len );
    115         } // if
    116 } // checkUnfreed
     98                char helpText[512];
     99                int len = snprintf( helpText, sizeof(helpText), "CFA warning (UNIX pid:%ld) : program terminating with %u(0x%x) bytes of storage allocated but not freed.\n"
     100                                                        "Possible cause is unfreed storage allocated by the program or system/library routines called from the program.\n",
     101                                                        (long int)getpid(), allocFree, allocFree ); // always print the UNIX pid
     102                __cfaabi_bits_write( STDERR_FILENO, helpText, len ); // print debug/nodebug
     103        } // if
     104} // prtUnfreed
    117105
    118106extern "C" {
     
    123111        void heapAppStop() {                                                            // called by __cfaabi_appready_startdown
    124112                fclose( stdin ); fclose( stdout );
    125                 checkUnfreed();
     113                prtUnfreed();
    126114        } // heapAppStop
    127115} // extern "C"
    128116#endif // __CFA_DEBUG__
     117
    129118
    130119// statically allocated variables => zero filled.
     
    134123static unsigned int maxBucketsUsed;                                             // maximum number of buckets in use
    135124
    136 
    137 // #comment TD : This defined is significantly different from the __ALIGN__ define from locks.hfa
    138 #define ALIGN 16
    139125
    140126#define SPINLOCK 0
     
    147133// Recursive definitions: HeapManager needs size of bucket array and bucket area needs sizeof HeapManager storage.
    148134// Break recusion by hardcoding number of buckets and statically checking number is correct after bucket array defined.
    149 enum { NoBucketSizes = 93 };                                                    // number of buckets sizes
     135enum { NoBucketSizes = 91 };                                                    // number of buckets sizes
    150136
    151137struct HeapManager {
     
    194180                        } kind; // Kind
    195181                } header; // Header
    196                 char pad[ALIGN - sizeof( Header )];
     182                char pad[libAlign() - sizeof( Header )];
    197183                char data[0];                                                                   // storage
    198184        }; // Storage
    199185
    200         static_assert( ALIGN >= sizeof( Storage ), "ALIGN < sizeof( Storage )" );
     186        static_assert( libAlign() >= sizeof( Storage ), "libAlign() < sizeof( Storage )" );
    201187
    202188        struct FreeHeader {
     
    228214#define __STATISTICS__
    229215
     216// Bucket size must be multiple of 16.
    230217// Powers of 2 are common allocation sizes, so make powers of 2 generate the minimum required size.
    231218static const unsigned int bucketSizes[] @= {                    // different bucket sizes
    232         16, 32, 48, 64,
    233         64 + sizeof(HeapManager.Storage), 96, 112, 128, 128 + sizeof(HeapManager.Storage), 160, 192, 224,
    234         256 + sizeof(HeapManager.Storage), 320, 384, 448, 512 + sizeof(HeapManager.Storage), 640, 768, 896,
    235         1_024 + sizeof(HeapManager.Storage), 1_536, 2_048 + sizeof(HeapManager.Storage), 2_560, 3_072, 3_584, 4_096 + sizeof(HeapManager.Storage), 6_144,
    236         8_192 + sizeof(HeapManager.Storage), 9_216, 10_240, 11_264, 12_288, 13_312, 14_336, 15_360,
    237         16_384 + sizeof(HeapManager.Storage), 18_432, 20_480, 22_528, 24_576, 26_624, 28_672, 30_720,
    238         32_768 + sizeof(HeapManager.Storage), 36_864, 40_960, 45_056, 49_152, 53_248, 57_344, 61_440,
    239         65_536 + sizeof(HeapManager.Storage), 73_728, 81_920, 90_112, 98_304, 106_496, 114_688, 122_880,
    240         131_072 + sizeof(HeapManager.Storage), 147_456, 163_840, 180_224, 196_608, 212_992, 229_376, 245_760,
    241         262_144 + sizeof(HeapManager.Storage), 294_912, 327_680, 360_448, 393_216, 425_984, 458_752, 491_520,
    242         524_288 + sizeof(HeapManager.Storage), 655_360, 786_432, 917_504, 1_048_576 + sizeof(HeapManager.Storage), 1_179_648, 1_310_720, 1_441_792,
    243         1_572_864, 1_703_936, 1_835_008, 1_966_080, 2_097_152 + sizeof(HeapManager.Storage), 2_621_440, 3_145_728, 3_670_016,
    244         4_194_304 + sizeof(HeapManager.Storage)
     219        16, 32, 48, 64 + sizeof(HeapManager.Storage), // 4
     220        96, 112, 128 + sizeof(HeapManager.Storage), // 3
     221        160, 192, 224, 256 + sizeof(HeapManager.Storage), // 4
     222        320, 384, 448, 512 + sizeof(HeapManager.Storage), // 4
     223        640, 768, 896, 1_024 + sizeof(HeapManager.Storage), // 4
     224        1_536, 2_048 + sizeof(HeapManager.Storage), // 2
     225        2_560, 3_072, 3_584, 4_096 + sizeof(HeapManager.Storage), // 4
     226        6_144, 8_192 + sizeof(HeapManager.Storage), // 2
     227        9_216, 10_240, 11_264, 12_288, 13_312, 14_336, 15_360, 16_384 + sizeof(HeapManager.Storage), // 8
     228        18_432, 20_480, 22_528, 24_576, 26_624, 28_672, 30_720, 32_768 + sizeof(HeapManager.Storage), // 8
     229        36_864, 40_960, 45_056, 49_152, 53_248, 57_344, 61_440, 65_536 + sizeof(HeapManager.Storage), // 8
     230        73_728, 81_920, 90_112, 98_304, 106_496, 114_688, 122_880, 131_072 + sizeof(HeapManager.Storage), // 8
     231        147_456, 163_840, 180_224, 196_608, 212_992, 229_376, 245_760, 262_144 + sizeof(HeapManager.Storage), // 8
     232        294_912, 327_680, 360_448, 393_216, 425_984, 458_752, 491_520, 524_288 + sizeof(HeapManager.Storage), // 8
     233        655_360, 786_432, 917_504, 1_048_576 + sizeof(HeapManager.Storage), // 4
     234        1_179_648, 1_310_720, 1_441_792, 1_572_864, 1_703_936, 1_835_008, 1_966_080, 2_097_152 + sizeof(HeapManager.Storage), // 8
     235        2_621_440, 3_145_728, 3_670_016, 4_194_304 + sizeof(HeapManager.Storage), // 4
    245236};
    246237
     
    251242static unsigned char lookup[LookupSizes];                               // O(1) lookup for small sizes
    252243#endif // FASTLOOKUP
     244
    253245static int mmapFd = -1;                                                                 // fake or actual fd for anonymous file
    254 
    255 
    256246#ifdef __CFA_DEBUG__
    257247static bool heapBoot = 0;                                                               // detect recursion during boot
     
    259249static HeapManager heapManager __attribute__(( aligned (128) )) @= {}; // size of cache line to prevent false sharing
    260250
    261 // #comment TD : The return type of this function should be commented
    262 static inline bool setMmapStart( size_t value ) {
    263   if ( value < pageSize || bucketSizes[NoBucketSizes - 1] < value ) return true;
    264         mmapStart = value;                                                                      // set global
    265 
    266         // find the closest bucket size less than or equal to the mmapStart size
    267         maxBucketsUsed = bsearchl( (unsigned int)mmapStart, bucketSizes, NoBucketSizes ); // binary search
    268         assert( maxBucketsUsed < NoBucketSizes );                       // subscript failure ?
    269         assert( mmapStart <= bucketSizes[maxBucketsUsed] ); // search failure ?
    270         return false;
    271 } // setMmapStart
    272 
    273 
    274 static void ?{}( HeapManager & manager ) with ( manager ) {
    275         pageSize = sysconf( _SC_PAGESIZE );
    276 
    277         for ( unsigned int i = 0; i < NoBucketSizes; i += 1 ) { // initialize the free lists
    278                 freeLists[i].blockSize = bucketSizes[i];
    279         } // for
    280 
    281         #ifdef FASTLOOKUP
    282         unsigned int idx = 0;
    283         for ( unsigned int i = 0; i < LookupSizes; i += 1 ) {
    284                 if ( i > bucketSizes[idx] ) idx += 1;
    285                 lookup[i] = idx;
    286         } // for
    287         #endif // FASTLOOKUP
    288 
    289         if ( setMmapStart( default_mmap_start() ) ) {
    290                 abort( "HeapManager : internal error, mmap start initialization failure." );
    291         } // if
    292         heapExpand = default_heap_expansion();
    293 
    294         char * End = (char *)sbrk( 0 );
    295         sbrk( (char *)libCeiling( (long unsigned int)End, libAlign() ) - End ); // move start of heap to multiple of alignment
    296         heapBegin = heapEnd = sbrk( 0 );                                        // get new start point
    297 } // HeapManager
    298 
    299 
    300 static void ^?{}( HeapManager & ) {
    301         #ifdef __STATISTICS__
    302         // if ( traceHeapTerm() ) {
    303         //      printStats();
    304         //      if ( checkfree() ) checkFree( heapManager, true );
    305         // } // if
    306         #endif // __STATISTICS__
    307 } // ~HeapManager
    308 
    309 
    310 static void memory_startup( void ) __attribute__(( constructor( STARTUP_PRIORITY_MEMORY ) ));
    311 void memory_startup( void ) {
    312         #ifdef __CFA_DEBUG__
    313         if ( unlikely( heapBoot ) ) {                                           // check for recursion during system boot
    314                 // DO NOT USE STREAMS AS THEY MAY BE UNAVAILABLE AT THIS POINT.
    315                 abort( "boot() : internal error, recursively invoked during system boot." );
    316         } // if
    317         heapBoot = true;
    318         #endif // __CFA_DEBUG__
    319 
    320         //assert( heapManager.heapBegin != 0 );
    321         //heapManager{};
    322         if ( heapManager.heapBegin == 0 ) heapManager{};
    323 } // memory_startup
    324 
    325 static void memory_shutdown( void ) __attribute__(( destructor( STARTUP_PRIORITY_MEMORY ) ));
    326 void memory_shutdown( void ) {
    327         ^heapManager{};
    328 } // memory_shutdown
    329 
    330251
    331252#ifdef __STATISTICS__
    332 static unsigned long long int mmap_storage;                             // heap statistics counters
     253// Heap statistics counters.
     254static unsigned long long int mmap_storage;
    333255static unsigned int mmap_calls;
    334256static unsigned long long int munmap_storage;
     
    348270static unsigned long long int realloc_storage;
    349271static unsigned int realloc_calls;
    350 
    351 static int statfd;                                                                              // statistics file descriptor (changed by malloc_stats_fd)
    352 
     272// Statistics file descriptor (changed by malloc_stats_fd).
     273static int statfd = STDERR_FILENO;                                              // default stderr
    353274
    354275// Use "write" because streams may be shutdown when calls are made.
    355276static void printStats() {
    356277        char helpText[512];
    357         __cfaabi_dbg_bits_print_buffer( helpText, sizeof(helpText),
     278        __cfaabi_bits_print_buffer( STDERR_FILENO, helpText, sizeof(helpText),
    358279                                                                        "\nHeap statistics:\n"
    359280                                                                        "  malloc: calls %u / storage %llu\n"
     
    405326                                                sbrk_calls, sbrk_storage
    406327                );
    407         return write( fileno( stream ), helpText, len );        // -1 => error
     328        __cfaabi_bits_write( fileno( stream ), helpText, len ); // ensures all bytes written or exit
     329        return len;
    408330} // printStatsXML
    409331#endif // __STATISTICS__
    410332
    411 // #comment TD : Is this the samething as Out-of-Memory?
    412 static inline void noMemory() {
    413         abort( "Heap memory exhausted at %zu bytes.\n"
    414                    "Possible cause is very large memory allocation and/or large amount of unfreed storage allocated by the program or system/library routines.",
    415                    ((char *)(sbrk( 0 )) - (char *)(heapManager.heapBegin)) );
    416 } // noMemory
     333
     334// static inline void noMemory() {
     335//      abort( "Heap memory exhausted at %zu bytes.\n"
     336//                 "Possible cause is very large memory allocation and/or large amount of unfreed storage allocated by the program or system/library routines.",
     337//                 ((char *)(sbrk( 0 )) - (char *)(heapManager.heapBegin)) );
     338// } // noMemory
    417339
    418340
    419341static inline void checkAlign( size_t alignment ) {
    420         if ( alignment < sizeof(void *) || ! libPow2( alignment ) ) {
    421                 abort( "Alignment %zu for memory allocation is less than sizeof(void *) and/or not a power of 2.", alignment );
     342        if ( alignment < libAlign() || ! libPow2( alignment ) ) {
     343                abort( "Alignment %zu for memory allocation is less than %d and/or not a power of 2.", alignment, libAlign() );
    422344        } // if
    423345} // checkAlign
     
    431353
    432354
    433 static inline void checkHeader( bool check, const char * name, void * addr ) {
    434         if ( unlikely( check ) ) {                                                      // bad address ?
    435                 abort( "Attempt to %s storage %p with address outside the heap.\n"
    436                            "Possible cause is duplicate free on same block or overwriting of memory.",
    437                            name, addr );
    438         } // if
    439 } // checkHeader
    440 
    441 // #comment TD : function should be commented and/or have a more evocative name
    442 //               this isn't either a check or a constructor which is what I would expect this function to be
    443 static inline void fakeHeader( HeapManager.Storage.Header *& header, size_t & size, size_t & alignment ) {
    444         if ( unlikely( (header->kind.fake.alignment & 1) == 1 ) ) { // fake header ?
    445                 size_t offset = header->kind.fake.offset;
    446                 alignment = header->kind.fake.alignment & -2;   // remove flag from value
    447                 #ifdef __CFA_DEBUG__
    448                 checkAlign( alignment );                                                // check alignment
    449                 #endif // __CFA_DEBUG__
    450                 header = (HeapManager.Storage.Header *)((char *)header - offset);
    451         } // if
    452 } // fakeHeader
    453 
    454 // #comment TD : Why is this a define
    455 #define headerAddr( addr ) ((HeapManager.Storage.Header *)( (char *)addr - sizeof(HeapManager.Storage) ))
    456 
    457 static inline bool headers( const char * name, void * addr, HeapManager.Storage.Header *& header, HeapManager.FreeHeader *& freeElem, size_t & size, size_t & alignment ) with ( heapManager ) {
    458         header = headerAddr( addr );
    459 
    460         if ( unlikely( heapEnd < addr ) ) {                                     // mmapped ?
    461                 fakeHeader( header, size, alignment );
    462                 size = header->kind.real.blockSize & -3;                // mmap size
    463                 return true;
    464         } // if
    465 
    466         #ifdef __CFA_DEBUG__
    467         checkHeader( addr < heapBegin || header < (HeapManager.Storage.Header *)heapBegin, name, addr ); // bad low address ?
    468         #endif // __CFA_DEBUG__
    469 
    470         // #comment TD : This code looks weird...
    471         //               It's called as the first statement of both branches of the last if, with the same parameters in all cases
    472 
    473         // header may be safe to dereference
    474         fakeHeader( header, size, alignment );
    475         #ifdef __CFA_DEBUG__
    476         checkHeader( header < (HeapManager.Storage.Header *)heapBegin || (HeapManager.Storage.Header *)heapEnd < header, name, addr ); // bad address ? (offset could be + or -)
    477         #endif // __CFA_DEBUG__
    478 
    479         freeElem = (HeapManager.FreeHeader *)((size_t)header->kind.real.home & -3);
    480         #ifdef __CFA_DEBUG__
    481         if ( freeElem < &freeLists[0] || &freeLists[NoBucketSizes] <= freeElem ) {
    482                 abort( "Attempt to %s storage %p with corrupted header.\n"
    483                            "Possible cause is duplicate free on same block or overwriting of header information.",
    484                            name, addr );
    485         } // if
    486         #endif // __CFA_DEBUG__
    487         size = freeElem->blockSize;
    488         return false;
    489 } // headers
    490 
    491 
    492 static inline void * extend( size_t size ) with ( heapManager ) {
    493         lock( extlock __cfaabi_dbg_ctx2 );
    494         ptrdiff_t rem = heapRemaining - size;
    495         if ( rem < 0 ) {
    496                 // If the size requested is bigger than the current remaining storage, increase the size of the heap.
    497 
    498                 size_t increase = libCeiling( size > heapExpand ? size : heapExpand, libAlign() );
    499                 if ( sbrk( increase ) == (void *)-1 ) {
    500                         unlock( extlock );
    501                         errno = ENOMEM;
    502                         return 0;
    503                 } // if
    504                 #ifdef __STATISTICS__
    505                 sbrk_calls += 1;
    506                 sbrk_storage += increase;
    507                 #endif // __STATISTICS__
    508                 #ifdef __CFA_DEBUG__
    509                 // Set new memory to garbage so subsequent uninitialized usages might fail.
    510                 memset( (char *)heapEnd + heapRemaining, '\377', increase );
    511                 #endif // __CFA_DEBUG__
    512                 rem = heapRemaining + increase - size;
    513         } // if
    514 
    515         HeapManager.Storage * block = (HeapManager.Storage *)heapEnd;
    516         heapRemaining = rem;
    517         heapEnd = (char *)heapEnd + size;
    518         unlock( extlock );
    519         return block;
    520 } // extend
    521 
    522 
     355// thunk problem
    523356size_t Bsearchl( unsigned int key, const unsigned int * vals, size_t dim ) {
    524357        size_t l = 0, m, h = dim;
     
    535368
    536369
     370static inline bool setMmapStart( size_t value ) {               // true => mmapped, false => sbrk
     371  if ( value < pageSize || bucketSizes[NoBucketSizes - 1] < value ) return true;
     372        mmapStart = value;                                                                      // set global
     373
     374        // find the closest bucket size less than or equal to the mmapStart size
     375        maxBucketsUsed = Bsearchl( (unsigned int)mmapStart, bucketSizes, NoBucketSizes ); // binary search
     376        assert( maxBucketsUsed < NoBucketSizes );                       // subscript failure ?
     377        assert( mmapStart <= bucketSizes[maxBucketsUsed] ); // search failure ?
     378        return false;
     379} // setMmapStart
     380
     381
     382static inline void checkHeader( bool check, const char name[], void * addr ) {
     383        if ( unlikely( check ) ) {                                                      // bad address ?
     384                abort( "Attempt to %s storage %p with address outside the heap.\n"
     385                           "Possible cause is duplicate free on same block or overwriting of memory.",
     386                           name, addr );
     387        } // if
     388} // checkHeader
     389
     390
     391static inline void fakeHeader( HeapManager.Storage.Header *& header, size_t & alignment ) {
     392        if ( unlikely( (header->kind.fake.alignment & 1) == 1 ) ) { // fake header ?
     393                size_t offset = header->kind.fake.offset;
     394                alignment = header->kind.fake.alignment & -2;   // remove flag from value
     395                #ifdef __CFA_DEBUG__
     396                checkAlign( alignment );                                                // check alignment
     397                #endif // __CFA_DEBUG__
     398                header = (HeapManager.Storage.Header *)((char *)header - offset);
     399        } // if
     400} // fakeHeader
     401
     402
     403// <-------+----------------------------------------------------> bsize (bucket size)
     404// |header |addr
     405//==================================================================================
     406//                                | alignment
     407// <-----------------<------------+-----------------------------> bsize (bucket size)
     408//                   |fake-header | addr
     409#define headerAddr( addr ) ((HeapManager.Storage.Header *)( (char *)addr - sizeof(HeapManager.Storage) ))
     410
     411// <-------<<--------------------- dsize ---------------------->> bsize (bucket size)
     412// |header |addr
     413//==================================================================================
     414//                                | alignment
     415// <------------------------------<<---------- dsize --------->>> bsize (bucket size)
     416//                   |fake-header |addr
     417#define dataStorage( bsize, addr, header ) (bsize - ( (char *)addr - (char *)header ))
     418
     419
     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 ) {
     421        header = headerAddr( addr );
     422
     423        if ( unlikely( heapEnd < addr ) ) {                                     // mmapped ?
     424                fakeHeader( header, alignment );
     425                size = header->kind.real.blockSize & -3;                // mmap size
     426                return true;
     427        } // if
     428
     429        #ifdef __CFA_DEBUG__
     430        checkHeader( addr < heapBegin || header < (HeapManager.Storage.Header *)heapBegin, name, addr ); // bad low address ?
     431        #endif // __CFA_DEBUG__
     432
     433        // header may be safe to dereference
     434        fakeHeader( header, alignment );
     435        #ifdef __CFA_DEBUG__
     436        checkHeader( header < (HeapManager.Storage.Header *)heapBegin || (HeapManager.Storage.Header *)heapEnd < header, name, addr ); // bad address ? (offset could be + or -)
     437        #endif // __CFA_DEBUG__
     438
     439        freeElem = (HeapManager.FreeHeader *)((size_t)header->kind.real.home & -3);
     440        #ifdef __CFA_DEBUG__
     441        if ( freeElem < &freeLists[0] || &freeLists[NoBucketSizes] <= freeElem ) {
     442                abort( "Attempt to %s storage %p with corrupted header.\n"
     443                           "Possible cause is duplicate free on same block or overwriting of header information.",
     444                           name, addr );
     445        } // if
     446        #endif // __CFA_DEBUG__
     447        size = freeElem->blockSize;
     448        return false;
     449} // headers
     450
     451
     452static inline void * extend( size_t size ) with ( heapManager ) {
     453        lock( extlock __cfaabi_dbg_ctx2 );
     454        ptrdiff_t rem = heapRemaining - size;
     455        if ( rem < 0 ) {
     456                // If the size requested is bigger than the current remaining storage, increase the size of the heap.
     457
     458                size_t increase = libCeiling( size > heapExpand ? size : heapExpand, libAlign() );
     459                if ( sbrk( increase ) == (void *)-1 ) {
     460                        unlock( extlock );
     461                        errno = ENOMEM;
     462                        return 0p;
     463                } // if
     464                #ifdef __STATISTICS__
     465                sbrk_calls += 1;
     466                sbrk_storage += increase;
     467                #endif // __STATISTICS__
     468                #ifdef __CFA_DEBUG__
     469                // Set new memory to garbage so subsequent uninitialized usages might fail.
     470                memset( (char *)heapEnd + heapRemaining, '\377', increase );
     471                #endif // __CFA_DEBUG__
     472                rem = heapRemaining + increase - size;
     473        } // if
     474
     475        HeapManager.Storage * block = (HeapManager.Storage *)heapEnd;
     476        heapRemaining = rem;
     477        heapEnd = (char *)heapEnd + size;
     478        unlock( extlock );
     479        return block;
     480} // extend
     481
     482
    537483static inline void * doMalloc( size_t size ) with ( heapManager ) {
    538484        HeapManager.Storage * block;                                            // pointer to new block of storage
     
    541487        // along with the block and is a multiple of the alignment size.
    542488
    543   if ( unlikely( size > ~0ul - sizeof(HeapManager.Storage) ) ) return 0;
     489  if ( unlikely( size > ~0ul - sizeof(HeapManager.Storage) ) ) return 0p;
    544490        size_t tsize = size + sizeof(HeapManager.Storage);
    545491        if ( likely( tsize < mmapStart ) ) {                            // small size => sbrk
     
    574520                block = freeElem->freeList.pop();
    575521                #endif // SPINLOCK
    576                 if ( unlikely( block == 0 ) ) {                                 // no free block ?
     522                if ( unlikely( block == 0p ) ) {                                // no free block ?
    577523                        #if defined( SPINLOCK )
    578524                        unlock( freeElem->lock );
     
    583529
    584530                        block = (HeapManager.Storage *)extend( tsize ); // mutual exclusion on call
    585   if ( unlikely( block == 0 ) ) return 0;
    586                         #if defined( SPINLOCK )
     531  if ( unlikely( block == 0p ) ) return 0p;
     532                #if defined( SPINLOCK )
    587533                } else {
    588534                        freeElem->freeList = block->header.kind.real.next;
    589535                        unlock( freeElem->lock );
    590                         #endif // SPINLOCK
     536                #endif // SPINLOCK
    591537                } // if
    592538
    593539                block->header.kind.real.home = freeElem;                // pointer back to free list of apropriate size
    594540        } else {                                                                                        // large size => mmap
    595   if ( unlikely( size > ~0ul - pageSize ) ) return 0;
     541  if ( unlikely( size > ~0ul - pageSize ) ) return 0p;
    596542                tsize = libCeiling( tsize, pageSize );                  // must be multiple of page size
    597543                #ifdef __STATISTICS__
     
    611557        } // if
    612558
    613         void * area = &(block->data);                                           // adjust off header to user bytes
     559        void * addr = &(block->data);                                           // adjust off header to user bytes
    614560
    615561        #ifdef __CFA_DEBUG__
    616         assert( ((uintptr_t)area & (libAlign() - 1)) == 0 ); // minimum alignment ?
     562        assert( ((uintptr_t)addr & (libAlign() - 1)) == 0 ); // minimum alignment ?
    617563        __atomic_add_fetch( &allocFree, tsize, __ATOMIC_SEQ_CST );
    618564        if ( traceHeap() ) {
    619565                enum { BufferSize = 64 };
    620566                char helpText[BufferSize];
    621                 int len = snprintf( helpText, BufferSize, "%p = Malloc( %zu ) (allocated %zu)\n", area, size, tsize );
    622                 // int len = snprintf( helpText, BufferSize, "Malloc %p %zu\n", area, size );
    623                 __cfaabi_dbg_bits_write( helpText, len );
     567                int len = snprintf( helpText, BufferSize, "%p = Malloc( %zu ) (allocated %zu)\n", addr, size, tsize );
     568                // int len = snprintf( helpText, BufferSize, "Malloc %p %zu\n", addr, size );
     569                __cfaabi_bits_write( STDERR_FILENO, helpText, len ); // print debug/nodebug
    624570        } // if
    625571        #endif // __CFA_DEBUG__
    626572
    627         return area;
     573        return addr;
    628574} // doMalloc
    629575
     
    631577static inline void doFree( void * addr ) with ( heapManager ) {
    632578        #ifdef __CFA_DEBUG__
    633         if ( unlikely( heapManager.heapBegin == 0 ) ) {
     579        if ( unlikely( heapManager.heapBegin == 0p ) ) {
    634580                abort( "doFree( %p ) : internal error, called before heap is initialized.", addr );
    635581        } // if
     
    677623                char helpText[BufferSize];
    678624                int len = snprintf( helpText, sizeof(helpText), "Free( %p ) size:%zu\n", addr, size );
    679                 __cfaabi_dbg_bits_write( helpText, len );
     625                __cfaabi_bits_write( STDERR_FILENO, helpText, len ); // print debug/nodebug
    680626        } // if
    681627        #endif // __CFA_DEBUG__
     
    683629
    684630
    685 size_t checkFree( HeapManager & manager ) with ( manager ) {
     631size_t prtFree( HeapManager & manager ) with ( manager ) {
    686632        size_t total = 0;
    687633        #ifdef __STATISTICS__
    688         __cfaabi_dbg_bits_acquire();
    689         __cfaabi_dbg_bits_print_nolock( "\nBin lists (bin size : free blocks on list)\n" );
     634        __cfaabi_bits_acquire();
     635        __cfaabi_bits_print_nolock( STDERR_FILENO, "\nBin lists (bin size : free blocks on list)\n" );
    690636        #endif // __STATISTICS__
    691637        for ( unsigned int i = 0; i < maxBucketsUsed; i += 1 ) {
     
    696642
    697643                #if defined( SPINLOCK )
    698                 for ( HeapManager.Storage * p = freeLists[i].freeList; p != 0; p = p->header.kind.real.next ) {
     644                for ( HeapManager.Storage * p = freeLists[i].freeList; p != 0p; p = p->header.kind.real.next ) {
    699645                #else
    700                 for ( HeapManager.Storage * p = freeLists[i].freeList.top(); p != 0; p = p->header.kind.real.next.top ) {
     646                for ( HeapManager.Storage * p = freeLists[i].freeList.top(); p != 0p; p = p->header.kind.real.next.top ) {
    701647                #endif // SPINLOCK
    702648                        total += size;
     
    707653
    708654                #ifdef __STATISTICS__
    709                 __cfaabi_dbg_bits_print_nolock( "%7zu, %-7u  ", size, N );
    710                 if ( (i + 1) % 8 == 0 ) __cfaabi_dbg_bits_print_nolock( "\n" );
     655                __cfaabi_bits_print_nolock( STDERR_FILENO, "%7zu, %-7u  ", size, N );
     656                if ( (i + 1) % 8 == 0 ) __cfaabi_bits_print_nolock( STDERR_FILENO, "\n" );
    711657                #endif // __STATISTICS__
    712658        } // for
    713659        #ifdef __STATISTICS__
    714         __cfaabi_dbg_bits_print_nolock( "\ntotal free blocks:%zu\n", total );
    715         __cfaabi_dbg_bits_release();
     660        __cfaabi_bits_print_nolock( STDERR_FILENO, "\ntotal free blocks:%zu\n", total );
     661        __cfaabi_bits_release();
    716662        #endif // __STATISTICS__
    717663        return (char *)heapEnd - (char *)heapBegin - total;
    718 } // checkFree
     664} // prtFree
     665
     666
     667static void ?{}( HeapManager & manager ) with ( manager ) {
     668        pageSize = sysconf( _SC_PAGESIZE );
     669
     670        for ( unsigned int i = 0; i < NoBucketSizes; i += 1 ) { // initialize the free lists
     671                freeLists[i].blockSize = bucketSizes[i];
     672        } // for
     673
     674        #ifdef FASTLOOKUP
     675        unsigned int idx = 0;
     676        for ( unsigned int i = 0; i < LookupSizes; i += 1 ) {
     677                if ( i > bucketSizes[idx] ) idx += 1;
     678                lookup[i] = idx;
     679        } // for
     680        #endif // FASTLOOKUP
     681
     682        if ( setMmapStart( default_mmap_start() ) ) {
     683                abort( "HeapManager : internal error, mmap start initialization failure." );
     684        } // if
     685        heapExpand = default_heap_expansion();
     686
     687        char * end = (char *)sbrk( 0 );
     688        sbrk( (char *)libCeiling( (long unsigned int)end, libAlign() ) - end ); // move start of heap to multiple of alignment
     689        heapBegin = heapEnd = sbrk( 0 );                                        // get new start point
     690} // HeapManager
     691
     692
     693static void ^?{}( HeapManager & ) {
     694        #ifdef __STATISTICS__
     695        if ( traceHeapTerm() ) {
     696                printStats();
     697                // if ( prtfree() ) prtFree( heapManager, true );
     698        } // if
     699        #endif // __STATISTICS__
     700} // ~HeapManager
     701
     702
     703static void memory_startup( void ) __attribute__(( constructor( STARTUP_PRIORITY_MEMORY ) ));
     704void memory_startup( void ) {
     705        #ifdef __CFA_DEBUG__
     706        if ( unlikely( heapBoot ) ) {                                           // check for recursion during system boot
     707                // DO NOT USE STREAMS AS THEY MAY BE UNAVAILABLE AT THIS POINT.
     708                abort( "boot() : internal error, recursively invoked during system boot." );
     709        } // if
     710        heapBoot = true;
     711        #endif // __CFA_DEBUG__
     712
     713        //assert( heapManager.heapBegin != 0 );
     714        //heapManager{};
     715        if ( heapManager.heapBegin == 0p ) heapManager{};
     716} // memory_startup
     717
     718static void memory_shutdown( void ) __attribute__(( destructor( STARTUP_PRIORITY_MEMORY ) ));
     719void memory_shutdown( void ) {
     720        ^heapManager{};
     721} // memory_shutdown
    719722
    720723
    721724static inline void * mallocNoStats( size_t size ) {             // necessary for malloc statistics
    722725        //assert( heapManager.heapBegin != 0 );
    723         if ( unlikely( heapManager.heapBegin == 0 ) ) heapManager{}; // called before memory_startup ?
    724         void * area = doMalloc( size );
    725         if ( unlikely( area == 0 ) ) errno = ENOMEM;            // POSIX
    726         return area;
     726        if ( unlikely( heapManager.heapBegin == 0p ) ) heapManager{}; // called before memory_startup ?
     727        void * addr = doMalloc( size );
     728        if ( unlikely( addr == 0p ) ) errno = ENOMEM;           // POSIX
     729        return addr;
    727730} // mallocNoStats
     731
     732
     733static inline void * callocNoStats( size_t noOfElems, size_t elemSize ) {
     734        size_t size = noOfElems * elemSize;
     735        char * addr = (char *)mallocNoStats( size );
     736  if ( unlikely( addr == 0p ) ) return 0p;
     737
     738        HeapManager.Storage.Header * header;
     739        HeapManager.FreeHeader * freeElem;
     740        size_t bsize, alignment;
     741        bool mapped __attribute__(( unused )) = headers( "calloc", addr, header, freeElem, bsize, alignment );
     742        #ifndef __CFA_DEBUG__
     743        // Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero.
     744        if ( ! mapped )
     745        #endif // __CFA_DEBUG__
     746                // Zero entire data space even when > than size => realloc without a new allocation and zero fill works.
     747                // <-------00000000000000000000000000000000000000000000000000000> bsize (bucket size)
     748                // `-header`-addr                      `-size
     749                memset( addr, '\0', bsize - sizeof(HeapManager.Storage) ); // set to zeros
     750
     751        header->kind.real.blockSize |= 2;                                       // mark as zero filled
     752        return addr;
     753} // callocNoStats
    728754
    729755
     
    745771        // subtract libAlign() because it is already the minimum alignment
    746772        // add sizeof(Storage) for fake header
    747         // #comment TD : this is the only place that calls doMalloc without calling mallocNoStats, why ?
    748         char * area = (char *)doMalloc( size + alignment - libAlign() + sizeof(HeapManager.Storage) );
    749   if ( unlikely( area == 0 ) ) return area;
     773        char * addr = (char *)mallocNoStats( size + alignment - libAlign() + sizeof(HeapManager.Storage) );
     774  if ( unlikely( addr == 0p ) ) return addr;
    750775
    751776        // address in the block of the "next" alignment address
    752         char * user = (char *)libCeiling( (uintptr_t)(area + sizeof(HeapManager.Storage)), alignment );
     777        char * user = (char *)libCeiling( (uintptr_t)(addr + sizeof(HeapManager.Storage)), alignment );
    753778
    754779        // address of header from malloc
    755         HeapManager.Storage.Header * realHeader = headerAddr( area );
     780        HeapManager.Storage.Header * realHeader = headerAddr( addr );
    756781        // address of fake header * before* the alignment location
    757782        HeapManager.Storage.Header * fakeHeader = headerAddr( user );
     
    763788        return user;
    764789} // memalignNoStats
     790
     791
     792static inline void * cmemalignNoStats( size_t alignment, size_t noOfElems, size_t elemSize ) {
     793        size_t size = noOfElems * elemSize;
     794        char * addr = (char *)memalignNoStats( alignment, size );
     795  if ( unlikely( addr == 0p ) ) return 0p;
     796        HeapManager.Storage.Header * header;
     797        HeapManager.FreeHeader * freeElem;
     798        size_t bsize;
     799        bool mapped __attribute__(( unused )) = headers( "cmemalign", addr, header, freeElem, bsize, alignment );
     800        #ifndef __CFA_DEBUG__
     801        // Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero.
     802        if ( ! mapped )
     803        #endif // __CFA_DEBUG__
     804                memset( addr, '\0', dataStorage( bsize, addr, header ) ); // set to zeros
     805        header->kind.real.blockSize |= 2;                               // mark as zero filled
     806
     807        return addr;
     808} // cmemalignNoStats
    765809
    766810
     
    776820extern "C" {
    777821        // The malloc() function allocates size bytes and returns a pointer to the allocated memory. The memory is not
    778         // initialized. If size is 0, then malloc() returns either NULL, or a unique pointer value that can later be
     822        // initialized. If size is 0, then malloc() returns either 0p, or a unique pointer value that can later be
    779823        // successfully passed to free().
    780824        void * malloc( size_t size ) {
     
    788832
    789833        // The calloc() function allocates memory for an array of nmemb elements of size bytes each and returns a pointer to
    790         // the allocated memory. The memory is set to zero. If nmemb or size is 0, then calloc() returns either NULL, or a
     834        // the allocated memory. The memory is set to zero. If nmemb or size is 0, then calloc() returns either 0p, or a
    791835        // unique pointer value that can later be successfully passed to free().
    792836        void * calloc( size_t noOfElems, size_t elemSize ) {
    793                 size_t size = noOfElems * elemSize;
    794837                #ifdef __STATISTICS__
    795838                __atomic_add_fetch( &calloc_calls, 1, __ATOMIC_SEQ_CST );
    796                 __atomic_add_fetch( &calloc_storage, size, __ATOMIC_SEQ_CST );
    797                 #endif // __STATISTICS__
    798 
    799                 char * area = (char *)mallocNoStats( size );
    800           if ( unlikely( area == 0 ) ) return 0;
     839                __atomic_add_fetch( &calloc_storage, noOfElems * elemSize, __ATOMIC_SEQ_CST );
     840                #endif // __STATISTICS__
     841
     842                return callocNoStats( noOfElems, elemSize );
     843        } // calloc
     844
     845        // The realloc() function changes the size of the memory block pointed to by ptr to size bytes. The contents will be
     846        // unchanged in the range from the start of the region up to the minimum of the old and new sizes. If the new size
     847        // is larger than the old size, the added memory will not be initialized.  If ptr is 0p, then the call is
     848        // equivalent to malloc(size), for all values of size; if size is equal to zero, and ptr is not 0p, then the call
     849        // is equivalent to free(ptr). Unless ptr is 0p, it must have been returned by an earlier call to malloc(),
     850        // calloc() or realloc(). If the area pointed to was moved, a free(ptr) is done.
     851        void * realloc( void * oaddr, size_t size ) {
     852                #ifdef __STATISTICS__
     853                __atomic_add_fetch( &realloc_calls, 1, __ATOMIC_SEQ_CST );
     854                #endif // __STATISTICS__
     855
     856                // If size is equal to 0, either NULL or a pointer suitable to be passed to free() is returned.
     857          if ( unlikely( size == 0 ) ) { free( oaddr ); return mallocNoStats( size ); } // special cases
     858          if ( unlikely( oaddr == 0p ) ) return mallocNoStats( size );
    801859
    802860                HeapManager.Storage.Header * header;
    803861                HeapManager.FreeHeader * freeElem;
    804                 size_t asize, alignment;
    805                 bool mapped __attribute__(( unused )) = headers( "calloc", area, header, freeElem, asize, alignment );
    806                 #ifndef __CFA_DEBUG__
    807                 // Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero.
    808                 if ( ! mapped )
    809                 #endif // __CFA_DEBUG__
    810                         memset( area, '\0', asize - sizeof(HeapManager.Storage) ); // set to zeros
    811 
    812                 header->kind.real.blockSize |= 2;                               // mark as zero filled
    813                 return area;
    814         } // calloc
    815 
    816         // #comment TD : Document this function
    817         void * cmemalign( size_t alignment, size_t noOfElems, size_t elemSize ) {
    818                 size_t size = noOfElems * elemSize;
    819                 #ifdef __STATISTICS__
    820                 __atomic_add_fetch( &cmemalign_calls, 1, __ATOMIC_SEQ_CST );
    821                 __atomic_add_fetch( &cmemalign_storage, size, __ATOMIC_SEQ_CST );
    822                 #endif // __STATISTICS__
    823 
    824                 char * area = (char *)memalignNoStats( alignment, size );
    825           if ( unlikely( area == 0 ) ) return 0;
    826                 HeapManager.Storage.Header * header;
    827                 HeapManager.FreeHeader * freeElem;
    828                 size_t asize;
    829                 bool mapped __attribute__(( unused )) = headers( "cmemalign", area, header, freeElem, asize, alignment );
    830                 #ifndef __CFA_DEBUG__
    831                 // Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero.
    832                 if ( ! mapped )
    833                         #endif // __CFA_DEBUG__
    834                         memset( area, '\0', asize - ( (char *)area - (char *)header ) ); // set to zeros
    835                 header->kind.real.blockSize |= 2;                               // mark as zero filled
    836 
    837                 return area;
    838         } // cmemalign
    839 
    840         // The realloc() function changes the size of the memory block pointed to by ptr to size bytes. The contents will be
    841         // unchanged in the range from the start of the region up to the minimum of the old and new sizes. If the new size
    842         // is larger than the old size, the added memory will not be initialized.  If ptr is NULL, then the call is
    843         // equivalent to malloc(size), for all values of size; if size is equal to zero, and ptr is not NULL, then the call
    844         // is equivalent to free(ptr). Unless ptr is NULL, it must have been returned by an earlier call to malloc(),
    845         // calloc() or realloc(). If the area pointed to was moved, a free(ptr) is done.
    846         void * realloc( void * addr, size_t size ) {
    847                 #ifdef __STATISTICS__
    848                 __atomic_add_fetch( &realloc_calls, 1, __ATOMIC_SEQ_CST );
    849                 #endif // __STATISTICS__
    850 
    851           if ( unlikely( addr == 0 ) ) return mallocNoStats( size ); // special cases
    852           if ( unlikely( size == 0 ) ) { free( addr ); return 0; }
    853 
    854                 HeapManager.Storage.Header * header;
    855                 HeapManager.FreeHeader * freeElem;
    856                 size_t asize, alignment = 0;
    857                 headers( "realloc", addr, header, freeElem, asize, alignment );
    858 
    859                 size_t usize = asize - ( (char *)addr - (char *)header ); // compute the amount of user storage in the block
    860                 if ( usize >= size ) {                                                  // already sufficient storage
     862                size_t bsize, oalign = 0;
     863                headers( "realloc", oaddr, header, freeElem, bsize, oalign );
     864
     865                size_t odsize = dataStorage( bsize, oaddr, header ); // data storage available in bucket
     866          if ( size <= odsize && odsize <= size * 2 ) { // allow up to 50% wasted storage in smaller size
     867                        // Do not know size of original allocation => cannot do 0 fill for any additional space because do not know
     868                        // where to start filling, i.e., do not overwrite existing values in space.
     869                        //
    861870                        // This case does not result in a new profiler entry because the previous one still exists and it must match with
    862871                        // the free for this memory.  Hence, this realloc does not appear in the profiler output.
    863                         return addr;
     872                        return oaddr;
    864873                } // if
    865874
     
    868877                #endif // __STATISTICS__
    869878
    870                 void * area;
    871                 if ( unlikely( alignment != 0 ) ) {                             // previous request memalign?
    872                         area = memalign( alignment, size );                     // create new aligned area
     879                // change size and copy old content to new storage
     880
     881                void * naddr;
     882                if ( unlikely( oalign != 0 ) ) {                                // previous request memalign?
     883                        if ( unlikely( header->kind.real.blockSize & 2 ) ) { // previous request zero fill
     884                                naddr = cmemalignNoStats( oalign, 1, size ); // create new aligned area
     885                        } else {
     886                                naddr = memalignNoStats( oalign, size ); // create new aligned area
     887                        } // if
    873888                } else {
    874                         area = mallocNoStats( size );                           // create new area
     889                        if ( unlikely( header->kind.real.blockSize & 2 ) ) { // previous request zero fill
     890                                naddr = callocNoStats( 1, size );               // create new area
     891                        } else {
     892                                naddr = mallocNoStats( size );                  // create new area
     893                        } // if
    875894                } // if
    876           if ( unlikely( area == 0 ) ) return 0;
    877                 if ( unlikely( header->kind.real.blockSize & 2 ) ) { // previous request zero fill (calloc/cmemalign) ?
    878                         assert( (header->kind.real.blockSize & 1) == 0 );
    879                         bool mapped __attribute__(( unused )) = headers( "realloc", area, header, freeElem, asize, alignment );
    880                         #ifndef __CFA_DEBUG__
    881                         // Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero.
    882                         if ( ! mapped )
    883                         #endif // __CFA_DEBUG__
    884                                 memset( (char *)area + usize, '\0', asize - ( (char *)area - (char *)header ) - usize ); // zero-fill back part
    885                         header->kind.real.blockSize |= 2;                       // mark new request as zero fill
    886                 } // if
    887                 memcpy( area, addr, usize );                                    // copy bytes
    888                 free( addr );
    889                 return area;
     895          if ( unlikely( naddr == 0p ) ) return 0p;
     896
     897                headers( "realloc", naddr, header, freeElem, bsize, oalign );
     898                size_t ndsize = dataStorage( bsize, naddr, header ); // data storage avilable in bucket
     899                // To preserve prior fill, the entire bucket must be copied versus the size.
     900                memcpy( naddr, oaddr, MIN( odsize, ndsize ) );  // copy bytes
     901                free( oaddr );
     902                return naddr;
    890903        } // realloc
    891904
     
    898911                #endif // __STATISTICS__
    899912
    900                 void * area = memalignNoStats( alignment, size );
    901 
    902                 return area;
     913                return memalignNoStats( alignment, size );
    903914        } // memalign
     915
     916
     917        // The cmemalign() function is the same as calloc() with memory alignment.
     918        void * cmemalign( size_t alignment, size_t noOfElems, size_t elemSize ) {
     919                #ifdef __STATISTICS__
     920                __atomic_add_fetch( &cmemalign_calls, 1, __ATOMIC_SEQ_CST );
     921                __atomic_add_fetch( &cmemalign_storage, noOfElems * elemSize, __ATOMIC_SEQ_CST );
     922                #endif // __STATISTICS__
     923
     924                return cmemalignNoStats( alignment, noOfElems, elemSize );
     925        } // cmemalign
    904926
    905927        // The function aligned_alloc() is the same as memalign(), except for the added restriction that size should be a
     
    912934        // The function posix_memalign() allocates size bytes and places the address of the allocated memory in *memptr. The
    913935        // address of the allocated memory will be a multiple of alignment, which must be a power of two and a multiple of
    914         // sizeof(void *). If size is 0, then posix_memalign() returns either NULL, or a unique pointer value that can later
     936        // sizeof(void *). If size is 0, then posix_memalign() returns either 0p, or a unique pointer value that can later
    915937        // be successfully passed to free(3).
    916938        int posix_memalign( void ** memptr, size_t alignment, size_t size ) {
    917939          if ( alignment < sizeof(void *) || ! libPow2( alignment ) ) return EINVAL; // check alignment
    918940                * memptr = memalign( alignment, size );
    919           if ( unlikely( * memptr == 0 ) ) return ENOMEM;
     941          if ( unlikely( * memptr == 0p ) ) return ENOMEM;
    920942                return 0;
    921943        } // posix_memalign
     
    930952        // The free() function frees the memory space pointed to by ptr, which must have been returned by a previous call to
    931953        // malloc(), calloc() or realloc().  Otherwise, or if free(ptr) has already been called before, undefined behavior
    932         // occurs. If ptr is NULL, no operation is performed.
     954        // occurs. If ptr is 0p, no operation is performed.
    933955        void free( void * addr ) {
    934956                #ifdef __STATISTICS__
     
    936958                #endif // __STATISTICS__
    937959
    938                 // #comment TD : To decrease nesting I would but the special case in the
    939                 //               else instead, plus it reads more naturally to have the
    940                 //               short / normal case instead
    941                 if ( unlikely( addr == 0 ) ) {                                  // special case
    942                         #ifdef __CFA_DEBUG__
    943                         if ( traceHeap() ) {
    944                                 #define nullmsg "Free( 0x0 ) size:0\n"
    945                                 // Do not debug print free( 0 ), as it can cause recursive entry from sprintf.
    946                                 __cfaabi_dbg_bits_write( nullmsg, sizeof(nullmsg) - 1 );
    947                         } // if
    948                         #endif // __CFA_DEBUG__
     960          if ( unlikely( addr == 0p ) ) {                                       // special case
     961                        // #ifdef __CFA_DEBUG__
     962                        // if ( traceHeap() ) {
     963                        //      #define nullmsg "Free( 0x0 ) size:0\n"
     964                        //      // Do not debug print free( 0p ), as it can cause recursive entry from sprintf.
     965                        //      __cfaabi_dbg_write( nullmsg, sizeof(nullmsg) - 1 );
     966                        // } // if
     967                        // #endif // __CFA_DEBUG__
    949968                        return;
    950969                } // exit
     
    953972        } // free
    954973
    955         // The mallopt() function adjusts parameters that control the behavior of the memory-allocation functions (see
    956         // malloc(3)). The param argument specifies the parameter to be modified, and value specifies the new value for that
    957         // parameter.
    958         int mallopt( int option, int value ) {
    959                 choose( option ) {
    960                   case M_TOP_PAD:
    961                         if ( setHeapExpand( value ) ) fallthru default;
    962                   case M_MMAP_THRESHOLD:
    963                         if ( setMmapStart( value ) ) fallthru default;
    964                   default:
    965                         // #comment TD : 1 for unsopported feels wrong
    966                         return 1;                                                                       // success, or unsupported
    967                 } // switch
    968                 return 0;                                                                               // error
    969         } // mallopt
    970 
    971         // The malloc_trim() function attempts to release free memory at the top of the heap (by calling sbrk(2) with a
    972         // suitable argument).
    973         int malloc_trim( size_t ) {
    974                 return 0;                                                                               // => impossible to release memory
    975         } // malloc_trim
    976 
    977         // The malloc_usable_size() function returns the number of usable bytes in the block pointed to by ptr, a pointer to
    978         // a block of memory allocated by malloc(3) or a related function.
    979         size_t malloc_usable_size( void * addr ) {
    980           if ( unlikely( addr == 0 ) ) return 0;                        // null allocation has 0 size
    981 
    982                 HeapManager.Storage.Header * header;
    983                 HeapManager.FreeHeader * freeElem;
    984                 size_t size, alignment;
    985 
    986                 headers( "malloc_usable_size", addr, header, freeElem, size, alignment );
    987                 size_t usize = size - ( (char *)addr - (char *)header ); // compute the amount of user storage in the block
    988                 return usize;
    989         } // malloc_usable_size
    990 
    991 
    992     // The malloc_alignment() function returns the alignment of the allocation.
     974
     975        // The malloc_alignment() function returns the alignment of the allocation.
    993976        size_t malloc_alignment( void * addr ) {
    994           if ( unlikely( addr == 0 ) ) return libAlign();       // minimum alignment
     977          if ( unlikely( addr == 0p ) ) return libAlign();      // minimum alignment
    995978                HeapManager.Storage.Header * header = headerAddr( addr );
    996979                if ( (header->kind.fake.alignment & 1) == 1 ) { // fake header ?
     
    1002985
    1003986
    1004     // The malloc_zero_fill() function returns true if the allocation is zero filled, i.e., initially allocated by calloc().
     987        // The malloc_zero_fill() function returns true if the allocation is zero filled, i.e., initially allocated by calloc().
    1005988        bool malloc_zero_fill( void * addr ) {
    1006           if ( unlikely( addr == 0 ) ) return false;            // null allocation is not zero fill
     989          if ( unlikely( addr == 0p ) ) return false;           // null allocation is not zero fill
    1007990                HeapManager.Storage.Header * header = headerAddr( addr );
    1008991                if ( (header->kind.fake.alignment & 1) == 1 ) { // fake header ?
     
    1013996
    1014997
    1015     // The malloc_stats() function prints (on default standard error) statistics about memory allocated by malloc(3) and
    1016     // related functions.
     998        // The malloc_usable_size() function returns the number of usable bytes in the block pointed to by ptr, a pointer to
     999        // a block of memory allocated by malloc(3) or a related function.
     1000        size_t malloc_usable_size( void * addr ) {
     1001          if ( unlikely( addr == 0p ) ) return 0;                       // null allocation has 0 size
     1002                HeapManager.Storage.Header * header;
     1003                HeapManager.FreeHeader * freeElem;
     1004                size_t bsize, alignment;
     1005
     1006                headers( "malloc_usable_size", addr, header, freeElem, bsize, alignment );
     1007                return dataStorage( bsize, addr, header );      // data storage in bucket
     1008        } // malloc_usable_size
     1009
     1010
     1011        // The malloc_stats() function prints (on default standard error) statistics about memory allocated by malloc(3) and
     1012        // related functions.
    10171013        void malloc_stats( void ) {
    10181014                #ifdef __STATISTICS__
    10191015                printStats();
    1020                 if ( checkFree() ) checkFree( heapManager );
     1016                if ( prtFree() ) prtFree( heapManager );
    10211017                #endif // __STATISTICS__
    10221018        } // malloc_stats
    10231019
    10241020        // The malloc_stats_fd() function changes the file descripter where malloc_stats() writes the statistics.
    1025         int malloc_stats_fd( int fd ) {
     1021        int malloc_stats_fd( int fd __attribute__(( unused )) ) {
    10261022                #ifdef __STATISTICS__
    10271023                int temp = statfd;
     
    10331029        } // malloc_stats_fd
    10341030
     1031
     1032        // The mallopt() function adjusts parameters that control the behavior of the memory-allocation functions (see
     1033        // malloc(3)). The param argument specifies the parameter to be modified, and value specifies the new value for that
     1034        // parameter.
     1035        int mallopt( int option, int value ) {
     1036                choose( option ) {
     1037                  case M_TOP_PAD:
     1038                        if ( setHeapExpand( value ) ) return 1;
     1039                  case M_MMAP_THRESHOLD:
     1040                        if ( setMmapStart( value ) ) return 1;
     1041                } // switch
     1042                return 0;                                                                               // error, unsupported
     1043        } // mallopt
     1044
     1045        // The malloc_trim() function attempts to release free memory at the top of the heap (by calling sbrk(2) with a
     1046        // suitable argument).
     1047        int malloc_trim( size_t ) {
     1048                return 0;                                                                               // => impossible to release memory
     1049        } // malloc_trim
     1050
     1051
    10351052        // The malloc_info() function exports an XML string that describes the current state of the memory-allocation
    10361053        // implementation in the caller.  The string is printed on the file stream stream.  The exported string includes
    10371054        // information about all arenas (see malloc(3)).
    10381055        int malloc_info( int options, FILE * stream ) {
     1056                if ( options != 0 ) { errno = EINVAL; return -1; }
    10391057                return printStatsXML( stream );
    10401058        } // malloc_info
     
    10461064        // structure is returned as the function result.  (It is the caller's responsibility to free(3) this memory.)
    10471065        void * malloc_get_state( void ) {
    1048                 return 0;                                                                               // unsupported
     1066                return 0p;                                                                              // unsupported
    10491067        } // malloc_get_state
    10501068
     
    10581076
    10591077
     1078// Must have CFA linkage to overload with C linkage realloc.
     1079void * realloc( void * oaddr, size_t nalign, size_t size ) {
     1080        #ifdef __STATISTICS__
     1081        __atomic_add_fetch( &realloc_calls, 1, __ATOMIC_SEQ_CST );
     1082        #endif // __STATISTICS__
     1083
     1084        // If size is equal to 0, either NULL or a pointer suitable to be passed to free() is returned.
     1085  if ( unlikely( size == 0 ) ) { free( oaddr ); return mallocNoStats( size ); } // special cases
     1086  if ( unlikely( oaddr == 0p ) ) return mallocNoStats( size );
     1087
     1088        if ( unlikely( nalign == 0 ) ) nalign = libAlign();     // reset alignment to minimum
     1089        #ifdef __CFA_DEBUG__
     1090        else
     1091                checkAlign( nalign );                                                   // check alignment
     1092        #endif // __CFA_DEBUG__
     1093
     1094        HeapManager.Storage.Header * header;
     1095        HeapManager.FreeHeader * freeElem;
     1096        size_t bsize, oalign = 0;
     1097        headers( "realloc", oaddr, header, freeElem, bsize, oalign );
     1098        size_t odsize = dataStorage( bsize, oaddr, header ); // data storage available in bucket
     1099
     1100  if ( oalign != 0 && (uintptr_t)oaddr % nalign == 0 ) { // has alignment and just happens to work out
     1101                headerAddr( oaddr )->kind.fake.alignment = nalign | 1; // update alignment (could be the same)
     1102                return realloc( oaddr, size );
     1103        } // if
     1104
     1105        #ifdef __STATISTICS__
     1106        __atomic_add_fetch( &realloc_storage, size, __ATOMIC_SEQ_CST );
     1107        #endif // __STATISTICS__
     1108
     1109        // change size and copy old content to new storage
     1110
     1111        void * naddr;
     1112        if ( unlikely( header->kind.real.blockSize & 2 ) ) { // previous request zero fill
     1113                naddr = cmemalignNoStats( nalign, 1, size );    // create new aligned area
     1114        } else {
     1115                naddr = memalignNoStats( nalign, size );                // create new aligned area
     1116        } // if
     1117
     1118        headers( "realloc", naddr, header, freeElem, bsize, oalign );
     1119        size_t ndsize = dataStorage( bsize, naddr, header ); // data storage avilable in bucket
     1120        // To preserve prior fill, the entire bucket must be copied versus the size.
     1121        memcpy( naddr, oaddr, MIN( odsize, ndsize ) );          // copy bytes
     1122        free( oaddr );
     1123        return naddr;
     1124} // realloc
     1125
     1126
    10601127// Local Variables: //
    10611128// tab-width: 4 //
  • libcfa/src/interpose.cfa

    r807a632 r3b56166  
    1010// Created On       : Wed Mar 29 16:10:31 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jul 14 22:57:16 2019
    13 // Update Count     : 116
     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
     
    9596        void __cfaabi_interpose_startup(void)  __attribute__(( constructor( STARTUP_PRIORITY_CORE ) ));
    9697        void __cfaabi_interpose_startup( void ) {
    97                 const char *version = NULL;
     98                const char *version = 0p;
    9899
    99100                preload_libgcc();
     
    105106#pragma GCC diagnostic pop
    106107
     108                // As a precaution (and necessity), errors that result in termination are delivered on a separate stack because
     109                // task stacks might be very small (4K) and the signal delivery corrupts memory to the point that a clean
     110                // shutdown is impossible. Also, when a stack overflow encounters the non-accessible sentinel page (debug only)
     111                // and generates a segment fault, the signal cannot be delivered on the sentinel page. Finally, calls to abort
     112                // print a stack trace that uses substantial stack space.
     113
     114                #define MINSTKSZ SIGSTKSZ * 8
     115                static char stack[MINSTKSZ] __attribute__(( aligned (16) ));
     116                static stack_t ss;
     117
     118                ss.ss_sp = stack;
     119                ss.ss_size = MINSTKSZ;
     120                ss.ss_flags = 0;
     121                if ( sigaltstack( &ss, 0p ) == -1 ) {
     122                        abort( "__cfaabi_interpose_startup : internal error, sigaltstack error(%d) %s.", errno, strerror( errno ) );
     123                } // if
     124
    107125                // Failure handler
    108                 __cfaabi_sigaction( SIGSEGV, sigHandler_segv , SA_SIGINFO );
    109                 __cfaabi_sigaction( SIGBUS , sigHandler_segv , SA_SIGINFO );
    110                 __cfaabi_sigaction( SIGILL , sigHandler_ill  , SA_SIGINFO );
    111                 __cfaabi_sigaction( SIGFPE , sigHandler_fpe  , SA_SIGINFO );
    112                 __cfaabi_sigaction( SIGABRT, sigHandler_abrt, SA_SIGINFO | SA_RESETHAND);
    113                 __cfaabi_sigaction( SIGTERM, sigHandler_term , SA_SIGINFO );
    114                 __cfaabi_sigaction( SIGINT , sigHandler_term , SA_SIGINFO );
     126                __cfaabi_sigaction( SIGSEGV, sigHandler_segv, SA_SIGINFO | SA_ONSTACK );
     127                __cfaabi_sigaction( SIGBUS , sigHandler_segv, SA_SIGINFO | SA_ONSTACK );
     128                __cfaabi_sigaction( SIGILL , sigHandler_ill , SA_SIGINFO | SA_ONSTACK );
     129                __cfaabi_sigaction( SIGFPE , sigHandler_fpe , SA_SIGINFO | SA_ONSTACK );
     130                __cfaabi_sigaction( SIGTERM, sigHandler_term, SA_SIGINFO | SA_ONSTACK | SA_RESETHAND ); // one shot handler, return to default
     131                __cfaabi_sigaction( SIGINT , sigHandler_term, SA_SIGINFO | SA_ONSTACK | SA_RESETHAND );
     132                __cfaabi_sigaction( SIGABRT, sigHandler_term, SA_SIGINFO | SA_ONSTACK | SA_RESETHAND );
     133                __cfaabi_sigaction( SIGHUP , sigHandler_term, SA_SIGINFO | SA_ONSTACK | SA_RESETHAND ); // terminal hangup
    115134        }
    116135}
     
    123142void exit( int status, const char fmt[], ... ) __attribute__(( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ ));
    124143void abort( const char fmt[], ... ) __attribute__(( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
     144void abort( bool signalAbort, const char fmt[], ... ) __attribute__(( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ ));
    125145
    126146extern "C" {
    127147        void abort( void ) __attribute__(( __nothrow__, __leaf__, __noreturn__ )) {
    128                 abort( NULL );
     148                abort( false, "%s", "" );
    129149        }
    130150
     
    132152                va_list argp;
    133153                va_start( argp, fmt );
    134                 abort( fmt, argp );
     154                abort( false, fmt, argp );
    135155                va_end( argp );
    136156        }
     
    141161}
    142162
    143 void * kernel_abort    ( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return NULL; }
    144 void   kernel_abort_msg( void * data, char * buffer, int size ) __attribute__(( __nothrow__, __leaf__, __weak__ )) {}
     163void * kernel_abort( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return 0p; }
     164void kernel_abort_msg( void * data, char buffer[], int size ) __attribute__(( __nothrow__, __leaf__, __weak__ )) {}
     165// See concurrency/kernel.cfa for strong definition used in multi-processor mode.
    145166int kernel_abort_lastframe( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return 4; }
    146167
    147168enum { abort_text_size = 1024 };
    148169static char abort_text[ abort_text_size ];
    149 static int abort_lastframe;
    150 
    151 void exit( int status, const char fmt[], ... ) __attribute__(( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ )) {
    152     va_list args;
    153     va_start( args, fmt );
    154     vfprintf( stderr, fmt, args );
    155     va_end( args );
    156         __cabi_libc.exit( status );
    157 }
    158 
    159 void abort( const char fmt[], ... ) __attribute__(( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )) {
    160         void * kernel_data = kernel_abort();                    // must be done here to lock down kernel
    161         int len;
    162 
    163         abort_lastframe = kernel_abort_lastframe();
    164         len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid)
    165         __cfaabi_dbg_bits_write( abort_text, len );
    166 
    167         if ( fmt ) {
    168                 va_list args;
    169                 va_start( args, fmt );
    170 
    171                 len = vsnprintf( abort_text, abort_text_size, fmt, args );
    172                 va_end( args );
    173                 __cfaabi_dbg_bits_write( abort_text, len );
    174 
    175                 if ( fmt[strlen( fmt ) - 1] != '\n' ) {         // add optional newline if missing at the end of the format text
    176                         __cfaabi_dbg_bits_write( "\n", 1 );
    177                 }
    178         }
    179 
    180         kernel_abort_msg( kernel_data, abort_text, abort_text_size );
    181         __cabi_libc.abort();
    182 }
    183 
    184 static void __cfaabi_backtrace() {
    185         enum {
    186                 Frames = 50,                                                                    // maximum number of stack frames
    187                 Start = 8,                                                                              // skip first N stack frames
    188         };
     170
     171static void __cfaabi_backtrace( int start ) {
     172        enum { Frames = 50, };                                                          // maximum number of stack frames
     173        int last = kernel_abort_lastframe();                            // skip last N stack frames
    189174
    190175        void * array[Frames];
    191176        size_t size = backtrace( array, Frames );
    192         char ** messages = backtrace_symbols( array, size );
    193 
    194         // find executable name
    195         *index( messages[0], '(' ) = '\0';
    196         __cfaabi_dbg_bits_print_nolock( "Stack back trace for: %s\n", messages[0]);
    197 
    198         for ( int i = Start; i < size - abort_lastframe && messages != NULL; i += 1 ) {
    199                 char * name = NULL, * offset_begin = NULL, * offset_end = NULL;
    200 
    201                 for ( char * p = messages[i]; *p; ++p ) {
    202                         //__cfaabi_dbg_bits_print_nolock( "X %s\n", p);
    203                         // find parantheses and +offset
     177        char ** messages = backtrace_symbols( array, size ); // does not demangle names
     178
     179        *index( messages[0], '(' ) = '\0';                                      // find executable name
     180        __cfaabi_bits_print_nolock( STDERR_FILENO, "Stack back trace for: %s\n", messages[0]);
     181
     182        for ( unsigned int i = start; i < size - last && messages != 0p; i += 1 ) {
     183                char * name = 0p, * offset_begin = 0p, * offset_end = 0p;
     184
     185                for ( char * p = messages[i]; *p; p += 1 ) {    // find parantheses and +offset
     186                        //__cfaabi_bits_print_nolock( "X %s\n", p);
    204187                        if ( *p == '(' ) {
    205188                                name = p;
     
    212195                }
    213196
    214                 // if line contains symbol print it
    215                 int frameNo = i - Start;
     197                // if line contains symbol, print it
     198                int frameNo = i - start;
    216199                if ( name && offset_begin && offset_end && name < offset_begin ) {
    217                         // delimit strings
    218                         *name++ = '\0';
     200                        *name++ = '\0';                                                         // delimit strings
    219201                        *offset_begin++ = '\0';
    220202                        *offset_end++ = '\0';
    221203
    222                         __cfaabi_dbg_bits_print_nolock( "(%i) %s : %s + %s %s\n", frameNo, messages[i], name, offset_begin, offset_end);
     204                        __cfaabi_bits_print_nolock( STDERR_FILENO, "(%i) %s : %s + %s %s\n", frameNo, messages[i], name, offset_begin, offset_end);
    223205                } else {                                                                                // otherwise, print the whole line
    224                         __cfaabi_dbg_bits_print_nolock( "(%i) %s\n", frameNo, messages[i] );
     206                        __cfaabi_bits_print_nolock( STDERR_FILENO, "(%i) %s\n", frameNo, messages[i] );
    225207                }
    226208        }
     
    228210}
    229211
     212void exit( int status, const char fmt[], ... ) {
     213        va_list args;
     214        va_start( args, fmt );
     215        vfprintf( stderr, fmt, args );
     216        va_end( args );
     217        __cabi_libc.exit( status );
     218}
     219
     220void abort( bool signalAbort, const char fmt[], ... ) {
     221        void * kernel_data = kernel_abort();                            // must be done here to lock down kernel
     222        int len;
     223
     224        signal( SIGABRT, SIG_DFL );                                                     // prevent final "real" abort from recursing to handler
     225
     226        len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid)
     227        __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
     228
     229        assert( fmt );
     230        va_list args;
     231        va_start( args, fmt );
     232
     233        len = vsnprintf( abort_text, abort_text_size, fmt, args );
     234        va_end( args );
     235        __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
     236
     237        if ( fmt[strlen( fmt ) - 1] != '\n' ) {                         // add optional newline if missing at the end of the format text
     238                __cfaabi_dbg_write( "\n", 1 );
     239        }
     240
     241        kernel_abort_msg( kernel_data, abort_text, abort_text_size );
     242        __cfaabi_backtrace( signalAbort ? 4 : 3 );
     243
     244        __cabi_libc.abort();                                                            // print stack trace in handler
     245}
     246
     247void abort( const char fmt[], ... ) {
     248        va_list args;
     249        va_start( args, fmt );
     250        abort( false, fmt, args );
     251        va_end( args );
     252}
     253
    230254void sigHandler_segv( __CFA_SIGPARMS__ ) {
    231         abort( "Addressing invalid memory at location %p\n"
    232                         "Possible cause is reading outside the address space or writing to a protected area within the address space with an invalid pointer or subscript.\n",
    233                         sfp->si_addr );
     255                if ( sfp->si_addr == 0p ) {
     256                        abort( true, "Null pointer (0p) dereference.\n" );
     257                } else {
     258                        abort( true, "%s at memory location %p.\n"
     259                                   "Possible cause is reading outside the address space or writing to a protected area within the address space with an invalid pointer or subscript.\n",
     260                                   (sig == SIGSEGV ? "Segment fault" : "Bus error"), sfp->si_addr );
     261                }
    234262}
    235263
    236264void sigHandler_ill( __CFA_SIGPARMS__ ) {
    237         abort( "Executing illegal instruction at location %p.\n"
     265        abort( true, "Executing illegal instruction at location %p.\n"
    238266                        "Possible cause is stack corruption.\n",
    239267                        sfp->si_addr );
     
    251279          default: msg = "unknown";
    252280        } // choose
    253         abort( "Computation error %s at location %p.\n", msg, sfp->si_addr );
    254 }
    255 
    256 void sigHandler_abrt( __CFA_SIGPARMS__ ) {
    257         __cfaabi_backtrace();
    258 
    259         // reset default signal handler
    260         __cfaabi_sigdefault( SIGABRT );
    261 
    262         raise( SIGABRT );
     281        abort( true, "Computation error %s at location %p.\n", msg, sfp->si_addr );
    263282}
    264283
    265284void sigHandler_term( __CFA_SIGPARMS__ ) {
    266         abort( "Application stopped by %s signal.", sig == SIGINT ? "an interrupt (SIGINT)" : "a terminate (SIGTERM)" );
     285        abort( true, "Application interrupted by signal: %s.\n", strsignal( sig ) );
    267286}
    268287
  • libcfa/src/iostream.cfa

    r807a632 r3b56166  
    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

    r807a632 r3b56166  
    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

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

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

    r807a632 r3b56166  
    1010// Created On       : Tue Jul 24 16:21:57 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jul 25 16:42:01 2018
    13 // Update Count     : 11
     12// Last Modified On : Tue Feb  4 13:03:18 2020
     13// Update Count     : 30
    1414//
    1515
     16#include <time.h>                                                                               // tzset
    1617#include "startup.hfa"
    17 #include <unistd.h>
    18 
    1918
    2019extern "C" {
    21     static void __cfaabi_appready_startup( void ) __attribute__(( constructor( STARTUP_PRIORITY_APPREADY ) ));
     20    void __cfaabi_appready_startup( void ) __attribute__(( constructor( STARTUP_PRIORITY_APPREADY ) ));
    2221    void __cfaabi_appready_startup( void ) {
     22                tzset();                                                                                // initialize time global variables
    2323                #ifdef __CFA_DEBUG__
    2424                extern void heapAppStart();
     
    2727    } // __cfaabi_appready_startup
    2828
    29     static void __cfaabi_appready_shutdown( void ) __attribute__(( destructor( STARTUP_PRIORITY_APPREADY ) ));
     29    void __cfaabi_appready_shutdown( void ) __attribute__(( destructor( STARTUP_PRIORITY_APPREADY ) ));
    3030    void __cfaabi_appready_shutdown( void ) {
    3131                #ifdef __CFA_DEBUG__
     
    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

    r807a632 r3b56166  
    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

    r807a632 r3b56166  
    1010// Created On       : Tue Jul 18 07:26:04 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jul 22 13:49:30 2018
    13 // Update Count     : 4
     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

    r807a632 r3b56166  
    1010// Created On       : Tue Jul 18 07:45:00 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jul 22 13:49:58 2018
    13 // Update Count     : 4
     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

    r807a632 r3b56166  
    1010// Created On       : Tue Jul 18 07:55:44 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jul 22 13:50:24 2018
    13 // Update Count     : 4
     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

    r807a632 r3b56166  
    1010// Created On       : Mon Jul  4 23:25:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 22 18:16:07 2018
    13 // Update Count     : 13
     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

    r807a632 r3b56166  
    1010// Created On       : Thu Feb  8 23:48:16 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb  8 23:50:44 2018
    13 // Update Count     : 4
     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

    r807a632 r3b56166  
    1010// Created On       : Thu Jan 28 17:10:29 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Oct 22 08:57:52 2019
    13 // Update Count     : 478
     12// Last Modified On : Tue Feb  4 08:27:08 2020
     13// Update Count     : 486
    1414//
    1515
     
    3030        T * alloc_set( T ptr[], size_t dim, char fill ) {       // realloc array with fill
    3131                size_t olen = malloc_usable_size( ptr );                // current allocation
    32                 char * nptr = (char *)realloc( (void *)ptr, dim * sizeof(T) ); // C realloc
     32                void * nptr = (void *)realloc( (void *)ptr, dim * sizeof(T) ); // C realloc
    3333                size_t nlen = malloc_usable_size( nptr );               // new allocation
    3434                if ( nlen > olen ) {                                                    // larger ?
    35                         memset( nptr + olen, (int)fill, nlen - olen ); // initialize added storage
     35                        memset( (char *)nptr + olen, (int)fill, nlen - olen ); // initialize added storage
    3636                } // if
    3737                return (T *)nptr;
    3838        } // alloc_set
    3939
    40         T * alloc_align( T ptr[], size_t align ) {                      // aligned realloc array
    41                 char * nptr;
    42                 size_t alignment = malloc_alignment( ptr );
    43                 if ( align != alignment && (uintptr_t)ptr % align != 0 ) {
    44                         size_t olen = malloc_usable_size( ptr );        // current allocation
    45                         nptr = (char *)memalign( align, olen );
    46                         size_t nlen = malloc_usable_size( nptr );       // new allocation
    47                         size_t lnth = olen < nlen ? olen : nlen;        // min
    48                         memcpy( nptr, ptr, lnth );                                      // initialize storage
    49                         free( ptr );
    50                 } else {
    51                         nptr = (char *)ptr;
    52                 } // if
    53                 return (T *)nptr;
    54         } // alloc_align
    55 
    56         T * alloc_align( T ptr[], size_t align, size_t dim ) { // aligned realloc array
    57                 char * nptr;
    58                 size_t alignment = malloc_alignment( ptr );
    59                 if ( align != alignment ) {
    60                         size_t olen = malloc_usable_size( ptr );        // current allocation
    61                         nptr = (char *)memalign( align, dim * sizeof(T) );
    62                         size_t nlen = malloc_usable_size( nptr );       // new allocation
    63                         size_t lnth = olen < nlen ? olen : nlen;        // min
    64                         memcpy( nptr, ptr, lnth );                                      // initialize storage
    65                         free( ptr );
    66                 } else {
    67                         nptr = (char *)realloc( (void *)ptr, dim * sizeof(T) ); // C realloc
    68                 } // if
    69                 return (T *)nptr;
    70         } // alloc_align
    71 
    7240        T * alloc_align_set( T ptr[], size_t align, char fill ) { // aligned realloc with fill
    7341                size_t olen = malloc_usable_size( ptr );                // current allocation
    74                 char * nptr = alloc_align( ptr, align );
     42                void * nptr = (void *)realloc( (void *)ptr, align, sizeof(T) ); // CFA realloc
     43                // char * nptr = alloc_align( ptr, align );
    7544                size_t nlen = malloc_usable_size( nptr );               // new allocation
    7645                if ( nlen > olen ) {                                                    // larger ?
    77                         memset( nptr + olen, (int)fill, nlen - olen ); // initialize added storage
     46                        memset( (char *)nptr + olen, (int)fill, nlen - olen ); // initialize added storage
    7847                } // if
    7948                return (T *)nptr;
     
    138107//---------------------------------------
    139108
    140 float _Complex strto( const char * sptr, char ** eptr ) {
     109float _Complex strto( const char sptr[], char ** eptr ) {
    141110        float re, im;
    142111        char * eeptr;
     
    149118} // strto
    150119
    151 double _Complex strto( const char * sptr, char ** eptr ) {
     120double _Complex strto( const char sptr[], char ** eptr ) {
    152121        double re, im;
    153122        char * eeptr;
     
    160129} // strto
    161130
    162 long double _Complex strto( const char * sptr, char ** eptr ) {
     131long double _Complex strto( const char sptr[], char ** eptr ) {
    163132        long double re, im;
    164133        char * eeptr;
  • libcfa/src/stdlib.hfa

    r807a632 r3b56166  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Oct 20 22:57:33 2019
    13 // Update Count     : 390
     12// Last Modified On : Tue Feb  4 08:27:01 2020
     13// Update Count     : 401
    1414//
    1515
     
    2828} // extern "C"
    2929
     30void * realloc( void * oaddr, size_t nalign, size_t size ); // CFA heap
     31
    3032//---------------------------------------
    3133
     
    5052        } // calloc
    5153
    52         T * realloc( T * ptr, size_t size ) {
    53                 if ( unlikely( ptr == 0 ) ) return malloc();
     54        T * realloc( T * ptr, size_t size ) {                           // CFA realloc, eliminate return-type cast
    5455                return (T *)(void *)realloc( (void *)ptr, size ); // C realloc
    5556        } // realloc
     
    5960        } // memalign
    6061
     62        T * cmemalign( size_t align, size_t dim  ) {
     63                return (T *)cmemalign( align, dim, sizeof(T) ); // CFA cmemalign
     64        } // cmemalign
     65
    6166        T * aligned_alloc( size_t align ) {
    6267                return (T *)aligned_alloc( align, sizeof(T) );  // C aligned_alloc
     
    7984
    8085        T * alloc( T ptr[], size_t dim ) {                                      // realloc
    81                 return realloc( ptr, dim * sizeof(T) );
     86                return (T *)(void *)realloc( (void *)ptr, dim * sizeof(T) ); // C realloc
    8287        } // alloc
    8388
     
    118123        } // alloc_align
    119124
     125        T * alloc_align( T ptr[], size_t align ) {                      // aligned realloc array
     126                return (T *)(void *)realloc( (void *)ptr, align, sizeof(T) ); // CFA realloc
     127        } // alloc_align
     128
     129        T * alloc_align( T ptr[], size_t align, size_t dim ) { // aligned realloc array
     130                return (T *)(void *)realloc( (void *)ptr, align, dim * sizeof(T) ); // CFA realloc
     131        } // alloc_align
     132
    120133        T * alloc_align_set( size_t align, char fill ) {
    121134                return (T *)memset( (T *)alloc_align( align ), (int)fill, sizeof(T) ); // initialize with fill value
     
    142155
    143156forall( dtype T | sized(T) ) {
    144         T * alloc_align( T ptr[], size_t align );                       // realign
    145         T * alloc_align( T ptr[], size_t align, size_t dim ); // aligned realloc array
    146157        T * alloc_align_set( T ptr[], size_t align, size_t dim, char fill ); // aligned realloc array with fill
    147158} // distribution
     
    182193
    183194static inline {
    184         int strto( const char * sptr, char ** eptr, int base ) { return (int)strtol( sptr, eptr, base ); }
    185         unsigned int strto( const char * sptr, char ** eptr, int base ) { return (unsigned int)strtoul( sptr, eptr, base ); }
    186         long int strto( const char * sptr, char ** eptr, int base ) { return strtol( sptr, eptr, base ); }
    187         unsigned long int strto( const char * sptr, char ** eptr, int base ) { return strtoul( sptr, eptr, base ); }
    188         long long int strto( const char * sptr, char ** eptr, int base ) { return strtoll( sptr, eptr, base ); }
    189         unsigned long long int strto( const char * sptr, char ** eptr, int base ) { return strtoull( sptr, eptr, base ); }
    190 
    191         float strto( const char * sptr, char ** eptr ) { return strtof( sptr, eptr ); }
    192         double strto( const char * sptr, char ** eptr ) { return strtod( sptr, eptr ); }
    193         long double strto( const char * sptr, char ** eptr ) { return strtold( sptr, eptr ); }
    194 } // distribution
    195 
    196 float _Complex strto( const char * sptr, char ** eptr );
    197 double _Complex strto( const char * sptr, char ** eptr );
    198 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 );
    199210
    200211static inline {
    201         int ato( const char * sptr ) { return (int)strtol( sptr, 0, 10 ); }
    202         unsigned int ato( const char * sptr ) { return (unsigned int)strtoul( sptr, 0, 10 ); }
    203         long int ato( const char * sptr ) { return strtol( sptr, 0, 10 ); }
    204         unsigned long int ato( const char * sptr ) { return strtoul( sptr, 0, 10 ); }
    205         long long int ato( const char * sptr ) { return strtoll( sptr, 0, 10 ); }
    206         unsigned long long int ato( const char * sptr ) { return strtoull( sptr, 0, 10 ); }
    207 
    208         float ato( const char * sptr ) { return strtof( sptr, 0 ); }
    209         double ato( const char * sptr ) { return strtod( sptr, 0 ); }
    210         long double ato( const char * sptr ) { return strtold( sptr, 0 ); }
    211 
    212         float _Complex ato( const char * sptr ) { return strto( sptr, NULL ); }
    213         double _Complex ato( const char * sptr ) { return strto( sptr, NULL ); }
    214         long double _Complex ato( const char * sptr ) { return strto( sptr, NULL ); }
     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 ); }
    215226} // distribution
    216227
  • libcfa/src/time.cfa

    r807a632 r3b56166  
    1010// Created On       : Tue Mar 27 13:33:14 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 13 08:41:55 2019
    13 // Update Count     : 65
     12// Last Modified On : Tue Feb  4 08:24:18 2020
     13// Update Count     : 70
    1414//
    1515
     
    3333forall( dtype ostype | ostream( ostype ) ) {
    3434        ostype & ?|?( ostype & os, Duration dur ) with( dur ) {
    35                 (ostype &)(os | tv / TIMEGRAN);                                 // print seconds
    36                 long int ns = (tv < 0 ? -tv : tv) % TIMEGRAN;   // compute nanoseconds
     35                (ostype &)(os | tn / TIMEGRAN);                                 // print seconds
     36                long int ns = (tn < 0 ? -tn : tn) % TIMEGRAN;   // compute nanoseconds
    3737                if ( ns != 0 ) {                                                                // some ?
    3838                        char buf[16];
     
    5252
    5353#ifdef __CFA_DEBUG__
    54 static void tabort( int year, int month, int day, int hour, int min, int sec, int nsec ) {
     54static void tabort( int year, int month, int day, int hour, int min, int sec, int64_t nsec ) {
    5555        abort | "Attempt to create Time( year=" | year | "(>=1970), month=" | month | "(1-12), day=" | day | "(1-31), hour=" | hour | "(0-23), min=" | min | "(0-59), sec=" | sec
    56                   | "(0-60), nsec=" | nsec | "(0-999_999_999), which exceeds range 00:00:00 UTC, January 1, 1970 to 03:14:07 UTC, January 19, 2038.";
     56                  | "(0-60), nsec=" | nsec | "(0-999_999_999), which is not in the range 00:00:00 UTC, January 1, 1970 to 03:14:07 UTC, January 19, 2038, where month and day have 1 origin.";
    5757} // tabort
    5858#endif // __CFA_DEBUG__
    5959
    60 void ?{}( Time & time, int year, int month, int day, int hour, int min, int sec, int nsec ) with( time ) {
     60void ?{}( Time & time, int year, int month, int day, int hour, int min, int sec, int64_t nsec ) with( time ) {
    6161        tm tm;
    6262
    63         tm.tm_isdst = -1;                                                                       // let mktime determine if alternate timezone is in effect
     63        // Values can be in any range (+/-) but result must be in the epoch.
    6464        tm.tm_year = year - 1900;                                                       // mktime uses 1900 as its starting point
    65 #ifdef __CFA_DEBUG__
    66         if ( month < 1 || 12 < month ) {
    67                 tabort( year, month, day, hour, min, sec, nsec );
    68         } // if
    69 #endif // __CFA_DEBUG__
     65        // Make month in range 1-12 to match with day.
    7066        tm.tm_mon = month - 1;                                                          // mktime uses range 0-11
    71 #ifdef __CFA_DEBUG__
    72         if ( day < 1 || 31 < day ) {
    73                 tabort( year, month, day, hour, min, sec, nsec );
    74         } // if
    75 #endif // __CFA_DEBUG__
    7667        tm.tm_mday = day;                                                                       // mktime uses range 1-31
    7768        tm.tm_hour = hour;
    7869        tm.tm_min = min;
    7970        tm.tm_sec = sec;
     71        tm.tm_isdst = -1;                                                                       // let mktime determine if alternate timezone is in effect
    8072        time_t epochsec = mktime( &tm );
    8173#ifdef __CFA_DEBUG__
    82         if ( epochsec == (time_t)-1 ) {
     74        if ( epochsec <= (time_t)-1 ) {                                         // MUST BE LESS THAN OR EQUAL!
    8375                tabort( year, month, day, hour, min, sec, nsec );
    8476        } // if
    8577#endif // __CFA_DEBUG__
    86         tv = (int64_t)(epochsec) * TIMEGRAN + nsec;                     // convert to nanoseconds
     78        tn = (int64_t)(epochsec) * TIMEGRAN + nsec;                     // convert to nanoseconds
    8779#ifdef __CFA_DEBUG__
    88         if ( tv > 2147483647LL * TIMEGRAN ) {                           // between 00:00:00 UTC, January 1, 1970 and 03:14:07 UTC, January 19, 2038.
     80        if ( tn > 2147483647LL * TIMEGRAN ) {                           // between 00:00:00 UTC, January 1, 1970 and 03:14:07 UTC, January 19, 2038.
    8981                tabort( year, month, day, hour, min, sec, nsec );
    9082        } // if
     
    9385
    9486char * yy_mm_dd( Time time, char * buf ) with( time ) {
    95         time_t s = tv / TIMEGRAN;
     87        time_t s = tn / TIMEGRAN;
    9688        tm tm;
    9789        gmtime_r( &s, &tm );                                                            // tm_mon <= 11, tm_mday <= 31
     
    108100
    109101char * mm_dd_yy( Time time, char * buf ) with( time ) {
    110         time_t s = tv / TIMEGRAN;
     102        time_t s = tn / TIMEGRAN;
    111103        tm tm;
    112104        gmtime_r( &s, &tm );                                                            // tm_mon <= 11, tm_mday <= 31
     
    123115
    124116char * dd_mm_yy( Time time, char * buf ) with( time ) {
    125         time_t s = tv / TIMEGRAN;
     117        time_t s = tn / TIMEGRAN;
    126118        tm tm;
    127119        gmtime_r( &s, &tm );                                                            // tm_mon <= 11, tm_mday <= 31
     
    137129} // dd_mm_yy
    138130
    139 size_t strftime( char * buf, size_t size, const char * fmt, Time time ) with( time ) {
    140         time_t s = tv / TIMEGRAN;
     131size_t strftime( char buf[], size_t size, const char fmt[], Time time ) with( time ) {
     132        time_t s = tn / TIMEGRAN;
    141133        tm tm;
    142134        gmtime_r( &s, &tm );
     
    147139        ostype & ?|?( ostype & os, Time time ) with( time ) {
    148140                char buf[32];                                                                   // at least 26
    149                 time_t s = tv / TIMEGRAN;
     141                time_t s = tn / TIMEGRAN;
    150142                ctime_r( &s, (char *)&buf );                                    // 26 characters: "Wed Jun 30 21:49:08 1993\n"
    151143                buf[24] = '\0';                                                                 // remove trailing '\n'
    152                 long int ns = (tv < 0 ? -tv : tv) % TIMEGRAN;   // compute nanoseconds
     144                long int ns = (tn < 0 ? -tn : tn) % TIMEGRAN;   // compute nanoseconds
    153145                if ( ns == 0 ) {                                                                // none ?
    154146                        (ostype &)(os | buf);                                           // print date/time/year
  • libcfa/src/time.hfa

    r807a632 r3b56166  
    1010// Created On       : Wed Mar 14 23:18:57 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Sep 22 12:25:34 2018
    13 // Update Count     : 643
     12// Last Modified On : Tue Feb  4 08:24:32 2020
     13// Update Count     : 654
    1414//
    1515
     
    3232        Duration ?=?( Duration & dur, __attribute__((unused)) zero_t ) { return dur{ 0 }; }
    3333
    34         Duration +?( Duration rhs ) with( rhs ) {       return (Duration)@{ +tv }; }
    35         Duration ?+?( Duration & lhs, Duration rhs ) { return (Duration)@{ lhs.tv + rhs.tv }; }
     34        Duration +?( Duration rhs ) with( rhs ) { return (Duration)@{ +tn }; }
     35        Duration ?+?( Duration & lhs, Duration rhs ) { return (Duration)@{ lhs.tn + rhs.tn }; }
    3636        Duration ?+=?( Duration & lhs, Duration rhs ) { lhs = lhs + rhs; return lhs; }
    3737
    38         Duration -?( Duration rhs ) with( rhs ) { return (Duration)@{ -tv }; }
    39         Duration ?-?( Duration & lhs, Duration rhs ) { return (Duration)@{ lhs.tv - rhs.tv }; }
     38        Duration -?( Duration rhs ) with( rhs ) { return (Duration)@{ -tn }; }
     39        Duration ?-?( Duration & lhs, Duration rhs ) { return (Duration)@{ lhs.tn - rhs.tn }; }
    4040        Duration ?-=?( Duration & lhs, Duration rhs ) { lhs = lhs - rhs; return lhs; }
    4141
    42         Duration ?*?( Duration lhs, int64_t rhs ) { return (Duration)@{ lhs.tv * rhs }; }
    43         Duration ?*?( int64_t lhs, Duration rhs ) { return (Duration)@{ lhs * rhs.tv }; }
     42        Duration ?*?( Duration lhs, int64_t rhs ) { return (Duration)@{ lhs.tn * rhs }; }
     43        Duration ?*?( int64_t lhs, Duration rhs ) { return (Duration)@{ lhs * rhs.tn }; }
    4444        Duration ?*=?( Duration & lhs, int64_t rhs ) { lhs = lhs * rhs; return lhs; }
    4545
    46         int64_t ?/?( Duration lhs, Duration rhs ) { return lhs.tv / rhs.tv; }
    47         Duration ?/?( Duration lhs, int64_t rhs ) { return (Duration)@{ lhs.tv / rhs }; }
     46        int64_t ?/?( Duration lhs, Duration rhs ) { return lhs.tn / rhs.tn; }
     47        Duration ?/?( Duration lhs, int64_t rhs ) { return (Duration)@{ lhs.tn / rhs }; }
    4848        Duration ?/=?( Duration & lhs, int64_t rhs ) { lhs = lhs / rhs; return lhs; }
    49         double div( Duration lhs, Duration rhs ) { return (double)lhs.tv / (double)rhs.tv; }
    50 
    51         Duration ?%?( Duration lhs, Duration rhs ) { return (Duration)@{ lhs.tv % rhs.tv }; }
     49        double div( Duration lhs, Duration rhs ) { return (double)lhs.tn / (double)rhs.tn; }
     50
     51        Duration ?%?( Duration lhs, Duration rhs ) { return (Duration)@{ lhs.tn % rhs.tn }; }
    5252        Duration ?%=?( Duration & lhs, Duration rhs ) { lhs = lhs % rhs; return lhs; }
    5353
    54         bool ?==?( Duration lhs, Duration rhs ) { return lhs.tv == rhs.tv; }
    55         bool ?!=?( Duration lhs, Duration rhs ) { return lhs.tv != rhs.tv; }
    56         bool ?<? ( Duration lhs, Duration rhs ) { return lhs.tv <  rhs.tv; }
    57         bool ?<=?( Duration lhs, Duration rhs ) { return lhs.tv <= rhs.tv; }
    58         bool ?>? ( Duration lhs, Duration rhs ) { return lhs.tv >  rhs.tv; }
    59         bool ?>=?( Duration lhs, Duration rhs ) { return lhs.tv >= rhs.tv; }
    60 
    61         bool ?==?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tv == 0; }
    62         bool ?!=?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tv != 0; }
    63         bool ?<? ( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tv <  0; }
    64         bool ?<=?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tv <= 0; }
    65         bool ?>? ( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tv >  0; }
    66         bool ?>=?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tv >= 0; }
    67 
    68         Duration abs( Duration rhs ) { return rhs.tv >= 0 ? rhs : -rhs; }
     54        bool ?==?( Duration lhs, Duration rhs ) { return lhs.tn == rhs.tn; }
     55        bool ?!=?( Duration lhs, Duration rhs ) { return lhs.tn != rhs.tn; }
     56        bool ?<? ( Duration lhs, Duration rhs ) { return lhs.tn <  rhs.tn; }
     57        bool ?<=?( Duration lhs, Duration rhs ) { return lhs.tn <= rhs.tn; }
     58        bool ?>? ( Duration lhs, Duration rhs ) { return lhs.tn >  rhs.tn; }
     59        bool ?>=?( Duration lhs, Duration rhs ) { return lhs.tn >= rhs.tn; }
     60
     61        bool ?==?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tn == 0; }
     62        bool ?!=?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tn != 0; }
     63        bool ?<? ( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tn <  0; }
     64        bool ?<=?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tn <= 0; }
     65        bool ?>? ( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tn >  0; }
     66        bool ?>=?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tn >= 0; }
     67
     68        Duration abs( Duration rhs ) { return rhs.tn >= 0 ? rhs : -rhs; }
    6969
    7070        Duration ?`ns( int64_t nsec ) { return (Duration)@{ nsec }; }
     
    8282        Duration ?`w( double weeks ) { return (Duration)@{ weeks * (7LL * 24LL * 60LL * 60LL * TIMEGRAN) }; }
    8383
    84         int64_t ?`ns( Duration dur ) { return dur.tv; }
    85         int64_t ?`us( Duration dur ) { return dur.tv / (TIMEGRAN / 1_000_000LL); }
    86         int64_t ?`ms( Duration dur ) { return dur.tv / (TIMEGRAN / 1_000LL); }
    87         int64_t ?`s( Duration dur ) { return dur.tv / TIMEGRAN; }
    88         int64_t ?`m( Duration dur ) { return dur.tv / (60LL * TIMEGRAN); }
    89         int64_t ?`h( Duration dur ) { return dur.tv / (60LL * 60LL * TIMEGRAN); }
    90         int64_t ?`d( Duration dur ) { return dur.tv / (24LL * 60LL * 60LL * TIMEGRAN); }
    91         int64_t ?`w( Duration dur ) { return dur.tv / (7LL * 24LL * 60LL * 60LL * TIMEGRAN); }
    92 
    93         Duration max( Duration lhs, Duration rhs ) { return  (lhs.tv < rhs.tv) ? rhs : lhs;}
    94         Duration min( Duration lhs, Duration rhs ) { return !(rhs.tv < lhs.tv) ? lhs : rhs;}
     84        int64_t ?`ns( Duration dur ) { return dur.tn; }
     85        int64_t ?`us( Duration dur ) { return dur.tn / (TIMEGRAN / 1_000_000LL); }
     86        int64_t ?`ms( Duration dur ) { return dur.tn / (TIMEGRAN / 1_000LL); }
     87        int64_t ?`s( Duration dur ) { return dur.tn / TIMEGRAN; }
     88        int64_t ?`m( Duration dur ) { return dur.tn / (60LL * TIMEGRAN); }
     89        int64_t ?`h( Duration dur ) { return dur.tn / (60LL * 60LL * TIMEGRAN); }
     90        int64_t ?`d( Duration dur ) { return dur.tn / (24LL * 60LL * 60LL * TIMEGRAN); }
     91        int64_t ?`w( Duration dur ) { return dur.tn / (7LL * 24LL * 60LL * 60LL * TIMEGRAN); }
     92
     93        Duration max( Duration lhs, Duration rhs ) { return  (lhs.tn < rhs.tn) ? rhs : lhs;}
     94        Duration min( Duration lhs, Duration rhs ) { return !(rhs.tn < lhs.tn) ? lhs : rhs;}
    9595} // distribution
    9696
     
    143143//######################### Time #########################
    144144
    145 void ?{}( Time & time, int year, int month = 0, int day = 0, int hour = 0, int min = 0, int sec = 0, int nsec = 0 );
     145void ?{}( Time & time, int year, int month = 1, int day = 1, int hour = 0, int min = 0, int sec = 0, int64_t nsec = 0 );
    146146static inline {
    147147        Time ?=?( Time & time, __attribute__((unused)) zero_t ) { return time{ 0 }; }
    148148
    149         void ?{}( Time & time, timeval t ) with( time ) { tv = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * 1000; }
     149        void ?{}( Time & time, timeval t ) with( time ) { tn = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * 1000; }
    150150        Time ?=?( Time & time, timeval t ) with( time ) {
    151                 tv = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * (TIMEGRAN / 1_000_000LL);
     151                tn = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * (TIMEGRAN / 1_000_000LL);
    152152                return time;
    153153        } // ?=?
    154154
    155         void ?{}( Time & time, timespec t ) with( time ) { tv = (int64_t)t.tv_sec * TIMEGRAN + t.tv_nsec; }
     155        void ?{}( Time & time, timespec t ) with( time ) { tn = (int64_t)t.tv_sec * TIMEGRAN + t.tv_nsec; }
    156156        Time ?=?( Time & time, timespec t ) with( time ) {
    157                 tv = (int64_t)t.tv_sec * TIMEGRAN + t.tv_nsec;
     157                tn = (int64_t)t.tv_sec * TIMEGRAN + t.tv_nsec;
    158158                return time;
    159159        } // ?=?
    160160
    161         Time ?+?( Time & lhs, Duration rhs ) { return (Time)@{ lhs.tv + rhs.tv }; }
     161        Time ?+?( Time & lhs, Duration rhs ) { return (Time)@{ lhs.tn + rhs.tn }; }
    162162        Time ?+?( Duration lhs, Time rhs ) { return rhs + lhs; }
    163163        Time ?+=?( Time & lhs, Duration rhs ) { lhs = lhs + rhs; return lhs; }
    164164
    165         Duration ?-?( Time lhs, Time rhs ) { return (Duration)@{ lhs.tv - rhs.tv }; }
    166         Time ?-?( Time lhs, Duration rhs ) { return (Time)@{ lhs.tv - rhs.tv }; }
     165        Duration ?-?( Time lhs, Time rhs ) { return (Duration)@{ lhs.tn - rhs.tn }; }
     166        Time ?-?( Time lhs, Duration rhs ) { return (Time)@{ lhs.tn - rhs.tn }; }
    167167        Time ?-=?( Time & lhs, Duration rhs ) { lhs = lhs - rhs; return lhs; }
    168         bool ?==?( Time lhs, Time rhs ) { return lhs.tv == rhs.tv; }
    169         bool ?!=?( Time lhs, Time rhs ) { return lhs.tv != rhs.tv; }
    170         bool ?<?( Time lhs, Time rhs ) { return lhs.tv < rhs.tv; }
    171         bool ?<=?( Time lhs, Time rhs ) { return lhs.tv <= rhs.tv; }
    172         bool ?>?( Time lhs, Time rhs ) { return lhs.tv > rhs.tv; }
    173         bool ?>=?( Time lhs, Time rhs ) { return lhs.tv >= rhs.tv; }
     168        bool ?==?( Time lhs, Time rhs ) { return lhs.tn == rhs.tn; }
     169        bool ?!=?( Time lhs, Time rhs ) { return lhs.tn != rhs.tn; }
     170        bool ?<?( Time lhs, Time rhs ) { return lhs.tn < rhs.tn; }
     171        bool ?<=?( Time lhs, Time rhs ) { return lhs.tn <= rhs.tn; }
     172        bool ?>?( Time lhs, Time rhs ) { return lhs.tn > rhs.tn; }
     173        bool ?>=?( Time lhs, Time rhs ) { return lhs.tn >= rhs.tn; }
     174
     175        int64_t ?`ns( Time t ) { return t.tn; }
    174176} // distribution
    175177
     
    189191} // dmy
    190192
    191 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 );
    192194
    193195//------------------------- timeval (cont) -------------------------
    194196
    195197static inline void ?{}( timeval & t, Time time ) with( t, time ) {
    196         tv_sec = tv / TIMEGRAN;                                                         // seconds
    197         tv_usec = tv % TIMEGRAN / (TIMEGRAN / 1_000_000LL);     // microseconds
     198        tv_sec = tn / TIMEGRAN;                                                         // seconds
     199        tv_usec = tn % TIMEGRAN / (TIMEGRAN / 1_000_000LL);     // microseconds
    198200} // ?{}
    199201
     
    201203
    202204static inline void ?{}( timespec & t, Time time ) with( t, time ) {
    203         tv_sec = tv / TIMEGRAN;                                                         // seconds
    204         tv_nsec = tv % TIMEGRAN;                                                        // nanoseconds
     205        tv_sec = tn / TIMEGRAN;                                                         // seconds
     206        tv_nsec = tn % TIMEGRAN;                                                        // nanoseconds
    205207} // ?{}
    206208
  • libcfa/src/time_t.hfa

    r807a632 r3b56166  
    1010// Created On       : Tue Apr 10 14:42:03 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Apr 13 07:51:47 2018
    13 // Update Count     : 6
     12// Last Modified On : Sun Jan  5 08:22:46 2020
     13// Update Count     : 7
    1414//
    1515
     
    2020
    2121struct Duration {                                                                               // private
    22         int64_t tv;                                                                                     // nanoseconds
     22        int64_t tn;                                                                                     // nanoseconds
    2323}; // Duration
    2424
    25 static inline void ?{}( Duration & dur ) with( dur ) { tv = 0; }
    26 static inline void ?{}( Duration & dur, __attribute__((unused)) zero_t ) with( dur ) { tv = 0; }
     25static inline void ?{}( Duration & dur ) with( dur ) { tn = 0; }
     26static inline void ?{}( Duration & dur, __attribute__((unused)) zero_t ) with( dur ) { tn = 0; }
    2727
    2828
     
    3030
    3131struct Time {                                                                                   // private
    32         uint64_t tv;                                                                            // nanoseconds since UNIX epoch
     32        uint64_t tn;                                                                            // nanoseconds since UNIX epoch
    3333}; // Time
    3434
    35 static inline void ?{}( Time & time ) with( time ) { tv = 0; }
    36 static inline void ?{}( Time & time, __attribute__((unused)) zero_t ) with( time ) { tv = 0; }
     35static inline void ?{}( Time & time ) with( time ) { tn = 0; }
     36static inline void ?{}( Time & time, __attribute__((unused)) zero_t ) with( time ) { tn = 0; }
    3737
    3838// Local Variables: //
  • longrun_tests/Makefile.in

    r807a632 r3b56166  
    486486LTCFACOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
    487487        $(LIBTOOLFLAGS) --mode=compile $(CFACC) $(DEFS) \
    488         $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) \
    489         $(AM_CFLAGS) $(CFLAGS)
     488        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(AM_CFLAGS) $(CFAFLAGS) $(CFLAGS)
    490489
    491490AM_V_CFA = $(am__v_CFA_@AM_V@)
     
    493492am__v_CFA_0 = @echo "  CFA     " $@;
    494493am__v_CFA_1 =
    495 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
    496 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
    497 am__v_JAVAC_0 = @echo "  JAVAC   " $@;
    498 am__v_JAVAC_1 =
    499 AM_V_GOC = $(am__v_GOC_@AM_V@)
    500 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)
    501 am__v_GOC_0 = @echo "  GOC     " $@;
    502 am__v_GOC_1 =
    503494UPPCC = u++
    504495UPPCOMPILE = $(UPPCC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_UPPFLAGS) $(UPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_CFLAGS) $(CFLAGS)
     
    507498am__v_UPP_0 = @echo "  UPP     " $@;
    508499am__v_UPP_1 =
     500AM_V_GOC = $(am__v_GOC_@AM_V@)
     501am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)
     502am__v_GOC_0 = @echo "  GOC     " $@;
     503am__v_GOC_1 =
     504AM_V_RUST = $(am__v_RUST_@AM_V@)
     505am__v_RUST_ = $(am__v_RUST_@AM_DEFAULT_V@)
     506am__v_RUST_0 = @echo "  RUST     " $@;
     507am__v_RUST_1 =
     508AM_V_NODEJS = $(am__v_NODEJS_@AM_V@)
     509am__v_NODEJS_ = $(am__v_NODEJS_@AM_DEFAULT_V@)
     510am__v_NODEJS_0 = @echo "  NODEJS     " $@;
     511am__v_NODEJS_1 =
     512AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
     513am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
     514am__v_JAVAC_0 = @echo "  JAVAC   " $@;
     515am__v_JAVAC_1 =
    509516repeats = 10
    510517max_time = 600
  • src/AST/Convert.cpp

    r807a632 r3b56166  
    1010// Created On       : Thu May 09 15::37::05 2019
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 25 22:21:46 2019
    13 // Update Count     : 13
     12// Last Modified On : Wed Dec 11 21:39:32 2019
     13// Update Count     : 33
    1414//
    1515
     
    245245                auto decl = new StructDecl(
    246246                        node->name,
    247                         node->kind,
     247                        (AggregateDecl::Aggregate)node->kind,
    248248                        get<Attribute>().acceptL( node->attributes ),
    249249                        LinkageSpec::Spec( node->linkage.val )
     
    675675
    676676        const ast::Expr * visit( const ast::KeywordCastExpr * node ) override final {
    677                 KeywordCastExpr::Target castTarget = KeywordCastExpr::NUMBER_OF_TARGETS;
    678                 switch (node->target) {
    679                         case ast::KeywordCastExpr::Coroutine:
    680                                 castTarget = KeywordCastExpr::Coroutine;
    681                                 break;
    682                         case ast::KeywordCastExpr::Thread:
    683                                 castTarget = KeywordCastExpr::Thread;
    684                                 break;
    685                         case ast::KeywordCastExpr::Monitor:
    686                                 castTarget = KeywordCastExpr::Monitor;
    687                                 break;
    688                         default:
    689                                 break;
    690                 }
    691                 assert ( castTarget < KeywordCastExpr::NUMBER_OF_TARGETS );
     677                AggregateDecl::Aggregate castTarget = (AggregateDecl::Aggregate)node->target;
     678                assert( AggregateDecl::Generator <= castTarget && castTarget <= AggregateDecl::Thread );
    692679                auto expr = visitBaseExpr( node,
    693680                        new KeywordCastExpr(
     
    887874                auto expr = visitBaseExpr( node,
    888875                        new AsmExpr(
    889                                 get<Expression>().accept1(node->inout),
     876                                new std::string(node->inout),
    890877                                get<Expression>().accept1(node->constraint),
    891878                                get<Expression>().accept1(node->operand)
     
    12361223                                cv( node ),
    12371224                                node->name,
    1238                                 node->kind == ast::TypeVar::Ftype,
     1225                                node->kind == ast::TypeDecl::Ftype,
    12391226                                get<Attribute>().acceptL( node->attributes )
    12401227                        };
     
    15041491                        old->location,
    15051492                        old->name,
    1506                         old->kind,
     1493                        (ast::AggregateDecl::Aggregate)old->kind,
    15071494                        GET_ACCEPT_V(attributes, Attribute),
    15081495                        { old->linkage.val }
     
    15911578                        { old->storageClasses.val },
    15921579                        GET_ACCEPT_1(base, Type),
    1593                         (ast::TypeVar::Kind)(unsigned)old->kind,
     1580                        (ast::TypeDecl::Kind)(unsigned)old->kind,
    15941581                        old->sized,
    15951582                        GET_ACCEPT_1(init, Type)
     
    20452032        }
    20462033
    2047         virtual void visit( const KeywordCastExpr * old) override final {
    2048                 ast::KeywordCastExpr::Target castTarget = ast::KeywordCastExpr::NUMBER_OF_TARGETS;
    2049                 switch (old->target) {
    2050                         case KeywordCastExpr::Coroutine:
    2051                                 castTarget = ast::KeywordCastExpr::Coroutine;
    2052                                 break;
    2053                         case KeywordCastExpr::Thread:
    2054                                 castTarget = ast::KeywordCastExpr::Thread;
    2055                                 break;
    2056                         case KeywordCastExpr::Monitor:
    2057                                 castTarget = ast::KeywordCastExpr::Monitor;
    2058                                 break;
    2059                         default:
    2060                                 break;
    2061                 }
    2062                 assert ( castTarget < ast::KeywordCastExpr::NUMBER_OF_TARGETS );
     2034        virtual void visit( const KeywordCastExpr * old ) override final {
     2035                ast::AggregateDecl::Aggregate castTarget = (ast::AggregateDecl::Aggregate)old->target;
     2036                assert( ast::AggregateDecl::Generator <= castTarget && castTarget <= ast::AggregateDecl::Thread );
    20632037                this->node = visitBaseExpr( old,
    20642038                        new ast::KeywordCastExpr(
     
    22582232                        new ast::AsmExpr(
    22592233                                old->location,
    2260                                 GET_ACCEPT_1(inout, Expr),
     2234                                old->inout,
    22612235                                GET_ACCEPT_1(constraint, Expr),
    22622236                                GET_ACCEPT_1(operand, Expr)
     
    25872561                        ty = new ast::TypeInstType{
    25882562                                old->name,
    2589                                 old->isFtype ? ast::TypeVar::Ftype : ast::TypeVar::Dtype,
     2563                                old->isFtype ? ast::TypeDecl::Ftype : ast::TypeDecl::Dtype,
    25902564                                cv( old ),
    25912565                                GET_ACCEPT_V( attributes, Attribute )
  • src/AST/Decl.cpp

    r807a632 r3b56166  
    99// Author           : Aaron B. Moss
    1010// Created On       : Thu May 9 10:00:00 2019
    11 // Last Modified By : Aaron B. Moss
    12 // Last Modified On : Thu May 9 10:00:00 2019
    13 // Update Count     : 1
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Dec 13 16:23:15 2019
     13// Update Count     : 20
    1414//
    1515
     
    1818#include <cassert>             // for assert, strict_dynamic_cast
    1919#include <iostream>
    20 #include <string>
    2120#include <unordered_map>
    2221
     
    2726#include "Node.hpp"            // for readonly
    2827#include "Type.hpp"            // for readonly
    29 #include "Parser/ParseNode.h"  // for DeclarationNode
    3028
    3129namespace ast {
     
    5654// --- TypeDecl
    5755
    58 std::string TypeDecl::typeString() const {
    59         static const std::string kindNames[] = { "object type", "function type", "tuple type" };
    60         assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1,
    61                 "typeString: kindNames is out of sync." );
    62         assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." );
    63         return (sized ? "sized " : "") + kindNames[ kind ];
     56const char * TypeDecl::typeString() const {
     57        static const char * kindNames[] = { "sized data type", "sized object type", "sized function type", "sized tuple type" };
     58        static_assert( sizeof(kindNames)/sizeof(kindNames[0]) == TypeDecl::NUMBER_OF_KINDS, "typeString: kindNames is out of sync." );
     59        assertf( kind < TypeDecl::NUMBER_OF_KINDS, "TypeDecl kind is out of bounds." );
     60        return sized ? kindNames[ kind ] : &kindNames[ kind ][ sizeof("sized") ]; // sizeof includes '\0'
    6461}
    6562
    66 std::string TypeDecl::genTypeString() const {
    67         static const std::string kindNames[] = { "dtype", "ftype", "ttype" };
    68         assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "genTypeString: kindNames is out of sync." );
    69         assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." );
     63const char * TypeDecl::genTypeString() const {
     64        static const char * kindNames[] = { "dtype", "otype", "ftype", "ttype" };
     65        static_assert( sizeof(kindNames)/sizeof(kindNames[0]) == TypeDecl::NUMBER_OF_KINDS, "genTypeString: kindNames is out of sync." );
     66        assertf( kind < TypeDecl::NUMBER_OF_KINDS, "TypeDecl kind is out of bounds." );
    7067        return kindNames[ kind ];
    7168}
     
    7370std::ostream & operator<< ( std::ostream & out, const TypeDecl::Data & data ) {
    7471        return out << data.kind << ", " << data.isComplete;
     72}
     73
     74// --- AggregateDecl
     75
     76// These must harmonize with the corresponding AggregateDecl::Aggregate enumerations.
     77static const char * aggregateNames[] = { "struct", "union", "enum", "exception", "trait", "generator", "coroutine", "monitor", "thread", "NoAggregateName" };
     78
     79const char * AggregateDecl::aggrString( AggregateDecl::Aggregate aggr ) {
     80        return aggregateNames[aggr];
    7581}
    7682
  • src/AST/Decl.hpp

    r807a632 r3b56166  
    99// Author           : Aaron B. Moss
    1010// Created On       : Thu May 9 10:00:00 2019
    11 // Last Modified By : Aaron B. Moss
    12 // Last Modified On : Thu May 9 10:00:00 2019
    13 // Update Count     : 1
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Dec 13 17:38:33 2019
     13// Update Count     : 29
    1414//
    1515
     
    2020#include <unordered_map>
    2121#include <vector>
     22#include <algorithm>
    2223
    2324#include "FunctionSpec.hpp"
     
    2728#include "ParseNode.hpp"
    2829#include "StorageClasses.hpp"
    29 #include "TypeVar.hpp"
    3030#include "Visitor.hpp"
    31 #include "Parser/ParseNode.h"  // for DeclarationNode::Aggregate
     31#include "Common/utility.h"
     32#include "Common/SemanticError.h"                                               // error_str
    3233
    3334// Must be included in *all* AST classes; should be #undef'd at the end of the file
     
    125126        std::vector< ptr<Expr> > withExprs;
    126127
    127         FunctionDecl( const CodeLocation & loc, const std::string &name, FunctionType * type,
     128        FunctionDecl( const CodeLocation & loc, const std::string & name, FunctionType * type,
    128129                CompoundStmt * stmts, Storage::Classes storage = {}, Linkage::Spec linkage = Linkage::C,
    129130                std::vector<ptr<Attribute>>&& attrs = {}, Function::Specs fs = {})
     
    136137        bool has_body() const { return stmts; }
    137138
    138         const DeclWithType * accept( Visitor &v ) const override { return v.visit( this ); }
     139        const DeclWithType * accept( Visitor & v ) const override { return v.visit( this ); }
    139140private:
    140141        FunctionDecl * clone() const override { return new FunctionDecl( *this ); }
     
    154155
    155156        /// Produces a name for the kind of alias
    156         virtual std::string typeString() const = 0;
     157        virtual const char * typeString() const = 0;
    157158
    158159private:
     
    163164/// Cforall type variable: `dtype T`
    164165class TypeDecl final : public NamedTypeDecl {
    165 public:
    166         TypeVar::Kind kind;
     166  public:
     167        enum Kind { Dtype, Otype, Ftype, Ttype, NUMBER_OF_KINDS };
     168
     169        Kind kind;
    167170        bool sized;
    168171        ptr<Type> init;
     
    170173        /// Data extracted from a type decl
    171174        struct Data {
    172                 TypeVar::Kind kind;
     175                Kind kind;
    173176                bool isComplete;
    174177
    175                 Data() : kind( (TypeVar::Kind)-1 ), isComplete( false ) {}
     178                Data() : kind( NUMBER_OF_KINDS ), isComplete( false ) {}
    176179                Data( const TypeDecl * d ) : kind( d->kind ), isComplete( d->sized ) {}
    177                 Data( TypeVar::Kind k, bool c ) : kind( k ), isComplete( c ) {}
     180                Data( Kind k, bool c ) : kind( k ), isComplete( c ) {}
    178181                Data( const Data & d1, const Data & d2 )
    179                 : kind( d1.kind ), isComplete( d1.isComplete || d2.isComplete ) {}
    180 
    181                 bool operator== ( const Data & o ) const {
    182                         return kind == o.kind && isComplete == o.isComplete;
    183                 }
    184                 bool operator!= ( const Data & o ) const { return !(*this == o); }
     182                        : kind( d1.kind ), isComplete( d1.isComplete || d2.isComplete ) {}
     183
     184                bool operator==( const Data & o ) const { return kind == o.kind && isComplete == o.isComplete; }
     185                bool operator!=( const Data & o ) const { return !(*this == o); }
    185186        };
    186187
    187         TypeDecl( const CodeLocation& loc, const std::string& name, Storage::Classes storage, Type* b,
    188                 TypeVar::Kind k, bool s, Type* i = nullptr )
    189         : NamedTypeDecl( loc, name, storage, b ), kind( k ), sized( k == TypeVar::Ttype || s ),
    190           init( i ) {}
    191 
    192         std::string typeString() const override;
     188        TypeDecl( const CodeLocation & loc, const std::string & name, Storage::Classes storage, Type * b,
     189                          Kind k, bool s, Type * i = nullptr )
     190                : NamedTypeDecl( loc, name, storage, b ), kind( k ), sized( k == Ttype || s ),
     191                init( i ) {}
     192
     193        const char * typeString() const override;
    193194        /// Produces a name for generated code
    194         std::string genTypeString() const;
     195        const char * genTypeString() const;
    195196
    196197        /// convenience accessor to match Type::isComplete()
     
    198199
    199200        const Decl * accept( Visitor & v ) const override { return v.visit( this ); }
    200 private:
     201  private:
    201202        TypeDecl * clone() const override { return new TypeDecl{ *this }; }
    202203        MUTATE_FRIEND
     
    212213        : NamedTypeDecl( loc, name, storage, b, spec ) {}
    213214
    214         std::string typeString() const override { return "typedef"; }
     215        const char * typeString() const override { return "typedef"; }
    215216
    216217        const Decl * accept( Visitor & v ) const override { return v.visit( this ); }
     
    223224class AggregateDecl : public Decl {
    224225public:
     226        enum Aggregate { Struct, Union, Enum, Exception, Trait, Generator, Coroutine, Monitor, Thread, NoAggregate };
     227        static const char * aggrString( Aggregate aggr );
     228
    225229        std::vector<ptr<Decl>> members;
    226230        std::vector<ptr<TypeDecl>> params;
     
    237241
    238242        /// Produces a name for the kind of aggregate
    239         virtual std::string typeString() const = 0;
     243        virtual const char * typeString() const = 0;
    240244
    241245private:
     
    247251class StructDecl final : public AggregateDecl {
    248252public:
    249         DeclarationNode::Aggregate kind;
     253        Aggregate kind;
    250254
    251255        StructDecl( const CodeLocation& loc, const std::string& name,
    252                 DeclarationNode::Aggregate kind = DeclarationNode::Struct,
     256                Aggregate kind = Struct,
    253257                std::vector<ptr<Attribute>>&& attrs = {}, Linkage::Spec linkage = Linkage::Cforall )
    254258        : AggregateDecl( loc, name, std::move(attrs), linkage ), kind( kind ) {}
    255259
    256         bool is_coroutine() { return kind == DeclarationNode::Coroutine; }
    257         bool is_monitor() { return kind == DeclarationNode::Monitor; }
    258         bool is_thread() { return kind == DeclarationNode::Thread; }
    259 
    260         const Decl * accept( Visitor & v ) const override { return v.visit( this ); }
    261 
    262         std::string typeString() const override { return "struct"; }
     260        bool is_coroutine() { return kind == Coroutine; }
     261        bool is_monitor() { return kind == Monitor; }
     262        bool is_thread() { return kind == Thread; }
     263
     264        const Decl * accept( Visitor & v ) const override { return v.visit( this ); }
     265
     266        const char * typeString() const override { return aggrString( kind ); }
    263267
    264268private:
     
    276280        const Decl * accept( Visitor& v ) const override { return v.visit( this ); }
    277281
    278         std::string typeString() const override { return "union"; }
     282        const char * typeString() const override { return aggrString( Union ); }
    279283
    280284private:
     
    295299        const Decl * accept( Visitor & v ) const override { return v.visit( this ); }
    296300
    297         std::string typeString() const override { return "enum"; }
     301        const char * typeString() const override { return aggrString( Enum ); }
    298302
    299303private:
     
    314318        const Decl * accept( Visitor & v ) const override { return v.visit( this ); }
    315319
    316         std::string typeString() const override { return "trait"; }
     320        const char * typeString() const override { return "trait"; }
    317321
    318322private:
     
    340344        ptr<AsmStmt> stmt;
    341345
    342         AsmDecl( const CodeLocation & loc, AsmStmt *stmt )
     346        AsmDecl( const CodeLocation & loc, AsmStmt * stmt )
    343347        : Decl( loc, "", {}, {} ), stmt(stmt) {}
    344348
    345         const AsmDecl * accept( Visitor &v ) const override { return v.visit( this ); }
    346 private:
    347         AsmDecl *clone() const override { return new AsmDecl( *this ); }
     349        const AsmDecl * accept( Visitor & v ) const override { return v.visit( this ); }
     350private:
     351        AsmDecl * clone() const override { return new AsmDecl( *this ); }
    348352        MUTATE_FRIEND
    349353};
     
    357361        : Decl( loc, "", {}, {} ), cond( condition ), msg( msg ) {}
    358362
    359         const StaticAssertDecl * accept( Visitor &v ) const override { return v.visit( this ); }
     363        const StaticAssertDecl * accept( Visitor & v ) const override { return v.visit( this ); }
    360364private:
    361365        StaticAssertDecl * clone() const override { return new StaticAssertDecl( *this ); }
  • src/AST/Expr.cpp

    r807a632 r3b56166  
    99// Author           : Aaron B. Moss
    1010// Created On       : Wed May 15 17:00:00 2019
    11 // Last Modified By : Andrew Beach
     11// Last Modified By : Peter A. Buhr
    1212// Created On       : Thr Jun 13 13:38:00 2019
    13 // Update Count     : 2
     13// Update Count     : 6
    1414//
    1515
     
    141141// --- KeywordCastExpr
    142142
    143 const std::string & KeywordCastExpr::targetString() const {
    144         static const std::string targetStrs[] = {
    145                 "coroutine", "thread", "monitor"
    146         };
    147         static_assert(
    148                 (sizeof(targetStrs) / sizeof(targetStrs[0])) == ((unsigned long)NUMBER_OF_TARGETS),
    149                 "Each KeywordCastExpr::Target should have a corresponding string representation"
    150         );
    151         return targetStrs[(unsigned long)target];
     143const char * KeywordCastExpr::targetString() const {
     144        return AggregateDecl::aggrString( target );
    152145}
    153146
  • src/AST/Expr.hpp

    r807a632 r3b56166  
    99// Author           : Aaron B. Moss
    1010// Created On       : Fri May 10 10:30:00 2019
    11 // Last Modified By : Aaron B. Moss
     11// Last Modified By : Peter A. Buhr
    1212// Created On       : Fri May 10 10:30:00 2019
    13 // Update Count     : 1
     13// Update Count     : 7
    1414//
    1515
     
    2626#include "Fwd.hpp"        // for UniqueId
    2727#include "Label.hpp"
     28#include "Decl.hpp"
    2829#include "ParseNode.hpp"
    2930#include "Visitor.hpp"
     
    300301public:
    301302        ptr<Expr> arg;
    302         enum Target { Coroutine, Thread, Monitor, NUMBER_OF_TARGETS } target;
    303 
    304         KeywordCastExpr( const CodeLocation & loc, const Expr * a, Target t )
     303        ast::AggregateDecl::Aggregate target;
     304
     305        KeywordCastExpr( const CodeLocation & loc, const Expr * a, ast::AggregateDecl::Aggregate t )
    305306        : Expr( loc ), arg( a ), target( t ) {}
    306307
    307308        /// Get a name for the target type
    308         const std::string& targetString() const;
     309        const char * targetString() const;
    309310
    310311        const Expr * accept( Visitor & v ) const override { return v.visit( this ); }
     
    556557class AsmExpr final : public Expr {
    557558public:
    558         ptr<Expr> inout;
     559        std::string inout;
    559560        ptr<Expr> constraint;
    560561        ptr<Expr> operand;
    561562
    562         AsmExpr( const CodeLocation & loc, const Expr * io, const Expr * con, const Expr * op )
     563        AsmExpr( const CodeLocation & loc, const std::string & io, const Expr * con, const Expr * op )
    563564        : Expr( loc ), inout( io ), constraint( con ), operand( op ) {}
    564565
  • src/AST/Pass.impl.hpp

    r807a632 r3b56166  
    13001300                        maybe_accept( node, &AsmExpr::result );
    13011301                }
    1302                 maybe_accept( node, &AsmExpr::inout      );
    13031302                maybe_accept( node, &AsmExpr::constraint );
    13041303                maybe_accept( node, &AsmExpr::operand    );
  • src/AST/Print.cpp

    r807a632 r3b56166  
    10111011                os << "Asm Expression:" << endl;
    10121012                ++indent;
    1013                 if ( node->inout ) node->inout->accept( *this );
     1013                if ( !node->inout.empty() ) os << "[" << node->inout << "] ";
    10141014                if ( node->constraint ) node->constraint->accept( *this );
    10151015                if ( node->operand ) node->operand->accept( *this );
     
    13591359                preprint( node );
    13601360                os << "instance of type " << node->name
    1361                    << " (" << (node->kind == ast::TypeVar::Ftype ? "" : "not ") << "function type)";
     1361                   << " (" << (node->kind == ast::TypeDecl::Ftype ? "" : "not ") << "function type)";
    13621362                print( node->params );
    13631363
  • src/AST/Type.cpp

    r807a632 r3b56166  
    99// Author           : Aaron B. Moss
    1010// Created On       : Mon May 13 15:00:00 2019
    11 // Last Modified By : Aaron B. Moss
    12 // Last Modified On : Mon May 13 15:00:00 2019
    13 // Update Count     : 1
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sun Dec 15 16:56:28 2019
     13// Update Count     : 4
    1414//
    1515
     
    4848// --- BasicType
    4949
    50 const char *BasicType::typeNames[] = {
     50// GENERATED START, DO NOT EDIT
     51// GENERATED BY BasicTypes-gen.cc
     52const char * BasicType::typeNames[] = {
    5153        "_Bool",
    5254        "char",
     
    8688        "_Float128x _Complex",
    8789};
    88 static_assert(
    89         sizeof(BasicType::typeNames)/sizeof(BasicType::typeNames[0]) == BasicType::NUMBER_OF_BASIC_TYPES,
    90         "Each basic type name should have a corresponding kind enum value"
    91 );
     90// GENERATED END
    9291
    9392// --- FunctionType
  • src/AST/Type.hpp

    r807a632 r3b56166  
    99// Author           : Aaron B. Moss
    1010// Created On       : Thu May 9 10:00:00 2019
    11 // Last Modified By : Aaron B. Moss
    12 // Last Modified On : Thu May 9 10:00:00 2019
    13 // Update Count     : 1
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Dec 11 21:56:46 2019
     13// Update Count     : 5
    1414//
    1515
     
    2626#include "Fwd.hpp"
    2727#include "Node.hpp"          // for Node, ptr, ptr_base
    28 #include "TypeVar.hpp"
    2928#include "Visitor.hpp"
    3029
     
    423422public:
    424423        readonly<TypeDecl> base;
    425         TypeVar::Kind kind;
     424        TypeDecl::Kind kind;
    426425
    427426        TypeInstType( const std::string& n, const TypeDecl * b, CV::Qualifiers q = {},
    428427                std::vector<ptr<Attribute>> && as = {} )
    429428        : ReferenceToType( n, q, std::move(as) ), base( b ), kind( b->kind ) {}
    430         TypeInstType( const std::string& n, TypeVar::Kind k, CV::Qualifiers q = {},
     429        TypeInstType( const std::string& n, TypeDecl::Kind k, CV::Qualifiers q = {},
    431430                std::vector<ptr<Attribute>> && as = {} )
    432431        : ReferenceToType( n, q, std::move(as) ), base(), kind( k ) {}
  • src/AST/TypeEnvironment.cpp

    r807a632 r3b56166  
    99// Author           : Aaron B. Moss
    1010// Created On       : Wed May 29 11:00:00 2019
    11 // Last Modified By : Aaron B. Moss
    12 // Last Modified On : Wed May 29 11:00:00 2019
    13 // Update Count     : 1
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Dec 11 21:49:13 2019
     13// Update Count     : 4
    1414//
    1515
     
    240240                return true;
    241241        } else if ( auto typeInst = dynamic_cast< const TypeInstType * >( type ) ) {
    242                 return typeInst->kind == TypeVar::Ftype;
     242                return typeInst->kind == TypeDecl::Ftype;
    243243        } else return false;
    244244}
     
    248248        bool tyVarCompatible( const TypeDecl::Data & data, const Type * type ) {
    249249                switch ( data.kind ) {
    250                   case TypeVar::Dtype:
     250                  case TypeDecl::Dtype:
    251251                        // to bind to an object type variable, the type must not be a function type.
    252252                        // if the type variable is specified to be a complete type then the incoming
     
    254254                        // xxx - should this also check that type is not a tuple type and that it's not a ttype?
    255255                        return ! isFtype( type ) && ( ! data.isComplete || type->isComplete() );
    256                   case TypeVar::Ftype:
     256                  case TypeDecl::Ftype:
    257257                        return isFtype( type );
    258                   case TypeVar::Ttype:
     258                  case TypeDecl::Ttype:
    259259                        // ttype unifies with any tuple type
    260260                        return dynamic_cast< const TupleType * >( type ) || Tuples::isTtype( type );
  • src/AST/TypeEnvironment.hpp

    r807a632 r3b56166  
    99// Author           : Aaron B. Moss
    1010// Created On       : Wed May 29 11:00:00 2019
    11 // Last Modified By : Aaron B. Moss
    12 // Last Modified On : Wed May 29 11:00:00 2019
    13 // Update Count     : 1
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Dec 11 21:55:54 2019
     13// Update Count     : 3
    1414//
    1515
     
    2828#include "Type.hpp"
    2929#include "TypeSubstitution.hpp"
    30 #include "TypeVar.hpp"
    3130#include "Common/Indenter.h"
    3231#include "ResolvExpr/WidenMode.h"
     
    107106        /// Singleton class constructor from substitution
    108107        EqvClass( const std::string & v, const Type * b )
    109         : vars{ v }, bound( b ), allowWidening( false ), data( TypeVar::Dtype, false ) {}
     108        : vars{ v }, bound( b ), allowWidening( false ), data( TypeDecl::Dtype, false ) {}
    110109
    111110        /// Single-var constructor (strips qualifiers from bound type)
  • src/AST/module.mk

    r807a632 r3b56166  
    1010## Author           : Thierry Delisle
    1111## Created On       : Thu May 09 16:05:36 2019
    12 ## Last Modified By :
    13 ## Last Modified On :
    14 ## Update Count     :
     12## Last Modified By : Peter A. Buhr
     13## Last Modified On : Sat Dec 14 07:29:10 2019
     14## Update Count     : 3
    1515###############################################################################
    1616
     
    3434        AST/TypeSubstitution.cpp
    3535
    36 
    37 
    3836SRC += $(SRC_AST)
    3937SRCDEMANGLE += $(SRC_AST)
  • src/BasicTypes-gen.cc

    r807a632 r3b56166  
    273273
    274274
    275         #define Type TOP_SRCDIR "src/SynTree/Type.h"
    276         resetInput( file, Type, buffer, code, str );
    277 
    278         if ( (start = str.find( STARTMK )) == string::npos ) Abort( "start", Type );
     275        #define TypeH TOP_SRCDIR "src/SynTree/Type.h"
     276        resetInput( file, TypeH, buffer, code, str );
     277
     278        if ( (start = str.find( STARTMK )) == string::npos ) Abort( "start", TypeH );
    279279        start += sizeof( STARTMK );                                                     // includes newline
    280280        code << str.substr( 0, start );
     
    289289        code << "\t";                                                                           // indentation for end marker
    290290
    291         if ( (start = str.find( ENDMK, start + 1 )) == string::npos ) Abort( "end", Type );
    292         code << str.substr( start );
    293 
    294         output( file, Type, code );
     291        if ( (start = str.find( ENDMK, start + 1 )) == string::npos ) Abort( "end", TypeH );
     292        code << str.substr( start );
     293
     294        output( file, TypeH, code );
     295        // cout << code.str();
     296
     297
     298        #define TypeC TOP_SRCDIR "src/SynTree/Type.cc"
     299        resetInput( file, TypeC, buffer, code, str );
     300
     301        if ( (start = str.find( STARTMK )) == string::npos ) Abort( "start", TypeC );
     302        start += sizeof( STARTMK );                                                     // includes newline
     303        code << str.substr( 0, start );
     304
     305        code << BYMK << endl;
     306        code << "const char * BasicType::typeNames[] = {" << endl;
     307        for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) {
     308                code << "\t\"" << graph[r].type << "\"," << endl;
     309        } // for       
     310        code << "};" << endl;
     311
     312        if ( (start = str.find( ENDMK, start + 1 )) == string::npos ) Abort( "end", TypeC );
     313        code << str.substr( start );
     314
     315        output( file, TypeC, code );
    295316        // cout << code.str();
    296317
    297318
    298319        // TEMPORARY DURING CHANGE OVER
    299         #define TypeAST TOP_SRCDIR "src/AST/Type.hpp"
    300         resetInput( file, TypeAST, buffer, code, str );
    301 
    302         if ( (start = str.find( STARTMK )) == string::npos ) Abort( "start", TypeAST );
     320        #define TypeH_AST TOP_SRCDIR "src/AST/Type.hpp"
     321        resetInput( file, TypeH_AST, buffer, code, str );
     322
     323        if ( (start = str.find( STARTMK )) == string::npos ) Abort( "start", TypeH_AST );
    303324        start += sizeof( STARTMK );                                                     // includes newline
    304325        code << str.substr( 0, start );
     
    313334        code << "\t";                                                                           // indentation for end marker
    314335
    315         if ( (start = str.find( ENDMK, start + 1 )) == string::npos ) Abort( "end", TypeAST );
    316         code << str.substr( start );
    317 
    318         output( file, TypeAST, code );
     336        if ( (start = str.find( ENDMK, start + 1 )) == string::npos ) Abort( "end", TypeH_AST );
     337        code << str.substr( start );
     338
     339        output( file, TypeH_AST, code );
     340        // cout << code.str();
     341
     342
     343        #define TypeC_AST TOP_SRCDIR "src/AST/Type.cpp"
     344        resetInput( file, TypeC_AST, buffer, code, str );
     345
     346        if ( (start = str.find( STARTMK )) == string::npos ) Abort( "start", TypeC_AST );
     347        start += sizeof( STARTMK );                                                     // includes newline
     348        code << str.substr( 0, start );
     349
     350        code << BYMK << endl;
     351        code << "const char * BasicType::typeNames[] = {" << endl;
     352        for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) {
     353                code << "\t\"" << graph[r].type << "\"," << endl;
     354        } // for       
     355        code << "};" << endl;
     356
     357        if ( (start = str.find( ENDMK, start + 1 )) == string::npos ) Abort( "end", TypeC_AST );
     358        code << str.substr( start );
     359
     360        output( file, TypeC_AST, code );
    319361        // cout << code.str();
    320362
  • src/CodeGen/CodeGenerator.cc

    r807a632 r3b56166  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Oct 19 19:30:38 2019
    13 // Update Count     : 506
     12// Last Modified On : Fri Dec 13 23:13:28 2019
     13// Update Count     : 508
    1414//
    1515#include "CodeGenerator.h"
     
    2323#include "InitTweak/InitTweak.h"     // for getPointerBase
    2424#include "OperatorTable.h"           // for OperatorInfo, operatorLookup
    25 #include "Parser/LinkageSpec.h"      // for Spec, Intrinsic
     25#include "SynTree/LinkageSpec.h"     // for Spec, Intrinsic
    2626#include "SynTree/Attribute.h"       // for Attribute
    2727#include "SynTree/BaseSyntaxNode.h"  // for BaseSyntaxNode
     
    786786
    787787        void CodeGenerator::postvisit( AsmExpr * asmExpr ) {
    788                 if ( asmExpr->get_inout() ) {
     788                if ( !asmExpr->inout.empty() ) {
    789789                        output << "[ ";
    790                         asmExpr->get_inout()->accept( *visitor );
     790                        output << asmExpr->inout;
    791791                        output << " ] ";
    792792                } // if
    793                 asmExpr->get_constraint()->accept( *visitor );
     793                asmExpr->constraint->accept( *visitor );
    794794                output << " ( ";
    795                 asmExpr->get_operand()->accept( *visitor );
     795                asmExpr->operand->accept( *visitor );
    796796                output << " )";
    797797        }
  • src/CodeGen/FixMain.h

    r807a632 r3b56166  
    1010// Created On       : Thr Jan 12 14:11:09 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:16:59 2017
    13 // Update Count     : 1
     12// Last Modified On : Fri Dec 13 23:12:21 2019
     13// Update Count     : 3
    1414//
    1515
     
    1919#include <memory>
    2020
    21 #include "Parser/LinkageSpec.h"
     21#include "SynTree/LinkageSpec.h"
    2222
    2323class FunctionDecl;
  • src/CodeGen/FixNames.cc

    r807a632 r3b56166  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Jun 28 15:26:00 2017
    13 // Update Count     : 20
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Dec 13 23:39:14 2019
     13// Update Count     : 21
    1414//
    1515
     
    2222#include "Common/SemanticError.h"  // for SemanticError
    2323#include "FixMain.h"               // for FixMain
    24 #include "Parser/LinkageSpec.h"    // for Cforall, isMangled
    2524#include "SymTab/Mangler.h"        // for Mangler
     25#include "SynTree/LinkageSpec.h"   // for Cforall, isMangled
    2626#include "SynTree/Constant.h"      // for Constant
    2727#include "SynTree/Declaration.h"   // for FunctionDecl, ObjectDecl, Declarat...
  • src/CodeGen/Generate.cc

    r807a632 r3b56166  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Aug 18 15:39:00 2017
    13 // Update Count     : 7
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Dec 13 23:38:56 2019
     13// Update Count     : 8
    1414//
    1515#include "Generate.h"
     
    2222#include "GenType.h"                 // for genPrettyType
    2323#include "Common/PassVisitor.h"      // for PassVisitor
    24 #include "Parser/LinkageSpec.h"      // for isBuiltin, isGeneratable
     24#include "SynTree/LinkageSpec.h"     // for isBuiltin, isGeneratable
    2525#include "SynTree/BaseSyntaxNode.h"  // for BaseSyntaxNode
    2626#include "SynTree/Declaration.h"     // for Declaration
  • src/CodeGen/module.mk

    r807a632 r3b56166  
    1111## Created On       : Mon Jun  1 17:49:17 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Tue Jun  2 11:17:02 2015
    14 ## Update Count     : 3
     13## Last Modified On : Sat Dec 14 07:29:42 2019
     14## Update Count     : 4
    1515###############################################################################
    1616
     
    2424        CodeGen/OperatorTable.cc
    2525
    26 
    2726SRC += $(SRC_CODEGEN) CodeGen/Generate.cc CodeGen/FixNames.cc
    2827SRCDEMANGLE += $(SRC_CODEGEN)
  • src/CodeTools/DeclStats.cc

    r807a632 r3b56166  
    99// Author           : Aaron Moss
    1010// Created On       : Wed Jan 31 16:40:00 2016
    11 // Last Modified By : Aaron Moss
    12 // Last Modified On : Wed Jan 31 16:40:00 2016
    13 // Update Count     : 1
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Dec 13 23:39:33 2019
     13// Update Count     : 2
    1414//
    1515
     
    2626#include "Common/VectorMap.h"      // for VectorMap
    2727#include "GenPoly/GenPoly.h"       // for hasPolyBase
    28 #include "Parser/LinkageSpec.h"    // for ::NoOfSpecs, Spec
     28#include "SynTree/LinkageSpec.h"   // for ::NoOfSpecs, Spec
    2929#include "SynTree/Declaration.h"   // for FunctionDecl, TypeDecl, Declaration
    3030#include "SynTree/Expression.h"    // for UntypedExpr, Expression
  • src/Common/Debug.h

    r807a632 r3b56166  
    99// Author           : Rob Schluntz
    1010// Created On       : Fri Sep 1 11:09:14 2017
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri Sep 1 11:09:36 2017
    13 // Update Count     : 2
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Dec 13 23:39:42 2019
     13// Update Count     : 3
    1414//
    1515
     
    2121
    2222#include "CodeGen/Generate.h"
    23 #include "Parser/LinkageSpec.h"
     23#include "SynTree/LinkageSpec.h"
    2424#include "SynTree/Declaration.h"
    2525
  • src/Common/PassVisitor.impl.h

    r807a632 r3b56166  
    24522452
    24532453        indexerScopedAccept( node->result    , *this );
    2454         maybeAccept_impl   ( node->inout     , *this );
    24552454        maybeAccept_impl   ( node->constraint, *this );
    24562455        maybeAccept_impl   ( node->operand   , *this );
     
    24642463
    24652464        indexerScopedAccept( node->result    , *this );
    2466         maybeAccept_impl   ( node->inout     , *this );
    24672465        maybeAccept_impl   ( node->constraint, *this );
    24682466        maybeAccept_impl   ( node->operand   , *this );
     
    24772475        indexerScopedMutate( node->env       , *this );
    24782476        indexerScopedMutate( node->result    , *this );
    2479         maybeMutate_impl   ( node->inout     , *this );
    24802477        maybeMutate_impl   ( node->constraint, *this );
    24812478        maybeMutate_impl   ( node->operand   , *this );
     
    33053302        VISIT_START( node );
    33063303
    3307         indexerAddStruct( node->name );
     3304        indexerAddUnion( node->name );
    33083305
    33093306        {
     
    33203317        VISIT_START( node );
    33213318
    3322         indexerAddStruct( node->name );
     3319        indexerAddUnion( node->name );
    33233320
    33243321        {
     
    33353332        MUTATE_START( node );
    33363333
    3337         indexerAddStruct( node->name );
     3334        indexerAddUnion( node->name );
    33383335
    33393336        {
  • src/Common/SemanticError.cc

    r807a632 r3b56166  
    149149// Helpers
    150150namespace ErrorHelpers {
     151        Colors colors = Colors::Auto;
     152
     153        static inline bool with_colors() {
     154                return colors == Colors::Auto ? isatty( STDERR_FILENO ) : bool(colors);
     155        }
     156
    151157        const std::string & error_str() {
    152                 static std::string str = isatty( STDERR_FILENO ) ? "\e[31merror:\e[39m " : "error: ";
     158                static std::string str = with_colors() ? "\e[31merror:\e[39m " : "error: ";
    153159                return str;
    154160        }
    155161
    156162        const std::string & warning_str() {
    157                 static std::string str = isatty( STDERR_FILENO ) ? "\e[95mwarning:\e[39m " : "warning: ";
     163                static std::string str = with_colors() ? "\e[95mwarning:\e[39m " : "warning: ";
    158164                return str;
    159165        }
    160166
    161167        const std::string & bold_ttycode() {
    162                 static std::string str = isatty( STDERR_FILENO ) ? "\e[1m" : "";
     168                static std::string str = with_colors() ? "\e[1m" : "";
    163169                return str;
    164170        }
    165171
    166172        const std::string & reset_font_ttycode() {
    167                 static std::string str = isatty( STDERR_FILENO ) ? "\e[0m" : "";
     173                static std::string str = with_colors() ? "\e[0m" : "";
    168174                return str;
    169175        }
  • src/Common/SemanticError.h

    r807a632 r3b56166  
    9797// Helpers
    9898namespace ErrorHelpers {
     99        enum class Colors {
     100                Never = false,
     101                Always = true,
     102                Auto,
     103        };
     104
     105        extern Colors colors;
     106
    99107        const std::string & error_str();
    100108        const std::string & warning_str();
  • src/Common/Stats/Time.h

    r807a632 r3b56166  
    99// Author           : Thierry Delisle
    1010// Created On       : Fri Mar 01 15:14:11 2019
    11 // Last Modified By :
     11// Last Modified By : Andrew Beach
    1212// Last Modified On :
    1313// Update Count     :
     
    4141                                f();
    4242                        }
     43
     44                        template<typename ret_t = void, typename func_t, typename... arg_t>
     45                        inline ret_t TimeCall(
     46                                        const char *, func_t func, arg_t&&... arg) {
     47                                return func(std::forward<arg_t>(arg)...);
     48                        }
    4349#               else
    4450                        void StartGlobal();
     
    5965                                func();
    6066                        }
     67
     68                        template<typename ret_t = void, typename func_t, typename... arg_t>
     69                        inline ret_t TimeCall(
     70                                        const char * name, func_t func, arg_t&&... arg) {
     71                                BlockGuard guard(name);
     72                                return func(std::forward<arg_t>(arg)...);
     73                        }
    6174#               endif
    6275        }
  • src/Concurrency/Keywords.cc

    r807a632 r3b56166  
    1111// Last Modified By :
    1212// Last Modified On :
    13 // Update Count     : 5
     13// Update Count     : 10
    1414//
    1515
     
    2424#include "CodeGen/OperatorTable.h" // for isConstructor
    2525#include "InitTweak/InitTweak.h"   // for getPointerBase
    26 #include "Parser/LinkageSpec.h"    // for Cforall
     26#include "SynTree/LinkageSpec.h"   // for Cforall
    2727#include "SynTree/Constant.h"      // for Constant
    2828#include "SynTree/Declaration.h"   // for StructDecl, FunctionDecl, ObjectDecl
     
    5353          public:
    5454
    55                 ConcurrentSueKeyword( std::string&& type_name, std::string&& field_name, std::string&& getter_name, std::string&& context_error, bool needs_main, KeywordCastExpr::Target cast_target ) :
     55                ConcurrentSueKeyword( std::string&& type_name, std::string&& field_name, std::string&& getter_name, std::string&& context_error, bool needs_main, AggregateDecl::Aggregate cast_target ) :
    5656                  type_name( type_name ), field_name( field_name ), getter_name( getter_name ), context_error( context_error ), needs_main( needs_main ), cast_target( cast_target ) {}
    5757
     
    5959
    6060                Declaration * postmutate( StructDecl * decl );
     61                DeclarationWithType * postmutate( FunctionDecl * decl );
    6162
    6263                void handle( StructDecl * );
     
    7576                const std::string context_error;
    7677                bool needs_main;
    77                 KeywordCastExpr::Target cast_target;
    78 
    79                 StructDecl* type_decl = nullptr;
     78                AggregateDecl::Aggregate cast_target;
     79
     80                StructDecl   * type_decl = nullptr;
     81                FunctionDecl * dtor_decl = nullptr;
    8082        };
    8183
     
    9799                        "__thrd",
    98100                        "get_thread",
    99                         "thread keyword requires threads to be in scope, add #include <thread.hfa>",
     101                        "thread keyword requires threads to be in scope, add #include <thread.hfa>\n",
    100102                        true,
    101                         KeywordCastExpr::Thread
     103                        AggregateDecl::Thread
    102104                )
    103105                {}
     
    129131                        "__cor",
    130132                        "get_coroutine",
    131                         "coroutine keyword requires coroutines to be in scope, add #include <coroutine.hfa>",
     133                        "coroutine keyword requires coroutines to be in scope, add #include <coroutine.hfa>\n",
    132134                        true,
    133                         KeywordCastExpr::Coroutine
     135                        AggregateDecl::Coroutine
    134136                )
    135137                {}
     
    161163                        "__mon",
    162164                        "get_monitor",
    163                         "monitor keyword requires monitors to be in scope, add #include <monitor.hfa>",
     165                        "monitor keyword requires monitors to be in scope, add #include <monitor.hfa>\n",
    164166                        false,
    165                         KeywordCastExpr::Monitor
     167                        AggregateDecl::Monitor
    166168                )
    167169                {}
     
    284286        }
    285287
     288        DeclarationWithType * ConcurrentSueKeyword::postmutate( FunctionDecl * decl ) {
     289                if( !type_decl ) return decl;
     290                if( !CodeGen::isDestructor( decl->name ) ) return decl;
     291
     292                auto params = decl->type->parameters;
     293                if( params.size() != 1 ) return decl;
     294
     295                auto type = dynamic_cast<ReferenceType*>( params.front()->get_type() );
     296                if( !type ) return decl;
     297
     298                auto stype = dynamic_cast<StructInstType*>( type->base );
     299                if( !stype ) return decl;
     300                if( stype->baseStruct != type_decl ) return decl;
     301
     302                if( !dtor_decl ) dtor_decl = decl;
     303                return decl;
     304        }
     305
    286306        Expression * ConcurrentSueKeyword::postmutate( KeywordCastExpr * cast ) {
    287307                if ( cast_target == cast->target ) {
    288308                        // convert (thread &)t to (thread_desc &)*get_thread(t), etc.
    289309                        if( !type_decl ) SemanticError( cast, context_error );
    290                         Expression * arg = cast->arg;
    291                         cast->arg = nullptr;
    292                         delete cast;
    293                         return new CastExpr(
    294                                 UntypedExpr::createDeref(
    295                                         new UntypedExpr( new NameExpr( getter_name ), { arg } )
    296                                 ),
    297                                 new ReferenceType(
    298                                         noQualifiers,
    299                                         new StructInstType( noQualifiers, type_decl ) )
    300                                 );
     310                        if( !dtor_decl ) SemanticError( cast, context_error );
     311                        assert( cast->result == nullptr );
     312                        cast->set_result( new ReferenceType( noQualifiers, new StructInstType( noQualifiers, type_decl ) ) );
     313                        cast->concrete_target.field  = field_name;
     314                        cast->concrete_target.getter = getter_name;
    301315                }
    302316                return cast;
     
    308322
    309323                if( !type_decl ) SemanticError( decl, context_error );
     324                if( !dtor_decl ) SemanticError( decl, context_error );
    310325
    311326                FunctionDecl * func = forwardDeclare( decl );
     
    701716                                new UntypedExpr(
    702717                                        new NameExpr( "__thrd_start" ),
    703                                         { new VariableExpr( param ) }
     718                                        { new VariableExpr( param ), new NameExpr("main") }
    704719                                )
    705720                        )
  • src/Concurrency/Waitfor.cc

    r807a632 r3b56166  
    1111// Last Modified By :
    1212// Last Modified On :
    13 // Update Count     : 7
     13// Update Count     : 12
    1414//
    1515
     
    2323#include "Common/PassVisitor.h"    // for PassVisitor
    2424#include "Common/SemanticError.h"  // for SemanticError
     25#include "Common/UniqueName.h"     // for UniqueName
    2526#include "Common/utility.h"        // for deleteAll, map_range
    2627#include "CodeGen/OperatorTable.h" // for isConstructor
    2728#include "InitTweak/InitTweak.h"   // for getPointerBase
    28 #include "Parser/LinkageSpec.h"    // for Cforall
    2929#include "ResolvExpr/Resolver.h"   // for findVoidExpression
     30#include "SynTree/LinkageSpec.h"   // for Cforall
    3031#include "SynTree/Constant.h"      // for Constant
    3132#include "SynTree/Declaration.h"   // for StructDecl, FunctionDecl, ObjectDecl
     
    4142void foo() {
    4243        while( true ) {
    43                 when( a < 1 ) waitfor( f, a ) { bar(); }
     44                when( a < 1 ) waitfor( f : a ) { bar(); }
    4445                or timeout( swagl() );
    45                 or waitfor( g, a ) { baz(); }
    46                 or waitfor( ^?{}, a ) { break; }
     46                or waitfor( g : a ) { baz(); }
     47                or waitfor( ^?{} : a ) { break; }
    4748                or waitfor( ^?{} ) { break; }
    4849        }
  • src/ControlStruct/ExceptTranslate.cc

    r807a632 r3b56166  
    1010// Created On       : Wed Jun 14 16:49:00 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Feb 13 18:15:29 2019
    13 // Update Count     : 11
     12// Last Modified On : Fri Dec 13 23:40:15 2019
     13// Update Count     : 12
    1414//
    1515
     
    2424#include "Common/SemanticError.h"     // for SemanticError
    2525#include "Common/utility.h"           // for CodeLocation
    26 #include "Parser/LinkageSpec.h"       // for Cforall
     26#include "SynTree/LinkageSpec.h"      // for Cforall
    2727#include "SynTree/Attribute.h"        // for Attribute
    2828#include "SynTree/Constant.h"         // for Constant
  • src/ControlStruct/LabelFixer.cc

    r807a632 r3b56166  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Mar 11 22:26:02 2019
    13 // Update Count     : 159
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Tue Jan 21 10:32:00 2020
     13// Update Count     : 160
    1414//
    1515
     
    2121#include "ControlStruct/LabelGenerator.h"  // for LabelGenerator
    2222#include "LabelFixer.h"
    23 #include "MLEMutator.h"                    // for MLEMutator
     23#include "MLEMutator.h"                    // for MultiLevelExitMutator
    2424#include "SynTree/Declaration.h"           // for FunctionDecl
    2525#include "SynTree/Expression.h"            // for NameExpr, Expression, Unty...
     
    4444
    4545        void LabelFixer::postvisit( FunctionDecl * functionDecl ) {
    46                 PassVisitor<MLEMutator> mlemut( resolveJumps(), generator );
    47                 functionDecl->acceptMutator( mlemut );
     46                PassVisitor<MultiLevelExitMutator> mlem( resolveJumps(), generator );
     47                // We start in the body so we can stop when we hit another FunctionDecl.
     48                maybeMutate( functionDecl->statements, mlem );
    4849        }
    4950
     
    7576
    7677
    77         // sets the definition of the labelTable entry to be the provided statement for every label in the list
    78         // parameter. Happens for every kind of statement
     78        // Sets the definition of the labelTable entry to be the provided statement for every label in
     79        // the list parameter. Happens for every kind of statement.
    7980        Label LabelFixer::setLabelsDef( std::list< Label > & llabel, Statement * definition ) {
    8081                assert( definition != 0 );
    8182                assert( llabel.size() > 0 );
    82 
    83                 Entry * e = new Entry( definition );
    8483
    8584                for ( std::list< Label >::iterator i = llabel.begin(); i != llabel.end(); i++ ) {
     
    8786                        l.set_statement( definition ); // attach statement to the label to be used later
    8887                        if ( labelTable.find( l ) == labelTable.end() ) {
    89                                 // all labels on this statement need to use the same entry, so this should only be created once
     88                                // All labels on this statement need to use the same entry,
     89                                // so this should only be created once.
    9090                                // undefined and unused until now, add an entry
    91                                 labelTable[ l ] =  e;
     91                                labelTable[ l ] = new Entry( definition );
    9292                        } else if ( labelTable[ l ]->defined() ) {
    9393                                // defined twice, error
    94                                 SemanticError( l.get_statement()->location, "Duplicate definition of label: " + l.get_name() );
    95                         }       else {
     94                                SemanticError( l.get_statement()->location,
     95                                        "Duplicate definition of label: " + l.get_name() );
     96                        } else {
    9697                                // used previously, but undefined until now -> link with this entry
     98                                // Question: Is changing objects important?
    9799                                delete labelTable[ l ];
    98                                 labelTable[ l ] = e;
     100                                labelTable[ l ] = new Entry( definition );
    99101                        } // if
    100102                } // for
    101103
    102                 // produce one of the labels attached to this statement to be temporarily used as the canonical label
     104                // Produce one of the labels attached to this statement to be temporarily used as the
     105                // canonical label.
    103106                return labelTable[ llabel.front() ]->get_label();
    104107        }
  • src/ControlStruct/MLEMutator.cc

    r807a632 r3b56166  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Oct 22 17:22:44 2019
    13 // Update Count     : 220
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Jan 22 11:50:00 2020
     13// Update Count     : 223
    1414//
    1515
     
    3333
    3434namespace ControlStruct {
    35         MLEMutator::~MLEMutator() {
     35        MultiLevelExitMutator::~MultiLevelExitMutator() {
    3636                delete targetTable;
    3737                targetTable = 0;
    3838        }
    3939        namespace {
    40                 bool isLoop( const MLEMutator::Entry & e ) { return dynamic_cast< WhileStmt * >( e.get_controlStructure() ) || dynamic_cast< ForStmt * >( e.get_controlStructure() ); }
    41                 bool isSwitch( const MLEMutator::Entry & e ) { return dynamic_cast< SwitchStmt *>( e.get_controlStructure() ); }
    42 
    43                 bool isBreakTarget( const MLEMutator::Entry & e ) { return isLoop( e ) || isSwitch( e ) || dynamic_cast< CompoundStmt *>( e.get_controlStructure() ); }
    44                 bool isContinueTarget( const MLEMutator::Entry & e ) { return isLoop( e ); }
    45                 bool isFallthroughTarget( const MLEMutator::Entry & e ) { return dynamic_cast< CaseStmt *>( e.get_controlStructure() );; }
    46                 bool isFallthroughDefaultTarget( const MLEMutator::Entry & e ) { return isSwitch( e ); }
     40                bool isLoop( const MultiLevelExitMutator::Entry & e ) {
     41                        return dynamic_cast< WhileStmt * >( e.get_controlStructure() )
     42                                || dynamic_cast< ForStmt * >( e.get_controlStructure() );
     43                }
     44                bool isSwitch( const MultiLevelExitMutator::Entry & e ) {
     45                        return dynamic_cast< SwitchStmt *>( e.get_controlStructure() );
     46                }
     47
     48                bool isBreakTarget( const MultiLevelExitMutator::Entry & e ) {
     49                        return isLoop( e ) || isSwitch( e )
     50                                || dynamic_cast< CompoundStmt *>( e.get_controlStructure() );
     51                }
     52                bool isContinueTarget( const MultiLevelExitMutator::Entry & e ) {
     53                        return isLoop( e );
     54                }
     55                bool isFallthroughTarget( const MultiLevelExitMutator::Entry & e ) {
     56                        return dynamic_cast< CaseStmt *>( e.get_controlStructure() );
     57                }
     58                bool isFallthroughDefaultTarget( const MultiLevelExitMutator::Entry & e ) {
     59                        return isSwitch( e );
     60                }
    4761        } // namespace
     62
     63        void MultiLevelExitMutator::premutate( FunctionDecl * ) {
     64                visit_children = false;
     65        }
    4866
    4967        // break labels have to come after the statement they break out of, so mutate a statement, then if they inform us
    5068        // through the breakLabel field tha they need a place to jump to on a break statement, add the break label to the
    5169        // body of statements
    52         void MLEMutator::fixBlock( std::list< Statement * > &kids, bool caseClause ) {
     70        void MultiLevelExitMutator::fixBlock( std::list< Statement * > &kids, bool caseClause ) {
    5371                SemanticErrorException errors;
    5472
     
    8199        }
    82100
    83         void MLEMutator::premutate( CompoundStmt *cmpndStmt ) {
     101        void MultiLevelExitMutator::premutate( CompoundStmt *cmpndStmt ) {
    84102                visit_children = false;
    85103                bool labeledBlock = !(cmpndStmt->labels.empty());
     
    118136                        }
    119137                }
    120                 assertf( false, "Could not find label '%s' on statement %s", originalTarget.get_name().c_str(), toString( stmt ).c_str() );
    121         }
    122 
    123 
    124         Statement *MLEMutator::postmutate( BranchStmt *branchStmt ) throw ( SemanticErrorException ) {
     138                assertf( false, "Could not find label '%s' on statement %s",
     139                        originalTarget.get_name().c_str(), toString( stmt ).c_str() );
     140        }
     141
     142
     143        Statement *MultiLevelExitMutator::postmutate( BranchStmt *branchStmt )
     144                        throw ( SemanticErrorException ) {
    125145                std::string originalTarget = branchStmt->originalTarget;
    126146
     
    230250        }
    231251
    232         Statement *MLEMutator::mutateLoop( Statement *bodyLoop, Entry &e ) {
     252        Statement *MultiLevelExitMutator::mutateLoop( Statement *bodyLoop, Entry &e ) {
     253                // only generate these when needed
     254                if( !e.isContUsed() && !e.isBreakUsed() ) return bodyLoop;
     255
    233256                // ensure loop body is a block
    234                 CompoundStmt *newBody;
    235                 if ( ! (newBody = dynamic_cast<CompoundStmt *>( bodyLoop )) ) {
    236                         newBody = new CompoundStmt();
    237                         newBody->get_kids().push_back( bodyLoop );
    238                 } // if
    239 
    240                 // only generate these when needed
     257                CompoundStmt * newBody = new CompoundStmt();
     258                newBody->get_kids().push_back( bodyLoop );
    241259
    242260                if ( e.isContUsed() ) {
     
    255273
    256274        template< typename LoopClass >
    257         void MLEMutator::prehandleLoopStmt( LoopClass * loopStmt ) {
     275        void MultiLevelExitMutator::prehandleLoopStmt( LoopClass * loopStmt ) {
    258276                // remember this as the most recent enclosing loop, then mutate the body of the loop -- this will determine
    259277                // whether brkLabel and contLabel are used with branch statements and will recursively do the same to nested
     
    266284
    267285        template< typename LoopClass >
    268         Statement * MLEMutator::posthandleLoopStmt( LoopClass * loopStmt ) {
     286        Statement * MultiLevelExitMutator::posthandleLoopStmt( LoopClass * loopStmt ) {
    269287                assert( ! enclosingControlStructures.empty() );
    270288                Entry &e = enclosingControlStructures.back();
     
    277295        }
    278296
    279         void MLEMutator::premutate( WhileStmt * whileStmt ) {
     297        void MultiLevelExitMutator::premutate( WhileStmt * whileStmt ) {
    280298                return prehandleLoopStmt( whileStmt );
    281299        }
    282300
    283         void MLEMutator::premutate( ForStmt * forStmt ) {
     301        void MultiLevelExitMutator::premutate( ForStmt * forStmt ) {
    284302                return prehandleLoopStmt( forStmt );
    285303        }
    286304
    287         Statement * MLEMutator::postmutate( WhileStmt * whileStmt ) {
     305        Statement * MultiLevelExitMutator::postmutate( WhileStmt * whileStmt ) {
    288306                return posthandleLoopStmt( whileStmt );
    289307        }
    290308
    291         Statement * MLEMutator::postmutate( ForStmt * forStmt ) {
     309        Statement * MultiLevelExitMutator::postmutate( ForStmt * forStmt ) {
    292310                return posthandleLoopStmt( forStmt );
    293311        }
    294312
    295         void MLEMutator::premutate( IfStmt * ifStmt ) {
     313        void MultiLevelExitMutator::premutate( IfStmt * ifStmt ) {
    296314                // generate a label for breaking out of a labeled if
    297315                bool labeledBlock = !(ifStmt->get_labels().empty());
     
    303321        }
    304322
    305         Statement * MLEMutator::postmutate( IfStmt * ifStmt ) {
     323        Statement * MultiLevelExitMutator::postmutate( IfStmt * ifStmt ) {
    306324                bool labeledBlock = !(ifStmt->get_labels().empty());
    307325                if ( labeledBlock ) {
     
    313331        }
    314332
    315         void MLEMutator::premutate( TryStmt * tryStmt ) {
     333        void MultiLevelExitMutator::premutate( TryStmt * tryStmt ) {
    316334                // generate a label for breaking out of a labeled if
    317335                bool labeledBlock = !(tryStmt->get_labels().empty());
     
    323341        }
    324342
    325         Statement * MLEMutator::postmutate( TryStmt * tryStmt ) {
     343        Statement * MultiLevelExitMutator::postmutate( TryStmt * tryStmt ) {
    326344                bool labeledBlock = !(tryStmt->get_labels().empty());
    327345                if ( labeledBlock ) {
     
    333351        }
    334352
    335         void MLEMutator::premutate( CaseStmt *caseStmt ) {
     353        void MultiLevelExitMutator::premutate( FinallyStmt * ) {
     354                GuardAction([this, old = std::move(enclosingControlStructures)]() {
     355                        enclosingControlStructures = std::move(old);
     356                });
     357                enclosingControlStructures = std::list<Entry>();
     358                GuardValue( inFinally );
     359                inFinally = true;
     360        }
     361
     362        void MultiLevelExitMutator::premutate( ReturnStmt *returnStmt ) {
     363                if ( inFinally ) {
     364                        SemanticError( returnStmt->location, "'return' may not appear in a finally clause" );
     365                }
     366        }
     367
     368        void MultiLevelExitMutator::premutate( CaseStmt *caseStmt ) {
    336369                visit_children = false;
    337370
     
    372405        }
    373406
    374         void MLEMutator::premutate( SwitchStmt *switchStmt ) {
     407        void MultiLevelExitMutator::premutate( SwitchStmt *switchStmt ) {
    375408                // generate a label for breaking out of a labeled switch
    376409                Label brkLabel = generator->newLabel("switchBreak", switchStmt);
     
    398431        }
    399432
    400         Statement * MLEMutator::postmutate( SwitchStmt * switchStmt ) {
     433        Statement * MultiLevelExitMutator::postmutate( SwitchStmt * switchStmt ) {
    401434                Entry &e = enclosingControlStructures.back();
    402435                assert ( e == switchStmt );
  • src/ControlStruct/MLEMutator.h

    r807a632 r3b56166  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Oct 22 17:22:47 2019
    13 // Update Count     : 45
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Jan 22 11:50:00 2020
     13// Update Count     : 48
    1414//
    1515
     
    3030        class LabelGenerator;
    3131
    32         class MLEMutator : public WithVisitorRef<MLEMutator>, public WithShortCircuiting, public WithGuards {
     32        class MultiLevelExitMutator : public WithVisitorRef<MultiLevelExitMutator>,
     33                        public WithShortCircuiting, public WithGuards {
    3334          public:
    3435                class Entry;
    35                 MLEMutator( std::map<Label, Statement *> *t, LabelGenerator *gen = 0 ) : targetTable( t ), breakLabel(std::string("")), generator( gen ) {}
    36                 ~MLEMutator();
     36                MultiLevelExitMutator( std::map<Label, Statement *> *t, LabelGenerator *gen = 0 ) :
     37                        targetTable( t ), breakLabel(std::string("")), generator( gen ) {}
     38                ~MultiLevelExitMutator();
     39
     40                void premutate( FunctionDecl * );
    3741
    3842                void premutate( CompoundStmt *cmpndStmt );
     
    4751                void premutate( SwitchStmt *switchStmt );
    4852                Statement * postmutate( SwitchStmt *switchStmt );
     53                void premutate( ReturnStmt *returnStmt );
    4954                void premutate( TryStmt *tryStmt );
    5055                Statement * postmutate( TryStmt *tryStmt );
     56                void premutate( FinallyStmt *finallyStmt );
    5157
    5258                Statement *mutateLoop( Statement *bodyLoop, Entry &e );
     
    110116                Label breakLabel;
    111117                LabelGenerator *generator;
     118                bool inFinally = false;
    112119
    113120                template< typename LoopClass >
  • src/GenPoly/Box.cc

    r807a632 r3b56166  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jun 21 15:49:59 2017
    13 // Update Count     : 346
     12// Last Modified On : Fri Dec 13 23:40:34 2019
     13// Update Count     : 347
    1414//
    1515
     
    3737#include "InitTweak/InitTweak.h"         // for getFunctionName, isAssignment
    3838#include "Lvalue.h"                      // for generalizedLvalue
    39 #include "Parser/LinkageSpec.h"          // for C, Spec, Cforall, Intrinsic
    4039#include "ResolvExpr/TypeEnvironment.h"  // for EqvClass
    4140#include "ResolvExpr/typeops.h"          // for typesCompatible
     
    4443#include "SymTab/Indexer.h"              // for Indexer
    4544#include "SymTab/Mangler.h"              // for Mangler
     45#include "SynTree/LinkageSpec.h"         // for C, Spec, Cforall, Intrinsic
    4646#include "SynTree/Attribute.h"           // for Attribute
    4747#include "SynTree/Constant.h"            // for Constant
  • src/GenPoly/Lvalue.cc

    r807a632 r3b56166  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 17 09:11:18 2017
    13 // Update Count     : 5
     12// Last Modified On : Fri Dec 13 23:14:38 2019
     13// Update Count     : 7
    1414//
    1515
     
    1717#include <string>                        // for string
    1818
     19#include "Common/UniqueName.h"
    1920#include "Common/PassVisitor.h"
    2021#include "GenPoly.h"                     // for isPolyType
     
    2223
    2324#include "InitTweak/InitTweak.h"
    24 #include "Parser/LinkageSpec.h"          // for Spec, isBuiltin, Intrinsic
    2525#include "ResolvExpr/TypeEnvironment.h"  // for AssertionSet, OpenVarSet
    2626#include "ResolvExpr/Unify.h"            // for unify
    2727#include "ResolvExpr/typeops.h"
    2828#include "SymTab/Indexer.h"              // for Indexer
     29#include "SynTree/LinkageSpec.h"         // for Spec, isBuiltin, Intrinsic
    2930#include "SynTree/Declaration.h"         // for Declaration, FunctionDecl
    3031#include "SynTree/Expression.h"          // for Expression, ConditionalExpr
     
    6061                }
    6162
    62                 struct ReferenceConversions final : public WithStmtsToAdd {
     63                struct ReferenceConversions final : public WithStmtsToAdd, public WithGuards {
    6364                        Expression * postmutate( CastExpr * castExpr );
    6465                        Expression * postmutate( AddressExpr * addrExpr );
     
    7172
    7273                struct FixIntrinsicResult final : public WithGuards {
     74                        enum {
     75                                NoSkip,
     76                                Skip,
     77                                SkipInProgress
     78                        } skip = NoSkip;
     79
     80                        void premutate( AsmExpr * ) { GuardValue( skip ); skip = Skip; }
     81                        void premutate( ApplicationExpr * ) { GuardValue( skip ); skip = (skip == Skip) ? SkipInProgress : NoSkip; }
     82
     83
    7384                        Expression * postmutate( ApplicationExpr * appExpr );
    7485                        void premutate( FunctionDecl * funcDecl );
     
    162173
    163174                Expression * FixIntrinsicResult::postmutate( ApplicationExpr * appExpr ) {
    164                         if ( isIntrinsicReference( appExpr ) ) {
     175                        if ( skip != SkipInProgress && isIntrinsicReference( appExpr ) ) {
    165176                                // eliminate reference types from intrinsic applications - now they return lvalues
    166177                                ReferenceType * result = strict_dynamic_cast< ReferenceType * >( appExpr->result );
  • src/GenPoly/Specialize.cc

    r807a632 r3b56166  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 16 07:53:59 2017
    13 // Update Count     : 31
     12// Last Modified On : Fri Dec 13 23:40:49 2019
     13// Update Count     : 32
    1414//
    1515
     
    2727#include "GenPoly.h"                     // for getFunctionType
    2828#include "InitTweak/InitTweak.h"         // for isIntrinsicCallExpr
    29 #include "Parser/LinkageSpec.h"          // for C
    3029#include "ResolvExpr/FindOpenVars.h"     // for findOpenVars
    3130#include "ResolvExpr/TypeEnvironment.h"  // for OpenVarSet, AssertionSet
    3231#include "Specialize.h"
     32#include "SynTree/LinkageSpec.h"         // for C
    3333#include "SynTree/Attribute.h"           // for Attribute
    3434#include "SynTree/Declaration.h"         // for FunctionDecl, DeclarationWit...
  • src/InitTweak/FixGlobalInit.cc

    r807a632 r3b56166  
    1010// Created On       : Mon May 04 15:14:56 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 16 07:53:11 2017
    13 // Update Count     : 18
     12// Last Modified On : Fri Dec 13 23:41:10 2019
     13// Update Count     : 19
    1414//
    1515
     
    2323#include "Common/UniqueName.h"     // for UniqueName
    2424#include "InitTweak.h"             // for isIntrinsicSingleArgCallStmt
    25 #include "Parser/LinkageSpec.h"    // for C
     25#include "SynTree/LinkageSpec.h"   // for C
    2626#include "SynTree/Attribute.h"     // for Attribute
    2727#include "SynTree/Constant.h"      // for Constant
  • src/InitTweak/FixInit.cc

    r807a632 r3b56166  
    1010// Created On       : Wed Jan 13 16:29:30 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Feb 13 18:15:56 2019
    13 // Update Count     : 76
     12// Last Modified On : Fri Dec 13 23:41:27 2019
     13// Update Count     : 77
    1414//
    1515#include "FixInit.h"
     
    3838#include "GenPoly/GenPoly.h"           // for getFunctionType
    3939#include "InitTweak.h"                 // for getFunctionName, getCallArg
    40 #include "Parser/LinkageSpec.h"        // for C, Spec, Cforall, isBuiltin
    4140#include "ResolvExpr/Resolver.h"       // for findVoidExpression
    4241#include "ResolvExpr/typeops.h"        // for typesCompatible
     
    4443#include "SymTab/Indexer.h"            // for Indexer
    4544#include "SymTab/Mangler.h"            // for Mangler
     45#include "SynTree/LinkageSpec.h"       // for C, Spec, Cforall, isBuiltin
    4646#include "SynTree/Attribute.h"         // for Attribute
    4747#include "SynTree/Constant.h"          // for Constant
  • src/InitTweak/GenInit.cc

    r807a632 r3b56166  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 17 09:12:36 2017
    13 // Update Count     : 183
     12// Last Modified On : Fri Dec 13 23:15:10 2019
     13// Update Count     : 184
    1414//
    1515#include "GenInit.h"
     
    3434#include "GenPoly/ScopedSet.h"         // for ScopedSet, ScopedSet<>::const_iter...
    3535#include "InitTweak.h"                 // for isConstExpr, InitExpander, checkIn...
    36 #include "Parser/LinkageSpec.h"        // for isOverridable, C
    3736#include "ResolvExpr/Resolver.h"
    3837#include "SymTab/Autogen.h"            // for genImplicitCall
    3938#include "SymTab/Mangler.h"            // for Mangler
     39#include "SynTree/LinkageSpec.h"       // for isOverridable, C
    4040#include "SynTree/Declaration.h"       // for ObjectDecl, DeclarationWithType
    4141#include "SynTree/Expression.h"        // for VariableExpr, UntypedExpr, Address...
  • src/InitTweak/InitTweak.cc

    r807a632 r3b56166  
    1010// Created On       : Fri May 13 11:26:36 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 25 22:21:48 2019
    13 // Update Count     : 7
     12// Last Modified On : Fri Dec 13 23:15:52 2019
     13// Update Count     : 8
    1414//
    1515
     
    3333#include "GenPoly/GenPoly.h"       // for getFunctionType
    3434#include "InitTweak.h"
    35 #include "Parser/LinkageSpec.h"    // for Spec, isBuiltin, Intrinsic
    3635#include "ResolvExpr/typeops.h"    // for typesCompatibleIgnoreQualifiers
    3736#include "SymTab/Autogen.h"
    3837#include "SymTab/Indexer.h"        // for Indexer
     38#include "SynTree/LinkageSpec.h"   // for Spec, isBuiltin, Intrinsic
    3939#include "SynTree/Attribute.h"     // for Attribute
    4040#include "SynTree/Constant.h"      // for Constant
  • src/MakeLibCfa.cc

    r807a632 r3b56166  
    1010// Created On       : Sat May 16 10:33:33 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Feb 17 21:08:09 2019
    13 // Update Count     : 41
     12// Last Modified On : Fri Dec 13 23:41:40 2019
     13// Update Count     : 42
    1414//
    1515
     
    2323#include "Common/SemanticError.h"   // for SemanticError
    2424#include "Common/UniqueName.h"      // for UniqueName
    25 #include "Parser/LinkageSpec.h"     // for Spec, Intrinsic, C
     25#include "SynTree/LinkageSpec.h"    // for Spec, Intrinsic, C
    2626#include "SynTree/Declaration.h"    // for FunctionDecl, ObjectDecl, Declara...
    2727#include "SynTree/Expression.h"     // for NameExpr, UntypedExpr, VariableExpr
  • src/Makefile.in

    r807a632 r3b56166  
    212212        SymTab/Indexer.$(OBJEXT) SymTab/Mangler.$(OBJEXT) \
    213213        SymTab/ManglerCommon.$(OBJEXT) SymTab/Validate.$(OBJEXT)
    214 am__objects_7 = SynTree/Type.$(OBJEXT) SynTree/VoidType.$(OBJEXT) \
    215         SynTree/BasicType.$(OBJEXT) SynTree/PointerType.$(OBJEXT) \
    216         SynTree/ArrayType.$(OBJEXT) SynTree/ReferenceType.$(OBJEXT) \
    217         SynTree/FunctionType.$(OBJEXT) \
    218         SynTree/ReferenceToType.$(OBJEXT) SynTree/TupleType.$(OBJEXT) \
    219         SynTree/TypeofType.$(OBJEXT) SynTree/AttrType.$(OBJEXT) \
    220         SynTree/VarArgsType.$(OBJEXT) SynTree/ZeroOneType.$(OBJEXT) \
    221         SynTree/Constant.$(OBJEXT) SynTree/Expression.$(OBJEXT) \
    222         SynTree/TupleExpr.$(OBJEXT) SynTree/CommaExpr.$(OBJEXT) \
    223         SynTree/TypeExpr.$(OBJEXT) SynTree/ApplicationExpr.$(OBJEXT) \
    224         SynTree/AddressExpr.$(OBJEXT) SynTree/Statement.$(OBJEXT) \
    225         SynTree/CompoundStmt.$(OBJEXT) SynTree/DeclStmt.$(OBJEXT) \
     214am__objects_7 = SynTree/AddressExpr.$(OBJEXT) \
     215        SynTree/AggregateDecl.$(OBJEXT) \
     216        SynTree/ApplicationExpr.$(OBJEXT) SynTree/ArrayType.$(OBJEXT) \
     217        SynTree/AttrType.$(OBJEXT) SynTree/Attribute.$(OBJEXT) \
     218        SynTree/BasicType.$(OBJEXT) SynTree/CommaExpr.$(OBJEXT) \
     219        SynTree/CompoundStmt.$(OBJEXT) SynTree/Constant.$(OBJEXT) \
     220        SynTree/DeclReplacer.$(OBJEXT) SynTree/DeclStmt.$(OBJEXT) \
    226221        SynTree/Declaration.$(OBJEXT) \
    227222        SynTree/DeclarationWithType.$(OBJEXT) \
    228         SynTree/ObjectDecl.$(OBJEXT) SynTree/FunctionDecl.$(OBJEXT) \
    229         SynTree/AggregateDecl.$(OBJEXT) \
    230         SynTree/NamedTypeDecl.$(OBJEXT) SynTree/TypeDecl.$(OBJEXT) \
    231         SynTree/Initializer.$(OBJEXT) \
    232         SynTree/TypeSubstitution.$(OBJEXT) SynTree/Attribute.$(OBJEXT) \
    233         SynTree/DeclReplacer.$(OBJEXT)
     223        SynTree/Expression.$(OBJEXT) SynTree/FunctionDecl.$(OBJEXT) \
     224        SynTree/FunctionType.$(OBJEXT) SynTree/Initializer.$(OBJEXT) \
     225        SynTree/LinkageSpec.$(OBJEXT) SynTree/NamedTypeDecl.$(OBJEXT) \
     226        SynTree/ObjectDecl.$(OBJEXT) SynTree/PointerType.$(OBJEXT) \
     227        SynTree/ReferenceToType.$(OBJEXT) \
     228        SynTree/ReferenceType.$(OBJEXT) SynTree/Statement.$(OBJEXT) \
     229        SynTree/TupleExpr.$(OBJEXT) SynTree/TupleType.$(OBJEXT) \
     230        SynTree/Type.$(OBJEXT) SynTree/TypeDecl.$(OBJEXT) \
     231        SynTree/TypeExpr.$(OBJEXT) SynTree/TypeSubstitution.$(OBJEXT) \
     232        SynTree/TypeofType.$(OBJEXT) SynTree/VarArgsType.$(OBJEXT) \
     233        SynTree/VoidType.$(OBJEXT) SynTree/ZeroOneType.$(OBJEXT)
    234234am__objects_8 = CompilationState.$(OBJEXT) $(am__objects_1) \
    235235        $(am__objects_2) Concurrency/Keywords.$(OBJEXT) \
    236236        $(am__objects_3) $(am__objects_4) GenPoly/GenPoly.$(OBJEXT) \
    237237        GenPoly/Lvalue.$(OBJEXT) InitTweak/GenInit.$(OBJEXT) \
    238         InitTweak/InitTweak.$(OBJEXT) Parser/LinkageSpec.$(OBJEXT) \
    239         $(am__objects_5) $(am__objects_6) SymTab/Demangle.$(OBJEXT) \
    240         $(am__objects_7) Tuples/TupleAssignment.$(OBJEXT) \
     238        InitTweak/InitTweak.$(OBJEXT) $(am__objects_5) \
     239        $(am__objects_6) SymTab/Demangle.$(OBJEXT) $(am__objects_7) \
     240        Tuples/TupleAssignment.$(OBJEXT) \
    241241        Tuples/TupleExpansion.$(OBJEXT) Tuples/Explode.$(OBJEXT) \
    242242        Tuples/Tuples.$(OBJEXT) Validate/HandleAttributes.$(OBJEXT) \
     
    261261        InitTweak/GenInit.$(OBJEXT) InitTweak/FixInit.$(OBJEXT) \
    262262        InitTweak/FixGlobalInit.$(OBJEXT) \
    263         InitTweak/InitTweak.$(OBJEXT) Parser/parser.$(OBJEXT) \
    264         Parser/lex.$(OBJEXT) Parser/TypedefTable.$(OBJEXT) \
    265         Parser/ParseNode.$(OBJEXT) Parser/DeclarationNode.$(OBJEXT) \
    266         Parser/ExpressionNode.$(OBJEXT) Parser/StatementNode.$(OBJEXT) \
    267         Parser/InitializerNode.$(OBJEXT) Parser/TypeData.$(OBJEXT) \
    268         Parser/LinkageSpec.$(OBJEXT) Parser/parserutility.$(OBJEXT) \
     263        InitTweak/InitTweak.$(OBJEXT) Parser/DeclarationNode.$(OBJEXT) \
     264        Parser/ExpressionNode.$(OBJEXT) \
     265        Parser/InitializerNode.$(OBJEXT) Parser/ParseNode.$(OBJEXT) \
     266        Parser/StatementNode.$(OBJEXT) Parser/TypeData.$(OBJEXT) \
     267        Parser/TypedefTable.$(OBJEXT) Parser/lex.$(OBJEXT) \
     268        Parser/parser.$(OBJEXT) Parser/parserutility.$(OBJEXT) \
    269269        $(am__objects_5) ResolvExpr/AlternativePrinter.$(OBJEXT) \
    270270        $(am__objects_6) $(am__objects_7) \
     
    559559        InitTweak/GenInit.cc InitTweak/FixInit.cc \
    560560        InitTweak/FixGlobalInit.cc InitTweak/InitTweak.cc \
    561         Parser/parser.yy Parser/lex.ll Parser/TypedefTable.cc \
    562         Parser/ParseNode.cc Parser/DeclarationNode.cc \
    563         Parser/ExpressionNode.cc Parser/StatementNode.cc \
    564         Parser/InitializerNode.cc Parser/TypeData.cc \
    565         Parser/LinkageSpec.cc Parser/parserutility.cc \
    566         $(SRC_RESOLVEXPR) ResolvExpr/AlternativePrinter.cc \
    567         $(SRC_SYMTAB) $(SRC_SYNTREE) Tuples/TupleAssignment.cc \
    568         Tuples/TupleExpansion.cc Tuples/Explode.cc Tuples/Tuples.cc \
     561        Parser/DeclarationNode.cc Parser/ExpressionNode.cc \
     562        Parser/InitializerNode.cc Parser/ParseNode.cc \
     563        Parser/StatementNode.cc Parser/TypeData.cc \
     564        Parser/TypedefTable.cc Parser/lex.ll Parser/parser.yy \
     565        Parser/parserutility.cc $(SRC_RESOLVEXPR) \
     566        ResolvExpr/AlternativePrinter.cc $(SRC_SYMTAB) $(SRC_SYNTREE) \
     567        Tuples/TupleAssignment.cc Tuples/TupleExpansion.cc \
     568        Tuples/Explode.cc Tuples/Tuples.cc \
    569569        Validate/HandleAttributes.cc Validate/FindSpecialDecls.cc \
    570570        Virtual/ExpandCasts.cc
     
    572572        Concurrency/Keywords.cc $(SRC_COMMON) $(SRC_CONTROLSTRUCT) \
    573573        GenPoly/GenPoly.cc GenPoly/Lvalue.cc InitTweak/GenInit.cc \
    574         InitTweak/InitTweak.cc Parser/LinkageSpec.cc $(SRC_RESOLVEXPR) \
    575         $(SRC_SYMTAB) SymTab/Demangle.cc $(SRC_SYNTREE) \
    576         Tuples/TupleAssignment.cc Tuples/TupleExpansion.cc \
    577         Tuples/Explode.cc Tuples/Tuples.cc \
     574        InitTweak/InitTweak.cc $(SRC_RESOLVEXPR) $(SRC_SYMTAB) \
     575        SymTab/Demangle.cc $(SRC_SYNTREE) Tuples/TupleAssignment.cc \
     576        Tuples/TupleExpansion.cc Tuples/Explode.cc Tuples/Tuples.cc \
    578577        Validate/HandleAttributes.cc Validate/FindSpecialDecls.cc
    579578MAINTAINERCLEANFILES = ${libdir}/${notdir ${cfa_cpplib_PROGRAMS}}
     
    663662
    664663SRC_SYNTREE = \
    665       SynTree/Type.cc \
    666       SynTree/VoidType.cc \
     664      SynTree/AddressExpr.cc \
     665      SynTree/AggregateDecl.cc \
     666      SynTree/ApplicationExpr.cc \
     667      SynTree/ArrayType.cc \
     668      SynTree/AttrType.cc \
     669      SynTree/Attribute.cc \
    667670      SynTree/BasicType.cc \
    668       SynTree/PointerType.cc \
    669       SynTree/ArrayType.cc \
    670       SynTree/ReferenceType.cc \
    671       SynTree/FunctionType.cc \
    672       SynTree/ReferenceToType.cc \
    673       SynTree/TupleType.cc \
    674       SynTree/TypeofType.cc \
    675       SynTree/AttrType.cc \
    676       SynTree/VarArgsType.cc \
    677       SynTree/ZeroOneType.cc \
     671      SynTree/CommaExpr.cc \
     672      SynTree/CompoundStmt.cc \
    678673      SynTree/Constant.cc \
    679       SynTree/Expression.cc \
    680       SynTree/TupleExpr.cc \
    681       SynTree/CommaExpr.cc \
    682       SynTree/TypeExpr.cc \
    683       SynTree/ApplicationExpr.cc \
    684       SynTree/AddressExpr.cc \
    685       SynTree/Statement.cc \
    686       SynTree/CompoundStmt.cc \
     674      SynTree/DeclReplacer.cc \
    687675      SynTree/DeclStmt.cc \
    688676      SynTree/Declaration.cc \
    689677      SynTree/DeclarationWithType.cc \
     678      SynTree/Expression.cc \
     679      SynTree/FunctionDecl.cc \
     680      SynTree/FunctionType.cc \
     681      SynTree/Initializer.cc \
     682      SynTree/LinkageSpec.cc \
     683      SynTree/NamedTypeDecl.cc \
    690684      SynTree/ObjectDecl.cc \
    691       SynTree/FunctionDecl.cc \
    692       SynTree/AggregateDecl.cc \
    693       SynTree/NamedTypeDecl.cc \
     685      SynTree/PointerType.cc \
     686      SynTree/ReferenceToType.cc \
     687      SynTree/ReferenceType.cc \
     688      SynTree/Statement.cc \
     689      SynTree/TupleExpr.cc \
     690      SynTree/TupleType.cc \
     691      SynTree/Type.cc \
    694692      SynTree/TypeDecl.cc \
    695       SynTree/Initializer.cc \
     693      SynTree/TypeExpr.cc \
    696694      SynTree/TypeSubstitution.cc \
    697       SynTree/Attribute.cc \
    698       SynTree/DeclReplacer.cc
     695      SynTree/TypeofType.cc \
     696      SynTree/VarArgsType.cc \
     697      SynTree/VoidType.cc \
     698      SynTree/ZeroOneType.cc
    699699
    700700
     
    869869InitTweak/InitTweak.$(OBJEXT): InitTweak/$(am__dirstamp) \
    870870        InitTweak/$(DEPDIR)/$(am__dirstamp)
    871 Parser/$(am__dirstamp):
    872         @$(MKDIR_P) Parser
    873         @: > Parser/$(am__dirstamp)
    874 Parser/$(DEPDIR)/$(am__dirstamp):
    875         @$(MKDIR_P) Parser/$(DEPDIR)
    876         @: > Parser/$(DEPDIR)/$(am__dirstamp)
    877 Parser/LinkageSpec.$(OBJEXT): Parser/$(am__dirstamp) \
    878         Parser/$(DEPDIR)/$(am__dirstamp)
    879871ResolvExpr/$(am__dirstamp):
    880872        @$(MKDIR_P) ResolvExpr
     
    957949        @$(MKDIR_P) SynTree/$(DEPDIR)
    958950        @: > SynTree/$(DEPDIR)/$(am__dirstamp)
     951SynTree/AddressExpr.$(OBJEXT): SynTree/$(am__dirstamp) \
     952        SynTree/$(DEPDIR)/$(am__dirstamp)
     953SynTree/AggregateDecl.$(OBJEXT): SynTree/$(am__dirstamp) \
     954        SynTree/$(DEPDIR)/$(am__dirstamp)
     955SynTree/ApplicationExpr.$(OBJEXT): SynTree/$(am__dirstamp) \
     956        SynTree/$(DEPDIR)/$(am__dirstamp)
     957SynTree/ArrayType.$(OBJEXT): SynTree/$(am__dirstamp) \
     958        SynTree/$(DEPDIR)/$(am__dirstamp)
     959SynTree/AttrType.$(OBJEXT): SynTree/$(am__dirstamp) \
     960        SynTree/$(DEPDIR)/$(am__dirstamp)
     961SynTree/Attribute.$(OBJEXT): SynTree/$(am__dirstamp) \
     962        SynTree/$(DEPDIR)/$(am__dirstamp)
     963SynTree/BasicType.$(OBJEXT): SynTree/$(am__dirstamp) \
     964        SynTree/$(DEPDIR)/$(am__dirstamp)
     965SynTree/CommaExpr.$(OBJEXT): SynTree/$(am__dirstamp) \
     966        SynTree/$(DEPDIR)/$(am__dirstamp)
     967SynTree/CompoundStmt.$(OBJEXT): SynTree/$(am__dirstamp) \
     968        SynTree/$(DEPDIR)/$(am__dirstamp)
     969SynTree/Constant.$(OBJEXT): SynTree/$(am__dirstamp) \
     970        SynTree/$(DEPDIR)/$(am__dirstamp)
     971SynTree/DeclReplacer.$(OBJEXT): SynTree/$(am__dirstamp) \
     972        SynTree/$(DEPDIR)/$(am__dirstamp)
     973SynTree/DeclStmt.$(OBJEXT): SynTree/$(am__dirstamp) \
     974        SynTree/$(DEPDIR)/$(am__dirstamp)
     975SynTree/Declaration.$(OBJEXT): SynTree/$(am__dirstamp) \
     976        SynTree/$(DEPDIR)/$(am__dirstamp)
     977SynTree/DeclarationWithType.$(OBJEXT): SynTree/$(am__dirstamp) \
     978        SynTree/$(DEPDIR)/$(am__dirstamp)
     979SynTree/Expression.$(OBJEXT): SynTree/$(am__dirstamp) \
     980        SynTree/$(DEPDIR)/$(am__dirstamp)
     981SynTree/FunctionDecl.$(OBJEXT): SynTree/$(am__dirstamp) \
     982        SynTree/$(DEPDIR)/$(am__dirstamp)
     983SynTree/FunctionType.$(OBJEXT): SynTree/$(am__dirstamp) \
     984        SynTree/$(DEPDIR)/$(am__dirstamp)
     985SynTree/Initializer.$(OBJEXT): SynTree/$(am__dirstamp) \
     986        SynTree/$(DEPDIR)/$(am__dirstamp)
     987SynTree/LinkageSpec.$(OBJEXT): SynTree/$(am__dirstamp) \
     988        SynTree/$(DEPDIR)/$(am__dirstamp)
     989SynTree/NamedTypeDecl.$(OBJEXT): SynTree/$(am__dirstamp) \
     990        SynTree/$(DEPDIR)/$(am__dirstamp)
     991SynTree/ObjectDecl.$(OBJEXT): SynTree/$(am__dirstamp) \
     992        SynTree/$(DEPDIR)/$(am__dirstamp)
     993SynTree/PointerType.$(OBJEXT): SynTree/$(am__dirstamp) \
     994        SynTree/$(DEPDIR)/$(am__dirstamp)
     995SynTree/ReferenceToType.$(OBJEXT): SynTree/$(am__dirstamp) \
     996        SynTree/$(DEPDIR)/$(am__dirstamp)
     997SynTree/ReferenceType.$(OBJEXT): SynTree/$(am__dirstamp) \
     998        SynTree/$(DEPDIR)/$(am__dirstamp)
     999SynTree/Statement.$(OBJEXT): SynTree/$(am__dirstamp) \
     1000        SynTree/$(DEPDIR)/$(am__dirstamp)
     1001SynTree/TupleExpr.$(OBJEXT): SynTree/$(am__dirstamp) \
     1002        SynTree/$(DEPDIR)/$(am__dirstamp)
     1003SynTree/TupleType.$(OBJEXT): SynTree/$(am__dirstamp) \
     1004        SynTree/$(DEPDIR)/$(am__dirstamp)
    9591005SynTree/Type.$(OBJEXT): SynTree/$(am__dirstamp) \
    9601006        SynTree/$(DEPDIR)/$(am__dirstamp)
     1007SynTree/TypeDecl.$(OBJEXT): SynTree/$(am__dirstamp) \
     1008        SynTree/$(DEPDIR)/$(am__dirstamp)
     1009SynTree/TypeExpr.$(OBJEXT): SynTree/$(am__dirstamp) \
     1010        SynTree/$(DEPDIR)/$(am__dirstamp)
     1011SynTree/TypeSubstitution.$(OBJEXT): SynTree/$(am__dirstamp) \
     1012        SynTree/$(DEPDIR)/$(am__dirstamp)
     1013SynTree/TypeofType.$(OBJEXT): SynTree/$(am__dirstamp) \
     1014        SynTree/$(DEPDIR)/$(am__dirstamp)
     1015SynTree/VarArgsType.$(OBJEXT): SynTree/$(am__dirstamp) \
     1016        SynTree/$(DEPDIR)/$(am__dirstamp)
    9611017SynTree/VoidType.$(OBJEXT): SynTree/$(am__dirstamp) \
    9621018        SynTree/$(DEPDIR)/$(am__dirstamp)
    963 SynTree/BasicType.$(OBJEXT): SynTree/$(am__dirstamp) \
    964         SynTree/$(DEPDIR)/$(am__dirstamp)
    965 SynTree/PointerType.$(OBJEXT): SynTree/$(am__dirstamp) \
    966         SynTree/$(DEPDIR)/$(am__dirstamp)
    967 SynTree/ArrayType.$(OBJEXT): SynTree/$(am__dirstamp) \
    968         SynTree/$(DEPDIR)/$(am__dirstamp)
    969 SynTree/ReferenceType.$(OBJEXT): SynTree/$(am__dirstamp) \
    970         SynTree/$(DEPDIR)/$(am__dirstamp)
    971 SynTree/FunctionType.$(OBJEXT): SynTree/$(am__dirstamp) \
    972         SynTree/$(DEPDIR)/$(am__dirstamp)
    973 SynTree/ReferenceToType.$(OBJEXT): SynTree/$(am__dirstamp) \
    974         SynTree/$(DEPDIR)/$(am__dirstamp)
    975 SynTree/TupleType.$(OBJEXT): SynTree/$(am__dirstamp) \
    976         SynTree/$(DEPDIR)/$(am__dirstamp)
    977 SynTree/TypeofType.$(OBJEXT): SynTree/$(am__dirstamp) \
    978         SynTree/$(DEPDIR)/$(am__dirstamp)
    979 SynTree/AttrType.$(OBJEXT): SynTree/$(am__dirstamp) \
    980         SynTree/$(DEPDIR)/$(am__dirstamp)
    981 SynTree/VarArgsType.$(OBJEXT): SynTree/$(am__dirstamp) \
    982         SynTree/$(DEPDIR)/$(am__dirstamp)
    9831019SynTree/ZeroOneType.$(OBJEXT): SynTree/$(am__dirstamp) \
    984         SynTree/$(DEPDIR)/$(am__dirstamp)
    985 SynTree/Constant.$(OBJEXT): SynTree/$(am__dirstamp) \
    986         SynTree/$(DEPDIR)/$(am__dirstamp)
    987 SynTree/Expression.$(OBJEXT): SynTree/$(am__dirstamp) \
    988         SynTree/$(DEPDIR)/$(am__dirstamp)
    989 SynTree/TupleExpr.$(OBJEXT): SynTree/$(am__dirstamp) \
    990         SynTree/$(DEPDIR)/$(am__dirstamp)
    991 SynTree/CommaExpr.$(OBJEXT): SynTree/$(am__dirstamp) \
    992         SynTree/$(DEPDIR)/$(am__dirstamp)
    993 SynTree/TypeExpr.$(OBJEXT): SynTree/$(am__dirstamp) \
    994         SynTree/$(DEPDIR)/$(am__dirstamp)
    995 SynTree/ApplicationExpr.$(OBJEXT): SynTree/$(am__dirstamp) \
    996         SynTree/$(DEPDIR)/$(am__dirstamp)
    997 SynTree/AddressExpr.$(OBJEXT): SynTree/$(am__dirstamp) \
    998         SynTree/$(DEPDIR)/$(am__dirstamp)
    999 SynTree/Statement.$(OBJEXT): SynTree/$(am__dirstamp) \
    1000         SynTree/$(DEPDIR)/$(am__dirstamp)
    1001 SynTree/CompoundStmt.$(OBJEXT): SynTree/$(am__dirstamp) \
    1002         SynTree/$(DEPDIR)/$(am__dirstamp)
    1003 SynTree/DeclStmt.$(OBJEXT): SynTree/$(am__dirstamp) \
    1004         SynTree/$(DEPDIR)/$(am__dirstamp)
    1005 SynTree/Declaration.$(OBJEXT): SynTree/$(am__dirstamp) \
    1006         SynTree/$(DEPDIR)/$(am__dirstamp)
    1007 SynTree/DeclarationWithType.$(OBJEXT): SynTree/$(am__dirstamp) \
    1008         SynTree/$(DEPDIR)/$(am__dirstamp)
    1009 SynTree/ObjectDecl.$(OBJEXT): SynTree/$(am__dirstamp) \
    1010         SynTree/$(DEPDIR)/$(am__dirstamp)
    1011 SynTree/FunctionDecl.$(OBJEXT): SynTree/$(am__dirstamp) \
    1012         SynTree/$(DEPDIR)/$(am__dirstamp)
    1013 SynTree/AggregateDecl.$(OBJEXT): SynTree/$(am__dirstamp) \
    1014         SynTree/$(DEPDIR)/$(am__dirstamp)
    1015 SynTree/NamedTypeDecl.$(OBJEXT): SynTree/$(am__dirstamp) \
    1016         SynTree/$(DEPDIR)/$(am__dirstamp)
    1017 SynTree/TypeDecl.$(OBJEXT): SynTree/$(am__dirstamp) \
    1018         SynTree/$(DEPDIR)/$(am__dirstamp)
    1019 SynTree/Initializer.$(OBJEXT): SynTree/$(am__dirstamp) \
    1020         SynTree/$(DEPDIR)/$(am__dirstamp)
    1021 SynTree/TypeSubstitution.$(OBJEXT): SynTree/$(am__dirstamp) \
    1022         SynTree/$(DEPDIR)/$(am__dirstamp)
    1023 SynTree/Attribute.$(OBJEXT): SynTree/$(am__dirstamp) \
    1024         SynTree/$(DEPDIR)/$(am__dirstamp)
    1025 SynTree/DeclReplacer.$(OBJEXT): SynTree/$(am__dirstamp) \
    10261020        SynTree/$(DEPDIR)/$(am__dirstamp)
    10271021Tuples/$(am__dirstamp):
     
    11401134InitTweak/FixGlobalInit.$(OBJEXT): InitTweak/$(am__dirstamp) \
    11411135        InitTweak/$(DEPDIR)/$(am__dirstamp)
     1136Parser/$(am__dirstamp):
     1137        @$(MKDIR_P) Parser
     1138        @: > Parser/$(am__dirstamp)
     1139Parser/$(DEPDIR)/$(am__dirstamp):
     1140        @$(MKDIR_P) Parser/$(DEPDIR)
     1141        @: > Parser/$(DEPDIR)/$(am__dirstamp)
     1142Parser/DeclarationNode.$(OBJEXT): Parser/$(am__dirstamp) \
     1143        Parser/$(DEPDIR)/$(am__dirstamp)
     1144Parser/ExpressionNode.$(OBJEXT): Parser/$(am__dirstamp) \
     1145        Parser/$(DEPDIR)/$(am__dirstamp)
     1146Parser/InitializerNode.$(OBJEXT): Parser/$(am__dirstamp) \
     1147        Parser/$(DEPDIR)/$(am__dirstamp)
     1148Parser/ParseNode.$(OBJEXT): Parser/$(am__dirstamp) \
     1149        Parser/$(DEPDIR)/$(am__dirstamp)
     1150Parser/StatementNode.$(OBJEXT): Parser/$(am__dirstamp) \
     1151        Parser/$(DEPDIR)/$(am__dirstamp)
     1152Parser/TypeData.$(OBJEXT): Parser/$(am__dirstamp) \
     1153        Parser/$(DEPDIR)/$(am__dirstamp)
     1154Parser/TypedefTable.$(OBJEXT): Parser/$(am__dirstamp) \
     1155        Parser/$(DEPDIR)/$(am__dirstamp)
     1156Parser/lex.$(OBJEXT): Parser/$(am__dirstamp) \
     1157        Parser/$(DEPDIR)/$(am__dirstamp)
    11421158Parser/parser.hh: Parser/parser.cc
    11431159        @if test ! -f $@; then rm -f Parser/parser.cc; else :; fi
    11441160        @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) Parser/parser.cc; else :; fi
    11451161Parser/parser.$(OBJEXT): Parser/$(am__dirstamp) \
    1146         Parser/$(DEPDIR)/$(am__dirstamp)
    1147 Parser/lex.$(OBJEXT): Parser/$(am__dirstamp) \
    1148         Parser/$(DEPDIR)/$(am__dirstamp)
    1149 Parser/TypedefTable.$(OBJEXT): Parser/$(am__dirstamp) \
    1150         Parser/$(DEPDIR)/$(am__dirstamp)
    1151 Parser/ParseNode.$(OBJEXT): Parser/$(am__dirstamp) \
    1152         Parser/$(DEPDIR)/$(am__dirstamp)
    1153 Parser/DeclarationNode.$(OBJEXT): Parser/$(am__dirstamp) \
    1154         Parser/$(DEPDIR)/$(am__dirstamp)
    1155 Parser/ExpressionNode.$(OBJEXT): Parser/$(am__dirstamp) \
    1156         Parser/$(DEPDIR)/$(am__dirstamp)
    1157 Parser/StatementNode.$(OBJEXT): Parser/$(am__dirstamp) \
    1158         Parser/$(DEPDIR)/$(am__dirstamp)
    1159 Parser/InitializerNode.$(OBJEXT): Parser/$(am__dirstamp) \
    1160         Parser/$(DEPDIR)/$(am__dirstamp)
    1161 Parser/TypeData.$(OBJEXT): Parser/$(am__dirstamp) \
    11621162        Parser/$(DEPDIR)/$(am__dirstamp)
    11631163Parser/parserutility.$(OBJEXT): Parser/$(am__dirstamp) \
     
    12701270@AMDEP_TRUE@@am__include@ @am__quote@Parser/$(DEPDIR)/ExpressionNode.Po@am__quote@
    12711271@AMDEP_TRUE@@am__include@ @am__quote@Parser/$(DEPDIR)/InitializerNode.Po@am__quote@
    1272 @AMDEP_TRUE@@am__include@ @am__quote@Parser/$(DEPDIR)/LinkageSpec.Po@am__quote@
    12731272@AMDEP_TRUE@@am__include@ @am__quote@Parser/$(DEPDIR)/ParseNode.Po@am__quote@
    12741273@AMDEP_TRUE@@am__include@ @am__quote@Parser/$(DEPDIR)/StatementNode.Po@am__quote@
     
    13291328@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/FunctionType.Po@am__quote@
    13301329@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/Initializer.Po@am__quote@
     1330@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/LinkageSpec.Po@am__quote@
    13311331@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/NamedTypeDecl.Po@am__quote@
    13321332@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/ObjectDecl.Po@am__quote@
  • src/Parser/DeclarationNode.cc

    r807a632 r3b56166  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 25 22:17:10 2019
    13 // Update Count     : 1116
     12// Last Modified On : Mon Dec 16 15:32:22 2019
     13// Update Count     : 1133
    1414//
    1515
     
    2424#include "Common/UniqueName.h"     // for UniqueName
    2525#include "Common/utility.h"        // for maybeClone, maybeBuild, CodeLocation
    26 #include "Parser/LinkageSpec.h"    // for Spec, linkageName, Cforall
    2726#include "Parser/ParseNode.h"      // for DeclarationNode, ExpressionNode
     27#include "SynTree/LinkageSpec.h"   // for Spec, linkageName, Cforall
    2828#include "SynTree/Attribute.h"     // for Attribute
    2929#include "SynTree/Declaration.h"   // for TypeDecl, ObjectDecl, Declaration
     
    4747const char * DeclarationNode::signednessNames[] = { "signed", "unsigned", "NoSignednessNames" };
    4848const char * DeclarationNode::lengthNames[] = { "short", "long", "long long", "NoLengthNames" };
    49 const char * DeclarationNode::aggregateNames[] = { "struct", "union", "trait", "coroutine", "monitor", "thread", "NoAggregateNames" };
    50 const char * DeclarationNode::typeClassNames[] = { "otype", "dtype", "ftype", "NoTypeClassNames" };
    5149const char * DeclarationNode::builtinTypeNames[] = { "__builtin_va_list", "__auto_type", "zero_t", "one_t", "NoBuiltinTypeNames" };
    5250
     
    5957
    6058//      variable.name = nullptr;
    61         variable.tyClass = NoTypeClass;
     59        variable.tyClass = TypeDecl::NUMBER_OF_KINDS;
    6260        variable.assertions = nullptr;
    6361        variable.initializer = nullptr;
     
    135133
    136134        if ( linkage != LinkageSpec::Cforall ) {
    137                 os << LinkageSpec::linkageName( linkage ) << " ";
     135                os << LinkageSpec::name( linkage ) << " ";
    138136        } // if
    139137
     
    267265}
    268266
    269 DeclarationNode * DeclarationNode::newAggregate( Aggregate kind, const string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) {
     267DeclarationNode * DeclarationNode::newAggregate( AggregateDecl::Aggregate kind, const string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) {
    270268        DeclarationNode * newnode = new DeclarationNode;
    271269        newnode->type = new TypeData( TypeData::Aggregate );
     
    313311} // DeclarationNode::newFromTypeGen
    314312
    315 DeclarationNode * DeclarationNode::newTypeParam( TypeClass tc, const string * name ) {
     313DeclarationNode * DeclarationNode::newTypeParam( TypeDecl::Kind tc, const string * name ) {
    316314        DeclarationNode * newnode = new DeclarationNode;
    317315        newnode->type = nullptr;
     
    328326        newnode->type = new TypeData( TypeData::Aggregate );
    329327        newnode->type->aggregate.name = name;
    330         newnode->type->aggregate.kind = Trait;
     328        newnode->type->aggregate.kind = AggregateDecl::Trait;
    331329        newnode->type->aggregate.params = params;
    332330        newnode->type->aggregate.fields = asserts;
     
    338336        newnode->type = new TypeData( TypeData::AggregateInst );
    339337        newnode->type->aggInst.aggregate = new TypeData( TypeData::Aggregate );
    340         newnode->type->aggInst.aggregate->aggregate.kind = Trait;
     338        newnode->type->aggInst.aggregate->aggregate.kind = AggregateDecl::Trait;
    341339        newnode->type->aggInst.aggregate->aggregate.name = name;
    342340        newnode->type->aggInst.params = params;
     
    671669
    672670DeclarationNode * DeclarationNode::addAssertions( DeclarationNode * assertions ) {
    673         if ( variable.tyClass != NoTypeClass ) {
     671        if ( variable.tyClass != TypeDecl::NUMBER_OF_KINDS ) {
    674672                if ( variable.assertions ) {
    675673                        variable.assertions->appendList( assertions );
     
    876874
    877875DeclarationNode * DeclarationNode::addTypeInitializer( DeclarationNode * init ) {
    878         assertf( variable.tyClass != NoTypeClass, "Called addTypeInitializer on something that isn't a type variable." );
     876        assertf( variable.tyClass != TypeDecl::NUMBER_OF_KINDS, "Called addTypeInitializer on something that isn't a type variable." );
    879877        variable.initializer = init;
    880878        return this;
     
    10751073        } // if
    10761074
    1077         if ( variable.tyClass != NoTypeClass ) {
     1075        if ( variable.tyClass != TypeDecl::NUMBER_OF_KINDS ) {
    10781076                // otype is internally converted to dtype + otype parameters
    10791077                static const TypeDecl::Kind kindMap[] = { TypeDecl::Dtype, TypeDecl::Dtype, TypeDecl::Ftype, TypeDecl::Ttype };
    1080                 assertf( sizeof(kindMap)/sizeof(kindMap[0]) == NoTypeClass, "DeclarationNode::build: kindMap is out of sync." );
     1078                static_assert( sizeof(kindMap)/sizeof(kindMap[0]) == TypeDecl::NUMBER_OF_KINDS, "DeclarationNode::build: kindMap is out of sync." );
    10811079                assertf( variable.tyClass < sizeof(kindMap)/sizeof(kindMap[0]), "Variable's tyClass is out of bounds." );
    1082                 TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ], variable.tyClass == Otype, variable.initializer ? variable.initializer->buildType() : nullptr );
     1080                TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ], variable.tyClass == TypeDecl::Otype, variable.initializer ? variable.initializer->buildType() : nullptr );
    10831081                buildList( variable.assertions, ret->get_assertions() );
    10841082                return ret;
  • src/Parser/ExpressionNode.cc

    r807a632 r3b56166  
    1010// Created On       : Sat May 16 13:17:07 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Aug  4 20:57:55 2019
    13 // Update Count     : 978
     12// Last Modified On : Wed Dec 18 21:14:58 2019
     13// Update Count     : 981
    1414//
    1515
     
    265265        static const BasicType::Kind kind[2][12] = {
    266266                { BasicType::Float, BasicType::Double, BasicType::LongDouble, BasicType::uuFloat80, BasicType::uuFloat128, BasicType::uFloat16, BasicType::uFloat32, BasicType::uFloat32x, BasicType::uFloat64, BasicType::uFloat64x, BasicType::uFloat128, BasicType::uFloat128x },
    267                 { BasicType::FloatComplex, BasicType::DoubleComplex, BasicType::LongDoubleComplex, (BasicType::Kind)-1, (BasicType::Kind)-1, BasicType::uFloat16Complex, BasicType::uFloat32Complex, BasicType::uFloat32xComplex, BasicType::uFloat64Complex, BasicType::uFloat64xComplex, BasicType::uFloat128Complex, BasicType::uFloat128xComplex },
     267                { BasicType::FloatComplex, BasicType::DoubleComplex, BasicType::LongDoubleComplex, BasicType::NUMBER_OF_BASIC_TYPES, BasicType::NUMBER_OF_BASIC_TYPES, BasicType::uFloat16Complex, BasicType::uFloat32Complex, BasicType::uFloat32xComplex, BasicType::uFloat64Complex, BasicType::uFloat64xComplex, BasicType::uFloat128Complex, BasicType::uFloat128xComplex },
    268268        };
    269269
     
    374374
    375375Expression * build_field_name_FLOATING_DECIMALconstant( const string & str ) {
    376         if ( str[str.size()-1] != '.' ) SemanticError( yylloc, "invalid tuple index " + str );
     376        if ( str[str.size() - 1] != '.' ) SemanticError( yylloc, "invalid tuple index " + str );
    377377        Expression * ret = build_constantInteger( *new string( str.substr( 0, str.size()-1 ) ) );
    378378        delete &str;
     
    434434} // build_cast
    435435
    436 Expression * build_keyword_cast( KeywordCastExpr::Target target, ExpressionNode * expr_node ) {
     436Expression * build_keyword_cast( AggregateDecl::Aggregate target, ExpressionNode * expr_node ) {
    437437        return new KeywordCastExpr( maybeMoveBuild< Expression >(expr_node), target );
    438438}
  • src/Parser/ParseNode.h

    r807a632 r3b56166  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 25 22:17:10 2019
    13 // Update Count     : 876
     12// Last Modified On : Fri Feb  7 17:56:02 2020
     13// Update Count     : 891
    1414//
    1515
     
    2828#include "Common/UniqueName.h"     // for UniqueName
    2929#include "Common/utility.h"        // for maybeClone, maybeBuild
    30 #include "Parser/LinkageSpec.h"    // for Spec
     30#include "SynTree/LinkageSpec.h"   // for Spec
     31#include "SynTree/Declaration.h"   // for Aggregate
    3132#include "SynTree/Expression.h"    // for Expression, ConstantExpr (ptr only)
    3233#include "SynTree/Label.h"         // for Label
     
    184185
    185186Expression * build_cast( DeclarationNode * decl_node, ExpressionNode * expr_node );
    186 Expression * build_keyword_cast( KeywordCastExpr::Target target, ExpressionNode * expr_node );
     187Expression * build_keyword_cast( AggregateDecl::Aggregate target, ExpressionNode * expr_node );
    187188Expression * build_virtual_cast( DeclarationNode * decl_node, ExpressionNode * expr_node );
    188189Expression * build_fieldSel( ExpressionNode * expr_node, Expression * member );
     
    217218        enum Length { Short, Long, LongLong, NoLength };
    218219        static const char * lengthNames[];
    219         enum Aggregate { Struct, Union, Exception, Trait, Coroutine, Monitor, Thread, NoAggregate };
    220         static const char * aggregateNames[];
    221         enum TypeClass { Otype, Dtype, Ftype, Ttype, NoTypeClass };
    222         static const char * typeClassNames[];
    223220        enum BuiltinType { Valist, AutoType, Zero, One, NoBuiltinType };
    224221        static const char * builtinTypeNames[];
     
    237234        static DeclarationNode * newQualifiedType( DeclarationNode *, DeclarationNode * );
    238235        static DeclarationNode * newFunction( const std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body );
    239         static DeclarationNode * newAggregate( Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body );
     236        static DeclarationNode * newAggregate( AggregateDecl::Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body );
    240237        static DeclarationNode * newEnum( const std::string * name, DeclarationNode * constants, bool body );
    241238        static DeclarationNode * newEnumConstant( const std::string * name, ExpressionNode * constant );
    242239        static DeclarationNode * newName( const std::string * );
    243240        static DeclarationNode * newFromTypeGen( const std::string *, ExpressionNode * params );
    244         static DeclarationNode * newTypeParam( TypeClass, const std::string * );
     241        static DeclarationNode * newTypeParam( TypeDecl::Kind, const std::string * );
    245242        static DeclarationNode * newTrait( const std::string * name, DeclarationNode * params, DeclarationNode * asserts );
    246243        static DeclarationNode * newTraitUse( const std::string * name, ExpressionNode * params );
     
    312309        struct Variable_t {
    313310//              const std::string * name;
    314                 DeclarationNode::TypeClass tyClass;
     311                TypeDecl::Kind tyClass;
    315312                DeclarationNode * assertions;
    316313                DeclarationNode * initializer;
     
    452449                                * out++ = result;
    453450                        } else {
    454                                 assertf(false, "buildList unknown type");
     451                                SemanticError( cur->location, "type specifier declaration in forall clause is currently unimplemented." );
    455452                        } // if
    456453                } catch( SemanticErrorException & e ) {
  • src/Parser/TypeData.cc

    r807a632 r3b56166  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Feb 13 18:16:23 2019
    13 // Update Count     : 649
     12// Last Modified On : Mon Dec 16 07:56:46 2019
     13// Update Count     : 662
    1414//
    1515
     
    6767          case Aggregate:
    6868                // aggregate = new Aggregate_t;
    69                 aggregate.kind = DeclarationNode::NoAggregate;
     69                aggregate.kind = AggregateDecl::NoAggregate;
    7070                aggregate.name = nullptr;
    7171                aggregate.params = nullptr;
     
    345345                break;
    346346          case Aggregate:
    347                 os << DeclarationNode::aggregateNames[ aggregate.kind ] << ' ' << *aggregate.name << endl;
     347                os << AggregateDecl::aggrString( aggregate.kind ) << ' ' << *aggregate.name << endl;
    348348                if ( aggregate.params ) {
    349349                        os << string( indent + 2, ' ' ) << "with type parameters" << endl;
     
    489489        for ( typename ForallList::iterator i = outputList.begin(); i != outputList.end(); ++i, n = (DeclarationNode*)n->get_next() ) {
    490490                TypeDecl * td = static_cast<TypeDecl *>(*i);
    491                 if ( n->variable.tyClass == DeclarationNode::Otype ) {
     491                if ( n->variable.tyClass == TypeDecl::Otype ) {
    492492                        // add assertion parameters to `type' tyvars in reverse order
    493493                        // add dtor:  void ^?{}(T *)
     
    522522        switch ( td->kind ) {
    523523          case TypeData::Unknown:
    524                         // fill in implicit int
    525                         return new BasicType( buildQualifiers( td ), BasicType::SignedInt );
     524                // fill in implicit int
     525                return new BasicType( buildQualifiers( td ), BasicType::SignedInt );
    526526          case TypeData::Basic:
    527                         return buildBasicType( td );
     527                return buildBasicType( td );
    528528          case TypeData::Pointer:
    529                         return buildPointer( td );
     529                return buildPointer( td );
    530530          case TypeData::Array:
    531                         return buildArray( td );
     531                return buildArray( td );
    532532          case TypeData::Reference:
    533                         return buildReference( td );
     533                return buildReference( td );
    534534          case TypeData::Function:
    535                         return buildFunction( td );
     535                return buildFunction( td );
    536536          case TypeData::AggregateInst:
    537                         return buildAggInst( td );
     537                return buildAggInst( td );
    538538          case TypeData::EnumConstant:
    539                         // the name gets filled in later -- by SymTab::Validate
    540                         return new EnumInstType( buildQualifiers( td ), "" );
     539                // the name gets filled in later -- by SymTab::Validate
     540                return new EnumInstType( buildQualifiers( td ), "" );
    541541          case TypeData::SymbolicInst:
    542                         return buildSymbolicInst( td );
     542                return buildSymbolicInst( td );
    543543          case TypeData::Tuple:
    544                         return buildTuple( td );
     544                return buildTuple( td );
    545545          case TypeData::Typeof:
    546546          case TypeData::Basetypeof:
    547                         return buildTypeof( td );
     547                return buildTypeof( td );
    548548          case TypeData::Builtin:
    549                         if (td->builtintype == DeclarationNode::Zero) {
    550                                 return new ZeroType( noQualifiers );
    551                         }
    552                         else if (td->builtintype == DeclarationNode::One) {
    553                                 return new OneType( noQualifiers );
    554                         }
    555                         else {
    556                                 return new VarArgsType( buildQualifiers( td ) );
    557                         }
     549                switch ( td->builtintype ) {
     550                  case DeclarationNode::Zero:
     551                        return new ZeroType( noQualifiers );
     552                  case DeclarationNode::One:
     553                        return new OneType( noQualifiers );
     554                  default:
     555                        return new VarArgsType( buildQualifiers( td ) );
     556                } // switch
    558557          case TypeData::GlobalScope:
    559                         return new GlobalScopeType();
    560                 case TypeData::Qualified:
    561                         return new QualifiedType( buildQualifiers( td ), typebuild( td->qualified.parent ), typebuild( td->qualified.child ) );
     558                return new GlobalScopeType();
     559          case TypeData::Qualified:
     560                return new QualifiedType( buildQualifiers( td ), typebuild( td->qualified.parent ), typebuild( td->qualified.child ) );
    562561          case TypeData::Symbolic:
    563562          case TypeData::Enum:
    564563          case TypeData::Aggregate:
    565                         assert( false );
     564                assert( false );
    566565        } // switch
    567566
     
    768767        AggregateDecl * at;
    769768        switch ( td->aggregate.kind ) {
    770           case DeclarationNode::Struct:
    771           case DeclarationNode::Coroutine:
    772           case DeclarationNode::Monitor:
    773           case DeclarationNode::Thread:
     769          case AggregateDecl::Struct:
     770          case AggregateDecl::Coroutine:
     771          case AggregateDecl::Monitor:
     772          case AggregateDecl::Thread:
    774773                at = new StructDecl( *td->aggregate.name, td->aggregate.kind, attributes, linkage );
    775774                buildForall( td->aggregate.params, at->get_parameters() );
    776775                break;
    777           case DeclarationNode::Union:
     776          case AggregateDecl::Union:
    778777                at = new UnionDecl( *td->aggregate.name, attributes, linkage );
    779778                buildForall( td->aggregate.params, at->get_parameters() );
    780779                break;
    781           case DeclarationNode::Trait:
     780          case AggregateDecl::Trait:
    782781                at = new TraitDecl( *td->aggregate.name, attributes, linkage );
    783782                buildList( td->aggregate.params, at->get_parameters() );
     
    809808                          AggregateDecl * typedecl = buildAggregate( type, attributes, linkage );
    810809                          switch ( type->aggregate.kind ) {
    811                                 case DeclarationNode::Struct:
    812                                 case DeclarationNode::Coroutine:
    813                                 case DeclarationNode::Monitor:
    814                                 case DeclarationNode::Thread:
     810                                case AggregateDecl::Struct:
     811                                case AggregateDecl::Coroutine:
     812                                case AggregateDecl::Monitor:
     813                                case AggregateDecl::Thread:
    815814                                  ret = new StructInstType( buildQualifiers( type ), (StructDecl *)typedecl );
    816815                                  break;
    817                                 case DeclarationNode::Union:
     816                                case AggregateDecl::Union:
    818817                                  ret = new UnionInstType( buildQualifiers( type ), (UnionDecl *)typedecl );
    819818                                  break;
    820                                 case DeclarationNode::Trait:
     819                                case AggregateDecl::Trait:
    821820                                  assert( false );
    822821                                  //ret = new TraitInstType( buildQualifiers( type ), (TraitDecl *)typedecl );
     
    827826                  } else {
    828827                          switch ( type->aggregate.kind ) {
    829                                 case DeclarationNode::Struct:
    830                                 case DeclarationNode::Coroutine:
    831                                 case DeclarationNode::Monitor:
    832                                 case DeclarationNode::Thread:
     828                                case AggregateDecl::Struct:
     829                                case AggregateDecl::Coroutine:
     830                                case AggregateDecl::Monitor:
     831                                case AggregateDecl::Thread:
    833832                                  ret = new StructInstType( buildQualifiers( type ), *type->aggregate.name );
    834833                                  break;
    835                                 case DeclarationNode::Union:
     834                                case AggregateDecl::Union:
    836835                                  ret = new UnionInstType( buildQualifiers( type ), *type->aggregate.name );
    837836                                  break;
    838                                 case DeclarationNode::Trait:
     837                                case AggregateDecl::Trait:
    839838                                  ret = new TraitInstType( buildQualifiers( type ), *type->aggregate.name );
    840839                                  break;
     
    863862          case TypeData::Aggregate: {
    864863                  switch ( type->aggregate.kind ) {
    865                         case DeclarationNode::Struct:
    866                         case DeclarationNode::Coroutine:
    867                         case DeclarationNode::Monitor:
    868                         case DeclarationNode::Thread:
     864                        case AggregateDecl::Struct:
     865                        case AggregateDecl::Coroutine:
     866                        case AggregateDecl::Monitor:
     867                        case AggregateDecl::Thread:
    869868                          ret = new StructInstType( buildQualifiers( type ), *type->aggregate.name );
    870869                          break;
    871                         case DeclarationNode::Union:
     870                        case AggregateDecl::Union:
    872871                          ret = new UnionInstType( buildQualifiers( type ), *type->aggregate.name );
    873872                          break;
    874                         case DeclarationNode::Trait:
     873                        case AggregateDecl::Trait:
    875874                          ret = new TraitInstType( buildQualifiers( type ), *type->aggregate.name );
    876875                          break;
  • src/Parser/TypeData.h

    r807a632 r3b56166  
    1010// Created On       : Sat May 16 15:18:36 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Nov  1 20:56:46 2018
    13 // Update Count     : 196
     12// Last Modified On : Fri Dec 13 23:42:35 2019
     13// Update Count     : 199
    1414//
    1515
     
    2121
    2222#include "ParseNode.h"           // for DeclarationNode, DeclarationNode::Ag...
    23 #include "Parser/LinkageSpec.h" // for Spec
     23#include "SynTree/LinkageSpec.h" // for Spec
    2424#include "SynTree/Type.h"        // for Type, ReferenceToType (ptr only)
    2525#include "SynTree/SynTree.h"     // for Visitor Nodes
     
    3030
    3131        struct Aggregate_t {
    32                 DeclarationNode::Aggregate kind;
     32                AggregateDecl::Aggregate kind;
    3333                const std::string * name = nullptr;
    3434                DeclarationNode * params = nullptr;
  • src/Parser/lex.ll

    r807a632 r3b56166  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Sun Aug  4 20:53:47 2019
    13  * Update Count     : 719
     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 - 1] = '\0'; yytext += 1;                         // 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/Parser/module.mk

    r807a632 r3b56166  
    1111## Created On       : Sat May 16 15:29:09 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Wed Jun 28 21:58:29 2017
    14 ## Update Count     : 104
     13## Last Modified On : Sat Dec 14 07:34:47 2019
     14## Update Count     : 107
    1515###############################################################################
    1616
     
    1919AM_YFLAGS = -d -t -v
    2020
    21 SRC += Parser/parser.yy \
    22        Parser/lex.ll \
    23        Parser/TypedefTable.cc \
    24        Parser/ParseNode.cc \
     21SRC += \
    2522       Parser/DeclarationNode.cc \
    2623       Parser/ExpressionNode.cc \
     24       Parser/InitializerNode.cc \
     25       Parser/ParseNode.cc \
    2726       Parser/StatementNode.cc \
    28        Parser/InitializerNode.cc \
    2927       Parser/TypeData.cc \
    30        Parser/LinkageSpec.cc \
     28       Parser/TypedefTable.cc \
     29       Parser/lex.ll \
     30       Parser/parser.yy \
    3131       Parser/parserutility.cc
    3232
    33 SRCDEMANGLE += \
    34         Parser/LinkageSpec.cc
    35 
    36 
    3733MOSTLYCLEANFILES += Parser/lex.cc Parser/parser.cc Parser/parser.hh Parser/parser.output
  • src/Parser/parser.yy

    r807a632 r3b56166  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Aug  4 21:48:23 2019
    13 // Update Count     : 4364
     12// Last Modified On : Sat Feb  1 10:04:40 2020
     13// Update Count     : 4440
    1414//
    1515
     
    5151using namespace std;
    5252
     53#include "SynTree/Declaration.h"
    5354#include "ParseNode.h"
    5455#include "TypedefTable.h"
    5556#include "TypeData.h"
    56 #include "LinkageSpec.h"
     57#include "SynTree/LinkageSpec.h"
    5758#include "Common/SemanticError.h"                                               // error_str
    5859#include "Common/utility.h"                                                             // for maybeMoveBuild, maybeBuild, CodeLo...
     
    211212} // forCtrl
    212213
    213 
    214214bool forall = false, yyy = false;                                               // aggregate have one or more forall qualifiers ?
    215215
     
    237237        ExpressionNode * en;
    238238        DeclarationNode * decl;
    239         DeclarationNode::Aggregate aggKey;
    240         DeclarationNode::TypeClass tclass;
     239        AggregateDecl::Aggregate aggKey;
     240        TypeDecl::Kind tclass;
    241241        StatementNode * sn;
    242242        WaitForStmt * wfs;
     
    323323%type<op> ptrref_operator                               unary_operator                          assignment_operator
    324324%type<en> primary_expression                    postfix_expression                      unary_expression
    325 %type<en> cast_expression                               exponential_expression          multiplicative_expression       additive_expression
     325%type<en> cast_expression_list                  cast_expression                         exponential_expression          multiplicative_expression       additive_expression
    326326%type<en> shift_expression                              relational_expression           equality_expression
    327327%type<en> AND_expression                                exclusive_OR_expression         inclusive_OR_expression
     
    365365%type<decl> abstract_parameter_declaration
    366366
    367 %type<aggKey> aggregate_key
     367%type<aggKey> aggregate_key aggregate_data aggregate_control
    368368%type<decl> aggregate_type aggregate_type_nobody
    369369
     
    579579        | '(' compound_statement ')'                                            // GCC, lambda expression
    580580                { $$ = new ExpressionNode( new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >($2) ) ) ); }
    581         | constant '`' IDENTIFIER                                                       // CFA, postfix call
    582                 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); }
    583         | string_literal '`' IDENTIFIER                                         // CFA, postfix call
    584                 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), new ExpressionNode( $1 ) ) ); }
    585         | IDENTIFIER '`' IDENTIFIER                                                     // CFA, postfix call
    586                 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), new ExpressionNode( build_varref( $1 ) ) ) ); }
    587         | tuple '`' IDENTIFIER                                                          // CFA, postfix call
    588                 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); }
    589         | '(' comma_expression ')' '`' IDENTIFIER                       // CFA, postfix call
    590                 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $5 ) ), $2 ) ); }
    591581        | type_name '.' identifier                                                      // CFA, nested type
    592582                { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }
     
    642632        | postfix_expression '(' argument_expression_list ')'
    643633                { $$ = new ExpressionNode( build_func( $1, $3 ) ); }
     634        | postfix_expression '`' identifier                                     // CFA, postfix call
     635                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); }
     636        | constant '`' identifier                                                       // CFA, postfix call
     637                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); }
     638        | string_literal '`' identifier                                         // CFA, postfix call
     639                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), new ExpressionNode( $1 ) ) ); }
    644640        | postfix_expression '.' identifier
    645641                { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); }
     
    650646        | postfix_expression '.' '[' field_name_list ']'        // CFA, tuple field selector
    651647                { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); }
     648        | postfix_expression '.' aggregate_control
     649                { $$ = new ExpressionNode( build_keyword_cast( $3, $1 ) ); }
    652650        | postfix_expression ARROW identifier
    653651                { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); }
     
    664662        | '(' type_no_function ')' '@' '{' initializer_list_opt comma_opt '}' // CFA, explicit C compound-literal
    665663                { $$ = new ExpressionNode( build_compoundLiteral( $2, (new InitializerNode( $6, true ))->set_maybeConstructed( false ) ) ); }
    666         | '^' primary_expression '{' argument_expression_list '}' // CFA
     664        | '^' primary_expression '{' argument_expression_list '}' // CFA, destructor call
    667665                {
    668666                        Token fn;
     
    677675        | argument_expression
    678676        | argument_expression_list ',' argument_expression
    679                 { $$ = (ExpressionNode *)( $1->set_last( $3 )); }
     677                { $$ = (ExpressionNode *)($1->set_last( $3 )); }
    680678        ;
    681679
     
    689687field_name_list:                                                                                // CFA, tuple field selector
    690688        field
    691         | field_name_list ',' field                                     { $$ = (ExpressionNode *)$1->set_last( $3 ); }
     689        | field_name_list ',' field                                     { $$ = (ExpressionNode *)($1->set_last( $3 )); }
    692690        ;
    693691
     
    793791        | '(' type_no_function ')' cast_expression
    794792                { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
    795                 // keyword cast cannot be grouped because of reduction in aggregate_key
    796         | '(' GENERATOR '&' ')' cast_expression                         // CFA
    797                 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Coroutine, $5 ) ); }
    798         | '(' COROUTINE '&' ')' cast_expression                         // CFA
    799                 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Coroutine, $5 ) ); }
    800         | '(' THREAD '&' ')' cast_expression                            // CFA
    801                 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Thread, $5 ) ); }
    802         | '(' MONITOR '&' ')' cast_expression                           // CFA
    803                 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Monitor, $5 ) ); }
     793        | '(' aggregate_control '&' ')' cast_expression         // CFA
     794                { $$ = new ExpressionNode( build_keyword_cast( $2, $5 ) ); }
    804795                // VIRTUAL cannot be opt because of look ahead issues
    805796        | '(' VIRTUAL ')' cast_expression                                       // CFA
     
    965956                { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $3 ) ) ); }
    966957        | '[' push assignment_expression pop ',' tuple_expression_list ']'
    967                 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)$3->set_last( $6 ) ) ); }
     958                { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)($3->set_last( $6 ) ) )); }
    968959        ;
    969960
     
    971962        assignment_expression_opt
    972963        | tuple_expression_list ',' assignment_expression_opt
    973                 { $$ = (ExpressionNode *)$1->set_last( $3 ); }
     964                { $$ = (ExpressionNode *)($1->set_last( $3 )); }
    974965        ;
    975966
     
    11951186                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
    11961187                                                OperKinds::LThan, $1->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
     1188        | '=' comma_expression                                                                  // CFA
     1189                { $$ = forCtrl( $2, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
     1190                                                OperKinds::LEThan, $2->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
    11971191        | comma_expression inclexcl comma_expression            // CFA
    11981192                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
     
    12021196                { $$ = forCtrl( $3, $1, new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
    12031197                                                OperKinds::LThan, $3->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
     1198        | comma_expression ';' '=' comma_expression                             // CFA
     1199                { $$ = forCtrl( $4, $1, new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
     1200                                                OperKinds::LEThan, $4->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
    12041201        | comma_expression ';' comma_expression inclexcl comma_expression // CFA
    12051202                { $$ = forCtrl( $3, $1, $3->clone(), $4, $5, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
     
    13061303        WAITFOR '(' cast_expression ')'
    13071304                { $$ = $3; }
    1308         | WAITFOR '(' cast_expression ',' argument_expression_list ')'
    1309                 { $$ = (ExpressionNode *)$3->set_last( $5 ); }
     1305//      | WAITFOR '(' cast_expression ',' argument_expression_list ')'
     1306//              { $$ = (ExpressionNode *)$3->set_last( $5 ); }
     1307        | WAITFOR '(' cast_expression_list ':' argument_expression_list ')'
     1308                { $$ = (ExpressionNode *)($3->set_last( $5 )); }
     1309        ;
     1310
     1311cast_expression_list:
     1312        cast_expression
     1313        | cast_expression_list ',' cast_expression
     1314                { $$ = (ExpressionNode *)($1->set_last( $3 )); }
    13101315        ;
    13111316
     
    14181423        asm_operand
    14191424        | asm_operands_list ',' asm_operand
    1420                 { $$ = (ExpressionNode *)$1->set_last( $3 ); }
     1425                { $$ = (ExpressionNode *)($1->set_last( $3 )); }
    14211426        ;
    14221427
    14231428asm_operand:                                                                                    // GCC
    14241429        string_literal '(' constant_expression ')'
    1425                 { $$ = new ExpressionNode( new AsmExpr( maybeMoveBuild< Expression >( (ExpressionNode *)nullptr ), $1, maybeMoveBuild< Expression >( $3 ) ) ); }
    1426         | '[' constant_expression ']' string_literal '(' constant_expression ')'
    1427                 { $$ = new ExpressionNode( new AsmExpr( maybeMoveBuild< Expression >( $2 ), $4, maybeMoveBuild< Expression >( $6 ) ) ); }
     1430                { $$ = new ExpressionNode( new AsmExpr( nullptr, $1, maybeMoveBuild< Expression >( $3 ) ) ); }
     1431        | '[' IDENTIFIER ']' string_literal '(' constant_expression ')'
     1432                { $$ = new ExpressionNode( new AsmExpr( $2, $4, maybeMoveBuild< Expression >( $6 ) ) ); }
    14281433        ;
    14291434
     
    14341439                { $$ = new ExpressionNode( $1 ); }
    14351440        | asm_clobbers_list_opt ',' string_literal
    1436                 // set_last returns ParseNode *
    1437                 { $$ = (ExpressionNode *)$1->set_last( new ExpressionNode( $3 ) ); }
     1441                { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( $3 ) )); }
    14381442        ;
    14391443
     
    20592063
    20602064aggregate_key:
     2065        aggregate_data
     2066        | aggregate_control
     2067        ;
     2068
     2069aggregate_data:
    20612070        STRUCT
    2062                 { yyy = true; $$ = DeclarationNode::Struct; }
     2071                { yyy = true; $$ = AggregateDecl::Struct; }
    20632072        | UNION
    2064                 { yyy = true; $$ = DeclarationNode::Union; }
    2065         | EXCEPTION
    2066                 { yyy = true; $$ = DeclarationNode::Exception; }
    2067         | GENERATOR
    2068                 { yyy = true; $$ = DeclarationNode::Coroutine; }
     2073                { yyy = true; $$ = AggregateDecl::Union; }
     2074        | EXCEPTION                                                                                     // CFA
     2075                { yyy = true; $$ = AggregateDecl::Exception; }
     2076        ;
     2077
     2078aggregate_control:                                                                              // CFA
     2079        GENERATOR
     2080                { yyy = true; $$ = AggregateDecl::Coroutine; }
    20692081        | COROUTINE
    2070                 { yyy = true; $$ = DeclarationNode::Coroutine; }
     2082                { yyy = true; $$ = AggregateDecl::Coroutine; }
    20712083        | MONITOR
    2072                 { yyy = true; $$ = DeclarationNode::Monitor; }
     2084                { yyy = true; $$ = AggregateDecl::Monitor; }
    20732085        | THREAD
    2074                 { yyy = true; $$ = DeclarationNode::Thread; }
     2086                { yyy = true; $$ = AggregateDecl::Thread; }
    20752087        ;
    20762088
     
    20962108                        distInl( $3 );
    20972109                }
     2110        | INLINE aggregate_control ';'                                          // CFA
     2111                { SemanticError( yylloc, "INLINE aggregate control currently unimplemented." ); $$ = nullptr; }
    20982112        | typedef_declaration ';'                                                       // CFA
    20992113        | cfa_field_declaring_list ';'                                          // CFA, new style field declaration
     
    23482362        | initializer_list_opt ',' initializer          { $$ = (InitializerNode *)( $1->set_last( $3 ) ); }
    23492363        | initializer_list_opt ',' designation initializer
    2350                 { $$ = (InitializerNode *)( $1->set_last( $4->set_designators( $3 ) ) ); }
     2364                { $$ = (InitializerNode *)($1->set_last( $4->set_designators( $3 ) )); }
    23512365        ;
    23522366
     
    23702384        designator
    23712385        | designator_list designator
    2372                 { $$ = (ExpressionNode *)( $1->set_last( $2 ) ); }
     2386                { $$ = (ExpressionNode *)($1->set_last( $2 )); }
    23732387        //| designator_list designator                                          { $$ = new ExpressionNode( $1, $2 ); }
    23742388        ;
     
    24262440        | type_specifier identifier_parameter_declarator
    24272441        | assertion_list
    2428                 { $$ = DeclarationNode::newTypeParam( DeclarationNode::Dtype, new string( DeclarationNode::anonymous.newName() ) )->addAssertions( $1 ); }
     2442                { $$ = DeclarationNode::newTypeParam( TypeDecl::Dtype, new string( DeclarationNode::anonymous.newName() ) )->addAssertions( $1 ); }
    24292443        ;
    24302444
    24312445type_class:                                                                                             // CFA
    24322446        OTYPE
    2433                 { $$ = DeclarationNode::Otype; }
     2447                { $$ = TypeDecl::Otype; }
    24342448        | DTYPE
    2435                 { $$ = DeclarationNode::Dtype; }
     2449                { $$ = TypeDecl::Dtype; }
    24362450        | FTYPE
    2437                 { $$ = DeclarationNode::Ftype; }
     2451                { $$ = TypeDecl::Ftype; }
    24382452        | TTYPE
    2439                 { $$ = DeclarationNode::Ttype; }
     2453                { $$ = TypeDecl::Ttype; }
    24402454        ;
    24412455
     
    24672481                { SemanticError( yylloc, toString("Expression generic parameters are currently unimplemented: ", $1->build()) ); $$ = nullptr; }
    24682482        | type_list ',' type
    2469                 { $$ = (ExpressionNode *)( $1->set_last( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ) ) ); }
     2483                { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ) )); }
    24702484        | type_list ',' assignment_expression
    24712485                { SemanticError( yylloc, toString("Expression generic parameters are currently unimplemented: ", $3->build()) ); $$ = nullptr; }
     
    25782592                {
    25792593                        linkageStack.push( linkage );                           // handle nested extern "C"/"Cforall"
    2580                         linkage = LinkageSpec::linkageUpdate( yylloc, linkage, $2 );
     2594                        linkage = LinkageSpec::update( yylloc, linkage, $2 );
    25812595                }
    25822596          '{' up external_definition_list_opt down '}'
  • src/ResolvExpr/AdjustExprType.cc

    r807a632 r3b56166  
    1010// Created On       : Sat May 16 23:41:42 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 17:34:53 2016
    13 // Update Count     : 4
     12// Last Modified On : Wed Dec 11 21:43:56 2019
     13// Update Count     : 6
    1414//
    1515
     
    133133                        // replace known function-type-variables with pointer-to-function
    134134                        if ( const ast::EqvClass * eqvClass = tenv.lookup( inst->name ) ) {
    135                                 if ( eqvClass->data.kind == ast::TypeVar::Ftype ) {
     135                                if ( eqvClass->data.kind == ast::TypeDecl::Ftype ) {
    136136                                        return new ast::PointerType{ inst };
    137137                                }
    138138                        } else if ( const ast::NamedTypeDecl * ntDecl = symtab.lookupType( inst->name ) ) {
    139139                                if ( auto tyDecl = dynamic_cast< const ast::TypeDecl * >( ntDecl ) ) {
    140                                         if ( tyDecl->kind == ast::TypeVar::Ftype ) {
     140                                        if ( tyDecl->kind == ast::TypeDecl::Ftype ) {
    141141                                                return new ast::PointerType{ inst };
    142142                                        }
  • src/ResolvExpr/AlternativeFinder.cc

    r807a632 r3b56166  
    6969                void postvisit( CastExpr * castExpr );
    7070                void postvisit( VirtualCastExpr * castExpr );
     71                void postvisit( KeywordCastExpr * castExpr );
    7172                void postvisit( UntypedMemberExpr * memberExpr );
    7273                void postvisit( MemberExpr * memberExpr );
     
    12551256        }
    12561257
     1258        void AlternativeFinder::Finder::postvisit( KeywordCastExpr * castExpr ) {
     1259                assertf( castExpr->get_result(), "Cast target should have been set in Validate." );
     1260                auto ref = dynamic_cast<ReferenceType*>(castExpr->get_result());
     1261                assert(ref);
     1262                auto inst = dynamic_cast<StructInstType*>(ref->base);
     1263                assert(inst);
     1264                auto target = inst->baseStruct;
     1265
     1266                AlternativeFinder finder( indexer, env );
     1267
     1268                auto pick_alternatives = [target, this](AltList & found, bool expect_ref) {
     1269                        for(auto & alt : found) {
     1270                                Type * expr = alt.expr->get_result();
     1271                                if(expect_ref) {
     1272                                        auto res = dynamic_cast<ReferenceType*>(expr);
     1273                                        if(!res) { continue; }
     1274                                        expr = res->base;
     1275                                }
     1276
     1277                                if(auto insttype = dynamic_cast<TypeInstType*>(expr)) {
     1278                                        auto td = alt.env.lookup(insttype->name);
     1279                                        if(!td) { continue; }
     1280                                        expr = td->type;
     1281                                }
     1282
     1283                                if(auto base = dynamic_cast<StructInstType*>(expr)) {
     1284                                        if(base->baseStruct == target) {
     1285                                                alternatives.push_back(
     1286                                                        std::move(alt)
     1287                                                );
     1288                                        }
     1289                                }
     1290                        }
     1291                };
     1292
     1293                try {
     1294                        // Attempt 1 : turn (thread&)X into (thread_desc&)X.__thrd
     1295                        // Clone is purely for memory management
     1296                        std::unique_ptr<Expression> tech1 { new UntypedMemberExpr(new NameExpr(castExpr->concrete_target.field), castExpr->arg->clone()) };
     1297
     1298                        // don't prune here, since it's guaranteed all alternatives will have the same type
     1299                        finder.findWithoutPrune( tech1.get() );
     1300                        pick_alternatives(finder.alternatives, false);
     1301
     1302                        return;
     1303                } catch(SemanticErrorException & ) {}
     1304
     1305                // Fallback : turn (thread&)X into (thread_desc&)get_thread(X)
     1306                std::unique_ptr<Expression> fallback { UntypedExpr::createDeref( new UntypedExpr(new NameExpr(castExpr->concrete_target.getter), { castExpr->arg->clone() })) };
     1307                // don't prune here, since it's guaranteed all alternatives will have the same type
     1308                finder.findWithoutPrune( fallback.get() );
     1309
     1310                pick_alternatives(finder.alternatives, true);
     1311
     1312                // Whatever happens here, we have no more fallbacks
     1313        }
     1314
    12571315        namespace {
    12581316                /// Gets name from untyped member expression (member must be NameExpr)
  • src/ResolvExpr/PtrsCastable.cc

    r807a632 r3b56166  
    1010// Created On       : Sun May 17 11:48:00 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 17:36:18 2016
    13 // Update Count     : 8
     12// Last Modified On : Wed Dec 11 21:48:33 2019
     13// Update Count     : 9
    1414//
    1515
     
    176176                        if ( const ast::NamedTypeDecl * named = symtab.lookupType( inst->name ) ) {
    177177                                if ( auto tyDecl = dynamic_cast< const ast::TypeDecl * >( named ) ) {
    178                                         if ( tyDecl->kind == ast::TypeVar::Ftype ) {
     178                                        if ( tyDecl->kind == ast::TypeDecl::Ftype ) {
    179179                                                return -1;
    180180                                        }
    181181                                }
    182182                        } else if ( const ast::EqvClass * eqvClass = env.lookup( inst->name ) ) {
    183                                 if ( eqvClass->data.kind == ast::TypeVar::Ftype ) {
     183                                if ( eqvClass->data.kind == ast::TypeDecl::Ftype ) {
    184184                                        return -1;
    185185                                }
  • src/ResolvExpr/Resolver.cc

    r807a632 r3b56166  
    485485                visit_children = false;
    486486                findVoidExpression( asmExpr->operand, indexer );
    487                 if ( asmExpr->get_inout() ) {
    488                         findVoidExpression( asmExpr->inout, indexer );
    489                 } // if
    490487        }
    491488
     
    13651362                asmExpr = ast::mutate_field(
    13661363                        asmExpr, &ast::AsmExpr::operand, findVoidExpression( asmExpr->operand, symtab ) );
    1367 
    1368                 if ( asmExpr->inout ) {
    1369                         asmExpr = ast::mutate_field(
    1370                                 asmExpr, &ast::AsmExpr::inout, findVoidExpression( asmExpr->inout, symtab ) );
    1371                 }
    13721364
    13731365                return asmExpr;
  • src/ResolvExpr/Unify.cc

    r807a632 r3b56166  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 12:27:10 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Sep  4 10:00:00 2019
    13 // Update Count     : 44
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Dec 13 23:43:05 2019
     13// Update Count     : 46
    1414//
    1515
     
    3232#include "Common/PassVisitor.h"     // for PassVisitor
    3333#include "FindOpenVars.h"           // for findOpenVars
    34 #include "Parser/LinkageSpec.h"     // for C
     34#include "SynTree/LinkageSpec.h"    // for C
    3535#include "SynTree/Constant.h"       // for Constant
    3636#include "SynTree/Declaration.h"    // for TypeDecl, TypeDecl::Data, Declarati...
     
    781781                                if ( const ast::EqvClass * clz = tenv.lookup( typeInst->name ) ) {
    782782                                        // expand ttype parameter into its actual type
    783                                         if ( clz->data.kind == ast::TypeVar::Ttype && clz->bound ) {
     783                                        if ( clz->data.kind == ast::TypeDecl::Ttype && clz->bound ) {
    784784                                                return clz->bound;
    785785                                        }
  • src/SymTab/Autogen.h

    r807a632 r3b56166  
    1010// Created On       : Sun May 17 21:53:34 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:50:25 2017
    13 // Update Count     : 15
     12// Last Modified On : Fri Dec 13 16:38:06 2019
     13// Update Count     : 16
    1414//
    1515
     
    3434#include "SynTree/Expression.h"   // for NameExpr, ConstantExpr, UntypedExpr...
    3535#include "SynTree/Type.h"         // for Type, ArrayType, Type::Qualifiers
     36#include "SynTree/Statement.h"    // for CompoundStmt, DeclStmt, ExprStmt
    3637
    3738class CompoundStmt;
  • src/SymTab/Demangle.cc

    r807a632 r3b56166  
    1010// Created On       : Thu Jul 19 12:52:41 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jul 30 13:46:33 2019
    13 // Update Count     : 3
     12// Last Modified On : Fri Dec 13 14:54:15 2019
     13// Update Count     : 4
    1414//
    1515
     
    366366                                // type variable types
    367367                                for (size_t k = 0; k < TypeDecl::NUMBER_OF_KINDS; ++k) {
    368                                         static const std::string typeVariableNames[] = { "DT", "FT", "TT", };
     368                                        static const std::string typeVariableNames[] = { "DT", "OT", "FT", "TT", };
    369369                                        static_assert(
    370370                                                sizeof(typeVariableNames)/sizeof(typeVariableNames[0]) == TypeDecl::NUMBER_OF_KINDS,
  • src/SymTab/Indexer.cc

    r807a632 r3b56166  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 21:37:33 2015
    11 // Last Modified By : Aaron B. Moss
    12 // Last Modified On : Fri Mar  8 13:55:00 2019
    13 // Update Count     : 21
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Dec 13 23:43:19 2019
     13// Update Count     : 22
    1414//
    1515
     
    3131#include "InitTweak/InitTweak.h"   // for isConstructor, isCopyFunction, isC...
    3232#include "Mangler.h"               // for Mangler
    33 #include "Parser/LinkageSpec.h"    // for isMangled, isOverridable, Spec
    3433#include "ResolvExpr/typeops.h"    // for typesCompatible
     34#include "SynTree/LinkageSpec.h"   // for isMangled, isOverridable, Spec
    3535#include "SynTree/Constant.h"      // for Constant
    3636#include "SynTree/Declaration.h"   // for DeclarationWithType, FunctionDecl
  • src/SymTab/Mangler.cc

    r807a632 r3b56166  
    1010// Created On       : Sun May 17 21:40:29 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jul 30 13:46:10 2019
    13 // Update Count     : 26
     12// Last Modified On : Fri Dec 13 23:43:49 2019
     13// Update Count     : 28
    1414//
    1515#include "Mangler.h"
     
    2626#include "Common/SemanticError.h"        // for SemanticError
    2727#include "Common/utility.h"              // for toString
    28 #include "Parser/LinkageSpec.h"          // for Spec, isOverridable, AutoGen, Int...
    2928#include "ResolvExpr/TypeEnvironment.h"  // for TypeEnvironment
     29#include "SynTree/LinkageSpec.h"         // for Spec, isOverridable, AutoGen, Int...
    3030#include "SynTree/Declaration.h"         // for TypeDecl, DeclarationWithType
    3131#include "SynTree/Expression.h"          // for TypeExpr, Expression, operator<<
     
    654654                        // aside from the assert false.
    655655                        assertf(false, "Mangler_new should not visit typedecl: %s", toCString(decl));
    656                         assertf( decl->kind < ast::TypeVar::Kind::NUMBER_OF_KINDS, "Unhandled type variable kind: %d", decl->kind );
     656                        assertf( decl->kind < ast::TypeDecl::Kind::NUMBER_OF_KINDS, "Unhandled type variable kind: %d", decl->kind );
    657657                        mangleName << Encoding::typeVariables[ decl->kind ] << ( decl->name.length() ) << decl->name;
    658658                }
     
    674674                                        for ( const ast::TypeDecl * decl : ptype->forall ) {
    675675                                                switch ( decl->kind ) {
    676                                                 case ast::TypeVar::Kind::Dtype:
     676                                                case ast::TypeDecl::Kind::Dtype:
    677677                                                        dcount++;
    678678                                                        break;
    679                                                 case ast::TypeVar::Kind::Ftype:
     679                                                case ast::TypeDecl::Kind::Ftype:
    680680                                                        fcount++;
    681681                                                        break;
    682                                                 case ast::TypeVar::Kind::Ttype:
     682                                                case ast::TypeDecl::Kind::Ttype:
    683683                                                        vcount++;
    684684                                                        break;
  • src/SymTab/ManglerCommon.cc

    r807a632 r3b56166  
    1010// Created On       : Sun May 17 21:44:03 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 14 17:06:37 2019
    13 // Update Count     : 26
     12// Last Modified On : Fri Dec 13 14:54:38 2019
     13// Update Count     : 28
    1414//
    1515
     
    104104                        const std::string typeVariables[] = {
    105105                                "BD", // dtype
     106                                "BO", // otype
    106107                                "BF", // ftype
    107108                                "BT", // ttype
  • src/SymTab/Validate.cc

    r807a632 r3b56166  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 21:50:04 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Aug  7 6:42:00 2019
    13 // Update Count     : 360
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Dec 13 23:43:34 2019
     13// Update Count     : 363
    1414//
    1515
     
    6969#include "InitTweak/GenInit.h"         // for fixReturnStatements
    7070#include "InitTweak/InitTweak.h"       // for isCtorDtorAssign
    71 #include "Parser/LinkageSpec.h"        // for C
    7271#include "ResolvExpr/typeops.h"        // for typesCompatible
    7372#include "ResolvExpr/Resolver.h"       // for findSingleExpression
    7473#include "ResolvExpr/ResolveTypeof.h"  // for resolveTypeof
    7574#include "SymTab/Autogen.h"            // for SizeType
     75#include "SynTree/LinkageSpec.h"       // for C
    7676#include "SynTree/Attribute.h"         // for noAttributes, Attribute
    7777#include "SynTree/Constant.h"          // for Constant
     
    375375                        Stats::Heap::newPass("validate-F");
    376376                        Stats::Time::BlockGuard guard("validate-F");
    377                         Stats::Time::TimeBlock("Fix Object Type", [&]() {
    378                                 FixObjectType::fix( translationUnit );
    379                         });
    380                         Stats::Time::TimeBlock("Array Length", [&]() {
    381                                 ArrayLength::computeLength( translationUnit );
    382                         });
    383                         Stats::Time::TimeBlock("Find Special Declarations", [&]() {
    384                                 Validate::findSpecialDecls( translationUnit );
    385                         });
    386                         Stats::Time::TimeBlock("Fix Label Address", [&]() {
    387                                 mutateAll( translationUnit, labelAddrFixer );
    388                         });
    389                         Stats::Time::TimeBlock("Handle Attributes", [&]() {
    390                                 Validate::handleAttributes( translationUnit );
    391                         });
     377                        Stats::Time::TimeCall("Fix Object Type",
     378                                FixObjectType::fix, translationUnit);
     379                        Stats::Time::TimeCall("Array Length",
     380                                ArrayLength::computeLength, translationUnit);
     381                        Stats::Time::TimeCall("Find Special Declarations",
     382                                Validate::findSpecialDecls, translationUnit);
     383                        Stats::Time::TimeCall("Fix Label Address",
     384                                mutateAll<LabelAddressFixer>, translationUnit, labelAddrFixer);
     385                        Stats::Time::TimeCall("Handle Attributes",
     386                                Validate::handleAttributes, translationUnit);
    392387                }
    393388        }
     
    10491044                Type * designatorType = tyDecl->base->stripDeclarator();
    10501045                if ( StructInstType * aggDecl = dynamic_cast< StructInstType * >( designatorType ) ) {
    1051                         declsToAddBefore.push_back( new StructDecl( aggDecl->name, DeclarationNode::Struct, noAttributes, tyDecl->linkage ) );
     1046                        declsToAddBefore.push_back( new StructDecl( aggDecl->name, AggregateDecl::Struct, noAttributes, tyDecl->linkage ) );
    10521047                } else if ( UnionInstType * aggDecl = dynamic_cast< UnionInstType * >( designatorType ) ) {
    10531048                        declsToAddBefore.push_back( new UnionDecl( aggDecl->name, noAttributes, tyDecl->linkage ) );
  • src/SynTree/AggregateDecl.cc

    r807a632 r3b56166  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 23:56:39 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Aug  4 14:22:00 2017
    13 // Update Count     : 22
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Mon Dec 16 15:07:20 2019
     13// Update Count     : 31
    1414//
    1515
     
    2121#include "Common/utility.h"      // for printAll, cloneAll, deleteAll
    2222#include "Declaration.h"         // for AggregateDecl, TypeDecl, Declaration
    23 #include "Parser/LinkageSpec.h"  // for Spec, linkageName, Cforall
     23#include "Initializer.h"
     24#include "LinkageSpec.h"         // for Spec, linkageName, Cforall
    2425#include "Type.h"                // for Type, Type::StorageClasses
    2526
     27
     28// These must harmonize with the corresponding AggregateDecl::Aggregate enumerations.
     29static const char * aggregateNames[] = { "struct", "union", "enum", "exception", "trait", "generator", "coroutine", "monitor", "thread", "NoAggregateName" };
     30
     31const char * AggregateDecl::aggrString( AggregateDecl::Aggregate aggr ) {
     32        return aggregateNames[aggr];
     33}
    2634
    2735AggregateDecl::AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes, LinkageSpec::Spec linkage ) : Parent( name, Type::StorageClasses(), linkage ), body( false ), attributes( attributes ) {
     
    4755        os << typeString() << " " << name << ":";
    4856        if ( get_linkage() != LinkageSpec::Cforall ) {
    49                 os << " " << LinkageSpec::linkageName( linkage );
     57                os << " " << LinkageSpec::name( linkage );
    5058        } // if
    5159        os << " with body " << has_body();
     
    7886}
    7987
    80 std::string StructDecl::typeString() const { return "struct"; }
     88const char * StructDecl::typeString() const { return aggrString( kind ); }
    8189
    82 std::string UnionDecl::typeString() const { return "union"; }
     90const char * UnionDecl::typeString() const { return aggrString( Union ); }
    8391
    84 std::string EnumDecl::typeString() const { return "enum"; }
     92const char * EnumDecl::typeString() const { return aggrString( Enum ); }
    8593
    86 std::string TraitDecl::typeString() const { return "trait"; }
     94const char * TraitDecl::typeString() const { return aggrString( Trait ); }
    8795
    8896bool EnumDecl::valueOf( Declaration * enumerator, long long int & value ) {
  • src/SynTree/Declaration.cc

    r807a632 r3b56166  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Aug  9 14:38:00 2017
    13 // Update Count     : 25
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Dec 11 16:39:56 2019
     13// Update Count     : 36
    1414//
    1515
     
    2424#include "SynTree/Statement.h"       // for AsmStmt
    2525#include "SynTree/SynTree.h"         // for UniqueId
     26#include "SynTree/Expression.h"
    2627#include "Type.h"                    // for Type, Type::StorageClasses
    2728
     29// To canonicalize declarations
    2830static UniqueId lastUniqueId = 0;
    2931
  • src/SynTree/Declaration.h

    r807a632 r3b56166  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Thr May  2 10:47:00 2019
    13 // Update Count     : 135
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Dec 13 23:11:22 2019
     13// Update Count     : 157
    1414//
    1515
     
    2424#include "BaseSyntaxNode.h"      // for BaseSyntaxNode
    2525#include "Mutator.h"             // for Mutator
    26 #include "Parser/LinkageSpec.h"  // for Spec, Cforall
    27 #include "Parser/ParseNode.h"    // for DeclarationNode, DeclarationNode::Ag...
     26#include "LinkageSpec.h"         // for Spec, Cforall
    2827#include "SynTree.h"             // for UniqueId
    2928#include "SynTree/Type.h"        // for Type, Type::StorageClasses, Type::Fu...
     
    4443        bool extension = false;
    4544
    46         Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage );
    47         Declaration( const Declaration &other );
     45        Declaration( const std::string & name, Type::StorageClasses scs, LinkageSpec::Spec linkage );
     46        Declaration( const Declaration & other );
    4847        virtual ~Declaration();
    4948
    50         const std::string &get_name() const { return name; }
     49        const std::string & get_name() const { return name; }
    5150        void set_name( std::string newValue ) { name = newValue; }
    5251
     
    5958
    6059        bool get_extension() const { return extension; }
    61         Declaration *set_extension( bool exten ) { extension = exten; return this; }
     60        Declaration * set_extension( bool exten ) { extension = exten; return this; }
    6261
    6362        void fixUniqueId( void );
    64         virtual Declaration *clone() const override = 0;
     63        virtual Declaration * clone() const override = 0;
    6564        virtual void accept( Visitor & v ) override = 0;
    6665        virtual void accept( Visitor & v ) const override = 0;
    67         virtual Declaration *acceptMutator( Mutator &m ) override = 0;
    68         virtual void print( std::ostream &os, Indenter indent = {} ) const override = 0;
    69         virtual void printShort( std::ostream &os, Indenter indent = {} ) const = 0;
     66        virtual Declaration * acceptMutator( Mutator & m ) override = 0;
     67        virtual void print( std::ostream & os, Indenter indent = {} ) const override = 0;
     68        virtual void printShort( std::ostream & os, Indenter indent = {} ) const = 0;
    7069
    7170        UniqueId uniqueId;
     
    8180        int scopeLevel = 0;
    8281
    83         Expression *asmName;
     82        Expression * asmName;
    8483        std::list< Attribute * > attributes;
    8584        bool isDeleted = false;
    8685
    87         DeclarationWithType( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, Type::FuncSpecifiers fs );
    88         DeclarationWithType( const DeclarationWithType &other );
     86        DeclarationWithType( const std::string & name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, Type::FuncSpecifiers fs );
     87        DeclarationWithType( const DeclarationWithType & other );
    8988        virtual ~DeclarationWithType();
    9089
     
    9796        DeclarationWithType * set_scopeLevel( int newValue ) { scopeLevel = newValue; return this; }
    9897
    99         Expression *get_asmName() const { return asmName; }
    100         DeclarationWithType * set_asmName( Expression *newValue ) { asmName = newValue; return this; }
     98        Expression * get_asmName() const { return asmName; }
     99        DeclarationWithType * set_asmName( Expression * newValue ) { asmName = newValue; return this; }
    101100
    102101        std::list< Attribute * >& get_attributes() { return attributes; }
     
    106105        //void set_functionSpecifiers( Type::FuncSpecifiers newValue ) { fs = newValue; }
    107106
    108         virtual DeclarationWithType *clone() const override = 0;
    109         virtual DeclarationWithType *acceptMutator( Mutator &m )  override = 0;
     107        virtual DeclarationWithType * clone() const override = 0;
     108        virtual DeclarationWithType * acceptMutator( Mutator & m )  override = 0;
    110109
    111110        virtual Type * get_type() const = 0;
     
    119118        typedef DeclarationWithType Parent;
    120119  public:
    121         Type *type;
    122         Initializer *init;
    123         Expression *bitfieldWidth;
    124 
    125         ObjectDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init,
     120        Type * type;
     121        Initializer * init;
     122        Expression * bitfieldWidth;
     123
     124        ObjectDecl( const std::string & name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression * bitfieldWidth, Type * type, Initializer * init,
    126125                                const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() );
    127         ObjectDecl( const ObjectDecl &other );
     126        ObjectDecl( const ObjectDecl & other );
    128127        virtual ~ObjectDecl();
    129128
    130129        virtual Type * get_type() const override { return type; }
    131         virtual void set_type(Type *newType) override { type = newType; }
    132 
    133         Initializer *get_init() const { return init; }
    134         void set_init( Initializer *newValue ) { init = newValue; }
    135 
    136         Expression *get_bitfieldWidth() const { return bitfieldWidth; }
    137         void set_bitfieldWidth( Expression *newValue ) { bitfieldWidth = newValue; }
     130        virtual void set_type(Type * newType) override { type = newType; }
     131
     132        Initializer * get_init() const { return init; }
     133        void set_init( Initializer * newValue ) { init = newValue; }
     134
     135        Expression * get_bitfieldWidth() const { return bitfieldWidth; }
     136        void set_bitfieldWidth( Expression * newValue ) { bitfieldWidth = newValue; }
    138137
    139138        static ObjectDecl * newObject( const std::string & name, Type * type, Initializer * init );
    140139
    141         virtual ObjectDecl *clone() const override { return new ObjectDecl( *this ); }
    142         virtual void accept( Visitor & v ) override { v.visit( this ); }
    143         virtual void accept( Visitor & v ) const override { v.visit( this ); }
    144         virtual DeclarationWithType *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    145         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    146         virtual void printShort( std::ostream &os, Indenter indent = {} ) const override;
     140        virtual ObjectDecl * clone() const override { return new ObjectDecl( *this ); }
     141        virtual void accept( Visitor & v ) override { v.visit( this ); }
     142        virtual void accept( Visitor & v ) const override { v.visit( this ); }
     143        virtual DeclarationWithType * acceptMutator( Mutator & m )  override { return m.mutate( this ); }
     144        virtual void print( std::ostream & os, Indenter indent = {} ) const override;
     145        virtual void printShort( std::ostream & os, Indenter indent = {} ) const override;
    147146};
    148147
     
    150149        typedef DeclarationWithType Parent;
    151150  public:
    152         FunctionType *type;
    153         CompoundStmt *statements;
     151        FunctionType * type;
     152        CompoundStmt * statements;
    154153        std::list< Expression * > withExprs;
    155154
    156         FunctionDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements,
     155        FunctionDecl( const std::string & name, Type::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType * type, CompoundStmt * statements,
    157156                                  const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() );
    158         FunctionDecl( const FunctionDecl &other );
     157        FunctionDecl( const FunctionDecl & other );
    159158        virtual ~FunctionDecl();
    160159
     
    163162
    164163        FunctionType * get_functionType() const { return type; }
    165         void set_functionType( FunctionType *newValue ) { type = newValue; }
    166         CompoundStmt *get_statements() const { return statements; }
    167         void set_statements( CompoundStmt *newValue ) { statements = newValue; }
     164        void set_functionType( FunctionType * newValue ) { type = newValue; }
     165        CompoundStmt * get_statements() const { return statements; }
     166        void set_statements( CompoundStmt * newValue ) { statements = newValue; }
    168167        bool has_body() const { return NULL != statements; }
    169168
    170169        static FunctionDecl * newFunction( const std::string & name, FunctionType * type, CompoundStmt * statements );
    171170
    172         virtual FunctionDecl *clone() const override { return new FunctionDecl( *this ); }
    173         virtual void accept( Visitor & v ) override { v.visit( this ); }
    174         virtual void accept( Visitor & v ) const override { v.visit( this ); }
    175         virtual DeclarationWithType *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    176         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    177         virtual void printShort( std::ostream &os, Indenter indent = {} ) const override;
     171        virtual FunctionDecl * clone() const override { return new FunctionDecl( *this ); }
     172        virtual void accept( Visitor & v ) override { v.visit( this ); }
     173        virtual void accept( Visitor & v ) const override { v.visit( this ); }
     174        virtual DeclarationWithType * acceptMutator( Mutator & m )  override { return m.mutate( this ); }
     175        virtual void print( std::ostream & os, Indenter indent = {} ) const override;
     176        virtual void printShort( std::ostream & os, Indenter indent = {} ) const override;
    178177};
    179178
     
    181180        typedef Declaration Parent;
    182181  public:
    183         Type *base;
    184         std::list< TypeDecl* > parameters;
    185         std::list< DeclarationWithType* > assertions;
    186 
    187         NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *type );
    188         NamedTypeDecl( const NamedTypeDecl &other );
     182        Type * base;
     183        std::list< TypeDecl * > parameters;
     184        std::list< DeclarationWithType * > assertions;
     185
     186        NamedTypeDecl( const std::string & name, Type::StorageClasses scs, Type * type );
     187        NamedTypeDecl( const NamedTypeDecl & other );
    189188        virtual ~NamedTypeDecl();
    190189
    191         Type *get_base() const { return base; }
    192         void set_base( Type *newValue ) { base = newValue; }
    193         std::list< TypeDecl* >& get_parameters() { return parameters; }
    194         std::list< DeclarationWithType* >& get_assertions() { return assertions; }
    195 
    196         virtual std::string typeString() const = 0;
    197 
    198         virtual NamedTypeDecl *clone() const override = 0;
    199         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    200         virtual void printShort( std::ostream &os, Indenter indent = {} ) const override;
     190        Type * get_base() const { return base; }
     191        void set_base( Type * newValue ) { base = newValue; }
     192        std::list< TypeDecl* > & get_parameters() { return parameters; }
     193        std::list< DeclarationWithType * >& get_assertions() { return assertions; }
     194
     195        virtual const char * typeString() const = 0;
     196
     197        virtual NamedTypeDecl * clone() const override = 0;
     198        virtual void print( std::ostream & os, Indenter indent = {} ) const override;
     199        virtual void printShort( std::ostream & os, Indenter indent = {} ) const override;
    201200};
    202201
     
    204203        typedef NamedTypeDecl Parent;
    205204  public:
    206         enum Kind { Dtype, Ftype, Ttype, NUMBER_OF_KINDS };
    207 
     205        enum Kind { Dtype, Otype, Ftype, Ttype, NUMBER_OF_KINDS };
     206
     207        Kind kind;
     208        bool sized;
    208209        Type * init;
    209         bool sized;
    210210
    211211        /// Data extracted from a type decl
    212212        struct Data {
    213                 TypeDecl::Kind kind;
     213                Kind kind;
    214214                bool isComplete;
    215215
    216                 Data() : kind( (TypeDecl::Kind)-1 ), isComplete( false ) {}
    217                 Data( TypeDecl * typeDecl ) : Data( typeDecl->get_kind(), typeDecl->isComplete() ) {}
     216                Data() : kind( NUMBER_OF_KINDS ), isComplete( false ) {}
     217                Data( const TypeDecl * typeDecl ) : Data( typeDecl->get_kind(), typeDecl->isComplete() ) {}
    218218                Data( Kind kind, bool isComplete ) : kind( kind ), isComplete( isComplete ) {}
    219                 Data( const Data& d1, const Data& d2 )
    220                 : kind( d1.kind ), isComplete ( d1.isComplete || d2.isComplete ) {}
    221 
    222                 bool operator==(const Data & other) const { return kind == other.kind && isComplete == other.isComplete; }
    223                 bool operator!=(const Data & other) const { return !(*this == other);}
     219                Data( const Data & d1, const Data & d2 )
     220                        : kind( d1.kind ), isComplete( d1.isComplete || d2.isComplete ) {}
     221
     222                bool operator==( const Data & other ) const { return kind == other.kind && isComplete == other.isComplete; }
     223                bool operator!=( const Data & other ) const { return !(*this == other);}
    224224        };
    225225
    226         TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, bool sized, Type * init = nullptr );
    227         TypeDecl( const TypeDecl &other );
     226        TypeDecl( const std::string & name, Type::StorageClasses scs, Type * type, Kind kind, bool sized, Type * init = nullptr );
     227        TypeDecl( const TypeDecl & other );
    228228        virtual ~TypeDecl();
    229229
     
    237237        TypeDecl * set_sized( bool newValue ) { sized = newValue; return this; }
    238238
    239         virtual std::string typeString() const override;
    240         virtual std::string genTypeString() const;
    241 
    242         virtual TypeDecl *clone() const override { return new TypeDecl( *this ); }
    243         virtual void accept( Visitor & v ) override { v.visit( this ); }
    244         virtual void accept( Visitor & v ) const override { v.visit( this ); }
    245         virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    246         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    247 
    248         Kind kind;
     239        virtual const char * typeString() const override;
     240        virtual const char * genTypeString() const;
     241
     242        virtual TypeDecl * clone() const override { return new TypeDecl( *this ); }
     243        virtual void accept( Visitor & v ) override { v.visit( this ); }
     244        virtual void accept( Visitor & v ) const override { v.visit( this ); }
     245        virtual Declaration * acceptMutator( Mutator & m )  override { return m.mutate( this ); }
     246        virtual void print( std::ostream & os, Indenter indent = {} ) const override;
    249247};
    250248
     
    252250        typedef NamedTypeDecl Parent;
    253251  public:
    254         TypedefDecl( const std::string &name, CodeLocation location, Type::StorageClasses scs, Type *type, LinkageSpec::Spec spec = LinkageSpec::Cforall )
     252        TypedefDecl( const std::string & name, CodeLocation location, Type::StorageClasses scs, Type * type, LinkageSpec::Spec spec = LinkageSpec::Cforall )
    255253                : Parent( name, scs, type ) { set_linkage( spec ); this->location = location; }
    256254
    257         TypedefDecl( const TypedefDecl &other ) : Parent( other ) {}
    258 
    259         virtual std::string typeString() const override;
    260 
    261         virtual TypedefDecl *clone() const override { return new TypedefDecl( *this ); }
    262         virtual void accept( Visitor & v ) override { v.visit( this ); }
    263         virtual void accept( Visitor & v ) const override { v.visit( this ); }
    264         virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     255        TypedefDecl( const TypedefDecl & other ) : Parent( other ) {}
     256
     257        virtual const char * typeString() const override;
     258
     259        virtual TypedefDecl * clone() const override { return new TypedefDecl( *this ); }
     260        virtual void accept( Visitor & v ) override { v.visit( this ); }
     261        virtual void accept( Visitor & v ) const override { v.visit( this ); }
     262        virtual Declaration * acceptMutator( Mutator & m )  override { return m.mutate( this ); }
    265263  private:
    266264};
     
    269267        typedef Declaration Parent;
    270268  public:
     269        enum Aggregate { Struct, Union, Enum, Exception, Trait, Generator, Coroutine, Monitor, Thread, NoAggregate };
     270        static const char * aggrString( Aggregate aggr );
     271
    271272        std::list<Declaration*> members;
    272273        std::list<TypeDecl*> parameters;
     
    275276        AggregateDecl * parent = nullptr;
    276277
    277         AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall );
    278         AggregateDecl( const AggregateDecl &other );
     278        AggregateDecl( const std::string & name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall );
     279        AggregateDecl( const AggregateDecl & other );
    279280        virtual ~AggregateDecl();
    280281
     
    288289        AggregateDecl * set_body( bool body ) { AggregateDecl::body = body; return this; }
    289290
    290         virtual void print( std::ostream &os, Indenter indent = {} ) const override final;
    291         virtual void printShort( std::ostream &os, Indenter indent = {} ) const override;
     291        virtual void print( std::ostream & os, Indenter indent = {} ) const override final;
     292        virtual void printShort( std::ostream & os, Indenter indent = {} ) const override;
    292293  protected:
    293         virtual std::string typeString() const = 0;
     294        virtual const char * typeString() const = 0;
    294295};
    295296
     
    297298        typedef AggregateDecl Parent;
    298299  public:
    299         StructDecl( const std::string &name, DeclarationNode::Aggregate kind = DeclarationNode::Struct, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ), kind( kind ) {}
    300         StructDecl( const StructDecl &other ) : Parent( other ), kind( other.kind ) {}
    301 
    302         bool is_coroutine() { return kind == DeclarationNode::Coroutine; }
    303         bool is_monitor() { return kind == DeclarationNode::Monitor; }
    304         bool is_thread() { return kind == DeclarationNode::Thread; }
    305 
    306         virtual StructDecl *clone() const override { return new StructDecl( *this ); }
    307         virtual void accept( Visitor & v ) override { v.visit( this ); }
    308         virtual void accept( Visitor & v ) const override { v.visit( this ); }
    309         virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    310         DeclarationNode::Aggregate kind;
    311   private:
    312         virtual std::string typeString() const override;
     300        StructDecl( const std::string & name, Aggregate kind = Struct, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ), kind( kind ) {}
     301        StructDecl( const StructDecl & other ) : Parent( other ), kind( other.kind ) {}
     302
     303        bool is_coroutine() { return kind == Coroutine; }
     304        bool is_monitor() { return kind == Monitor; }
     305        bool is_thread() { return kind == Thread; }
     306
     307        virtual StructDecl * clone() const override { return new StructDecl( *this ); }
     308        virtual void accept( Visitor & v ) override { v.visit( this ); }
     309        virtual void accept( Visitor & v ) const override { v.visit( this ); }
     310        virtual Declaration * acceptMutator( Mutator & m )  override { return m.mutate( this ); }
     311        Aggregate kind;
     312  private:
     313        virtual const char * typeString() const override;
    313314};
    314315
     
    316317        typedef AggregateDecl Parent;
    317318  public:
    318         UnionDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ) {}
    319         UnionDecl( const UnionDecl &other ) : Parent( other ) {}
    320 
    321         virtual UnionDecl *clone() const override { return new UnionDecl( *this ); }
    322         virtual void accept( Visitor & v ) override { v.visit( this ); }
    323         virtual void accept( Visitor & v ) const override { v.visit( this ); }
    324         virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    325   private:
    326         virtual std::string typeString() const override;
     319        UnionDecl( const std::string & name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ) {}
     320        UnionDecl( const UnionDecl & other ) : Parent( other ) {}
     321
     322        virtual UnionDecl * clone() const override { return new UnionDecl( *this ); }
     323        virtual void accept( Visitor & v ) override { v.visit( this ); }
     324        virtual void accept( Visitor & v ) const override { v.visit( this ); }
     325        virtual Declaration * acceptMutator( Mutator & m )  override { return m.mutate( this ); }
     326  private:
     327        virtual const char * typeString() const override;
    327328};
    328329
     
    330331        typedef AggregateDecl Parent;
    331332  public:
    332         EnumDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ) {}
    333         EnumDecl( const EnumDecl &other ) : Parent( other ) {}
     333        EnumDecl( const std::string & name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ) {}
     334        EnumDecl( const EnumDecl & other ) : Parent( other ) {}
    334335
    335336        bool valueOf( Declaration * enumerator, long long int & value );
    336337
    337         virtual EnumDecl *clone() const override { return new EnumDecl( *this ); }
    338         virtual void accept( Visitor & v ) override { v.visit( this ); }
    339         virtual void accept( Visitor & v ) const override { v.visit( this ); }
    340         virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     338        virtual EnumDecl * clone() const override { return new EnumDecl( *this ); }
     339        virtual void accept( Visitor & v ) override { v.visit( this ); }
     340        virtual void accept( Visitor & v ) const override { v.visit( this ); }
     341        virtual Declaration * acceptMutator( Mutator & m )  override { return m.mutate( this ); }
    341342  private:
    342343        std::unordered_map< std::string, long long int > enumValues;
    343         virtual std::string typeString() const override;
     344        virtual const char * typeString() const override;
    344345};
    345346
     
    347348        typedef AggregateDecl Parent;
    348349  public:
    349         TraitDecl( const std::string &name, const std::list< Attribute * > & attributes, LinkageSpec::Spec linkage ) : Parent( name, attributes, linkage ) {
     350        TraitDecl( const std::string & name, const std::list< Attribute * > & attributes, LinkageSpec::Spec linkage ) : Parent( name, attributes, linkage ) {
    350351                assertf( attributes.empty(), "attribute unsupported for traits" );
    351352        }
    352         TraitDecl( const TraitDecl &other ) : Parent( other ) {}
    353 
    354         virtual TraitDecl *clone() const override { return new TraitDecl( *this ); }
    355         virtual void accept( Visitor & v ) override { v.visit( this ); }
    356         virtual void accept( Visitor & v ) const override { v.visit( this ); }
    357         virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    358   private:
    359         virtual std::string typeString() const override;
     353        TraitDecl( const TraitDecl & other ) : Parent( other ) {}
     354
     355        virtual TraitDecl * clone() const override { return new TraitDecl( *this ); }
     356        virtual void accept( Visitor & v ) override { v.visit( this ); }
     357        virtual void accept( Visitor & v ) const override { v.visit( this ); }
     358        virtual Declaration * acceptMutator( Mutator & m )  override { return m.mutate( this ); }
     359  private:
     360        virtual const char * typeString() const override;
    360361};
    361362
     
    379380class AsmDecl : public Declaration {
    380381  public:
    381         AsmStmt *stmt;
    382 
    383         AsmDecl( AsmStmt *stmt );
    384         AsmDecl( const AsmDecl &other );
     382        AsmStmt * stmt;
     383
     384        AsmDecl( AsmStmt * stmt );
     385        AsmDecl( const AsmDecl & other );
    385386        virtual ~AsmDecl();
    386387
    387         AsmStmt *get_stmt() { return stmt; }
    388         void set_stmt( AsmStmt *newValue ) { stmt = newValue; }
    389 
    390         virtual AsmDecl *clone() const override { return new AsmDecl( *this ); }
    391         virtual void accept( Visitor & v ) override { v.visit( this ); }
    392         virtual void accept( Visitor & v ) const override { v.visit( this ); }
    393         virtual AsmDecl *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    394         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    395         virtual void printShort( std::ostream &os, Indenter indent = {} ) const override;
     388        AsmStmt * get_stmt() { return stmt; }
     389        void set_stmt( AsmStmt * newValue ) { stmt = newValue; }
     390
     391        virtual AsmDecl * clone() const override { return new AsmDecl( *this ); }
     392        virtual void accept( Visitor & v ) override { v.visit( this ); }
     393        virtual void accept( Visitor & v ) const override { v.visit( this ); }
     394        virtual AsmDecl * acceptMutator( Mutator & m )  override { return m.mutate( this ); }
     395        virtual void print( std::ostream & os, Indenter indent = {} ) const override;
     396        virtual void printShort( std::ostream & os, Indenter indent = {} ) const override;
    396397};
    397398
     
    408409        virtual void accept( Visitor & v ) override { v.visit( this ); }
    409410        virtual void accept( Visitor & v ) const override { v.visit( this ); }
    410         virtual StaticAssertDecl * acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    411         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    412         virtual void printShort( std::ostream &os, Indenter indent = {} ) const override;
     411        virtual StaticAssertDecl * acceptMutator( Mutator & m )  override { return m.mutate( this ); }
     412        virtual void print( std::ostream & os, Indenter indent = {} ) const override;
     413        virtual void printShort( std::ostream & os, Indenter indent = {} ) const override;
    413414};
    414415
  • src/SynTree/DeclarationWithType.cc

    r807a632 r3b56166  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 16 08:34:35 2017
    13 // Update Count     : 25
     12// Last Modified On : Fri Dec 13 23:45:16 2019
     13// Update Count     : 26
    1414//
    1515
     
    2020#include "Common/utility.h"      // for cloneAll, deleteAll, maybeClone
    2121#include "Declaration.h"         // for DeclarationWithType, Declaration
    22 #include "Parser/LinkageSpec.h"  // for Spec
    23 #include "SynTree/Expression.h"  // for ConstantExpr
     22#include "LinkageSpec.h"         // for Spec
     23#include "Expression.h"          // for ConstantExpr
    2424#include "Type.h"                // for Type, Type::FuncSpecifiers, Type::St...
    2525
  • src/SynTree/Expression.cc

    r807a632 r3b56166  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Thr Aug 15 13:43:00 2019
    13 // Update Count     : 64
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Dec 11 07:55:15 2019
     13// Update Count     : 70
    1414//
    1515
     
    2222
    2323#include "Common/utility.h"          // for maybeClone, cloneAll, deleteAll
    24 #include "Declaration.h"             // for ObjectDecl, DeclarationWithType
    2524#include "Expression.h"              // for Expression, ImplicitCopyCtorExpr
    2625#include "InitTweak/InitTweak.h"     // for getCallArg, getPointerBase
     
    294293}
    295294
    296 KeywordCastExpr::KeywordCastExpr( Expression * arg, Target target ) : Expression(), arg(arg), target( target ) {
     295KeywordCastExpr::KeywordCastExpr( Expression * arg, AggregateDecl::Aggregate target ) : Expression(), arg(arg), target( target ) {
    297296}
    298297
     
    304303}
    305304
    306 const std::string & KeywordCastExpr::targetString() const {
    307         static const std::string targetStrs[] = {
    308                 "coroutine", "thread", "monitor"
    309         };
    310         static_assert(
    311                 (sizeof(targetStrs) / sizeof(targetStrs[0])) == ((unsigned long)NUMBER_OF_TARGETS),
    312                 "Each KeywordCastExpr::Target should have a corresponding string representation"
    313         );
    314         return targetStrs[(unsigned long)target];
     305const char * KeywordCastExpr::targetString() const {
     306        return AggregateDecl::aggrString( target );
    315307}
    316308
     
    527519}
    528520
    529 AsmExpr::AsmExpr( const AsmExpr & other ) : Expression( other ), inout( maybeClone( other.inout ) ), constraint( maybeClone( other.constraint ) ), operand( maybeClone( other.operand ) ) {}
     521AsmExpr::AsmExpr( const AsmExpr & other ) : Expression( other ), inout( other.inout ), constraint( maybeClone( other.constraint ) ), operand( maybeClone( other.operand ) ) {}
    530522
    531523
    532524void AsmExpr::print( std::ostream & os, Indenter indent ) const {
    533525        os << "Asm Expression: " << std::endl;
    534         if ( inout ) inout->print( os, indent+1 );
     526        if ( !inout.empty() ) os <<  "[" << inout << "] ";
    535527        if ( constraint ) constraint->print( os, indent+1 );
    536528        if ( operand ) operand->print( os, indent+1 );
  • src/SynTree/Expression.h

    r807a632 r3b56166  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Thr Aug 15 13:46:00 2019
    13 // Update Count     : 54
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Dec 11 16:50:19 2019
     13// Update Count     : 60
    1414//
    1515
     
    2828#include "Label.h"                // for Label
    2929#include "Mutator.h"              // for Mutator
     30#include "Declaration.h"          // for Aggregate
    3031#include "SynTree.h"              // for UniqueId
    3132#include "Visitor.h"              // for Visitor
     
    229230public:
    230231        Expression * arg;
    231         enum Target {
    232                 Coroutine, Thread, Monitor, NUMBER_OF_TARGETS
    233         } target;
    234 
    235         KeywordCastExpr( Expression * arg, Target target );
     232        struct Concrete {
     233                std::string field;
     234                std::string getter;
     235        };
     236        AggregateDecl::Aggregate target;
     237        Concrete concrete_target;
     238
     239        KeywordCastExpr( Expression * arg, AggregateDecl::Aggregate target );
    236240        KeywordCastExpr( const KeywordCastExpr & other );
    237241        virtual ~KeywordCastExpr();
    238242
    239         const std::string & targetString() const;
     243        const char * targetString() const;
    240244
    241245        virtual KeywordCastExpr * clone() const override { return new KeywordCastExpr( * this ); }
     
    575579class AsmExpr : public Expression {
    576580  public:
    577         Expression * inout;
     581        std::string inout;
    578582        Expression * constraint;
    579583        Expression * operand;
    580584
    581         AsmExpr( Expression * inout, Expression * constraint, Expression * operand ) : inout( inout ), constraint( constraint ), operand( operand ) {}
     585        AsmExpr( const std::string * _inout, Expression * constraint, Expression * operand ) : inout( _inout ? *_inout : "" ), constraint( constraint ), operand( operand ) { delete _inout; }
    582586        AsmExpr( const AsmExpr & other );
    583         virtual ~AsmExpr() { delete inout; delete constraint; delete operand; };
    584 
    585         Expression * get_inout() const { return inout; }
    586         void set_inout( Expression * newValue ) { inout = newValue; }
    587 
    588         Expression * get_constraint() const { return constraint; }
    589         void set_constraint( Expression * newValue ) { constraint = newValue; }
    590 
    591         Expression * get_operand() const { return operand; }
    592         void set_operand( Expression * newValue ) { operand = newValue; }
     587        virtual ~AsmExpr() { delete constraint; delete operand; };
    593588
    594589        virtual AsmExpr * clone() const override { return new AsmExpr( * this ); }
  • src/SynTree/FunctionDecl.cc

    r807a632 r3b56166  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 16 08:33:41 2017
    13 // Update Count     : 74
     12// Last Modified On : Mon Dec 16 15:11:20 2019
     13// Update Count     : 77
    1414//
    1515
     
    2323#include "Common/utility.h"      // for maybeClone, printAll
    2424#include "Declaration.h"         // for FunctionDecl, FunctionDecl::Parent
    25 #include "Parser/LinkageSpec.h"  // for Spec, linkageName, Cforall
     25#include "Expression.h"
     26#include "LinkageSpec.h"         // for Spec, linkageName, Cforall
    2627#include "Statement.h"           // for CompoundStmt
    2728#include "Type.h"                // for Type, FunctionType, Type::FuncSpecif...
     
    7273        } // if
    7374        if ( linkage != LinkageSpec::Cforall ) {
    74                 os << LinkageSpec::linkageName( linkage ) << " ";
     75                os << LinkageSpec::name( linkage ) << " ";
    7576        } // if
    7677
  • src/SynTree/LinkageSpec.h

    r807a632 r3b56166  
    1010// Created On       : Sat May 16 13:24:28 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jul 10 16:02:34 2019
    13 // Update Count     : 18
     12// Last Modified On : Mon Dec 16 15:03:43 2019
     13// Update Count     : 20
    1414//
    1515
     
    2121
    2222namespace LinkageSpec {
    23         // All linkage specs are some combination of these flags:
    24         enum { Mangle = 1 << 0, Generate = 1 << 1, Overrideable = 1 << 2, Builtin = 1 << 3, GccBuiltin = 1 << 4, NoOfSpecs = 1 << 5, };
     23        // Bitflags for linkage specifiers
     24        enum {
     25                Mangle = 1 << 0,
     26                Generate = 1 << 1,
     27                Overrideable = 1 << 2,
     28                Builtin = 1 << 3,
     29                GccBuiltin = 1 << 4,
     30        };
    2531
     32        // Bitflag type for storage classes
    2633        union Spec {
    2734                unsigned int val;
     
    4249
    4350
    44         Spec linkageUpdate( CodeLocation location, Spec old_spec, const std::string * cmd );
    45         /* If cmd = "C" returns a Spec that is old_spec with is_mangled = false
    46          * If cmd = "Cforall" returns old_spec Spec with is_mangled = true
    47          */
     51        Spec update( CodeLocation location, Spec spec, const std::string * cmd );
     52        // If cmd = "C" returns a Spec that is old_spec with is_mangled = false
     53        // If cmd = "Cforall" returns old_spec Spec with is_mangled = true
    4854
    49         std::string linkageName( Spec );
     55        std::string name( Spec );
    5056
    5157        // To Update: LinkageSpec::isXyz( cur_spec ) -> cur_spec.is_xyz
  • src/SynTree/NamedTypeDecl.cc

    r807a632 r3b56166  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Aug  9 13:28:00 2017
    13 // Update Count     : 14
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Mon Dec 16 15:11:40 2019
     13// Update Count     : 17
    1414//
    1515
     
    2020#include "Common/utility.h"      // for printAll, cloneAll, deleteAll, maybe...
    2121#include "Declaration.h"         // for NamedTypeDecl, DeclarationWithType
    22 #include "Parser/LinkageSpec.h"  // for Spec, Cforall, linkageName
     22#include "LinkageSpec.h"         // for Spec, Cforall, linkageName
    2323#include "Type.h"                // for Type, Type::StorageClasses
    2424
     
    4444
    4545        if ( linkage != LinkageSpec::Cforall ) {
    46                 os << LinkageSpec::linkageName( linkage ) << " ";
     46                os << LinkageSpec::name( linkage ) << " ";
    4747        } // if
    4848        get_storageClasses().print( os );
     
    7878}
    7979
    80 std::string TypedefDecl::typeString() const { return "typedef"; }
     80const char * TypedefDecl::typeString() const { return "typedef"; }
    8181
    8282// Local Variables: //
  • src/SynTree/ObjectDecl.cc

    r807a632 r3b56166  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 16 08:34:27 2017
    13 // Update Count     : 59
     12// Last Modified On : Mon Dec 16 15:12:03 2019
     13// Update Count     : 61
    1414//
    1515
     
    2323#include "Expression.h"          // for Expression
    2424#include "Initializer.h"         // for Initializer
    25 #include "Parser/LinkageSpec.h"  // for Spec, linkageName, Cforall
     25#include "LinkageSpec.h"         // for Spec, linkageName, Cforall
    2626#include "Type.h"                // for Type, Type::StorageClasses, Type::Fu...
    2727
     
    4848
    4949        if ( linkage != LinkageSpec::Cforall ) {
    50                 os << LinkageSpec::linkageName( linkage ) << " ";
     50                os << LinkageSpec::name( linkage ) << " ";
    5151        } // if
    5252
  • src/SynTree/Statement.cc

    r807a632 r3b56166  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Sep  3 20:46:44 2017
    13 // Update Count     : 68
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Mon Jan 20 16:03:00 2020
     13// Update Count     : 71
    1414//
    1515
     
    4646Statement::~Statement() {}
    4747
    48 ExprStmt::ExprStmt( Expression *expr ) : Statement(), expr( expr ) {}
    49 
    50 ExprStmt::ExprStmt( const ExprStmt &other ) : Statement( other ), expr( maybeClone( other.expr ) ) {}
     48ExprStmt::ExprStmt( Expression * expr ) : Statement(), expr( expr ) {}
     49
     50ExprStmt::ExprStmt( const ExprStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) {}
    5151
    5252ExprStmt::~ExprStmt() {
     
    5454}
    5555
    56 void ExprStmt::print( std::ostream &os, Indenter indent ) const {
     56void ExprStmt::print( std::ostream & os, Indenter indent ) const {
    5757        os << "Expression Statement:" << endl << indent+1;
    5858        expr->print( os, indent+1 );
     
    6060
    6161
    62 AsmStmt::AsmStmt( bool voltile, Expression *instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ) : Statement(), voltile( voltile ), instruction( instruction ), output( output ), input( input ), clobber( clobber ), gotolabels( gotolabels ) {}
     62AsmStmt::AsmStmt( bool voltile, Expression * instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ) : Statement(), voltile( voltile ), instruction( instruction ), output( output ), input( input ), clobber( clobber ), gotolabels( gotolabels ) {}
    6363
    6464AsmStmt::AsmStmt( const AsmStmt & other ) : Statement( other ), voltile( other.voltile ), instruction( maybeClone( other.instruction ) ), gotolabels( other.gotolabels ) {
     
    7575}
    7676
    77 void AsmStmt::print( std::ostream &os, Indenter indent ) const {
     77void AsmStmt::print( std::ostream & os, Indenter indent ) const {
    7878        os << "Assembler Statement:" << endl;
    7979        os << indent+1 << "instruction: " << endl << indent;
     
    9696DirectiveStmt::DirectiveStmt( const std::string & directive ) : Statement(), directive( directive ) {}
    9797
    98 void DirectiveStmt::print( std::ostream &os, Indenter ) const {
     98void DirectiveStmt::print( std::ostream & os, Indenter ) const {
    9999        os << "GCC Directive:" << directive << endl;
    100100}
    101101
    102102
    103 const char *BranchStmt::brType[] = { "Goto", "Break", "Continue" };
     103const char * BranchStmt::brType[] = {
     104        "Goto", "Break", "Continue", "Fall Through", "Fall Through Default",
     105};
    104106
    105107BranchStmt::BranchStmt( Label target, Type type ) throw ( SemanticErrorException ) :
     
    111113}
    112114
    113 BranchStmt::BranchStmt( Expression *computedTarget, Type type ) throw ( SemanticErrorException ) :
     115BranchStmt::BranchStmt( Expression * computedTarget, Type type ) throw ( SemanticErrorException ) :
    114116        Statement(), computedTarget( computedTarget ), type( type ) {
    115117        if ( type != BranchStmt::Goto || computedTarget == nullptr ) {
     
    118120}
    119121
    120 void BranchStmt::print( std::ostream &os, Indenter indent ) const {
     122void BranchStmt::print( std::ostream & os, Indenter indent ) const {
     123        assert(type < 5);
    121124        os << "Branch (" << brType[type] << ")" << endl ;
    122125        if ( target != "" ) os << indent+1 << "with target: " << target << endl;
     
    125128}
    126129
    127 ReturnStmt::ReturnStmt( Expression *expr ) : Statement(), expr( expr ) {}
     130ReturnStmt::ReturnStmt( Expression * expr ) : Statement(), expr( expr ) {}
    128131
    129132ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) {}
     
    133136}
    134137
    135 void ReturnStmt::print( std::ostream &os, Indenter indent ) const {
     138void ReturnStmt::print( std::ostream & os, Indenter indent ) const {
    136139        os << "Return Statement, returning: ";
    137140        if ( expr != nullptr ) {
     
    142145}
    143146
    144 IfStmt::IfStmt( Expression *condition, Statement *thenPart, Statement *elsePart, std::list<Statement *> initialization ):
     147IfStmt::IfStmt( Expression * condition, Statement * thenPart, Statement * elsePart, std::list<Statement *> initialization ):
    145148        Statement(), condition( condition ), thenPart( thenPart ), elsePart( elsePart ), initialization( initialization ) {}
    146149
     
    157160}
    158161
    159 void IfStmt::print( std::ostream &os, Indenter indent ) const {
     162void IfStmt::print( std::ostream & os, Indenter indent ) const {
    160163        os << "If on condition: " << endl;
    161164        os << indent+1;
     
    176179        thenPart->print( os, indent+1 );
    177180
    178         if ( elsePart != 0 ) {
     181        if ( elsePart != nullptr ) {
    179182                os << indent << "... else: " << endl;
    180183                os << indent+1;
     
    183186}
    184187
    185 SwitchStmt::SwitchStmt( Expression * condition, const std::list<Statement *> &statements ):
     188SwitchStmt::SwitchStmt( Expression * condition, const std::list<Statement *> & statements ):
    186189        Statement(), condition( condition ), statements( statements ) {
    187190}
     
    198201}
    199202
    200 void SwitchStmt::print( std::ostream &os, Indenter indent ) const {
     203void SwitchStmt::print( std::ostream & os, Indenter indent ) const {
    201204        os << "Switch on condition: ";
    202205        condition->print( os );
     
    208211}
    209212
    210 CaseStmt::CaseStmt( Expression *condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticErrorException ) :
     213CaseStmt::CaseStmt( Expression * condition, const std::list<Statement *> & statements, bool deflt ) throw ( SemanticErrorException ) :
    211214        Statement(), condition( condition ), stmts( statements ), _isDefault( deflt ) {
    212         if ( isDefault() && condition != 0 ) SemanticError( condition, "default case with condition: " );
     215        if ( isDefault() && condition != nullptr ) SemanticError( condition, "default case with condition: " );
    213216}
    214217
     
    229232}
    230233
    231 void CaseStmt::print( std::ostream &os, Indenter indent ) const {
     234void CaseStmt::print( std::ostream & os, Indenter indent ) const {
    232235        if ( isDefault() ) os << indent << "Default ";
    233236        else {
     
    243246}
    244247
    245 WhileStmt::WhileStmt( Expression *condition, Statement *body, std::list< Statement * > & initialization, bool isDoWhile ):
     248WhileStmt::WhileStmt( Expression * condition, Statement * body, std::list< Statement * > & initialization, bool isDoWhile ):
    246249        Statement(), condition( condition), body( body), initialization( initialization ), isDoWhile( isDoWhile) {
    247250}
     
    256259}
    257260
    258 void WhileStmt::print( std::ostream &os, Indenter indent ) const {
     261void WhileStmt::print( std::ostream & os, Indenter indent ) const {
    259262        os << "While on condition: " << endl ;
    260263        condition->print( os, indent+1 );
     
    262265        os << indent << "... with body: " << endl;
    263266
    264         if ( body != 0 ) body->print( os, indent+1 );
    265 }
    266 
    267 ForStmt::ForStmt( std::list<Statement *> initialization, Expression *condition, Expression *increment, Statement *body ):
     267        if ( body != nullptr ) body->print( os, indent+1 );
     268}
     269
     270ForStmt::ForStmt( std::list<Statement *> initialization, Expression * condition, Expression * increment, Statement * body ):
    268271        Statement(), initialization( initialization ), condition( condition ), increment( increment ), body( body ) {
    269272}
     
    282285}
    283286
    284 void ForStmt::print( std::ostream &os, Indenter indent ) const {
     287void ForStmt::print( std::ostream & os, Indenter indent ) const {
    285288        Statement::print( os, indent ); // print labels
    286289
     
    305308        }
    306309
    307         if ( body != 0 ) {
     310        if ( body != nullptr ) {
    308311                os << "\n" << indent << "... with body: \n" << indent+1;
    309312                body->print( os, indent+1 );
     
    317320}
    318321
    319 ThrowStmt::ThrowStmt( const ThrowStmt &other ) :
     322ThrowStmt::ThrowStmt( const ThrowStmt & other ) :
    320323        Statement ( other ), kind( other.kind ), expr( maybeClone( other.expr ) ), target( maybeClone( other.target ) ) {
    321324}
     
    326329}
    327330
    328 void ThrowStmt::print( std::ostream &os, Indenter indent) const {
     331void ThrowStmt::print( std::ostream & os, Indenter indent) const {
    329332        if ( target ) os << "Non-Local ";
    330333        os << "Throw Statement, raising: ";
     
    336339}
    337340
    338 TryStmt::TryStmt( CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock ) :
     341TryStmt::TryStmt( CompoundStmt * tryBlock, std::list<CatchStmt *> & handlers, FinallyStmt * finallyBlock ) :
    339342        Statement(), block( tryBlock ),  handlers( handlers ), finallyBlock( finallyBlock ) {
    340343}
    341344
    342 TryStmt::TryStmt( const TryStmt &other ) : Statement( other ), block( maybeClone( other.block ) ), finallyBlock( maybeClone( other.finallyBlock ) ) {
     345TryStmt::TryStmt( const TryStmt & other ) : Statement( other ), block( maybeClone( other.block ) ), finallyBlock( maybeClone( other.finallyBlock ) ) {
    343346        cloneAll( other.handlers, handlers );
    344347}
     
    350353}
    351354
    352 void TryStmt::print( std::ostream &os, Indenter indent ) const {
     355void TryStmt::print( std::ostream & os, Indenter indent ) const {
    353356        os << "Try Statement" << endl;
    354357        os << indent << "... with block:" << endl << indent+1;
     
    363366
    364367        // finally block
    365         if ( finallyBlock != 0 ) {
     368        if ( finallyBlock != nullptr ) {
    366369                os << indent << "... and finally:" << endl << indent+1;
    367370                finallyBlock->print( os, indent+1 );
     
    369372}
    370373
    371 CatchStmt::CatchStmt( Kind kind, Declaration *decl, Expression *cond, Statement *body ) :
     374CatchStmt::CatchStmt( Kind kind, Declaration * decl, Expression * cond, Statement * body ) :
    372375        Statement(), kind ( kind ), decl ( decl ), cond ( cond ), body( body ) {
    373376                assertf( decl, "Catch clause must have a declaration." );
     
    383386}
    384387
    385 void CatchStmt::print( std::ostream &os, Indenter indent ) const {
     388void CatchStmt::print( std::ostream & os, Indenter indent ) const {
    386389        os << "Catch " << ((Terminate == kind) ? "Terminate" : "Resume") << " Statement" << endl;
    387390
     
    401404
    402405
    403 FinallyStmt::FinallyStmt( CompoundStmt *block ) : Statement(), block( block ) {
     406FinallyStmt::FinallyStmt( CompoundStmt * block ) : Statement(), block( block ) {
    404407}
    405408
     
    411414}
    412415
    413 void FinallyStmt::print( std::ostream &os, Indenter indent ) const {
     416void FinallyStmt::print( std::ostream & os, Indenter indent ) const {
    414417        os << "Finally Statement" << endl;
    415418        os << indent << "... with block:" << endl << indent+1;
     
    458461}
    459462
    460 void WaitForStmt::print( std::ostream &os, Indenter indent ) const {
     463void WaitForStmt::print( std::ostream & os, Indenter indent ) const {
    461464        os << "Waitfor Statement" << endl;
    462465        indent += 1;
     
    514517}
    515518
    516 void NullStmt::print( std::ostream &os, Indenter indent ) const {
     519void NullStmt::print( std::ostream & os, Indenter indent ) const {
    517520        os << "Null Statement" << endl;
    518521        Statement::print( os, indent );
     
    530533}
    531534
    532 void ImplicitCtorDtorStmt::print( std::ostream &os, Indenter indent ) const {
     535void ImplicitCtorDtorStmt::print( std::ostream & os, Indenter indent ) const {
    533536        os << "Implicit Ctor Dtor Statement" << endl;
    534537        os << indent << "... with Ctor/Dtor: ";
  • src/SynTree/Statement.h

    r807a632 r3b56166  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar 12 09:01:53 2019
    13 // Update Count     : 83
     12// Last Modified On : Fri Jan 10 14:13:24 2020
     13// Update Count     : 85
    1414//
    1515
     
    257257        Statement * body;
    258258
    259         ForStmt( std::list<Statement *> initialization, Expression * condition = 0, Expression * increment = 0, Statement * body = 0 );
     259        ForStmt( std::list<Statement *> initialization, Expression * condition = nullptr, Expression * increment = nullptr, Statement * body = nullptr );
    260260        ForStmt( const ForStmt & other );
    261261        virtual ~ForStmt();
     
    357357        FinallyStmt * finallyBlock;
    358358
    359         TryStmt( CompoundStmt * tryBlock, std::list<CatchStmt *> & handlers, FinallyStmt * finallyBlock = 0 );
     359        TryStmt( CompoundStmt * tryBlock, std::list<CatchStmt *> & handlers, FinallyStmt * finallyBlock = nullptr );
    360360        TryStmt( const TryStmt & other );
    361361        virtual ~TryStmt();
  • src/SynTree/TupleType.cc

    r807a632 r3b56166  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Feb  1 17:10:58 2017
    13 // Update Count     : 3
     12// Last Modified On : Fri Dec 13 23:44:38 2019
     13// Update Count     : 4
    1414//
    1515
     
    2020#include "Declaration.h"         // for Declaration, ObjectDecl
    2121#include "Initializer.h"         // for ListInit
    22 #include "Parser/LinkageSpec.h"  // for Cforall
     22#include "LinkageSpec.h"         // for Cforall
    2323#include "Type.h"                // for TupleType, Type, Type::Qualifiers
    2424
  • src/SynTree/Type.cc

    r807a632 r3b56166  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Aug  4 21:05:07 2019
    13 // Update Count     : 45
     12// Last Modified On : Sun Dec 15 16:52:37 2019
     13// Update Count     : 49
    1414//
    1515#include "Type.h"
     
    2424using namespace std;
    2525
     26// GENERATED START, DO NOT EDIT
     27// GENERATED BY BasicTypes-gen.cc
    2628const char * BasicType::typeNames[] = {
    2729        "_Bool",
     
    4547        "float",
    4648        "float _Complex",
    47         //"float _Imaginary",
    4849        "_Float32x",
    4950        "_Float32x _Complex",
     
    5253        "double",
    5354        "double _Complex",
    54         //"double _Imaginary",
    5555        "_Float64x",
    5656        "_Float64x _Complex",
     
    6161        "long double",
    6262        "long double _Complex",
    63         //"long double _Imaginary",
    6463        "_Float128x",
    6564        "_Float128x _Complex",
    6665};
    67 static_assert(
    68         sizeof(BasicType::typeNames) / sizeof(BasicType::typeNames[0]) == BasicType::NUMBER_OF_BASIC_TYPES,
    69         "Each basic type name should have a corresponding kind enum value"
    70 );
     66// GENERATED END
    7167
    7268Type::Type( const Qualifiers &tq, const std::list< Attribute * > & attributes ) : tq( tq ), attributes( attributes ) {}
  • src/SynTree/TypeDecl.cc

    r807a632 r3b56166  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Aug  9 14:35:00 2017
    13 // Update Count     : 6
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Dec 13 15:26:14 2019
     13// Update Count     : 21
    1414//
    1515
     
    2121#include "Type.h"            // for Type, Type::StorageClasses
    2222
    23 TypeDecl::TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, bool sized, Type * init ) : Parent( name, scs, type ), init( init ), sized( kind == Ttype || sized ), kind( kind ) {
     23TypeDecl::TypeDecl( const std::string & name, Type::StorageClasses scs, Type * type, Kind kind, bool sized, Type * init ) : Parent( name, scs, type ), kind( kind ), sized( kind == Ttype || sized ), init( init ) {
    2424}
    2525
    26 TypeDecl::TypeDecl( const TypeDecl &other ) : Parent( other ), init( maybeClone( other.init ) ), sized( other.sized ), kind( other.kind ) {
     26TypeDecl::TypeDecl( const TypeDecl & other ) : Parent( other ), kind( other.kind ), sized( other.sized ), init( maybeClone( other.init ) ) {
    2727}
    2828
    2929TypeDecl::~TypeDecl() {
    30   delete init;
     30        delete init;
    3131}
    3232
    33 std::string TypeDecl::typeString() const {
    34         static const std::string kindNames[] = { "object type", "function type", "tuple type" };
    35         assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "typeString: kindNames is out of sync." );
    36         assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." );
    37         return (isComplete() ? "sized " : "") + kindNames[ kind ];
     33const char * TypeDecl::typeString() const {
     34        static const char * kindNames[] = { "sized data type", "sized object type", "sized function type", "sized tuple type" };
     35        static_assert( sizeof(kindNames)/sizeof(kindNames[0]) == TypeDecl::NUMBER_OF_KINDS, "typeString: kindNames is out of sync." );
     36        assertf( kind < TypeDecl::NUMBER_OF_KINDS, "TypeDecl kind is out of bounds." );
     37        return isComplete() ? kindNames[ kind ] : &kindNames[ kind ][ sizeof("sized") ]; // sizeof includes '\0'
    3838}
    3939
    40 std::string TypeDecl::genTypeString() const {
    41         static const std::string kindNames[] = { "dtype", "ftype", "ttype" };
    42         assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "genTypeString: kindNames is out of sync." );
    43         assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." );
     40const char * TypeDecl::genTypeString() const {
     41        static const char * kindNames[] = { "dtype", "otype", "ftype", "ttype" };
     42        static_assert( sizeof(kindNames)/sizeof(kindNames[0]) == TypeDecl::NUMBER_OF_KINDS, "genTypeString: kindNames is out of sync." );
     43        assertf( kind < TypeDecl::NUMBER_OF_KINDS, "TypeDecl kind is out of bounds." );
    4444        return kindNames[ kind ];
    4545}
    4646
    4747void TypeDecl::print( std::ostream &os, Indenter indent ) const {
    48   NamedTypeDecl::print( os, indent );
    49   if ( init ) {
    50     os << std::endl << indent << "with type initializer: ";
    51     init->print( os, indent + 1 );
    52   }
     48        NamedTypeDecl::print( os, indent );
     49        if ( init ) {
     50                os << std::endl << indent << "with type initializer: ";
     51                init->print( os, indent + 1 );
     52        } // if
    5353}
    5454
    55 
    5655std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data ) {
    57   return os << data.kind << ", " << data.isComplete;
     56        return os << data.kind << ", " << data.isComplete;
    5857}
    5958
  • src/SynTree/module.mk

    r807a632 r3b56166  
    1111## Created On       : Mon Jun  1 17:49:17 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Mon Jun  1 17:54:09 2015
    14 ## Update Count     : 1
     13## Last Modified On : Sat Dec 14 07:26:43 2019
     14## Update Count     : 2
    1515###############################################################################
    1616
    1717SRC_SYNTREE = \
    18       SynTree/Type.cc \
    19       SynTree/VoidType.cc \
     18      SynTree/AddressExpr.cc \
     19      SynTree/AggregateDecl.cc \
     20      SynTree/ApplicationExpr.cc \
     21      SynTree/ArrayType.cc \
     22      SynTree/AttrType.cc \
     23      SynTree/Attribute.cc \
    2024      SynTree/BasicType.cc \
    21       SynTree/PointerType.cc \
    22       SynTree/ArrayType.cc \
    23       SynTree/ReferenceType.cc \
    24       SynTree/FunctionType.cc \
    25       SynTree/ReferenceToType.cc \
    26       SynTree/TupleType.cc \
    27       SynTree/TypeofType.cc \
    28       SynTree/AttrType.cc \
    29       SynTree/VarArgsType.cc \
    30       SynTree/ZeroOneType.cc \
     25      SynTree/CommaExpr.cc \
     26      SynTree/CompoundStmt.cc \
    3127      SynTree/Constant.cc \
    32       SynTree/Expression.cc \
    33       SynTree/TupleExpr.cc \
    34       SynTree/CommaExpr.cc \
    35       SynTree/TypeExpr.cc \
    36       SynTree/ApplicationExpr.cc \
    37       SynTree/AddressExpr.cc \
    38       SynTree/Statement.cc \
    39       SynTree/CompoundStmt.cc \
     28      SynTree/DeclReplacer.cc \
    4029      SynTree/DeclStmt.cc \
    4130      SynTree/Declaration.cc \
    4231      SynTree/DeclarationWithType.cc \
     32      SynTree/Expression.cc \
     33      SynTree/FunctionDecl.cc \
     34      SynTree/FunctionType.cc \
     35      SynTree/Initializer.cc \
     36      SynTree/LinkageSpec.cc \
     37      SynTree/NamedTypeDecl.cc \
    4338      SynTree/ObjectDecl.cc \
    44       SynTree/FunctionDecl.cc \
    45       SynTree/AggregateDecl.cc \
    46       SynTree/NamedTypeDecl.cc \
     39      SynTree/PointerType.cc \
     40      SynTree/ReferenceToType.cc \
     41      SynTree/ReferenceType.cc \
     42      SynTree/Statement.cc \
     43      SynTree/TupleExpr.cc \
     44      SynTree/TupleType.cc \
     45      SynTree/Type.cc \
    4746      SynTree/TypeDecl.cc \
    48       SynTree/Initializer.cc \
     47      SynTree/TypeExpr.cc \
    4948      SynTree/TypeSubstitution.cc \
    50       SynTree/Attribute.cc \
    51       SynTree/DeclReplacer.cc
     49      SynTree/TypeofType.cc \
     50      SynTree/VarArgsType.cc \
     51      SynTree/VoidType.cc \
     52      SynTree/ZeroOneType.cc
    5253
    5354SRC += $(SRC_SYNTREE)
  • src/Tuples/TupleAssignment.cc

    r807a632 r3b56166  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 17 09:43:03 2017
    13 // Update Count     : 8
     12// Last Modified On : Fri Dec 13 23:45:33 2019
     13// Update Count     : 9
    1414//
    1515
     
    3434#include "InitTweak/GenInit.h"             // for genCtorInit
    3535#include "InitTweak/InitTweak.h"           // for getPointerBase, isAssignment
    36 #include "Parser/LinkageSpec.h"            // for Cforall
    3736#include "ResolvExpr/Alternative.h"        // for AltList, Alternative
    3837#include "ResolvExpr/AlternativeFinder.h"  // for AlternativeFinder, simpleC...
     
    4140#include "ResolvExpr/TypeEnvironment.h"    // for TypeEnvironment
    4241#include "ResolvExpr/typeops.h"            // for combos
     42#include "SynTree/LinkageSpec.h"           // for Cforall
    4343#include "SynTree/Declaration.h"           // for ObjectDecl
    4444#include "SynTree/Expression.h"            // for Expression, CastExpr, Name...
  • src/Tuples/TupleExpansion.cc

    r807a632 r3b56166  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Jul 19 14:39:00 2019
    13 // Update Count     : 22
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Dec 13 23:45:51 2019
     13// Update Count     : 24
    1414//
    1515
     
    2727#include "Common/utility.h"       // for CodeLocation
    2828#include "InitTweak/InitTweak.h"  // for getFunction
    29 #include "Parser/LinkageSpec.h"   // for Spec, C, Intrinsic
     29#include "SynTree/LinkageSpec.h"  // for Spec, C, Intrinsic
    3030#include "SynTree/Constant.h"     // for Constant
    3131#include "SynTree/Declaration.h"  // for StructDecl, DeclarationWithType
     
    361361        const ast::TypeInstType * isTtype( const ast::Type * type ) {
    362362                if ( const ast::TypeInstType * inst = dynamic_cast< const ast::TypeInstType * >( type ) ) {
    363                         if ( inst->base && inst->base->kind == ast::TypeVar::Ttype ) {
     363                        if ( inst->base && inst->base->kind == ast::TypeDecl::Ttype ) {
    364364                                return inst;
    365365                        }
  • src/cfa.make

    r807a632 r3b56166  
    1 
    2 
    31CFACOMPILE = $(CFACC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) $(AM_CFLAGS) $(CFLAGS)
    42LTCFACOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
    53        $(LIBTOOLFLAGS) --mode=compile $(CFACC) $(DEFS) \
    6         $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) \
    7         $(AM_CFLAGS) $(CFLAGS)
     4        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(AM_CFLAGS) $(CFAFLAGS) $(CFLAGS)
    85
    96AM_V_CFA = $(am__v_CFA_@AM_V@)
     
    2219        $(am__mv) $$depbase.Tpo $$depbase.Plo
    2320
    24 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
    25 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
    26 am__v_JAVAC_0 = @echo "  JAVAC   " $@;
    27 am__v_JAVAC_1 =
    28 
    29 AM_V_GOC = $(am__v_GOC_@AM_V@)
    30 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)
    31 am__v_GOC_0 = @echo "  GOC     " $@;
    32 am__v_GOC_1 =
    33 
    3421UPPCC = u++
    3522UPPCOMPILE = $(UPPCC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_UPPFLAGS) $(UPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_CFLAGS) $(CFLAGS)
     
    3926am__v_UPP_0 = @echo "  UPP     " $@;
    4027am__v_UPP_1 =
     28
     29AM_V_GOC = $(am__v_GOC_@AM_V@)
     30am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)
     31am__v_GOC_0 = @echo "  GOC     " $@;
     32am__v_GOC_1 =
     33
     34AM_V_RUST = $(am__v_RUST_@AM_V@)
     35am__v_RUST_ = $(am__v_RUST_@AM_DEFAULT_V@)
     36am__v_RUST_0 = @echo "  RUST     " $@;
     37am__v_RUST_1 =
     38
     39AM_V_NODEJS = $(am__v_NODEJS_@AM_V@)
     40am__v_NODEJS_ = $(am__v_NODEJS_@AM_DEFAULT_V@)
     41am__v_NODEJS_0 = @echo "  NODEJS     " $@;
     42am__v_NODEJS_1 =
     43
     44AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
     45am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
     46am__v_JAVAC_0 = @echo "  JAVAC   " $@;
     47am__v_JAVAC_1 =
  • src/main.cc

    r807a632 r3b56166  
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Aug 23 06:50:08 2019
    13 // Update Count     : 607
     12// Last Modified On : Sat Feb  8 08:33:50 2020
     13// Update Count     : 633
    1414//
    1515
     
    2020#include <cstdio>                           // for fopen, FILE, fclose, stdin
    2121#include <cstdlib>                          // for exit, free, abort, EXIT_F...
    22 #include <csignal>                         // for signal, SIGABRT, SIGSEGV
     22#include <csignal>                          // for signal, SIGABRT, SIGSEGV
    2323#include <cstring>                          // for index
    2424#include <fstream>                          // for ofstream
     
    2828#include <list>                             // for list
    2929#include <string>                           // for char_traits, operator<<
     30
     31using namespace std;
     32
    3033
    3134#include "CompilationState.h"
     
    5356#include "InitTweak/GenInit.h"              // for genInit
    5457#include "MakeLibCfa.h"                     // for makeLibCfa
    55 #include "Parser/LinkageSpec.h"             // for Spec, Cforall, Intrinsic
    5658#include "Parser/ParseNode.h"               // for DeclarationNode, buildList
    5759#include "Parser/TypedefTable.h"            // for TypedefTable
     
    5961#include "ResolvExpr/Resolver.h"            // for resolve
    6062#include "SymTab/Validate.h"                // for validate
     63#include "SynTree/LinkageSpec.h"            // for Spec, Cforall, Intrinsic
    6164#include "SynTree/Declaration.h"            // for Declaration
    6265#include "SynTree/Visitor.h"                // for acceptAll
     
    6467#include "Virtual/ExpandCasts.h"            // for expandCasts
    6568
    66 
    67 using namespace std;
    6869
    6970static void NewPass( const char * const name ) {
     
    9798static bool waiting_for_gdb = false;                                    // flag to set cfa-cpp to wait for gdb on start
    9899
    99 static std::string PreludeDirector = "";
     100static string PreludeDirector = "";
    100101
    101102static void parse_cmdline( int argc, char *argv[] );
     
    104105
    105106static void backtrace( int start ) {                                    // skip first N stack frames
    106         enum { Frames = 50 };
     107        enum { Frames = 50, };                                                          // maximum number of stack frames
    107108        void * array[Frames];
    108         int size = ::backtrace( array, Frames );
     109        size_t size = ::backtrace( array, Frames );
    109110        char ** messages = ::backtrace_symbols( array, size ); // does not demangle names
    110111
     
    113114
    114115        // skip last 2 stack frames after main
    115         for ( int i = start; i < size - 2 && messages != nullptr; i += 1 ) {
     116        for ( unsigned int i = start; i < size - 2 && messages != nullptr; i += 1 ) {
    116117                char * mangled_name = nullptr, * offset_begin = nullptr, * offset_end = nullptr;
    117                 for ( char *p = messages[i]; *p; ++p ) {        // find parantheses and +offset
     118
     119                for ( char * p = messages[i]; *p; p += 1 ) {    // find parantheses and +offset
    118120                        if ( *p == '(' ) {
    119121                                mangled_name = p;
     
    153155} // backtrace
    154156
    155 static void sigSegvBusHandler( int sig_num ) {
    156         cerr << "*CFA runtime error* program cfa-cpp terminated with "
    157                  <<     (sig_num == SIGSEGV ? "segment fault" : "bus error")
    158                  << "." << endl;
     157#define SIGPARMS int sig __attribute__(( unused )), siginfo_t * sfp __attribute__(( unused )), ucontext_t * cxt __attribute__(( unused ))
     158
     159static void Signal( int sig, void (*handler)(SIGPARMS), int flags ) {
     160        struct sigaction act;
     161
     162        act.sa_sigaction = (void (*)(int, siginfo_t *, void *))handler;
     163        act.sa_flags = flags;
     164
     165        if ( sigaction( sig, &act, nullptr ) == -1 ) {
     166            cerr << "*CFA runtime error* problem installing signal handler, error(" << errno << ") " << strerror( errno ) << endl;
     167            _exit( EXIT_FAILURE );
     168        } // if
     169} // Signal
     170
     171static void sigSegvBusHandler( SIGPARMS ) {
     172        if ( sfp->si_addr == nullptr ) {
     173                cerr << "Null pointer (nullptr) dereference." << endl;
     174        } else {
     175                cerr << (sig == SIGSEGV ? "Segment fault" : "Bus error") << " at memory location " << sfp->si_addr << "." << endl
     176                         << "Possible cause is reading outside the address space or writing to a protected area within the address space with an invalid pointer or subscript." << endl;
     177        } // if
    159178        backtrace( 2 );                                                                         // skip first 2 stack frames
    160         //_exit( EXIT_FAILURE );
    161179        abort();                                                                                        // cause core dump for debugging
    162180} // sigSegvBusHandler
    163181
    164 static void sigAbortHandler( __attribute__((unused)) int sig_num ) {
     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
     199static void sigAbortHandler( SIGPARMS ) {
    165200        backtrace( 6 );                                                                         // skip first 6 stack frames
    166         signal( SIGABRT, SIG_DFL);                                                      // reset default signal handler
     201        Signal( SIGABRT, (void (*)(SIGPARMS))SIG_DFL, SA_SIGINFO );     // reset default signal handler
    167202        raise( SIGABRT );                                                                       // reraise SIGABRT
    168203} // sigAbortHandler
     
    173208        list< Declaration * > translationUnit;
    174209
    175         signal( SIGSEGV, sigSegvBusHandler );
    176         signal( SIGBUS, sigSegvBusHandler );
    177         signal( SIGABRT, sigAbortHandler );
    178 
    179         // std::cout << "main" << std::endl;
     210        Signal( SIGSEGV, sigSegvBusHandler, SA_SIGINFO );
     211        Signal( SIGBUS, sigSegvBusHandler, SA_SIGINFO );
     212        Signal( SIGFPE, sigFpeHandler, SA_SIGINFO );
     213        Signal( SIGABRT, sigAbortHandler, SA_SIGINFO );
     214
     215        // cout << "main" << endl;
    180216        // for ( int i = 0; i < argc; i += 1 ) {
    181         //      std::cout << '\t' << argv[i] << std::endl;
     217        //      cout << '\t' << argv[i] << endl;
    182218        // } // for
    183219
     
    186222
    187223        if ( waiting_for_gdb ) {
    188                 std::cerr << "Waiting for gdb" << std::endl;
    189                 std::cerr << "run :" << std::endl;
    190                 std::cerr << "  gdb attach " << getpid() << std::endl;
     224                cerr << "Waiting for gdb" << endl;
     225                cerr << "run :" << endl;
     226                cerr << "  gdb attach " << getpid() << endl;
    191227                raise(SIGSTOP);
    192228        } // if
     
    388424                return EXIT_FAILURE;
    389425        } catch ( ... ) {
    390                 std::exception_ptr eptr = std::current_exception();
     426                exception_ptr eptr = current_exception();
    391427                try {
    392428                        if (eptr) {
    393                                 std::rethrow_exception(eptr);
     429                                rethrow_exception(eptr);
    394430                        } else {
    395                                 std::cerr << "Exception Uncaught and Unknown" << std::endl;
    396                         } // if
    397                 } catch(const std::exception& e) {
    398                         std::cerr << "Uncaught Exception \"" << e.what() << "\"\n";
     431                                cerr << "Exception Uncaught and Unknown" << endl;
     432                        } // if
     433                } catch(const exception& e) {
     434                        cerr << "Uncaught Exception \"" << e.what() << "\"\n";
    399435                } // try
    400436                return EXIT_FAILURE;
     
    407443
    408444
    409 static const char optstring[] = ":hlLmNnpP:S:twW:D:";
     445static const char optstring[] = ":c:ghlLmNnpP:S:twW:D:";
    410446
    411447enum { PreludeDir = 128 };
    412448static struct option long_opts[] = {
     449        { "colors", required_argument, nullptr, 'c' },
     450        { "gdb", no_argument, nullptr, 'g' },
    413451        { "help", no_argument, nullptr, 'h' },
    414452        { "libcfa", no_argument, nullptr, 'l' },
     
    422460        { "statistics", required_argument, nullptr, 'S' },
    423461        { "tree", no_argument, nullptr, 't' },
    424         { "gdb", no_argument, nullptr, 'g' },
    425462        { "", no_argument, nullptr, 0 },                                        // -w
    426463        { "", no_argument, nullptr, 0 },                                        // -W
     
    430467
    431468static const char * description[] = {
    432         "print help message",                                                           // -h
    433         "generate libcfa.c",                                                            // -l
    434         "generate line marks",                                                          // -L
    435         "do not replace main",                                                          // -m
    436         "do not generate line marks",                                           // -N
    437         "do not read prelude",                                                          // -n
     469        "diagnostic color: never, always, or auto.",          // -c
     470        "wait for gdb to attach",                             // -g
     471        "print help message",                                 // -h
     472        "generate libcfa.c",                                  // -l
     473        "generate line marks",                                // -L
     474        "do not replace main",                                // -m
     475        "do not generate line marks",                         // -N
     476        "do not read prelude",                                // -n
    438477        "generate prototypes for prelude functions",            // -p
    439         "print",                                                                                        // -P
     478        "print",                                              // -P
    440479        "<directory> prelude directory for debug/nodebug",      // no flag
    441480        "<option-list> enable profiling information:\n          counters,heap,time,all,none", // -S
    442         "building cfa standard lib",                                                                    // -t
    443         "wait for gdb to attach",                                                                       // -g
    444         "",                                                                                                     // -w
    445         "",                                                                                                     // -W
    446         "",                                                                                                     // -D
     481        "building cfa standard lib",                          // -t
     482        "",                                                   // -w
     483        "",                                                   // -W
     484        "",                                                   // -D
    447485}; // description
    448486
     
    512550        while ( (c = getopt_long( argc, argv, optstring, long_opts, nullptr )) != -1 ) {
    513551                switch ( c ) {
     552                  case 'c':                                                                             // diagnostic colors
     553                        if ( strcmp( optarg, "always" ) == 0 ) {
     554                                ErrorHelpers::colors = ErrorHelpers::Colors::Always;
     555                        } else if ( strcmp( optarg, "never" ) == 0 ) {
     556                                ErrorHelpers::colors = ErrorHelpers::Colors::Never;
     557                        } else if ( strcmp( optarg, "auto" ) == 0 ) {
     558                                ErrorHelpers::colors = ErrorHelpers::Colors::Auto;
     559                        } // if
     560                        break;
    514561                  case 'h':                                                                             // help message
    515562                        usage( argv );                                                          // no return
  • tests/.expect/alloc.txt

    r807a632 r3b56166  
    3030CFA resize array alloc
    31310xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef
    32 CFA resize array alloc, fill
     32CFA resize array alloc
    33330xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede
    34 CFA resize array alloc, fill
     34CFA resize array alloc
    35350xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef
    3636CFA resize array alloc, fill
    37 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede
     370xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede
    3838
    3939C   memalign 42 42.5
  • tests/.expect/completeTypeError.txt

    r807a632 r3b56166  
    1010      Application of
    1111        Variable Expression: *?: forall
    12           DT: object type
     12          DT: data type
    1313          function
    1414        ... with parameters
     
    3333      Application of
    3434        Variable Expression: *?: forall
    35           DT: object type
     35          DT: data type
    3636          function
    3737        ... with parameters
     
    8787Cost ( 0, 1, 0, 0, 1, -5, 0 ): Application of
    8888            Variable Expression: baz: forall
    89               T: sized object type
     89              T: sized data type
    9090              ... with assertions
    9191                ?=?: pointer to function
  • tests/.expect/gccExtensions.x64.txt

    r807a632 r3b56166  
    1212    asm volatile ( "mov %1, %0\n\t" "add $1, %0" : "=" "r" ( _X3dsti_2 ) :  :  );
    1313    asm volatile ( "mov %1, %0\n\t" "add $1, %0" : "=r" ( _X3dsti_2 ) : "r" ( _X3srci_2 ) :  );
    14     asm ( "mov %1, %0\n\t" "add $1, %0" : "=r" ( _X3dsti_2 ), "=r" ( _X3srci_2 ) : [ _X3srci_2 ] "r" ( _X3dsti_2 ) : "r0" );
     14    asm ( "mov %1, %0\n\t" "add $1, %0" : "=r" ( _X3dsti_2 ), "=r" ( _X3srci_2 ) : [ src ] "r" ( _X3dsti_2 ) : "r0" );
    1515    L2: L1: asm goto ( "frob %%r5, %1; jc %l[L1]; mov (%2), %%r5" :  : "r" ( _X3srci_2 ), "r" ( (&_X3dsti_2) ) : "r5", "memory" : L1, L2 );
    1616    double _Complex _X2c1Cd_2;
  • tests/.expect/gccExtensions.x86.txt

    r807a632 r3b56166  
    1212    asm volatile ( "mov %1, %0\n\t" "add $1, %0" : "=" "r" ( _X3dsti_2 ) :  :  );
    1313    asm volatile ( "mov %1, %0\n\t" "add $1, %0" : "=r" ( _X3dsti_2 ) : "r" ( _X3srci_2 ) :  );
    14     asm ( "mov %1, %0\n\t" "add $1, %0" : "=r" ( _X3dsti_2 ), "=r" ( _X3srci_2 ) : [ _X3srci_2 ] "r" ( _X3dsti_2 ) : "r0" );
     14    asm ( "mov %1, %0\n\t" "add $1, %0" : "=r" ( _X3dsti_2 ), "=r" ( _X3srci_2 ) : [ src ] "r" ( _X3dsti_2 ) : "r0" );
    1515    L2: L1: asm goto ( "frob %%r5, %1; jc %l[L1]; mov (%2), %%r5" :  : "r" ( _X3srci_2 ), "r" ( (&_X3dsti_2) ) : "r5", "memory" : L1, L2 );
    1616    double _Complex _X2c1Cd_2;
  • tests/.expect/loopctrl.txt

    r807a632 r3b56166  
    66A
    77A A A A A A A A A A
     8A A A A A A A A A A A
    89B B B B B
    910C C C C C
     
    1213
    13140 1 2 3 4 5 6 7 8 9
     150 1 2 3 4 5 6 7 8 9 10
    14161 3 5 7 9
    151710 8 6 4 2
     
    2830N N N N N N N N N N
    29310 1 2 3 4 5 6 7 8 9
     320 1 2 3 4 5 6 7 8 9 10
    303310 9 8 7 6 5 4 3 2 1
    3134
  • tests/.expect/rational.txt

    r807a632 r3b56166  
    11constructor
    2 3/1 4/1 0/1
     23/1 4/1 0/1 0/1 1/1
    331/2 5/7
    442/3 -3/2
  • tests/.expect/references.txt

    r807a632 r3b56166  
    36363
    37373 9 { 1., 7. }, [1, 2, 3]
     384
    3839Destructing a Y
    3940Destructing a Y
  • tests/.expect/time.txt

    r807a632 r3b56166  
    1818Dividing that by 2 gives 2403.5 seconds
    19194807 seconds is 1 hours, 20 minutes, 7 seconds
     202020 Jan  5 14:01:40 (GMT)
     211970 Jan  5 14:00:00 (GMT)
     221973 Jan  2 06:59:00 (GMT)
  • tests/Makefile.am

    r807a632 r3b56166  
    4646
    4747# adjust CC to current flags
    48 CC = $(if $(ifeq $(DISTCC_CFA_PATH),yes),distcc $(DISTCC_CFA_PATH),$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
     48CC = $(if $(DISTCC_CFA_PATH),distcc $(DISTCC_CFA_PATH) ${ARCH_FLAGS},$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
    4949CFACC = $(CC)
    5050
     
    5353
    5454# adjusted CC but without the actual distcc call
    55 CFACCLOCAL = $(if $(DISTCC_CFA_PATH),$(DISTCC_CFA_PATH),$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
     55CFACCLOCAL = $(if $(DISTCC_CFA_PATH),$(DISTCC_CFA_PATH) ${ARCH_FLAGS},$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
    5656
    5757PRETTY_PATH=mkdir -p $(dir $(abspath ${@})) && cd ${srcdir} &&
  • tests/Makefile.in

    r807a632 r3b56166  
    214214
    215215# adjust CC to current flags
    216 CC = $(if $(ifeq $(DISTCC_CFA_PATH),yes),distcc $(DISTCC_CFA_PATH),$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
     216CC = $(if $(DISTCC_CFA_PATH),distcc $(DISTCC_CFA_PATH) ${ARCH_FLAGS},$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
    217217CCAS = @CCAS@
    218218CCASDEPMODE = @CCASDEPMODE@
     
    358358LTCFACOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
    359359        $(LIBTOOLFLAGS) --mode=compile $(CFACC) $(DEFS) \
    360         $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) \
    361         $(AM_CFLAGS) $(CFLAGS)
     360        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(AM_CFLAGS) $(CFAFLAGS) $(CFLAGS)
    362361
    363362AM_V_CFA = $(am__v_CFA_@AM_V@)
     
    365364am__v_CFA_0 = @echo "  CFA     " $@;
    366365am__v_CFA_1 =
    367 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
    368 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
    369 am__v_JAVAC_0 = @echo "  JAVAC   " $@;
    370 am__v_JAVAC_1 =
    371 AM_V_GOC = $(am__v_GOC_@AM_V@)
    372 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)
    373 am__v_GOC_0 = @echo "  GOC     " $@;
    374 am__v_GOC_1 =
    375366UPPCC = u++
    376367UPPCOMPILE = $(UPPCC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_UPPFLAGS) $(UPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_CFLAGS) $(CFLAGS)
     
    379370am__v_UPP_0 = @echo "  UPP     " $@;
    380371am__v_UPP_1 =
     372AM_V_GOC = $(am__v_GOC_@AM_V@)
     373am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)
     374am__v_GOC_0 = @echo "  GOC     " $@;
     375am__v_GOC_1 =
     376AM_V_RUST = $(am__v_RUST_@AM_V@)
     377am__v_RUST_ = $(am__v_RUST_@AM_DEFAULT_V@)
     378am__v_RUST_0 = @echo "  RUST     " $@;
     379am__v_RUST_1 =
     380AM_V_NODEJS = $(am__v_NODEJS_@AM_V@)
     381am__v_NODEJS_ = $(am__v_NODEJS_@AM_DEFAULT_V@)
     382am__v_NODEJS_0 = @echo "  NODEJS     " $@;
     383am__v_NODEJS_1 =
     384AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
     385am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
     386am__v_JAVAC_0 = @echo "  JAVAC   " $@;
     387am__v_JAVAC_1 =
    381388debug = yes
    382389installed = no
     
    405412
    406413# adjusted CC but without the actual distcc call
    407 CFACCLOCAL = $(if $(DISTCC_CFA_PATH),$(DISTCC_CFA_PATH),$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
     414CFACCLOCAL = $(if $(DISTCC_CFA_PATH),$(DISTCC_CFA_PATH) ${ARCH_FLAGS},$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
    408415PRETTY_PATH = mkdir -p $(dir $(abspath ${@})) && cd ${srcdir} &&
    409416avl_test_SOURCES = avltree/avl_test.cfa avltree/avl0.cfa avltree/avl1.cfa avltree/avl2.cfa avltree/avl3.cfa avltree/avl4.cfa avltree/avl-private.cfa
  • tests/alloc.cfa

    r807a632 r3b56166  
    1010// Created On       : Wed Feb  3 07:56:22 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Oct 20 21:45:21 2019
    13 // Update Count     : 391
     12// Last Modified On : Fri Nov 22 15:34:19 2019
     13// Update Count     : 404
    1414//
    1515
     
    126126
    127127        p = alloc( p, 2 * dim );                            // CFA resize array alloc
    128         for ( i; dim ~ 2 * dim ) { p[i] = 0x1010101; }
     128        for ( i; dim ~ 2 * dim ) { p[i] = 0x1010101; }          // fill upper part
    129129        printf( "CFA resize array alloc\n" );
    130130        for ( i; 2 * dim ) { printf( "%#x ", p[i] ); }
     
    139139
    140140        p = alloc_set( p, 3 * dim, fill );                                      // CFA resize array alloc, fill
    141         printf( "CFA resize array alloc, fill\n" );
     141        printf( "CFA resize array alloc\n" );
    142142        for ( i; 3 * dim ) { printf( "%#x ", p[i] ); }
    143143        printf( "\n" );
     
    145145
    146146        p = alloc_set( p, dim, fill );                                          // CFA resize array alloc, fill
    147         printf( "CFA resize array alloc, fill\n" );
     147        printf( "CFA resize array alloc\n" );
    148148        for ( i; dim ) { printf( "%#x ", p[i] ); }
    149149        printf( "\n" );
  • tests/builtins/sync.cfa

    r807a632 r3b56166  
    44void foo() {
    55        volatile _Bool * vpB = 0; _Bool vB = 0;
    6         volatile char * vp1 = 0; char * rp1 = 0; char v1 = 0;
    7         volatile short * vp2 = 0; short * rp2 = 0; short v2 = 0;
    8         volatile int * vp4 = 0; int * rp4 = 0; int v4 = 0;
    9         volatile long long int * vp8 = 0; long long int * rp8 = 0; long long int v8 = 0;
    10         #if defined(__SIZEOF_INT128__)
    11         volatile __int128 * vp16 = 0; __int128 * rp16 = 0; __int128 v16 = 0;
     6        volatile char * vpc = 0; char * rpc = 0; char vc = 0;
     7        volatile short * vps = 0; short * rps = 0; short vs = 0;
     8        volatile int * vpi = 0; int * rpi = 0; int vi = 0;
     9        volatile long int * vpl = 0; long int * rpl = 0; long int vl = 0;
     10        volatile long long int * vpll = 0; long long int * rpll = 0; long long int vll = 0;
     11        #if defined(__SIZEOF_INT128__)
     12        volatile __int128 * vplll = 0; __int128 * rplll = 0; __int128 vlll = 0;
    1213        #endif
    1314        struct type * volatile * vpp = 0; struct type ** rpp = 0; struct type * vp = 0;
    1415
    15         { char ret; ret = __sync_fetch_and_add(vp1, v1); }
    16         { char ret; ret = __sync_fetch_and_add_1(vp1, v1); }
    17         { short ret; ret = __sync_fetch_and_add(vp2, v2); }
    18         { short ret; ret = __sync_fetch_and_add_2(vp2, v2); }
    19         { int ret; ret = __sync_fetch_and_add(vp4, v4); }
    20         { int ret; ret = __sync_fetch_and_add_4(vp4, v4); }
    21         { long long int ret; ret = __sync_fetch_and_add(vp8, v8); }
    22         { long long int ret; ret = __sync_fetch_and_add_8(vp8, v8); }
    23         #if defined(__SIZEOF_INT128__)
    24         { __int128 ret; ret = __sync_fetch_and_add(vp16, v16); }
    25         { __int128 ret; ret = __sync_fetch_and_add_16(vp16, v16); }
    26         #endif
    27 
    28         { char ret; ret = __sync_fetch_and_sub(vp1, v1); }
    29         { char ret; ret = __sync_fetch_and_sub_1(vp1, v1); }
    30         { short ret; ret = __sync_fetch_and_sub(vp2, v2); }
    31         { short ret; ret = __sync_fetch_and_sub_2(vp2, v2); }
    32         { int ret; ret = __sync_fetch_and_sub(vp4, v4); }
    33         { int ret; ret = __sync_fetch_and_sub_4(vp4, v4); }
    34         { long long int ret; ret = __sync_fetch_and_sub(vp8, v8); }
    35         { long long int ret; ret = __sync_fetch_and_sub_8(vp8, v8); }
    36         #if defined(__SIZEOF_INT128__)
    37         { __int128 ret; ret = __sync_fetch_and_sub(vp16, v16); }
    38         { __int128 ret; ret = __sync_fetch_and_sub_16(vp16, v16); }
    39         #endif
    40 
    41         { char ret; ret = __sync_fetch_and_or(vp1, v1); }
    42         { char ret; ret = __sync_fetch_and_or_1(vp1, v1); }
    43         { short ret; ret = __sync_fetch_and_or(vp2, v2); }
    44         { short ret; ret = __sync_fetch_and_or_2(vp2, v2); }
    45         { int ret; ret = __sync_fetch_and_or(vp4, v4); }
    46         { int ret; ret = __sync_fetch_and_or_4(vp4, v4); }
    47         { long long int ret; ret = __sync_fetch_and_or(vp8, v8); }
    48         { long long int ret; ret = __sync_fetch_and_or_8(vp8, v8); }
    49         #if defined(__SIZEOF_INT128__)
    50         { __int128 ret; ret = __sync_fetch_and_or(vp16, v16); }
    51         { __int128 ret; ret = __sync_fetch_and_or_16(vp16, v16); }
    52         #endif
    53 
    54         { char ret; ret = __sync_fetch_and_and(vp1, v1); }
    55         { char ret; ret = __sync_fetch_and_and_1(vp1, v1); }
    56         { short ret; ret = __sync_fetch_and_and(vp2, v2); }
    57         { short ret; ret = __sync_fetch_and_and_2(vp2, v2); }
    58         { int ret; ret = __sync_fetch_and_and(vp4, v4); }
    59         { int ret; ret = __sync_fetch_and_and_4(vp4, v4); }
    60         { long long int ret; ret = __sync_fetch_and_and(vp8, v8); }
    61         { long long int ret; ret = __sync_fetch_and_and_8(vp8, v8); }
    62         #if defined(__SIZEOF_INT128__)
    63         { __int128 ret; ret = __sync_fetch_and_and(vp16, v16); }
    64         { __int128 ret; ret = __sync_fetch_and_and_16(vp16, v16); }
    65         #endif
    66 
    67         { char ret; ret = __sync_fetch_and_xor(vp1, v1); }
    68         { char ret; ret = __sync_fetch_and_xor_1(vp1, v1); }
    69         { short ret; ret = __sync_fetch_and_xor(vp2, v2); }
    70         { short ret; ret = __sync_fetch_and_xor_2(vp2, v2); }
    71         { int ret; ret = __sync_fetch_and_xor(vp4, v4); }
    72         { int ret; ret = __sync_fetch_and_xor_4(vp4, v4); }
    73         { long long int ret; ret = __sync_fetch_and_xor(vp8, v8); }
    74         { long long int ret; ret = __sync_fetch_and_xor_8(vp8, v8); }
    75         #if defined(__SIZEOF_INT128__)
    76         { __int128 ret; ret = __sync_fetch_and_xor(vp16, v16); }
    77         { __int128 ret; ret = __sync_fetch_and_xor_16(vp16, v16); }
    78         #endif
    79 
    80         { char ret; ret = __sync_fetch_and_nand(vp1, v1); }
    81         { char ret; ret = __sync_fetch_and_nand_1(vp1, v1); }
    82         { short ret; ret = __sync_fetch_and_nand(vp2, v2); }
    83         { short ret; ret = __sync_fetch_and_nand_2(vp2, v2); }
    84         { int ret; ret = __sync_fetch_and_nand(vp4, v4); }
    85         { int ret; ret = __sync_fetch_and_nand_4(vp4, v4); }
    86         { long long int ret; ret = __sync_fetch_and_nand(vp8, v8); }
    87         { long long int ret; ret = __sync_fetch_and_nand_8(vp8, v8); }
    88         #if defined(__SIZEOF_INT128__)
    89         { __int128 ret; ret = __sync_fetch_and_nand(vp16, v16); }
    90         { __int128 ret; ret = __sync_fetch_and_nand_16(vp16, v16); }
    91         #endif
    92 
    93         { char ret; ret = __sync_add_and_fetch(vp1, v1); }
    94         { char ret; ret = __sync_add_and_fetch_1(vp1, v1); }
    95         { short ret; ret = __sync_add_and_fetch(vp2, v2); }
    96         { short ret; ret = __sync_add_and_fetch_2(vp2, v2); }
    97         { int ret; ret = __sync_add_and_fetch(vp4, v4); }
    98         { int ret; ret = __sync_add_and_fetch_4(vp4, v4); }
    99         { long long int ret; ret = __sync_add_and_fetch(vp8, v8); }
    100         { long long int ret; ret = __sync_add_and_fetch_8(vp8, v8); }
    101         #if defined(__SIZEOF_INT128__)
    102         { __int128 ret; ret = __sync_add_and_fetch(vp16, v16); }
    103         { __int128 ret; ret = __sync_add_and_fetch_16(vp16, v16); }
    104         #endif
    105 
    106         { char ret; ret = __sync_sub_and_fetch(vp1, v1); }
    107         { char ret; ret = __sync_sub_and_fetch_1(vp1, v1); }
    108         { short ret; ret = __sync_sub_and_fetch(vp2, v2); }
    109         { short ret; ret = __sync_sub_and_fetch_2(vp2, v2); }
    110         { int ret; ret = __sync_sub_and_fetch(vp4, v4); }
    111         { int ret; ret = __sync_sub_and_fetch_4(vp4, v4); }
    112         { long long int ret; ret = __sync_sub_and_fetch(vp8, v8); }
    113         { long long int ret; ret = __sync_sub_and_fetch_8(vp8, v8); }
    114         #if defined(__SIZEOF_INT128__)
    115         { __int128 ret; ret = __sync_sub_and_fetch(vp16, v16); }
    116         { __int128 ret; ret = __sync_sub_and_fetch_16(vp16, v16); }
    117         #endif
    118 
    119         { char ret; ret = __sync_or_and_fetch(vp1, v1); }
    120         { char ret; ret = __sync_or_and_fetch_1(vp1, v1); }
    121         { short ret; ret = __sync_or_and_fetch(vp2, v2); }
    122         { short ret; ret = __sync_or_and_fetch_2(vp2, v2); }
    123         { int ret; ret = __sync_or_and_fetch(vp4, v4); }
    124         { int ret; ret = __sync_or_and_fetch_4(vp4, v4); }
    125         { long long int ret; ret = __sync_or_and_fetch(vp8, v8); }
    126         { long long int ret; ret = __sync_or_and_fetch_8(vp8, v8); }
    127         #if defined(__SIZEOF_INT128__)
    128         { __int128 ret; ret = __sync_or_and_fetch(vp16, v16); }
    129         { __int128 ret; ret = __sync_or_and_fetch_16(vp16, v16); }
    130         #endif
    131 
    132         { char ret; ret = __sync_and_and_fetch(vp1, v1); }
    133         { char ret; ret = __sync_and_and_fetch_1(vp1, v1); }
    134         { short ret; ret = __sync_and_and_fetch(vp2, v2); }
    135         { short ret; ret = __sync_and_and_fetch_2(vp2, v2); }
    136         { int ret; ret = __sync_and_and_fetch(vp4, v4); }
    137         { int ret; ret = __sync_and_and_fetch_4(vp4, v4); }
    138         { long long int ret; ret = __sync_and_and_fetch(vp8, v8); }
    139         { long long int ret; ret = __sync_and_and_fetch_8(vp8, v8); }
    140         #if defined(__SIZEOF_INT128__)
    141         { __int128 ret; ret = __sync_and_and_fetch(vp16, v16); }
    142         { __int128 ret; ret = __sync_and_and_fetch_16(vp16, v16); }
    143         #endif
    144 
    145         { char ret; ret = __sync_xor_and_fetch(vp1, v1); }
    146         { char ret; ret = __sync_xor_and_fetch_1(vp1, v1); }
    147         { short ret; ret = __sync_xor_and_fetch(vp2, v2); }
    148         { short ret; ret = __sync_xor_and_fetch_2(vp2, v2); }
    149         { int ret; ret = __sync_xor_and_fetch(vp4, v4); }
    150         { int ret; ret = __sync_xor_and_fetch_4(vp4, v4); }
    151         { long long int ret; ret = __sync_xor_and_fetch(vp8, v8); }
    152         { long long int ret; ret = __sync_xor_and_fetch_8(vp8, v8); }
    153         #if defined(__SIZEOF_INT128__)
    154         { __int128 ret; ret = __sync_xor_and_fetch(vp16, v16); }
    155         { __int128 ret; ret = __sync_xor_and_fetch_16(vp16, v16); }
    156         #endif
    157 
    158         { char ret; ret = __sync_nand_and_fetch(vp1, v1); }
    159         { char ret; ret = __sync_nand_and_fetch_1(vp1, v1); }
    160         { short ret; ret = __sync_nand_and_fetch(vp2, v2); }
    161         { short ret; ret = __sync_nand_and_fetch_2(vp2, v2); }
    162         { int ret; ret = __sync_nand_and_fetch(vp4, v4); }
    163         { int ret; ret = __sync_nand_and_fetch_4(vp4, v4); }
    164         { long long int ret; ret = __sync_nand_and_fetch(vp8, v8); }
    165         { long long int ret; ret = __sync_nand_and_fetch_8(vp8, v8); }
    166         #if defined(__SIZEOF_INT128__)
    167         { __int128 ret; ret = __sync_nand_and_fetch(vp16, v16); }
    168         { __int128 ret; ret = __sync_nand_and_fetch_16(vp16, v16); }
    169         #endif
    170 
    171         { _Bool ret; ret = __sync_bool_compare_and_swap(vp1, v1, v1); }
    172         { _Bool ret; ret = __sync_bool_compare_and_swap_1(vp1, v1, v1); }
    173         { _Bool ret; ret = __sync_bool_compare_and_swap(vp2, v2, v2); }
    174         { _Bool ret; ret = __sync_bool_compare_and_swap_2(vp2, v2, v2); }
    175         { _Bool ret; ret = __sync_bool_compare_and_swap(vp4, v4, v4); }
    176         { _Bool ret; ret = __sync_bool_compare_and_swap_4(vp4, v4, v4); }
    177         { _Bool ret; ret = __sync_bool_compare_and_swap(vp8, v8, v8); }
    178         { _Bool ret; ret = __sync_bool_compare_and_swap_8(vp8, v8, v8); }
    179         #if defined(__SIZEOF_INT128__)
    180         { _Bool ret; ret = __sync_bool_compare_and_swap(vp16, v16, v16); }
    181         { _Bool ret; ret = __sync_bool_compare_and_swap_16(vp16, v16,v16); }
     16        { char ret; ret = __sync_fetch_and_add(vpc, vc); }
     17        { short ret; ret = __sync_fetch_and_add(vps, vs); }
     18        { int ret; ret = __sync_fetch_and_add(vpi, vi); }
     19        { long int ret; ret = __sync_fetch_and_add(vpl, vl); }
     20        { long long int ret; ret = __sync_fetch_and_add(vpll, vll); }
     21        #if defined(__SIZEOF_INT128__)
     22        { __int128 ret; ret = __sync_fetch_and_add(vplll, vlll); }
     23        #endif
     24
     25        { char ret; ret = __sync_fetch_and_sub(vpc, vc); }
     26        { short ret; ret = __sync_fetch_and_sub(vps, vs); }
     27        { int ret; ret = __sync_fetch_and_sub(vpi, vi); }
     28        { long int ret; ret = __sync_fetch_and_sub(vpl, vl); }
     29        { long long int ret; ret = __sync_fetch_and_sub(vpll, vll); }
     30        #if defined(__SIZEOF_INT128__)
     31        { __int128 ret; ret = __sync_fetch_and_sub(vplll, vlll); }
     32        #endif
     33
     34        { char ret; ret = __sync_fetch_and_or(vpc, vc); }
     35        { short ret; ret = __sync_fetch_and_or(vps, vs); }
     36        { int ret; ret = __sync_fetch_and_or(vpi, vi); }
     37        { long int ret; ret = __sync_fetch_and_or(vpl, vl); }
     38        { long long int ret; ret = __sync_fetch_and_or(vpll, vll); }
     39        #if defined(__SIZEOF_INT128__)
     40        { __int128 ret; ret = __sync_fetch_and_or(vplll, vlll); }
     41        #endif
     42
     43        { char ret; ret = __sync_fetch_and_and(vpc, vc); }
     44        { short ret; ret = __sync_fetch_and_and(vps, vs); }
     45        { int ret; ret = __sync_fetch_and_and(vpi, vi); }
     46        { long int ret; ret = __sync_fetch_and_and(vpl, vl); }
     47        { long long int ret; ret = __sync_fetch_and_and(vpll, vll); }
     48        #if defined(__SIZEOF_INT128__)
     49        { __int128 ret; ret = __sync_fetch_and_and(vplll, vlll); }
     50        #endif
     51
     52        { char ret; ret = __sync_fetch_and_xor(vpc, vc); }
     53        { short ret; ret = __sync_fetch_and_xor(vps, vs); }
     54        { int ret; ret = __sync_fetch_and_xor(vpi, vi); }
     55        { long int ret; ret = __sync_fetch_and_xor(vpl, vl); }
     56        { long long int ret; ret = __sync_fetch_and_xor(vpll, vll); }
     57        #if defined(__SIZEOF_INT128__)
     58        { __int128 ret; ret = __sync_fetch_and_xor(vplll, vlll); }
     59        #endif
     60
     61        { char ret; ret = __sync_fetch_and_nand(vpc, vc); }
     62        { short ret; ret = __sync_fetch_and_nand(vps, vs); }
     63        { int ret; ret = __sync_fetch_and_nand(vpi, vi); }
     64        { long int ret; ret = __sync_fetch_and_nand(vpl, vl); }
     65        { long long int ret; ret = __sync_fetch_and_nand(vpll, vll); }
     66        #if defined(__SIZEOF_INT128__)
     67        { __int128 ret; ret = __sync_fetch_and_nand(vplll, vlll); }
     68        { __int128 ret; ret = __sync_fetch_and_nand_16(vplll, vlll); }
     69        #endif
     70
     71        { char ret; ret = __sync_add_and_fetch(vpc, vc); }
     72        { short ret; ret = __sync_add_and_fetch(vps, vs); }
     73        { int ret; ret = __sync_add_and_fetch(vpi, vi); }
     74        { long int ret; ret = __sync_add_and_fetch(vpl, vl); }
     75        { long long int ret; ret = __sync_add_and_fetch(vpll, vll); }
     76        #if defined(__SIZEOF_INT128__)
     77        { __int128 ret; ret = __sync_add_and_fetch(vplll, vlll); }
     78        #endif
     79
     80        { char ret; ret = __sync_sub_and_fetch(vpc, vc); }
     81        { short ret; ret = __sync_sub_and_fetch(vps, vs); }
     82        { int ret; ret = __sync_sub_and_fetch(vpi, vi); }
     83        { long int ret; ret = __sync_sub_and_fetch(vpl, vl); }
     84        { long long int ret; ret = __sync_sub_and_fetch(vpll, vll); }
     85        #if defined(__SIZEOF_INT128__)
     86        { __int128 ret; ret = __sync_sub_and_fetch(vplll, vlll); }
     87        #endif
     88
     89        { char ret; ret = __sync_or_and_fetch(vpc, vc); }
     90        { short ret; ret = __sync_or_and_fetch(vps, vs); }
     91        { int ret; ret = __sync_or_and_fetch(vpi, vi); }
     92        { long int ret; ret = __sync_or_and_fetch(vpl, vl); }
     93        { long long int ret; ret = __sync_or_and_fetch(vpll, vll); }
     94        #if defined(__SIZEOF_INT128__)
     95        { __int128 ret; ret = __sync_or_and_fetch(vplll, vlll); }
     96        #endif
     97
     98        { char ret; ret = __sync_and_and_fetch(vpc, vc); }
     99        { short ret; ret = __sync_and_and_fetch(vps, vs); }
     100        { int ret; ret = __sync_and_and_fetch(vpi, vi); }
     101        { long int ret; ret = __sync_and_and_fetch(vpl, vl); }
     102        { long long int ret; ret = __sync_and_and_fetch(vpll, vll); }
     103        #if defined(__SIZEOF_INT128__)
     104        { __int128 ret; ret = __sync_and_and_fetch(vplll, vlll); }
     105        #endif
     106
     107        { char ret; ret = __sync_xor_and_fetch(vpc, vc); }
     108        { short ret; ret = __sync_xor_and_fetch(vps, vs); }
     109        { int ret; ret = __sync_xor_and_fetch(vpi, vi); }
     110        { long int ret; ret = __sync_xor_and_fetch(vpl, vl); }
     111        { long long int ret; ret = __sync_xor_and_fetch(vpll, vll); }
     112        #if defined(__SIZEOF_INT128__)
     113        { __int128 ret; ret = __sync_xor_and_fetch(vplll, vlll); }
     114        #endif
     115
     116        { char ret; ret = __sync_nand_and_fetch(vpc, vc); }
     117        { short ret; ret = __sync_nand_and_fetch(vps, vs); }
     118        { int ret; ret = __sync_nand_and_fetch(vpi, vi); }
     119        { long int ret; ret = __sync_nand_and_fetch(vpl, vl); }
     120        { long long int ret; ret = __sync_nand_and_fetch(vpll, vll); }
     121        #if defined(__SIZEOF_INT128__)
     122        { __int128 ret; ret = __sync_nand_and_fetch(vplll, vlll); }
     123        #endif
     124
     125        { _Bool ret; ret = __sync_bool_compare_and_swap(vpc, vc, vc); }
     126        { _Bool ret; ret = __sync_bool_compare_and_swap(vps, vs, vs); }
     127        { _Bool ret; ret = __sync_bool_compare_and_swap(vpi, vi, vi); }
     128        { _Bool ret; ret = __sync_bool_compare_and_swap(vpl, vl, vl); }
     129        { _Bool ret; ret = __sync_bool_compare_and_swap(vpll, vll, vll); }
     130        #if defined(__SIZEOF_INT128__)
     131        { _Bool ret; ret = __sync_bool_compare_and_swap(vplll, vlll, vlll); }
    182132        #endif
    183133        { _Bool ret; ret = __sync_bool_compare_and_swap(vpp, vp, vp); }
    184134
    185         { char ret; ret = __sync_val_compare_and_swap(vp1, v1, v1); }
    186         { char ret; ret = __sync_val_compare_and_swap_1(vp1, v1, v1); }
    187         { short ret; ret = __sync_val_compare_and_swap(vp2, v2, v2); }
    188         { short ret; ret = __sync_val_compare_and_swap_2(vp2, v2, v2); }
    189         { int ret; ret = __sync_val_compare_and_swap(vp4, v4, v4); }
    190         { int ret; ret = __sync_val_compare_and_swap_4(vp4, v4, v4); }
    191         { long long int ret; ret = __sync_val_compare_and_swap(vp8, v8, v8); }
    192         { long long int ret; ret = __sync_val_compare_and_swap_8(vp8, v8, v8); }
    193         #if defined(__SIZEOF_INT128__)
    194         { __int128 ret; ret = __sync_val_compare_and_swap(vp16, v16, v16); }
    195         { __int128 ret; ret = __sync_val_compare_and_swap_16(vp16, v16,v16); }
     135        { char ret; ret = __sync_val_compare_and_swap(vpc, vc, vc); }
     136        { short ret; ret = __sync_val_compare_and_swap(vps, vs, vs); }
     137        { int ret; ret = __sync_val_compare_and_swap(vpi, vi, vi); }
     138        { long int ret; ret = __sync_val_compare_and_swap(vpl, vl, vl); }
     139        { long long int ret; ret = __sync_val_compare_and_swap(vpll, vll, vll); }
     140        #if defined(__SIZEOF_INT128__)
     141        { __int128 ret; ret = __sync_val_compare_and_swap(vplll, vlll, vlll); }
    196142        #endif
    197143        { struct type * ret; ret = __sync_val_compare_and_swap(vpp, vp, vp); }
    198144
    199145
    200         { char ret; ret = __sync_lock_test_and_set(vp1, v1); }
    201         { char ret; ret = __sync_lock_test_and_set_1(vp1, v1); }
    202         { short ret; ret = __sync_lock_test_and_set(vp2, v2); }
    203         { short ret; ret = __sync_lock_test_and_set_2(vp2, v2); }
    204         { int ret; ret = __sync_lock_test_and_set(vp4, v4); }
    205         { int ret; ret = __sync_lock_test_and_set_4(vp4, v4); }
    206         { long long int ret; ret = __sync_lock_test_and_set(vp8, v8); }
    207         { long long int ret; ret = __sync_lock_test_and_set_8(vp8, v8); }
    208         #if defined(__SIZEOF_INT128__)
    209         { __int128 ret; ret = __sync_lock_test_and_set(vp16, v16); }
    210         { __int128 ret; ret = __sync_lock_test_and_set_16(vp16, v16); }
    211         #endif
    212 
    213         { __sync_lock_release(vp1); }
    214         { __sync_lock_release_1(vp1); }
    215         { __sync_lock_release(vp2); }
    216         { __sync_lock_release_2(vp2); }
    217         { __sync_lock_release(vp4); }
    218         { __sync_lock_release_4(vp4); }
    219         { __sync_lock_release(vp8); }
    220         { __sync_lock_release_8(vp8); }
    221         #if defined(__SIZEOF_INT128__)
    222         { __sync_lock_release(vp16); }
    223         { __sync_lock_release_16(vp16); }
     146        { char ret; ret = __sync_lock_test_and_set(vpc, vc); }
     147        { short ret; ret = __sync_lock_test_and_set(vps, vs); }
     148        { int ret; ret = __sync_lock_test_and_set(vpi, vi); }
     149        { long int ret; ret = __sync_lock_test_and_set(vpl, vl); }
     150        { long long int ret; ret = __sync_lock_test_and_set(vpll, vll); }
     151        #if defined(__SIZEOF_INT128__)
     152        { __int128 ret; ret = __sync_lock_test_and_set(vplll, vlll); }
     153        #endif
     154
     155        { __sync_lock_release(vpc); }
     156        { __sync_lock_release(vps); }
     157        { __sync_lock_release(vpi); }
     158        { __sync_lock_release(vpl); }
     159        { __sync_lock_release(vpll); }
     160        #if defined(__SIZEOF_INT128__)
     161        { __sync_lock_release(vplll); }
    224162        #endif
    225163
     
    230168
    231169        { _Bool ret; ret = __atomic_test_and_set(vpB, vB); }
    232         { _Bool ret; ret = __atomic_test_and_set(vp1, v1); }
     170        { _Bool ret; ret = __atomic_test_and_set(vpc, vc); }
    233171        { __atomic_clear(vpB, vB); }
    234         { __atomic_clear(vp1, v1); }
    235 
    236         { char ret; ret = __atomic_exchange_n(vp1, v1, __ATOMIC_SEQ_CST); }
    237         { char ret; ret = __atomic_exchange_1(vp1, v1, __ATOMIC_SEQ_CST); }
    238         { char ret; __atomic_exchange(vp1, &v1, &ret, __ATOMIC_SEQ_CST); }
    239         { short ret; ret = __atomic_exchange_n(vp2, v2, __ATOMIC_SEQ_CST); }
    240         { short ret; ret = __atomic_exchange_2(vp2, v2, __ATOMIC_SEQ_CST); }
    241         { short ret; __atomic_exchange(vp2, &v2, &ret, __ATOMIC_SEQ_CST); }
    242         { int ret; ret = __atomic_exchange_n(vp4, v4, __ATOMIC_SEQ_CST); }
    243         { int ret; ret = __atomic_exchange_4(vp4, v4, __ATOMIC_SEQ_CST); }
    244         { int ret; __atomic_exchange(vp4, &v4, &ret, __ATOMIC_SEQ_CST); }
    245         { long long int ret; ret = __atomic_exchange_n(vp8, v8, __ATOMIC_SEQ_CST); }
    246         { long long int ret; ret = __atomic_exchange_8(vp8, v8, __ATOMIC_SEQ_CST); }
    247         { long long int ret; __atomic_exchange(vp8, &v8, &ret, __ATOMIC_SEQ_CST); }
    248         #if defined(__SIZEOF_INT128__)
    249         { __int128 ret; ret = __atomic_exchange_n(vp16, v16, __ATOMIC_SEQ_CST); }
    250         { __int128 ret; ret = __atomic_exchange_16(vp16, v16, __ATOMIC_SEQ_CST); }
    251         { __int128 ret; __atomic_exchange(vp16, &v16, &ret, __ATOMIC_SEQ_CST); }
     172        { __atomic_clear(vpc, vc); }
     173
     174        { char ret; ret = __atomic_exchange_n(vpc, vc, __ATOMIC_SEQ_CST); }
     175        { char ret; __atomic_exchange(vpc, &vc, &ret, __ATOMIC_SEQ_CST); }
     176        { short ret; ret = __atomic_exchange_n(vps, vs, __ATOMIC_SEQ_CST); }
     177        { short ret; __atomic_exchange(vps, &vs, &ret, __ATOMIC_SEQ_CST); }
     178        { int ret; ret = __atomic_exchange_n(vpi, vi, __ATOMIC_SEQ_CST); }
     179        { int ret; __atomic_exchange(vpi, &vi, &ret, __ATOMIC_SEQ_CST); }
     180        { long int ret; ret = __atomic_exchange_n(vpl, vl, __ATOMIC_SEQ_CST); }
     181        { long int ret; __atomic_exchange(vpl, &vl, &ret, __ATOMIC_SEQ_CST); }
     182        { long long int ret; ret = __atomic_exchange_n(vpll, vll, __ATOMIC_SEQ_CST); }
     183        { long long int ret; __atomic_exchange(vpll, &vll, &ret, __ATOMIC_SEQ_CST); }
     184        #if defined(__SIZEOF_INT128__)
     185        { __int128 ret; ret = __atomic_exchange_n(vplll, vlll, __ATOMIC_SEQ_CST); }
     186        { __int128 ret; __atomic_exchange(vplll, &vlll, &ret, __ATOMIC_SEQ_CST); }
    252187        #endif
    253188        { struct type * ret; ret = __atomic_exchange_n(vpp, vp, __ATOMIC_SEQ_CST); }
    254189        { struct type * ret; __atomic_exchange(vpp, &vp, &ret, __ATOMIC_SEQ_CST); }
    255190
    256         { char ret; ret = __atomic_load_n(vp1, __ATOMIC_SEQ_CST); }
    257         { char ret; ret = __atomic_load_1(vp1, __ATOMIC_SEQ_CST); }
    258         { char ret; __atomic_load(vp1, &ret, __ATOMIC_SEQ_CST); }
    259         { short ret; ret = __atomic_load_n(vp2, __ATOMIC_SEQ_CST); }
    260         { short ret; ret = __atomic_load_2(vp2, __ATOMIC_SEQ_CST); }
    261         { short ret; __atomic_load(vp2, &ret, __ATOMIC_SEQ_CST); }
    262         { int ret; ret = __atomic_load_n(vp4, __ATOMIC_SEQ_CST); }
    263         { int ret; ret = __atomic_load_4(vp4, __ATOMIC_SEQ_CST); }
    264         { int ret; __atomic_load(vp4, &ret, __ATOMIC_SEQ_CST); }
    265         { long long int ret; ret = __atomic_load_n(vp8, __ATOMIC_SEQ_CST); }
    266         { long long int ret; ret = __atomic_load_8(vp8, __ATOMIC_SEQ_CST); }
    267         { long long int ret; __atomic_load(vp8, &ret, __ATOMIC_SEQ_CST); }
    268         #if defined(__SIZEOF_INT128__)
    269         { __int128 ret; ret = __atomic_load_n(vp16, __ATOMIC_SEQ_CST); }
    270         { __int128 ret; ret = __atomic_load_16(vp16, __ATOMIC_SEQ_CST); }
    271         { __int128 ret; __atomic_load(vp16, &ret, __ATOMIC_SEQ_CST); }
     191        { char ret; ret = __atomic_load_n(vpc, __ATOMIC_SEQ_CST); }
     192        { char ret; __atomic_load(vpc, &ret, __ATOMIC_SEQ_CST); }
     193        { short ret; ret = __atomic_load_n(vps, __ATOMIC_SEQ_CST); }
     194        { short ret; __atomic_load(vps, &ret, __ATOMIC_SEQ_CST); }
     195        { int ret; ret = __atomic_load_n(vpi, __ATOMIC_SEQ_CST); }
     196        { int ret; __atomic_load(vpi, &ret, __ATOMIC_SEQ_CST); }
     197        { long int ret; ret = __atomic_load_n(vpl, __ATOMIC_SEQ_CST); }
     198        { long int ret; __atomic_load(vpl, &ret, __ATOMIC_SEQ_CST); }
     199        { long long int ret; ret = __atomic_load_n(vpll, __ATOMIC_SEQ_CST); }
     200        { long long int ret; __atomic_load(vpll, &ret, __ATOMIC_SEQ_CST); }
     201        #if defined(__SIZEOF_INT128__)
     202        { __int128 ret; ret = __atomic_load_n(vplll, __ATOMIC_SEQ_CST); }
     203        { __int128 ret; __atomic_load(vplll, &ret, __ATOMIC_SEQ_CST); }
    272204        #endif
    273205        { struct type * ret; ret = __atomic_load_n(vpp, __ATOMIC_SEQ_CST); }
    274206        { struct type * ret; __atomic_load(vpp, &ret, __ATOMIC_SEQ_CST); }
    275207
    276         { _Bool ret; ret = __atomic_compare_exchange_n(vp1, rp1, v1, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    277         { _Bool ret; ret = __atomic_compare_exchange_1(vp1, rp1, v1, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    278         { _Bool ret; ret = __atomic_compare_exchange(vp1, rp1, &v1, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    279         { _Bool ret; ret = __atomic_compare_exchange_n(vp2, rp2, v2, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    280         { _Bool ret; ret = __atomic_compare_exchange_2(vp2, rp2, v2, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    281         { _Bool ret; ret = __atomic_compare_exchange(vp2, rp2, &v2, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    282         { _Bool ret; ret = __atomic_compare_exchange_n(vp4, rp4, v4, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    283         { _Bool ret; ret = __atomic_compare_exchange_4(vp4, rp4, v4, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    284         { _Bool ret; ret = __atomic_compare_exchange(vp4, rp4, &v4, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    285         { _Bool ret; ret = __atomic_compare_exchange_n(vp8, rp8, v8, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    286         { _Bool ret; ret = __atomic_compare_exchange_8(vp8, rp8, v8, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    287         { _Bool ret; ret = __atomic_compare_exchange(vp8, rp8, &v8, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    288         #if defined(__SIZEOF_INT128__)
    289         { _Bool ret; ret = __atomic_compare_exchange_n(vp16, rp16, v16, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    290         { _Bool ret; ret = __atomic_compare_exchange_16(vp16, rp16, v16, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    291         { _Bool ret; ret = __atomic_compare_exchange(vp16, rp16, &v16, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     208        { _Bool ret; ret = __atomic_compare_exchange_n(vpc, rpc, vc, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     209        { _Bool ret; ret = __atomic_compare_exchange(vpc, rpc, &vc, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     210        { _Bool ret; ret = __atomic_compare_exchange_n(vps, rps, vs, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     211        { _Bool ret; ret = __atomic_compare_exchange(vps, rps, &vs, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     212        { _Bool ret; ret = __atomic_compare_exchange_n(vpi, rpi, vi, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     213        { _Bool ret; ret = __atomic_compare_exchange(vpi, rpi, &vi, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     214        { _Bool ret; ret = __atomic_compare_exchange_n(vpl, rpl, vl, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     215        { _Bool ret; ret = __atomic_compare_exchange(vpl, rpl, &vl, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     216        { _Bool ret; ret = __atomic_compare_exchange_n(vpll, rpll, vll, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     217        { _Bool ret; ret = __atomic_compare_exchange(vpll, rpll, &vll, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     218        #if defined(__SIZEOF_INT128__)
     219        { _Bool ret; ret = __atomic_compare_exchange_n(vplll, rplll, vlll, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     220        { _Bool ret; ret = __atomic_compare_exchange(vplll, rplll, &vlll, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    292221        #endif
    293222        { _Bool ret; ret = __atomic_compare_exchange_n(vpp, rpp, vp, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    294223        { _Bool ret; ret = __atomic_compare_exchange(vpp, rpp, &vp, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    295224
    296         { __atomic_store_n(vp1, v1, __ATOMIC_SEQ_CST); }
    297         { __atomic_store_1(vp1, v1, __ATOMIC_SEQ_CST); }
    298         { __atomic_store(vp1, &v1, __ATOMIC_SEQ_CST); }
    299         { __atomic_store_n(vp2, v2, __ATOMIC_SEQ_CST); }
    300         { __atomic_store_2(vp2, v2, __ATOMIC_SEQ_CST); }
    301         { __atomic_store(vp2, &v2, __ATOMIC_SEQ_CST); }
    302         { __atomic_store_n(vp4, v4, __ATOMIC_SEQ_CST); }
    303         { __atomic_store_4(vp4, v4, __ATOMIC_SEQ_CST); }
    304         { __atomic_store(vp4, &v4, __ATOMIC_SEQ_CST); }
    305         { __atomic_store_n(vp8, v8, __ATOMIC_SEQ_CST); }
    306         { __atomic_store_8(vp8, v8, __ATOMIC_SEQ_CST); }
    307         { __atomic_store(vp8, &v8, __ATOMIC_SEQ_CST); }
    308         #if defined(__SIZEOF_INT128__)
    309         { __atomic_store_n(vp16, v16, __ATOMIC_SEQ_CST); }
    310         { __atomic_store_16(vp16, v16, __ATOMIC_SEQ_CST); }
    311         { __atomic_store(vp16, &v16, __ATOMIC_SEQ_CST); }
     225        { __atomic_store_n(vpc, vc, __ATOMIC_SEQ_CST); }
     226        { __atomic_store(vpc, &vc, __ATOMIC_SEQ_CST); }
     227        { __atomic_store_n(vps, vs, __ATOMIC_SEQ_CST); }
     228        { __atomic_store(vps, &vs, __ATOMIC_SEQ_CST); }
     229        { __atomic_store_n(vpi, vi, __ATOMIC_SEQ_CST); }
     230        { __atomic_store(vpi, &vi, __ATOMIC_SEQ_CST); }
     231        { __atomic_store_n(vpl, vl, __ATOMIC_SEQ_CST); }
     232        { __atomic_store(vpl, &vl, __ATOMIC_SEQ_CST); }
     233        { __atomic_store_n(vpll, vll, __ATOMIC_SEQ_CST); }
     234        { __atomic_store(vpll, &vll, __ATOMIC_SEQ_CST); }
     235        #if defined(__SIZEOF_INT128__)
     236        { __atomic_store_n(vplll, vlll, __ATOMIC_SEQ_CST); }
     237        { __atomic_store(vplll, &vlll, __ATOMIC_SEQ_CST); }
    312238        #endif
    313239        { __atomic_store_n(vpp, vp, __ATOMIC_SEQ_CST); }
    314240        { __atomic_store(vpp, &vp, __ATOMIC_SEQ_CST); }
    315241
    316         { char ret; ret = __atomic_add_fetch(vp1, v1, __ATOMIC_SEQ_CST); }
    317         { char ret; ret = __atomic_add_fetch_1(vp1, v1, __ATOMIC_SEQ_CST); }
    318         { short ret; ret = __atomic_add_fetch(vp2, v2, __ATOMIC_SEQ_CST); }
    319         { short ret; ret = __atomic_add_fetch_2(vp2, v2, __ATOMIC_SEQ_CST); }
    320         { int ret; ret = __atomic_add_fetch(vp4, v4, __ATOMIC_SEQ_CST); }
    321         { int ret; ret = __atomic_add_fetch_4(vp4, v4, __ATOMIC_SEQ_CST); }
    322         { long long int ret; ret = __atomic_add_fetch(vp8, v8, __ATOMIC_SEQ_CST); }
    323         { long long int ret; ret = __atomic_add_fetch_8(vp8, v8, __ATOMIC_SEQ_CST); }
    324         #if defined(__SIZEOF_INT128__)
    325         { __int128 ret; ret = __atomic_add_fetch(vp16, v16, __ATOMIC_SEQ_CST); }
    326         { __int128 ret; ret = __atomic_add_fetch_16(vp16, v16, __ATOMIC_SEQ_CST); }
    327         #endif
    328 
    329         { char ret; ret = __atomic_sub_fetch(vp1, v1, __ATOMIC_SEQ_CST); }
    330         { char ret; ret = __atomic_sub_fetch_1(vp1, v1, __ATOMIC_SEQ_CST); }
    331         { short ret; ret = __atomic_sub_fetch(vp2, v2, __ATOMIC_SEQ_CST); }
    332         { short ret; ret = __atomic_sub_fetch_2(vp2, v2, __ATOMIC_SEQ_CST); }
    333         { int ret; ret = __atomic_sub_fetch(vp4, v4, __ATOMIC_SEQ_CST); }
    334         { int ret; ret = __atomic_sub_fetch_4(vp4, v4, __ATOMIC_SEQ_CST); }
    335         { long long int ret; ret = __atomic_sub_fetch(vp8, v8, __ATOMIC_SEQ_CST); }
    336         { long long int ret; ret = __atomic_sub_fetch_8(vp8, v8, __ATOMIC_SEQ_CST); }
    337         #if defined(__SIZEOF_INT128__)
    338         { __int128 ret; ret = __atomic_sub_fetch(vp16, v16, __ATOMIC_SEQ_CST); }
    339         { __int128 ret; ret = __atomic_sub_fetch_16(vp16, v16, __ATOMIC_SEQ_CST); }
    340         #endif
    341 
    342         { char ret; ret = __atomic_and_fetch(vp1, v1, __ATOMIC_SEQ_CST); }
    343         { char ret; ret = __atomic_and_fetch_1(vp1, v1, __ATOMIC_SEQ_CST); }
    344         { short ret; ret = __atomic_and_fetch(vp2, v2, __ATOMIC_SEQ_CST); }
    345         { short ret; ret = __atomic_and_fetch_2(vp2, v2, __ATOMIC_SEQ_CST); }
    346         { int ret; ret = __atomic_and_fetch(vp4, v4, __ATOMIC_SEQ_CST); }
    347         { int ret; ret = __atomic_and_fetch_4(vp4, v4, __ATOMIC_SEQ_CST); }
    348         { long long int ret; ret = __atomic_and_fetch(vp8, v8, __ATOMIC_SEQ_CST); }
    349         { long long int ret; ret = __atomic_and_fetch_8(vp8, v8, __ATOMIC_SEQ_CST); }
    350         #if defined(__SIZEOF_INT128__)
    351         { __int128 ret; ret = __atomic_and_fetch(vp16, v16, __ATOMIC_SEQ_CST); }
    352         { __int128 ret; ret = __atomic_and_fetch_16(vp16, v16, __ATOMIC_SEQ_CST); }
    353         #endif
    354 
    355         { char ret; ret = __atomic_nand_fetch(vp1, v1, __ATOMIC_SEQ_CST); }
    356         { char ret; ret = __atomic_nand_fetch_1(vp1, v1, __ATOMIC_SEQ_CST); }
    357         { short ret; ret = __atomic_nand_fetch(vp2, v2, __ATOMIC_SEQ_CST); }
    358         { short ret; ret = __atomic_nand_fetch_2(vp2, v2, __ATOMIC_SEQ_CST); }
    359         { int ret; ret = __atomic_nand_fetch(vp4, v4, __ATOMIC_SEQ_CST); }
    360         { int ret; ret = __atomic_nand_fetch_4(vp4, v4, __ATOMIC_SEQ_CST); }
    361         { long long int ret; ret = __atomic_nand_fetch(vp8, v8, __ATOMIC_SEQ_CST); }
    362         { long long int ret; ret = __atomic_nand_fetch_8(vp8, v8, __ATOMIC_SEQ_CST); }
    363         #if defined(__SIZEOF_INT128__)
    364         { __int128 ret; ret = __atomic_nand_fetch(vp16, v16, __ATOMIC_SEQ_CST); }
    365         { __int128 ret; ret = __atomic_nand_fetch_16(vp16, v16, __ATOMIC_SEQ_CST); }
    366         #endif
    367 
    368         { char ret; ret = __atomic_xor_fetch(vp1, v1, __ATOMIC_SEQ_CST); }
    369         { char ret; ret = __atomic_xor_fetch_1(vp1, v1, __ATOMIC_SEQ_CST); }
    370         { short ret; ret = __atomic_xor_fetch(vp2, v2, __ATOMIC_SEQ_CST); }
    371         { short ret; ret = __atomic_xor_fetch_2(vp2, v2, __ATOMIC_SEQ_CST); }
    372         { int ret; ret = __atomic_xor_fetch(vp4, v4, __ATOMIC_SEQ_CST); }
    373         { int ret; ret = __atomic_xor_fetch_4(vp4, v4, __ATOMIC_SEQ_CST); }
    374         { long long int ret; ret = __atomic_xor_fetch(vp8, v8, __ATOMIC_SEQ_CST); }
    375         { long long int ret; ret = __atomic_xor_fetch_8(vp8, v8, __ATOMIC_SEQ_CST); }
    376         #if defined(__SIZEOF_INT128__)
    377         { __int128 ret; ret = __atomic_xor_fetch(vp16, v16, __ATOMIC_SEQ_CST); }
    378         { __int128 ret; ret = __atomic_xor_fetch_16(vp16, v16, __ATOMIC_SEQ_CST); }
    379         #endif
    380 
    381         { char ret; ret = __atomic_or_fetch(vp1, v1, __ATOMIC_SEQ_CST); }
    382         { char ret; ret = __atomic_or_fetch_1(vp1, v1, __ATOMIC_SEQ_CST); }
    383         { short ret; ret = __atomic_or_fetch(vp2, v2, __ATOMIC_SEQ_CST); }
    384         { short ret; ret = __atomic_or_fetch_2(vp2, v2, __ATOMIC_SEQ_CST); }
    385         { int ret; ret = __atomic_or_fetch(vp4, v4, __ATOMIC_SEQ_CST); }
    386         { int ret; ret = __atomic_or_fetch_4(vp4, v4, __ATOMIC_SEQ_CST); }
    387         { long long int ret; ret = __atomic_or_fetch(vp8, v8, __ATOMIC_SEQ_CST); }
    388         { long long int ret; ret = __atomic_or_fetch_8(vp8, v8, __ATOMIC_SEQ_CST); }
    389         #if defined(__SIZEOF_INT128__)
    390         { __int128 ret; ret = __atomic_or_fetch(vp16, v16, __ATOMIC_SEQ_CST); }
    391         { __int128 ret; ret = __atomic_or_fetch_16(vp16, v16, __ATOMIC_SEQ_CST); }
    392         #endif
    393 
    394         { char ret; ret = __atomic_fetch_add(vp1, v1, __ATOMIC_SEQ_CST); }
    395         { char ret; ret = __atomic_fetch_add_1(vp1, v1, __ATOMIC_SEQ_CST); }
    396         { short ret; ret = __atomic_fetch_add(vp2, v2, __ATOMIC_SEQ_CST); }
    397         { short ret; ret = __atomic_fetch_add_2(vp2, v2, __ATOMIC_SEQ_CST); }
    398         { int ret; ret = __atomic_fetch_add(vp4, v4, __ATOMIC_SEQ_CST); }
    399         { int ret; ret = __atomic_fetch_add_4(vp4, v4, __ATOMIC_SEQ_CST); }
    400         { long long int ret; ret = __atomic_fetch_add(vp8, v8, __ATOMIC_SEQ_CST); }
    401         { long long int ret; ret = __atomic_fetch_add_8(vp8, v8, __ATOMIC_SEQ_CST); }
    402         #if defined(__SIZEOF_INT128__)
    403         { __int128 ret; ret = __atomic_fetch_add(vp16, v16, __ATOMIC_SEQ_CST); }
    404         { __int128 ret; ret = __atomic_fetch_add_16(vp16, v16, __ATOMIC_SEQ_CST); }
    405         #endif
    406 
    407         { char ret; ret = __atomic_fetch_sub(vp1, v1, __ATOMIC_SEQ_CST); }
    408         { char ret; ret = __atomic_fetch_sub_1(vp1, v1, __ATOMIC_SEQ_CST); }
    409         { short ret; ret = __atomic_fetch_sub(vp2, v2, __ATOMIC_SEQ_CST); }
    410         { short ret; ret = __atomic_fetch_sub_2(vp2, v2, __ATOMIC_SEQ_CST); }
    411         { int ret; ret = __atomic_fetch_sub(vp4, v4, __ATOMIC_SEQ_CST); }
    412         { int ret; ret = __atomic_fetch_sub_4(vp4, v4, __ATOMIC_SEQ_CST); }
    413         { long long int ret; ret = __atomic_fetch_sub(vp8, v8, __ATOMIC_SEQ_CST); }
    414         { long long int ret; ret = __atomic_fetch_sub_8(vp8, v8, __ATOMIC_SEQ_CST); }
    415         #if defined(__SIZEOF_INT128__)
    416         { __int128 ret; ret = __atomic_fetch_sub(vp16, v16, __ATOMIC_SEQ_CST); }
    417         { __int128 ret; ret = __atomic_fetch_sub_16(vp16, v16, __ATOMIC_SEQ_CST); }
    418         #endif
    419 
    420         { char ret; ret = __atomic_fetch_and(vp1, v1, __ATOMIC_SEQ_CST); }
    421         { char ret; ret = __atomic_fetch_and_1(vp1, v1, __ATOMIC_SEQ_CST); }
    422         { short ret; ret = __atomic_fetch_and(vp2, v2, __ATOMIC_SEQ_CST); }
    423         { short ret; ret = __atomic_fetch_and_2(vp2, v2, __ATOMIC_SEQ_CST); }
    424         { int ret; ret = __atomic_fetch_and(vp4, v4, __ATOMIC_SEQ_CST); }
    425         { int ret; ret = __atomic_fetch_and_4(vp4, v4, __ATOMIC_SEQ_CST); }
    426         { long long int ret; ret = __atomic_fetch_and(vp8, v8, __ATOMIC_SEQ_CST); }
    427         { long long int ret; ret = __atomic_fetch_and_8(vp8, v8, __ATOMIC_SEQ_CST); }
    428         #if defined(__SIZEOF_INT128__)
    429         { __int128 ret; ret = __atomic_fetch_and(vp16, v16, __ATOMIC_SEQ_CST); }
    430         { __int128 ret; ret = __atomic_fetch_and_16(vp16, v16, __ATOMIC_SEQ_CST); }
    431         #endif
    432 
    433         { char ret; ret = __atomic_fetch_nand(vp1, v1, __ATOMIC_SEQ_CST); }
    434         { char ret; ret = __atomic_fetch_nand_1(vp1, v1, __ATOMIC_SEQ_CST); }
    435         { short ret; ret = __atomic_fetch_nand(vp2, v2, __ATOMIC_SEQ_CST); }
    436         { short ret; ret = __atomic_fetch_nand_2(vp2, v2, __ATOMIC_SEQ_CST); }
    437         { int ret; ret = __atomic_fetch_nand(vp4, v4, __ATOMIC_SEQ_CST); }
    438         { int ret; ret = __atomic_fetch_nand_4(vp4, v4, __ATOMIC_SEQ_CST); }
    439         { long long int ret; ret = __atomic_fetch_nand(vp8, v8, __ATOMIC_SEQ_CST); }
    440         { long long int ret; ret = __atomic_fetch_nand_8(vp8, v8, __ATOMIC_SEQ_CST); }
    441         #if defined(__SIZEOF_INT128__)
    442         { __int128 ret; ret = __atomic_fetch_nand(vp16, v16, __ATOMIC_SEQ_CST); }
    443         { __int128 ret; ret = __atomic_fetch_nand_16(vp16, v16, __ATOMIC_SEQ_CST); }
    444         #endif
    445 
    446         { char ret; ret = __atomic_fetch_xor(vp1, v1, __ATOMIC_SEQ_CST); }
    447         { char ret; ret = __atomic_fetch_xor_1(vp1, v1, __ATOMIC_SEQ_CST); }
    448         { short ret; ret = __atomic_fetch_xor(vp2, v2, __ATOMIC_SEQ_CST); }
    449         { short ret; ret = __atomic_fetch_xor_2(vp2, v2, __ATOMIC_SEQ_CST); }
    450         { int ret; ret = __atomic_fetch_xor(vp4, v4, __ATOMIC_SEQ_CST); }
    451         { int ret; ret = __atomic_fetch_xor_4(vp4, v4, __ATOMIC_SEQ_CST); }
    452         { long long int ret; ret = __atomic_fetch_xor(vp8, v8, __ATOMIC_SEQ_CST); }
    453         { long long int ret; ret = __atomic_fetch_xor_8(vp8, v8, __ATOMIC_SEQ_CST); }
    454         #if defined(__SIZEOF_INT128__)
    455         { __int128 ret; ret = __atomic_fetch_xor(vp16, v16, __ATOMIC_SEQ_CST); }
    456         { __int128 ret; ret = __atomic_fetch_xor_16(vp16, v16, __ATOMIC_SEQ_CST); }
    457         #endif
    458 
    459         { char ret; ret = __atomic_fetch_or(vp1, v1, __ATOMIC_SEQ_CST); }
    460         { char ret; ret = __atomic_fetch_or_1(vp1, v1, __ATOMIC_SEQ_CST); }
    461         { short ret; ret = __atomic_fetch_or(vp2, v2, __ATOMIC_SEQ_CST); }
    462         { short ret; ret = __atomic_fetch_or_2(vp2, v2, __ATOMIC_SEQ_CST); }
    463         { int ret; ret = __atomic_fetch_or(vp4, v4, __ATOMIC_SEQ_CST); }
    464         { int ret; ret = __atomic_fetch_or_4(vp4, v4, __ATOMIC_SEQ_CST); }
    465         { long long int ret; ret = __atomic_fetch_or(vp8, v8, __ATOMIC_SEQ_CST); }
    466         { long long int ret; ret = __atomic_fetch_or_8(vp8, v8, __ATOMIC_SEQ_CST); }
    467         #if defined(__SIZEOF_INT128__)
    468         { __int128 ret; ret = __atomic_fetch_or(vp16, v16, __ATOMIC_SEQ_CST); }
    469         { __int128 ret; ret = __atomic_fetch_or_16(vp16, v16, __ATOMIC_SEQ_CST); }
    470         #endif
    471 
    472         { _Bool ret; ret = __atomic_always_lock_free(sizeof(int), vp4); }
    473         { _Bool ret; ret = __atomic_is_lock_free(sizeof(int), vp4); }
     242        { char ret; ret = __atomic_add_fetch(vpc, vc, __ATOMIC_SEQ_CST); }
     243        { short ret; ret = __atomic_add_fetch(vps, vs, __ATOMIC_SEQ_CST); }
     244        { int ret; ret = __atomic_add_fetch(vpi, vi, __ATOMIC_SEQ_CST); }
     245        { long int ret; ret = __atomic_add_fetch(vpl, vl, __ATOMIC_SEQ_CST); }
     246        { long long int ret; ret = __atomic_add_fetch(vpll, vll, __ATOMIC_SEQ_CST); }
     247        #if defined(__SIZEOF_INT128__)
     248        { __int128 ret; ret = __atomic_add_fetch(vplll, vlll, __ATOMIC_SEQ_CST); }
     249        #endif
     250
     251        { char ret; ret = __atomic_sub_fetch(vpc, vc, __ATOMIC_SEQ_CST); }
     252        { short ret; ret = __atomic_sub_fetch(vps, vs, __ATOMIC_SEQ_CST); }
     253        { int ret; ret = __atomic_sub_fetch(vpi, vi, __ATOMIC_SEQ_CST); }
     254        { long int ret; ret = __atomic_sub_fetch(vpl, vl, __ATOMIC_SEQ_CST); }
     255        { long long int ret; ret = __atomic_sub_fetch(vpll, vll, __ATOMIC_SEQ_CST); }
     256        #if defined(__SIZEOF_INT128__)
     257        { __int128 ret; ret = __atomic_sub_fetch(vplll, vlll, __ATOMIC_SEQ_CST); }
     258        #endif
     259
     260        { char ret; ret = __atomic_and_fetch(vpc, vc, __ATOMIC_SEQ_CST); }
     261        { short ret; ret = __atomic_and_fetch(vps, vs, __ATOMIC_SEQ_CST); }
     262        { int ret; ret = __atomic_and_fetch(vpi, vi, __ATOMIC_SEQ_CST); }
     263        { long int ret; ret = __atomic_and_fetch(vpl, vl, __ATOMIC_SEQ_CST); }
     264        { long long int ret; ret = __atomic_and_fetch(vpll, vll, __ATOMIC_SEQ_CST); }
     265        #if defined(__SIZEOF_INT128__)
     266        { __int128 ret; ret = __atomic_and_fetch(vplll, vlll, __ATOMIC_SEQ_CST); }
     267        #endif
     268
     269        { char ret; ret = __atomic_nand_fetch(vpc, vc, __ATOMIC_SEQ_CST); }
     270        { short ret; ret = __atomic_nand_fetch(vps, vs, __ATOMIC_SEQ_CST); }
     271        { int ret; ret = __atomic_nand_fetch(vpi, vi, __ATOMIC_SEQ_CST); }
     272        { long int ret; ret = __atomic_nand_fetch(vpl, vl, __ATOMIC_SEQ_CST); }
     273        { long long int ret; ret = __atomic_nand_fetch(vpll, vll, __ATOMIC_SEQ_CST); }
     274        #if defined(__SIZEOF_INT128__)
     275        { __int128 ret; ret = __atomic_nand_fetch(vplll, vlll, __ATOMIC_SEQ_CST); }
     276        #endif
     277
     278        { char ret; ret = __atomic_xor_fetch(vpc, vc, __ATOMIC_SEQ_CST); }
     279        { short ret; ret = __atomic_xor_fetch(vps, vs, __ATOMIC_SEQ_CST); }
     280        { int ret; ret = __atomic_xor_fetch(vpi, vi, __ATOMIC_SEQ_CST); }
     281        { long int ret; ret = __atomic_xor_fetch(vpl, vl, __ATOMIC_SEQ_CST); }
     282        { long long int ret; ret = __atomic_xor_fetch(vpll, vll, __ATOMIC_SEQ_CST); }
     283        #if defined(__SIZEOF_INT128__)
     284        { __int128 ret; ret = __atomic_xor_fetch(vplll, vlll, __ATOMIC_SEQ_CST); }
     285        #endif
     286
     287        { char ret; ret = __atomic_or_fetch(vpc, vc, __ATOMIC_SEQ_CST); }
     288        { short ret; ret = __atomic_or_fetch(vps, vs, __ATOMIC_SEQ_CST); }
     289        { int ret; ret = __atomic_or_fetch(vpi, vi, __ATOMIC_SEQ_CST); }
     290        { long int ret; ret = __atomic_or_fetch(vpl, vl, __ATOMIC_SEQ_CST); }
     291        { long long int ret; ret = __atomic_or_fetch(vpll, vll, __ATOMIC_SEQ_CST); }
     292        #if defined(__SIZEOF_INT128__)
     293        { __int128 ret; ret = __atomic_or_fetch(vplll, vlll, __ATOMIC_SEQ_CST); }
     294        #endif
     295
     296        { char ret; ret = __atomic_fetch_add(vpc, vc, __ATOMIC_SEQ_CST); }
     297        { short ret; ret = __atomic_fetch_add(vps, vs, __ATOMIC_SEQ_CST); }
     298        { int ret; ret = __atomic_fetch_add(vpi, vi, __ATOMIC_SEQ_CST); }
     299        { long int ret; ret = __atomic_fetch_add(vpl, vl, __ATOMIC_SEQ_CST); }
     300        { long long int ret; ret = __atomic_fetch_add(vpll, vll, __ATOMIC_SEQ_CST); }
     301        #if defined(__SIZEOF_INT128__)
     302        { __int128 ret; ret = __atomic_fetch_add(vplll, vlll, __ATOMIC_SEQ_CST); }
     303        #endif
     304
     305        { char ret; ret = __atomic_fetch_sub(vpc, vc, __ATOMIC_SEQ_CST); }
     306        { short ret; ret = __atomic_fetch_sub(vps, vs, __ATOMIC_SEQ_CST); }
     307        { int ret; ret = __atomic_fetch_sub(vpi, vi, __ATOMIC_SEQ_CST); }
     308        { long int ret; ret = __atomic_fetch_sub(vpl, vl, __ATOMIC_SEQ_CST); }
     309        { long long int ret; ret = __atomic_fetch_sub(vpll, vll, __ATOMIC_SEQ_CST); }
     310        #if defined(__SIZEOF_INT128__)
     311        { __int128 ret; ret = __atomic_fetch_sub(vplll, vlll, __ATOMIC_SEQ_CST); }
     312        #endif
     313
     314        { char ret; ret = __atomic_fetch_and(vpc, vc, __ATOMIC_SEQ_CST); }
     315        { short ret; ret = __atomic_fetch_and(vps, vs, __ATOMIC_SEQ_CST); }
     316        { int ret; ret = __atomic_fetch_and(vpi, vi, __ATOMIC_SEQ_CST); }
     317        { long int ret; ret = __atomic_fetch_and(vpl, vl, __ATOMIC_SEQ_CST); }
     318        { long long int ret; ret = __atomic_fetch_and(vpll, vll, __ATOMIC_SEQ_CST); }
     319        #if defined(__SIZEOF_INT128__)
     320        { __int128 ret; ret = __atomic_fetch_and(vplll, vlll, __ATOMIC_SEQ_CST); }
     321        #endif
     322
     323        { char ret; ret = __atomic_fetch_nand(vpc, vc, __ATOMIC_SEQ_CST); }
     324        { short ret; ret = __atomic_fetch_nand(vps, vs, __ATOMIC_SEQ_CST); }
     325        { int ret; ret = __atomic_fetch_nand(vpi, vi, __ATOMIC_SEQ_CST); }
     326        { long int ret; ret = __atomic_fetch_nand(vpl, vl, __ATOMIC_SEQ_CST); }
     327        { long long int ret; ret = __atomic_fetch_nand(vpll, vll, __ATOMIC_SEQ_CST); }
     328        #if defined(__SIZEOF_INT128__)
     329        { __int128 ret; ret = __atomic_fetch_nand(vplll, vlll, __ATOMIC_SEQ_CST); }
     330        #endif
     331
     332        { char ret; ret = __atomic_fetch_xor(vpc, vc, __ATOMIC_SEQ_CST); }
     333        { short ret; ret = __atomic_fetch_xor(vps, vs, __ATOMIC_SEQ_CST); }
     334        { int ret; ret = __atomic_fetch_xor(vpi, vi, __ATOMIC_SEQ_CST); }
     335        { long int ret; ret = __atomic_fetch_xor(vpl, vl, __ATOMIC_SEQ_CST); }
     336        { long long int ret; ret = __atomic_fetch_xor(vpll, vll, __ATOMIC_SEQ_CST); }
     337        #if defined(__SIZEOF_INT128__)
     338        { __int128 ret; ret = __atomic_fetch_xor(vplll, vlll, __ATOMIC_SEQ_CST); }
     339        #endif
     340
     341        { char ret; ret = __atomic_fetch_or(vpc, vc, __ATOMIC_SEQ_CST); }
     342        { short ret; ret = __atomic_fetch_or(vps, vs, __ATOMIC_SEQ_CST); }
     343        { int ret; ret = __atomic_fetch_or(vpi, vi, __ATOMIC_SEQ_CST); }
     344        { long int ret; ret = __atomic_fetch_or(vpl, vl, __ATOMIC_SEQ_CST); }
     345        { long long int ret; ret = __atomic_fetch_or(vpll, vll, __ATOMIC_SEQ_CST); }
     346        #if defined(__SIZEOF_INT128__)
     347        { __int128 ret; ret = __atomic_fetch_or(vplll, vlll, __ATOMIC_SEQ_CST); }
     348        #endif
     349
     350        { _Bool ret; ret = __atomic_always_lock_free(sizeof(int), vpi); }
     351        { _Bool ret; ret = __atomic_is_lock_free(sizeof(int), vpi); }
    474352        { __atomic_thread_fence(__ATOMIC_SEQ_CST); }
    475353        { __atomic_signal_fence(__ATOMIC_SEQ_CST); }
  • tests/concurrent/examples/boundedBufferEXT.cfa

    r807a632 r3b56166  
    1010// Created On       : Wed Apr 18 22:52:12 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jun 21 08:19:20 2019
    13 // Update Count     : 14
     12// Last Modified On : Thu Jan 16 22:36:34 2020
     13// Update Count     : 15
    1414//
    1515
     
    3737
    3838        void insert( Buffer(T) & mutex buffer, T elem ) with( buffer ) {
    39                 if ( count == BufferSize ) waitfor( remove, buffer );
     39                if ( count == BufferSize ) waitfor( remove : buffer );
    4040                elements[back] = elem;
    4141                back = ( back + 1 ) % BufferSize;
     
    4444
    4545        T remove( Buffer(T) & mutex buffer ) with( buffer ) {
    46                 if ( count == 0 ) waitfor( insert, buffer );
     46                if ( count == 0 ) waitfor( insert : buffer );
    4747                T elem = elements[front];
    4848                front = ( front + 1 ) % BufferSize;
  • tests/concurrent/examples/boundedBufferTHREAD.cfa

    r807a632 r3b56166  
    1010// Created On       : Wed Apr 18 22:52:12 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jun 21 11:50:12 2019
    13 // Update Count     : 24
     12// Last Modified On : Thu Jan 16 23:09:43 2020
     13// Update Count     : 25
    1414//
    1515
     
    4444        void main( Buffer & buffer ) with( buffer ) {
    4545                for () {
    46                         waitfor( ^?{}, buffer ) {
     46                        waitfor( ^?{} : buffer ) {
    4747                                break;
    48                         } or when ( count != 20 ) waitfor( insert, buffer ) {
     48                        } or when ( count != 20 ) waitfor( insert : buffer ) {
    4949                                back = (back + 1) % 20;
    5050                                count += 1;
    51                         } or when ( count != 0 ) waitfor( remove, buffer ) {
     51                        } or when ( count != 0 ) waitfor( remove : buffer ) {
    5252                                front = (front + 1) % 20;
    5353                                count -= 1;
  • tests/concurrent/examples/gortn.cfa

    r807a632 r3b56166  
    1010// Created On       : Wed Feb 20 08:02:37 2019
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jun 21 08:25:03 2019
    13 // Update Count     : 4
     12// Last Modified On : Thu Jan 16 22:43:40 2020
     13// Update Count     : 5
    1414//
    1515
     
    2626void main( GoRtn & gortn ) with( gortn ) {
    2727        for () {
    28                 waitfor( mem1, gortn ) sout | i;
    29                 or waitfor( mem2, gortn ) sout | f;
    30                 or waitfor( mem3, gortn ) sout | m.i | m.j;
    31                 or waitfor( ^?{}, gortn ) break;
     28                waitfor( mem1 : gortn ) sout | i;
     29                or waitfor( mem2 : gortn ) sout | f;
     30                or waitfor( mem3 : gortn ) sout | m.i | m.j;
     31                or waitfor( ^?{} : gortn ) break;
    3232        }
    3333}
  • tests/concurrent/preempt.cfa

    r807a632 r3b56166  
    3636                if( (counter % 7) == this.value ) {
    3737                        __cfaabi_check_preemption();
    38                         int next = __atomic_add_fetch_4(&counter, 1, __ATOMIC_SEQ_CST);
     38                        int next = __atomic_add_fetch( &counter, 1, __ATOMIC_SEQ_CST );
    3939                        __cfaabi_check_preemption();
    4040                        if( (next % 100) == 0 ) printf("%d\n", (int)next);
  • tests/concurrent/signal/wait.cfa

    r807a632 r3b56166  
    9898        }
    9999
    100         __sync_fetch_and_sub_4( &waiter_left, 1);
     100        __atomic_fetch_sub( &waiter_left, 1,  __ATOMIC_SEQ_CST );
    101101}
    102102
     
    109109        }
    110110
    111         __sync_fetch_and_sub_4( &waiter_left, 1);
     111        __atomic_fetch_sub( &waiter_left, 1,  __ATOMIC_SEQ_CST );
    112112}
    113113
     
    120120        }
    121121
    122         __sync_fetch_and_sub_4( &waiter_left, 1);
     122        __atomic_fetch_sub( &waiter_left, 1,  __ATOMIC_SEQ_CST );
    123123}
    124124
     
    131131        }
    132132
    133         __sync_fetch_and_sub_4( &waiter_left, 1);
     133        __atomic_fetch_sub( &waiter_left, 1,  __ATOMIC_SEQ_CST );
    134134}
    135135
  • tests/concurrent/thread.cfa

    r807a632 r3b56166  
    77thread Second { semaphore* lock; };
    88
    9 void ?{}( First  & this, semaphore & lock ) { ((thread&)this){"Thread 1"}; this.lock = &lock; }
    10 void ?{}( Second & this, semaphore & lock ) { ((thread&)this){"Thread 2"}; this.lock = &lock; }
     9void ?{}( First  & this, semaphore & lock ) { ((thread&)this){ "Thread 1" }; this.lock = &lock; }
     10void ?{}( Second & this, semaphore & lock ) { ((thread&)this){ "Thread 2" }; this.lock = &lock; }
    1111
    1212void main(First& this) {
  • tests/concurrent/waitfor/barge.cfa

    r807a632 r3b56166  
    6565                yield(random( 10 ));
    6666                this.state = WAITFOR;
    67                 waitfor(do_call, this) {
     67                waitfor(do_call : this) {
    6868                        sout | i;
    6969                }
  • tests/concurrent/waitfor/dtor.cfa

    r807a632 r3b56166  
    4747        yield(random( 10 ));
    4848        set_state( this, MAIN );
    49         waitfor( ^?{}, this ) {
     49        waitfor( ^?{} : this ) {
    5050                set_state( this, AFTER );
    5151        }
  • tests/concurrent/waitfor/else.cfa

    r807a632 r3b56166  
    1414        sout | "Starting";
    1515
    16         when( false ) waitfor( notcalled, m );
     16        when( false ) waitfor( notcalled : m );
    1717
    1818        sout | "Step" | i++;
    1919
    20         waitfor( notcalled, m ); or else {
     20        waitfor( notcalled : m ); or else {
    2121                sout | "else called";
    2222        }
     
    2424        sout | "Step" | i++;
    2525
    26         when( true ) waitfor( notcalled, m ); or when( true ) else {
     26        when( true ) waitfor( notcalled : m ); or when( true ) else {
    2727                sout | "else called";
    2828        }
     
    3030        sout | "Step" | i++;
    3131
    32         when( false ) waitfor( notcalled, m ); or when( true ) else {
     32        when( false ) waitfor( notcalled : m ); or when( true ) else {
    3333                sout | "else called";
    3434        }
     
    3636        sout | "Step" | i++;
    3737
    38         when( false ) waitfor( notcalled, m ); or when( false ) else {
     38        when( false ) waitfor( notcalled : m ); or when( false ) else {
    3939                sout | "else called";
    4040        }
  • tests/concurrent/waitfor/parse.cfa

    r807a632 r3b56166  
    2424
    2525        //---------------------------------------
    26         waitfor( f1, a ) {
     26        waitfor( f1 : a ) {
    2727                1;
    2828        }
    2929
    3030        //---------------------------------------
    31         waitfor( f1, a ) {
     31        waitfor( f1 : a ) {
    3232                2;
    3333        }
    34         waitfor( f2, a ) {
     34        waitfor( f2 : a ) {
    3535                3;
    3636        }
    3737
    3838        //---------------------------------------
    39         when( 1 < 3 ) waitfor( f2, a, a ) {
     39        when( 1 < 3 ) waitfor( f2 : a, a ) {
    4040                4;
    4141        }
     
    4545
    4646        //---------------------------------------
    47         when( 2 < 3 ) waitfor( f3, a ) {
     47        when( 2 < 3 ) waitfor( f3 : a ) {
    4848                5;
    4949        }
     
    5353
    5454        //---------------------------------------
    55         when( 3 < 3 ) waitfor( f3, a, a ) {
     55        when( 3 < 3 ) waitfor( f3 : a, a ) {
    5656                7;
    5757        }
     
    6464
    6565        //---------------------------------------
    66         when( 6 < 3 ) waitfor( f3, a, a, a ) {
     66        when( 6 < 3 ) waitfor( f3 : a, a, a ) {
    6767                10;
    6868        }
    69         or when( 7 < 3 ) waitfor( f1, a  ) {
     69        or when( 7 < 3 ) waitfor( f1 : a  ) {
    7070                11;
    7171        }
     
    7575
    7676        //---------------------------------------
    77         when( 8 < 3 ) waitfor( f3, a, a ) {
     77        when( 8 < 3 ) waitfor( f3 : a, a ) {
    7878                13;
    7979        }
    80         or waitfor( f1, a  ) {
     80        or waitfor( f1 : a  ) {
    8181                14;
    8282        }
     
    8686
    8787        //---------------------------------------
    88         when( 10 < 3 ) waitfor( f1, a ) {
     88        when( 10 < 3 ) waitfor( f1 : a ) {
    8989                16;
    9090        }
    91         or waitfor( f2, a, a ) {
     91        or waitfor( f2 : a, a ) {
    9292                17;
    9393        }
     
    100100}
    101101
    102 int main() {
    103 
    104 }
     102int main() {}
  • tests/concurrent/waitfor/parse2.cfa

    r807a632 r3b56166  
    1010// Created On       : Wed Aug 30 17:53:29 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 22 13:42:11 2019
    13 // Update Count     : 3
     12// Last Modified On : Thu Jan 16 23:13:37 2020
     13// Update Count     : 6
    1414//
    1515
     
    2626        }
    2727
    28         waitfor( x, z ) {
     28        waitfor( x : z ) {
    2929        }
    3030
     
    3737        or waitfor( y );
    3838
    39         waitfor( x, z );
     39        waitfor( x : z );
    4040        or waitfor( y );
    4141
     
    4343        or when( true ) waitfor( y );
    4444
    45         when( true ) waitfor( x, z );
     45        when( true ) waitfor( x : z );
    4646        or when( true ) waitfor( y );
    4747
     
    5050        }
    5151
    52         waitfor( x, z ) {
     52        waitfor( x : z ) {
    5353        } or waitfor( y ) {
    5454        }
     
    8080        or else;
    8181
    82         when( true ) waitfor( x, z );
     82        when( true ) waitfor( x : z );
    8383        or else;
    8484
     
    9999        }
    100100
    101         when( true ) waitfor( x, z );
     101        when( true ) waitfor( x : z );
    102102        or else {
    103103        }
     
    115115        or when( true ) else;
    116116
    117         when( true ) waitfor( x, z );
     117        when( true ) waitfor( x : z );
    118118        or when( true ) else;
    119119
     
    134134        }
    135135
    136         when( true ) waitfor( x, z );
     136        when( true ) waitfor( x : z );
    137137        or when( true ) else {
    138138        }
     
    149149        or timeout( 3 );
    150150
    151         waitfor( x, z );
     151        waitfor( x : z );
    152152        or timeout( 3 );
    153153
     
    163163        }
    164164
    165         when( true ) waitfor( x, z ) {
     165        when( true ) waitfor( x : z ) {
    166166        } or timeout( 3 ) {
    167167        }
     
    171171        }
    172172
    173         when( true ) waitfor( x, z ) {
     173        when( true ) waitfor( x : z ) {
    174174        } or when ( true ) timeout( 3 ) {
    175175        }
     
    229229
    230230        int or, timeout;
    231         waitfor( timeout, 7 ) 3;
    232         waitfor( timeout, 7 ) 3; or waitfor( timeout, 7 ) 3;
    233         when( or ) waitfor( or, ) { 4; } or timeout( 1 ) 3;
    234         when( 3 ) waitfor( or, 2 ) 4; or else 4;
    235         when( 3 ) waitfor( or, 3 ) 4; or when( or ) timeout( or ) 4; or when( or ) else timeout;
    236         when( 3 ) waitfor( or, or ) 3; or when( or ) waitfor( or, timeout ) 4; or else 4;
    237         when( 3 ) waitfor( or, or ) 3; or waitfor( or, 9 ) 4; or when( or ) timeout( timeout ) 4;
    238         when( 3 ) waitfor( or, 3 ) 3; or waitfor( or, 7 ) or; or timeout( 1 ) or; or when( 3 ) else or;
     231        waitfor( timeout : 7 ) 3;
     232        waitfor( timeout : 7 ) 3; or waitfor( timeout : 7 ) 3;
     233        when( or ) waitfor( or : ) { 4; } or timeout( 1 ) 3;
     234        when( 3 ) waitfor( or : 2 ) 4; or else 4;
     235        when( 3 ) waitfor( or : 3 ) 4; or when( or ) timeout( or ) 4; or when( or ) else timeout;
     236        when( 3 ) waitfor( or : or ) 3; or when( or ) waitfor( or : timeout ) 4; or else 4;
     237        when( 3 ) waitfor( or : or ) 3; or waitfor( or : 9 ) 4; or when( or ) timeout( timeout ) 4;
     238        when( 3 ) waitfor( or : 3 ) 3; or waitfor( or : 7 ) or; or timeout( 1 ) or; or when( 3 ) else or;
    239239
    240240        // test else selection
  • tests/concurrent/waitfor/recurse.cfa

    r807a632 r3b56166  
    6666
    6767        rand_yield();
    68         waitfor( call4, this );
     68        waitfor( call4 : this );
    6969        rand_yield();
    7070
     
    7878
    7979        rand_yield();
    80         waitfor( call3, this );
     80        waitfor( call3 : this );
    8181        rand_yield();
    8282
     
    9292
    9393        rand_yield();
    94         waitfor( call2, this );
     94        waitfor( call2 : this );
    9595        rand_yield();
    9696
  • tests/concurrent/waitfor/statment.cfa

    r807a632 r3b56166  
    101101
    102102        while( !done ) {
    103                    waitfor( get_index, this );
    104                 or waitfor( call1, this ) { sout | "Statement"; if( this.last_val != 1 ) { serr | "Incorrect index: expected" | 1 | "got" | this.last_val; } }
    105                 or waitfor( call2, this ) { sout | "Statement"; if( this.last_val != 2 ) { serr | "Incorrect index: expected" | 2 | "got" | this.last_val; } }
    106                 or waitfor( call3, this ) { sout | "Statement"; if( this.last_val != 3 ) { serr | "Incorrect index: expected" | 3 | "got" | this.last_val; } }
    107                 or waitfor( call4, this ) { sout | "Statement"; if( this.last_val != 4 ) { serr | "Incorrect index: expected" | 4 | "got" | this.last_val; } }
    108                 or waitfor( call5, this ) { sout | "Statement"; if( this.last_val != 5 ) { serr | "Incorrect index: expected" | 5 | "got" | this.last_val; } }
    109                 or waitfor( call6, this ) { sout | "Statement"; if( this.last_val != 6 ) { serr | "Incorrect index: expected" | 6 | "got" | this.last_val; } }
    110                 or waitfor( call7, this ) { sout | "Statement"; if( this.last_val != 7 ) { serr | "Incorrect index: expected" | 7 | "got" | this.last_val; } }
     103                   waitfor( get_index : this );
     104                or waitfor( call1 : this ) { sout | "Statement"; if( this.last_val != 1 ) { serr | "Incorrect index: expected" | 1 | "got" | this.last_val; } }
     105                or waitfor( call2 : this ) { sout | "Statement"; if( this.last_val != 2 ) { serr | "Incorrect index: expected" | 2 | "got" | this.last_val; } }
     106                or waitfor( call3 : this ) { sout | "Statement"; if( this.last_val != 3 ) { serr | "Incorrect index: expected" | 3 | "got" | this.last_val; } }
     107                or waitfor( call4 : this ) { sout | "Statement"; if( this.last_val != 4 ) { serr | "Incorrect index: expected" | 4 | "got" | this.last_val; } }
     108                or waitfor( call5 : this ) { sout | "Statement"; if( this.last_val != 5 ) { serr | "Incorrect index: expected" | 5 | "got" | this.last_val; } }
     109                or waitfor( call6 : this ) { sout | "Statement"; if( this.last_val != 6 ) { serr | "Incorrect index: expected" | 6 | "got" | this.last_val; } }
     110                or waitfor( call7 : this ) { sout | "Statement"; if( this.last_val != 7 ) { serr | "Incorrect index: expected" | 7 | "got" | this.last_val; } }
    111111
    112112                done = true;
  • tests/concurrent/waitfor/when.cfa

    r807a632 r3b56166  
    5858void arbiter( global_t & mutex this ) {
    5959        for( int i = 0; i < N; i++ ) {
    60                    when( this.last_call == 6 ) waitfor( call1, this ) { if( this.last_call != 1) { serr | "Expected last_call to be 1 got" | this.last_call; } }
    61                 or when( this.last_call == 1 ) waitfor( call2, this ) { if( this.last_call != 2) { serr | "Expected last_call to be 2 got" | this.last_call; } }
    62                 or when( this.last_call == 2 ) waitfor( call3, this ) { if( this.last_call != 3) { serr | "Expected last_call to be 3 got" | this.last_call; } }
    63                 or when( this.last_call == 3 ) waitfor( call4, this ) { if( this.last_call != 4) { serr | "Expected last_call to be 4 got" | this.last_call; } }
    64                 or when( this.last_call == 4 ) waitfor( call5, this ) { if( this.last_call != 5) { serr | "Expected last_call to be 5 got" | this.last_call; } }
    65                 or when( this.last_call == 5 ) waitfor( call6, this ) { if( this.last_call != 6) { serr | "Expected last_call to be 6 got" | this.last_call; } }
     60                   when( this.last_call == 6 ) waitfor( call1 : this ) { if( this.last_call != 1) { serr | "Expected last_call to be 1 got" | this.last_call; } }
     61                or when( this.last_call == 1 ) waitfor( call2 : this ) { if( this.last_call != 2) { serr | "Expected last_call to be 2 got" | this.last_call; } }
     62                or when( this.last_call == 2 ) waitfor( call3 : this ) { if( this.last_call != 3) { serr | "Expected last_call to be 3 got" | this.last_call; } }
     63                or when( this.last_call == 3 ) waitfor( call4 : this ) { if( this.last_call != 4) { serr | "Expected last_call to be 4 got" | this.last_call; } }
     64                or when( this.last_call == 4 ) waitfor( call5 : this ) { if( this.last_call != 5) { serr | "Expected last_call to be 5 got" | this.last_call; } }
     65                or when( this.last_call == 5 ) waitfor( call6 : this ) { if( this.last_call != 6) { serr | "Expected last_call to be 6 got" | this.last_call; } }
    6666
    6767                sout | this.last_call;
  • tests/expression.cfa

    r807a632 r3b56166  
     1struct S { int i; };
     2void ?{}( S & s, int i ) { s.i = i; }
     3int ?`mary( int );
     4int ?`mary( S );
     5[int] ?`mary( [int, int] );
     6int & ?`jane( int & );
     7int jack( int );
     8
    19int main() {
    2     struct s { int i; } x, *p = &x;
    3     int i = 3;
     10    int a[3] = { 0, 0, 0 };
     11    S s = { 3 }, * ps = &s;
     12    [int] t = { 3 };
     13    * [int] pt = &t;
     14    int i = 1, j = 2;
    415
    516    // operators
    617
    7     ! i;
     18    !i;
    819    ~i;
    920    +i;
    1021    -i;
    11     *p;
    12     ++p;
    13     --p;
    14     p++;
    15     p--;
     22    *ps;
     23    ++ps;
     24    --ps;
     25    ps++;
     26    ps--;
    1627
    17     i+i;
    18     i-i;
    19     i*i;
     28    i + j;
     29    i - j;
     30    i * j;
    2031
    21     i/i;
    22     i%i;
    23     i^i;
    24     i&i;
    25     i|i;
    26     i<i;
    27     i>i;
    28     i=i;
     32    i / j;
     33    i % j;
     34    i ^ j;
     35    i & j;
     36    i | j;
     37    i < j;
     38    i > j;
     39    i = j;
    2940
    30     i==i;
    31     i!=i;
    32     i<<i;
    33     i>>i;
    34     i<=i;
    35     i>=i;
    36     i&&i;
    37     i||i;
    38     p->i;
    39     i*=i;
    40     i/=i;
    41     i%=i;
    42     i+=i;
    43     i-=i;
    44     i&=i;
    45     i|=i;
    46     i^=i;
    47     i<<=i;
    48     i>>=i;
     41    i == j;
     42    i != j;
     43    i << j;
     44    i >> j;
     45    i <= j;
     46    i >= j;
     47    i && j;
     48    i || j;
     49    ps->i;
    4950
    50     i?i:i;
     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;
     61
     62    i ? i : j;
     63
     64    // postfix function call
     65
     66    (3 + 4)`mary;
     67    ({3 + 4;})`mary;
     68    [3, 4]`mary;
     69    3`mary;
     70    a[0]`mary;
     71    a[0]`mary`mary;
     72    s{0}`mary;
     73    a[3]`jane++;
     74    jack(3)`mary;
     75    s.i`mary;
     76    t.0`mary;
     77    s.[i]`mary;
     78    ps->i`mary;
     79    pt->0`mary;
     80    ps->[i]`mary;
     81    i++`mary;
     82    i--`mary;
     83    (S){2}`mary;
     84    (S)@{2}`mary;
    5185} // main
  • tests/heap.cfa

    r807a632 r3b56166  
    1010// Created On       : Tue Nov  6 17:54:56 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 19 08:22:34 2019
    13 // Update Count     : 19
     12// Last Modified On : Sun Nov 24 12:34:51 2019
     13// Update Count     : 28
    1414//
    1515
     
    3838        enum { NoOfAllocs = 5000, NoOfMmaps = 10 };
    3939        char * locns[NoOfAllocs];
    40         int i;
     40        size_t amount;
     41        enum { limit = 64 * 1024 };                                                     // check alignments up to here
    4142
    4243        // check alloc/free
     
    7475                size_t s = (i + 1) * 20;
    7576                char * area = (char *)malloc( s );
    76                 if ( area == 0 ) abort( "malloc/free out of memory" );
     77                if ( area == 0p ) abort( "malloc/free out of memory" );
    7778                area[0] = '\345'; area[s - 1] = '\345';                 // fill first/last
    7879                area[malloc_usable_size( area ) - 1] = '\345';  // fill ultimate byte
     
    8384                size_t s = i + 1;                                                               // +1 to make initialization simpler
    8485                locns[i] = (char *)malloc( s );
    85                 if ( locns[i] == 0 ) abort( "malloc/free out of memory" );
     86                if ( locns[i] == 0p ) abort( "malloc/free out of memory" );
    8687                locns[i][0] = '\345'; locns[i][s - 1] = '\345'; // fill first/last
    8788                locns[i][malloc_usable_size( locns[i] ) - 1] = '\345'; // fill ultimate byte
     
    99100                size_t s = i + default_mmap_start();                    // cross over point
    100101                char * area = (char *)malloc( s );
    101                 if ( area == 0 ) abort( "malloc/free out of memory" );
     102                if ( area == 0p ) abort( "malloc/free out of memory" );
    102103                area[0] = '\345'; area[s - 1] = '\345';                 // fill first/last
    103104                area[malloc_usable_size( area ) - 1] = '\345';  // fill ultimate byte
     
    108109                size_t s = i + default_mmap_start();                    // cross over point
    109110                locns[i] = (char *)malloc( s );
    110                 if ( locns[i] == 0 ) abort( "malloc/free out of memory" );
     111                if ( locns[i] == 0p ) abort( "malloc/free out of memory" );
    111112                locns[i][0] = '\345'; locns[i][s - 1] = '\345'; // fill first/last
    112113                locns[i][malloc_usable_size( locns[i] ) - 1] = '\345'; // fill ultimate byte
     
    124125                size_t s = (i + 1) * 20;
    125126                char * area = (char *)calloc( 5, s );
    126                 if ( area == 0 ) abort( "calloc/free out of memory" );
     127                if ( area == 0p ) abort( "calloc/free out of memory" );
    127128                if ( area[0] != '\0' || area[s - 1] != '\0' ||
    128129                         area[malloc_usable_size( area ) - 1] != '\0' ||
     
    136137                size_t s = i + 1;
    137138                locns[i] = (char *)calloc( 5, s );
    138                 if ( locns[i] == 0 ) abort( "calloc/free out of memory" );
     139                if ( locns[i] == 0p ) abort( "calloc/free out of memory" );
    139140                if ( locns[i][0] != '\0' || locns[i][s - 1] != '\0' ||
    140141                         locns[i][malloc_usable_size( locns[i] ) - 1] != '\0' ||
     
    155156                size_t s = i + default_mmap_start();                    // cross over point
    156157                char * area = (char *)calloc( 1, s );
    157                 if ( area == 0 ) abort( "calloc/free out of memory" );
     158                if ( area == 0p ) abort( "calloc/free out of memory" );
    158159                if ( area[0] != '\0' || area[s - 1] != '\0' ) abort( "calloc/free corrupt storage4.1" );
    159160                if ( area[malloc_usable_size( area ) - 1] != '\0' ) abort( "calloc/free corrupt storage4.2" );
     
    167168                size_t s = i + default_mmap_start();                    // cross over point
    168169                locns[i] = (char *)calloc( 1, s );
    169                 if ( locns[i] == 0 ) abort( "calloc/free out of memory" );
     170                if ( locns[i] == 0p ) abort( "calloc/free out of memory" );
    170171                if ( locns[i][0] != '\0' || locns[i][s - 1] != '\0' ||
    171172                         locns[i][malloc_usable_size( locns[i] ) - 1] != '\0' ||
     
    183184        // check memalign/free (sbrk)
    184185
    185         enum { limit = 64 * 1024 };                                                     // check alignments up to here
    186 
    187186        for ( a; libAlign() ~= limit ~ a ) {                            // generate powers of 2
    188187                //sout | alignments[a];
    189188                for ( s; 1 ~ NoOfAllocs ) {                                             // allocation of size 0 can return null
    190189                        char * area = (char *)memalign( a, s );
    191                         if ( area == 0 ) abort( "memalign/free out of memory" );
    192                         //sout | i | " " | area;
     190                        if ( area == 0p ) abort( "memalign/free out of memory" );
     191                        //sout | i | area;
    193192                        if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment
    194193                                abort( "memalign/free bad alignment : memalign(%d,%d) = %p", (int)a, s, area );
    195194                        } // if
    196                         area[0] = '\345'; area[s - 1] = '\345'; // fill first/last byte
     195                        area[0] = '\345'; area[s - 1] = '\345';         // fill first/last byte
    197196                        area[malloc_usable_size( area ) - 1] = '\345'; // fill ultimate byte
    198197                        free( area );
     
    207206                        size_t s = i + default_mmap_start();            // cross over point
    208207                        char * area = (char *)memalign( a, s );
    209                         if ( area == 0 ) abort( "memalign/free out of memory" );
    210                         //sout | i | " " | area;
     208                        if ( area == 0p ) abort( "memalign/free out of memory" );
     209                        //sout | i | area;
    211210                        if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment
    212211                                abort( "memalign/free bad alignment : memalign(%d,%d) = %p", (int)a, (int)s, area );
     
    223222                // initial N byte allocation
    224223                char * area = (char *)calloc( 5, i );
    225                 if ( area == 0 ) abort( "calloc/realloc/free out of memory" );
     224                if ( area == 0p ) abort( "calloc/realloc/free out of memory" );
    226225                if ( area[0] != '\0' || area[i - 1] != '\0' ||
    227226                         area[malloc_usable_size( area ) - 1] != '\0' ||
     
    231230                for ( s; i ~ 256 * 1024 ~ 26 ) {                                // start at initial memory request
    232231                        area = (char *)realloc( area, s );                      // attempt to reuse storage
    233                         if ( area == 0 ) abort( "calloc/realloc/free out of memory" );
     232                        if ( area == 0p ) abort( "calloc/realloc/free out of memory" );
    234233                        if ( area[0] != '\0' || area[s - 1] != '\0' ||
    235234                                 area[malloc_usable_size( area ) - 1] != '\0' ||
     
    245244                size_t s = i + default_mmap_start();                    // cross over point
    246245                char * area = (char *)calloc( 1, s );
    247                 if ( area == 0 ) abort( "calloc/realloc/free out of memory" );
     246                if ( area == 0p ) abort( "calloc/realloc/free out of memory" );
    248247                if ( area[0] != '\0' || area[s - 1] != '\0' ||
    249248                         area[malloc_usable_size( area ) - 1] != '\0' ||
     
    253252                for ( r; i ~ 256 * 1024 ~ 26 ) {                                // start at initial memory request
    254253                        area = (char *)realloc( area, r );                      // attempt to reuse storage
    255                         if ( area == 0 ) abort( "calloc/realloc/free out of memory" );
     254                        if ( area == 0p ) abort( "calloc/realloc/free out of memory" );
    256255                        if ( area[0] != '\0' || area[r - 1] != '\0' ||
    257256                                 area[malloc_usable_size( area ) - 1] != '\0' ||
     
    263262        // check memalign/realloc/free
    264263
    265         size_t amount = 2;
     264        amount = 2;
    266265        for ( a; libAlign() ~= limit ~ a ) {                            // generate powers of 2
    267266                // initial N byte allocation
    268267                char * area = (char *)memalign( a, amount );    // aligned N-byte allocation
    269                 if ( area == 0 ) abort( "memalign/realloc/free out of memory" ); // no storage ?
    270                 //sout | alignments[a] | " " | area;
     268                if ( area == 0p ) abort( "memalign/realloc/free out of memory" ); // no storage ?
     269                //sout | alignments[a] | area;
    271270                if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment
    272271                        abort( "memalign/realloc/free bad alignment : memalign(%d,%d) = %p", (int)a, (int)amount, area );
     
    278277                        if ( area[0] != '\345' || area[s - 2] != '\345' ) abort( "memalign/realloc/free corrupt storage" );
    279278                        area = (char *)realloc( area, s );                      // attempt to reuse storage
    280                         if ( area == 0 ) abort( "memalign/realloc/free out of memory" ); // no storage ?
    281                         //sout | i | " " | area;
     279                        if ( area == 0p ) abort( "memalign/realloc/free out of memory" ); // no storage ?
     280                        //sout | i | area;
    282281                        if ( (size_t)area % a != 0 ) {                          // check for initial alignment
    283282                                abort( "memalign/realloc/free bad alignment %p", area );
     
    294293                for ( s; 1 ~ limit ) {                                                  // allocation of size 0 can return null
    295294                        char * area = (char *)cmemalign( a, 1, s );
    296                         if ( area == 0 ) abort( "cmemalign/free out of memory" );
    297                         //sout | i | " " | area;
     295                        if ( area == 0p ) abort( "cmemalign/free out of memory" );
     296                        //sout | i | area;
    298297                        if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment
    299298                                abort( "cmemalign/free bad alignment : cmemalign(%d,%d) = %p", (int)a, s, area );
     
    313312                // initial N byte allocation
    314313                char * area = (char *)cmemalign( a, 1, amount ); // aligned N-byte allocation
    315                 if ( area == 0 ) abort( "cmemalign/realloc/free out of memory" ); // no storage ?
    316                 //sout | alignments[a] | " " | area;
     314                if ( area == 0p ) abort( "cmemalign/realloc/free out of memory" ); // no storage ?
     315                //sout | alignments[a] | area;
    317316                if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment
    318317                        abort( "cmemalign/realloc/free bad alignment : cmemalign(%d,%d) = %p", (int)a, (int)amount, area );
     
    327326                        if ( area[0] != '\345' || area[s - 2] != '\345' ) abort( "cmemalign/realloc/free corrupt storage2" );
    328327                        area = (char *)realloc( area, s );                      // attempt to reuse storage
    329                         if ( area == 0 ) abort( "cmemalign/realloc/free out of memory" ); // no storage ?
    330                         //sout | i | " " | area;
     328                        if ( area == 0p ) abort( "cmemalign/realloc/free out of memory" ); // no storage ?
     329                        //sout | i | area;
    331330                        if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment
    332331                                abort( "cmemalign/realloc/free bad alignment %p", area );
     
    339338                free( area );
    340339        } // for
     340
     341        // check memalign/realloc with align/free
     342
     343        amount = 2;
     344        for ( a; libAlign() ~= limit ~ a ) {                            // generate powers of 2
     345                // initial N byte allocation
     346                char * area = (char *)memalign( a, amount );    // aligned N-byte allocation
     347                if ( area == 0p ) abort( "memalign/realloc with align/free out of memory" ); // no storage ?
     348                //sout | alignments[a] | area | endl;
     349                if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment
     350                        abort( "memalign/realloc with align/free bad alignment : memalign(%d,%d) = %p", (int)a, (int)amount, area );
     351                } // if
     352                area[0] = '\345'; area[amount - 2] = '\345';    // fill first/penultimate byte
     353
     354                // Do not start this loop index at 0 because realloc of 0 bytes frees the storage.
     355                for ( s; amount ~ 256 * 1024 ) {                                // start at initial memory request
     356                        if ( area[0] != '\345' || area[s - 2] != '\345' ) abort( "memalign/realloc/free corrupt storage" );
     357                        area = (char *)realloc( area, a * 2, s );       // attempt to reuse storage
     358                        if ( area == 0p ) abort( "memalign/realloc with align/free out of memory" ); // no storage ?
     359                        //sout | i | area | endl;
     360                        if ( (size_t)area % a * 2 != 0 ) {                      // check for initial alignment
     361                                abort( "memalign/realloc with align/free bad alignment %p", area );
     362                        } // if
     363                        area[s - 1] = '\345';                                           // fill last byte
     364                } // for
     365                free( area );
     366        } // for
     367
     368        // check cmemalign/realloc with align/free
     369
     370        amount = 2;
     371        for ( size_t a = libAlign() + libAlign(); a <= limit; a += a ) { // generate powers of 2
     372                // initial N byte allocation
     373                char *area = (char *)cmemalign( a, 1, amount ); // aligned N-byte allocation
     374                if ( area == 0p ) abort( "cmemalign/realloc with align/free out of memory" ); // no storage ?
     375                //sout | alignments[a] | area | endl;
     376                if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment
     377                        abort( "cmemalign/realloc with align/free bad alignment : cmemalign(%d,%d) = %p", (int)a, (int)amount, area );
     378                } // if
     379                if ( area[0] != '\0' || area[amount - 1] != '\0' ||
     380                         area[malloc_usable_size( area ) - 1] != '\0' ||
     381                         ! malloc_zero_fill( area ) ) abort( "cmemalign/realloc with align/free corrupt storage1" );
     382                area[0] = '\345'; area[amount - 2] = '\345';    // fill first/penultimate byte
     383
     384                // Do not start this loop index at 0 because realloc of 0 bytes frees the storage.
     385                for ( int s = amount; s < 256 * 1024; s += 1 ) { // start at initial memory request
     386                        if ( area[0] != '\345' || area[s - 2] != '\345' ) abort( "cmemalign/realloc with align/free corrupt storage2" );
     387                        area = (char *)realloc( area, a * 2, s );       // attempt to reuse storage
     388                        if ( area == 0p ) abort( "cmemalign/realloc with align/free out of memory" ); // no storage ?
     389                        //sout | i | area | endl;
     390                        if ( (size_t)area % a * 2 != 0 || malloc_alignment( area ) != a * 2 ) { // check for initial alignment
     391                                abort( "cmemalign/realloc with align/free bad alignment %p %jd %jd", area, malloc_alignment( area ), a * 2 );
     392                        } // if
     393                        if ( area[s - 1] != '\0' || area[s - 1] != '\0' ||
     394                                 area[malloc_usable_size( area ) - 1] != '\0' ||
     395                                 ! malloc_zero_fill( area ) ) abort( "cmemalign/realloc/free corrupt storage3" );
     396                        area[s - 1] = '\345';                                           // fill last byte
     397                } // for
     398                free( area );
     399        } // for
     400
    341401        //sout | "worker" | thisTask() | "successful completion";
    342402} // Worker main
  • tests/labelledExit.cfa

    r807a632 r3b56166  
    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/linking/withthreads.cfa

    r807a632 r3b56166  
    3434// Local Variables: //
    3535// tab-width: 4 //
    36 // compile-command: "cfa nothreads.cfa" //
     36// compile-command: "cfa withthreads.cfa" //
    3737// End: //
  • tests/loopctrl.cfa

    r807a632 r3b56166  
    1010// Created On       : Wed Aug  8 18:32:59 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 12 12:05:05 2019
    13 // Update Count     : 106
     12// Last Modified On : Thu Dec 12 17:55:26 2019
     13// Update Count     : 108
    1414//
    1515
     
    4343        for ( 1 ) { sout | "A"; }                                                       sout | nl;
    4444        for ( 10 ) { sout | "A"; }                                                      sout | nl;
     45        for ( = 10 ) { sout | "A"; }                                            sout | nl;
    4546        for ( 1 ~= 10 ~ 2 ) { sout | "B"; }                                     sout | nl;
    4647        for ( 10 -~= 1 ~ 2 ) { sout | "C"; }                            sout | nl;
     
    4950
    5051        for ( i; 10 ) { sout | i; }                                                     sout | nl;
     52        for ( i; = 10 ) { sout | i; }                                           sout | nl;
    5153        for ( i; 1 ~= 10 ~ 2 ) { sout | i; }                            sout | nl;
    5254        for ( i; 10 -~= 1 ~ 2 ) { sout | i; }                           sout | nl;
     
    8789        for ( N ) { sout | "N"; }                                                       sout | nl;
    8890        for ( i; N ) { sout | i; }                                                      sout | nl;
     91        for ( i; = N ) { sout | i; }                                            sout | nl;
    8992        for ( i; N -~ 0 ) { sout | i; }                                         sout | nl | nl;
    9093
  • tests/pybin/tools.py

    r807a632 r3b56166  
    175175
    176176def which(program):
    177     fpath, fname = os.path.split(program)
    178     if fpath:
    179         if is_exe(program):
    180             return program
    181     else:
    182         for path in os.environ["PATH"].split(os.pathsep):
    183             exe_file = os.path.join(path, program)
    184             if is_exe(exe_file):
    185                 return exe_file
    186 
    187     return None
     177        fpath, fname = os.path.split(program)
     178        if fpath:
     179                if is_exe(program):
     180                        return program
     181        else:
     182                for path in os.environ["PATH"].split(os.pathsep):
     183                        exe_file = os.path.join(path, program)
     184                        if is_exe(exe_file):
     185                                return exe_file
     186        return None
    188187
    189188@contextlib.contextmanager
     
    365364
    366365class Timed:
    367     def __enter__(self):
    368         self.start = time.time()
    369         return self
    370 
    371     def __exit__(self, *args):
    372         self.end = time.time()
    373         self.duration = self.end - self.start
     366        def __enter__(self):
     367                self.start = time.time()
     368                return self
     369
     370        def __exit__(self, *args):
     371                self.end = time.time()
     372                self.duration = self.end - self.start
    374373
    375374def timed(src, timeout):
    376375        expire = time.time() + timeout
    377376        i = iter(src)
    378         while True:
    379                 yield i.next(max(expire - time.time(), 0))
     377        with contextlib.suppress(StopIteration):
     378                while True:
     379                        yield i.next(max(expire - time.time(), 0))
  • tests/quotedKeyword.cfa

    r807a632 r3b56166  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec  4 21:45:53 2018
    13 // Update Count     : 23
     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
  • tests/raii/dtor-early-exit.cfa

    r807a632 r3b56166  
    217217}
    218218
     219void i() {
     220        // potential loop
     221        for() {
     222                if(true) continue;
     223                int t = 0;
     224        }
     225}
     226
    219227// TODO: implement __label__ and uncomment these lines
    220228void computedGoto() {
  • tests/rational.cfa

    r807a632 r3b56166  
    1010// Created On       : Mon Mar 28 08:43:12 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar 27 07:37:17 2019
    13 // Update Count     : 80
     12// Last Modified On : Sat Feb  8 18:46:23 2020
     13// Update Count     : 86
    1414//
    1515
     
    1919#include <fstream.hfa>
    2020
    21 double convert( int i ) { return (double)i; }
     21typedef Rational(int) RatInt;
     22double convert( int i ) { return (double)i; }                   // used by narrow/widen
    2223int convert( double d ) { return (int)d; }
    2324
    2425int main() {
    2526        sout | "constructor";
    26         Rational(int) a = { 3 }, b = { 4 }, c;
    27         sout | a | b | c;
     27        RatInt a = { 3 }, b = { 4 }, c, d = 0, e = 1;
     28        sout | a | b | c | d | e;
    2829
    29         a = (Rational(int)){ 4, 8 };
    30         b = (Rational(int)){ 5, 7 };
     30        a = (RatInt){ 4, 8 };
     31        b = (RatInt){ 5, 7 };
    3132        sout | a | b;
    32         a = (Rational(int)){ -2, -3 };
    33         b = (Rational(int)){ 3, -2 };
     33        a = (RatInt){ -2, -3 };
     34        b = (RatInt){ 3, -2 };
    3435        sout | a | b;
    35         a = (Rational(int)){ -2, 3 };
    36         b = (Rational(int)){ 3, 2 };
     36        a = (RatInt){ -2, 3 };
     37        b = (RatInt){ 3, 2 };
    3738        sout | a | b;
    3839
    3940        sout | "logical";
    40         a = (Rational(int)){ -2 };
    41         b = (Rational(int)){ -3, 2 };
     41        a = (RatInt){ -2 };
     42        b = (RatInt){ -3, 2 };
    4243        sout | a | b;
    4344//      sout | a == 1; // FIX ME
     
    5859
    5960        sout | "conversion";
    60         a = (Rational(int)){ 3, 4 };
     61        a = (RatInt){ 3, 4 };
    6162        sout | widen( a );
    62         a = (Rational(int)){ 1, 7 };
     63        a = (RatInt){ 1, 7 };
    6364        sout | widen( a );
    64         a = (Rational(int)){ 355, 113 };
     65        a = (RatInt){ 355, 113 };
    6566        sout | widen( a );
    6667        sout | narrow( 0.75, 4 );
     
    7475
    7576        sout | "more tests";
    76         Rational(int) x = { 1, 2 }, y = { 2 };
     77        RatInt x = { 1, 2 }, y = { 2 };
    7778        sout | x - y;
    7879        sout | x > y;
     
    8081        sout | y | denominator( y, -2 ) | y;
    8182
    82         Rational(int) z = { 0, 5 };
     83        RatInt z = { 0, 5 };
    8384        sout | z;
    8485
    8586        sout | x | numerator( x, 0 ) | x;
    8687
    87         x = (Rational(int)){ 1, MAX } + (Rational(int)){ 1, MAX };
     88        x = (RatInt){ 1, MAX } + (RatInt){ 1, MAX };
    8889        sout | x;
    89         x = (Rational(int)){ 3, MAX } + (Rational(int)){ 2, MAX };
     90        x = (RatInt){ 3, MAX } + (RatInt){ 2, MAX };
    9091        sout | x;
    9192
  • tests/references.cfa

    r807a632 r3b56166  
    119119                f( 3, a + b, (S){ 1.0, 7.0 }, (int [3]){ 1, 2, 3 } ); // two rvalue to reference
    120120        }
     121
     122        {
     123                int a = 3;
     124                int *p = &a;
     125                asm (
     126                        "incl %[p]\n\t"
     127                        : [p] "+m" (*p)
     128                );
     129                printf("%d\n", a);
     130        }
    121131}
    122132
  • tests/test.py

    r807a632 r3b56166  
    1010import tempfile
    1111import time
     12
     13import os
     14import psutil
     15import signal
    1216
    1317################################################################################
     
    221225        make('clean', output_file=subprocess.DEVNULL, error=subprocess.DEVNULL)
    222226
     227        # since python prints stacks by default on a interrupt, redo the interrupt handling to be silent
     228        def worker_init():
     229                def sig_int(signal_num, frame):
     230                        pass
     231
     232                signal.signal(signal.SIGINT, sig_int)
     233
    223234        # create the executor for our jobs and handle the signal properly
    224         pool = multiprocessing.Pool(jobs)
     235        pool = multiprocessing.Pool(jobs, worker_init)
    225236
    226237        failed = False
     238
     239        def stop(x, y):
     240                print("Tests interrupted by user", file=sys.stderr)
     241                sys.exit(1)
     242        signal.signal(signal.SIGINT, stop)
    227243
    228244        # for each test to run
  • tests/time.cfa

    r807a632 r3b56166  
    1010// Created On       : Tue Mar 27 17:24:56 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Dec 20 23:09:21 2018
    13 // Update Count     : 23
     12// Last Modified On : Sun Jan  5 18:27:37 2020
     13// Update Count     : 34
    1414//
    1515
     
    2020        Duration d1 = 3`h, d2 = 2`s, d3 = 3.375`s, d4 = 12`s, d5 = 1`s + 10_000`ns;
    2121        sout | d1 | d2 | d3 | d4 | d5;
    22         int i;
    2322        d1 = 0;
    2423        sout | d1 | d2 | d3;
     
    3534        sout | t;
    3635        t = t + d1;
    37         sout | t | t.tv;
     36        sout | t | t`ns;
    3837        Time t1 = (timespec){ 104_414, 10_000_000 };
    39         sout | t1 | t1.tv;
    40         sout | t - t  | t + d5 | t.tv;
    41         char buf[16];
     38        sout | t1 | t1`ns;
     39        sout | t - t  | t + d5 | t`ns;
     40        char buf[64];
    4241        sout | "yy/mm/dd" | [t, buf]`ymd | nonl;                        // shared buf => separate calls
    4342        sout | "mm/dd/yy" | mm_dd_yy( t, buf ) | nonl;
     
    4645        sout | "dd/yy/mm" | [t, buf]`dmy;
    4746        Time t2 = { 2001, 7, 4, 0, 0, 1, 0 }, t3 = (timeval){ 994_219_201 };
    48         sout | t2 | t2.tv | nl | t3 | t3.tv;
     47        sout | t2 | t2`ns | nl | t3 | t3`ns;
    4948        sout | nl;
    5049
     
    6362        sout | "Dividing that by 2 gives" | s / 2 | "seconds";
    6463        sout | s | "seconds is" | s`h | "hours," | (s % 1`h)`m | "minutes," | (s % 1`m)`s | "seconds";
     64
     65    t1 = (Time){ 2020, 1, 5, 9, 0, 0, 100000000000LL };
     66    t2 = (Time){ 1969, 13, 5, 9 };
     67    t3 = (Time){ 1970, 25, 366, 48, 120, -120, 60000000000LL };
     68    strftime( buf, 128, "%Y %b %e %H:%M:%S (GMT)", t1 );
     69    sout | buf;
     70    strftime( buf, 128, "%Y %b %e %H:%M:%S (GMT)", t2 );
     71    sout | buf;
     72    strftime( buf, 128, "%Y %b %e %H:%M:%S (GMT)", t3 );
     73    sout | buf;
    6574} // main
    6675
  • tools/catchsig.c

    r807a632 r3b56166  
    2121        printf("Starting...\n");
    2222        sig(SIGHUP);
    23       sig(SIGINT);
    24       sig(SIGQUIT);
    25       sig(SIGILL);
    26       sig(SIGABRT);
    27       sig(SIGFPE);
    28       sig(SIGSEGV);
    29       sig(SIGPIPE);
    30       sig(SIGALRM);
    31       sig(SIGTERM);
    32       sig(SIGUSR1);
    33       sig(SIGUSR2);
    34       sig(SIGCHLD);
    35       sig(SIGCONT);
    36       sig(SIGTSTP);
    37       sig(SIGTTIN);
    38       sig(SIGTTOU);
     23        sig(SIGINT);
     24        sig(SIGQUIT);
     25        sig(SIGILL);
     26        sig(SIGABRT);
     27        sig(SIGFPE);
     28        sig(SIGSEGV);
     29        sig(SIGPIPE);
     30        sig(SIGALRM);
     31        sig(SIGTERM);
     32        sig(SIGUSR1);
     33        sig(SIGUSR2);
     34        sig(SIGCHLD);
     35        sig(SIGCONT);
     36        sig(SIGTSTP);
     37        sig(SIGTTIN);
     38        sig(SIGTTOU);
    3939        while(1);
    4040        return 0;
  • tools/stat.py

    r807a632 r3b56166  
    1717                avg = numpy.mean  (content)
    1818                std = numpy.std   (content)
    19                 print "median {0:.1f} avg {1:.1f} stddev {2:.2f}".format( med, avg, std )
     19                print "median {0:.1f} avg {1:.1f} stddev {2:.1f}".format( med, avg, std )
    2020
    2121
Note: See TracChangeset for help on using the changeset viewer.