Changes in / [bdfc032:aefb247]


Ignore:
Files:
10 added
32 deleted
95 edited

Legend:

Unmodified
Added
Removed
  • benchmark/Makefile.am

    rbdfc032 raefb247  
    1111## Created On       : Sun May 31 09:08:15 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Sat Jan 25 09:20:44 2020
    14 ## Update Count     : 255
     13## Last Modified On : Mon Jul 29 18:02:19 2019
     14## Update Count     : 54
    1515###############################################################################
    1616
     
    2828BENCH_V_CFA = $(__bench_v_CFA_$(__quiet))
    2929BENCH_V_CXX = $(__bench_v_CXX_$(__quiet))
     30BENCH_V_GOC = $(__bench_v_GOC_$(__quiet))
     31BENCH_V_JAVAC = $(__bench_v_JAVAC_$(__quiet))
    3032BENCH_V_UPP = $(__bench_v_UPP_$(__quiet))
    31 BENCH_V_GOC = $(__bench_v_GOC_$(__quiet))
    32 BENCH_V_RUSTC = $(__bench_v_RUSTC_$(__quiet))
    33 BENCH_V_NODEJS = $(__bench_v_NODEJS_$(__quiet))
    34 BENCH_V_JAVAC = $(__bench_v_JAVAC_$(__quiet))
    3533
    3634__quiet = verbose
     
    3836__bench_v_CFA_quiet = @
    3937__bench_v_CXX_quiet = @
     38__bench_v_GOC_quiet = @
     39__bench_v_JAVAC_quiet = @
    4040__bench_v_UPP_quiet = @
    41 __bench_v_GOC_quiet = @
    42 __bench_v_RUSTC_quiet = @
    43 __bench_v_JAVAC_quiet = @
    4441__bench_v_CC_verbose = $(AM_V_CC)
    4542__bench_v_CFA_verbose = $(AM_V_CFA)
    4643__bench_v_CXX_verbose = $(AM_V_CXX)
     44__bench_v_GOC_verbose = $(AM_V_GOC)
     45__bench_v_JAVAC_verbose = $(AM_V_JAVAC)
    4746__bench_v_UPP_verbose = $(AM_V_UPP)
    48 __bench_v_GOC_verbose = $(AM_V_GOC)
    49 __bench_v_RUSTC_verbose = $(AM_V_RUSTC)
    50 __bench_v_NODEJS_verbose = $(AM_V_NODEJS)
    51 __bench_v_JAVAC_verbose = $(AM_V_JAVAC)
    5247
    5348
     
    5651STATS    = ${abs_top_srcdir}/tools/stat.py
    5752# NEED AT LEAST 4 DATA VALUES FOR BENCHMARKS BECAUSE THE MAX AND MIN VALUES ARE REMOVED
    58 repeats  = 13 # 31 for benchmarks
     53repeats  = 5 # 31 for benchmarks
    5954arch     = x64
    6055skipcompile = no
     
    6762
    6863dummyC.c:
    69         echo "int main() { return 0; }" > ${@}
     64        @echo "int main() { return 0; }" > ${@}
    7065
    7166dummyCXX.cpp:
    72         echo "int main() { return 0; }" > ${@}
    73 
    74 #.SILENT:               # do not print recipe
    75 .ONESHELL:              # use one shell to execute recipe
     67        @echo "int main() { return 0; }" > ${@}
     68
    7669.NOTPARALLEL:
    77 .PHONY: compile.csv basic.csv ctxswitch.csv mutex.csv schedint.csv
    78 
    79 ## =========================================================================================================
    80 
    81 all : basic$(EXEEXT) ctxswitch$(EXEEXT) mutex$(EXEEXT) schedint$(EXEEXT) schedext$(EXEEXT) creation$(EXEEXT)
    82 
    83 basic_loop_DURATION = 15000000000
    84 basic_function_DURATION = 10000000000
    85 basic_tls_fetch_add_DURATION = 10000000000
    86 basic_DURATION = 250000000
    87 
    88 ctxswitch_pthread_DURATION = 25000000
    89 ctxswitch_rust_thread_DURATION = $(ctxswitch_pthread_DURATION)
    90 ctxswitch_cfa_generator_DURATION = 5000000000
    91 ctxswitch_nodejs_await_DURATION = 5000000
    92 ctxswitch_DURATION = 100000000
    93 
    94 #mutex_java_DURATION = 10000000
    95 mutex_DURATION = 50000000
    96 
    97 schedint_pthread_DURATION = 1000000
    98 schedint_java_DURATION = $(schedint_pthread_DURATION)
    99 schedint_rust_DURATION = $(schedint_pthread_DURATION)
    100 schedint_DURATION = 10000000
    101 
    102 schedext_DURATION = 10000000
    103 
    104 creation_pthread_DURATION = 250000
    105 creation_rust_thread_DURATION = ${creation_pthread_DURATION}
    106 creation_java_thread_DURATION = ${creation_pthread_DURATION}
    107 creation_cfa_coroutine_DURATION = 100000000
    108 creation_cfa_coroutine_eager_DURATION = 10000000
    109 creation_upp_coroutine_DURATION = ${creation_cfa_coroutine_eager_DURATION}
    110 creation_cfa_thread_DURATION = 10000000
    111 creation_upp_thread_DURATION = ${creation_cfa_thread_DURATION}
    112 creation_DURATION = 10000000
     70.PHONY: compile.csv ctxswitch.csv mutex.csv signal.csv
     71
     72## =========================================================================================================
     73all : ctxswitch$(EXEEXT) mutex$(EXEEXT) signal$(EXEEXT) waitfor$(EXEEXT) creation$(EXEEXT)
    11374
    11475%.run : %$(EXEEXT) ${REPEAT}
    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
     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
    12783
    12884%.runquiet :
    129         +make $(basename $@) CFLAGS="-w" __quiet=quiet
    130         taskset -c 1 ./a.out
    131         rm -f a.out
     85        @+make $(basename $@) CFLAGS="-w" __quiet=quiet
     86        @taskset -c 1 ./a.out
     87        @rm -f a.out
    13288
    13389%.make :
    134         printf "${PRINT_FORMAT}" $(basename $(subst compile-,,$@))
    135         +/usr/bin/time -f ${TIME_FORMAT} make $(basename $@) 2>&1
     90        @printf "${PRINT_FORMAT}" $(basename $(subst compile-,,$@))
     91        @+/usr/bin/time -f ${TIME_FORMAT} make $(basename $@) 2>&1
    13692
    13793${REPEAT} :
    138         +make -C ${abs_top_builddir}/tools repeat
     94        @+make -C ${abs_top_builddir}/tools repeat
    13995
    14096## =========================================================================================================
     
    144100jenkins$(EXEEXT):
    145101@DOifskipcompile@
    146         +make compile.csv
    147         -+make compile.diff.csv
     102        @+make compile.csv
     103        @-+make compile.diff.csv
    148104@DOendif@
    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
     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
    157111@DOifskipcompile@
    158112        cat compile.csv
    159113        -cat compile.diff.csv
    160114@DOendif@
    161         cat basic.csv
    162         -cat basic.diff.csv
    163115        cat ctxswitch.csv
    164116        -cat ctxswitch.diff.csv
    165117        cat mutex.csv
    166118        -cat mutex.diff.csv
    167         cat schedint.csv
    168         -cat schedint.diff.csv
     119        cat signal.csv
     120        -cat signal.diff.csv
    169121
    170122compile.csv:
    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 
    182 basic.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 $@
     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 $@
    188133
    189134ctxswitch.csv:
    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 $@
     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 $@
    195140
    196141mutex.csv:
    197         echo "1-monitor,2-monitor" > $@
    198         +make mutex-cfa1.runquiet >> $@ && echo -n ',' >> $@
    199         +make mutex-cfa2.runquiet >> $@
    200         $(srcdir)/fixcsv.sh $@
    201 
    202 schedint.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 $@
     142        @echo "1-monitor,2-monitor" > $@
     143        @+make mutex-cfa1.runquiet >> $@ && echo -n ',' >> $@
     144        @+make mutex-cfa2.runquiet >> $@
     145        @$(srcdir)/fixcsv.sh $@
     146
     147signal.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 $@
    209154
    210155%.diff.csv: %.csv
    211         test -e $(srcdir)/baselines/$(arch)/$< || (echo "Error : Missing baseline for ${<}" && false)
    212         $(srcdir)/baselines/calc.py $(srcdir)/baselines/$(arch)/$(<) $(<) > $@
    213 
    214 ## =========================================================================================================
    215 
    216 BASIC_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 
    223 basic-loop$(EXEEXT):
    224         $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/loop.c
    225 
    226 basic-function$(EXEEXT):
    227         $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/function.c
    228 
    229 basic-fetch_add$(EXEEXT):
    230         $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/fetch_add.c
    231 
    232 basic-ttst_lock$(EXEEXT):
    233         $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/ttst_lock.c
    234 
    235 basic-tls-fetch_add$(EXEEXT):
    236         $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/tls_fetch_add.c
    237 
    238 basic$(EXEEXT): $(BASIC_DEPEND)
    239 
    240 ## =========================================================================================================
    241 
    242 CTXSWITCH_DEPEND  =                     \
     156        @test -e $(srcdir)/baselines/$(arch)/$< || (echo "Error : Missing baseline for ${<}" && false)
     157        @$(srcdir)/baselines/calc.py $(srcdir)/baselines/$(arch)/$(<) $(<) > $@
     158
     159
     160## =========================================================================================================
     161loop$(EXEEXT):
     162        $(BENCH_V_CC)$(COMPILE) -DBENCH_N=5000000000 $(srcdir)/loop.c
     163
     164function$(EXEEXT):
     165        $(BENCH_V_CC)$(COMPILE) -DBENCH_N=5000000000 $(srcdir)/function.c
     166
     167fetch_add$(EXEEXT):
     168        $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000  $(srcdir)/fetch_add.c
     169
     170ttst_lock$(EXEEXT):
     171        $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000  $(srcdir)/ttst_lock.c
     172
     173tls-fetch_add$(EXEEXT):
     174        $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000  $(srcdir)/tls-fetch_add.c
     175
     176## =========================================================================================================
     177CTXSWITCH_DEPEND  =                 \
     178        loop.run                                \
     179        function.run                    \
     180        fetch_add.run                   \
     181        ttst_lock.run                   \
     182        tls-fetch_add.run                       \
     183        ctxswitch-pthread.run           \
    243184        ctxswitch-cfa_generator.run     \
    244185        ctxswitch-cfa_coroutine.run     \
     
    247188        ctxswitch-upp_coroutine.run     \
    248189        ctxswitch-upp_thread.run        \
    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
     190        ctxswitch-goroutine.run         \
     191        ctxswitch-java_thread.run
     192
    257193
    258194if WITH_LIBFIBRE
    259 CTXSWITCH_DEPEND  +=                    \
    260         ctxswitch-kos_fibre.run         \
     195CTXSWITCH_DEPEND  +=           \
     196        ctxswitch-kos_fibre.run  \
    261197        ctxswitch-kos_fibre2.run
     198
    262199
    263200ctxswitch-kos_fibre$(EXEEXT):
     
    270207ctxswitch$(EXEEXT): $(CTXSWITCH_DEPEND)
    271208
     209ctxswitch-pthread$(EXEEXT):
     210        $(BENCH_V_CC)$(COMPILE)    -DBENCH_N=50000000 $(srcdir)/ctxswitch/pthreads.c
     211
    272212ctxswitch-cfa_generator$(EXEEXT):
    273         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_gen.cfa
     213        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_gen.cfa
    274214
    275215ctxswitch-cfa_coroutine$(EXEEXT):
    276         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_cor.cfa
     216        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_cor.cfa
    277217
    278218ctxswitch-cfa_thread$(EXEEXT):
    279         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_thrd.cfa
     219        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_thrd.cfa
    280220
    281221ctxswitch-cfa_thread2$(EXEEXT):
    282         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_thrd2.cfa
     222        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_thrd2.cfa
    283223
    284224ctxswitch-upp_coroutine$(EXEEXT):
    285         $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/ctxswitch/upp_cor.cc
     225        $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/upp_cor.cc
    286226
    287227ctxswitch-upp_thread$(EXEEXT):
    288         $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/ctxswitch/upp_thrd.cc
    289 
    290 ctxswitch-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 
    295 ctxswitch-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 
    300 ctxswitch-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 
    305 ctxswitch-goroutine_thread$(EXEEXT):
     228        $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/upp_thrd.cc
     229
     230ctxswitch-goroutine$(EXEEXT):
    306231        $(BENCH_V_GOC)go build -o a.out $(srcdir)/ctxswitch/goroutine.go
    307 
    308 ctxswitch-rust_thread$(EXEEXT):
    309         $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/ctxswitch/rust_thrd.rs
    310232
    311233ctxswitch-java_thread$(EXEEXT):
    312234        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/ctxswitch/JavaThread.java
    313         echo "#!/bin/sh" > a.out
    314         echo "java JavaThread" >> a.out
    315         chmod a+x a.out
    316 
    317 ctxswitch-pthread$(EXEEXT):
    318         $(BENCH_V_CC)$(COMPILE) $(srcdir)/ctxswitch/pthreads.c
    319 
    320 ## =========================================================================================================
    321 
    322 mutex$(EXEEXT) :                \
     235        @echo "#!/bin/sh" > a.out
     236        @echo "java JavaThread" >> a.out
     237        @chmod a+x a.out
     238
     239## =========================================================================================================
     240mutex$(EXEEXT) :\
     241        loop.run                        \
     242        function.run            \
     243        fetch_add.run           \
     244        mutex-pthread_lock.run  \
     245        mutex-upp.run           \
    323246        mutex-cfa1.run          \
    324247        mutex-cfa2.run          \
    325248        mutex-cfa4.run          \
    326         mutex-upp.run           \
    327         mutex-go.run            \
    328         mutex-rust.run          \
    329         mutex-java.run          \
    330         mutex-pthread.run
    331 
    332 mutex-pthread$(EXEEXT):
    333         $(BENCH_V_CC)$(COMPILE) $(srcdir)/mutex/pthreads.c
     249        mutex-java_thread.run
     250
     251mutex-pthread_lock$(EXEEXT):
     252        $(BENCH_V_CC)$(COMPILE)    -DBENCH_N=50000000 $(srcdir)/mutex/pthreads.c
     253
     254mutex-upp$(EXEEXT):
     255        $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/mutex/upp.cc
    334256
    335257mutex-cfa1$(EXEEXT):
    336         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa1.cfa
     258        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000  $(srcdir)/mutex/cfa1.cfa
    337259
    338260mutex-cfa2$(EXEEXT):
    339         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa2.cfa
     261        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000  $(srcdir)/mutex/cfa2.cfa
    340262
    341263mutex-cfa4$(EXEEXT):
    342         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa4.cfa
    343 
    344 mutex-upp$(EXEEXT):
    345         $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/mutex/upp.cc
    346 
    347 mutex-go$(EXEEXT):
    348         $(BENCH_V_GOC)go build -o a.out $(srcdir)/mutex/goroutine.go
    349 
    350 mutex-rust$(EXEEXT):
    351         $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/mutex/rust.rs
    352 
    353 mutex-java$(EXEEXT):
     264        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000  $(srcdir)/mutex/cfa4.cfa
     265
     266mutex-java_thread$(EXEEXT):
    354267        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/mutex/JavaThread.java
    355         echo "#!/bin/sh" > a.out
    356         echo "java JavaThread" >> a.out
    357         chmod a+x a.out
    358 
    359 ## =========================================================================================================
    360 
    361 schedint$(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 
    370 schedint-cfa1$(EXEEXT):
    371         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa1.cfa
    372 
    373 schedint-cfa2$(EXEEXT):
    374         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa2.cfa
    375 
    376 schedint-cfa4$(EXEEXT):
    377         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa4.cfa
    378 
    379 schedint-upp$(EXEEXT):
    380         $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedint/upp.cc
    381 
    382 schedint-rust$(EXEEXT):
    383         $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/schedint/rust.rs
    384 
    385 schedint-java$(EXEEXT):
     268        @echo "#!/bin/sh" > a.out
     269        @echo "java JavaThread" >> a.out
     270        @chmod a+x a.out
     271
     272## =========================================================================================================
     273signal$(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
     281signal-pthread_cond$(EXEEXT):
     282        $(BENCH_V_CC)$(COMPILE)    -DBENCH_N=500000  $(srcdir)/schedint/pthreads.c
     283
     284signal-upp$(EXEEXT):
     285        $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=5000000 $(srcdir)/schedint/upp.cc
     286
     287signal-cfa1$(EXEEXT):
     288        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedint/cfa1.cfa
     289
     290signal-cfa2$(EXEEXT):
     291        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedint/cfa2.cfa
     292
     293signal-cfa4$(EXEEXT):
     294        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedint/cfa4.cfa
     295
     296signal-java_thread$(EXEEXT):
    386297        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/schedint/JavaThread.java
    387         echo "#!/bin/sh" > a.out
    388         echo "java JavaThread" >> a.out
    389         chmod a+x a.out
    390 
    391 schedint-pthread$(EXEEXT):
    392         $(BENCH_V_CC)$(COMPILE) $(srcdir)/schedint/pthreads.c
    393 
    394 ## =========================================================================================================
    395 
    396 schedext$(EXEEXT) :             \
    397         schedext-cfa1.run       \
    398         schedext-cfa2.run       \
    399         schedext-cfa4.run       \
    400         schedext-upp.run        \
    401         schedext-goroutine.run
    402 
    403 schedext-cfa1$(EXEEXT):
    404         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa1.cfa
    405 
    406 schedext-cfa2$(EXEEXT):
    407         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa2.cfa
    408 
    409 schedext-cfa4$(EXEEXT):
    410         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa4.cfa
    411 
    412 schedext-upp$(EXEEXT):
    413         $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedext/upp.cc
    414 
    415 schedext-goroutine$(EXEEXT):
    416         $(BENCH_V_GOC)go build -o a.out $(srcdir)/schedext/goroutine.go
    417 
    418 
    419 ## =========================================================================================================
    420 
    421 creation$(EXEEXT) :                             \
    422         creation-cfa_generator.run              \
     298        @echo "#!/bin/sh" > a.out
     299        @echo "java JavaThread" >> a.out
     300        @chmod a+x a.out
     301
     302
     303## =========================================================================================================
     304waitfor$(EXEEXT) :\
     305        waitfor-upp.run         \
     306        waitfor-cfa1.run                \
     307        waitfor-cfa2.run                \
     308        waitfor-cfa4.run
     309
     310waitfor-upp$(EXEEXT):
     311        $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=5000000 $(srcdir)/schedext/upp.cc
     312
     313waitfor-cfa1$(EXEEXT):
     314        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedext/cfa1.cfa
     315
     316waitfor-cfa2$(EXEEXT):
     317        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedext/cfa2.cfa
     318
     319waitfor-cfa4$(EXEEXT):
     320        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedext/cfa4.cfa
     321
     322## =========================================================================================================
     323creation$(EXEEXT) :\
     324        creation-pthread.run                    \
    423325        creation-cfa_coroutine.run              \
    424326        creation-cfa_coroutine_eager.run        \
     
    426328        creation-upp_coroutine.run              \
    427329        creation-upp_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 
    435 creation-cfa_generator$(EXEEXT):
    436         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_gen.cfa
     330        creation-goroutine.run                  \
     331        creation-java_thread.run
    437332
    438333creation-cfa_coroutine$(EXEEXT):
    439         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_cor.cfa
     334        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_cor.cfa
    440335
    441336creation-cfa_coroutine_eager$(EXEEXT):
    442         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_cor.cfa  -DEAGER
     337        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_cor.cfa  -DEAGER
    443338
    444339creation-cfa_thread$(EXEEXT):
    445         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_thrd.cfa
     340        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_thrd.cfa
    446341
    447342creation-upp_coroutine$(EXEEXT):
    448         $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/creation/upp_cor.cc
     343        $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/creation/upp_cor.cc
    449344
    450345creation-upp_thread$(EXEEXT):
    451         $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/creation/upp_thrd.cc
    452 
    453 creation-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 
    458 creation-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 
    463 creation-goroutine_thread$(EXEEXT):
     346        $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/creation/upp_thrd.cc
     347
     348creation-pthread$(EXEEXT):
     349        $(BENCH_V_CC)$(COMPILE)    -DBENCH_N=250000   $(srcdir)/creation/pthreads.c
     350
     351creation-goroutine$(EXEEXT):
    464352        $(BENCH_V_GOC)go build -o a.out $(srcdir)/creation/goroutine.go
    465 
    466 creation-rust_thread$(EXEEXT):
    467         $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/creation/rust_thrd.rs
    468353
    469354creation-java_thread$(EXEEXT):
    470355        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/creation/JavaThread.java
    471         echo "#!/bin/sh" > a.out
    472         echo "java JavaThread" >> a.out
    473         chmod a+x a.out
    474 
    475 creation-pthread$(EXEEXT):
    476         $(BENCH_V_CC)$(COMPILE) $(srcdir)/creation/pthreads.c
    477 
    478 ## =========================================================================================================
    479 
    480 compile$(EXEEXT) :              \
     356        @echo "#!/bin/sh" > a.out
     357        @echo "java JavaThread" >> a.out
     358        @chmod a+x a.out
     359
     360## =========================================================================================================
     361
     362compile$(EXEEXT) :\
    481363        compile-array.make      \
    482364        compile-attributes.make \
     
    488370        compile-typeof.make
    489371
     372
    490373testdir = $(top_srcdir)/tests
    491374
    492375compile-array$(EXEEXT):
    493         $(CFACOMPILE) -fsyntax-only -w $(testdir)/array.cfa
     376        @$(CFACOMPILE) -fsyntax-only -w $(testdir)/array.cfa
    494377
    495378compile-attributes$(EXEEXT):
    496         $(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa
     379        @$(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa
    497380
    498381compile-empty$(EXEEXT):
    499         $(CFACOMPILE) -fsyntax-only -w $(srcdir)/compile/empty.cfa
     382        @$(CFACOMPILE) -fsyntax-only -w $(srcdir)/compile/empty.cfa
    500383
    501384compile-expression$(EXEEXT):
    502         $(CFACOMPILE) -fsyntax-only -w $(testdir)/expression.cfa
     385        @$(CFACOMPILE) -fsyntax-only -w $(testdir)/expression.cfa
    503386
    504387compile-io$(EXEEXT):
    505         $(CFACOMPILE) -fsyntax-only -w $(testdir)/io1.cfa
     388        @$(CFACOMPILE) -fsyntax-only -w $(testdir)/io1.cfa
    506389
    507390compile-monitor$(EXEEXT):
    508         $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/monitor.cfa
     391        @$(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/monitor.cfa
    509392
    510393compile-operators$(EXEEXT):
    511         $(CFACOMPILE) -fsyntax-only -w $(testdir)/operators.cfa
     394        @$(CFACOMPILE) -fsyntax-only -w $(testdir)/operators.cfa
    512395
    513396compile-thread$(EXEEXT):
    514         $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/thread.cfa
     397        @$(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/thread.cfa
    515398
    516399compile-typeof$(EXEEXT):
    517         $(CFACOMPILE) -fsyntax-only -w $(testdir)/typeof.cfa
     400        @$(CFACOMPILE) -fsyntax-only -w $(testdir)/typeof.cfa
  • benchmark/Makefile.in

    rbdfc032 raefb247  
    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
     
    358358am__v_CFA_0 = @echo "  CFA     " $@;
    359359am__v_CFA_1 =
     360AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
     361am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
     362am__v_JAVAC_0 = @echo "  JAVAC   " $@;
     363am__v_JAVAC_1 =
     364AM_V_GOC = $(am__v_GOC_@AM_V@)
     365am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)
     366am__v_GOC_0 = @echo "  GOC     " $@;
     367am__v_GOC_1 =
    360368UPPCC = u++
    361369UPPCOMPILE = $(UPPCC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_UPPFLAGS) $(UPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_CFLAGS) $(CFLAGS)
     
    364372am__v_UPP_0 = @echo "  UPP     " $@;
    365373am__v_UPP_1 =
    366 AM_V_GOC = $(am__v_GOC_@AM_V@)
    367 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)
    368 am__v_GOC_0 = @echo "  GOC     " $@;
    369 am__v_GOC_1 =
    370 AM_V_RUST = $(am__v_RUST_@AM_V@)
    371 am__v_RUST_ = $(am__v_RUST_@AM_DEFAULT_V@)
    372 am__v_RUST_0 = @echo "  RUST     " $@;
    373 am__v_RUST_1 =
    374 AM_V_NODEJS = $(am__v_NODEJS_@AM_V@)
    375 am__v_NODEJS_ = $(am__v_NODEJS_@AM_DEFAULT_V@)
    376 am__v_NODEJS_0 = @echo "  NODEJS     " $@;
    377 am__v_NODEJS_1 =
    378 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
    379 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
    380 am__v_JAVAC_0 = @echo "  JAVAC   " $@;
    381 am__v_JAVAC_1 =
    382374
    383375# applies to both programs
     
    388380BENCH_V_CFA = $(__bench_v_CFA_$(__quiet))
    389381BENCH_V_CXX = $(__bench_v_CXX_$(__quiet))
     382BENCH_V_GOC = $(__bench_v_GOC_$(__quiet))
     383BENCH_V_JAVAC = $(__bench_v_JAVAC_$(__quiet))
    390384BENCH_V_UPP = $(__bench_v_UPP_$(__quiet))
    391 BENCH_V_GOC = $(__bench_v_GOC_$(__quiet))
    392 BENCH_V_RUSTC = $(__bench_v_RUSTC_$(__quiet))
    393 BENCH_V_NODEJS = $(__bench_v_NODEJS_$(__quiet))
    394 BENCH_V_JAVAC = $(__bench_v_JAVAC_$(__quiet))
    395385__quiet = verbose
    396386__bench_v_CC_quiet = @
    397387__bench_v_CFA_quiet = @
    398388__bench_v_CXX_quiet = @
     389__bench_v_GOC_quiet = @
     390__bench_v_JAVAC_quiet = @
    399391__bench_v_UPP_quiet = @
    400 __bench_v_GOC_quiet = @
    401 __bench_v_RUSTC_quiet = @
    402 __bench_v_JAVAC_quiet = @
    403392__bench_v_CC_verbose = $(AM_V_CC)
    404393__bench_v_CFA_verbose = $(AM_V_CFA)
    405394__bench_v_CXX_verbose = $(AM_V_CXX)
     395__bench_v_GOC_verbose = $(AM_V_GOC)
     396__bench_v_JAVAC_verbose = $(AM_V_JAVAC)
    406397__bench_v_UPP_verbose = $(AM_V_UPP)
    407 __bench_v_GOC_verbose = $(AM_V_GOC)
    408 __bench_v_RUSTC_verbose = $(AM_V_RUSTC)
    409 __bench_v_NODEJS_verbose = $(AM_V_NODEJS)
    410 __bench_v_JAVAC_verbose = $(AM_V_JAVAC)
    411398TOOLSDIR = ${abs_top_builddir}/tools/
    412399REPEAT = ${abs_top_builddir}/tools/repeat
    413400STATS = ${abs_top_srcdir}/tools/stat.py
    414401# NEED AT LEAST 4 DATA VALUES FOR BENCHMARKS BECAUSE THE MAX AND MIN VALUES ARE REMOVED
    415 repeats = 13 # 31 for benchmarks
     402repeats = 5 # 31 for benchmarks
    416403arch = x64
    417404skipcompile = no
     
    419406PRINT_FORMAT = %20s: #Comments needed for spacing
    420407dummy_SOURCES = dummyC.c dummyCXX.cpp
    421 basic_loop_DURATION = 15000000000
    422 basic_function_DURATION = 10000000000
    423 basic_tls_fetch_add_DURATION = 10000000000
    424 basic_DURATION = 250000000
    425 ctxswitch_pthread_DURATION = 25000000
    426 ctxswitch_rust_thread_DURATION = $(ctxswitch_pthread_DURATION)
    427 ctxswitch_cfa_generator_DURATION = 5000000000
    428 ctxswitch_nodejs_await_DURATION = 5000000
    429 ctxswitch_DURATION = 100000000
    430 
    431 #mutex_java_DURATION = 10000000
    432 mutex_DURATION = 50000000
    433 schedint_pthread_DURATION = 1000000
    434 schedint_java_DURATION = $(schedint_pthread_DURATION)
    435 schedint_rust_DURATION = $(schedint_pthread_DURATION)
    436 schedint_DURATION = 10000000
    437 schedext_DURATION = 10000000
    438 creation_pthread_DURATION = 250000
    439 creation_rust_thread_DURATION = ${creation_pthread_DURATION}
    440 creation_java_thread_DURATION = ${creation_pthread_DURATION}
    441 creation_cfa_coroutine_DURATION = 100000000
    442 creation_cfa_coroutine_eager_DURATION = 10000000
    443 creation_upp_coroutine_DURATION = ${creation_cfa_coroutine_eager_DURATION}
    444 creation_cfa_thread_DURATION = 10000000
    445 creation_upp_thread_DURATION = ${creation_cfa_thread_DURATION}
    446 creation_DURATION = 10000000
    447408FIX_NEW_LINES = cat $@ | tr "\n" "\t" | sed -r 's/\t,/,/' | tr "\t" "\n" > $@
    448 BASIC_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 
    455 CTXSWITCH_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)
     409CTXSWITCH_DEPEND = loop.run function.run fetch_add.run ttst_lock.run \
     410        tls-fetch_add.run ctxswitch-pthread.run \
     411        ctxswitch-cfa_generator.run ctxswitch-cfa_coroutine.run \
     412        ctxswitch-cfa_thread.run ctxswitch-cfa_thread2.run \
     413        ctxswitch-upp_coroutine.run ctxswitch-upp_thread.run \
     414        ctxswitch-goroutine.run ctxswitch-java_thread.run \
     415        $(am__append_1)
    463416testdir = $(top_srcdir)/tests
    464417all: all-am
     
    779732
    780733dummyC.c:
    781         echo "int main() { return 0; }" > ${@}
     734        @echo "int main() { return 0; }" > ${@}
    782735
    783736dummyCXX.cpp:
    784         echo "int main() { return 0; }" > ${@}
    785 
    786 #.SILENT:               # do not print recipe
    787 .ONESHELL:              # use one shell to execute recipe
     737        @echo "int main() { return 0; }" > ${@}
     738
    788739.NOTPARALLEL:
    789 .PHONY: compile.csv basic.csv ctxswitch.csv mutex.csv schedint.csv
    790 
    791 all : basic$(EXEEXT) ctxswitch$(EXEEXT) mutex$(EXEEXT) schedint$(EXEEXT) schedext$(EXEEXT) creation$(EXEEXT)
     740.PHONY: compile.csv ctxswitch.csv mutex.csv signal.csv
     741
     742all : ctxswitch$(EXEEXT) mutex$(EXEEXT) signal$(EXEEXT) waitfor$(EXEEXT) creation$(EXEEXT)
    792743
    793744%.run : %$(EXEEXT) ${REPEAT}
    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
     745        @rm -f .result.log
     746        @echo "------------------------------------------------------"
     747        @echo $<
     748        @${REPEAT} ${repeats} ./a.out | tee -a .result.log
     749        @${STATS} .result.log
     750        @echo "------------------------------------------------------"
     751        @rm -f a.out .result.log *.class
    806752
    807753%.runquiet :
    808         +make $(basename $@) CFLAGS="-w" __quiet=quiet
    809         taskset -c 1 ./a.out
    810         rm -f a.out
     754        @+make $(basename $@) CFLAGS="-w" __quiet=quiet
     755        @taskset -c 1 ./a.out
     756        @rm -f a.out
    811757
    812758%.make :
    813         printf "${PRINT_FORMAT}" $(basename $(subst compile-,,$@))
    814         +/usr/bin/time -f ${TIME_FORMAT} make $(basename $@) 2>&1
     759        @printf "${PRINT_FORMAT}" $(basename $(subst compile-,,$@))
     760        @+/usr/bin/time -f ${TIME_FORMAT} make $(basename $@) 2>&1
    815761
    816762${REPEAT} :
    817         +make -C ${abs_top_builddir}/tools repeat
     763        @+make -C ${abs_top_builddir}/tools repeat
    818764
    819765jenkins$(EXEEXT):
    820766@DOifskipcompile@
    821         +make compile.csv
    822         -+make compile.diff.csv
     767        @+make compile.csv
     768        @-+make compile.diff.csv
    823769@DOendif@
    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
     770        @+make ctxswitch.csv
     771        @-+make ctxswitch.diff.csv
     772        @+make mutex.csv
     773        @-+make mutex.diff.csv
     774        @+make signal.csv
     775        @-+make signal.diff.csv
    832776@DOifskipcompile@
    833777        cat compile.csv
    834778        -cat compile.diff.csv
    835779@DOendif@
    836         cat basic.csv
    837         -cat basic.diff.csv
    838780        cat ctxswitch.csv
    839781        -cat ctxswitch.diff.csv
    840782        cat mutex.csv
    841783        -cat mutex.diff.csv
    842         cat schedint.csv
    843         -cat schedint.diff.csv
     784        cat signal.csv
     785        -cat signal.diff.csv
    844786
    845787compile.csv:
    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 
    857 basic.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 $@
     788        @echo "array,attributes,empty,expression,io,monitor,operators,typeof" > $@
     789        @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-array.make >> $@
     790        @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-attributes.make >> $@
     791        @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-empty.make >> $@
     792        @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-expression.make >> $@
     793        @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-io.make >> $@
     794        @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-monitor.make >> $@
     795        @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-operators.make >> $@
     796        @+make TIME_FORMAT='%e' PRINT_FORMAT='' compile-typeof.make >> $@
     797        @$(srcdir)/fixcsv.sh $@
    863798
    864799ctxswitch.csv:
    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 $@
     800        @echo "generator,coroutine,thread" > $@
     801        @+make ctxswitch-cfa_generator.runquiet >> $@ && echo -n ',' >> $@
     802        @+make ctxswitch-cfa_coroutine.runquiet >> $@ && echo -n ',' >> $@
     803        @+make ctxswitch-cfa_thread.runquiet >> $@
     804        @$(srcdir)/fixcsv.sh $@
    870805
    871806mutex.csv:
    872         echo "1-monitor,2-monitor" > $@
    873         +make mutex-cfa1.runquiet >> $@ && echo -n ',' >> $@
    874         +make mutex-cfa2.runquiet >> $@
    875         $(srcdir)/fixcsv.sh $@
    876 
    877 schedint.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 $@
     807        @echo "1-monitor,2-monitor" > $@
     808        @+make mutex-cfa1.runquiet >> $@ && echo -n ',' >> $@
     809        @+make mutex-cfa2.runquiet >> $@
     810        @$(srcdir)/fixcsv.sh $@
     811
     812signal.csv:
     813        @echo "signal-1,signal-2,waitfor-1,waitfor-2" > $@
     814        @+make signal-cfa1.runquiet >> $@ && echo -n ',' >> $@
     815        @+make signal-cfa2.runquiet >> $@ && echo -n ',' >> $@
     816        @+make waitfor-cfa1.runquiet >> $@ && echo -n ',' >> $@
     817        @+make waitfor-cfa2.runquiet >> $@
     818        @$(srcdir)/fixcsv.sh $@
    884819
    885820%.diff.csv: %.csv
    886         test -e $(srcdir)/baselines/$(arch)/$< || (echo "Error : Missing baseline for ${<}" && false)
    887         $(srcdir)/baselines/calc.py $(srcdir)/baselines/$(arch)/$(<) $(<) > $@
    888 
    889 basic-loop$(EXEEXT):
    890         $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/loop.c
    891 
    892 basic-function$(EXEEXT):
    893         $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/function.c
    894 
    895 basic-fetch_add$(EXEEXT):
    896         $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/fetch_add.c
    897 
    898 basic-ttst_lock$(EXEEXT):
    899         $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/ttst_lock.c
    900 
    901 basic-tls-fetch_add$(EXEEXT):
    902         $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/tls_fetch_add.c
    903 
    904 basic$(EXEEXT): $(BASIC_DEPEND)
     821        @test -e $(srcdir)/baselines/$(arch)/$< || (echo "Error : Missing baseline for ${<}" && false)
     822        @$(srcdir)/baselines/calc.py $(srcdir)/baselines/$(arch)/$(<) $(<) > $@
     823
     824loop$(EXEEXT):
     825        $(BENCH_V_CC)$(COMPILE) -DBENCH_N=5000000000 $(srcdir)/loop.c
     826
     827function$(EXEEXT):
     828        $(BENCH_V_CC)$(COMPILE) -DBENCH_N=5000000000 $(srcdir)/function.c
     829
     830fetch_add$(EXEEXT):
     831        $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000  $(srcdir)/fetch_add.c
     832
     833ttst_lock$(EXEEXT):
     834        $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000  $(srcdir)/ttst_lock.c
     835
     836tls-fetch_add$(EXEEXT):
     837        $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000  $(srcdir)/tls-fetch_add.c
    905838
    906839@WITH_LIBFIBRE_TRUE@ctxswitch-kos_fibre$(EXEEXT):
     
    912845ctxswitch$(EXEEXT): $(CTXSWITCH_DEPEND)
    913846
     847ctxswitch-pthread$(EXEEXT):
     848        $(BENCH_V_CC)$(COMPILE)    -DBENCH_N=50000000 $(srcdir)/ctxswitch/pthreads.c
     849
    914850ctxswitch-cfa_generator$(EXEEXT):
    915         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_gen.cfa
     851        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_gen.cfa
    916852
    917853ctxswitch-cfa_coroutine$(EXEEXT):
    918         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_cor.cfa
     854        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_cor.cfa
    919855
    920856ctxswitch-cfa_thread$(EXEEXT):
    921         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_thrd.cfa
     857        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_thrd.cfa
    922858
    923859ctxswitch-cfa_thread2$(EXEEXT):
    924         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_thrd2.cfa
     860        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_thrd2.cfa
    925861
    926862ctxswitch-upp_coroutine$(EXEEXT):
    927         $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/ctxswitch/upp_cor.cc
     863        $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/upp_cor.cc
    928864
    929865ctxswitch-upp_thread$(EXEEXT):
    930         $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/ctxswitch/upp_thrd.cc
    931 
    932 ctxswitch-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 
    937 ctxswitch-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 
    942 ctxswitch-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 
    947 ctxswitch-goroutine_thread$(EXEEXT):
     866        $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/upp_thrd.cc
     867
     868ctxswitch-goroutine$(EXEEXT):
    948869        $(BENCH_V_GOC)go build -o a.out $(srcdir)/ctxswitch/goroutine.go
    949 
    950 ctxswitch-rust_thread$(EXEEXT):
    951         $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/ctxswitch/rust_thrd.rs
    952870
    953871ctxswitch-java_thread$(EXEEXT):
    954872        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/ctxswitch/JavaThread.java
    955         echo "#!/bin/sh" > a.out
    956         echo "java JavaThread" >> a.out
    957         chmod a+x a.out
    958 
    959 ctxswitch-pthread$(EXEEXT):
    960         $(BENCH_V_CC)$(COMPILE) $(srcdir)/ctxswitch/pthreads.c
    961 
    962 mutex$(EXEEXT) :                \
     873        @echo "#!/bin/sh" > a.out
     874        @echo "java JavaThread" >> a.out
     875        @chmod a+x a.out
     876
     877mutex$(EXEEXT) :\
     878        loop.run                        \
     879        function.run            \
     880        fetch_add.run           \
     881        mutex-pthread_lock.run  \
     882        mutex-upp.run           \
    963883        mutex-cfa1.run          \
    964884        mutex-cfa2.run          \
    965885        mutex-cfa4.run          \
    966         mutex-upp.run           \
    967         mutex-go.run            \
    968         mutex-rust.run          \
    969         mutex-java.run          \
    970         mutex-pthread.run
    971 
    972 mutex-pthread$(EXEEXT):
    973         $(BENCH_V_CC)$(COMPILE) $(srcdir)/mutex/pthreads.c
     886        mutex-java_thread.run
     887
     888mutex-pthread_lock$(EXEEXT):
     889        $(BENCH_V_CC)$(COMPILE)    -DBENCH_N=50000000 $(srcdir)/mutex/pthreads.c
     890
     891mutex-upp$(EXEEXT):
     892        $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/mutex/upp.cc
    974893
    975894mutex-cfa1$(EXEEXT):
    976         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa1.cfa
     895        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000  $(srcdir)/mutex/cfa1.cfa
    977896
    978897mutex-cfa2$(EXEEXT):
    979         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa2.cfa
     898        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000  $(srcdir)/mutex/cfa2.cfa
    980899
    981900mutex-cfa4$(EXEEXT):
    982         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa4.cfa
    983 
    984 mutex-upp$(EXEEXT):
    985         $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/mutex/upp.cc
    986 
    987 mutex-go$(EXEEXT):
    988         $(BENCH_V_GOC)go build -o a.out $(srcdir)/mutex/goroutine.go
    989 
    990 mutex-rust$(EXEEXT):
    991         $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/mutex/rust.rs
    992 
    993 mutex-java$(EXEEXT):
     901        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000  $(srcdir)/mutex/cfa4.cfa
     902
     903mutex-java_thread$(EXEEXT):
    994904        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/mutex/JavaThread.java
    995         echo "#!/bin/sh" > a.out
    996         echo "java JavaThread" >> a.out
    997         chmod a+x a.out
    998 
    999 schedint$(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 
    1008 schedint-cfa1$(EXEEXT):
    1009         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa1.cfa
    1010 
    1011 schedint-cfa2$(EXEEXT):
    1012         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa2.cfa
    1013 
    1014 schedint-cfa4$(EXEEXT):
    1015         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa4.cfa
    1016 
    1017 schedint-upp$(EXEEXT):
    1018         $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedint/upp.cc
    1019 
    1020 schedint-rust$(EXEEXT):
    1021         $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/schedint/rust.rs
    1022 
    1023 schedint-java$(EXEEXT):
     905        @echo "#!/bin/sh" > a.out
     906        @echo "java JavaThread" >> a.out
     907        @chmod a+x a.out
     908
     909signal$(EXEEXT) :\
     910        signal-pthread_cond.run \
     911        signal-upp.run          \
     912        signal-cfa1.run         \
     913        signal-cfa2.run         \
     914        signal-cfa4.run         \
     915        signal-java_thread.run
     916
     917signal-pthread_cond$(EXEEXT):
     918        $(BENCH_V_CC)$(COMPILE)    -DBENCH_N=500000  $(srcdir)/schedint/pthreads.c
     919
     920signal-upp$(EXEEXT):
     921        $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=5000000 $(srcdir)/schedint/upp.cc
     922
     923signal-cfa1$(EXEEXT):
     924        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedint/cfa1.cfa
     925
     926signal-cfa2$(EXEEXT):
     927        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedint/cfa2.cfa
     928
     929signal-cfa4$(EXEEXT):
     930        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedint/cfa4.cfa
     931
     932signal-java_thread$(EXEEXT):
    1024933        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/schedint/JavaThread.java
    1025         echo "#!/bin/sh" > a.out
    1026         echo "java JavaThread" >> a.out
    1027         chmod a+x a.out
    1028 
    1029 schedint-pthread$(EXEEXT):
    1030         $(BENCH_V_CC)$(COMPILE) $(srcdir)/schedint/pthreads.c
    1031 
    1032 schedext$(EXEEXT) :             \
    1033         schedext-cfa1.run       \
    1034         schedext-cfa2.run       \
    1035         schedext-cfa4.run       \
    1036         schedext-upp.run        \
    1037         schedext-goroutine.run
    1038 
    1039 schedext-cfa1$(EXEEXT):
    1040         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa1.cfa
    1041 
    1042 schedext-cfa2$(EXEEXT):
    1043         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa2.cfa
    1044 
    1045 schedext-cfa4$(EXEEXT):
    1046         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa4.cfa
    1047 
    1048 schedext-upp$(EXEEXT):
    1049         $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedext/upp.cc
    1050 
    1051 schedext-goroutine$(EXEEXT):
    1052         $(BENCH_V_GOC)go build -o a.out $(srcdir)/schedext/goroutine.go
    1053 
    1054 creation$(EXEEXT) :                             \
    1055         creation-cfa_generator.run              \
     934        @echo "#!/bin/sh" > a.out
     935        @echo "java JavaThread" >> a.out
     936        @chmod a+x a.out
     937
     938waitfor$(EXEEXT) :\
     939        waitfor-upp.run         \
     940        waitfor-cfa1.run                \
     941        waitfor-cfa2.run                \
     942        waitfor-cfa4.run
     943
     944waitfor-upp$(EXEEXT):
     945        $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=5000000 $(srcdir)/schedext/upp.cc
     946
     947waitfor-cfa1$(EXEEXT):
     948        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedext/cfa1.cfa
     949
     950waitfor-cfa2$(EXEEXT):
     951        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedext/cfa2.cfa
     952
     953waitfor-cfa4$(EXEEXT):
     954        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedext/cfa4.cfa
     955
     956creation$(EXEEXT) :\
     957        creation-pthread.run                    \
    1056958        creation-cfa_coroutine.run              \
    1057959        creation-cfa_coroutine_eager.run        \
     
    1059961        creation-upp_coroutine.run              \
    1060962        creation-upp_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 
    1068 creation-cfa_generator$(EXEEXT):
    1069         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_gen.cfa
     963        creation-goroutine.run                  \
     964        creation-java_thread.run
    1070965
    1071966creation-cfa_coroutine$(EXEEXT):
    1072         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_cor.cfa
     967        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_cor.cfa
    1073968
    1074969creation-cfa_coroutine_eager$(EXEEXT):
    1075         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_cor.cfa  -DEAGER
     970        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_cor.cfa  -DEAGER
    1076971
    1077972creation-cfa_thread$(EXEEXT):
    1078         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_thrd.cfa
     973        $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_thrd.cfa
    1079974
    1080975creation-upp_coroutine$(EXEEXT):
    1081         $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/creation/upp_cor.cc
     976        $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/creation/upp_cor.cc
    1082977
    1083978creation-upp_thread$(EXEEXT):
    1084         $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/creation/upp_thrd.cc
    1085 
    1086 creation-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 
    1091 creation-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 
    1096 creation-goroutine_thread$(EXEEXT):
     979        $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/creation/upp_thrd.cc
     980
     981creation-pthread$(EXEEXT):
     982        $(BENCH_V_CC)$(COMPILE)    -DBENCH_N=250000   $(srcdir)/creation/pthreads.c
     983
     984creation-goroutine$(EXEEXT):
    1097985        $(BENCH_V_GOC)go build -o a.out $(srcdir)/creation/goroutine.go
    1098 
    1099 creation-rust_thread$(EXEEXT):
    1100         $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/creation/rust_thrd.rs
    1101986
    1102987creation-java_thread$(EXEEXT):
    1103988        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/creation/JavaThread.java
    1104         echo "#!/bin/sh" > a.out
    1105         echo "java JavaThread" >> a.out
    1106         chmod a+x a.out
    1107 
    1108 creation-pthread$(EXEEXT):
    1109         $(BENCH_V_CC)$(COMPILE) $(srcdir)/creation/pthreads.c
    1110 
    1111 compile$(EXEEXT) :              \
     989        @echo "#!/bin/sh" > a.out
     990        @echo "java JavaThread" >> a.out
     991        @chmod a+x a.out
     992
     993compile$(EXEEXT) :\
    1112994        compile-array.make      \
    1113995        compile-attributes.make \
     
    11201002
    11211003compile-array$(EXEEXT):
    1122         $(CFACOMPILE) -fsyntax-only -w $(testdir)/array.cfa
     1004        @$(CFACOMPILE) -fsyntax-only -w $(testdir)/array.cfa
    11231005
    11241006compile-attributes$(EXEEXT):
    1125         $(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa
     1007        @$(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa
    11261008
    11271009compile-empty$(EXEEXT):
    1128         $(CFACOMPILE) -fsyntax-only -w $(srcdir)/compile/empty.cfa
     1010        @$(CFACOMPILE) -fsyntax-only -w $(srcdir)/compile/empty.cfa
    11291011
    11301012compile-expression$(EXEEXT):
    1131         $(CFACOMPILE) -fsyntax-only -w $(testdir)/expression.cfa
     1013        @$(CFACOMPILE) -fsyntax-only -w $(testdir)/expression.cfa
    11321014
    11331015compile-io$(EXEEXT):
    1134         $(CFACOMPILE) -fsyntax-only -w $(testdir)/io1.cfa
     1016        @$(CFACOMPILE) -fsyntax-only -w $(testdir)/io1.cfa
    11351017
    11361018compile-monitor$(EXEEXT):
    1137         $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/monitor.cfa
     1019        @$(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/monitor.cfa
    11381020
    11391021compile-operators$(EXEEXT):
    1140         $(CFACOMPILE) -fsyntax-only -w $(testdir)/operators.cfa
     1022        @$(CFACOMPILE) -fsyntax-only -w $(testdir)/operators.cfa
    11411023
    11421024compile-thread$(EXEEXT):
    1143         $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/thread.cfa
     1025        @$(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/thread.cfa
    11441026
    11451027compile-typeof$(EXEEXT):
    1146         $(CFACOMPILE) -fsyntax-only -w $(testdir)/typeof.cfa
     1028        @$(CFACOMPILE) -fsyntax-only -w $(testdir)/typeof.cfa
    11471029
    11481030# Tell versions [3.59,3.63) of GNU make to not export all variables.
  • benchmark/bench.h

    rbdfc032 raefb247  
    55#endif
    66        #include <stdlib.h>
    7         #include <stdint.h>                             // uint64_t
    8         #include <unistd.h>                             // sysconf
     7        #include <unistd.h>                                     // sysconf
    98#if ! defined(__cforall)
    109        #include <time.h>
     
    1615
    1716
    18 static 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
     17static 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
    2332
    2433#ifndef BENCH_N
    25 #define BENCH_N 10000000
     34#define BENCH_N 500 //10000000
    2635#endif
    2736
    28 size_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 
    3637#define BENCH(statement, output)                \
    37         uint64_t StartTime, EndTime;            \
     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;       \
    3844        StartTime = bench_time();               \
    39         statement;                              \
     45        statement;                                      \
    4046        EndTime = bench_time();                 \
    41         double output = (double)( EndTime - StartTime ) / times;
    42 
     47        double output =         \
     48            (double)( EndTime - StartTime ) / n;
    4349
    4450#if defined(__cforall)
     
    4753}
    4854#endif
    49 #if defined(__U_CPLUSPLUS__)
    50 unsigned int uDefaultPreemption() {
    51         return 0;
    52 }
    53 #endif
  • benchmark/creation/JavaThread.java

    rbdfc032 raefb247  
    2626        static int x = 2;
    2727
    28         static private int times = Integer.parseInt("10000") ;
     28        static private final int NoOfTimes = 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 <= times; i += 1) {
     35                for(int i = 1; i <= NoOfTimes; i += 1) {
    3636                        MyThread m = new MyThread();
    3737                        x = nextRandom( x );
     
    4444                helper();
    4545                long end = System.nanoTime();
    46                 System.out.println( (end - start) / times );
     46                System.out.println( (end - start) / NoOfTimes );
    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 
    52                 for (int i = Integer.parseInt("5"); --i >= 0 ; ) {
     49                for (int n = Integer.parseInt("5"); --n >= 0 ; ) {
    5350                        InnerMain();
    54                         Thread.sleep(2000);             // 2 seconds
     51                        Thread.sleep(2000);     // 2 seconds
    5552                        x = nextRandom(x);
    5653                }
     
    5855        }
    5956}
    60 
    61 // Local Variables: //
    62 // tab-width: 4 //
    63 // End: //
  • benchmark/creation/cfa_cor.cfa

    rbdfc032 raefb247  
    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[] ) {
    15         BENCH_START()
     14int main(int argc, char* argv[]) {
    1615        BENCH(
    17                 for ( times ) {
    18                         MyCoroutine c;
     16                for ( i; n ) {
     17                        MyCoroutine m;
    1918                },
    2019                result
    2120        )
    22         printf( "%g\n", result );
     21
     22        printf("%g\n", result);
    2323}
    24 
    25 // Local Variables: //
    26 // tab-width: 4 //
    27 // End: //
  • benchmark/creation/cfa_thrd.cfa

    rbdfc032 raefb247  
    77void main(MyThread &) {}
    88
    9 int main( int argc, char * argv[] ) {
    10         BENCH_START()
     9int main(int argc, char* argv[]) {
    1110        BENCH(
    12                 for ( times ) {
     11                for ( i; n ) {
    1312                        MyThread m;
    1413                },
    1514                result
    1615        )
    17         printf( "%g\n", result );
     16
     17        printf("%g\n", result);
    1818}
    19 
    20 // Local Variables: //
    21 // tab-width: 4 //
    22 // End: //
  • benchmark/creation/goroutine.go

    rbdfc032 raefb247  
    22
    33import (
    4         "fmt"
    5         "time"
    6         "os"
    7         "strconv"
     4    "fmt"
     5    "time"
    86)
    97
     
    1917
    2018func main() {
    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 
     19        const NoOfTimes = 500000
    2520        start := time.Now()
    26         for i := 1; i <= times; i += 1 {
     21        for i := 1; i <= NoOfTimes; i += 1 {
    2722                go noop()               // creation
    28                 <- shake                // wait for completion
    2923        }
    3024        end := time.Now()
    31         fmt.Printf( "%d\n", end.Sub(start) / time.Duration(times) )
     25        fmt.Printf("%d\n", end.Sub(start) / time.Duration(NoOfTimes))
     26        <- shake
    3227}
    33 
    34 // Local Variables: //
    35 // tab-width: 4 //
    36 // End: //
  • benchmark/creation/pthreads.c

    rbdfc032 raefb247  
    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[] ) {
    11         BENCH_START()
     10int main(int argc, char* argv[]) {
    1211        BENCH(
    13                 for (size_t i = 0; i < times; i++) {
     12                for (size_t i = 0; i < n; i++) {
    1413                        pthread_t thread;
    1514                        if (pthread_create(&thread, NULL, foo, NULL) < 0) {
     
    1716                                return 1;
    1817                        }
     18
    1919                        if (pthread_join( thread, NULL) < 0) {
    2020                                perror( "failure" );
     
    2424                result
    2525        )
    26         printf( "%g\n", result );
     26
     27        printf("%g\n", result);
    2728}
    28 
    29 // Local Variables: //
    30 // tab-width: 4 //
    31 // End: //
  • benchmark/creation/upp_cor.cc

    rbdfc032 raefb247  
    55_Coroutine MyCor {
    66        void main() {}
    7   public:
    8         MyCor() { resume(); }
    97};
    108
    11 int main( int argc, char * argv[] ) {
    12         BENCH_START()
     9int main(int argc, char* argv[]) {
    1310        BENCH(
    14                 for (size_t i = 0; i < times; i++) {
     11                for (size_t i = 0; i < n; i++) {
    1512                        MyCor m;
    1613                },
    1714                result
    1815        )
    19         printf( "%g\n", result );
     16
     17        printf("%g\n", result);
    2018}
    21 
    22 // Local Variables: //
    23 // tab-width: 4 //
    24 // End: //
  • benchmark/creation/upp_thrd.cc

    rbdfc032 raefb247  
    77};
    88
    9 int main( int argc, char * argv[] ) {
    10         BENCH_START()
     9int main(int argc, char* argv[]) {
    1110        BENCH(
    12                 for (size_t i = 0; i < times; i++) {
     11                for (size_t i = 0; i < n; i++) {
    1312                        MyThread m;
    1413                },
    1514                result
    1615        )
    17         printf( "%g\n", result );
     16
     17        printf("%g\n", result);
    1818}
    19 
    20 // Local Variables: //
    21 // tab-width: 4 //
    22 // End: //
  • benchmark/ctxswitch/JavaThread.java

    rbdfc032 raefb247  
    2626        static int x = 2;
    2727
    28         static private int times = Integer.parseInt("100000");
     28        static private final int NoOfTimes = Integer.parseInt("1000000") ;
    2929
    3030        public static void helper() {
    31                 for(int i = 1; i <= times; i += 1) {
     31                for(int i = 1; i <= NoOfTimes; i += 1) {
    3232                        Thread.yield();
    3333                }
     
    3737                helper();
    3838                long end = System.nanoTime();
    39                 System.out.println( (end - start) / times );
     39                System.out.println( (end - start) / NoOfTimes );
    4040        }
    4141        public static void main(String[] args) throws InterruptedException {
    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 ; ) {
     42                for (int n = Integer.parseInt("5"); --n >= 0 ; ) {
    4643                        InnerMain();
    47                         Thread.sleep(2000);     // 2 seconds
     44                        Thread.sleep(2000);     // 2 seconds
    4845                        x = nextRandom(x);
    4946                }
     
    5148        }
    5249}
    53 
    54 // Local Variables: //
    55 // tab-width: 4 //
    56 // End: //
  • benchmark/ctxswitch/cfa_cor.cfa

    rbdfc032 raefb247  
    44#include "bench.h"
    55
    6 coroutine C {} c;
    7 void main( __attribute__((unused)) C & ) {
    8         while () {
     6coroutine GreatSuspender {};
     7
     8void ?{}( GreatSuspender & this ) {
     9        prime(this);
     10}
     11
     12void main( __attribute__((unused)) GreatSuspender & this ) {
     13        while( true ) {
    914                suspend();
    1015        }
    1116}
    12 int main( int argc, char * argv[] ) {
    13         BENCH_START()
     17
     18int main(int argc, char* argv[]) {
     19        GreatSuspender s;
     20
    1421        BENCH(
    15                 for ( times ) {
    16                         resume( c );
     22                for ( i; n ) {
     23                        resume( s );
    1724                },
    1825                result
    1926        )
    20         printf( "%g\n", result );
     27
     28        printf("%g\n", result);
    2129}
    22 
    23 // Local Variables: //
    24 // tab-width: 4 //
    25 // End: //
  • benchmark/ctxswitch/cfa_cor_then.cfa

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

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

    rbdfc032 raefb247  
    33#include "bench.h"
    44
    5 int main( int argc, char * argv[] ) {
    6         BENCH_START()
     5int main(int argc, char* argv[]) {
    76        BENCH(
    8                 for ( times ) {
     7                for ( i; n ) {
    98                        yield();
    109                },
    1110                result
    1211        )
    13         printf( "%g\n", result );
     12
     13        printf("%g\n", result);
    1414}
    15 
    16 // Local Variables: //
    17 // tab-width: 4 //
    18 // End: //
  • benchmark/ctxswitch/cfa_thrd2.cfa

    rbdfc032 raefb247  
    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[] ) {
    16         BENCH_START()
     15int main(int argc, char* argv[]) {
    1716        Fibre f1;
    1817        BENCH(
    19                 for ( times ) {
     18                for ( i; n ) {
    2019                        yield();
    2120                },
    2221                result
    2322        )
    24         printf( "%g\n", result );
     23
     24        printf("%g\n", result);
    2525        done = true;
     26        return 0;
    2627}
    27 
    28 // Local Variables: //
    29 // tab-width: 4 //
    30 // End: //
  • benchmark/ctxswitch/goroutine.go

    rbdfc032 raefb247  
    22
    33import (
    4         "fmt"
    5         "time"
    6         "os"
    7         "strconv"
    8         "runtime"
     4    "fmt"
     5    "runtime"
     6    "time"
    97)
    108
     
    3028
    3129func main() {
    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
     30        const NoOfTimes = 10000000
     31        go ContextSwitch( NoOfTimes )           // context switch
    3632        <- shake
    3733}
    38 
    39 // Local Variables: //
    40 // tab-width: 4 //
    41 // End: //
  • benchmark/ctxswitch/kos_fibre.cpp

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

    rbdfc032 raefb247  
    1111}
    1212
    13 int main( int argc, char * argv[] ) {
    14         BENCH_START()
     13int main(int argc, char* argv[]) {
    1514        Fibre* f1 = (new Fibre)->run(f1main);
    1615        BENCH(
    17                 for (size_t i = 0; i < times; i++) {
     16                for (size_t i = 0; i < n; i++) {
    1817                        Fibre::yield();
    1918                },
    2019                result
    2120        )
    22         printf( "%g\n", result );
     21        printf("%g\n", result);
    2322        done = true;
    2423        Fibre::yield();
    2524        f1->join();
     25        return 0;
    2626}
    27 
    28 // Local Variables: //
    29 // tab-width: 4 //
    30 // End: //
  • benchmark/ctxswitch/pthreads.c

    rbdfc032 raefb247  
    66#include "bench.h"
    77
    8 int main( int argc, char * argv[] ) {
    9         BENCH_START()
     8int main(int argc, char* argv[]) {
    109        BENCH(
    11                 for (size_t i = 0; i < times; i++) {
     10                for (size_t i = 0; i < n; i++) {
    1211                        sched_yield();
    1312                },
    1413                result
    1514        )
    16         printf( "%g\n", result );
     15
     16        printf("%g\n", result);
    1717}
  • benchmark/ctxswitch/upp_cor.cc

    rbdfc032 raefb247  
    33#include "bench.h"
    44
    5 _Coroutine C {
     5_Coroutine GreatSuspender {
     6public:
     7        GreatSuspender() {
     8                resume();
     9        }
     10
     11        void do_resume() {
     12                resume();
     13        }
     14private:
    615        void main() {
    716                while( true ) {
     
    918                }
    1019        }
    11   public:
    12         void do_resume() {
    13                 resume();
    14         }
    15 } c;
    16 int main( int argc, char * argv[] ) {
    17         BENCH_START()
     20};
     21
     22int main(int argc, char* argv[]) {
     23        GreatSuspender s;
     24
    1825        BENCH(
    19                 for (size_t i = 0; i < times; i++) {
    20                         c.do_resume();
     26                for (size_t i = 0; i < n; i++) {
     27                        s.do_resume();
    2128                },
    2229                result
    2330        )
    24         printf( "%g\n", result );
     31
     32        printf("%g\n", result);
    2533}
    26 
    27 // Local Variables: //
    28 // tab-width: 4 //
    29 // End: //
  • benchmark/ctxswitch/upp_thrd.cc

    rbdfc032 raefb247  
    33#include "bench.h"
    44
    5 int main( int argc, char * argv[] ) {
    6         BENCH_START()
     5int main(int argc, char* argv[]) {
    76        BENCH(
    8                 for (size_t i = 0; i < times; i++) {
     7                for (size_t i = 0; i < n; i++) {
    98                        uThisTask().yield();
    109                },
    1110                result
    1211        )
    13         printf( "%g\n", result );
     12
     13        printf("%g\n", result);
    1414}
    15 
    16 // Local Variables: //
    17 // tab-width: 4 //
    18 // End: //
  • benchmark/mutex/JavaThread.java

    rbdfc032 raefb247  
    2626        static int x = 2;
    2727
    28         static private int times = Integer.parseInt("100000000");
     28        static private final int NoOfTimes = 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 <= times; i += 1) {
     37                for(int i = 1; i <= NoOfTimes; i += 1) {
    3838                        x = nextRandom(x);
    3939                        j.noop();
     
    4444                helper();
    4545                long end = System.nanoTime();
    46                 System.out.println( (end - start) / times );
     46                System.out.println( (end - start) / NoOfTimes );
    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 
    5249                for (int n = Integer.parseInt("5"); --n >= 0 ; ) {
    5350                        InnerMain();
     
    5855        }
    5956}
    60 
    61 // Local Variables: //
    62 // tab-width: 4 //
    63 // End: //
  • benchmark/mutex/cfa1.cfa

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

    rbdfc032 raefb247  
    44#include "bench.h"
    55
    6 monitor M {} m1, m2;
     6monitor M {};
     7void __attribute__((noinline)) call( M & mutex m1, M & mutex m2 ) {}
    78
    8 void __attribute__((noinline)) call( M & mutex p1, M & mutex p2 ) {}
    9 
    10 int main( int argc, char * argv[] ) {
    11         BENCH_START()
     9int main(int argc, char* argv[]) {
     10        M m1, m2;
    1211        BENCH(
    13                 for ( times ) {
    14                         call( m1, m2 );
     12                for ( i; n ) {
     13                        call(m1, m2);
    1514                },
    1615                result
    1716        )
    18         printf( "%g\n", result );
     17
     18        printf("%g\n", result);
    1919}
    20 
    21 // Local Variables: //
    22 // tab-width: 4 //
    23 // End: //
  • benchmark/mutex/cfa4.cfa

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

    rbdfc032 raefb247  
    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 int main( int argc, char * argv[] ) {
    13         BENCH_START()
     12
     13int main(int argc, char* argv[]) {
    1414        BENCH(
    15                 for ( size_t i = 0; i < times; i++ ) {
     15                for (size_t i = 0; i < n; i++) {
    1616                        call();
    1717                },
    1818                result
    1919        )
    20         printf( "%g\n", result );
     20
     21        printf("%g\n", result);
    2122}
    22 
    23 // Local Variables: //
    24 // tab-width: 4 //
    25 // End: //
  • benchmark/mutex/upp.cc

    rbdfc032 raefb247  
    88};
    99
    10 int main( int argc, char * argv[] ) {
    11         BENCH_START()
     10int main(int argc, char* argv[]) {
    1211        MyMonitor m;
    1312        BENCH(
    14                 for ( size_t i = 0; i < times; i++ ) {
     13                for (size_t i = 0; i < n; i++) {
    1514                        m.call();
    1615                },
    1716                result
    1817        )
    19         printf( "%g\n", result );
     18
     19        printf("%g\n", result);
    2020}
    21 
    22 // Local Variables: //
    23 // tab-width: 4 //
    24 // End: //
  • benchmark/schedext/cfa1.cfa

    rbdfc032 raefb247  
    44#include <stdio.h>
    55
    6 #include "../bench.h"
     6#include "bench.h"
    77
    8 monitor M {} m1;
     8int argc;
     9char** argv;
     10volatile int go = 0;
    911
    10 void __attribute__((noinline)) call( M & mutex p1 ) {}
    11 void __attribute__((noinline)) wait( M & mutex p1 ) {
    12         for ( times ) {
    13                 waitfor( call : p1 );
    14         }
     12monitor M {};
     13M m1;
     14
     15void __attribute__((noinline)) call( M & mutex a1 ) {}
     16
     17int  __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;
    1529}
    1630
    1731thread T {};
     32void ^?{}( T & mutex this ) {}
    1833void main( T & ) {
    19         BENCH(
    20                 for ( times ) { call( m1 ); },
    21                 result
    22         )
    23         printf( "%g\n", result );
     34        while(go == 0) { yield(); }
     35        while(go == 1) { call(m1); }
     36
    2437}
    2538
    26 int main( int argc, char * argv[] ) {
    27         BENCH_START()
     39int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) {
    2840        T t;
    29         wait( m1 );
     41        return wait(m1);
    3042}
    31 
    32 // Local Variables: //
    33 // tab-width: 4 //
    34 // End: //
  • benchmark/schedext/cfa2.cfa

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

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

    rbdfc032 raefb247  
    33#include "bench.h"
    44
     5int argc;
     6char** argv;
     7volatile int go = 0;
     8
    59_Monitor M {
    610public:
    711        void __attribute__((noinline)) call() {}
    8         void __attribute__((noinline)) wait() {
    9                 for ( size_t i = 0; i < times; i++ ) {
    10                         _Accept(call);
    11                 }
     12
     13        int __attribute__((noinline)) wait() {
     14                go = 1;
     15                BENCH(
     16                        for (size_t i = 0; i < n; i++) {
     17                                _Accept(call);
     18                        },
     19                        result
     20                )
     21
     22                printf("%g\n", result);
     23                go = 0;
     24                return 0;
    1225        }
    13 } m;
     26};
     27
     28M m;
    1429
    1530_Task T {
    1631        void main() {
    17                 BENCH(
    18                         for ( size_t i = 0; i < times; i++ ) {
    19                                 m.call();
    20                         },
    21                         result
    22                 )
    23                 printf( "%g\n", result );
     32                while(go == 0) { yield(); }
     33                while(go == 1) { m.call(); }
     34
    2435        }
    2536};
    2637
    27 int main( int argc, char * argv[] ) {
    28         BENCH_START()
     38int main(int margc, char* margv[]) {
     39        argc = margc;
     40        argv = margv;
    2941        T t;
    30         m.wait();
     42        return m.wait();
    3143}
    32 
    33 // Local Variables: //
    34 // tab-width: 4 //
    35 // End: //
  • benchmark/schedint/JavaThread.java

    rbdfc032 raefb247  
    4949        static int x = 2;
    5050
    51         static private int times = Integer.parseInt("1000000");
     51        static private final int NoOfTimes = Integer.parseInt("1000000") ;
    5252
    5353        public static void helper( Monitor m ) throws InterruptedException {
    54                 for(int i = 1; i <= times; i += 1) {
     54                for(int i = 1; i <= NoOfTimes; i += 1) {
    5555                        m.wait();               // relase monitor lock
    5656                        m.next = true;
     
    6363                synchronized(m) {
    6464                        s.start();
    65                         while( ! Monitor.go ) { // waiter must start first
     65                        while( !Monitor.go ) {
    6666                                Thread.yield();
    6767                        }
     
    7272                Monitor.go = false;
    7373                s.join();
    74                 System.out.println( (end - start) / times);
     74                System.out.println( (end - start) / NoOfTimes);
    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 
    8077                for (int n = Integer.parseInt("5"); --n >= 0 ; ) {
    8178                        InnerMain();
     
    8683        }
    8784}
    88 
    89 // Local Variables: //
    90 // tab-width: 4 //
    91 // End: //
  • benchmark/schedint/cfa1.cfa

    rbdfc032 raefb247  
    44#include <stdio.h>
    55
    6 #include "../bench.h"
     6#include "bench.h"
    77
     8int argc;
     9char** argv;
    810volatile int go = 0;
    911
    1012condition c;
    11 monitor M {} m1;
     13monitor M {};
     14M m1;
    1215
    13 void __attribute__((noinline)) call( M & mutex p1 ) {
    14         signal( c );
     16void __attribute__((noinline)) call( M & mutex a1 ) {
     17        signal(c);
    1518}
    16 void __attribute__((noinline)) wait( M & mutex p1 ) {
     19
     20int  __attribute__((noinline)) wait( M & mutex a1 ) {
    1721        go = 1;
    18         for ( times ) {
    19                 wait( c );
    20         }
     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;
    2132}
    2233
    2334thread T {};
     35void ^?{}( T & mutex ) {}
    2436void main( T & ) {
    25         while ( go == 0 ) { yield(); } // waiter must start first
    26         BENCH(
    27                 for ( times ) { call( m1 ); },
    28                 result
    29         )
    30         printf( "%g\n", result );
     37        while(go == 0) { yield(); }
     38        while(go == 1) { call(m1); }
     39
    3140}
    3241
    33 int main( int argc, char * argv[] ) {
    34         BENCH_START()
     42int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) {
    3543        T t;
    36         wait( m1 );
     44        return wait(m1);
    3745}
    38 
    39 // Local Variables: //
    40 // tab-width: 4 //
    41 // End: //
  • benchmark/schedint/cfa2.cfa

    rbdfc032 raefb247  
    44#include <stdio.h>
    55
    6 #include "../bench.h"
     6#include "bench.h"
    77
     8int argc;
     9char** argv;
    810volatile int go = 0;
    911
    1012condition c;
    11 monitor M {} m1, m2;
     13monitor M {};
     14M m1, m2;
    1215
    13 void __attribute__((noinline)) call( M & mutex p1, M & mutex p2 ) {
    14         signal( c );
     16void __attribute__((noinline)) call( M & mutex a1, M & mutex a2 ) {
     17        signal(c);
    1518}
    16 void __attribute__((noinline)) wait( M & mutex p1, M & mutex p2 ) {
     19
     20int  __attribute__((noinline)) wait( M & mutex a1, M & mutex a2 ) {
    1721        go = 1;
    18         for ( times ) {
    19                 wait( c );
    20         }
     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;
    2132}
    2233
    2334thread T {};
     35void ^?{}( T & mutex this ) {}
    2436void main( T & ) {
    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 );
     37        while(go == 0) { yield(); }
     38        while(go == 1) { call(m1, m2); }
     39
    3140}
    3241
    33 int main( int argc, char * argv[] ) {
    34         BENCH_START()
     42int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) {
    3543        T t;
    36         wait( m1, m2 );
     44        return wait(m1, m2);
    3745}
    38 
    39 // Local Variables: //
    40 // tab-width: 4 //
    41 // End: //
  • benchmark/schedint/cfa4.cfa

    rbdfc032 raefb247  
    44#include <stdio.h>
    55
    6 #include "../bench.h"
     6#include "bench.h"
    77
     8int argc;
     9char** argv;
    810volatile int go = 0;
    911
    1012condition c;
    11 monitor M {} m1, m2, m3, m4;
     13monitor M {};
     14M m1, m2, m3, m4;
    1215
    13 void __attribute__((noinline)) call( M & mutex p1, M & mutex p2, M & mutex p3, M & mutex p4 ) {
    14         signal( c );
     16void __attribute__((noinline)) call( M & mutex a1, M & mutex a2, M & mutex a3, M & mutex a4 ) {
     17        signal(c);
    1518}
    16 void __attribute__((noinline)) wait( M & mutex p1, M & mutex p2, M & mutex p3, M & mutex p4 ) {
     19
     20int  __attribute__((noinline)) wait( M & mutex a1, M & mutex a2, M & mutex a3, M & mutex a4 ) {
    1721        go = 1;
    18         for ( times ) {
    19                 wait( c );
    20         }
     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;
    2132}
    2233
    2334thread T {};
     35void ^?{}( T & mutex this ) {}
    2436void main( T & ) {
    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 );
     37        while(go == 0) { yield(); }
     38        while(go == 1) { call(m1, m2, m3, m4); }
     39
    3140}
    3241
    33 int main( int argc, char * argv[] ) {
    34         BENCH_START()
     42int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) {
    3543        T t;
    36         wait( m1, m2, m3, m4 );
     44        return wait(m1, m2, m3, m4);
    3745}
    38 
    39 // Local Variables: //
    40 // tab-width: 4 //
    41 // End: //
  • benchmark/schedint/pthreads.c

    rbdfc032 raefb247  
    44#include "bench.h"
    55
     6int argc;
     7char** argv;
    68volatile int go = 0;
    79
     10pthread_cond_t c;
    811pthread_mutex_t m;
    9 pthread_cond_t c;
    1012
    1113void __attribute__((noinline)) call() {
    12         pthread_mutex_lock( &m );
    13         pthread_cond_signal( &c );
    14         pthread_mutex_unlock( &m );
     14        pthread_mutex_lock(&m);
     15        pthread_cond_signal(&c);
     16        pthread_mutex_unlock(&m);
    1517}
    1618
    17 void __attribute__((noinline)) wait() {
     19int __attribute__((noinline)) wait() {
    1820        pthread_mutex_lock(&m);
    1921        go = 1;
    20         for ( size_t i = 0; i < times; i++ ) {
    21                 pthread_cond_wait( &c, &m );
    22         }
     22        BENCH(
     23                for (size_t i = 0; i < n; i++) {
     24                        pthread_cond_wait(&c, &m);
     25                },
     26                result
     27        )
     28
     29        printf("%g\n", result);
    2330        go = 0;
    24         pthread_mutex_unlock( &m );
     31        pthread_mutex_unlock(&m);
     32        return 0;
    2533}
    2634
    27 void * 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
    30         BENCH(
    31                 while ( go == 1 ) { call(); },
    32                 result
    33         )
    34         printf( "%g\n", result );
     35void* thread_main(__attribute__((unused)) void * arg ) {
     36        while(go == 0) { sched_yield(); }
     37        while(go == 1) { call(); }
    3538        return NULL;
    3639}
    3740
    38 int main( int argc, char * argv[] ) {
    39         BENCH_START()
     41int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) {
    4042        pthread_t thread;
    41         if ( pthread_create( &thread, NULL, thread_main, NULL ) < 0 ) {
     43        if (pthread_create(&thread, NULL, thread_main, NULL) < 0) {
    4244                perror( "failure" );
    4345                return 1;
    4446        }
    4547        wait();
    46         if ( pthread_join( thread, NULL ) < 0 ) {
     48        if (pthread_join( thread, NULL) < 0) {
    4749                perror( "failure" );
    4850                return 1;
    4951        }
     52        return 0;
    5053}
    51 
    52 // Local Variables: //
    53 // tab-width: 4 //
    54 // End: //
  • benchmark/schedint/upp.cc

    rbdfc032 raefb247  
    33#include "bench.h"
    44
     5int argc;
     6char** argv;
    57volatile int go = 0;
    68
     
    1113                cond.signal();
    1214        }
    13         void __attribute__((noinline)) wait() {
     15
     16        int __attribute__((noinline)) wait() {
    1417                go = 1;
    15                 for ( size_t i = 0; i < times; i++ ) {
    16                         cond.wait();
    17                 }
     18                BENCH(
     19                        for (size_t i = 0; i < n; i++) {
     20                                cond.wait();
     21                        },
     22                        result
     23                )
     24
     25                printf("%g\n", result);
     26                go = 0;
     27                return 0;
    1828        }
    19 } m;
     29};
     30
     31M m;
    2032
    2133_Task T {
    2234        void main() {
    23                 while ( go == 0 ) { yield(); } // waiter must start first
    24                 BENCH(
    25                         for ( size_t i = 0; i < times; i++ ) {
    26                                 m.call();
    27                         },
    28                         result
    29                 )
    30                 printf( "%g\n", result );
     35                while(go == 0) { yield(); }
     36                while(go == 1) { m.call(); }
     37
    3138        }
    3239};
    3340
    34 int main( int argc, char * argv[] ) {
    35         BENCH_START()
     41int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) {
    3642        T t;
    37         m.wait();
     43        return m.wait();
    3844}
    39 
    40 // Local Variables: //
    41 // tab-width: 4 //
    42 // End: //
  • driver/cfa.cc

    rbdfc032 raefb247  
    1010// Created On       : Tue Aug 20 13:44:49 2002
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jan 31 16:48:03 2020
    13 // Update Count     : 421
     12// Last Modified On : Tue Sep 10 17:00:15 2019
     13// Update Count     : 420
    1414//
    1515
     
    187187                        } else if ( arg == "-XCFA" ) {                          // CFA pass through
    188188                                i += 1;
    189                                 if ( i == argc ) continue;                              // next argument available ?
    190189                                Putenv( argv, argv[i] );
    191190
  • libcfa/src/Makefile.in

    rbdfc032 raefb247  
    425425am__v_CFA_0 = @echo "  CFA     " $@;
    426426am__v_CFA_1 =
     427AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
     428am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
     429am__v_JAVAC_0 = @echo "  JAVAC   " $@;
     430am__v_JAVAC_1 =
     431AM_V_GOC = $(am__v_GOC_@AM_V@)
     432am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)
     433am__v_GOC_0 = @echo "  GOC     " $@;
     434am__v_GOC_1 =
    427435UPPCC = u++
    428436UPPCOMPILE = $(UPPCC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_UPPFLAGS) $(UPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_CFLAGS) $(CFLAGS)
     
    431439am__v_UPP_0 = @echo "  UPP     " $@;
    432440am__v_UPP_1 =
    433 AM_V_GOC = $(am__v_GOC_@AM_V@)
    434 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)
    435 am__v_GOC_0 = @echo "  GOC     " $@;
    436 am__v_GOC_1 =
    437 AM_V_RUST = $(am__v_RUST_@AM_V@)
    438 am__v_RUST_ = $(am__v_RUST_@AM_DEFAULT_V@)
    439 am__v_RUST_0 = @echo "  RUST     " $@;
    440 am__v_RUST_1 =
    441 AM_V_NODEJS = $(am__v_NODEJS_@AM_V@)
    442 am__v_NODEJS_ = $(am__v_NODEJS_@AM_DEFAULT_V@)
    443 am__v_NODEJS_0 = @echo "  NODEJS     " $@;
    444 am__v_NODEJS_1 =
    445 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
    446 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
    447 am__v_JAVAC_0 = @echo "  JAVAC   " $@;
    448 am__v_JAVAC_1 =
    449441lib_LTLIBRARIES = libcfa.la libcfathread.la
    450442gdbwaittarget = ""
  • libcfa/src/bits/containers.hfa

    rbdfc032 raefb247  
    1010// Created On       : Tue Oct 31 16:38:50 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jan 15 07:42:35 2020
    13 // Update Count     : 28
     12// Last Modified On : Wed Jun 26 08:52:20 2019
     13// Update Count     : 4
    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 ) {
     55        forall(dtype T | sized(T))
     56        static inline T* begin( const __small_array(T) & this ) {
    5757                return ((typeof(this.data))this.data);
    5858        }
    5959
    6060        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){ 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                 }
     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;
    121122        }
    122123#endif
     
    144145
    145146#ifdef __cforall
    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;
     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;
    166168                        }
    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                 }
     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;
    190195        }
    191196#endif
     
    218223
    219224#ifdef __cforall
    220         forall(dtype T )
     225
     226        forall(dtype T | sized(T))
    221227        static inline [void] ?{}( __dllist(T) & this, * [T * & next, T * & prev] ( T & ) __get ) {
    222                 this.head{ 0p };
     228                this.head{ NULL };
    223229                this.__get = __get;
    224230        }
     
    226232        #define next 0
    227233        #define prev 1
    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 
     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
    245241                        // prevent code movement across barrier
    246242                        asm( "" : : : "memory" );
    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                                 }
     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;
    258263                        }
    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                 }
     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;
    268277        }
    269278        #undef next
     
    277286
    278287#endif
    279 
    280 // Local Variables: //
    281 // tab-width: 4 //
    282 // End: //
  • libcfa/src/bits/defs.hfa

    rbdfc032 raefb247  
    1010// Created On       : Thu Nov  9 13:24:10 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jan 28 22:38:27 2020
    13 // Update Count     : 9
     12// Last Modified On : Thu Feb  8 16:22:41 2018
     13// Update Count     : 8
    1414//
    1515
     
    3434
    3535#ifdef __cforall
    36 void abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
    37 void abort( bool signalAbort, const char fmt[], ... ) __attribute__ (( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ ));
     36void abort ( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
    3837extern "C" {
    3938#endif
  • libcfa/src/bits/signal.hfa

    rbdfc032 raefb247  
    4040        sigaddset( &act.sa_mask, SIGALRM );             // disabled during signal handler
    4141        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 );
    4942        act.sa_flags = flags;
    5043
    51         if ( sigaction( sig, &act, 0p ) == -1 ) {
     44        if ( sigaction( sig, &act, NULL ) == -1 ) {
    5245                __cfaabi_dbg_print_buffer_decl(
    5346                        " __cfaabi_sigaction( sig:%d, handler:%p, flags:%d ), problem installing signal handler, error(%d) %s.\n",
     
    5548                );
    5649                _exit( EXIT_FAILURE );
    57         } // if
     50        }
    5851}
     52
     53// Sigaction wrapper : restore default handler
     54static void __cfaabi_sigdefault( int sig ) {
     55        struct sigaction act;
     56
     57        act.sa_handler = SIG_DFL;
     58        act.sa_flags = 0;
     59        sigemptyset( &act.sa_mask );
     60
     61        if ( sigaction( sig, &act, NULL ) == -1 ) {
     62                __cfaabi_dbg_print_buffer_decl(
     63                        " __cfaabi_sigdefault( sig:%d ), problem reseting signal handler, error(%d) %s.\n",
     64                        sig, errno, strerror( errno )
     65                );
     66                _exit( EXIT_FAILURE );
     67        }
     68}
  • libcfa/src/clock.hfa

    rbdfc032 raefb247  
    1010// Created On       : Thu Apr 12 14:36:06 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan  6 12:49:58 2020
    13 // Update Count     : 9
     12// Last Modified On : Thu Jun 13 21:21:13 2019
     13// Update Count     : 8
    1414//
    1515
    1616#include <time.hfa>
     17
    1718
    1819//######################### C time #########################
     
    2526static inline tm * localtime_r( time_t tp, tm * result ) { return localtime_r( &tp, result ); }
    2627
     28
    2729//######################### Clock #########################
    2830
    2931struct Clock {                                                                                  // private
    3032        Duration offset;                                                                        // for virtual clock: contains offset from real-time
     33        int clocktype;                                                                          // implementation only -1 (virtual), CLOCK_REALTIME
    3134};
    3235
    3336static inline {
     37        void resetClock( Clock & clk ) with( clk ) {
     38                clocktype = CLOCK_REALTIME_COARSE;
     39        } // Clock::resetClock
     40
    3441        void resetClock( Clock & clk, Duration adj ) with( clk ) {
     42                clocktype = -1;
    3543                offset = adj + __timezone`s;                                    // timezone (global) is (UTC - local time) in seconds
    3644        } // resetClock
    3745
     46        void ?{}( Clock & clk ) { resetClock( clk ); }
    3847        void ?{}( Clock & clk, Duration adj ) { resetClock( clk, adj ); }
    3948
     
    8089                return ret;
    8190        } // getTime
    82 
    83         Time getCPUTime() {
    84                 timespec ts;
    85                 clock_gettime( CLOCK_THREAD_CPUTIME_ID, &ts );
    86                 return (Time){ ts };
    87     } // getCPUTime
    8891} // distribution
    8992
  • libcfa/src/concurrency/CtxSwitch-x86_64.S

    rbdfc032 raefb247  
    8787CtxInvokeStub:
    8888        movq %rbx, %rdi
    89         movq %r12, %rsi
    90         jmp *%r13
     89        jmp *%r12
    9190        .size  CtxInvokeStub, .-CtxInvokeStub
    9291
  • libcfa/src/concurrency/alarm.cfa

    rbdfc032 raefb247  
    1010// Created On       : Fri Jun 2 11:31:25 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jan  5 08:41:36 2020
    13 // Update Count     : 69
     12// Last Modified On : Tue Dec  3 22:47:24 2019
     13// Update Count     : 68
    1414//
    1515
     
    3939
    4040void __kernel_set_timer( Duration alarm ) {
    41         verifyf(alarm >= 1`us || alarm == 0, "Setting timer to < 1us (%jins)", alarm`ns);
     41        verifyf(alarm >= 1`us || alarm == 0, "Setting timer to < 1us (%jins)", alarm.tv);
    4242        setitimer( ITIMER_REAL, &(itimerval){ alarm }, 0p );
    4343}
  • libcfa/src/concurrency/coroutine.cfa

    rbdfc032 raefb247  
    187187// is not inline (We can't inline Cforall in C)
    188188extern "C" {
    189         void __leave_coroutine( struct coroutine_desc * src ) {
     189        void __suspend_internal(void) {
     190                suspend();
     191        }
     192
     193        void __leave_coroutine( coroutine_desc * src ) {
    190194                coroutine_desc * starter = src->cancellation != 0 ? src->last : src->starter;
    191195
     
    203207                CoroutineCtxSwitch( src, starter );
    204208        }
    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         }
    217209}
    218210
  • libcfa/src/concurrency/coroutine.hfa

    rbdfc032 raefb247  
    6161// Start coroutine routines
    6262extern "C" {
    63         void CtxInvokeCoroutine(void (*main)(void *), void * this);
     63      forall(dtype T | is_coroutine(T))
     64      void CtxInvokeCoroutine(T * this);
    6465
    65         forall(dtype T)
    66         void CtxStart(void (*main)(T &), struct coroutine_desc * cor, T & this, void (*invoke)(void (*main)(void *), void *));
     66      forall(dtype T | is_coroutine(T))
     67      void CtxStart(T * this, void ( *invoke)(T *));
    6768
    6869        extern void _CtxCoroutine_Unwind(struct _Unwind_Exception * storage, struct coroutine_desc *) __attribute__ ((__noreturn__));
     
    128129
    129130        if( unlikely(dst->context.SP == 0p) ) {
    130                 TL_GET( this_thread )->curr_cor = dst;
    131131                __stack_prepare(&dst->stack, 65000);
    132                 CtxStart(main, dst, cor, CtxInvokeCoroutine);
    133                 TL_GET( this_thread )->curr_cor = src;
     132                CtxStart(&cor, CtxInvokeCoroutine);
    134133        }
    135134
  • libcfa/src/concurrency/invoke.c

    rbdfc032 raefb247  
    2929// Called from the kernel when starting a coroutine or task so must switch back to user mode.
    3030
    31 extern void __leave_coroutine ( struct coroutine_desc * );
    32 extern struct coroutine_desc * __finish_coroutine(void);
    33 extern void __leave_thread_monitor();
     31extern void __suspend_internal(void);
     32extern void __leave_coroutine( struct coroutine_desc * );
     33extern void __finish_creation( struct thread_desc * );
     34extern void __leave_thread_monitor( struct thread_desc * this );
    3435extern void disable_interrupts() OPTIONAL_THREAD;
    3536extern void enable_interrupts( __cfaabi_dbg_ctx_param );
     
    3738void CtxInvokeCoroutine(
    3839        void (*main)(void *),
     40        struct coroutine_desc *(*get_coroutine)(void *),
    3941        void *this
    4042) {
    41         // Finish setting up the coroutine by setting its state
    42         struct coroutine_desc * cor = __finish_coroutine();
     43        struct coroutine_desc* cor = get_coroutine( this );
    4344
    44         // Call the main of the coroutine
     45        if(cor->state == Primed) {
     46                __suspend_internal();
     47        }
     48
     49        cor->state = Active;
     50
    4551        main( this );
    4652
     
    7783
    7884void CtxInvokeThread(
     85        void (*dtor)(void *),
    7986        void (*main)(void *),
     87        struct thread_desc *(*get_thread)(void *),
    8088        void *this
    8189) {
     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
    8297        // Officially start the thread by enabling preemption
    8398        enable_interrupts( __cfaabi_dbg_ctx );
     
    93108        // The order of these 4 operations is very important
    94109        //Final suspend, should never return
    95         __leave_thread_monitor();
     110        __leave_thread_monitor( thrd );
    96111        __cabi_abort( "Resumed dead thread" );
    97112}
    98113
     114
    99115void CtxStart(
    100116        void (*main)(void *),
    101         struct coroutine_desc * cor,
     117        struct coroutine_desc *(*get_coroutine)(void *),
    102118        void *this,
    103119        void (*invoke)(void *)
    104120) {
     121        struct coroutine_desc * cor = get_coroutine( this );
    105122        struct __stack_t * stack = cor->stack.storage;
    106123
     
    121138
    122139        fs->dummyReturn = NULL;
    123         fs->argument[0] = main;     // argument to invoke
    124         fs->argument[1] = this;     // argument to invoke
     140        fs->argument[0] = this;     // argument to invoke
    125141        fs->rturn = invoke;
    126142
     
    140156        fs->dummyReturn = NULL;
    141157        fs->rturn = CtxInvokeStub;
    142         fs->fixedRegisters[0] = main;
    143         fs->fixedRegisters[1] = this;
    144         fs->fixedRegisters[2] = invoke;
     158        fs->fixedRegisters[0] = this;
     159        fs->fixedRegisters[1] = invoke;
    145160
    146161#elif defined( __ARM_ARCH )
    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)
     162
    148163        struct FakeStack {
    149164                float fpRegs[16];                       // floating point registers
  • libcfa/src/concurrency/kernel.cfa

    rbdfc032 raefb247  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jan 30 22:55:50 2020
    13 // Update Count     : 56
     12// Last Modified On : Thu Dec  5 16:25:52 2019
     13// Update Count     : 52
    1414//
    1515
     
    469469        );
    470470
    471         Abort( pthread_attr_setstack( &attr, stack, stacksize ), "pthread_attr_setstack" );
     471        Abort( pthread_attr_setstack( &attr, stack, stacksize ), "pthread_attr_setstack" ); 
    472472
    473473        Abort( pthread_create( pthread, &attr, start, arg ), "pthread_create" );
     
    490490        verify( ! kernelTLS.preemption_state.enabled );
    491491
    492         kernelTLS.this_thread->curr_cor = dst;
    493492        __stack_prepare( &dst->stack, 65000 );
    494         CtxStart(main, dst, this->runner, CtxInvokeCoroutine);
     493        CtxStart(&this->runner, CtxInvokeCoroutine);
    495494
    496495        verify( ! kernelTLS.preemption_state.enabled );
     
    506505        CtxSwitch( &src->context, &dst->context );
    507506        // when CtxSwitch returns we are back in the src coroutine
    508 
    509         mainThread->curr_cor = &mainThread->self_cor;
    510507
    511508        // set state of new coroutine to active
     
    844841                sigemptyset( &mask );
    845842                sigaddset( &mask, SIGALRM );            // block SIGALRM signals
    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
     843                sigsuspend( &mask );                    // block the processor to prevent further damage during abort
     844                _exit( EXIT_FAILURE );                  // if processor unblocks before it is killed, terminate it
    849845        }
    850846        else {
  • libcfa/src/concurrency/kernel_private.hfa

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

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

    rbdfc032 raefb247  
    5858void ?{}( scoped(T)& this ) with( this ) {
    5959        handle{};
    60         __thrd_start(handle, main);
     60        __thrd_start(handle);
    6161}
    6262
     
    6464void ?{}( scoped(T)& this, P params ) with( this ) {
    6565        handle{ params };
    66         __thrd_start(handle, main);
     66        __thrd_start(handle);
    6767}
    6868
     
    7575// Starting and stopping threads
    7676forall( dtype T | is_thread(T) )
    77 void __thrd_start( T & this, void (*main_p)(T &) ) {
     77void __thrd_start( T& this ) {
    7878        thread_desc * this_thrd = get_thread(this);
    7979        thread_desc * curr_thrd = TL_GET( this_thread );
    8080
    8181        disable_interrupts();
    82         CtxStart(main_p, get_coroutine(this), this, CtxInvokeThread);
    83 
     82        CtxStart(&this, CtxInvokeThread);
    8483        this_thrd->context.[SP, FP] = this_thrd->self_cor.context.[SP, FP];
    8584        verify( this_thrd->context.SP );
    86         // CtxSwitch( &curr_thrd->context, &this_thrd->context );
     85        CtxSwitch( &curr_thrd->context, &this_thrd->context );
    8786
    8887        ScheduleThread(this_thrd);
    8988        enable_interrupts( __cfaabi_dbg_ctx );
     89}
     90
     91extern "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        }
    90100}
    91101
  • libcfa/src/concurrency/thread.hfa

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

    rbdfc032 raefb247  
    88#include <stdio.h>
    99
    10 forall( dtype T )
    11 monitor Buffer {                                        // unbounded buffer
    12     __queue_t( T ) queue;                               // unbounded list of work requests
    13     condition delay;
    14 }; // Buffer
    15 forall( dtype T | is_node(T) ) {
     10forall( 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
    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.head != 0 ) wait( delay );                   // no request to process ? => wait
    23 //      return pop_head( queue );
     22        if ( ! queue ) wait( delay );                   // no request to process ? => wait
     23        return pop_head( queue );
    2424    } // remove
    2525} // distribution
  • libcfa/src/interpose.cfa

    rbdfc032 raefb247  
    1010// Created On       : Wed Mar 29 16:10:31 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jan 30 17:47:32 2020
    13 // Update Count     : 156
     12// Last Modified On : Fri Dec 13 13:45:21 2019
     13// Update Count     : 121
    1414//
    1515
     
    9595        void __cfaabi_interpose_startup(void)  __attribute__(( constructor( STARTUP_PRIORITY_CORE ) ));
    9696        void __cfaabi_interpose_startup( void ) {
    97                 const char *version = 0p;
     97                const char *version = NULL;
    9898
    9999                preload_libgcc();
     
    105105#pragma GCC diagnostic pop
    106106
    107                 // As a precaution (and necessity), errors that result in termination are delivered on a separate stack because
    108                 // task stacks might be very small (4K) and the signal delivery corrupts memory to the point that a clean
    109                 // shutdown is impossible. Also, when a stack overflow encounters the non-accessible sentinel page (debug only)
    110                 // and generates a segment fault, the signal cannot be delivered on the sentinel page. Finally, calls to abort
    111                 // print a stack trace that uses substantial stack space.
    112 
    113                 #define MINSTKSZ SIGSTKSZ * 8
    114                 static char stack[MINSTKSZ] __attribute__(( aligned (16) ));
    115                 static stack_t ss;
    116 
    117                 ss.ss_sp = stack;
    118                 ss.ss_size = MINSTKSZ;
    119                 ss.ss_flags = 0;
    120                 if ( sigaltstack( &ss, 0p ) == -1 ) {
    121                         abort( "__cfaabi_interpose_startup : internal error, sigaltstack error(%d) %s.", errno, strerror( errno ) );
    122                 } // if
    123 
    124107                // Failure handler
    125                 __cfaabi_sigaction( SIGSEGV, sigHandler_segv, SA_SIGINFO | SA_ONSTACK );
    126                 __cfaabi_sigaction( SIGBUS , sigHandler_segv, SA_SIGINFO | SA_ONSTACK );
    127                 __cfaabi_sigaction( SIGILL , sigHandler_ill , SA_SIGINFO | SA_ONSTACK );
    128                 __cfaabi_sigaction( SIGFPE , sigHandler_fpe , SA_SIGINFO | SA_ONSTACK );
    129                 __cfaabi_sigaction( SIGTERM, sigHandler_term, SA_SIGINFO | SA_ONSTACK | SA_RESETHAND ); // one shot handler, return to default
    130                 __cfaabi_sigaction( SIGINT , sigHandler_term, SA_SIGINFO | SA_ONSTACK | SA_RESETHAND );
    131                 __cfaabi_sigaction( SIGABRT, sigHandler_term, SA_SIGINFO | SA_ONSTACK | SA_RESETHAND );
    132                 __cfaabi_sigaction( SIGHUP , sigHandler_term, SA_SIGINFO | SA_ONSTACK | SA_RESETHAND ); // terminal hangup
     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 );
    133115        }
    134116}
     
    141123void exit( int status, const char fmt[], ... ) __attribute__(( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ ));
    142124void abort( const char fmt[], ... ) __attribute__(( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
    143 void abort( bool signalAbort, const char fmt[], ... ) __attribute__(( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ ));
    144125
    145126extern "C" {
    146127        void abort( void ) __attribute__(( __nothrow__, __leaf__, __noreturn__ )) {
    147                 abort( false, NULL ); // FIX ME: 0p does not work
     128                abort( NULL );
    148129        }
    149130
     
    151132                va_list argp;
    152133                va_start( argp, fmt );
    153                 abort( false, fmt, argp );
     134                abort( fmt, argp );
    154135                va_end( argp );
    155136        }
     
    160141}
    161142
    162 void * kernel_abort( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return 0p; }
    163 void kernel_abort_msg( void * data, char * buffer, int size ) __attribute__(( __nothrow__, __leaf__, __weak__ )) {}
    164 // See concurrency/kernel.cfa for strong definition used in multi-processor mode.
     143void * kernel_abort    ( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return NULL; }
     144void   kernel_abort_msg( void * data, char * buffer, int size ) __attribute__(( __nothrow__, __leaf__, __weak__ )) {}
    165145int kernel_abort_lastframe( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return 4; }
    166146
    167147enum { abort_text_size = 1024 };
    168148static char abort_text[ abort_text_size ];
    169 
    170 static void __cfaabi_backtrace( int start ) {
     149static int abort_lastframe;
     150
     151void 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
     159void 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_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_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_write( "\n", 1 );
     177                }
     178        }
     179
     180        kernel_abort_msg( kernel_data, abort_text, abort_text_size );
     181        __cabi_libc.abort();
     182}
     183
     184static void __cfaabi_backtrace() {
    171185        enum {
    172186                Frames = 50,                                                                    // maximum number of stack frames
     187                Start = 8,                                                                              // skip first N stack frames
    173188        };
    174         int last = kernel_abort_lastframe();                            // skip last N stack frames
    175189
    176190        void * array[Frames];
     
    178192        char ** messages = backtrace_symbols( array, size );
    179193
    180         *index( messages[0], '(' ) = '\0';                                      // find executable name
     194        // find executable name
     195        *index( messages[0], '(' ) = '\0';
    181196        __cfaabi_bits_print_nolock( STDERR_FILENO, "Stack back trace for: %s\n", messages[0]);
    182197
    183         for ( unsigned int i = start; i < size - last && messages != 0p; i += 1 ) {
     198        for ( int i = Start; i < size - abort_lastframe && messages != 0p; i += 1 ) {
    184199                char * name = 0p, * offset_begin = 0p, * offset_end = 0p;
    185200
    186                 for ( char * p = messages[i]; *p; ++p ) {               // find parantheses and +offset
     201                for ( char * p = messages[i]; *p; ++p ) {
    187202                        //__cfaabi_bits_print_nolock( "X %s\n", p);
     203                        // find parantheses and +offset
    188204                        if ( *p == '(' ) {
    189205                                name = p;
     
    196212                }
    197213
    198                 // if line contains symbol, print it
    199                 int frameNo = i - start;
     214                // if line contains symbol print it
     215                int frameNo = i - Start;
    200216                if ( name && offset_begin && offset_end && name < offset_begin ) {
    201                         *name++ = '\0';                                                         // delimit strings
     217                        // delimit strings
     218                        *name++ = '\0';
    202219                        *offset_begin++ = '\0';
    203220                        *offset_end++ = '\0';
     
    211228}
    212229
    213 void exit( int status, const char fmt[], ... ) {
    214         va_list args;
    215         va_start( args, fmt );
    216         vfprintf( stderr, fmt, args );
    217         va_end( args );
    218         __cabi_libc.exit( status );
    219 }
    220 
    221 void abort( bool signalAbort, const char fmt[], ... ) {
    222         void * kernel_data = kernel_abort();                            // must be done here to lock down kernel
    223         int len;
    224 
    225         signal( SIGABRT, SIG_DFL );                                                     // prevent final "real" abort from recursing to handler
    226 
    227         len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid)
    228         __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
    229 
    230         if ( fmt ) {
    231                 va_list args;
    232                 va_start( args, fmt );
    233 
    234                 len = vsnprintf( abort_text, abort_text_size, fmt, args );
    235                 va_end( args );
    236                 __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
    237 
    238                 if ( fmt[strlen( fmt ) - 1] != '\n' ) {                 // add optional newline if missing at the end of the format text
    239                         __cfaabi_dbg_write( "\n", 1 );
    240                 }
    241         }
    242 
    243         kernel_abort_msg( kernel_data, abort_text, abort_text_size );
    244         __cfaabi_backtrace( signalAbort ? 4 : 3 );
    245 
    246         __cabi_libc.abort();                                                            // print stack trace in handler
    247 }
    248 
    249 void abort( const char fmt[], ... ) {
    250         va_list args;
    251         va_start( args, fmt );
    252         abort( false, fmt, args );
    253         va_end( args );
    254 }
    255 
    256230void sigHandler_segv( __CFA_SIGPARMS__ ) {
    257                 if ( sfp->si_addr == 0p ) {
    258                         abort( true, "Null pointer (0p) dereference.\n" );
     231                if ( sfp->si_addr == NULL ) {
     232                        abort( "Null pointer (0p) dereference.\n" );
    259233                } else {
    260                         abort( true, "%s at memory location %p.\n"
     234                        abort( "%s at memory location %p.\n"
    261235                                   "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",
    262236                                   (sig == SIGSEGV ? "Segment fault" : "Bus error"), sfp->si_addr );
     
    265239
    266240void sigHandler_ill( __CFA_SIGPARMS__ ) {
    267         abort( true, "Executing illegal instruction at location %p.\n"
     241        abort( "Executing illegal instruction at location %p.\n"
    268242                        "Possible cause is stack corruption.\n",
    269243                        sfp->si_addr );
     
    281255          default: msg = "unknown";
    282256        } // choose
    283         abort( true, "Computation error %s at location %p.\n", msg, sfp->si_addr );
     257        abort( "Computation error %s at location %p.\n", msg, sfp->si_addr );
     258}
     259
     260void sigHandler_abrt( __CFA_SIGPARMS__ ) {
     261        __cfaabi_backtrace();
     262
     263        // reset default signal handler
     264        __cfaabi_sigdefault( SIGABRT );
     265
     266        raise( SIGABRT );
    284267}
    285268
    286269void sigHandler_term( __CFA_SIGPARMS__ ) {
    287         abort( true, "Application interrupted by signal: %s.\n", strsignal( sig ) );
     270        abort( "Application stopped by %s signal.", sig == SIGINT ? "an interrupt (SIGINT)" : "a terminate (SIGTERM)" );
    288271}
    289272
  • libcfa/src/startup.cfa

    rbdfc032 raefb247  
    1010// Created On       : Tue Jul 24 16:21:57 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Dec 13 13:16:45 2019
    13 // Update Count     : 29
     12// Last Modified On : Sat Nov 30 07:07:56 2019
     13// Update Count     : 13
    1414//
    1515
     16#include "startup.hfa"
    1617#include <time.h>                                                                               // tzset
    17 #include "startup.hfa"
    1818
    1919extern "C" {
    20     void __cfaabi_appready_startup( void ) __attribute__(( constructor( STARTUP_PRIORITY_APPREADY ) ));
     20    static void __cfaabi_appready_startup( void ) __attribute__(( constructor( STARTUP_PRIORITY_APPREADY ) ));
    2121    void __cfaabi_appready_startup( void ) {
    2222                tzset();                                                                                // initialize time global variables
     
    2727    } // __cfaabi_appready_startup
    2828
    29     void __cfaabi_appready_shutdown( void ) __attribute__(( destructor( STARTUP_PRIORITY_APPREADY ) ));
     29    static void __cfaabi_appready_shutdown( void ) __attribute__(( destructor( STARTUP_PRIORITY_APPREADY ) ));
    3030    void __cfaabi_appready_shutdown( void ) {
    3131                #ifdef __CFA_DEBUG__
  • libcfa/src/stdhdr/bfdlink.h

    rbdfc032 raefb247  
    1010// Created On       : Tue Jul 18 07:26:04 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Feb  1 07:15:29 2020
    13 // Update Count     : 5
     12// Last Modified On : Sun Jul 22 13:49:30 2018
     13// Update Count     : 4
    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

    rbdfc032 raefb247  
    1010// Created On       : Tue Jul 18 07:45:00 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Feb  1 07:15:39 2020
    13 // Update Count     : 5
     12// Last Modified On : Sun Jul 22 13:49:58 2018
     13// Update Count     : 4
    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

    rbdfc032 raefb247  
    1010// Created On       : Tue Jul 18 07:55:44 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Feb  1 07:15:47 2020
    13 // Update Count     : 5
     12// Last Modified On : Sun Jul 22 13:50:24 2018
     13// Update Count     : 4
    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

    rbdfc032 raefb247  
    1010// Created On       : Mon Jul  4 23:25:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Feb  1 07:15:58 2020
    13 // Update Count     : 14
     12// Last Modified On : Thu Feb 22 18:16:07 2018
     13// Update Count     : 13
    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

    rbdfc032 raefb247  
    1010// Created On       : Thu Feb  8 23:48:16 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Feb  1 07:16:05 2020
    13 // Update Count     : 5
     12// Last Modified On : Thu Feb  8 23:50:44 2018
     13// Update Count     : 4
    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/time.cfa

    rbdfc032 raefb247  
    1010// Created On       : Tue Mar 27 13:33:14 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jan  5 17:27:40 2020
    13 // Update Count     : 69
     12// Last Modified On : Sat Jul 13 08:41:55 2019
     13// Update Count     : 65
    1414//
    1515
     
    3333forall( dtype ostype | ostream( ostype ) ) {
    3434        ostype & ?|?( ostype & os, Duration dur ) with( dur ) {
    35                 (ostype &)(os | tn / TIMEGRAN);                                 // print seconds
    36                 long int ns = (tn < 0 ? -tn : tn) % TIMEGRAN;   // compute nanoseconds
     35                (ostype &)(os | tv / TIMEGRAN);                                 // print seconds
     36                long int ns = (tv < 0 ? -tv : tv) % 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, int64_t nsec ) {
     54static void tabort( int year, int month, int day, int hour, int min, int sec, int 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 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.";
     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.";
    5757} // tabort
    5858#endif // __CFA_DEBUG__
    5959
    60 void ?{}( Time & time, int year, int month, int day, int hour, int min, int sec, int64_t nsec ) with( time ) {
     60void ?{}( Time & time, int year, int month, int day, int hour, int min, int sec, int nsec ) with( time ) {
    6161        tm tm;
    6262
    63         // Values can be in any range (+/-) but result must be in the epoch.
     63        tm.tm_isdst = -1;                                                                       // let mktime determine if alternate timezone is in effect
    6464        tm.tm_year = year - 1900;                                                       // mktime uses 1900 as its starting point
    65         // Make month in range 1-12 to match with day.
     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__
    6670        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__
    6776        tm.tm_mday = day;                                                                       // mktime uses range 1-31
    6877        tm.tm_hour = hour;
    6978        tm.tm_min = min;
    7079        tm.tm_sec = sec;
    71         tm.tm_isdst = -1;                                                                       // let mktime determine if alternate timezone is in effect
    7280        time_t epochsec = mktime( &tm );
    7381#ifdef __CFA_DEBUG__
    74         if ( epochsec <= (time_t)-1 ) {                                         // MUST BE LESS THAN OR EQUAL!
     82        if ( epochsec == (time_t)-1 ) {
    7583                tabort( year, month, day, hour, min, sec, nsec );
    7684        } // if
    7785#endif // __CFA_DEBUG__
    78         tn = (int64_t)(epochsec) * TIMEGRAN + nsec;                     // convert to nanoseconds
     86        tv = (int64_t)(epochsec) * TIMEGRAN + nsec;                     // convert to nanoseconds
    7987#ifdef __CFA_DEBUG__
    80         if ( tn > 2147483647LL * TIMEGRAN ) {                           // between 00:00:00 UTC, January 1, 1970 and 03:14:07 UTC, January 19, 2038.
     88        if ( tv > 2147483647LL * TIMEGRAN ) {                           // between 00:00:00 UTC, January 1, 1970 and 03:14:07 UTC, January 19, 2038.
    8189                tabort( year, month, day, hour, min, sec, nsec );
    8290        } // if
     
    8593
    8694char * yy_mm_dd( Time time, char * buf ) with( time ) {
    87         time_t s = tn / TIMEGRAN;
     95        time_t s = tv / TIMEGRAN;
    8896        tm tm;
    8997        gmtime_r( &s, &tm );                                                            // tm_mon <= 11, tm_mday <= 31
     
    100108
    101109char * mm_dd_yy( Time time, char * buf ) with( time ) {
    102         time_t s = tn / TIMEGRAN;
     110        time_t s = tv / TIMEGRAN;
    103111        tm tm;
    104112        gmtime_r( &s, &tm );                                                            // tm_mon <= 11, tm_mday <= 31
     
    115123
    116124char * dd_mm_yy( Time time, char * buf ) with( time ) {
    117         time_t s = tn / TIMEGRAN;
     125        time_t s = tv / TIMEGRAN;
    118126        tm tm;
    119127        gmtime_r( &s, &tm );                                                            // tm_mon <= 11, tm_mday <= 31
     
    130138
    131139size_t strftime( char * buf, size_t size, const char * fmt, Time time ) with( time ) {
    132         time_t s = tn / TIMEGRAN;
     140        time_t s = tv / TIMEGRAN;
    133141        tm tm;
    134142        gmtime_r( &s, &tm );
     
    139147        ostype & ?|?( ostype & os, Time time ) with( time ) {
    140148                char buf[32];                                                                   // at least 26
    141                 time_t s = tn / TIMEGRAN;
     149                time_t s = tv / TIMEGRAN;
    142150                ctime_r( &s, (char *)&buf );                                    // 26 characters: "Wed Jun 30 21:49:08 1993\n"
    143151                buf[24] = '\0';                                                                 // remove trailing '\n'
    144                 long int ns = (tn < 0 ? -tn : tn) % TIMEGRAN;   // compute nanoseconds
     152                long int ns = (tv < 0 ? -tv : tv) % TIMEGRAN;   // compute nanoseconds
    145153                if ( ns == 0 ) {                                                                // none ?
    146154                        (ostype &)(os | buf);                                           // print date/time/year
  • libcfa/src/time.hfa

    rbdfc032 raefb247  
    1010// Created On       : Wed Mar 14 23:18:57 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan  6 12:50:16 2020
    13 // Update Count     : 653
     12// Last Modified On : Sat Sep 22 12:25:34 2018
     13// Update Count     : 643
    1414//
    1515
     
    3232        Duration ?=?( Duration & dur, __attribute__((unused)) zero_t ) { return dur{ 0 }; }
    3333
    34         Duration +?( Duration rhs ) with( rhs ) { return (Duration)@{ +tn }; }
    35         Duration ?+?( Duration & lhs, Duration rhs ) { return (Duration)@{ lhs.tn + rhs.tn }; }
     34        Duration +?( Duration rhs ) with( rhs ) {       return (Duration)@{ +tv }; }
     35        Duration ?+?( Duration & lhs, Duration rhs ) { return (Duration)@{ lhs.tv + rhs.tv }; }
    3636        Duration ?+=?( Duration & lhs, Duration rhs ) { lhs = lhs + rhs; return lhs; }
    3737
    38         Duration -?( Duration rhs ) with( rhs ) { return (Duration)@{ -tn }; }
    39         Duration ?-?( Duration & lhs, Duration rhs ) { return (Duration)@{ lhs.tn - rhs.tn }; }
     38        Duration -?( Duration rhs ) with( rhs ) { return (Duration)@{ -tv }; }
     39        Duration ?-?( Duration & lhs, Duration rhs ) { return (Duration)@{ lhs.tv - rhs.tv }; }
    4040        Duration ?-=?( Duration & lhs, Duration rhs ) { lhs = lhs - rhs; return lhs; }
    4141
    42         Duration ?*?( Duration lhs, int64_t rhs ) { return (Duration)@{ lhs.tn * rhs }; }
    43         Duration ?*?( int64_t lhs, Duration rhs ) { return (Duration)@{ lhs * rhs.tn }; }
     42        Duration ?*?( Duration lhs, int64_t rhs ) { return (Duration)@{ lhs.tv * rhs }; }
     43        Duration ?*?( int64_t lhs, Duration rhs ) { return (Duration)@{ lhs * rhs.tv }; }
    4444        Duration ?*=?( Duration & lhs, int64_t rhs ) { lhs = lhs * rhs; return lhs; }
    4545
    46         int64_t ?/?( Duration lhs, Duration rhs ) { return lhs.tn / rhs.tn; }
    47         Duration ?/?( Duration lhs, int64_t rhs ) { return (Duration)@{ lhs.tn / rhs }; }
     46        int64_t ?/?( Duration lhs, Duration rhs ) { return lhs.tv / rhs.tv; }
     47        Duration ?/?( Duration lhs, int64_t rhs ) { return (Duration)@{ lhs.tv / rhs }; }
    4848        Duration ?/=?( Duration & lhs, int64_t rhs ) { lhs = lhs / rhs; return lhs; }
    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 }; }
     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 }; }
    5252        Duration ?%=?( Duration & lhs, Duration rhs ) { lhs = lhs % rhs; return lhs; }
    5353
    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; }
     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; }
    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.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;}
     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;}
    9595} // distribution
    9696
     
    143143//######################### Time #########################
    144144
    145 void ?{}( Time & time, int year, int month = 1, int day = 1, int hour = 0, int min = 0, int sec = 0, int64_t nsec = 0 );
     145void ?{}( Time & time, int year, int month = 0, int day = 0, int hour = 0, int min = 0, int sec = 0, int nsec = 0 );
    146146static inline {
    147147        Time ?=?( Time & time, __attribute__((unused)) zero_t ) { return time{ 0 }; }
    148148
    149         void ?{}( Time & time, timeval t ) with( time ) { tn = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * 1000; }
     149        void ?{}( Time & time, timeval t ) with( time ) { tv = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * 1000; }
    150150        Time ?=?( Time & time, timeval t ) with( time ) {
    151                 tn = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * (TIMEGRAN / 1_000_000LL);
     151                tv = (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 ) { tn = (int64_t)t.tv_sec * TIMEGRAN + t.tv_nsec; }
     155        void ?{}( Time & time, timespec t ) with( time ) { tv = (int64_t)t.tv_sec * TIMEGRAN + t.tv_nsec; }
    156156        Time ?=?( Time & time, timespec t ) with( time ) {
    157                 tn = (int64_t)t.tv_sec * TIMEGRAN + t.tv_nsec;
     157                tv = (int64_t)t.tv_sec * TIMEGRAN + t.tv_nsec;
    158158                return time;
    159159        } // ?=?
    160160
    161         Time ?+?( Time & lhs, Duration rhs ) { return (Time)@{ lhs.tn + rhs.tn }; }
     161        Time ?+?( Time & lhs, Duration rhs ) { return (Time)@{ lhs.tv + rhs.tv }; }
    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.tn - rhs.tn }; }
    166         Time ?-?( Time lhs, Duration rhs ) { return (Time)@{ lhs.tn - rhs.tn }; }
     165        Duration ?-?( Time lhs, Time rhs ) { return (Duration)@{ lhs.tv - rhs.tv }; }
     166        Time ?-?( Time lhs, Duration rhs ) { return (Time)@{ lhs.tv - rhs.tv }; }
    167167        Time ?-=?( Time & lhs, Duration rhs ) { lhs = lhs - rhs; return lhs; }
    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; }
     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; }
    176174} // distribution
    177175
     
    196194
    197195static inline void ?{}( timeval & t, Time time ) with( t, time ) {
    198         tv_sec = tn / TIMEGRAN;                                                         // seconds
    199         tv_usec = tn % TIMEGRAN / (TIMEGRAN / 1_000_000LL);     // microseconds
     196        tv_sec = tv / TIMEGRAN;                                                         // seconds
     197        tv_usec = tv % TIMEGRAN / (TIMEGRAN / 1_000_000LL);     // microseconds
    200198} // ?{}
    201199
     
    203201
    204202static inline void ?{}( timespec & t, Time time ) with( t, time ) {
    205         tv_sec = tn / TIMEGRAN;                                                         // seconds
    206         tv_nsec = tn % TIMEGRAN;                                                        // nanoseconds
     203        tv_sec = tv / TIMEGRAN;                                                         // seconds
     204        tv_nsec = tv % TIMEGRAN;                                                        // nanoseconds
    207205} // ?{}
    208206
  • libcfa/src/time_t.hfa

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

    rbdfc032 raefb247  
    492492am__v_CFA_0 = @echo "  CFA     " $@;
    493493am__v_CFA_1 =
     494AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
     495am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
     496am__v_JAVAC_0 = @echo "  JAVAC   " $@;
     497am__v_JAVAC_1 =
     498AM_V_GOC = $(am__v_GOC_@AM_V@)
     499am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)
     500am__v_GOC_0 = @echo "  GOC     " $@;
     501am__v_GOC_1 =
    494502UPPCC = u++
    495503UPPCOMPILE = $(UPPCC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_UPPFLAGS) $(UPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_CFLAGS) $(CFLAGS)
     
    498506am__v_UPP_0 = @echo "  UPP     " $@;
    499507am__v_UPP_1 =
    500 AM_V_GOC = $(am__v_GOC_@AM_V@)
    501 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)
    502 am__v_GOC_0 = @echo "  GOC     " $@;
    503 am__v_GOC_1 =
    504 AM_V_RUST = $(am__v_RUST_@AM_V@)
    505 am__v_RUST_ = $(am__v_RUST_@AM_DEFAULT_V@)
    506 am__v_RUST_0 = @echo "  RUST     " $@;
    507 am__v_RUST_1 =
    508 AM_V_NODEJS = $(am__v_NODEJS_@AM_V@)
    509 am__v_NODEJS_ = $(am__v_NODEJS_@AM_DEFAULT_V@)
    510 am__v_NODEJS_0 = @echo "  NODEJS     " $@;
    511 am__v_NODEJS_1 =
    512 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
    513 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
    514 am__v_JAVAC_0 = @echo "  JAVAC   " $@;
    515 am__v_JAVAC_1 =
    516508repeats = 10
    517509max_time = 600
  • src/Common/Stats/Time.h

    rbdfc032 raefb247  
    99// Author           : Thierry Delisle
    1010// Created On       : Fri Mar 01 15:14:11 2019
    11 // Last Modified By : Andrew Beach
     11// Last Modified By :
    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                         }
    4943#               else
    5044                        void StartGlobal();
     
    6559                                func();
    6660                        }
    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                         }
    7461#               endif
    7562        }
  • src/Concurrency/Keywords.cc

    rbdfc032 raefb247  
    716716                                new UntypedExpr(
    717717                                        new NameExpr( "__thrd_start" ),
    718                                         { new VariableExpr( param ), new NameExpr("main") }
     718                                        { new VariableExpr( param ) }
    719719                                )
    720720                        )
  • src/Concurrency/Waitfor.cc

    rbdfc032 raefb247  
    1111// Last Modified By :
    1212// Last Modified On :
    13 // Update Count     : 12
     13// Update Count     : 11
    1414//
    1515
     
    4242void foo() {
    4343        while( true ) {
    44                 when( a < 1 ) waitfor( f : a ) { bar(); }
     44                when( a < 1 ) waitfor( f, a ) { bar(); }
    4545                or timeout( swagl() );
    46                 or waitfor( g : a ) { baz(); }
    47                 or waitfor( ^?{} : a ) { break; }
     46                or waitfor( g, a ) { baz(); }
     47                or waitfor( ^?{}, a ) { break; }
    4848                or waitfor( ^?{} ) { break; }
    4949        }
  • src/ControlStruct/LabelFixer.cc

    rbdfc032 raefb247  
    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 : Tue Jan 21 10:32:00 2020
    13 // Update Count     : 160
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Mon Mar 11 22:26:02 2019
     13// Update Count     : 159
    1414//
    1515
     
    2121#include "ControlStruct/LabelGenerator.h"  // for LabelGenerator
    2222#include "LabelFixer.h"
    23 #include "MLEMutator.h"                    // for MultiLevelExitMutator
     23#include "MLEMutator.h"                    // for MLEMutator
    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<MultiLevelExitMutator> mlem( resolveJumps(), generator );
    47                 // We start in the body so we can stop when we hit another FunctionDecl.
    48                 maybeMutate( functionDecl->statements, mlem );
     46                PassVisitor<MLEMutator> mlemut( resolveJumps(), generator );
     47                functionDecl->acceptMutator( mlemut );
    4948        }
    5049
     
    7675
    7776
    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.
     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
    8079        Label LabelFixer::setLabelsDef( std::list< Label > & llabel, Statement * definition ) {
    8180                assert( definition != 0 );
    8281                assert( llabel.size() > 0 );
     82
     83                Entry * e = new Entry( definition );
    8384
    8485                for ( std::list< Label >::iterator i = llabel.begin(); i != llabel.end(); i++ ) {
     
    8687                        l.set_statement( definition ); // attach statement to the label to be used later
    8788                        if ( labelTable.find( l ) == labelTable.end() ) {
    88                                 // All labels on this statement need to use the same entry,
    89                                 // so this should only be created once.
     89                                // all labels on this statement need to use the same entry, so this should only be created once
    9090                                // undefined and unused until now, add an entry
    91                                 labelTable[ l ] = new Entry( definition );
     91                                labelTable[ l ] =  e;
    9292                        } else if ( labelTable[ l ]->defined() ) {
    9393                                // defined twice, error
    94                                 SemanticError( l.get_statement()->location,
    95                                         "Duplicate definition of label: " + l.get_name() );
    96                         } else {
     94                                SemanticError( l.get_statement()->location, "Duplicate definition of label: " + l.get_name() );
     95                        }       else {
    9796                                // used previously, but undefined until now -> link with this entry
    98                                 // Question: Is changing objects important?
    9997                                delete labelTable[ l ];
    100                                 labelTable[ l ] = new Entry( definition );
     98                                labelTable[ l ] = e;
    10199                        } // if
    102100                } // for
    103101
    104                 // Produce one of the labels attached to this statement to be temporarily used as the
    105                 // canonical label.
     102                // produce one of the labels attached to this statement to be temporarily used as the canonical label
    106103                return labelTable[ llabel.front() ]->get_label();
    107104        }
  • src/ControlStruct/MLEMutator.cc

    rbdfc032 raefb247  
    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 : Wed Jan 22 11:50:00 2020
    13 // Update Count     : 223
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue Oct 22 17:22:44 2019
     13// Update Count     : 220
    1414//
    1515
     
    3333
    3434namespace ControlStruct {
    35         MultiLevelExitMutator::~MultiLevelExitMutator() {
     35        MLEMutator::~MLEMutator() {
    3636                delete targetTable;
    3737                targetTable = 0;
    3838        }
    3939        namespace {
    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                 }
     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 ); }
    6147        } // namespace
    62 
    63         void MultiLevelExitMutator::premutate( FunctionDecl * ) {
    64                 visit_children = false;
    65         }
    6648
    6749        // break labels have to come after the statement they break out of, so mutate a statement, then if they inform us
    6850        // through the breakLabel field tha they need a place to jump to on a break statement, add the break label to the
    6951        // body of statements
    70         void MultiLevelExitMutator::fixBlock( std::list< Statement * > &kids, bool caseClause ) {
     52        void MLEMutator::fixBlock( std::list< Statement * > &kids, bool caseClause ) {
    7153                SemanticErrorException errors;
    7254
     
    9981        }
    10082
    101         void MultiLevelExitMutator::premutate( CompoundStmt *cmpndStmt ) {
     83        void MLEMutator::premutate( CompoundStmt *cmpndStmt ) {
    10284                visit_children = false;
    10385                bool labeledBlock = !(cmpndStmt->labels.empty());
     
    136118                        }
    137119                }
    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 ) {
     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 ) {
    145125                std::string originalTarget = branchStmt->originalTarget;
    146126
     
    250230        }
    251231
    252         Statement *MultiLevelExitMutator::mutateLoop( Statement *bodyLoop, Entry &e ) {
     232        Statement *MLEMutator::mutateLoop( Statement *bodyLoop, Entry &e ) {
    253233                // only generate these when needed
    254234                if( !e.isContUsed() && !e.isBreakUsed() ) return bodyLoop;
     
    273253
    274254        template< typename LoopClass >
    275         void MultiLevelExitMutator::prehandleLoopStmt( LoopClass * loopStmt ) {
     255        void MLEMutator::prehandleLoopStmt( LoopClass * loopStmt ) {
    276256                // remember this as the most recent enclosing loop, then mutate the body of the loop -- this will determine
    277257                // whether brkLabel and contLabel are used with branch statements and will recursively do the same to nested
     
    284264
    285265        template< typename LoopClass >
    286         Statement * MultiLevelExitMutator::posthandleLoopStmt( LoopClass * loopStmt ) {
     266        Statement * MLEMutator::posthandleLoopStmt( LoopClass * loopStmt ) {
    287267                assert( ! enclosingControlStructures.empty() );
    288268                Entry &e = enclosingControlStructures.back();
     
    295275        }
    296276
    297         void MultiLevelExitMutator::premutate( WhileStmt * whileStmt ) {
     277        void MLEMutator::premutate( WhileStmt * whileStmt ) {
    298278                return prehandleLoopStmt( whileStmt );
    299279        }
    300280
    301         void MultiLevelExitMutator::premutate( ForStmt * forStmt ) {
     281        void MLEMutator::premutate( ForStmt * forStmt ) {
    302282                return prehandleLoopStmt( forStmt );
    303283        }
    304284
    305         Statement * MultiLevelExitMutator::postmutate( WhileStmt * whileStmt ) {
     285        Statement * MLEMutator::postmutate( WhileStmt * whileStmt ) {
    306286                return posthandleLoopStmt( whileStmt );
    307287        }
    308288
    309         Statement * MultiLevelExitMutator::postmutate( ForStmt * forStmt ) {
     289        Statement * MLEMutator::postmutate( ForStmt * forStmt ) {
    310290                return posthandleLoopStmt( forStmt );
    311291        }
    312292
    313         void MultiLevelExitMutator::premutate( IfStmt * ifStmt ) {
     293        void MLEMutator::premutate( IfStmt * ifStmt ) {
    314294                // generate a label for breaking out of a labeled if
    315295                bool labeledBlock = !(ifStmt->get_labels().empty());
     
    321301        }
    322302
    323         Statement * MultiLevelExitMutator::postmutate( IfStmt * ifStmt ) {
     303        Statement * MLEMutator::postmutate( IfStmt * ifStmt ) {
    324304                bool labeledBlock = !(ifStmt->get_labels().empty());
    325305                if ( labeledBlock ) {
     
    331311        }
    332312
    333         void MultiLevelExitMutator::premutate( TryStmt * tryStmt ) {
     313        void MLEMutator::premutate( TryStmt * tryStmt ) {
    334314                // generate a label for breaking out of a labeled if
    335315                bool labeledBlock = !(tryStmt->get_labels().empty());
     
    341321        }
    342322
    343         Statement * MultiLevelExitMutator::postmutate( TryStmt * tryStmt ) {
     323        Statement * MLEMutator::postmutate( TryStmt * tryStmt ) {
    344324                bool labeledBlock = !(tryStmt->get_labels().empty());
    345325                if ( labeledBlock ) {
     
    351331        }
    352332
    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 ) {
     333        void MLEMutator::premutate( CaseStmt *caseStmt ) {
    369334                visit_children = false;
    370335
     
    405370        }
    406371
    407         void MultiLevelExitMutator::premutate( SwitchStmt *switchStmt ) {
     372        void MLEMutator::premutate( SwitchStmt *switchStmt ) {
    408373                // generate a label for breaking out of a labeled switch
    409374                Label brkLabel = generator->newLabel("switchBreak", switchStmt);
     
    431396        }
    432397
    433         Statement * MultiLevelExitMutator::postmutate( SwitchStmt * switchStmt ) {
     398        Statement * MLEMutator::postmutate( SwitchStmt * switchStmt ) {
    434399                Entry &e = enclosingControlStructures.back();
    435400                assert ( e == switchStmt );
  • src/ControlStruct/MLEMutator.h

    rbdfc032 raefb247  
    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 : Wed Jan 22 11:50:00 2020
    13 // Update Count     : 48
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue Oct 22 17:22:47 2019
     13// Update Count     : 45
    1414//
    1515
     
    3030        class LabelGenerator;
    3131
    32         class MultiLevelExitMutator : public WithVisitorRef<MultiLevelExitMutator>,
    33                         public WithShortCircuiting, public WithGuards {
     32        class MLEMutator : public WithVisitorRef<MLEMutator>, public WithShortCircuiting, public WithGuards {
    3433          public:
    3534                class Entry;
    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 * );
     35                MLEMutator( std::map<Label, Statement *> *t, LabelGenerator *gen = 0 ) : targetTable( t ), breakLabel(std::string("")), generator( gen ) {}
     36                ~MLEMutator();
    4137
    4238                void premutate( CompoundStmt *cmpndStmt );
     
    5147                void premutate( SwitchStmt *switchStmt );
    5248                Statement * postmutate( SwitchStmt *switchStmt );
    53                 void premutate( ReturnStmt *returnStmt );
    5449                void premutate( TryStmt *tryStmt );
    5550                Statement * postmutate( TryStmt *tryStmt );
    56                 void premutate( FinallyStmt *finallyStmt );
    5751
    5852                Statement *mutateLoop( Statement *bodyLoop, Entry &e );
     
    116110                Label breakLabel;
    117111                LabelGenerator *generator;
    118                 bool inFinally = false;
    119112
    120113                template< typename LoopClass >
  • src/Parser/lex.ll

    rbdfc032 raefb247  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Sat Feb  1 07:16:44 2020
    13  * Update Count     : 724
     12 * Last Modified On : Sun Aug  4 20:53:47 2019
     13 * Update Count     : 719
    1414 */
    1515
     
    330330                                /* identifier */
    331331{identifier}    { IDENTIFIER_RETURN(); }
    332 "``"{identifier}"``" {                                                                  // CFA
    333         yytext[yyleng - 2] = '\0'; yytext += 2;                         // SKULLDUGGERY: remove backquotes (ok to shorten?)
     332"`"{identifier}"`" {                                                                    // CFA
     333        yytext[yyleng - 1] = '\0'; yytext += 1;                         // SKULLDUGGERY: remove backquotes (ok to shorten?)
    334334        IDENTIFIER_RETURN();
    335335}
  • src/Parser/parser.yy

    rbdfc032 raefb247  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Feb  1 10:04:40 2020
    13 // Update Count     : 4440
     12// Last Modified On : Mon Dec 16 15:32:58 2019
     13// Update Count     : 4409
    1414//
    1515
     
    323323%type<op> ptrref_operator                               unary_operator                          assignment_operator
    324324%type<en> primary_expression                    postfix_expression                      unary_expression
    325 %type<en> cast_expression_list                  cast_expression                         exponential_expression          multiplicative_expression       additive_expression
     325%type<en> 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
     
    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 ) ); }
    581591        | type_name '.' identifier                                                      // CFA, nested type
    582592                { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }
     
    632642        | postfix_expression '(' argument_expression_list ')'
    633643                { $$ = 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 ) ) ); }
    640644        | postfix_expression '.' identifier
    641645                { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); }
     
    662666        | '(' type_no_function ')' '@' '{' initializer_list_opt comma_opt '}' // CFA, explicit C compound-literal
    663667                { $$ = new ExpressionNode( build_compoundLiteral( $2, (new InitializerNode( $6, true ))->set_maybeConstructed( false ) ) ); }
    664         | '^' primary_expression '{' argument_expression_list '}' // CFA, destructor call
     668        | '^' primary_expression '{' argument_expression_list '}' // CFA
    665669                {
    666670                        Token fn;
     
    675679        | argument_expression
    676680        | argument_expression_list ',' argument_expression
    677                 { $$ = (ExpressionNode *)($1->set_last( $3 )); }
     681                { $$ = (ExpressionNode *)( $1->set_last( $3 )); }
    678682        ;
    679683
     
    687691field_name_list:                                                                                // CFA, tuple field selector
    688692        field
    689         | field_name_list ',' field                                     { $$ = (ExpressionNode *)($1->set_last( $3 )); }
     693        | field_name_list ',' field                                     { $$ = (ExpressionNode *)$1->set_last( $3 ); }
    690694        ;
    691695
     
    956960                { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $3 ) ) ); }
    957961        | '[' push assignment_expression pop ',' tuple_expression_list ']'
    958                 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)($3->set_last( $6 ) ) )); }
     962                { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)$3->set_last( $6 ) ) ); }
    959963        ;
    960964
     
    962966        assignment_expression_opt
    963967        | tuple_expression_list ',' assignment_expression_opt
    964                 { $$ = (ExpressionNode *)($1->set_last( $3 )); }
     968                { $$ = (ExpressionNode *)$1->set_last( $3 ); }
    965969        ;
    966970
     
    13031307        WAITFOR '(' cast_expression ')'
    13041308                { $$ = $3; }
    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 
    1311 cast_expression_list:
    1312         cast_expression
    1313         | cast_expression_list ',' cast_expression
    1314                 { $$ = (ExpressionNode *)($1->set_last( $3 )); }
     1309        | WAITFOR '(' cast_expression ',' argument_expression_list ')'
     1310                { $$ = (ExpressionNode *)$3->set_last( $5 ); }
    13151311        ;
    13161312
     
    14231419        asm_operand
    14241420        | asm_operands_list ',' asm_operand
    1425                 { $$ = (ExpressionNode *)($1->set_last( $3 )); }
     1421                { $$ = (ExpressionNode *)$1->set_last( $3 ); }
    14261422        ;
    14271423
     
    14391435                { $$ = new ExpressionNode( $1 ); }
    14401436        | asm_clobbers_list_opt ',' string_literal
    1441                 { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( $3 ) )); }
     1437                // set_last returns ParseNode *
     1438                { $$ = (ExpressionNode *)$1->set_last( new ExpressionNode( $3 ) ); }
    14421439        ;
    14431440
     
    23622359        | initializer_list_opt ',' initializer          { $$ = (InitializerNode *)( $1->set_last( $3 ) ); }
    23632360        | initializer_list_opt ',' designation initializer
    2364                 { $$ = (InitializerNode *)($1->set_last( $4->set_designators( $3 ) )); }
     2361                { $$ = (InitializerNode *)( $1->set_last( $4->set_designators( $3 ) ) ); }
    23652362        ;
    23662363
     
    23842381        designator
    23852382        | designator_list designator
    2386                 { $$ = (ExpressionNode *)($1->set_last( $2 )); }
     2383                { $$ = (ExpressionNode *)( $1->set_last( $2 ) ); }
    23872384        //| designator_list designator                                          { $$ = new ExpressionNode( $1, $2 ); }
    23882385        ;
     
    24812478                { SemanticError( yylloc, toString("Expression generic parameters are currently unimplemented: ", $1->build()) ); $$ = nullptr; }
    24822479        | type_list ',' type
    2483                 { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ) )); }
     2480                { $$ = (ExpressionNode *)( $1->set_last( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ) ) ); }
    24842481        | type_list ',' assignment_expression
    24852482                { SemanticError( yylloc, toString("Expression generic parameters are currently unimplemented: ", $3->build()) ); $$ = nullptr; }
  • src/SymTab/Validate.cc

    rbdfc032 raefb247  
    375375                        Stats::Heap::newPass("validate-F");
    376376                        Stats::Time::BlockGuard guard("validate-F");
    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);
     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                        });
    387392                }
    388393        }
  • src/SynTree/Statement.cc

    rbdfc032 raefb247  
    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 : Mon Jan 20 16:03:00 2020
    13 // Update Count     : 71
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sun Sep  3 20:46:44 2017
     13// Update Count     : 68
    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[] = {
    104         "Goto", "Break", "Continue", "Fall Through", "Fall Through Default",
    105 };
     103const char *BranchStmt::brType[] = { "Goto", "Break", "Continue" };
    106104
    107105BranchStmt::BranchStmt( Label target, Type type ) throw ( SemanticErrorException ) :
     
    113111}
    114112
    115 BranchStmt::BranchStmt( Expression * computedTarget, Type type ) throw ( SemanticErrorException ) :
     113BranchStmt::BranchStmt( Expression *computedTarget, Type type ) throw ( SemanticErrorException ) :
    116114        Statement(), computedTarget( computedTarget ), type( type ) {
    117115        if ( type != BranchStmt::Goto || computedTarget == nullptr ) {
     
    120118}
    121119
    122 void BranchStmt::print( std::ostream & os, Indenter indent ) const {
    123         assert(type < 5);
     120void BranchStmt::print( std::ostream &os, Indenter indent ) const {
    124121        os << "Branch (" << brType[type] << ")" << endl ;
    125122        if ( target != "" ) os << indent+1 << "with target: " << target << endl;
     
    128125}
    129126
    130 ReturnStmt::ReturnStmt( Expression * expr ) : Statement(), expr( expr ) {}
     127ReturnStmt::ReturnStmt( Expression *expr ) : Statement(), expr( expr ) {}
    131128
    132129ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) {}
     
    136133}
    137134
    138 void ReturnStmt::print( std::ostream & os, Indenter indent ) const {
     135void ReturnStmt::print( std::ostream &os, Indenter indent ) const {
    139136        os << "Return Statement, returning: ";
    140137        if ( expr != nullptr ) {
     
    145142}
    146143
    147 IfStmt::IfStmt( Expression * condition, Statement * thenPart, Statement * elsePart, std::list<Statement *> initialization ):
     144IfStmt::IfStmt( Expression *condition, Statement *thenPart, Statement *elsePart, std::list<Statement *> initialization ):
    148145        Statement(), condition( condition ), thenPart( thenPart ), elsePart( elsePart ), initialization( initialization ) {}
    149146
     
    160157}
    161158
    162 void IfStmt::print( std::ostream & os, Indenter indent ) const {
     159void IfStmt::print( std::ostream &os, Indenter indent ) const {
    163160        os << "If on condition: " << endl;
    164161        os << indent+1;
     
    179176        thenPart->print( os, indent+1 );
    180177
    181         if ( elsePart != nullptr ) {
     178        if ( elsePart != 0 ) {
    182179                os << indent << "... else: " << endl;
    183180                os << indent+1;
     
    186183}
    187184
    188 SwitchStmt::SwitchStmt( Expression * condition, const std::list<Statement *> & statements ):
     185SwitchStmt::SwitchStmt( Expression * condition, const std::list<Statement *> &statements ):
    189186        Statement(), condition( condition ), statements( statements ) {
    190187}
     
    201198}
    202199
    203 void SwitchStmt::print( std::ostream & os, Indenter indent ) const {
     200void SwitchStmt::print( std::ostream &os, Indenter indent ) const {
    204201        os << "Switch on condition: ";
    205202        condition->print( os );
     
    211208}
    212209
    213 CaseStmt::CaseStmt( Expression * condition, const std::list<Statement *> & statements, bool deflt ) throw ( SemanticErrorException ) :
     210CaseStmt::CaseStmt( Expression *condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticErrorException ) :
    214211        Statement(), condition( condition ), stmts( statements ), _isDefault( deflt ) {
    215         if ( isDefault() && condition != nullptr ) SemanticError( condition, "default case with condition: " );
     212        if ( isDefault() && condition != 0 ) SemanticError( condition, "default case with condition: " );
    216213}
    217214
     
    232229}
    233230
    234 void CaseStmt::print( std::ostream & os, Indenter indent ) const {
     231void CaseStmt::print( std::ostream &os, Indenter indent ) const {
    235232        if ( isDefault() ) os << indent << "Default ";
    236233        else {
     
    246243}
    247244
    248 WhileStmt::WhileStmt( Expression * condition, Statement * body, std::list< Statement * > & initialization, bool isDoWhile ):
     245WhileStmt::WhileStmt( Expression *condition, Statement *body, std::list< Statement * > & initialization, bool isDoWhile ):
    249246        Statement(), condition( condition), body( body), initialization( initialization ), isDoWhile( isDoWhile) {
    250247}
     
    259256}
    260257
    261 void WhileStmt::print( std::ostream & os, Indenter indent ) const {
     258void WhileStmt::print( std::ostream &os, Indenter indent ) const {
    262259        os << "While on condition: " << endl ;
    263260        condition->print( os, indent+1 );
     
    265262        os << indent << "... with body: " << endl;
    266263
    267         if ( body != nullptr ) body->print( os, indent+1 );
    268 }
    269 
    270 ForStmt::ForStmt( std::list<Statement *> initialization, Expression * condition, Expression * increment, Statement * body ):
     264        if ( body != 0 ) body->print( os, indent+1 );
     265}
     266
     267ForStmt::ForStmt( std::list<Statement *> initialization, Expression *condition, Expression *increment, Statement *body ):
    271268        Statement(), initialization( initialization ), condition( condition ), increment( increment ), body( body ) {
    272269}
     
    285282}
    286283
    287 void ForStmt::print( std::ostream & os, Indenter indent ) const {
     284void ForStmt::print( std::ostream &os, Indenter indent ) const {
    288285        Statement::print( os, indent ); // print labels
    289286
     
    308305        }
    309306
    310         if ( body != nullptr ) {
     307        if ( body != 0 ) {
    311308                os << "\n" << indent << "... with body: \n" << indent+1;
    312309                body->print( os, indent+1 );
     
    320317}
    321318
    322 ThrowStmt::ThrowStmt( const ThrowStmt & other ) :
     319ThrowStmt::ThrowStmt( const ThrowStmt &other ) :
    323320        Statement ( other ), kind( other.kind ), expr( maybeClone( other.expr ) ), target( maybeClone( other.target ) ) {
    324321}
     
    329326}
    330327
    331 void ThrowStmt::print( std::ostream & os, Indenter indent) const {
     328void ThrowStmt::print( std::ostream &os, Indenter indent) const {
    332329        if ( target ) os << "Non-Local ";
    333330        os << "Throw Statement, raising: ";
     
    339336}
    340337
    341 TryStmt::TryStmt( CompoundStmt * tryBlock, std::list<CatchStmt *> & handlers, FinallyStmt * finallyBlock ) :
     338TryStmt::TryStmt( CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock ) :
    342339        Statement(), block( tryBlock ),  handlers( handlers ), finallyBlock( finallyBlock ) {
    343340}
    344341
    345 TryStmt::TryStmt( const TryStmt & other ) : Statement( other ), block( maybeClone( other.block ) ), finallyBlock( maybeClone( other.finallyBlock ) ) {
     342TryStmt::TryStmt( const TryStmt &other ) : Statement( other ), block( maybeClone( other.block ) ), finallyBlock( maybeClone( other.finallyBlock ) ) {
    346343        cloneAll( other.handlers, handlers );
    347344}
     
    353350}
    354351
    355 void TryStmt::print( std::ostream & os, Indenter indent ) const {
     352void TryStmt::print( std::ostream &os, Indenter indent ) const {
    356353        os << "Try Statement" << endl;
    357354        os << indent << "... with block:" << endl << indent+1;
     
    366363
    367364        // finally block
    368         if ( finallyBlock != nullptr ) {
     365        if ( finallyBlock != 0 ) {
    369366                os << indent << "... and finally:" << endl << indent+1;
    370367                finallyBlock->print( os, indent+1 );
     
    372369}
    373370
    374 CatchStmt::CatchStmt( Kind kind, Declaration * decl, Expression * cond, Statement * body ) :
     371CatchStmt::CatchStmt( Kind kind, Declaration *decl, Expression *cond, Statement *body ) :
    375372        Statement(), kind ( kind ), decl ( decl ), cond ( cond ), body( body ) {
    376373                assertf( decl, "Catch clause must have a declaration." );
     
    386383}
    387384
    388 void CatchStmt::print( std::ostream & os, Indenter indent ) const {
     385void CatchStmt::print( std::ostream &os, Indenter indent ) const {
    389386        os << "Catch " << ((Terminate == kind) ? "Terminate" : "Resume") << " Statement" << endl;
    390387
     
    404401
    405402
    406 FinallyStmt::FinallyStmt( CompoundStmt * block ) : Statement(), block( block ) {
     403FinallyStmt::FinallyStmt( CompoundStmt *block ) : Statement(), block( block ) {
    407404}
    408405
     
    414411}
    415412
    416 void FinallyStmt::print( std::ostream & os, Indenter indent ) const {
     413void FinallyStmt::print( std::ostream &os, Indenter indent ) const {
    417414        os << "Finally Statement" << endl;
    418415        os << indent << "... with block:" << endl << indent+1;
     
    461458}
    462459
    463 void WaitForStmt::print( std::ostream & os, Indenter indent ) const {
     460void WaitForStmt::print( std::ostream &os, Indenter indent ) const {
    464461        os << "Waitfor Statement" << endl;
    465462        indent += 1;
     
    517514}
    518515
    519 void NullStmt::print( std::ostream & os, Indenter indent ) const {
     516void NullStmt::print( std::ostream &os, Indenter indent ) const {
    520517        os << "Null Statement" << endl;
    521518        Statement::print( os, indent );
     
    533530}
    534531
    535 void ImplicitCtorDtorStmt::print( std::ostream & os, Indenter indent ) const {
     532void ImplicitCtorDtorStmt::print( std::ostream &os, Indenter indent ) const {
    536533        os << "Implicit Ctor Dtor Statement" << endl;
    537534        os << indent << "... with Ctor/Dtor: ";
  • src/SynTree/Statement.h

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

    rbdfc032 raefb247  
     1
     2
    13CFACOMPILE = $(CFACC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) $(AM_CFLAGS) $(CFLAGS)
    24LTCFACOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
     
    1921        $(am__mv) $$depbase.Tpo $$depbase.Plo
    2022
     23AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
     24am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
     25am__v_JAVAC_0 = @echo "  JAVAC   " $@;
     26am__v_JAVAC_1 =
     27
     28AM_V_GOC = $(am__v_GOC_@AM_V@)
     29am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)
     30am__v_GOC_0 = @echo "  GOC     " $@;
     31am__v_GOC_1 =
     32
    2133UPPCC = u++
    2234UPPCOMPILE = $(UPPCC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_UPPFLAGS) $(UPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_CFLAGS) $(CFLAGS)
     
    2638am__v_UPP_0 = @echo "  UPP     " $@;
    2739am__v_UPP_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 
    34 AM_V_RUST = $(am__v_RUST_@AM_V@)
    35 am__v_RUST_ = $(am__v_RUST_@AM_DEFAULT_V@)
    36 am__v_RUST_0 = @echo "  RUST     " $@;
    37 am__v_RUST_1 =
    38 
    39 AM_V_NODEJS = $(am__v_NODEJS_@AM_V@)
    40 am__v_NODEJS_ = $(am__v_NODEJS_@AM_DEFAULT_V@)
    41 am__v_NODEJS_0 = @echo "  NODEJS     " $@;
    42 am__v_NODEJS_1 =
    43 
    44 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
    45 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
    46 am__v_JAVAC_0 = @echo "  JAVAC   " $@;
    47 am__v_JAVAC_1 =
  • tests/.expect/time.txt

    rbdfc032 raefb247  
    1818Dividing that by 2 gives 2403.5 seconds
    19194807 seconds is 1 hours, 20 minutes, 7 seconds
    20 2020 Jan  5 14:01:40 (GMT)
    21 1970 Jan  5 14:00:00 (GMT)
    22 1973 Jan  2 06:59:00 (GMT)
  • tests/Makefile.in

    rbdfc032 raefb247  
    364364am__v_CFA_0 = @echo "  CFA     " $@;
    365365am__v_CFA_1 =
     366AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
     367am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
     368am__v_JAVAC_0 = @echo "  JAVAC   " $@;
     369am__v_JAVAC_1 =
     370AM_V_GOC = $(am__v_GOC_@AM_V@)
     371am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)
     372am__v_GOC_0 = @echo "  GOC     " $@;
     373am__v_GOC_1 =
    366374UPPCC = u++
    367375UPPCOMPILE = $(UPPCC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_UPPFLAGS) $(UPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_CFLAGS) $(CFLAGS)
     
    370378am__v_UPP_0 = @echo "  UPP     " $@;
    371379am__v_UPP_1 =
    372 AM_V_GOC = $(am__v_GOC_@AM_V@)
    373 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)
    374 am__v_GOC_0 = @echo "  GOC     " $@;
    375 am__v_GOC_1 =
    376 AM_V_RUST = $(am__v_RUST_@AM_V@)
    377 am__v_RUST_ = $(am__v_RUST_@AM_DEFAULT_V@)
    378 am__v_RUST_0 = @echo "  RUST     " $@;
    379 am__v_RUST_1 =
    380 AM_V_NODEJS = $(am__v_NODEJS_@AM_V@)
    381 am__v_NODEJS_ = $(am__v_NODEJS_@AM_DEFAULT_V@)
    382 am__v_NODEJS_0 = @echo "  NODEJS     " $@;
    383 am__v_NODEJS_1 =
    384 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
    385 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
    386 am__v_JAVAC_0 = @echo "  JAVAC   " $@;
    387 am__v_JAVAC_1 =
    388380debug = yes
    389381installed = no
  • tests/concurrent/examples/boundedBufferEXT.cfa

    rbdfc032 raefb247  
    1010// Created On       : Wed Apr 18 22:52:12 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jan 16 22:36:34 2020
    13 // Update Count     : 15
     12// Last Modified On : Fri Jun 21 08:19:20 2019
     13// Update Count     : 14
    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

    rbdfc032 raefb247  
    1010// Created On       : Wed Apr 18 22:52:12 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jan 16 23:09:43 2020
    13 // Update Count     : 25
     12// Last Modified On : Fri Jun 21 11:50:12 2019
     13// Update Count     : 24
    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

    rbdfc032 raefb247  
    1010// Created On       : Wed Feb 20 08:02:37 2019
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jan 16 22:43:40 2020
    13 // Update Count     : 5
     12// Last Modified On : Fri Jun 21 08:25:03 2019
     13// Update Count     : 4
    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/waitfor/barge.cfa

    rbdfc032 raefb247  
    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

    rbdfc032 raefb247  
    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

    rbdfc032 raefb247  
    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

    rbdfc032 raefb247  
    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() {}
     102int main() {
     103
     104}
  • tests/concurrent/waitfor/parse2.cfa

    rbdfc032 raefb247  
    1010// Created On       : Wed Aug 30 17:53:29 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jan 16 23:13:37 2020
    13 // Update Count     : 6
     12// Last Modified On : Fri Mar 22 13:42:11 2019
     13// Update Count     : 3
    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

    rbdfc032 raefb247  
    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

    rbdfc032 raefb247  
    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

    rbdfc032 raefb247  
    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

    rbdfc032 raefb247  
    1 struct S { int i; };
    2 void ?{}( S & s, int i ) { s.i = i; }
    3 int ?`mary( int );
    4 int ?`mary( S );
    5 [int] ?`mary( [int, int] );
    6 int & ?`jane( int & );
    7 int jack( int );
    8 
    91int main() {
    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;
     2    struct s { int i; } x, *p = &x;
     3    int i = 3;
    154
    165    // operators
    176
    18     !i;
     7    ! i;
    198    ~i;
    209    +i;
    2110    -i;
    22     *ps;
    23     ++ps;
    24     --ps;
    25     ps++;
    26     ps--;
     11    *p;
     12    ++p;
     13    --p;
     14    p++;
     15    p--;
    2716
    28     i + j;
    29     i - j;
    30     i * j;
     17    i+i;
     18    i-i;
     19    i*i;
    3120
    32     i / j;
    33     i % j;
    34     i ^ j;
    35     i & j;
    36     i | j;
    37     i < j;
    38     i > j;
    39     i = j;
     21    i/i;
     22    i%i;
     23    i^i;
     24    i&i;
     25    i|i;
     26    i<i;
     27    i>i;
     28    i=i;
    4029
    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;
     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;
    5049
    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;
     50    i?i:i;
    8551} // main
  • tests/quotedKeyword.cfa

    rbdfc032 raefb247  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Feb  1 00:02:22 2020
    13 // Update Count     : 24
     12// Last Modified On : Tue Dec  4 21:45:53 2018
     13// Update Count     : 23
    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/time.cfa

    rbdfc032 raefb247  
    1010// Created On       : Tue Mar 27 17:24:56 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jan  5 18:27:37 2020
    13 // Update Count     : 34
     12// Last Modified On : Fri Nov 29 23:05:30 2019
     13// Update Count     : 24
    1414//
    1515
     
    3434        sout | t;
    3535        t = t + d1;
    36         sout | t | t`ns;
     36        sout | t | t.tv;
    3737        Time t1 = (timespec){ 104_414, 10_000_000 };
    38         sout | t1 | t1`ns;
    39         sout | t - t  | t + d5 | t`ns;
    40         char buf[64];
     38        sout | t1 | t1.tv;
     39        sout | t - t  | t + d5 | t.tv;
     40        char buf[16];
    4141        sout | "yy/mm/dd" | [t, buf]`ymd | nonl;                        // shared buf => separate calls
    4242        sout | "mm/dd/yy" | mm_dd_yy( t, buf ) | nonl;
     
    4545        sout | "dd/yy/mm" | [t, buf]`dmy;
    4646        Time t2 = { 2001, 7, 4, 0, 0, 1, 0 }, t3 = (timeval){ 994_219_201 };
    47         sout | t2 | t2`ns | nl | t3 | t3`ns;
     47        sout | t2 | t2.tv | nl | t3 | t3.tv;
    4848        sout | nl;
    4949
     
    6262        sout | "Dividing that by 2 gives" | s / 2 | "seconds";
    6363        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;
    7464} // main
    7565
  • tools/stat.py

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