Changes in / [3d5701e:9fb8f01]
- Files:
-
- 36 added
- 100 deleted
- 267 edited
-
.gitignore (modified) (1 diff)
-
Jenkins/FullBuild (modified) (1 diff)
-
Jenkinsfile (modified) (7 diffs)
-
Makefile.in (modified) (2 diffs)
-
benchmark/Makefile.am (modified) (12 diffs)
-
benchmark/Makefile.in (modified) (12 diffs)
-
benchmark/baselines/x64/schedint.csv (deleted)
-
benchmark/baselines/x64/signal.csv (added)
-
benchmark/baselines/x86/schedint.csv (deleted)
-
benchmark/baselines/x86/signal.csv (added)
-
benchmark/basic/fetch_add.c (deleted)
-
benchmark/basic/function.c (deleted)
-
benchmark/basic/loop.c (deleted)
-
benchmark/basic/tls_fetch_add.c (deleted)
-
benchmark/basic/ttst_lock.c (deleted)
-
benchmark/bench.h (modified) (3 diffs)
-
benchmark/creation/JavaThread.java (modified) (4 diffs)
-
benchmark/creation/cfa_cor.cfa (modified) (1 diff)
-
benchmark/creation/cfa_gen.cfa (deleted)
-
benchmark/creation/cfa_thrd.cfa (modified) (1 diff)
-
benchmark/creation/goroutine.go (modified) (2 diffs)
-
benchmark/creation/node_cor.js (deleted)
-
benchmark/creation/pthreads.c (modified) (3 diffs)
-
benchmark/creation/python_cor.py (deleted)
-
benchmark/creation/rust_thrd.rs (deleted)
-
benchmark/creation/upp_cor.cc (modified) (1 diff)
-
benchmark/creation/upp_thrd.cc (modified) (1 diff)
-
benchmark/ctxswitch/JavaThread.java (modified) (3 diffs)
-
benchmark/ctxswitch/cfa_cor.cfa (modified) (1 diff)
-
benchmark/ctxswitch/cfa_cor_then.cfa (modified) (1 diff)
-
benchmark/ctxswitch/cfa_gen.cfa (modified) (1 diff)
-
benchmark/ctxswitch/cfa_thrd.cfa (modified) (1 diff)
-
benchmark/ctxswitch/cfa_thrd2.cfa (modified) (1 diff)
-
benchmark/ctxswitch/goroutine.go (modified) (2 diffs)
-
benchmark/ctxswitch/kos_fibre.cpp (modified) (1 diff)
-
benchmark/ctxswitch/kos_fibre2.cpp (modified) (1 diff)
-
benchmark/ctxswitch/node_await.js (deleted)
-
benchmark/ctxswitch/node_cor.js (deleted)
-
benchmark/ctxswitch/pthreads.c (modified) (1 diff)
-
benchmark/ctxswitch/python_cor.py (deleted)
-
benchmark/ctxswitch/rust_thrd.rs (deleted)
-
benchmark/ctxswitch/upp_cor.cc (modified) (2 diffs)
-
benchmark/ctxswitch/upp_thrd.cc (modified) (1 diff)
-
benchmark/exclude (deleted)
-
benchmark/fetch_add.c (added)
-
benchmark/function.c (added)
-
benchmark/loop.c (added)
-
benchmark/mutex/JavaThread.java (modified) (4 diffs)
-
benchmark/mutex/cfa1.cfa (modified) (1 diff)
-
benchmark/mutex/cfa2.cfa (modified) (1 diff)
-
benchmark/mutex/cfa4.cfa (modified) (1 diff)
-
benchmark/mutex/goroutine.go (deleted)
-
benchmark/mutex/pthreads.c (modified) (1 diff)
-
benchmark/mutex/rust.rs (deleted)
-
benchmark/mutex/upp.cc (modified) (1 diff)
-
benchmark/mutexC/JavaThread.java (deleted)
-
benchmark/mutexC/cfa1.cfa (deleted)
-
benchmark/mutexC/cfa2.cfa (deleted)
-
benchmark/mutexC/cfa4.cfa (deleted)
-
benchmark/mutexC/pthreads.c (deleted)
-
benchmark/mutexC/rust.rs (deleted)
-
benchmark/mutexC/upp.cc (deleted)
-
benchmark/schedext/cfa1.cfa (modified) (1 diff)
-
benchmark/schedext/cfa2.cfa (modified) (1 diff)
-
benchmark/schedext/cfa4.cfa (modified) (1 diff)
-
benchmark/schedext/goroutine.go (deleted)
-
benchmark/schedext/upp.cc (modified) (1 diff)
-
benchmark/schedint/JavaThread.java (modified) (4 diffs)
-
benchmark/schedint/cfa1.cfa (modified) (1 diff)
-
benchmark/schedint/cfa2.cfa (modified) (1 diff)
-
benchmark/schedint/cfa4.cfa (modified) (1 diff)
-
benchmark/schedint/pthreads.c (modified) (1 diff)
-
benchmark/schedint/rust.rs (deleted)
-
benchmark/schedint/upp.cc (modified) (2 diffs)
-
benchmark/size/size.cfa (deleted)
-
benchmark/tls-fetch_add.c (added)
-
benchmark/ttst_lock.c (added)
-
configure (modified) (9 diffs)
-
configure.ac (modified) (2 diffs)
-
doc/papers/concurrency/Paper.tex (modified) (7 diffs)
-
doc/papers/ibm_CASCON19/ThreadingModels.fig (deleted)
-
doc/papers/ibm_CASCON19/ThreadingModels.png (deleted)
-
doc/papers/ibm_CASCON19/ThreadingModels.svg (deleted)
-
doc/papers/ibm_CASCON19/abstract.txt (deleted)
-
doc/papers/ibm_CASCON19/client.cfa (deleted)
-
doc/papers/ibm_CASCON19/server.cfa (deleted)
-
doc/papers/ibm_CASCON19/slides.pdf (deleted)
-
doc/proposals/approx-equal.md (deleted)
-
doc/theses/thierry_delisle_PhD/.gitignore (deleted)
-
doc/theses/thierry_delisle_PhD/code/Makefile (deleted)
-
doc/theses/thierry_delisle_PhD/code/assert.hpp (deleted)
-
doc/theses/thierry_delisle_PhD/code/bts_test.cpp (deleted)
-
doc/theses/thierry_delisle_PhD/code/prefetch.cpp (deleted)
-
doc/theses/thierry_delisle_PhD/code/processor.hpp (deleted)
-
doc/theses/thierry_delisle_PhD/code/processor_list.hpp (deleted)
-
doc/theses/thierry_delisle_PhD/code/processor_list_fast.cpp (deleted)
-
doc/theses/thierry_delisle_PhD/code/processor_list_good.cpp (deleted)
-
doc/theses/thierry_delisle_PhD/code/randbit.cpp (deleted)
-
doc/theses/thierry_delisle_PhD/code/relaxed_list.cpp (deleted)
-
doc/theses/thierry_delisle_PhD/code/relaxed_list.hpp (deleted)
-
doc/theses/thierry_delisle_PhD/code/relaxed_list_layout.cpp (deleted)
-
doc/theses/thierry_delisle_PhD/code/scale.sh (deleted)
-
doc/theses/thierry_delisle_PhD/code/utils.hpp (deleted)
-
doc/theses/thierry_delisle_PhD/comp_II/Makefile (deleted)
-
doc/theses/thierry_delisle_PhD/comp_II/comp_II.tex (deleted)
-
doc/theses/thierry_delisle_PhD/comp_II/comp_II_too_big.tex (deleted)
-
doc/theses/thierry_delisle_PhD/comp_II/glossary.tex (deleted)
-
doc/theses/thierry_delisle_PhD/comp_II/local.bib (deleted)
-
driver/Makefile.in (modified) (2 diffs)
-
driver/cc1.cc (modified) (16 diffs)
-
driver/cfa.cc (modified) (17 diffs)
-
libcfa/Makefile.in (modified) (2 diffs)
-
libcfa/automake/missing (modified) (1 diff, 1 prop)
-
libcfa/configure (modified) (6 diffs)
-
libcfa/configure.ac (modified) (2 diffs)
-
libcfa/prelude/Makefile.am (modified) (5 diffs)
-
libcfa/prelude/Makefile.in (modified) (9 diffs)
-
libcfa/prelude/builtins.c (modified) (2 diffs)
-
libcfa/prelude/extras.regx (modified) (1 diff)
-
libcfa/prelude/extras.regx2 (deleted)
-
libcfa/prelude/prototypes.awk (modified) (4 diffs)
-
libcfa/prelude/sync-builtins.cf (modified) (8 diffs)
-
libcfa/src/Makefile.am (modified) (3 diffs)
-
libcfa/src/Makefile.in (modified) (8 diffs)
-
libcfa/src/assert.cfa (modified) (3 diffs)
-
libcfa/src/bits/align.hfa (modified) (2 diffs)
-
libcfa/src/bits/containers.hfa (modified) (8 diffs)
-
libcfa/src/bits/debug.cfa (modified) (6 diffs)
-
libcfa/src/bits/debug.hfa (modified) (4 diffs)
-
libcfa/src/bits/defs.hfa (modified) (3 diffs)
-
libcfa/src/bits/locks.hfa (modified) (5 diffs)
-
libcfa/src/bits/signal.hfa (modified) (2 diffs)
-
libcfa/src/clock.hfa (modified) (3 diffs)
-
libcfa/src/concurrency/CtxSwitch-arm.S (modified) (2 diffs)
-
libcfa/src/concurrency/CtxSwitch-i386.S (modified) (2 diffs)
-
libcfa/src/concurrency/CtxSwitch-x86_64.S (modified) (3 diffs)
-
libcfa/src/concurrency/alarm.cfa (modified) (5 diffs)
-
libcfa/src/concurrency/alarm.hfa (modified) (3 diffs)
-
libcfa/src/concurrency/coroutine.cfa (modified) (9 diffs)
-
libcfa/src/concurrency/coroutine.hfa (modified) (12 diffs)
-
libcfa/src/concurrency/invoke.c (modified) (7 diffs)
-
libcfa/src/concurrency/invoke.h (modified) (12 diffs)
-
libcfa/src/concurrency/kernel.cfa (modified) (40 diffs)
-
libcfa/src/concurrency/kernel.hfa (modified) (10 diffs)
-
libcfa/src/concurrency/kernel_private.hfa (modified) (4 diffs)
-
libcfa/src/concurrency/monitor.cfa (modified) (42 diffs)
-
libcfa/src/concurrency/monitor.hfa (modified) (8 diffs)
-
libcfa/src/concurrency/mutex.cfa (modified) (12 diffs)
-
libcfa/src/concurrency/mutex.hfa (modified) (5 diffs)
-
libcfa/src/concurrency/preemption.cfa (modified) (20 diffs)
-
libcfa/src/concurrency/thread.cfa (modified) (6 diffs)
-
libcfa/src/concurrency/thread.hfa (modified) (3 diffs)
-
libcfa/src/exception.c (modified) (15 diffs)
-
libcfa/src/executor.cfa (modified) (2 diffs)
-
libcfa/src/fstream.cfa (modified) (11 diffs)
-
libcfa/src/fstream.hfa (modified) (5 diffs)
-
libcfa/src/gmp.hfa (modified) (5 diffs)
-
libcfa/src/heap.cfa (modified) (40 diffs)
-
libcfa/src/interpose.cfa (modified) (11 diffs)
-
libcfa/src/iostream.cfa (modified) (43 diffs)
-
libcfa/src/iostream.hfa (modified) (10 diffs)
-
libcfa/src/math.hfa (modified) (2 diffs)
-
libcfa/src/rational.cfa (modified) (2 diffs)
-
libcfa/src/startup.cfa (modified) (3 diffs)
-
libcfa/src/stdhdr/assert.h (modified) (2 diffs)
-
libcfa/src/stdhdr/bfdlink.h (modified) (1 diff)
-
libcfa/src/stdhdr/hwloc.h (modified) (1 diff)
-
libcfa/src/stdhdr/krb5.h (modified) (1 diff)
-
libcfa/src/stdhdr/math.h (modified) (1 diff)
-
libcfa/src/stdhdr/sys/ucontext.h (modified) (1 diff)
-
libcfa/src/stdlib.cfa (modified) (8 diffs)
-
libcfa/src/stdlib.hfa (modified) (7 diffs)
-
libcfa/src/time.cfa (modified) (8 diffs)
-
libcfa/src/time.hfa (modified) (6 diffs)
-
libcfa/src/time_t.hfa (modified) (3 diffs)
-
longrun_tests/Makefile.am (modified) (1 diff)
-
longrun_tests/Makefile.in (modified) (6 diffs)
-
src/AST/Convert.cpp (modified) (10 diffs)
-
src/AST/Decl.cpp (modified) (5 diffs)
-
src/AST/Decl.hpp (modified) (18 diffs)
-
src/AST/Expr.cpp (modified) (2 diffs)
-
src/AST/Expr.hpp (modified) (4 diffs)
-
src/AST/Pass.impl.hpp (modified) (1 diff)
-
src/AST/Print.cpp (modified) (2 diffs)
-
src/AST/Type.cpp (modified) (3 diffs)
-
src/AST/Type.hpp (modified) (3 diffs)
-
src/AST/TypeEnvironment.cpp (modified) (4 diffs)
-
src/AST/TypeEnvironment.hpp (modified) (3 diffs)
-
src/AST/TypeVar.hpp (added)
-
src/AST/module.mk (modified) (2 diffs)
-
src/BasicTypes-gen.cc (modified) (3 diffs)
-
src/CodeGen/CodeGenerator.cc (modified) (27 diffs)
-
src/CodeGen/CodeGenerator.h (modified) (5 diffs)
-
src/CodeGen/FixMain.h (modified) (3 diffs)
-
src/CodeGen/FixNames.cc (modified) (2 diffs)
-
src/CodeGen/GenType.cc (modified) (1 diff)
-
src/CodeGen/GenType.h (modified) (2 diffs)
-
src/CodeGen/Generate.cc (modified) (3 diffs)
-
src/CodeGen/OperatorTable.cc (modified) (3 diffs)
-
src/CodeGen/OperatorTable.h (modified) (3 diffs)
-
src/CodeGen/Options.h (modified) (1 diff)
-
src/CodeGen/module.mk (modified) (2 diffs)
-
src/CodeTools/DeclStats.cc (modified) (2 diffs)
-
src/CodeTools/ResolvProtoDump.cc (modified) (2 diffs)
-
src/Common/Debug.h (modified) (2 diffs)
-
src/Common/PassVisitor.impl.h (modified) (6 diffs)
-
src/Common/SemanticError.cc (modified) (1 diff)
-
src/Common/SemanticError.h (modified) (3 diffs)
-
src/Common/Stats/Time.h (modified) (3 diffs)
-
src/Common/utility.h (modified) (3 diffs)
-
src/Concurrency/Keywords.cc (modified) (21 diffs)
-
src/Concurrency/Waitfor.cc (modified) (4 diffs)
-
src/ControlStruct/ExceptTranslate.cc (modified) (2 diffs)
-
src/ControlStruct/LabelFixer.cc (modified) (5 diffs)
-
src/ControlStruct/MLEMutator.cc (modified) (12 diffs)
-
src/ControlStruct/MLEMutator.h (modified) (5 diffs)
-
src/ControlStruct/Mutate.cc (modified) (2 diffs)
-
src/GenPoly/Box.cc (modified) (4 diffs)
-
src/GenPoly/Lvalue.cc (modified) (8 diffs)
-
src/GenPoly/Specialize.cc (modified) (2 diffs)
-
src/InitTweak/FixGlobalInit.cc (modified) (2 diffs)
-
src/InitTweak/FixInit.cc (modified) (4 diffs)
-
src/InitTweak/FixInit.h (modified) (2 diffs)
-
src/InitTweak/GenInit.cc (modified) (2 diffs)
-
src/InitTweak/InitTweak.cc (modified) (2 diffs)
-
src/MakeLibCfa.cc (modified) (4 diffs)
-
src/Makefile.in (modified) (13 diffs)
-
src/Parser/DeclarationNode.cc (modified) (12 diffs)
-
src/Parser/ExpressionNode.cc (modified) (4 diffs)
-
src/Parser/LinkageSpec.cc (added)
-
src/Parser/LinkageSpec.h (added)
-
src/Parser/ParseNode.h (modified) (7 diffs)
-
src/Parser/ParserTypes.h (modified) (2 diffs)
-
src/Parser/TypeData.cc (modified) (9 diffs)
-
src/Parser/TypeData.h (modified) (3 diffs)
-
src/Parser/TypedefTable.cc (modified) (2 diffs)
-
src/Parser/TypedefTable.h (modified) (2 diffs)
-
src/Parser/lex.ll (modified) (4 diffs)
-
src/Parser/module.mk (modified) (2 diffs)
-
src/Parser/parser.yy (modified) (29 diffs)
-
src/ResolvExpr/AdjustExprType.cc (modified) (2 diffs)
-
src/ResolvExpr/AlternativeFinder.cc (modified) (2 diffs)
-
src/ResolvExpr/ConversionCost.cc (modified) (1 diff)
-
src/ResolvExpr/PtrsCastable.cc (modified) (2 diffs)
-
src/ResolvExpr/ResolveAssertions.cc (modified) (1 diff)
-
src/ResolvExpr/Resolver.cc (modified) (5 diffs)
-
src/ResolvExpr/Unify.cc (modified) (6 diffs)
-
src/SymTab/Autogen.h (modified) (3 diffs)
-
src/SymTab/Demangle.cc (modified) (5 diffs)
-
src/SymTab/Indexer.cc (modified) (2 diffs)
-
src/SymTab/Mangler.cc (modified) (6 diffs)
-
src/SymTab/ManglerCommon.cc (modified) (3 diffs)
-
src/SymTab/Validate.cc (modified) (10 diffs)
-
src/SynTree/AddressExpr.cc (modified) (1 diff)
-
src/SynTree/AggregateDecl.cc (modified) (4 diffs)
-
src/SynTree/ApplicationExpr.cc (modified) (2 diffs)
-
src/SynTree/ArrayType.cc (modified) (1 diff)
-
src/SynTree/Attribute.h (modified) (2 diffs)
-
src/SynTree/CommaExpr.cc (modified) (2 diffs)
-
src/SynTree/Declaration.cc (modified) (2 diffs)
-
src/SynTree/Declaration.h (modified) (23 diffs)
-
src/SynTree/DeclarationWithType.cc (modified) (2 diffs)
-
src/SynTree/Expression.cc (modified) (20 diffs)
-
src/SynTree/Expression.h (modified) (5 diffs)
-
src/SynTree/FunctionDecl.cc (modified) (3 diffs)
-
src/SynTree/LinkageSpec.cc (deleted)
-
src/SynTree/LinkageSpec.h (deleted)
-
src/SynTree/NamedTypeDecl.cc (modified) (4 diffs)
-
src/SynTree/ObjectDecl.cc (modified) (3 diffs)
-
src/SynTree/Statement.cc (modified) (34 diffs)
-
src/SynTree/Statement.h (modified) (3 diffs)
-
src/SynTree/TopLvalue.cc (added)
-
src/SynTree/TopLvalue.h (added)
-
src/SynTree/TupleExpr.cc (modified) (3 diffs)
-
src/SynTree/TupleType.cc (modified) (2 diffs)
-
src/SynTree/Type.cc (modified) (6 diffs)
-
src/SynTree/Type.h (modified) (6 diffs)
-
src/SynTree/TypeDecl.cc (modified) (2 diffs)
-
src/SynTree/module.mk (modified) (1 diff)
-
src/Tuples/TupleAssignment.cc (modified) (3 diffs)
-
src/Tuples/TupleExpansion.cc (modified) (4 diffs)
-
src/cfa.make (modified) (3 diffs)
-
src/main.cc (modified) (26 diffs)
-
tests/.expect/alloc-ERROR.txt (modified) (4 diffs)
-
tests/.expect/alloc.txt (modified) (4 diffs)
-
tests/.expect/attributes.x64.txt (modified) (1 diff)
-
tests/.expect/attributes.x86.txt (modified) (1 diff)
-
tests/.expect/completeTypeError.txt (added)
-
tests/.expect/declarationErrors.txt (added)
-
tests/.expect/gccExtensions.x64.txt (modified) (1 diff)
-
tests/.expect/gccExtensions.x86.txt (modified) (1 diff)
-
tests/.expect/loopctrl.txt (modified) (3 diffs)
-
tests/.expect/nested-types-ERR1.txt (modified) (1 diff)
-
tests/.expect/nested-types-ERR2.txt (modified) (1 diff)
-
tests/.expect/rational.txt (modified) (1 diff)
-
tests/.expect/references.txt (modified) (1 diff)
-
tests/.expect/scopeErrors.txt (added)
-
tests/.expect/time.txt (modified) (1 diff)
-
tests/.expect/userLiterals.txt (deleted)
-
tests/Makefile.am (modified) (5 diffs)
-
tests/Makefile.in (modified) (9 diffs)
-
tests/abort.cfa (added)
-
tests/alloc.cfa (modified) (9 diffs)
-
tests/builtins/sync.cfa (modified) (2 diffs)
-
tests/completeTypeError.cfa (added)
-
tests/concurrent/.expect/keywordErrors.txt (deleted)
-
tests/concurrent/examples/.expect/datingService.txt (modified) (1 diff)
-
tests/concurrent/examples/boundedBufferEXT.cfa (modified) (3 diffs)
-
tests/concurrent/examples/boundedBufferTHREAD.cfa (modified) (2 diffs)
-
tests/concurrent/examples/datingService.cfa (modified) (3 diffs)
-
tests/concurrent/examples/gortn.cfa (modified) (2 diffs)
-
tests/concurrent/examples/quickSort.cfa (modified) (5 diffs)
-
tests/concurrent/keywordErrors.cfa (deleted)
-
tests/concurrent/multi-monitor.cfa (modified) (1 diff)
-
tests/concurrent/park/.expect/contention.txt (deleted)
-
tests/concurrent/park/.expect/force_preempt.txt (deleted)
-
tests/concurrent/park/contention.cfa (deleted)
-
tests/concurrent/park/force_preempt.cfa (deleted)
-
tests/concurrent/preempt.cfa (modified) (1 diff)
-
tests/concurrent/signal/block.cfa (modified) (2 diffs)
-
tests/concurrent/signal/wait.cfa (modified) (4 diffs)
-
tests/concurrent/thread.cfa (modified) (1 diff)
-
tests/concurrent/waitfor/barge.cfa (modified) (1 diff)
-
tests/concurrent/waitfor/dtor.cfa (modified) (1 diff)
-
tests/concurrent/waitfor/else.cfa (modified) (4 diffs)
-
tests/concurrent/waitfor/parse.cfa (modified) (7 diffs)
-
tests/concurrent/waitfor/parse2.cfa (modified) (13 diffs)
-
tests/concurrent/waitfor/recurse.cfa (modified) (3 diffs)
-
tests/concurrent/waitfor/statment.cfa (modified) (1 diff)
-
tests/concurrent/waitfor/when.cfa (modified) (1 diff)
-
tests/config.py.in (modified) (1 diff)
-
tests/context.cfa (added)
-
tests/declarationErrors.cfa (added)
-
tests/errors/.expect/completeType.txt (deleted)
-
tests/errors/.expect/declaration.txt (deleted)
-
tests/errors/.expect/scope.txt (deleted)
-
tests/errors/.expect/signature.txt (deleted)
-
tests/errors/completeType.cfa (deleted)
-
tests/errors/declaration.cfa (deleted)
-
tests/errors/scope.cfa (deleted)
-
tests/errors/signature.cfa (deleted)
-
tests/except-0.cfa (added)
-
tests/except-1.cfa (added)
-
tests/except-2.cfa (added)
-
tests/except-3.cfa (added)
-
tests/except-mac.hfa (added)
-
tests/exceptions/.expect/except-0.txt (deleted)
-
tests/exceptions/.expect/except-1.txt (deleted)
-
tests/exceptions/.expect/except-2.txt (deleted)
-
tests/exceptions/.expect/except-3.txt (deleted)
-
tests/exceptions/.expect/finally-error.txt (deleted)
-
tests/exceptions/except-0.cfa (deleted)
-
tests/exceptions/except-1.cfa (deleted)
-
tests/exceptions/except-2.cfa (deleted)
-
tests/exceptions/except-3.cfa (deleted)
-
tests/exceptions/except-mac.hfa (deleted)
-
tests/exceptions/finally-error.cfa (deleted)
-
tests/expression.cfa (modified) (1 diff)
-
tests/heap.cfa (modified) (22 diffs)
-
tests/labelledExit.cfa (modified) (2 diffs)
-
tests/linking/.expect/nostdlib.txt (deleted)
-
tests/linking/nostdlib.cfa (deleted)
-
tests/linking/withthreads.cfa (modified) (1 diff)
-
tests/loopctrl.cfa (modified) (4 diffs)
-
tests/namedParmArg.cfa (added)
-
tests/nested-types.cfa (modified) (2 diffs)
-
tests/occursError.cfa (added)
-
tests/pybin/settings.py (modified) (4 diffs)
-
tests/pybin/tools.py (modified) (11 diffs)
-
tests/quotedKeyword.cfa (modified) (2 diffs)
-
tests/raii/dtor-early-exit.cfa (modified) (1 diff)
-
tests/rational.cfa (modified) (5 diffs)
-
tests/references.cfa (modified) (1 diff)
-
tests/scope.cfa (added)
-
tests/scopeErrors.cfa (added)
-
tests/structMember.cfa (added)
-
tests/subrange.cfa (added)
-
tests/test.py (modified) (5 diffs)
-
tests/time.cfa (modified) (5 diffs)
-
tests/typeGenerator.cfa (added)
-
tests/typedef.cfa (added)
-
tests/typedefDeclarator.cfa (added)
-
tests/userLiterals.cfa (modified) (6 diffs)
-
tests/virtualCast.cfa (added)
-
tests/withStatement.cfa (added)
-
tests/zombies/context.cfa (deleted)
-
tests/zombies/namedParmArg.cfa (deleted)
-
tests/zombies/occursError.cfa (deleted)
-
tests/zombies/scope.cfa (deleted)
-
tests/zombies/structMember.cfa (deleted)
-
tests/zombies/subrange.cfa (deleted)
-
tests/zombies/typeGenerator.cfa (deleted)
-
tests/zombies/typedef.cfa (deleted)
-
tests/zombies/typedefDeclarator.cfa (deleted)
-
tests/zombies/virtualCast.cfa (deleted)
-
tests/zombies/withStatement.cfa (deleted)
-
tools/Makefile.in (modified) (2 diffs)
-
tools/PrettyGitLogs.sh (added)
-
tools/build/distcc_hash (deleted)
-
tools/build/push2dist.sh (deleted)
-
tools/catchsig.c (modified) (1 diff)
-
tools/prettyprinter/Makefile.in (modified) (2 diffs)
-
tools/stat.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
.gitignore
r3d5701e r9fb8f01 21 21 .deps 22 22 .dirstamp 23 /bin24 /lib25 /include26 /share27 /build23 bin 24 lib 25 include 26 share 27 build 28 28 *.class 29 29 -
Jenkins/FullBuild
r3d5701e r9fb8f01 17 17 18 18 parallel ( 19 clang_x86: { trigger_build( 'gcc-8', 'x86' ) }, 20 gcc_5_x86: { trigger_build( 'gcc-7', 'x86' ) }, 19 gcc_6_x64: { trigger_build( 'gcc-6', 'x64' ) }, 21 20 gcc_6_x86: { trigger_build( 'gcc-6', 'x86' ) }, 22 gcc_9_x64: { trigger_build( 'gcc-9', 'x64' ) },23 gcc_8_x64: { trigger_build( 'gcc-8', 'x64' ) },24 gcc_7_x64: { trigger_build( 'gcc-7', 'x64' ) },25 gcc_6_x64: { trigger_build( 'gcc-6', 'x64' ) },26 21 gcc_5_x64: { trigger_build( 'gcc-5', 'x64' ) }, 22 gcc_5_x86: { trigger_build( 'gcc-5', 'x86' ) }, 27 23 clang_x64: { trigger_build( 'clang', 'x64' ) }, 24 clang_x86: { trigger_build( 'clang', 'x86' ) }, 28 25 ) 29 26 } -
Jenkinsfile
r3d5701e r9fb8f01 102 102 103 103 echo GitLogMessage() 104 105 // This is a complete hack but it solves problems with automake thinking it needs to regenerate makefiles106 // We fudged automake/missing to handle that but automake stills bakes prints inside the makefiles107 // and these cause more problems.108 sh 'find . -name Makefile.in -exec touch {} +'109 104 } 110 105 } … … 160 155 161 156 def test() { 162 try { 163 build_stage('Test: short', !Settings.RunAllTests) { 164 dir (BuildDir) { 165 //Run the tests from the tests directory 166 sh "make --no-print-directory -C tests archiveerrors=${BuildDir}/tests/crashes/short" 167 } 168 } 169 170 build_stage('Test: full', Settings.RunAllTests) { 171 dir (BuildDir) { 172 //Run the tests from the tests directory 173 sh """make --no-print-directory -C tests timeouts="--timeout=600 --global-timeout=14400" all-tests debug=yes archiveerrors=${BuildDir}/tests/crashes/full-debug""" 174 sh """make --no-print-directory -C tests timeouts="--timeout=600 --global-timeout=14400" all-tests debug=no archiveerrors=${BuildDir}/tests/crashes/full-nodebug""" 175 } 176 } 177 } 178 catch (Exception err) { 179 echo "Archiving core dumps" 180 dir (BuildDir) { 181 archiveArtifacts artifacts: "tests/crashes/**/*", fingerprint: true 182 } 183 throw err 157 build_stage('Test: short', !Settings.RunAllTests) { 158 dir (BuildDir) { 159 //Run the tests from the tests directory 160 sh 'make --no-print-directory -C tests' 161 } 162 } 163 164 build_stage('Test: full', Settings.RunAllTests) { 165 dir (BuildDir) { 166 //Run the tests from the tests directory 167 sh 'make --no-print-directory -C tests timeouts="--timeout=600 --global-timeout=14400" all-tests debug=yes' 168 sh 'make --no-print-directory -C tests timeouts="--timeout=600 --global-timeout=14400" all-tests debug=no ' 169 } 184 170 } 185 171 } … … 215 201 216 202 //Then publish the results 217 do_plot(Settings.RunBenchmark && Settings.Publish, 'compile' , groupCompile , false, 'Compilation')218 do_plot(Settings.RunBenchmark && Settings.Publish, 'compile.diff' , groupCompile , true , 'Compilation (relative)')219 do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch' , groupConcurrency, false, 'Context Switching')220 do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch.diff' , groupConcurrency, true , 'Context Switching (relative)')221 do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex' , groupConcurrency, false, 'Mutual Exclusion')222 do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex.diff' , groupConcurrency, true , 'Mutual Exclusion (relative)')223 do_plot(Settings.RunBenchmark && Settings.Publish, 's cheduling', groupConcurrency, false, 'Internal and External Scheduling')224 do_plot(Settings.RunBenchmark && Settings.Publish, 's cheduling.diff', groupConcurrency, true , 'Internal and External Scheduling (relative)')203 do_plot(Settings.RunBenchmark && Settings.Publish, 'compile' , groupCompile , false, 'Compilation') 204 do_plot(Settings.RunBenchmark && Settings.Publish, 'compile.diff' , groupCompile , true , 'Compilation (relative)') 205 do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch' , groupConcurrency, false, 'Context Switching') 206 do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch.diff', groupConcurrency, true , 'Context Switching (relative)') 207 do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex' , groupConcurrency, false, 'Mutual Exclusion') 208 do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex.diff' , groupConcurrency, true , 'Mutual Exclusion (relative)') 209 do_plot(Settings.RunBenchmark && Settings.Publish, 'signal' , groupConcurrency, false, 'Internal and External Scheduling') 210 do_plot(Settings.RunBenchmark && Settings.Publish, 'signal.diff' , groupConcurrency, true , 'Internal and External Scheduling (relative)') 225 211 } 226 212 } … … 229 215 //Routine responsible of sending the email notification once the build is completed 230 216 //=========================================================================================================== 231 @NonCPS232 def SplitLines(String text) {233 def list = []234 235 text.eachLine {236 list += it237 }238 239 return list240 }241 242 217 def GitLogMessage() { 243 218 if (!Settings || !Settings.GitOldRef || !Settings.GitNewRef) return "\nERROR retrieveing git information!\n" 244 219 245 def oldRef = Settings.GitOldRef 246 def newRef = Settings.GitNewRef 247 248 def revText = sh(returnStdout: true, script: "git rev-list ${oldRef}..${newRef}").trim() 249 def revList = SplitLines( revText ) 250 251 def gitUpdate = "" 252 revList.each { rev -> 253 def type = sh(returnStdout: true, script: "git cat-file -t ${rev}").trim() 254 gitUpdate = gitUpdate + " via ${rev} (${type})" 255 } 256 257 def rev = oldRef 258 def type = sh(returnStdout: true, script: "git cat-file -t ${rev}").trim() 259 gitUpdate = gitUpdate + " from ${rev} (${type})" 260 261 def gitLog = sh(returnStdout: true, script: "git rev-list --format=short ${oldRef}...${newRef}").trim() 262 263 def gitDiff = sh(returnStdout: true, script: "git diff --stat --color ${newRef} ${oldRef}").trim() 264 gitDiff = gitDiff.replace('[32m', '<span style="color: #00AA00;">') 265 gitDiff = gitDiff.replace('[31m', '<span style="color: #AA0000;">') 266 gitDiff = gitDiff.replace('[m', '</span>') 220 sh "${SrcDir}/tools/PrettyGitLogs.sh ${SrcDir} ${BuildDir} ${Settings.GitOldRef} ${Settings.GitNewRef}" 221 222 def gitUpdate = readFile("${BuildDir}/GIT_UPDATE") 223 def gitLog = readFile("${BuildDir}/GIT_LOG") 224 def gitDiff = readFile("${BuildDir}/GIT_DIFF") 267 225 268 226 return """ … … 363 321 BuildSettings(java.util.Collections$UnmodifiableMap param, String branch) { 364 322 switch( param.Compiler ) { 365 case 'gcc-9':366 this.Compiler = new CC_Desc('gcc-9', 'g++-9', 'gcc-9')367 break368 case 'gcc-8':369 this.Compiler = new CC_Desc('gcc-8', 'g++-8', 'gcc-8')370 break371 case 'gcc-7':372 this.Compiler = new CC_Desc('gcc-7', 'g++-7', 'gcc-7')373 break374 323 case 'gcc-6': 375 324 this.Compiler = new CC_Desc('gcc-6', 'g++-6', 'gcc-6') … … 382 331 break 383 332 case 'clang': 384 this.Compiler = new CC_Desc('clang', 'clang++ -6.0', 'gcc-6')333 this.Compiler = new CC_Desc('clang', 'clang++', 'gcc-6') 385 334 break 386 335 default : … … 444 393 description: 'Which compiler to use', \ 445 394 name: 'Compiler', \ 446 choices: 'gcc- 9\ngcc-8\ngcc-7\ngcc-6\ngcc-5\ngcc-4.9\nclang', \447 defaultValue: 'gcc- 8', \395 choices: 'gcc-6\ngcc-5\ngcc-4.9\nclang', \ 396 defaultValue: 'gcc-6', \ 448 397 ], \ 449 398 [$class: 'ChoiceParameterDefinition', \ -
Makefile.in
r3d5701e r9fb8f01 264 264 CCDEPMODE = @CCDEPMODE@ 265 265 CFACC = @CFACC@ 266 CFACC_INSTALL = @CFACC_INSTALL@267 266 CFACPP = @CFACPP@ 268 267 CFA_BACKEND_CC = @CFA_BACKEND_CC@ … … 295 294 FGREP = @FGREP@ 296 295 GREP = @GREP@ 297 HAS_DISTCC = @HAS_DISTCC@298 296 HOST_FLAGS = @HOST_FLAGS@ 299 297 INSTALL = @INSTALL@ -
benchmark/Makefile.am
r3d5701e r9fb8f01 11 11 ## Created On : Sun May 31 09:08:15 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Sat Jan 25 09:20:44 202014 ## Update Count : 25513 ## Last Modified On : Mon Jul 29 18:02:19 2019 14 ## Update Count : 54 15 15 ############################################################################### 16 16 … … 22 22 23 23 AM_CFLAGS = -O2 -Wall -Wextra -I$(srcdir) -lrt -pthread # -Werror 24 AM_CFAFLAGS = -quiet -nodebug 24 AM_CFAFLAGS = -quiet -nodebug -in-tree 25 25 AM_UPPFLAGS = -quiet -nodebug -multi -std=c++14 26 26 … … 28 28 BENCH_V_CFA = $(__bench_v_CFA_$(__quiet)) 29 29 BENCH_V_CXX = $(__bench_v_CXX_$(__quiet)) 30 BENCH_V_GOC = $(__bench_v_GOC_$(__quiet)) 31 BENCH_V_JAVAC = $(__bench_v_JAVAC_$(__quiet)) 30 32 BENCH_V_UPP = $(__bench_v_UPP_$(__quiet)) 31 BENCH_V_GOC = $(__bench_v_GOC_$(__quiet))32 BENCH_V_PY = $(__bench_v_PY_$(__quiet))33 BENCH_V_RUSTC = $(__bench_v_RUSTC_$(__quiet))34 BENCH_V_NODEJS = $(__bench_v_NODEJS_$(__quiet))35 BENCH_V_JAVAC = $(__bench_v_JAVAC_$(__quiet))36 33 37 34 __quiet = verbose … … 39 36 __bench_v_CFA_quiet = @ 40 37 __bench_v_CXX_quiet = @ 38 __bench_v_GOC_quiet = @ 39 __bench_v_JAVAC_quiet = @ 41 40 __bench_v_UPP_quiet = @ 42 __bench_v_GOC_quiet = @43 __bench_v_RUSTC_quiet = @44 __bench_v_JAVAC_quiet = @45 41 __bench_v_CC_verbose = $(AM_V_CC) 46 42 __bench_v_CFA_verbose = $(AM_V_CFA) 47 43 __bench_v_CXX_verbose = $(AM_V_CXX) 44 __bench_v_GOC_verbose = $(AM_V_GOC) 45 __bench_v_JAVAC_verbose = $(AM_V_JAVAC) 48 46 __bench_v_UPP_verbose = $(AM_V_UPP) 49 __bench_v_GOC_verbose = $(AM_V_GOC)50 __bench_v_PY_verbose = $(AM_V_PY)51 __bench_v_RUSTC_verbose = $(AM_V_RUST)52 __bench_v_NODEJS_verbose = $(AM_V_NODEJS)53 __bench_v_JAVAC_verbose = $(AM_V_JAVAC)54 47 55 48 … … 58 51 STATS = ${abs_top_srcdir}/tools/stat.py 59 52 # NEED AT LEAST 4 DATA VALUES FOR BENCHMARKS BECAUSE THE MAX AND MIN VALUES ARE REMOVED 60 repeats = 13# 31 for benchmarks53 repeats = 5 # 31 for benchmarks 61 54 arch = x64 62 55 skipcompile = no … … 69 62 70 63 dummyC.c: 71 echo "int main() { return 0; }" > ${@}64 @echo "int main() { return 0; }" > ${@} 72 65 73 66 dummyCXX.cpp: 74 echo "int main() { return 0; }" > ${@} 75 76 .SILENT: # do not print recipe 67 @echo "int main() { return 0; }" > ${@} 68 77 69 .NOTPARALLEL: 78 .PHONY: jenkins cleancsv 79 80 ## ========================================================================================================= 81 82 all : basic$(EXEEXT) ctxswitch$(EXEEXT) mutex$(EXEEXT) schedint$(EXEEXT) schedext$(EXEEXT) creation$(EXEEXT) 83 84 basic_loop_DURATION = 15000000000 85 basic_function_DURATION = 10000000000 86 basic_tls_fetch_add_DURATION = 10000000000 87 basic_DURATION = 250000000 88 89 ctxswitch_pthread_DURATION = 25000000 90 ctxswitch_rust_thread_DURATION = $(ctxswitch_pthread_DURATION) 91 ctxswitch_cfa_generator_DURATION = 5000000000 92 ctxswitch_nodejs_await_DURATION = 5000000 93 ctxswitch_DURATION = 100000000 94 95 #mutex_java_DURATION = 10000000 96 mutex_DURATION = 50000000 97 98 schedint_pthread_DURATION = 1000000 99 schedint_java_DURATION = $(schedint_pthread_DURATION) 100 schedint_rust_DURATION = $(schedint_pthread_DURATION) 101 schedint_DURATION = 10000000 102 103 schedext_DURATION = 10000000 104 105 creation_pthread_DURATION = 250000 106 creation_rust_thread_DURATION = ${creation_pthread_DURATION} 107 creation_java_thread_DURATION = ${creation_pthread_DURATION} 108 creation_cfa_coroutine_DURATION = 100000000 109 creation_cfa_coroutine_eager_DURATION = 10000000 110 creation_upp_coroutine_DURATION = ${creation_cfa_coroutine_eager_DURATION} 111 creation_cfa_thread_DURATION = 10000000 112 creation_upp_thread_DURATION = ${creation_cfa_thread_DURATION} 113 creation_DURATION = 10000000 70 .PHONY: compile.csv ctxswitch.csv mutex.csv signal.csv 71 72 ## ========================================================================================================= 73 all : ctxswitch$(EXEEXT) mutex$(EXEEXT) signal$(EXEEXT) waitfor$(EXEEXT) creation$(EXEEXT) 114 74 115 75 %.run : %$(EXEEXT) ${REPEAT} 116 rm -f .result.log 117 echo "------------------------------------------------------" 118 echo $< 119 ${REPEAT} ${repeats} -- ./a.out\ 120 $(if ${$(subst -,_,$(basename $@))_DURATION},\ 121 ${$(subst -,_,$(basename $@))_DURATION},\ 122 ${$(firstword $(subst -, ,$(basename $@)))_DURATION}) | tee -a .result.log 123 ${STATS} .result.log 124 echo "------------------------------------------------------" 125 rm -f a.out .result.log *.class 126 127 # ${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 128 83 129 84 %.runquiet : 130 +make $(basename $@) CFLAGS="-w" __quiet=quiet131 taskset -c 1 ./a.out132 rm -f a.out85 @+make $(basename $@) CFLAGS="-w" __quiet=quiet 86 @taskset -c 1 ./a.out 87 @rm -f a.out 133 88 134 89 %.make : 135 printf "${PRINT_FORMAT}" $(basename $(subst compile-,,$@))136 +/usr/bin/time -f ${TIME_FORMAT} make $(basename $@) 2>&190 @printf "${PRINT_FORMAT}" $(basename $(subst compile-,,$@)) 91 @+/usr/bin/time -f ${TIME_FORMAT} make $(basename $@) 2>&1 137 92 138 93 ${REPEAT} : 139 +make -C ${abs_top_builddir}/tools repeat94 @+make -C ${abs_top_builddir}/tools repeat 140 95 141 96 ## ========================================================================================================= … … 143 98 FIX_NEW_LINES = cat $@ | tr "\n" "\t" | sed -r 's/\t,/,/' | tr "\t" "\n" > $@ 144 99 145 cleancsv: 146 rm -f compile.csv basic.csv ctxswitch.csv mutex.csv scheduling.csv 147 148 jenkins$(EXEEXT): cleancsv 100 jenkins$(EXEEXT): 149 101 @DOifskipcompile@ 150 +make compile.csv151 -+make compile.diff.csv102 @+make compile.csv 103 @-+make compile.diff.csv 152 104 @DOendif@ 153 +make ctxswitch.csv154 -+make ctxswitch.diff.csv155 +make mutex.csv156 -+make mutex.diff.csv157 +make scheduling.csv158 -+make scheduling.diff.csv105 @+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 159 111 @DOifskipcompile@ 160 112 cat compile.csv … … 165 117 cat mutex.csv 166 118 -cat mutex.diff.csv 167 cat s cheduling.csv168 -cat s cheduling.diff.csv119 cat signal.csv 120 -cat signal.diff.csv 169 121 170 122 compile.csv: 171 echo "building $@" 172 echo "array,attributes,empty,expression,io,monitor,operators,typeof" > $@ 173 +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-array.make >> $@ 174 +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-attributes.make >> $@ 175 +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-empty.make >> $@ 176 +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-expression.make >> $@ 177 +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-io.make >> $@ 178 +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-monitor.make >> $@ 179 +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-operators.make >> $@ 180 +make TIME_FORMAT='%e' PRINT_FORMAT='' compile-typeof.make >> $@ 181 $(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 $@ 182 133 183 134 ctxswitch.csv: 184 echo "building $@" 185 echo "generator,coroutine,thread" > $@ 186 +make ctxswitch-cfa_generator.runquiet >> $@ && echo -n ',' >> $@ 187 +make ctxswitch-cfa_coroutine.runquiet >> $@ && echo -n ',' >> $@ 188 +make ctxswitch-cfa_thread.runquiet >> $@ 189 $(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 $@ 190 140 191 141 mutex.csv: 192 echo "building $@" 193 echo "1-monitor,2-monitor" > $@ 194 +make mutex-cfa1.runquiet >> $@ && echo -n ',' >> $@ 195 +make mutex-cfa2.runquiet >> $@ 196 $(srcdir)/fixcsv.sh $@ 197 198 scheduling.csv: 199 echo "building $@" 200 echo "schedint-1,schedint-2,schedext-1,schedext-2" > $@ 201 +make schedint-cfa1.runquiet >> $@ && echo -n ',' >> $@ 202 +make schedint-cfa2.runquiet >> $@ && echo -n ',' >> $@ 203 +make schedext-cfa1.runquiet >> $@ && echo -n ',' >> $@ 204 +make schedext-cfa2.runquiet >> $@ 205 $(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 147 signal.csv: 148 @echo "signal-1,signal-2,waitfor-1,waitfor-2" > $@ 149 @+make signal-cfa1.runquiet >> $@ && echo -n ',' >> $@ 150 @+make signal-cfa2.runquiet >> $@ && echo -n ',' >> $@ 151 @+make waitfor-cfa1.runquiet >> $@ && echo -n ',' >> $@ 152 @+make waitfor-cfa2.runquiet >> $@ 153 @$(srcdir)/fixcsv.sh $@ 206 154 207 155 %.diff.csv: %.csv 208 test -e $(srcdir)/baselines/$(arch)/$< || (echo "Error : Missing baseline for ${<}" && false) 209 $(srcdir)/baselines/calc.py $(srcdir)/baselines/$(arch)/$(<) $(<) > $@ 210 211 ## ========================================================================================================= 212 213 BASIC_DEPEND = \ 214 basic-loop.run \ 215 basic-function.run \ 216 basic-fetch_add.run \ 217 basic-ttst_lock.run \ 218 basic-tls-fetch_add.run 219 220 basic-loop$(EXEEXT): 221 $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/loop.c 222 223 basic-function$(EXEEXT): 224 $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/function.c 225 226 basic-fetch_add$(EXEEXT): 227 $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/fetch_add.c 228 229 basic-ttst_lock$(EXEEXT): 230 $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/ttst_lock.c 231 232 basic-tls-fetch_add$(EXEEXT): 233 $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/tls_fetch_add.c 234 235 basic$(EXEEXT): $(BASIC_DEPEND) 236 237 ## ========================================================================================================= 238 239 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 ## ========================================================================================================= 161 loop$(EXEEXT): 162 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=5000000000 $(srcdir)/loop.c 163 164 function$(EXEEXT): 165 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=5000000000 $(srcdir)/function.c 166 167 fetch_add$(EXEEXT): 168 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000 $(srcdir)/fetch_add.c 169 170 ttst_lock$(EXEEXT): 171 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000 $(srcdir)/ttst_lock.c 172 173 tls-fetch_add$(EXEEXT): 174 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000 $(srcdir)/tls-fetch_add.c 175 176 ## ========================================================================================================= 177 CTXSWITCH_DEPEND = \ 178 loop.run \ 179 function.run \ 180 fetch_add.run \ 181 ttst_lock.run \ 182 tls-fetch_add.run \ 183 ctxswitch-pthread.run \ 240 184 ctxswitch-cfa_generator.run \ 241 185 ctxswitch-cfa_coroutine.run \ … … 244 188 ctxswitch-upp_coroutine.run \ 245 189 ctxswitch-upp_thread.run \ 246 ctxswitch-python_coroutine.run \ 247 ctxswitch-nodejs_coroutine.run \ 248 ctxswitch-nodejs_await.run \ 249 ctxswitch-goroutine_thread.run \ 250 ctxswitch-rust_thread.run \ 251 ctxswitch-nodejs_coroutine.run \ 252 ctxswitch-java_thread.run \ 253 ctxswitch-pthread.run 190 ctxswitch-goroutine.run \ 191 ctxswitch-java_thread.run 192 254 193 255 194 if WITH_LIBFIBRE 256 CTXSWITCH_DEPEND += \257 ctxswitch-kos_fibre.run \195 CTXSWITCH_DEPEND += \ 196 ctxswitch-kos_fibre.run \ 258 197 ctxswitch-kos_fibre2.run 198 259 199 260 200 ctxswitch-kos_fibre$(EXEEXT): … … 267 207 ctxswitch$(EXEEXT): $(CTXSWITCH_DEPEND) 268 208 209 ctxswitch-pthread$(EXEEXT): 210 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/pthreads.c 211 269 212 ctxswitch-cfa_generator$(EXEEXT): 270 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_gen.cfa213 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_gen.cfa 271 214 272 215 ctxswitch-cfa_coroutine$(EXEEXT): 273 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_cor.cfa216 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_cor.cfa 274 217 275 218 ctxswitch-cfa_thread$(EXEEXT): 276 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_thrd.cfa219 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_thrd.cfa 277 220 278 221 ctxswitch-cfa_thread2$(EXEEXT): 279 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_thrd2.cfa222 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_thrd2.cfa 280 223 281 224 ctxswitch-upp_coroutine$(EXEEXT): 282 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/ctxswitch/upp_cor.cc225 $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/upp_cor.cc 283 226 284 227 ctxswitch-upp_thread$(EXEEXT): 285 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/ctxswitch/upp_thrd.cc 286 287 ctxswitch-python_coroutine$(EXEEXT): 288 $(BENCH_V_PY)echo "#!/bin/sh" > a.out 289 echo "python3.7 $(srcdir)/ctxswitch/python_cor.py" >> a.out 290 chmod a+x a.out 291 292 ctxswitch-nodejs_coroutine$(EXEEXT): 293 $(BENCH_V_NODEJS)echo "#!/bin/sh" > a.out 294 echo "nodejs $(srcdir)/ctxswitch/node_cor.js" >> a.out 295 chmod a+x a.out 296 297 ctxswitch-nodejs_await$(EXEEXT): 298 $(BENCH_V_NODEJS)echo "#!/bin/sh" > a.out 299 echo "nodejs $(srcdir)/ctxswitch/node_await.js" >> a.out 300 chmod a+x a.out 301 302 ctxswitch-goroutine_thread$(EXEEXT): 228 $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/upp_thrd.cc 229 230 ctxswitch-goroutine$(EXEEXT): 303 231 $(BENCH_V_GOC)go build -o a.out $(srcdir)/ctxswitch/goroutine.go 304 305 ctxswitch-rust_thread$(EXEEXT):306 $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/ctxswitch/rust_thrd.rs307 232 308 233 ctxswitch-java_thread$(EXEEXT): 309 234 $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/ctxswitch/JavaThread.java 310 echo "#!/bin/sh" > a.out 311 echo "java JavaThread" >> a.out 312 chmod a+x a.out 313 314 ctxswitch-pthread$(EXEEXT): 315 $(BENCH_V_CC)$(COMPILE) $(srcdir)/ctxswitch/pthreads.c 316 317 ## ========================================================================================================= 318 319 mutex$(EXEEXT) : \ 235 @echo "#!/bin/sh" > a.out 236 @echo "java JavaThread" >> a.out 237 @chmod a+x a.out 238 239 ## ========================================================================================================= 240 mutex$(EXEEXT) :\ 241 loop.run \ 242 function.run \ 243 fetch_add.run \ 244 mutex-pthread_lock.run \ 245 mutex-upp.run \ 320 246 mutex-cfa1.run \ 321 247 mutex-cfa2.run \ 322 248 mutex-cfa4.run \ 323 mutex-upp.run \ 324 mutex-go.run \ 325 mutex-rust.run \ 326 mutex-java.run \ 327 mutex-pthread.run 328 329 mutex-pthread$(EXEEXT): 330 $(BENCH_V_CC)$(COMPILE) $(srcdir)/mutex/pthreads.c 249 mutex-java_thread.run 250 251 mutex-pthread_lock$(EXEEXT): 252 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=50000000 $(srcdir)/mutex/pthreads.c 253 254 mutex-upp$(EXEEXT): 255 $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/mutex/upp.cc 331 256 332 257 mutex-cfa1$(EXEEXT): 333 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa1.cfa258 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000 $(srcdir)/mutex/cfa1.cfa 334 259 335 260 mutex-cfa2$(EXEEXT): 336 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa2.cfa261 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000 $(srcdir)/mutex/cfa2.cfa 337 262 338 263 mutex-cfa4$(EXEEXT): 339 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa4.cfa 340 341 mutex-upp$(EXEEXT): 342 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/mutex/upp.cc 343 344 mutex-go$(EXEEXT): 345 $(BENCH_V_GOC)go build -o a.out $(srcdir)/mutex/goroutine.go 346 347 mutex-rust$(EXEEXT): 348 $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/mutex/rust.rs 349 350 mutex-java$(EXEEXT): 264 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000 $(srcdir)/mutex/cfa4.cfa 265 266 mutex-java_thread$(EXEEXT): 351 267 $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/mutex/JavaThread.java 352 echo "#!/bin/sh" > a.out 353 echo "java JavaThread" >> a.out 354 chmod a+x a.out 355 356 ## ========================================================================================================= 357 358 schedint$(EXEEXT) : \ 359 schedint-cfa1.run \ 360 schedint-cfa2.run \ 361 schedint-cfa4.run \ 362 schedint-upp.run \ 363 schedint-rust.run \ 364 schedint-java.run \ 365 schedint-pthread.run 366 367 schedint-cfa1$(EXEEXT): 368 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa1.cfa 369 370 schedint-cfa2$(EXEEXT): 371 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa2.cfa 372 373 schedint-cfa4$(EXEEXT): 374 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa4.cfa 375 376 schedint-upp$(EXEEXT): 377 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedint/upp.cc 378 379 schedint-rust$(EXEEXT): 380 $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/schedint/rust.rs 381 382 schedint-java$(EXEEXT): 268 @echo "#!/bin/sh" > a.out 269 @echo "java JavaThread" >> a.out 270 @chmod a+x a.out 271 272 ## ========================================================================================================= 273 signal$(EXEEXT) :\ 274 signal-pthread_cond.run \ 275 signal-upp.run \ 276 signal-cfa1.run \ 277 signal-cfa2.run \ 278 signal-cfa4.run \ 279 signal-java_thread.run 280 281 signal-pthread_cond$(EXEEXT): 282 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000 $(srcdir)/schedint/pthreads.c 283 284 signal-upp$(EXEEXT): 285 $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=5000000 $(srcdir)/schedint/upp.cc 286 287 signal-cfa1$(EXEEXT): 288 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000 $(srcdir)/schedint/cfa1.cfa 289 290 signal-cfa2$(EXEEXT): 291 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000 $(srcdir)/schedint/cfa2.cfa 292 293 signal-cfa4$(EXEEXT): 294 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000 $(srcdir)/schedint/cfa4.cfa 295 296 signal-java_thread$(EXEEXT): 383 297 $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/schedint/JavaThread.java 384 echo "#!/bin/sh" > a.out 385 echo "java JavaThread" >> a.out 386 chmod a+x a.out 387 388 schedint-pthread$(EXEEXT): 389 $(BENCH_V_CC)$(COMPILE) $(srcdir)/schedint/pthreads.c 390 391 ## ========================================================================================================= 392 393 schedext$(EXEEXT) : \ 394 schedext-cfa1.run \ 395 schedext-cfa2.run \ 396 schedext-cfa4.run \ 397 schedext-upp.run \ 398 schedext-goroutine.run 399 400 schedext-cfa1$(EXEEXT): 401 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa1.cfa 402 403 schedext-cfa2$(EXEEXT): 404 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa2.cfa 405 406 schedext-cfa4$(EXEEXT): 407 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa4.cfa 408 409 schedext-upp$(EXEEXT): 410 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedext/upp.cc 411 412 schedext-goroutine$(EXEEXT): 413 $(BENCH_V_GOC)go build -o a.out $(srcdir)/schedext/goroutine.go 414 415 416 ## ========================================================================================================= 417 418 creation$(EXEEXT) : \ 419 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 ## ========================================================================================================= 304 waitfor$(EXEEXT) :\ 305 waitfor-upp.run \ 306 waitfor-cfa1.run \ 307 waitfor-cfa2.run \ 308 waitfor-cfa4.run 309 310 waitfor-upp$(EXEEXT): 311 $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=5000000 $(srcdir)/schedext/upp.cc 312 313 waitfor-cfa1$(EXEEXT): 314 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000 $(srcdir)/schedext/cfa1.cfa 315 316 waitfor-cfa2$(EXEEXT): 317 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000 $(srcdir)/schedext/cfa2.cfa 318 319 waitfor-cfa4$(EXEEXT): 320 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000 $(srcdir)/schedext/cfa4.cfa 321 322 ## ========================================================================================================= 323 creation$(EXEEXT) :\ 324 creation-pthread.run \ 420 325 creation-cfa_coroutine.run \ 421 326 creation-cfa_coroutine_eager.run \ … … 423 328 creation-upp_coroutine.run \ 424 329 creation-upp_thread.run \ 425 creation-python_coroutine.run \ 426 creation-nodejs_coroutine.run \ 427 creation-goroutine_thread.run \ 428 creation-rust_thread.run \ 429 creation-java_thread.run \ 430 creation-pthread.run 431 432 creation-cfa_generator$(EXEEXT): 433 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_gen.cfa 330 creation-goroutine.run \ 331 creation-java_thread.run 434 332 435 333 creation-cfa_coroutine$(EXEEXT): 436 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_cor.cfa334 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_cor.cfa 437 335 438 336 creation-cfa_coroutine_eager$(EXEEXT): 439 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_cor.cfa -DEAGER337 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_cor.cfa -DEAGER 440 338 441 339 creation-cfa_thread$(EXEEXT): 442 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_thrd.cfa340 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_thrd.cfa 443 341 444 342 creation-upp_coroutine$(EXEEXT): 445 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/creation/upp_cor.cc343 $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/creation/upp_cor.cc 446 344 447 345 creation-upp_thread$(EXEEXT): 448 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/creation/upp_thrd.cc 449 450 creation-python_coroutine$(EXEEXT): 451 $(BENCH_V_PY)echo "#!/bin/sh" > a.out 452 echo "python3.7 $(srcdir)/creation/python_cor.py" >> a.out 453 chmod a+x a.out 454 455 creation-nodejs_coroutine$(EXEEXT): 456 $(BENCH_V_NODEJS)echo "#!/bin/sh" > a.out 457 echo "nodejs $(srcdir)/creation/node_cor.js" >> a.out 458 chmod a+x a.out 459 460 creation-goroutine_thread$(EXEEXT): 346 $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/creation/upp_thrd.cc 347 348 creation-pthread$(EXEEXT): 349 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=250000 $(srcdir)/creation/pthreads.c 350 351 creation-goroutine$(EXEEXT): 461 352 $(BENCH_V_GOC)go build -o a.out $(srcdir)/creation/goroutine.go 462 463 creation-rust_thread$(EXEEXT):464 $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/creation/rust_thrd.rs465 353 466 354 creation-java_thread$(EXEEXT): 467 355 $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/creation/JavaThread.java 468 echo "#!/bin/sh" > a.out 469 echo "java JavaThread" >> a.out 470 chmod a+x a.out 471 472 creation-pthread$(EXEEXT): 473 $(BENCH_V_CC)$(COMPILE) $(srcdir)/creation/pthreads.c 474 475 ## ========================================================================================================= 476 477 compile$(EXEEXT) : \ 356 @echo "#!/bin/sh" > a.out 357 @echo "java JavaThread" >> a.out 358 @chmod a+x a.out 359 360 ## ========================================================================================================= 361 362 compile$(EXEEXT) :\ 478 363 compile-array.make \ 479 364 compile-attributes.make \ … … 485 370 compile-typeof.make 486 371 372 487 373 testdir = $(top_srcdir)/tests 488 374 489 375 compile-array$(EXEEXT): 490 $(CFACOMPILE) -fsyntax-only -w $(testdir)/array.cfa376 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/array.cfa 491 377 492 378 compile-attributes$(EXEEXT): 493 $(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa379 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa 494 380 495 381 compile-empty$(EXEEXT): 496 $(CFACOMPILE) -fsyntax-only -w $(srcdir)/compile/empty.cfa382 @$(CFACOMPILE) -fsyntax-only -w $(srcdir)/compile/empty.cfa 497 383 498 384 compile-expression$(EXEEXT): 499 $(CFACOMPILE) -fsyntax-only -w $(testdir)/expression.cfa385 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/expression.cfa 500 386 501 387 compile-io$(EXEEXT): 502 $(CFACOMPILE) -fsyntax-only -w $(testdir)/io1.cfa388 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/io1.cfa 503 389 504 390 compile-monitor$(EXEEXT): 505 $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/monitor.cfa391 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/monitor.cfa 506 392 507 393 compile-operators$(EXEEXT): 508 $(CFACOMPILE) -fsyntax-only -w $(testdir)/operators.cfa394 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/operators.cfa 509 395 510 396 compile-thread$(EXEEXT): 511 $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/thread.cfa397 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/thread.cfa 512 398 513 399 compile-typeof$(EXEEXT): 514 $(CFACOMPILE) -fsyntax-only -w $(testdir)/typeof.cfa 515 516 ## ========================================================================================================= 517 518 size$(EXEEXT) : size-cfa.runquiet 519 520 size-cfa$(EXEEXT): 521 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/size/size.cfa 400 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/typeof.cfa -
benchmark/Makefile.in
r3d5701e r9fb8f01 93 93 EXTRA_PROGRAMS = dummy$(EXEEXT) 94 94 @WITH_LIBFIBRE_TRUE@am__append_1 = \ 95 @WITH_LIBFIBRE_TRUE@ ctxswitch-kos_fibre.run \95 @WITH_LIBFIBRE_TRUE@ ctxswitch-kos_fibre.run \ 96 96 @WITH_LIBFIBRE_TRUE@ ctxswitch-kos_fibre2.run 97 97 … … 214 214 CCDEPMODE = @CCDEPMODE@ 215 215 CFACC = @CFACC@ 216 CFACC_INSTALL = @CFACC_INSTALL@217 216 CFACPP = @CFACPP@ 218 217 CFA_BACKEND_CC = @CFA_BACKEND_CC@ … … 245 244 FGREP = @FGREP@ 246 245 GREP = @GREP@ 247 HAS_DISTCC = @HAS_DISTCC@248 246 HOST_FLAGS = @HOST_FLAGS@ 249 247 INSTALL = @INSTALL@ … … 352 350 LTCFACOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ 353 351 $(LIBTOOLFLAGS) --mode=compile $(CFACC) $(DEFS) \ 354 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(AM_CFLAGS) $(CFAFLAGS) $(CFLAGS) 352 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) \ 353 $(AM_CFLAGS) $(CFLAGS) 355 354 356 355 AM_V_CFA = $(am__v_CFA_@AM_V@) … … 358 357 am__v_CFA_0 = @echo " CFA " $@; 359 358 am__v_CFA_1 = 359 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@) 360 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@) 361 am__v_JAVAC_0 = @echo " JAVAC " $@; 362 am__v_JAVAC_1 = 363 AM_V_GOC = $(am__v_GOC_@AM_V@) 364 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@) 365 am__v_GOC_0 = @echo " GOC " $@; 366 am__v_GOC_1 = 360 367 UPPCC = u++ 361 368 UPPCOMPILE = $(UPPCC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_UPPFLAGS) $(UPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_CFLAGS) $(CFLAGS) … … 364 371 am__v_UPP_0 = @echo " UPP " $@; 365 372 am__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_PY = $(am__v_PY_@AM_V@)371 am__v_PY_ = $(am__v_PY_@AM_DEFAULT_V@)372 am__v_PY_0 = @echo " PYTHON " $@;373 am__v_PY_1 =374 AM_V_RUST = $(am__v_RUST_@AM_V@)375 am__v_RUST_ = $(am__v_RUST_@AM_DEFAULT_V@)376 am__v_RUST_0 = @echo " RUST " $@;377 am__v_RUST_1 =378 AM_V_NODEJS = $(am__v_NODEJS_@AM_V@)379 am__v_NODEJS_ = $(am__v_NODEJS_@AM_DEFAULT_V@)380 am__v_NODEJS_0 = @echo " NODEJS " $@;381 am__v_NODEJS_1 =382 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)383 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)384 am__v_JAVAC_0 = @echo " JAVAC " $@;385 am__v_JAVAC_1 =386 373 387 374 # applies to both programs 388 375 AM_CFLAGS = -O2 -Wall -Wextra -I$(srcdir) -lrt -pthread # -Werror 389 AM_CFAFLAGS = -quiet -nodebug 376 AM_CFAFLAGS = -quiet -nodebug -in-tree 390 377 AM_UPPFLAGS = -quiet -nodebug -multi -std=c++14 391 378 BENCH_V_CC = $(__bench_v_CC_$(__quiet)) 392 379 BENCH_V_CFA = $(__bench_v_CFA_$(__quiet)) 393 380 BENCH_V_CXX = $(__bench_v_CXX_$(__quiet)) 381 BENCH_V_GOC = $(__bench_v_GOC_$(__quiet)) 382 BENCH_V_JAVAC = $(__bench_v_JAVAC_$(__quiet)) 394 383 BENCH_V_UPP = $(__bench_v_UPP_$(__quiet)) 395 BENCH_V_GOC = $(__bench_v_GOC_$(__quiet))396 BENCH_V_PY = $(__bench_v_PY_$(__quiet))397 BENCH_V_RUSTC = $(__bench_v_RUSTC_$(__quiet))398 BENCH_V_NODEJS = $(__bench_v_NODEJS_$(__quiet))399 BENCH_V_JAVAC = $(__bench_v_JAVAC_$(__quiet))400 384 __quiet = verbose 401 385 __bench_v_CC_quiet = @ 402 386 __bench_v_CFA_quiet = @ 403 387 __bench_v_CXX_quiet = @ 388 __bench_v_GOC_quiet = @ 389 __bench_v_JAVAC_quiet = @ 404 390 __bench_v_UPP_quiet = @ 405 __bench_v_GOC_quiet = @406 __bench_v_RUSTC_quiet = @407 __bench_v_JAVAC_quiet = @408 391 __bench_v_CC_verbose = $(AM_V_CC) 409 392 __bench_v_CFA_verbose = $(AM_V_CFA) 410 393 __bench_v_CXX_verbose = $(AM_V_CXX) 394 __bench_v_GOC_verbose = $(AM_V_GOC) 395 __bench_v_JAVAC_verbose = $(AM_V_JAVAC) 411 396 __bench_v_UPP_verbose = $(AM_V_UPP) 412 __bench_v_GOC_verbose = $(AM_V_GOC)413 __bench_v_PY_verbose = $(AM_V_PY)414 __bench_v_RUSTC_verbose = $(AM_V_RUST)415 __bench_v_NODEJS_verbose = $(AM_V_NODEJS)416 __bench_v_JAVAC_verbose = $(AM_V_JAVAC)417 397 TOOLSDIR = ${abs_top_builddir}/tools/ 418 398 REPEAT = ${abs_top_builddir}/tools/repeat 419 399 STATS = ${abs_top_srcdir}/tools/stat.py 420 400 # NEED AT LEAST 4 DATA VALUES FOR BENCHMARKS BECAUSE THE MAX AND MIN VALUES ARE REMOVED 421 repeats = 13# 31 for benchmarks401 repeats = 5 # 31 for benchmarks 422 402 arch = x64 423 403 skipcompile = no … … 425 405 PRINT_FORMAT = %20s: #Comments needed for spacing 426 406 dummy_SOURCES = dummyC.c dummyCXX.cpp 427 basic_loop_DURATION = 15000000000428 basic_function_DURATION = 10000000000429 basic_tls_fetch_add_DURATION = 10000000000430 basic_DURATION = 250000000431 ctxswitch_pthread_DURATION = 25000000432 ctxswitch_rust_thread_DURATION = $(ctxswitch_pthread_DURATION)433 ctxswitch_cfa_generator_DURATION = 5000000000434 ctxswitch_nodejs_await_DURATION = 5000000435 ctxswitch_DURATION = 100000000436 437 #mutex_java_DURATION = 10000000438 mutex_DURATION = 50000000439 schedint_pthread_DURATION = 1000000440 schedint_java_DURATION = $(schedint_pthread_DURATION)441 schedint_rust_DURATION = $(schedint_pthread_DURATION)442 schedint_DURATION = 10000000443 schedext_DURATION = 10000000444 creation_pthread_DURATION = 250000445 creation_rust_thread_DURATION = ${creation_pthread_DURATION}446 creation_java_thread_DURATION = ${creation_pthread_DURATION}447 creation_cfa_coroutine_DURATION = 100000000448 creation_cfa_coroutine_eager_DURATION = 10000000449 creation_upp_coroutine_DURATION = ${creation_cfa_coroutine_eager_DURATION}450 creation_cfa_thread_DURATION = 10000000451 creation_upp_thread_DURATION = ${creation_cfa_thread_DURATION}452 creation_DURATION = 10000000453 407 FIX_NEW_LINES = cat $@ | tr "\n" "\t" | sed -r 's/\t,/,/' | tr "\t" "\n" > $@ 454 BASIC_DEPEND = \ 455 basic-loop.run \ 456 basic-function.run \ 457 basic-fetch_add.run \ 458 basic-ttst_lock.run \ 459 basic-tls-fetch_add.run 460 461 CTXSWITCH_DEPEND = ctxswitch-cfa_generator.run \ 462 ctxswitch-cfa_coroutine.run ctxswitch-cfa_thread.run \ 463 ctxswitch-cfa_thread2.run ctxswitch-upp_coroutine.run \ 464 ctxswitch-upp_thread.run ctxswitch-python_coroutine.run \ 465 ctxswitch-nodejs_coroutine.run ctxswitch-nodejs_await.run \ 466 ctxswitch-goroutine_thread.run ctxswitch-rust_thread.run \ 467 ctxswitch-nodejs_coroutine.run ctxswitch-java_thread.run \ 468 ctxswitch-pthread.run $(am__append_1) 408 CTXSWITCH_DEPEND = loop.run function.run fetch_add.run ttst_lock.run \ 409 tls-fetch_add.run ctxswitch-pthread.run \ 410 ctxswitch-cfa_generator.run ctxswitch-cfa_coroutine.run \ 411 ctxswitch-cfa_thread.run ctxswitch-cfa_thread2.run \ 412 ctxswitch-upp_coroutine.run ctxswitch-upp_thread.run \ 413 ctxswitch-goroutine.run ctxswitch-java_thread.run \ 414 $(am__append_1) 469 415 testdir = $(top_srcdir)/tests 470 416 all: all-am … … 785 731 786 732 dummyC.c: 787 echo "int main() { return 0; }" > ${@}733 @echo "int main() { return 0; }" > ${@} 788 734 789 735 dummyCXX.cpp: 790 echo "int main() { return 0; }" > ${@} 791 792 .SILENT: # do not print recipe 736 @echo "int main() { return 0; }" > ${@} 737 793 738 .NOTPARALLEL: 794 .PHONY: jenkins cleancsv795 796 all : basic$(EXEEXT) ctxswitch$(EXEEXT) mutex$(EXEEXT) schedint$(EXEEXT) schedext$(EXEEXT) creation$(EXEEXT)739 .PHONY: compile.csv ctxswitch.csv mutex.csv signal.csv 740 741 all : ctxswitch$(EXEEXT) mutex$(EXEEXT) signal$(EXEEXT) waitfor$(EXEEXT) creation$(EXEEXT) 797 742 798 743 %.run : %$(EXEEXT) ${REPEAT} 799 rm -f .result.log 800 echo "------------------------------------------------------" 801 echo $< 802 ${REPEAT} ${repeats} -- ./a.out\ 803 $(if ${$(subst -,_,$(basename $@))_DURATION},\ 804 ${$(subst -,_,$(basename $@))_DURATION},\ 805 ${$(firstword $(subst -, ,$(basename $@)))_DURATION}) | tee -a .result.log 806 ${STATS} .result.log 807 echo "------------------------------------------------------" 808 rm -f a.out .result.log *.class 809 810 # ${REPEAT} ${repeats} -- /usr/bin/time -f "%Uu %Ss %Er %Mkb" ./a.out 744 @rm -f .result.log 745 @echo "------------------------------------------------------" 746 @echo $< 747 @${REPEAT} ${repeats} ./a.out | tee -a .result.log 748 @${STATS} .result.log 749 @echo "------------------------------------------------------" 750 @rm -f a.out .result.log *.class 811 751 812 752 %.runquiet : 813 +make $(basename $@) CFLAGS="-w" __quiet=quiet814 taskset -c 1 ./a.out815 rm -f a.out753 @+make $(basename $@) CFLAGS="-w" __quiet=quiet 754 @taskset -c 1 ./a.out 755 @rm -f a.out 816 756 817 757 %.make : 818 printf "${PRINT_FORMAT}" $(basename $(subst compile-,,$@))819 +/usr/bin/time -f ${TIME_FORMAT} make $(basename $@) 2>&1758 @printf "${PRINT_FORMAT}" $(basename $(subst compile-,,$@)) 759 @+/usr/bin/time -f ${TIME_FORMAT} make $(basename $@) 2>&1 820 760 821 761 ${REPEAT} : 822 +make -C ${abs_top_builddir}/tools repeat 823 824 cleancsv: 825 rm -f compile.csv basic.csv ctxswitch.csv mutex.csv scheduling.csv 826 827 jenkins$(EXEEXT): cleancsv 762 @+make -C ${abs_top_builddir}/tools repeat 763 764 jenkins$(EXEEXT): 828 765 @DOifskipcompile@ 829 +make compile.csv830 -+make compile.diff.csv766 @+make compile.csv 767 @-+make compile.diff.csv 831 768 @DOendif@ 832 +make ctxswitch.csv833 -+make ctxswitch.diff.csv834 +make mutex.csv835 -+make mutex.diff.csv836 +make scheduling.csv837 -+make scheduling.diff.csv769 @+make ctxswitch.csv 770 @-+make ctxswitch.diff.csv 771 @+make mutex.csv 772 @-+make mutex.diff.csv 773 @+make signal.csv 774 @-+make signal.diff.csv 838 775 @DOifskipcompile@ 839 776 cat compile.csv … … 844 781 cat mutex.csv 845 782 -cat mutex.diff.csv 846 cat s cheduling.csv847 -cat s cheduling.diff.csv783 cat signal.csv 784 -cat signal.diff.csv 848 785 849 786 compile.csv: 850 echo "building $@" 851 echo "array,attributes,empty,expression,io,monitor,operators,typeof" > $@ 852 +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-array.make >> $@ 853 +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-attributes.make >> $@ 854 +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-empty.make >> $@ 855 +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-expression.make >> $@ 856 +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-io.make >> $@ 857 +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-monitor.make >> $@ 858 +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-operators.make >> $@ 859 +make TIME_FORMAT='%e' PRINT_FORMAT='' compile-typeof.make >> $@ 860 $(srcdir)/fixcsv.sh $@ 787 @echo "array,attributes,empty,expression,io,monitor,operators,typeof" > $@ 788 @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-array.make >> $@ 789 @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-attributes.make >> $@ 790 @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-empty.make >> $@ 791 @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-expression.make >> $@ 792 @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-io.make >> $@ 793 @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-monitor.make >> $@ 794 @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-operators.make >> $@ 795 @+make TIME_FORMAT='%e' PRINT_FORMAT='' compile-typeof.make >> $@ 796 @$(srcdir)/fixcsv.sh $@ 861 797 862 798 ctxswitch.csv: 863 echo "building $@" 864 echo "generator,coroutine,thread" > $@ 865 +make ctxswitch-cfa_generator.runquiet >> $@ && echo -n ',' >> $@ 866 +make ctxswitch-cfa_coroutine.runquiet >> $@ && echo -n ',' >> $@ 867 +make ctxswitch-cfa_thread.runquiet >> $@ 868 $(srcdir)/fixcsv.sh $@ 799 @echo "generator,coroutine,thread" > $@ 800 @+make ctxswitch-cfa_generator.runquiet >> $@ && echo -n ',' >> $@ 801 @+make ctxswitch-cfa_coroutine.runquiet >> $@ && echo -n ',' >> $@ 802 @+make ctxswitch-cfa_thread.runquiet >> $@ 803 @$(srcdir)/fixcsv.sh $@ 869 804 870 805 mutex.csv: 871 echo "building $@" 872 echo "1-monitor,2-monitor" > $@ 873 +make mutex-cfa1.runquiet >> $@ && echo -n ',' >> $@ 874 +make mutex-cfa2.runquiet >> $@ 875 $(srcdir)/fixcsv.sh $@ 876 877 scheduling.csv: 878 echo "building $@" 879 echo "schedint-1,schedint-2,schedext-1,schedext-2" > $@ 880 +make schedint-cfa1.runquiet >> $@ && echo -n ',' >> $@ 881 +make schedint-cfa2.runquiet >> $@ && echo -n ',' >> $@ 882 +make schedext-cfa1.runquiet >> $@ && echo -n ',' >> $@ 883 +make schedext-cfa2.runquiet >> $@ 884 $(srcdir)/fixcsv.sh $@ 806 @echo "1-monitor,2-monitor" > $@ 807 @+make mutex-cfa1.runquiet >> $@ && echo -n ',' >> $@ 808 @+make mutex-cfa2.runquiet >> $@ 809 @$(srcdir)/fixcsv.sh $@ 810 811 signal.csv: 812 @echo "signal-1,signal-2,waitfor-1,waitfor-2" > $@ 813 @+make signal-cfa1.runquiet >> $@ && echo -n ',' >> $@ 814 @+make signal-cfa2.runquiet >> $@ && echo -n ',' >> $@ 815 @+make waitfor-cfa1.runquiet >> $@ && echo -n ',' >> $@ 816 @+make waitfor-cfa2.runquiet >> $@ 817 @$(srcdir)/fixcsv.sh $@ 885 818 886 819 %.diff.csv: %.csv 887 test -e $(srcdir)/baselines/$(arch)/$< || (echo "Error : Missing baseline for ${<}" && false) 888 $(srcdir)/baselines/calc.py $(srcdir)/baselines/$(arch)/$(<) $(<) > $@ 889 890 basic-loop$(EXEEXT): 891 $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/loop.c 892 893 basic-function$(EXEEXT): 894 $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/function.c 895 896 basic-fetch_add$(EXEEXT): 897 $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/fetch_add.c 898 899 basic-ttst_lock$(EXEEXT): 900 $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/ttst_lock.c 901 902 basic-tls-fetch_add$(EXEEXT): 903 $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/tls_fetch_add.c 904 905 basic$(EXEEXT): $(BASIC_DEPEND) 820 @test -e $(srcdir)/baselines/$(arch)/$< || (echo "Error : Missing baseline for ${<}" && false) 821 @$(srcdir)/baselines/calc.py $(srcdir)/baselines/$(arch)/$(<) $(<) > $@ 822 823 loop$(EXEEXT): 824 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=5000000000 $(srcdir)/loop.c 825 826 function$(EXEEXT): 827 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=5000000000 $(srcdir)/function.c 828 829 fetch_add$(EXEEXT): 830 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000 $(srcdir)/fetch_add.c 831 832 ttst_lock$(EXEEXT): 833 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000 $(srcdir)/ttst_lock.c 834 835 tls-fetch_add$(EXEEXT): 836 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000 $(srcdir)/tls-fetch_add.c 906 837 907 838 @WITH_LIBFIBRE_TRUE@ctxswitch-kos_fibre$(EXEEXT): … … 913 844 ctxswitch$(EXEEXT): $(CTXSWITCH_DEPEND) 914 845 846 ctxswitch-pthread$(EXEEXT): 847 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/pthreads.c 848 915 849 ctxswitch-cfa_generator$(EXEEXT): 916 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_gen.cfa850 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_gen.cfa 917 851 918 852 ctxswitch-cfa_coroutine$(EXEEXT): 919 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_cor.cfa853 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_cor.cfa 920 854 921 855 ctxswitch-cfa_thread$(EXEEXT): 922 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_thrd.cfa856 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_thrd.cfa 923 857 924 858 ctxswitch-cfa_thread2$(EXEEXT): 925 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_thrd2.cfa859 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_thrd2.cfa 926 860 927 861 ctxswitch-upp_coroutine$(EXEEXT): 928 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/ctxswitch/upp_cor.cc862 $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/upp_cor.cc 929 863 930 864 ctxswitch-upp_thread$(EXEEXT): 931 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/ctxswitch/upp_thrd.cc 932 933 ctxswitch-python_coroutine$(EXEEXT): 934 $(BENCH_V_PY)echo "#!/bin/sh" > a.out 935 echo "python3.7 $(srcdir)/ctxswitch/python_cor.py" >> a.out 936 chmod a+x a.out 937 938 ctxswitch-nodejs_coroutine$(EXEEXT): 939 $(BENCH_V_NODEJS)echo "#!/bin/sh" > a.out 940 echo "nodejs $(srcdir)/ctxswitch/node_cor.js" >> a.out 941 chmod a+x a.out 942 943 ctxswitch-nodejs_await$(EXEEXT): 944 $(BENCH_V_NODEJS)echo "#!/bin/sh" > a.out 945 echo "nodejs $(srcdir)/ctxswitch/node_await.js" >> a.out 946 chmod a+x a.out 947 948 ctxswitch-goroutine_thread$(EXEEXT): 865 $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/upp_thrd.cc 866 867 ctxswitch-goroutine$(EXEEXT): 949 868 $(BENCH_V_GOC)go build -o a.out $(srcdir)/ctxswitch/goroutine.go 950 951 ctxswitch-rust_thread$(EXEEXT):952 $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/ctxswitch/rust_thrd.rs953 869 954 870 ctxswitch-java_thread$(EXEEXT): 955 871 $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/ctxswitch/JavaThread.java 956 echo "#!/bin/sh" > a.out 957 echo "java JavaThread" >> a.out 958 chmod a+x a.out 959 960 ctxswitch-pthread$(EXEEXT): 961 $(BENCH_V_CC)$(COMPILE) $(srcdir)/ctxswitch/pthreads.c 962 963 mutex$(EXEEXT) : \ 872 @echo "#!/bin/sh" > a.out 873 @echo "java JavaThread" >> a.out 874 @chmod a+x a.out 875 876 mutex$(EXEEXT) :\ 877 loop.run \ 878 function.run \ 879 fetch_add.run \ 880 mutex-pthread_lock.run \ 881 mutex-upp.run \ 964 882 mutex-cfa1.run \ 965 883 mutex-cfa2.run \ 966 884 mutex-cfa4.run \ 967 mutex-upp.run \ 968 mutex-go.run \ 969 mutex-rust.run \ 970 mutex-java.run \ 971 mutex-pthread.run 972 973 mutex-pthread$(EXEEXT): 974 $(BENCH_V_CC)$(COMPILE) $(srcdir)/mutex/pthreads.c 885 mutex-java_thread.run 886 887 mutex-pthread_lock$(EXEEXT): 888 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=50000000 $(srcdir)/mutex/pthreads.c 889 890 mutex-upp$(EXEEXT): 891 $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/mutex/upp.cc 975 892 976 893 mutex-cfa1$(EXEEXT): 977 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa1.cfa894 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000 $(srcdir)/mutex/cfa1.cfa 978 895 979 896 mutex-cfa2$(EXEEXT): 980 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa2.cfa897 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000 $(srcdir)/mutex/cfa2.cfa 981 898 982 899 mutex-cfa4$(EXEEXT): 983 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa4.cfa 984 985 mutex-upp$(EXEEXT): 986 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/mutex/upp.cc 987 988 mutex-go$(EXEEXT): 989 $(BENCH_V_GOC)go build -o a.out $(srcdir)/mutex/goroutine.go 990 991 mutex-rust$(EXEEXT): 992 $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/mutex/rust.rs 993 994 mutex-java$(EXEEXT): 900 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000 $(srcdir)/mutex/cfa4.cfa 901 902 mutex-java_thread$(EXEEXT): 995 903 $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/mutex/JavaThread.java 996 echo "#!/bin/sh" > a.out 997 echo "java JavaThread" >> a.out 998 chmod a+x a.out 999 1000 schedint$(EXEEXT) : \ 1001 schedint-cfa1.run \ 1002 schedint-cfa2.run \ 1003 schedint-cfa4.run \ 1004 schedint-upp.run \ 1005 schedint-rust.run \ 1006 schedint-java.run \ 1007 schedint-pthread.run 1008 1009 schedint-cfa1$(EXEEXT): 1010 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa1.cfa 1011 1012 schedint-cfa2$(EXEEXT): 1013 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa2.cfa 1014 1015 schedint-cfa4$(EXEEXT): 1016 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa4.cfa 1017 1018 schedint-upp$(EXEEXT): 1019 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedint/upp.cc 1020 1021 schedint-rust$(EXEEXT): 1022 $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/schedint/rust.rs 1023 1024 schedint-java$(EXEEXT): 904 @echo "#!/bin/sh" > a.out 905 @echo "java JavaThread" >> a.out 906 @chmod a+x a.out 907 908 signal$(EXEEXT) :\ 909 signal-pthread_cond.run \ 910 signal-upp.run \ 911 signal-cfa1.run \ 912 signal-cfa2.run \ 913 signal-cfa4.run \ 914 signal-java_thread.run 915 916 signal-pthread_cond$(EXEEXT): 917 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000 $(srcdir)/schedint/pthreads.c 918 919 signal-upp$(EXEEXT): 920 $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=5000000 $(srcdir)/schedint/upp.cc 921 922 signal-cfa1$(EXEEXT): 923 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000 $(srcdir)/schedint/cfa1.cfa 924 925 signal-cfa2$(EXEEXT): 926 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000 $(srcdir)/schedint/cfa2.cfa 927 928 signal-cfa4$(EXEEXT): 929 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000 $(srcdir)/schedint/cfa4.cfa 930 931 signal-java_thread$(EXEEXT): 1025 932 $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/schedint/JavaThread.java 1026 echo "#!/bin/sh" > a.out 1027 echo "java JavaThread" >> a.out 1028 chmod a+x a.out 1029 1030 schedint-pthread$(EXEEXT): 1031 $(BENCH_V_CC)$(COMPILE) $(srcdir)/schedint/pthreads.c 1032 1033 schedext$(EXEEXT) : \ 1034 schedext-cfa1.run \ 1035 schedext-cfa2.run \ 1036 schedext-cfa4.run \ 1037 schedext-upp.run \ 1038 schedext-goroutine.run 1039 1040 schedext-cfa1$(EXEEXT): 1041 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa1.cfa 1042 1043 schedext-cfa2$(EXEEXT): 1044 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa2.cfa 1045 1046 schedext-cfa4$(EXEEXT): 1047 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa4.cfa 1048 1049 schedext-upp$(EXEEXT): 1050 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedext/upp.cc 1051 1052 schedext-goroutine$(EXEEXT): 1053 $(BENCH_V_GOC)go build -o a.out $(srcdir)/schedext/goroutine.go 1054 1055 creation$(EXEEXT) : \ 1056 creation-cfa_generator.run \ 933 @echo "#!/bin/sh" > a.out 934 @echo "java JavaThread" >> a.out 935 @chmod a+x a.out 936 937 waitfor$(EXEEXT) :\ 938 waitfor-upp.run \ 939 waitfor-cfa1.run \ 940 waitfor-cfa2.run \ 941 waitfor-cfa4.run 942 943 waitfor-upp$(EXEEXT): 944 $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=5000000 $(srcdir)/schedext/upp.cc 945 946 waitfor-cfa1$(EXEEXT): 947 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000 $(srcdir)/schedext/cfa1.cfa 948 949 waitfor-cfa2$(EXEEXT): 950 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000 $(srcdir)/schedext/cfa2.cfa 951 952 waitfor-cfa4$(EXEEXT): 953 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000 $(srcdir)/schedext/cfa4.cfa 954 955 creation$(EXEEXT) :\ 956 creation-pthread.run \ 1057 957 creation-cfa_coroutine.run \ 1058 958 creation-cfa_coroutine_eager.run \ … … 1060 960 creation-upp_coroutine.run \ 1061 961 creation-upp_thread.run \ 1062 creation-python_coroutine.run \ 1063 creation-nodejs_coroutine.run \ 1064 creation-goroutine_thread.run \ 1065 creation-rust_thread.run \ 1066 creation-java_thread.run \ 1067 creation-pthread.run 1068 1069 creation-cfa_generator$(EXEEXT): 1070 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_gen.cfa 962 creation-goroutine.run \ 963 creation-java_thread.run 1071 964 1072 965 creation-cfa_coroutine$(EXEEXT): 1073 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_cor.cfa966 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_cor.cfa 1074 967 1075 968 creation-cfa_coroutine_eager$(EXEEXT): 1076 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_cor.cfa -DEAGER969 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_cor.cfa -DEAGER 1077 970 1078 971 creation-cfa_thread$(EXEEXT): 1079 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_thrd.cfa972 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_thrd.cfa 1080 973 1081 974 creation-upp_coroutine$(EXEEXT): 1082 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/creation/upp_cor.cc975 $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/creation/upp_cor.cc 1083 976 1084 977 creation-upp_thread$(EXEEXT): 1085 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/creation/upp_thrd.cc 1086 1087 creation-python_coroutine$(EXEEXT): 1088 $(BENCH_V_PY)echo "#!/bin/sh" > a.out 1089 echo "python3.7 $(srcdir)/creation/python_cor.py" >> a.out 1090 chmod a+x a.out 1091 1092 creation-nodejs_coroutine$(EXEEXT): 1093 $(BENCH_V_NODEJS)echo "#!/bin/sh" > a.out 1094 echo "nodejs $(srcdir)/creation/node_cor.js" >> a.out 1095 chmod a+x a.out 1096 1097 creation-goroutine_thread$(EXEEXT): 978 $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/creation/upp_thrd.cc 979 980 creation-pthread$(EXEEXT): 981 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=250000 $(srcdir)/creation/pthreads.c 982 983 creation-goroutine$(EXEEXT): 1098 984 $(BENCH_V_GOC)go build -o a.out $(srcdir)/creation/goroutine.go 1099 1100 creation-rust_thread$(EXEEXT):1101 $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/creation/rust_thrd.rs1102 985 1103 986 creation-java_thread$(EXEEXT): 1104 987 $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/creation/JavaThread.java 1105 echo "#!/bin/sh" > a.out 1106 echo "java JavaThread" >> a.out 1107 chmod a+x a.out 1108 1109 creation-pthread$(EXEEXT): 1110 $(BENCH_V_CC)$(COMPILE) $(srcdir)/creation/pthreads.c 1111 1112 compile$(EXEEXT) : \ 988 @echo "#!/bin/sh" > a.out 989 @echo "java JavaThread" >> a.out 990 @chmod a+x a.out 991 992 compile$(EXEEXT) :\ 1113 993 compile-array.make \ 1114 994 compile-attributes.make \ … … 1121 1001 1122 1002 compile-array$(EXEEXT): 1123 $(CFACOMPILE) -fsyntax-only -w $(testdir)/array.cfa1003 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/array.cfa 1124 1004 1125 1005 compile-attributes$(EXEEXT): 1126 $(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa1006 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa 1127 1007 1128 1008 compile-empty$(EXEEXT): 1129 $(CFACOMPILE) -fsyntax-only -w $(srcdir)/compile/empty.cfa1009 @$(CFACOMPILE) -fsyntax-only -w $(srcdir)/compile/empty.cfa 1130 1010 1131 1011 compile-expression$(EXEEXT): 1132 $(CFACOMPILE) -fsyntax-only -w $(testdir)/expression.cfa1012 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/expression.cfa 1133 1013 1134 1014 compile-io$(EXEEXT): 1135 $(CFACOMPILE) -fsyntax-only -w $(testdir)/io1.cfa1015 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/io1.cfa 1136 1016 1137 1017 compile-monitor$(EXEEXT): 1138 $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/monitor.cfa1018 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/monitor.cfa 1139 1019 1140 1020 compile-operators$(EXEEXT): 1141 $(CFACOMPILE) -fsyntax-only -w $(testdir)/operators.cfa1021 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/operators.cfa 1142 1022 1143 1023 compile-thread$(EXEEXT): 1144 $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/thread.cfa1024 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/thread.cfa 1145 1025 1146 1026 compile-typeof$(EXEEXT): 1147 $(CFACOMPILE) -fsyntax-only -w $(testdir)/typeof.cfa 1148 1149 size$(EXEEXT) : size-cfa.runquiet 1150 1151 size-cfa$(EXEEXT): 1152 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/size/size.cfa 1027 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/typeof.cfa 1153 1028 1154 1029 # Tell versions [3.59,3.63) of GNU make to not export all variables. -
benchmark/bench.h
r3d5701e r9fb8f01 5 5 #endif 6 6 #include <stdlib.h> 7 #include <stdint.h> // uint64_t 8 #include <unistd.h> // sysconf 7 #include <unistd.h> // sysconf 9 8 #if ! defined(__cforall) 10 9 #include <time.h> … … 16 15 17 16 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 17 static inline unsigned long long int bench_time() { 18 struct timespec ts; 19 clock_gettime( 20 #if defined( __linux__ ) 21 CLOCK_THREAD_CPUTIME_ID, 22 #elif defined( __freebsd__ ) 23 CLOCK_PROF, 24 #elif defined( __solaris__ ) 25 CLOCK_HIGHRES, 26 #else 27 #error uC++ : internal error, unsupported architecture 28 #endif 29 &ts ); 30 return 1000000000LL * ts.tv_sec + ts.tv_nsec; 31 } // Time 23 32 24 33 #ifndef BENCH_N 25 #define BENCH_N 1000000034 #define BENCH_N 500 //10000000 26 35 #endif 27 36 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 36 37 #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; \ 38 44 StartTime = bench_time(); \ 39 statement; \45 statement; \ 40 46 EndTime = bench_time(); \ 41 double output = (double)( EndTime - StartTime ) / times;42 47 double output = \ 48 (double)( EndTime - StartTime ) / n; 43 49 44 50 #if defined(__cforall) … … 47 53 } 48 54 #endif 49 #if defined(__U_CPLUSPLUS__)50 unsigned int uDefaultPreemption() {51 return 0;52 }53 #endif -
benchmark/creation/JavaThread.java
r3d5701e r9fb8f01 26 26 static int x = 2; 27 27 28 static private int times = Integer.parseInt("10000") ;28 static private final int NoOfTimes = Integer.parseInt("10000") ; 29 29 30 30 public static class MyThread extends Thread { … … 33 33 } 34 34 public static void helper() throws InterruptedException { 35 for(int i = 1; i <= times; i += 1) {35 for(int i = 1; i <= NoOfTimes; i += 1) { 36 36 MyThread m = new MyThread(); 37 37 x = nextRandom( x ); … … 44 44 helper(); 45 45 long end = System.nanoTime(); 46 System.out.println( (end - start) / times );46 System.out.println( (end - start) / NoOfTimes ); 47 47 } 48 48 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 ; ) { 53 50 InnerMain(); 54 Thread.sleep(2000); // 2 seconds51 Thread.sleep(2000); // 2 seconds 55 52 x = nextRandom(x); 56 53 } … … 58 55 } 59 56 } 60 61 // Local Variables: //62 // tab-width: 4 //63 // End: // -
benchmark/creation/cfa_cor.cfa
r3d5701e r9fb8f01 5 5 6 6 coroutine MyCoroutine {}; 7 void ?{} ( MyCoroutine & this) {7 void ?{} (MyCoroutine & this) { 8 8 #ifdef EAGER 9 resume( this);9 resume(this); 10 10 #endif 11 11 } 12 void main( MyCoroutine &) {}12 void main(MyCoroutine &) {} 13 13 14 int main( int argc, char * argv[] ) { 15 BENCH_START() 14 int main(int argc, char* argv[]) { 16 15 BENCH( 17 for ( times) {18 MyCoroutine c;16 for ( i; n ) { 17 MyCoroutine m; 19 18 }, 20 19 result 21 20 ) 22 printf( "%g\n", result ); 21 22 printf("%g\n", result); 23 23 } 24 25 // Local Variables: //26 // tab-width: 4 //27 // End: // -
benchmark/creation/cfa_thrd.cfa
r3d5701e r9fb8f01 7 7 void main(MyThread &) {} 8 8 9 int main( int argc, char * argv[] ) { 10 BENCH_START() 9 int main(int argc, char* argv[]) { 11 10 BENCH( 12 for ( times) {11 for ( i; n ) { 13 12 MyThread m; 14 13 }, 15 14 result 16 15 ) 17 printf( "%g\n", result ); 16 17 printf("%g\n", result); 18 18 } 19 20 // Local Variables: //21 // tab-width: 4 //22 // End: // -
benchmark/creation/goroutine.go
r3d5701e r9fb8f01 2 2 3 3 import ( 4 "fmt" 5 "time" 6 "os" 7 "strconv" 4 "fmt" 5 "time" 8 6 ) 9 7 … … 19 17 20 18 func 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 25 20 start := time.Now() 26 for i := 1; i <= times; i += 1 {21 for i := 1; i <= NoOfTimes; i += 1 { 27 22 go noop() // creation 28 <- shake // wait for completion29 23 } 30 24 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 32 27 } 33 34 // Local Variables: //35 // tab-width: 4 //36 // End: // -
benchmark/creation/pthreads.c
r3d5701e r9fb8f01 4 4 #include "bench.h" 5 5 6 static void * foo(void *arg) {6 static void *foo(void *arg) { 7 7 return arg; 8 8 } 9 9 10 int main( int argc, char * argv[] ) { 11 BENCH_START() 10 int main(int argc, char* argv[]) { 12 11 BENCH( 13 for (size_t i = 0; i < times; i++) {12 for (size_t i = 0; i < n; i++) { 14 13 pthread_t thread; 15 14 if (pthread_create(&thread, NULL, foo, NULL) < 0) { … … 17 16 return 1; 18 17 } 18 19 19 if (pthread_join( thread, NULL) < 0) { 20 20 perror( "failure" ); … … 24 24 result 25 25 ) 26 printf( "%g\n", result ); 26 27 printf("%g\n", result); 27 28 } 28 29 // Local Variables: //30 // tab-width: 4 //31 // End: // -
benchmark/creation/upp_cor.cc
r3d5701e r9fb8f01 5 5 _Coroutine MyCor { 6 6 void main() {} 7 public:8 MyCor() { resume(); }9 7 }; 10 8 11 int main( int argc, char * argv[] ) { 12 BENCH_START() 9 int main(int argc, char* argv[]) { 13 10 BENCH( 14 for (size_t i = 0; i < times; i++) {11 for (size_t i = 0; i < n; i++) { 15 12 MyCor m; 16 13 }, 17 14 result 18 15 ) 19 printf( "%g\n", result ); 16 17 printf("%g\n", result); 20 18 } 21 22 // Local Variables: //23 // tab-width: 4 //24 // End: // -
benchmark/creation/upp_thrd.cc
r3d5701e r9fb8f01 7 7 }; 8 8 9 int main( int argc, char * argv[] ) { 10 BENCH_START() 9 int main(int argc, char* argv[]) { 11 10 BENCH( 12 for (size_t i = 0; i < times; i++) {11 for (size_t i = 0; i < n; i++) { 13 12 MyThread m; 14 13 }, 15 14 result 16 15 ) 17 printf( "%g\n", result ); 16 17 printf("%g\n", result); 18 18 } 19 20 // Local Variables: //21 // tab-width: 4 //22 // End: // -
benchmark/ctxswitch/JavaThread.java
r3d5701e r9fb8f01 26 26 static int x = 2; 27 27 28 static private int times = Integer.parseInt("100000");28 static private final int NoOfTimes = Integer.parseInt("1000000") ; 29 29 30 30 public static void helper() { 31 for(int i = 1; i <= times; i += 1) {31 for(int i = 1; i <= NoOfTimes; i += 1) { 32 32 Thread.yield(); 33 33 } … … 37 37 helper(); 38 38 long end = System.nanoTime(); 39 System.out.println( (end - start) / times );39 System.out.println( (end - start) / NoOfTimes ); 40 40 } 41 41 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 ; ) { 46 43 InnerMain(); 47 Thread.sleep(2000); // 2 seconds44 Thread.sleep(2000); // 2 seconds 48 45 x = nextRandom(x); 49 46 } … … 51 48 } 52 49 } 53 54 // Local Variables: //55 // tab-width: 4 //56 // End: // -
benchmark/ctxswitch/cfa_cor.cfa
r3d5701e r9fb8f01 4 4 #include "bench.h" 5 5 6 coroutine C {} c; 7 void main( __attribute__((unused)) C & ) { 8 while () { 6 coroutine GreatSuspender {}; 7 8 void ?{}( GreatSuspender & this ) { 9 prime(this); 10 } 11 12 void main( __attribute__((unused)) GreatSuspender & this ) { 13 while( true ) { 9 14 suspend(); 10 15 } 11 16 } 12 int main( int argc, char * argv[] ) { 13 BENCH_START() 17 18 int main(int argc, char* argv[]) { 19 GreatSuspender s; 20 14 21 BENCH( 15 for ( times) {16 resume( c);22 for ( i; n ) { 23 resume( s ); 17 24 }, 18 25 result 19 26 ) 20 printf( "%g\n", result ); 27 28 printf("%g\n", result); 21 29 } 22 23 // Local Variables: //24 // tab-width: 4 //25 // End: // -
benchmark/ctxswitch/cfa_cor_then.cfa
r3d5701e r9fb8f01 6 6 void noOp(void) {} 7 7 8 coroutine C {} c;8 coroutine GreatSuspender {}; 9 9 10 void ?{}( C& this ) {10 void ?{}( GreatSuspender & this ) { 11 11 prime(this); 12 12 } 13 13 14 void main( __attribute__((unused)) C& this ) {15 while () {14 void main( __attribute__((unused)) GreatSuspender & this ) { 15 while( true ) { 16 16 suspend_then(noOp); 17 17 } 18 18 } 19 19 20 int main( int argc, char * argv[] ) { 21 BENCH_START() 20 int main(int argc, char* argv[]) { 21 GreatSuspender s; 22 22 23 BENCH( 23 for ( times) {24 resume( c);24 for ( i; n ) { 25 resume( s ); 25 26 }, 26 27 result 27 28 ) 28 printf( "%g\n", result ); 29 30 printf("%g\n", result); 29 31 } 30 31 // Local Variables: //32 // tab-width: 4 //33 // End: // -
benchmark/ctxswitch/cfa_gen.cfa
r3d5701e r9fb8f01 3 3 typedef struct { 4 4 void * next; 5 } C;5 } GreatSuspender; 6 6 7 void comain( C * c) {8 if ( __builtin_expect(c->next != 0, 1) ) goto *(c->next);9 c->next = &&s1;7 void comain( GreatSuspender * this ) { 8 if ( __builtin_expect(this->next != 0, 1) ) goto *(this->next); 9 this->next = &&s1; 10 10 for () { 11 return;11 return; 12 12 s1: ; 13 13 } 14 14 } 15 15 16 int main( int argc, char * argv[]) {17 BENCH_START() 18 C c = { 0 }; 16 int main(int argc, char* argv[]) { 17 GreatSuspender s = { 0 }; 18 19 19 BENCH( 20 for ( times) {21 comain( & c);20 for ( i; n ) { 21 comain( &s ); 22 22 }, 23 23 result 24 24 ) 25 printf( "%g\n", result ); 25 26 printf("%g\n", result); 26 27 } 27 28 // Local Variables: //29 // tab-width: 4 //30 // End: // -
benchmark/ctxswitch/cfa_thrd.cfa
r3d5701e r9fb8f01 3 3 #include "bench.h" 4 4 5 int main( int argc, char * argv[] ) { 6 BENCH_START() 5 int main(int argc, char* argv[]) { 7 6 BENCH( 8 for ( times) {7 for ( i; n ) { 9 8 yield(); 10 9 }, 11 10 result 12 11 ) 13 printf( "%g\n", result ); 12 13 printf("%g\n", result); 14 14 } 15 16 // Local Variables: //17 // tab-width: 4 //18 // End: // -
benchmark/ctxswitch/cfa_thrd2.cfa
r3d5701e r9fb8f01 8 8 9 9 void main(__attribute__((unused)) Fibre & this) { 10 while ( ! done) {10 while(!done) { 11 11 yield(); 12 12 } 13 13 } 14 14 15 int main( int argc, char * argv[] ) { 16 BENCH_START() 15 int main(int argc, char* argv[]) { 17 16 Fibre f1; 18 17 BENCH( 19 for ( times) {18 for ( i; n ) { 20 19 yield(); 21 20 }, 22 21 result 23 22 ) 24 printf( "%g\n", result ); 23 24 printf("%g\n", result); 25 25 done = true; 26 return 0; 26 27 } 27 28 // Local Variables: //29 // tab-width: 4 //30 // End: // -
benchmark/ctxswitch/goroutine.go
r3d5701e r9fb8f01 2 2 3 3 import ( 4 "fmt" 5 "time" 6 "os" 7 "strconv" 8 "runtime" 4 "fmt" 5 "runtime" 6 "time" 9 7 ) 10 8 … … 30 28 31 29 func 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 36 32 <- shake 37 33 } 38 39 // Local Variables: //40 // tab-width: 4 //41 // End: // -
benchmark/ctxswitch/kos_fibre.cpp
r3d5701e r9fb8f01 3 3 #include "bench.h" 4 4 5 int main( int argc, char * argv[] ) { 6 BENCH_START() 5 int main(int argc, char* argv[]) { 7 6 BENCH( 8 for (size_t i = 0; i < times; i++) {7 for (size_t i = 0; i < n; i++) { 9 8 Fibre::yield(); 10 9 }, 11 10 result 12 11 ) 13 printf( "%g\n", result ); 12 printf("%g\n", result); 13 return 0; 14 14 } 15 16 // Local Variables: //17 // tab-width: 4 //18 // End: // -
benchmark/ctxswitch/kos_fibre2.cpp
r3d5701e r9fb8f01 11 11 } 12 12 13 int main( int argc, char * argv[] ) { 14 BENCH_START() 13 int main(int argc, char* argv[]) { 15 14 Fibre* f1 = (new Fibre)->run(f1main); 16 15 BENCH( 17 for (size_t i = 0; i < times; i++) {16 for (size_t i = 0; i < n; i++) { 18 17 Fibre::yield(); 19 18 }, 20 19 result 21 20 ) 22 printf( "%g\n", result);21 printf("%g\n", result); 23 22 done = true; 24 23 Fibre::yield(); 25 24 f1->join(); 25 return 0; 26 26 } 27 28 // Local Variables: //29 // tab-width: 4 //30 // End: // -
benchmark/ctxswitch/pthreads.c
r3d5701e r9fb8f01 6 6 #include "bench.h" 7 7 8 int main( int argc, char * argv[] ) { 9 BENCH_START() 8 int main(int argc, char* argv[]) { 10 9 BENCH( 11 for (size_t i = 0; i < times; i++) {10 for (size_t i = 0; i < n; i++) { 12 11 sched_yield(); 13 12 }, 14 13 result 15 14 ) 16 printf( "%g\n", result ); 15 16 printf("%g\n", result); 17 17 } -
benchmark/ctxswitch/upp_cor.cc
r3d5701e r9fb8f01 3 3 #include "bench.h" 4 4 5 _Coroutine C { 5 _Coroutine GreatSuspender { 6 public: 7 GreatSuspender() { 8 resume(); 9 } 10 11 void do_resume() { 12 resume(); 13 } 14 private: 6 15 void main() { 7 16 while( true ) { … … 9 18 } 10 19 } 11 public: 12 void do_resume() { 13 resume(); 14 } 15 } c; 16 int main( int argc, char * argv[] ) { 17 BENCH_START() 20 }; 21 22 int main(int argc, char* argv[]) { 23 GreatSuspender s; 24 18 25 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(); 21 28 }, 22 29 result 23 30 ) 24 printf( "%g\n", result ); 31 32 printf("%g\n", result); 25 33 } 26 27 // Local Variables: //28 // tab-width: 4 //29 // End: // -
benchmark/ctxswitch/upp_thrd.cc
r3d5701e r9fb8f01 3 3 #include "bench.h" 4 4 5 int main( int argc, char * argv[] ) { 6 BENCH_START() 5 int main(int argc, char* argv[]) { 7 6 BENCH( 8 for (size_t i = 0; i < times; i++) {7 for (size_t i = 0; i < n; i++) { 9 8 uThisTask().yield(); 10 9 }, 11 10 result 12 11 ) 13 printf( "%g\n", result ); 12 13 printf("%g\n", result); 14 14 } 15 16 // Local Variables: //17 // tab-width: 4 //18 // End: // -
benchmark/mutex/JavaThread.java
r3d5701e r9fb8f01 26 26 static int x = 2; 27 27 28 static private int times = Integer.parseInt("100000000");28 static private final int NoOfTimes = Integer.parseInt("100000000") ; 29 29 30 30 public synchronized void noop() { … … 35 35 // Inhibit biased locking ... 36 36 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) { 38 38 x = nextRandom(x); 39 39 j.noop(); … … 44 44 helper(); 45 45 long end = System.nanoTime(); 46 System.out.println( (end - start) / times );46 System.out.println( (end - start) / NoOfTimes ); 47 47 } 48 48 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 49 for (int n = Integer.parseInt("5"); --n >= 0 ; ) { 53 50 InnerMain(); … … 58 55 } 59 56 } 60 61 // Local Variables: //62 // tab-width: 4 //63 // End: // -
benchmark/mutex/cfa1.cfa
r3d5701e r9fb8f01 4 4 #include "bench.h" 5 5 6 monitor M {} m1;7 void __attribute__((noinline)) call( M & mutex p1) {}6 monitor M {}; 7 void __attribute__((noinline)) call( M & mutex m ) {} 8 8 9 int main( int argc, char * argv[]) {10 BENCH_START()9 int main(int argc, char* argv[]) { 10 M m; 11 11 BENCH( 12 for ( times) {13 call( m1);12 for ( i; n ) { 13 call(m); 14 14 }, 15 15 result 16 16 ) 17 printf( "%g\n", result ); 17 18 printf("%g\n", result); 18 19 } 19 20 // Local Variables: //21 // tab-width: 4 //22 // End: // -
benchmark/mutex/cfa2.cfa
r3d5701e r9fb8f01 4 4 #include "bench.h" 5 5 6 monitor M {} m1, m2; 6 monitor M {}; 7 void __attribute__((noinline)) call( M & mutex m1, M & mutex m2 ) {} 7 8 8 void __attribute__((noinline)) call( M & mutex p1, M & mutex p2 ) {} 9 10 int main( int argc, char * argv[] ) { 11 BENCH_START() 9 int main(int argc, char* argv[]) { 10 M m1, m2; 12 11 BENCH( 13 for ( times) {14 call( m1, m2);12 for ( i; n ) { 13 call(m1, m2); 15 14 }, 16 15 result 17 16 ) 18 printf( "%g\n", result ); 17 18 printf("%g\n", result); 19 19 } 20 21 // Local Variables: //22 // tab-width: 4 //23 // End: // -
benchmark/mutex/cfa4.cfa
r3d5701e r9fb8f01 5 5 6 6 7 monitor M {} m1, m2, m3, m4;8 void __attribute__((noinline)) call( M & mutex p1, M & mutex p2, M & mutex p3, M & mutex p4 ) {}7 monitor M {}; 8 void __attribute__((noinline)) call( M & mutex m1, M & mutex m2, M & mutex m3, M & mutex m4 ) {} 9 9 10 int main( int argc, char * argv[]) {11 BENCH_START()10 int main(int argc, char* argv[]) { 11 M m1, m2, m3, m4; 12 12 BENCH( 13 for ( times) {14 call( m1, m2, m3, m4);13 for ( i; n ) { 14 call(m1, m2, m3, m4); 15 15 }, 16 16 result 17 17 ) 18 printf( "%g\n", result ); 18 19 printf("%g\n", result); 19 20 } 20 21 // Local Variables: //22 // tab-width: 4 //23 // End: // -
benchmark/mutex/pthreads.c
r3d5701e r9fb8f01 7 7 8 8 void __attribute__((noinline)) call() { 9 pthread_mutex_lock ( &mutex);10 pthread_mutex_unlock( &mutex);9 pthread_mutex_lock (&mutex); 10 pthread_mutex_unlock(&mutex); 11 11 } 12 int main( int argc, char * argv[] ) { 13 BENCH_START() 12 13 int main(int argc, char* argv[]) { 14 14 BENCH( 15 for ( size_t i = 0; i < times; i++) {15 for (size_t i = 0; i < n; i++) { 16 16 call(); 17 17 }, 18 18 result 19 19 ) 20 printf( "%g\n", result ); 20 21 printf("%g\n", result); 21 22 } 22 23 // Local Variables: //24 // tab-width: 4 //25 // End: // -
benchmark/mutex/upp.cc
r3d5701e r9fb8f01 8 8 }; 9 9 10 int main( int argc, char * argv[] ) { 11 BENCH_START() 10 int main(int argc, char* argv[]) { 12 11 MyMonitor m; 13 12 BENCH( 14 for ( size_t i = 0; i < times; i++) {13 for (size_t i = 0; i < n; i++) { 15 14 m.call(); 16 15 }, 17 16 result 18 17 ) 19 printf( "%g\n", result ); 18 19 printf("%g\n", result); 20 20 } 21 22 // Local Variables: //23 // tab-width: 4 //24 // End: // -
benchmark/schedext/cfa1.cfa
r3d5701e r9fb8f01 4 4 #include <stdio.h> 5 5 6 #include " ../bench.h"6 #include "bench.h" 7 7 8 monitor M {} m1; 8 int argc; 9 char** argv; 10 volatile int go = 0; 9 11 10 void __attribute__((noinline)) call( M & mutex p1 ) {} 11 void __attribute__((noinline)) wait( M & mutex p1 ) { 12 for ( times ) { 13 waitfor( call : p1 ); 14 } 12 monitor M {}; 13 M m1; 14 15 void __attribute__((noinline)) call( M & mutex a1 ) {} 16 17 int __attribute__((noinline)) wait( M & mutex a1 ) { 18 go = 1; 19 BENCH( 20 for ( i; n ) { 21 waitfor(call, a1); 22 }, 23 result 24 ) 25 26 printf("%g\n", result); 27 go = 0; 28 return 0; 15 29 } 16 30 17 31 thread T {}; 32 void ^?{}( T & mutex this ) {} 18 33 void 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 24 37 } 25 38 26 int main( int argc, char * argv[] ) { 27 BENCH_START() 39 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) { 28 40 T t; 29 wait( m1);41 return wait(m1); 30 42 } 31 32 // Local Variables: //33 // tab-width: 4 //34 // End: // -
benchmark/schedext/cfa2.cfa
r3d5701e r9fb8f01 4 4 #include <stdio.h> 5 5 6 #include " ../bench.h"6 #include "bench.h" 7 7 8 monitor M {} m1, m2; 8 int argc; 9 char** argv; 10 volatile int go = 0; 9 11 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 & ) { 12 monitor M {}; 13 M m1, m2; 14 15 void __attribute__((noinline)) call( M & mutex a1, M & mutex a2 ) {} 16 17 int __attribute__((noinline)) wait( M & mutex a1, M & mutex a2 ) { 18 go = 1; 18 19 BENCH( 19 for ( times) {20 call( m1, m2);20 for ( i; n ) { 21 waitfor(call, a1, a2); 21 22 }, 22 23 result 23 24 ) 24 printf( "%g\n", result ); 25 26 printf("%g\n", result); 27 go = 0; 28 return 0; 25 29 } 26 30 27 int main( int argc, char * argv[] ) { 28 BENCH_START() 29 T t; 30 wait( m1, m2 ); 31 thread T {}; 32 void ^?{}( T & mutex this ) {} 33 void main( T & ) { 34 while(go == 0) { yield(); } 35 while(go == 1) { call(m1, m2); } 36 31 37 } 32 38 33 // Local Variables: // 34 // tab-width: 4 // 35 // End: // 39 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) { 40 T t; 41 return wait(m1, m2); 42 } -
benchmark/schedext/cfa4.cfa
r3d5701e r9fb8f01 4 4 #include <stdio.h> 5 5 6 #include " ../bench.h"6 #include "bench.h" 7 7 8 monitor M {} m1, m2, m3, m4; 8 int argc; 9 char** argv; 10 volatile int go = 0; 9 11 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 & ) { 12 monitor M {}; 13 M m1, m2, m3, m4; 14 15 void __attribute__((noinline)) call( M & mutex a1, M & mutex a2, M & mutex a3, M & mutex a4 ) {} 16 17 int __attribute__((noinline)) wait( M & mutex a1, M & mutex a2, M & mutex a3, M & mutex a4 ) { 18 go = 1; 18 19 BENCH( 19 for ( times) {20 call( m1, m2, m3, m4);20 for ( i; n ) { 21 waitfor(call, a1, a2, a3, a4); 21 22 }, 22 23 result 23 24 ) 24 printf( "%g\n", result ); 25 26 printf("%g\n", result); 27 go = 0; 28 return 0; 25 29 } 26 30 27 int main( int argc, char * argv[] ) { 28 BENCH_START() 29 T t; 30 wait( m1, m2, m3, m4 ); 31 thread T {}; 32 void ^?{}( T & mutex this ) {} 33 void main( T & ) { 34 while(go == 0) { yield(); } 35 while(go == 1) { call(m1, m2, m3, m4); } 36 31 37 } 32 38 33 // Local Variables: // 34 // tab-width: 4 // 35 // End: // 39 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) { 40 T t; 41 return wait(m1, m2, m3, m4); 42 } -
benchmark/schedext/upp.cc
r3d5701e r9fb8f01 3 3 #include "bench.h" 4 4 5 int argc; 6 char** argv; 7 volatile int go = 0; 8 5 9 _Monitor M { 6 10 public: 7 11 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; 12 25 } 13 } m; 26 }; 27 28 M m; 14 29 15 30 _Task T { 16 31 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 24 35 } 25 36 }; 26 37 27 int main( int argc, char * argv[] ) { 28 BENCH_START() 38 int main(int margc, char* margv[]) { 39 argc = margc; 40 argv = margv; 29 41 T t; 30 m.wait();42 return m.wait(); 31 43 } 32 33 // Local Variables: //34 // tab-width: 4 //35 // End: // -
benchmark/schedint/JavaThread.java
r3d5701e r9fb8f01 49 49 static int x = 2; 50 50 51 static private int times = Integer.parseInt("1000000");51 static private final int NoOfTimes = Integer.parseInt("1000000") ; 52 52 53 53 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) { 55 55 m.wait(); // relase monitor lock 56 56 m.next = true; … … 63 63 synchronized(m) { 64 64 s.start(); 65 while( ! Monitor.go ) { // waiter must start first65 while( !Monitor.go ) { 66 66 Thread.yield(); 67 67 } … … 72 72 Monitor.go = false; 73 73 s.join(); 74 System.out.println( (end - start) / times);74 System.out.println( (end - start) / NoOfTimes); 75 75 } 76 76 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 80 77 for (int n = Integer.parseInt("5"); --n >= 0 ; ) { 81 78 InnerMain(); … … 86 83 } 87 84 } 88 89 // Local Variables: //90 // tab-width: 4 //91 // End: // -
benchmark/schedint/cfa1.cfa
r3d5701e r9fb8f01 4 4 #include <stdio.h> 5 5 6 #include " ../bench.h"6 #include "bench.h" 7 7 8 int argc; 9 char** argv; 8 10 volatile int go = 0; 9 11 10 12 condition c; 11 monitor M {} m1; 13 monitor M {}; 14 M m1; 12 15 13 void __attribute__((noinline)) call( M & mutex p1 ) {14 signal( c);16 void __attribute__((noinline)) call( M & mutex a1 ) { 17 signal(c); 15 18 } 16 void __attribute__((noinline)) wait( M & mutex p1 ) { 19 20 int __attribute__((noinline)) wait( M & mutex a1 ) { 17 21 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; 21 32 } 22 33 23 34 thread T {}; 35 void ^?{}( T & mutex ) {} 24 36 void 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 31 40 } 32 41 33 int main( int argc, char * argv[] ) { 34 BENCH_START() 42 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) { 35 43 T t; 36 wait( m1);44 return wait(m1); 37 45 } 38 39 // Local Variables: //40 // tab-width: 4 //41 // End: // -
benchmark/schedint/cfa2.cfa
r3d5701e r9fb8f01 4 4 #include <stdio.h> 5 5 6 #include " ../bench.h"6 #include "bench.h" 7 7 8 int argc; 9 char** argv; 8 10 volatile int go = 0; 9 11 10 12 condition c; 11 monitor M {} m1, m2; 13 monitor M {}; 14 M m1, m2; 12 15 13 void __attribute__((noinline)) call( M & mutex p1, M & mutex p2 ) {14 signal( c);16 void __attribute__((noinline)) call( M & mutex a1, M & mutex a2 ) { 17 signal(c); 15 18 } 16 void __attribute__((noinline)) wait( M & mutex p1, M & mutex p2 ) { 19 20 int __attribute__((noinline)) wait( M & mutex a1, M & mutex a2 ) { 17 21 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; 21 32 } 22 33 23 34 thread T {}; 35 void ^?{}( T & mutex this ) {} 24 36 void 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 31 40 } 32 41 33 int main( int argc, char * argv[] ) { 34 BENCH_START() 42 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) { 35 43 T t; 36 wait( m1, m2);44 return wait(m1, m2); 37 45 } 38 39 // Local Variables: //40 // tab-width: 4 //41 // End: // -
benchmark/schedint/cfa4.cfa
r3d5701e r9fb8f01 4 4 #include <stdio.h> 5 5 6 #include " ../bench.h"6 #include "bench.h" 7 7 8 int argc; 9 char** argv; 8 10 volatile int go = 0; 9 11 10 12 condition c; 11 monitor M {} m1, m2, m3, m4; 13 monitor M {}; 14 M m1, m2, m3, m4; 12 15 13 void __attribute__((noinline)) call( M & mutex p1, M & mutex p2, M & mutex p3, M & mutex p4 ) {14 signal( c);16 void __attribute__((noinline)) call( M & mutex a1, M & mutex a2, M & mutex a3, M & mutex a4 ) { 17 signal(c); 15 18 } 16 void __attribute__((noinline)) wait( M & mutex p1, M & mutex p2, M & mutex p3, M & mutex p4 ) { 19 20 int __attribute__((noinline)) wait( M & mutex a1, M & mutex a2, M & mutex a3, M & mutex a4 ) { 17 21 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; 21 32 } 22 33 23 34 thread T {}; 35 void ^?{}( T & mutex this ) {} 24 36 void 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 31 40 } 32 41 33 int main( int argc, char * argv[] ) { 34 BENCH_START() 42 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) { 35 43 T t; 36 wait( m1, m2, m3, m4);44 return wait(m1, m2, m3, m4); 37 45 } 38 39 // Local Variables: //40 // tab-width: 4 //41 // End: // -
benchmark/schedint/pthreads.c
r3d5701e r9fb8f01 4 4 #include "bench.h" 5 5 6 int argc; 7 char** argv; 6 8 volatile int go = 0; 7 9 10 pthread_cond_t c; 8 11 pthread_mutex_t m; 9 pthread_cond_t c;10 12 11 13 void __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); 15 17 } 16 18 17 void__attribute__((noinline)) wait() {19 int __attribute__((noinline)) wait() { 18 20 pthread_mutex_lock(&m); 19 21 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); 23 30 go = 0; 24 pthread_mutex_unlock( &m ); 31 pthread_mutex_unlock(&m); 32 return 0; 25 33 } 26 34 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 ); 35 void* thread_main(__attribute__((unused)) void * arg ) { 36 while(go == 0) { sched_yield(); } 37 while(go == 1) { call(); } 35 38 return NULL; 36 39 } 37 40 38 int main( int argc, char * argv[] ) { 39 BENCH_START() 41 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) { 40 42 pthread_t thread; 41 if ( pthread_create( &thread, NULL, thread_main, NULL ) < 0) {43 if (pthread_create(&thread, NULL, thread_main, NULL) < 0) { 42 44 perror( "failure" ); 43 45 return 1; 44 46 } 45 47 wait(); 46 if ( pthread_join( thread, NULL ) < 0) {48 if (pthread_join( thread, NULL) < 0) { 47 49 perror( "failure" ); 48 50 return 1; 49 51 } 52 return 0; 50 53 } 51 52 // Local Variables: //53 // tab-width: 4 //54 // End: // -
benchmark/schedint/upp.cc
r3d5701e r9fb8f01 3 3 #include "bench.h" 4 4 5 int argc; 6 char** argv; 5 7 volatile int go = 0; 6 8 … … 11 13 cond.signal(); 12 14 } 13 void __attribute__((noinline)) wait() { 15 16 int __attribute__((noinline)) wait() { 14 17 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; 18 28 } 19 } m; 29 }; 30 31 M m; 20 32 21 33 _Task T { 22 34 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 31 38 } 32 39 }; 33 40 34 int main( int argc, char * argv[] ) { 35 BENCH_START() 41 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) { 36 42 T t; 37 m.wait();43 return m.wait(); 38 44 } 39 40 // Local Variables: //41 // tab-width: 4 //42 // End: // -
configure
r3d5701e r9fb8f01 663 663 ac_ct_DUMPBIN 664 664 DUMPBIN 665 LD 665 666 FGREP 666 667 EGREP … … 700 701 LDFLAGS 701 702 CXXFLAGS 703 CXX 702 704 CFA_FLAGS 703 705 LIBCFA_TARGET_MAKEFILES … … 715 717 BUILD_IN_TREE_FLAGS 716 718 CFACPP 717 CFACC_INSTALL718 719 CFACC 719 720 DRIVER_DIR … … 722 723 CFA_INCDIR 723 724 CFA_PREFIX 724 HAS_DISTCC725 LD726 CXX727 ENABLE_DISTCC_FALSE728 ENABLE_DISTCC_TRUE729 725 DOendif 730 726 DOifskipcompile … … 801 797 enable_silent_rules 802 798 with_cfa_name 803 enable_distcc804 799 with_target_hosts 805 800 enable_gprofiler … … 1464 1459 --enable-silent-rules less verbose build output (undo: "make V=1") 1465 1460 --disable-silent-rules verbose build output (undo: "make V=0") 1466 --enable-distcc whether or not to enable distributed compilation1467 1461 --enable-gprofiler whether or not to enable gprofiler tools (if available) 1468 1462 --enable-demangler whether or not to build the demangler (executable and library) … … 3190 3184 3191 3185 #============================================================================== 3192 # distcc support3193 3194 # Check whether --enable-distcc was given.3195 if test "${enable_distcc+set}" = set; then :3196 enableval=$enable_distcc; enable_distcc=$enableval3197 else3198 enable_distcc=no3199 fi3200 3201 3202 if test x$enable_distcc = xyes; then3203 ENABLE_DISTCC_TRUE=3204 ENABLE_DISTCC_FALSE='#'3205 else3206 ENABLE_DISTCC_TRUE='#'3207 ENABLE_DISTCC_FALSE=3208 fi3209 3210 HAS_DISTCC="False"3211 3212 if test x$enable_distcc = xyes; then3213 CXX="distcc ${CXX}"3214 LD="distcc ${LD} -lstdc++"3215 HAS_DISTCC="True"3216 echo "Enabling distributed builds"3217 fi3218 3219 3220 3221 3222 3223 #==============================================================================3224 3186 # Installation paths 3225 3187 … … 3304 3266 DRIVER_DIR=${TOP_BUILDDIR}driver/ 3305 3267 CFACC=${DRIVER_DIR}cfa 3306 CFACC_INSTALL=${CFA_BINDIR}${CFA_NAME}3307 3268 CFACPP=${DRIVER_DIR}cfa-cpp 3308 3309 3269 3310 3270 … … 17057 17017 fi 17058 17018 17059 if test -z "${ENABLE_DISTCC_TRUE}" && test -z "${ENABLE_DISTCC_FALSE}"; then17060 as_fn_error $? "conditional \"ENABLE_DISTCC\" was never defined.17061 Usually this means the macro was only invoked conditionally." "$LINENO" 517062 fi17063 17019 if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then 17064 17020 as_fn_error $? "conditional \"AMDEP\" was never defined. -
configure.ac
r3d5701e r9fb8f01 58 58 59 59 #============================================================================== 60 # distcc support61 62 AC_ARG_ENABLE(distcc,63 [ --enable-distcc whether or not to enable distributed compilation],64 enable_distcc=$enableval, enable_distcc=no)65 66 AM_CONDITIONAL([ENABLE_DISTCC], [test x$enable_distcc = xyes])67 HAS_DISTCC="False"68 69 if test x$enable_distcc = xyes; then70 CXX="distcc ${CXX}"71 LD="distcc ${LD} -lstdc++"72 HAS_DISTCC="True"73 echo "Enabling distributed builds"74 fi75 76 AC_SUBST(CXX)77 AC_SUBST(LD)78 AC_SUBST(HAS_DISTCC)79 80 #==============================================================================81 60 # Installation paths 82 61 M4CFA_PARSE_PREFIX … … 93 72 DRIVER_DIR=${TOP_BUILDDIR}driver/ 94 73 CFACC=${DRIVER_DIR}cfa 95 CFACC_INSTALL=${CFA_BINDIR}${CFA_NAME}96 74 CFACPP=${DRIVER_DIR}cfa-cpp 97 75 AC_SUBST(DRIVER_DIR) 98 76 AC_SUBST(CFACC) 99 AC_SUBST(CFACC_INSTALL)100 77 AC_SUBST(CFACPP) 101 78 -
doc/papers/concurrency/Paper.tex
r3d5701e r9fb8f01 239 239 \lstMakeShortInline@% 240 240 241 \newcommand{\commenttd}[1]{{\color{red}{Thierry : #1}}}242 243 241 \let\OLDthebibliography\thebibliography 244 242 \renewcommand\thebibliography[1]{ … … 1165 1163 % } 1166 1164 % int main() { 1167 % 1165 % 1168 1166 % for ( int i = 0; i < 10; i += 1 ) { 1169 1167 % printf( "%d\n", fib() ); … … 1836 1834 if ( random() % 3 ) transfer( b1, b2, 7 ); 1837 1835 } 1838 } 1836 } 1839 1837 int main() { 1840 1838 `Person p1 = { b1, b2 }, p2 = { b2, b1 };` … … 1866 1864 if ( random() % 3 ) transfer( b1, b2, 7 ); 1867 1865 } 1868 } 1866 } 1869 1867 int main() { 1870 1868 `thread p1(person, ref(b1), ref(b2)), p2(person, ref(b2), ref(b1));` … … 2741 2739 % \section{Parallelism} 2742 2740 % \label{s:Parallelism} 2743 % 2741 % 2744 2742 % Historically, computer performance was about processor speeds. 2745 2743 % However, with heat dissipation being a direct consequence of speed increase, parallelism is the new source for increased performance~\cite{Sutter05, Sutter05b}. … … 2748 2746 % However, kernel threads are better as an implementation tool because of complexity and higher cost. 2749 2747 % Therefore, different abstractions are often layered onto kernel threads to simplify them, \eg pthreads. 2750 % 2751 % 2748 % 2749 % 2752 2750 % \subsection{User Threads} 2753 % 2751 % 2754 2752 % A direct improvement on kernel threads is user threads, \eg Erlang~\cite{Erlang} and \uC~\cite{uC++book}. 2755 2753 % This approach provides an interface that matches the language paradigms, gives more control over concurrency by the language runtime, and an abstract (and portable) interface to the underlying kernel threads across operating systems. … … 2757 2755 % Like kernel threads, user threads support preemption, which maximizes nondeterminism, but increases the potential for concurrency errors: race, livelock, starvation, and deadlock. 2758 2756 % \CFA adopts user-threads to provide more flexibility and a low-cost mechanism to build any other concurrency approach, \eg thread pools and actors~\cite{Actors}. 2759 % 2757 % 2760 2758 % A variant of user thread is \newterm{fibres}, which removes preemption, \eg Go~\cite{Go} @goroutine@s. 2761 2759 % Like functional programming, which removes mutation and its associated problems, removing preemption from concurrency reduces nondeterminism, making race and deadlock errors more difficult to generate. -
driver/Makefile.in
r3d5701e r9fb8f01 201 201 CCDEPMODE = @CCDEPMODE@ 202 202 CFACC = @CFACC@ 203 CFACC_INSTALL = @CFACC_INSTALL@204 203 CFACPP = @CFACPP@ 205 204 CFA_BACKEND_CC = @CFA_BACKEND_CC@ … … 232 231 FGREP = @FGREP@ 233 232 GREP = @GREP@ 234 HAS_DISTCC = @HAS_DISTCC@235 233 HOST_FLAGS = @HOST_FLAGS@ 236 234 INSTALL = @INSTALL@ -
driver/cc1.cc
r3d5701e r9fb8f01 10 10 // Created On : Fri Aug 26 14:23:51 2005 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Oct 20 08:14:33201913 // Update Count : 3 8512 // Last Modified On : Fri Aug 23 15:06:27 2019 13 // Update Count : 371 14 14 // 15 15 … … 33 33 34 34 35 static string compiler_path( CFA_BACKEND_CC ); // C compiler path/name 35 static string installlibdir( CFA_LIBDIR ); // fixed location of cc1 and cfa-cpp commands when installed 36 static string compiler_path( CFA_BACKEND_CC ); // path/name of C compiler 36 37 static bool CFA_flag = false; // -CFA flag 37 38 static bool save_temps = false; // -save-temps flag 38 39 static string o_file; 39 static string bprefix;40 40 41 41 … … 58 58 59 59 60 static string __CFA_FLAGPREFIX__( "__CFA_FLAG" ); // "N__=" suffix60 static string __CFA_FLAGPREFIX__( "__CFA_FLAG" ); 61 61 62 62 static void checkEnv1( const char * args[], int & nargs ) { // stage 1 … … 70 70 71 71 if ( prefix( arg, __CFA_FLAGPREFIX__ ) ) { 72 string val( arg.substr( arg.find_first_of( "=" ) + 1) );72 string val( arg.substr( __CFA_FLAGPREFIX__.size() + 4 ) ); 73 73 if ( prefix( val, "-compiler=" ) ) { 74 74 compiler_path = val.substr( 10 ); … … 89 89 90 90 if ( prefix( arg, __CFA_FLAGPREFIX__ ) ) { 91 string val( arg.substr( arg.find_first_of( "=" ) + 1) );91 string val( arg.substr( __CFA_FLAGPREFIX__.size() + 4 ) ); 92 92 if ( prefix( val, "-compiler=" ) ) { 93 93 compiler_path = val.substr( 10 ); … … 98 98 } else if ( prefix( val, "-o=" ) ) { // output file for -CFA 99 99 o_file = val.substr( 3 ); 100 } else if ( prefix( val, "-B=" ) ) { // location of cfa-cpp 101 bprefix = val.substr( 3 ); 102 } else { // normal flag for cfa-cpp 103 args[nargs++] = ( *new string( arg.substr( arg.find_first_of( "=" ) + 1 ) ) ).c_str(); 100 } else { 101 args[nargs++] = ( *new string( arg.substr( __CFA_FLAGPREFIX__.size() + 4 ) ) ).c_str(); 104 102 } // if 105 103 } // if … … 108 106 109 107 110 static char tmpname[] = P_tmpdir "/CFAXXXXXX.i fa";108 static char tmpname[] = P_tmpdir "/CFAXXXXXX.i"; 111 109 static int tmpfilefd = -1; 112 110 static bool startrm = false; … … 293 291 294 292 execvp( args[0], (char * const *)args ); // should not return 295 perror( "CC1 Translator error: stage 1 cpp, execvp" ); 296 cerr << " invoked " << args[0] << endl; 293 perror( "CC1 Translator error: stage 1, execvp" ); 297 294 exit( EXIT_FAILURE ); 298 295 } // if … … 335 332 #endif // __DEBUG_H__ 336 333 337 enum {338 Color_Auto = 0,339 Color_Always = 1,340 Color_Never = 2,341 } color_arg = Color_Auto;342 343 const char * color_names[3] = { "--colors=auto", "--colors=always", "--colors=never" };344 345 334 // process all the arguments 346 335 … … 349 338 if ( prefix( arg, "-" ) ) { 350 339 // strip inappropriate flags 351 352 if ( prefix( arg, "-fdiagnostics-color=" ) ) {353 string choice = arg.substr(20);354 if(choice == "always") color_arg = Color_Always;355 else if(choice == "never" ) color_arg = Color_Never;356 else if(choice == "auto" ) color_arg = Color_Auto;357 } else if ( arg == "-fno-diagnostics-color" ) {358 color_arg = Color_Auto;359 }360 340 361 341 if ( arg == "-quiet" || arg == "-version" || arg == "-fpreprocessed" || … … 431 411 } // if 432 412 } else { 433 tmpfilefd = mkstemps( tmpname, 4);413 tmpfilefd = mkstemps( tmpname, 2 ); 434 414 if ( tmpfilefd == -1 ) { 435 415 perror( "CC1 Translator error: stage 2, mkstemp" ); … … 447 427 448 428 if ( fork() == 0 ) { // child runs CFA 449 cargs[0] = ( *new string( bprefix + "cfa-cpp" ) ).c_str(); 429 cargs[0] = ( *new string( installlibdir + "cfa-cpp" ) ).c_str(); 430 450 431 cargs[ncargs++] = cpp_in; 451 432 … … 457 438 cargs[ncargs++] = cfa_cpp_out.c_str(); 458 439 } // if 459 460 cargs[ncargs++] = color_names[color_arg]; 461 462 cargs[ncargs] = nullptr; // terminate argument list 440 cargs[ncargs] = nullptr; // terminate argument list 463 441 464 442 #ifdef __DEBUG_H__ … … 470 448 471 449 execvp( cargs[0], (char * const *)cargs ); // should not return 472 perror( "CC1 Translator error: stage 2 cfa-cpp, execvp" ); 473 cerr << " invoked " << cargs[0] << endl; 450 perror( "CC1 Translator error: stage 2, execvp" ); 474 451 exit( EXIT_FAILURE ); 475 452 } // if … … 507 484 args[0] = compiler_path.c_str(); 508 485 args[nargs++] = "-S"; // only compile and put assembler output in specified file 509 args[nargs++] = "-x"; 510 args[nargs++] = "cpp-output"; 511 486 if ( save_temps ) { // make gcc accept .ifa suffix 487 args[nargs++] = "-x"; 488 args[nargs++] = "cpp-output"; 489 } // if 512 490 args[nargs++] = cfa_cpp_out.c_str(); 513 491 args[nargs] = nullptr; // terminate argument list … … 522 500 523 501 execvp( args[0], (char * const *)args ); // should not return 524 perror( "CC1 Translator error: stage 2 cc1, execvp" ); 525 cerr << " invoked " << args[0] << endl; 502 perror( "CC1 Translator error: stage 2, execvp" ); 526 503 exit( EXIT_FAILURE ); // tell gcc not to go any further 527 504 } // if 528 505 529 506 wait( &code ); // wait for child to finish 507 508 if ( WIFSIGNALED(code) ) { // child failed ? 509 rmtmpfile(); // remove tmpname 510 cerr << "CC1 Translator error: stage 2, child failed " << WTERMSIG(code) << endl; 511 exit( EXIT_FAILURE ); 512 } // if 513 514 #ifdef __DEBUG_H__ 515 cerr << "return code from gcc cc1:" << WEXITSTATUS(code) << endl; 516 #endif // __DEBUG_H__ 517 530 518 rmtmpfile(); // remove tmpname 531 532 if ( WIFSIGNALED(code) ) { // child failed ?533 cerr << "CC1 Translator error: stage 2, child failed " << WTERMSIG(code) << endl;534 exit( EXIT_FAILURE );535 } // if536 537 #ifdef __DEBUG_H__538 cerr << "return code from gcc cc1:" << WEXITSTATUS(code) << endl;539 #endif // __DEBUG_H__540 541 519 exit( WEXITSTATUS( code ) ); // stop regardless of success or failure 542 520 } // Stage2 -
driver/cfa.cc
r3d5701e r9fb8f01 10 10 // Created On : Tue Aug 20 13:44:49 2002 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jan 31 16:48:03 202013 // Update Count : 4 2112 // Last Modified On : Fri Aug 23 16:27:07 2019 13 // Update Count : 411 14 14 // 15 15 16 16 #include <iostream> 17 #include <cstdio> // perror 18 #include <cstdlib> // putenv, exit 19 #include <climits> // PATH_MAX 20 #include <unistd.h> // execvp 21 #include <string> // STL version 22 #include <string.h> // strcmp 23 #include <algorithm> // find 17 #include <cstdio> // perror 18 #include <cstdlib> // putenv, exit 19 #include <unistd.h> // execvp 20 #include <string> // STL version 21 #include <string.h> // strcmp 22 #include <algorithm> // find 24 23 25 24 #include <sys/types.h> … … 34 33 using std::to_string; 35 34 36 // #define __DEBUG_H__ 37 38 // "N__=" suffix 39 static string __CFA_FLAGPREFIX__( "__CFA_FLAG" ); 35 //#define __DEBUG_H__ 36 40 37 41 38 void Putenv( char * argv[], string arg ) { 42 // environment variables must have unique names 43 static int flags = 0; 44 45 if ( putenv( (char *)( *new string( string( __CFA_FLAGPREFIX__ + to_string( flags++ ) + "__=" ) + arg ) ).c_str() ) ) { 39 static int flags = 0; // environment variables must have unique names 40 41 if ( putenv( (char *)( *new string( string( "__CFA_FLAG" + to_string( flags++ ) + "__=" ) + arg ) ).c_str() ) ) { 46 42 cerr << argv[0] << " error, cannot set environment variable." << endl; 47 43 exit( EXIT_FAILURE ); … … 49 45 } // Putenv 50 46 51 // check if string has prefix 52 bool prefix( const string & arg, const string & pre ) { 47 48 bool prefix( const string & arg, const string & pre ) { // check if string has prefix 53 49 return arg.substr( 0, pre.size() ) == pre; 54 50 } // prefix 55 51 56 inline bool ends_with(const string & str, const string & sfix) { 57 if (sfix.size() > str.size()) return false; 58 return std::equal(str.rbegin(), str.rbegin() + sfix.size(), sfix.rbegin(), sfix.rend()); 59 } 60 61 // check if string has suffix 62 bool suffix( const string & arg ) { 52 bool suffix( const string & arg ) { // check if string has suffix 63 53 enum { NumSuffixes = 3 }; 64 54 static const string suffixes[NumSuffixes] = { "cfa", "hfa", "ifa" }; … … 74 64 struct stat info; 75 65 if ( stat( path.c_str(), &info ) != 0 ) return false; 76 return (info.st_mode & S_IFDIR) != 0; 66 if ( info.st_mode & S_IFDIR ) return true; 67 return false; 77 68 } // dirExists 78 79 static inline string dir(const string & path) {80 return path.substr(0, path.find_last_of('/'));81 }82 83 // Different path modes84 enum PathMode {85 Installed, // cfa is installed, use prefix86 BuildTree, // cfa is in the tree, use source and build tree87 Distributed // cfa is distributed, use build tree for includes and executable directory for .cfs88 };89 90 // Get path mode from /proc91 PathMode FromProc() {92 std::string abspath;93 abspath.resize(PATH_MAX);94 95 // get executable path from /proc/self/exe96 ssize_t size = readlink("/proc/self/exe", const_cast<char*>(abspath.c_str()), abspath.size());97 if(size <= 0) {98 std::cerr << "Error could not evaluate absolute path from /proc/self/exe" << std::endl;99 std::cerr << "Failed with " << std::strerror(errno) << std::endl;100 std::exit(1);101 }102 103 // Trim extra characters104 abspath.resize(size);105 106 // Are we installed107 if(abspath.rfind(CFA_BINDIR , 0) == 0) { return Installed; }108 109 // Is this the build tree110 if(abspath.rfind(TOP_BUILDDIR, 0) == 0) { return BuildTree; }111 112 // Does this look like distcc113 if(abspath.find("/.cfadistcc/") != std::string::npos) { return Distributed; }114 115 // None of the above? Give up since we don't know where the prelude or include directories are116 std::cerr << "Cannot find required files from excutable path " << abspath << std::endl;117 std::exit(1);118 }119 69 120 70 … … 132 82 string heading; // banner printed at start of cfa compilation 133 83 string arg; // current command-line argument during command-line parsing 134 string bprefix; // path where gcc looks for compilersteps84 string Bprefix; // path where gcc looks for compiler command steps 135 85 string langstd; // language standard 136 86 … … 153 103 bool m32 = false; // -m32 flag 154 104 bool m64 = false; // -m64 flag 155 bool compiling_libs = false;105 bool intree = false; // build in tree 156 106 int o_file = 0; // -o filename position 157 158 PathMode path = FromProc();159 107 160 108 const char *args[argc + 100]; // cfa command line values, plus some space for additional flags … … 187 135 } else if ( arg == "-XCFA" ) { // CFA pass through 188 136 i += 1; 189 if ( i == argc ) continue; // next argument available ?190 137 Putenv( argv, argv[i] ); 191 138 … … 212 159 } else if ( arg == "-no-include-stdhdr" ) { 213 160 noincstd_flag = true; // strip the no-include-stdhdr flag 214 } else if ( arg == "- cfalib") {215 compiling_libs= true;161 } else if ( arg == "-in-tree" ) { 162 intree = true; 216 163 } else if ( arg == "-compiler" ) { 217 164 // use the user specified compiler … … 264 211 } // if 265 212 } else if ( prefix( arg, "-B" ) ) { 266 bprefix = arg.substr(2); // strip the -B flag 213 Bprefix = arg.substr(2); // strip the -B flag 214 args[nargs++] = ( *new string( string("-D__GCC_BPREFIX__=") + Bprefix ) ).c_str(); 267 215 } else if ( arg == "-c" || arg == "-S" || arg == "-E" || arg == "-M" || arg == "-MM" ) { 268 216 args[nargs++] = argv[i]; // pass argument along … … 315 263 // -E flag stops at cc1 stage 1, so cfa-cpp in cc1 stage 2 is never executed. 316 264 if ( cpp_flag && CFA_flag ) { 317 CFA_flag = false;318 cerr << argv[0] << " warning, both -E and -CFA flags specified, using -E and ignoring -CFA." << endl;265 cerr << argv[0] << " error, cannot use -E and -CFA flags together." << endl; 266 exit( EXIT_FAILURE ); 319 267 } // if 320 268 321 269 // add the CFA include-library paths, which allow direct access to header files without directory qualification 322 string libbase; 323 switch(path) { 324 case Installed: 270 if ( ! intree ) { 325 271 args[nargs++] = "-I" CFA_INCDIR; 326 // do not use during build 327 if ( ! noincstd_flag ) { 272 if ( ! noincstd_flag ) { // do not use during build 328 273 args[nargs++] = "-I" CFA_INCDIR "stdhdr"; 329 274 } // if 330 275 args[nargs++] = "-I" CFA_INCDIR "concurrency"; 331 276 args[nargs++] = "-I" CFA_INCDIR "containers"; 332 libbase = CFA_LIBDIR; 333 break; 334 case BuildTree: 335 case Distributed: 277 } else { 336 278 args[nargs++] = "-I" TOP_SRCDIR "libcfa/src"; 337 // do not use during build 338 if ( ! noincstd_flag ) { 279 if ( ! noincstd_flag ) { // do not use during build 339 280 args[nargs++] = "-I" TOP_SRCDIR "libcfa/src" "/stdhdr"; 340 281 } // if 341 282 args[nargs++] = "-I" TOP_SRCDIR "libcfa/src" "/concurrency"; 342 283 args[nargs++] = "-I" TOP_SRCDIR "libcfa/src" "/containers"; 343 344 libbase = TOP_BUILDDIR "libcfa/";345 346 break;347 284 } // if 348 285 … … 351 288 args[nargs++] = "stdbool.h"; 352 289 353 if( compiling_libs ) { 290 string libbase; 291 if ( ! intree ) { 292 libbase = CFA_LIBDIR; 293 } else { 294 libbase = TOP_BUILDDIR "libcfa/"; 354 295 Putenv( argv, "-t" ); 355 296 } // if … … 364 305 } // if 365 306 366 const char * config = nolib ? "nolib" : (debug ? "debug": "nodebug"); 367 string libdir = libbase + arch + "-" + config; 368 369 if (path != Distributed) { 370 if ( ! nolib && ! dirExists( libdir ) ) { 371 cerr << argv[0] << " internal error, configuration " << config << " not installed." << endl; 372 cerr << "Was looking for " << libdir << endl; 373 for(int i = 1; i < argc; i++) { 374 cerr << argv[i] << " "; 375 } 376 cerr << endl; 377 libdir = libbase + arch + "-" + "nolib"; 378 } // if 379 380 if ( ! dirExists( libdir ) ) { 381 cerr << argv[0] << " internal error, cannot find prelude directory." << endl; 382 cerr << "Was looking for " << libdir << endl; 383 exit( EXIT_FAILURE ); 384 } // if 385 } // if 386 387 switch(path) { 388 case Installed : Putenv( argv, "--prelude-dir=" + libdir ); break; 389 case BuildTree : Putenv( argv, "--prelude-dir=" + libdir + "/prelude" ); break; 390 case Distributed : Putenv( argv, "--prelude-dir=" + dir(argv[0]) ); break; 391 } 307 string libdir( libbase + arch + "-" + (nolib ? "nolib" : (debug ? "debug": "nodebug")) ); 308 if ( ! dirExists( libdir ) ) { 309 cerr << argv[0] << " internal error, cannot find prelude directory " << libdir << endl; 310 exit( EXIT_FAILURE ); 311 } // if 392 312 393 313 for ( int i = 0; i < nlibs; i += 1 ) { // copy non-user libraries after all user libraries … … 402 322 args[nargs++] = "-Xlinker"; 403 323 args[nargs++] = "--undefined=__cfaabi_appready_startup"; 404 args[nargs++] = "-z"; 405 args[nargs++] = "execstack"; 406 407 // include the cfa library in case it is needed 408 args[nargs++] = ( *new string( string("-L" ) + libdir + (path != Installed ? "/src/.libs" : "")) ).c_str(); 409 args[nargs++] = ( *new string( string("-Wl,-rpath," ) + libdir + (path != Installed ? "/src/.libs" : "")) ).c_str(); 324 325 // include the cfa library in case it's needed 326 args[nargs++] = ( *new string( string("-L" ) + libdir + (intree ? "/src/.libs" : "")) ).c_str(); 327 args[nargs++] = ( *new string( string("-Wl,-rpath," ) + libdir + (intree ? "/src/.libs" : "")) ).c_str(); 410 328 args[nargs++] = "-Wl,--push-state,--as-needed"; 411 329 args[nargs++] = "-lcfathread"; 412 330 args[nargs++] = "-Wl,--pop-state"; 413 args[nargs++] = "-Wl,--push-state,--no-as-needed";414 331 args[nargs++] = "-lcfa"; 415 args[nargs++] = "-Wl,--pop-state"; 416 args[nargs++] = "-pthread"; 332 args[nargs++] = "-lpthread"; 417 333 args[nargs++] = "-ldl"; 418 334 args[nargs++] = "-lrt"; … … 445 361 } // if 446 362 363 Putenv( argv, "--prelude-dir=" + libdir + (intree ? "/prelude" : "") ); 364 447 365 if ( debug ) { 448 366 heading += " (debug)"; … … 452 370 } // if 453 371 454 if ( bprefix.length() == 0 ) { 455 switch(path) { 456 case Installed : bprefix = installlibdir; break; 457 case BuildTree : bprefix = srcdriverdir ; break; 458 case Distributed : bprefix = dir(argv[0]) ; break; 459 } 460 if ( bprefix[bprefix.length() - 1] != '/' ) bprefix += '/'; 461 Putenv( argv, string("-B=") + bprefix ); 372 if ( Bprefix.length() == 0 ) { 373 Bprefix = ! intree ? installlibdir : srcdriverdir; 374 if ( Bprefix[Bprefix.length() - 1] != '/' ) Bprefix += '/'; 375 args[nargs++] = ( *new string( string("-D__GCC_BPREFIX__=") + Bprefix ) ).c_str(); 462 376 } // if 463 377 … … 487 401 args[nargs++] = "-fgnu89-inline"; 488 402 args[nargs++] = "-D__int8_t_defined"; // prevent gcc type-size attributes 489 args[nargs++] = ( *new string( string("-B") + bprefix ) ).c_str();403 args[nargs++] = ( *new string( string("-B") + Bprefix ) ).c_str(); 490 404 } else { 491 405 cerr << argv[0] << " error, compiler \"" << compiler_name << "\" unsupported." << endl; … … 501 415 cerr << " \"" << args[i] << "\"" << endl; 502 416 } // for 503 cerr << endl;504 417 #endif // __DEBUG_H__ 505 418 506 419 if ( ! quiet ) { 507 420 cerr << "CFA " << "Version " << Version << heading << endl; 421 508 422 if ( help ) { 509 423 cerr << -
libcfa/Makefile.in
r3d5701e r9fb8f01 231 231 CFACC = @CFACC@ 232 232 CFACPP = @CFACPP@ 233 CFADIR_HASH = @CFADIR_HASH@234 233 CFA_BINDIR = @CFA_BINDIR@ 235 234 CFA_INCDIR = @CFA_INCDIR@ … … 275 274 LIPO = @LIPO@ 276 275 LN_S = @LN_S@ 277 LOCAL_CC1 = @LOCAL_CC1@278 LOCAL_CFACC = @LOCAL_CFACC@279 276 LTLIBOBJS = @LTLIBOBJS@ 280 277 LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -
libcfa/automake/missing
-
Property mode
changed from
100644to120000
r3d5701e r9fb8f01 1 #! /bin/sh 2 # Tdelisle : having the Makefiles.in automatically regenerated causes problems 3 # when using multiple versions of automake, even if only on end user machines 4 # therefore I am disabling that feature by commenting this script 5 exit 0 1 /usr/share/automake-1.15/missing -
Property mode
changed from
-
libcfa/configure
r3d5701e r9fb8f01 707 707 CONFIG_CFLAGS 708 708 ARCH_FLAGS 709 CFADIR_HASH710 LOCAL_CC1711 LOCAL_CFACC712 709 CFACPP 713 710 CFACC 714 ENABLE_DISTCC_FALSE715 ENABLE_DISTCC_TRUE716 711 CFA_VERSION 717 712 DRIVER_DIR … … 788 783 enable_option_checking 789 784 enable_silent_rules 790 enable_distcc791 785 with_cfa_name 792 786 enable_shared … … 1451 1445 --enable-silent-rules less verbose build output (undo: "make V=1") 1452 1446 --disable-silent-rules verbose build output (undo: "make V=0") 1453 --enable-distcc whether or not to enable distributed compilation1454 1447 --enable-shared[=PKGS] build shared libraries [default=yes] 1455 1448 --enable-static[=PKGS] build static libraries [default=yes] … … 2948 2941 2949 2942 2950 # Check whether --enable-distcc was given. 2951 if test "${enable_distcc+set}" = set; then : 2952 enableval=$enable_distcc; enable_distcc=$enableval 2953 else 2954 enable_distcc=no 2955 fi 2956 2957 2958 echo -n "checking for distributated build... " 2959 if test x$enable_distcc = xno; then 2960 CFACC=${DRIVER_DIR}cfa 2961 echo "no" 2962 else 2963 tools="$(readlink -m $ac_confdir/)/../tools/build" 2964 config=$(basename $(readlink -f .)) 2965 echo "$tools/distcc_hash $config" 2966 CFADIR_HASH=$($tools/distcc_hash $config) 2967 CFACC="distcc ~/.cfadistcc/${CFADIR_HASH}/cfa" 2968 echo "yes (hash=${CFADIR_HASH})" 2969 fi 2943 CFACC=${DRIVER_DIR}cfa 2970 2944 CFACPP=${DRIVER_DIR}cfa-cpp 2971 LOCAL_CFACC=${DRIVER_DIR}cfa2972 LOCAL_CC1=${DRIVER_DIR}cc12973 2974 if test x$enable_distcc = xyes; then2975 ENABLE_DISTCC_TRUE=2976 ENABLE_DISTCC_FALSE='#'2977 else2978 ENABLE_DISTCC_TRUE='#'2979 ENABLE_DISTCC_FALSE=2980 fi2981 2982 2983 2984 2985 2986 2945 2987 2946 … … 3000 2959 case $CONFIGURATION in 3001 2960 "debug" ) 3002 CONFIG_CFLAGS="-O 0-g"2961 CONFIG_CFLAGS="-Og -g" 3003 2962 CONFIG_CFAFLAGS="-debug" 3004 2963 CONFIG_BUILDLIB="yes" … … 17023 16982 fi 17024 16983 17025 if test -z "${ENABLE_DISTCC_TRUE}" && test -z "${ENABLE_DISTCC_FALSE}"; then17026 as_fn_error $? "conditional \"ENABLE_DISTCC\" was never defined.17027 Usually this means the macro was only invoked conditionally." "$LINENO" 517028 fi17029 16984 if test -z "${BUILDLIB_TRUE}" && test -z "${BUILDLIB_FALSE}"; then 17030 16985 as_fn_error $? "conditional \"BUILDLIB\" was never defined. -
libcfa/configure.ac
r3d5701e r9fb8f01 27 27 AC_ARG_VAR(CFA_VERSION, [The long version of cfa]) 28 28 29 AC_ARG_ENABLE(distcc, 30 [ --enable-distcc whether or not to enable distributed compilation], 31 enable_distcc=$enableval, enable_distcc=no) 32 33 echo -n "checking for distributated build... " 34 if test x$enable_distcc = xno; then 35 CFACC=${DRIVER_DIR}cfa 36 echo "no" 37 else 38 tools="$(readlink -m $ac_confdir/)/../tools/build" 39 config=$(basename $(readlink -f .)) 40 echo "$tools/distcc_hash $config" 41 CFADIR_HASH=$($tools/distcc_hash $config) 42 CFACC="distcc ~/.cfadistcc/${CFADIR_HASH}/cfa" 43 echo "yes (hash=${CFADIR_HASH})" 44 fi 29 CFACC=${DRIVER_DIR}cfa 45 30 CFACPP=${DRIVER_DIR}cfa-cpp 46 LOCAL_CFACC=${DRIVER_DIR}cfa47 LOCAL_CC1=${DRIVER_DIR}cc148 49 AM_CONDITIONAL([ENABLE_DISTCC], [test x$enable_distcc = xyes])50 51 31 AC_SUBST(CFACC) 52 32 AC_SUBST(CFACPP) 53 AC_SUBST(LOCAL_CFACC)54 AC_SUBST(LOCAL_CC1)55 AC_SUBST(CFADIR_HASH)56 33 AC_SUBST(CFA_VERSION) 57 34 … … 68 45 case $CONFIGURATION in 69 46 "debug" ) 70 CONFIG_CFLAGS="-O 0-g"47 CONFIG_CFLAGS="-Og -g" 71 48 CONFIG_CFAFLAGS="-debug" 72 49 CONFIG_BUILDLIB="yes" -
libcfa/prelude/Makefile.am
r3d5701e r9fb8f01 11 11 ## Created On : Sun May 31 08:54:01 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Mon Feb 3 21:27:18 202014 ## Update Count : 20 813 ## Last Modified On : Wed Dec 14 15:00:35 2016 14 ## Update Count : 205 15 15 ############################################################################### 16 16 … … 23 23 cfalib_DATA = gcc-builtins.cf builtins.cf extras.cf prelude.cfa bootloader.c 24 24 25 CC = @ LOCAL_CFACC@25 CC = @CFACC@ 26 26 AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC @ARCH_FLAGS@ @CONFIG_CFLAGS@ 27 27 AM_CFAFLAGS = @CONFIG_CFAFLAGS@ … … 36 36 extras.cf : ${srcdir}/extras.regx ${srcdir}/extras.c 37 37 ${AM_V_GEN}gcc ${AM_CFLAGS} -E ${srcdir}/extras.c | grep -f ${srcdir}/extras.regx > extras.cf 38 ${AM_V_GEN}gcc ${AM_CFLAGS} -E ${srcdir}/extras.c | grep -zo -f ${srcdir}/extras.regx2 | tr '\0' '\n' >> extras.cf39 38 40 39 # create forward declarations for gcc builtins … … 55 54 56 55 # create forward declarations for cfa builtins 57 builtins.cf : builtins.c @LOCAL_CFACC@56 builtins.cf : builtins.c ${CC} 58 57 ${AM_V_GEN}gcc ${AM_CFLAGS} -E -P ${<} -o ${@} -MD -MP -MF $(DEPDIR)/builtins.Po -D__cforall 59 58 ${AM_V_at}sed -i 's/builtins.o/builtins.cf/g' $(DEPDIR)/builtins.Po … … 69 68 MOSTLYCLEANFILES = bootloader.c builtins.cf extras.cf gcc-builtins.c gcc-builtins.cf prelude.cfa 70 69 MAINTAINERCLEANFILES = ${addprefix ${libdir}/,${cfalib_DATA}} ${addprefix ${libdir}/,${lib_LIBRARIES}} 71 72 if ENABLE_DISTCC73 distribution: @LOCAL_CFACC@ @LOCAL_CC1@ @CFACPP@ gcc-builtins.cf builtins.cf extras.cf prelude.cfa bootloader.c $(srcdir)/../../tools/build/push2dist.sh74 ${AM_V_GEN}$(srcdir)/../../tools/build/push2dist.sh @CFADIR_HASH@75 @echo "Dummy file to track distribution to remote hosts" > ${@}76 77 all: all-am distribution78 endif ENABLE_DISTCC -
libcfa/prelude/Makefile.in
r3d5701e r9fb8f01 1 # Makefile.in generated by automake 1.1 6.1from Makefile.am.1 # Makefile.in generated by automake 1.15 from Makefile.am. 2 2 # @configure_input@ 3 3 4 # Copyright (C) 1994-201 8Free Software Foundation, Inc.4 # Copyright (C) 1994-2014 Free Software Foundation, Inc. 5 5 6 6 # This Makefile.in is free software; the Free Software Foundation … … 167 167 AUTOMAKE = @AUTOMAKE@ 168 168 AWK = @AWK@ 169 CC = @ LOCAL_CFACC@169 CC = @CFACC@ 170 170 CCAS = @CCAS@ 171 171 CCASDEPMODE = @CCASDEPMODE@ … … 174 174 CFACC = @CFACC@ 175 175 CFACPP = @CFACPP@ 176 CFADIR_HASH = @CFADIR_HASH@177 176 CFA_BINDIR = @CFA_BINDIR@ 178 177 CFA_INCDIR = @CFA_INCDIR@ … … 218 217 LIPO = @LIPO@ 219 218 LN_S = @LN_S@ 220 LOCAL_CC1 = @LOCAL_CC1@221 LOCAL_CFACC = @LOCAL_CFACC@222 219 LTLIBOBJS = @LTLIBOBJS@ 223 220 LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ … … 331 328 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ 332 329 *) \ 333 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__ maybe_remake_depfiles)'; \334 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__ maybe_remake_depfiles);; \330 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ 331 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ 335 332 esac; 336 333 … … 377 374 378 375 379 distdir: $(BUILT_SOURCES) 380 $(MAKE) $(AM_MAKEFLAGS) distdir-am 381 382 distdir-am: $(DISTFILES) 376 distdir: $(DISTFILES) 383 377 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 384 378 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ … … 543 537 extras.cf : ${srcdir}/extras.regx ${srcdir}/extras.c 544 538 ${AM_V_GEN}gcc ${AM_CFLAGS} -E ${srcdir}/extras.c | grep -f ${srcdir}/extras.regx > extras.cf 545 ${AM_V_GEN}gcc ${AM_CFLAGS} -E ${srcdir}/extras.c | grep -zo -f ${srcdir}/extras.regx2 | tr '\0' '\n' >> extras.cf546 539 547 540 # create forward declarations for gcc builtins … … 562 555 563 556 # create forward declarations for cfa builtins 564 builtins.cf : builtins.c @LOCAL_CFACC@557 builtins.cf : builtins.c ${CC} 565 558 ${AM_V_GEN}gcc ${AM_CFLAGS} -E -P ${<} -o ${@} -MD -MP -MF $(DEPDIR)/builtins.Po -D__cforall 566 559 ${AM_V_at}sed -i 's/builtins.o/builtins.cf/g' $(DEPDIR)/builtins.Po … … 573 566 maintainer-clean-local : 574 567 rm -rf $(DEPDIR) 575 576 @ENABLE_DISTCC_TRUE@distribution: @LOCAL_CFACC@ @LOCAL_CC1@ @CFACPP@ gcc-builtins.cf builtins.cf extras.cf prelude.cfa bootloader.c $(srcdir)/../../tools/build/push2dist.sh577 @ENABLE_DISTCC_TRUE@ ${AM_V_GEN}$(srcdir)/../../tools/build/push2dist.sh @CFADIR_HASH@578 @ENABLE_DISTCC_TRUE@ @echo "Dummy file to track distribution to remote hosts" > ${@}579 580 @ENABLE_DISTCC_TRUE@all: all-am distribution581 568 582 569 # Tell versions [3.59,3.63) of GNU make to not export all variables. -
libcfa/prelude/builtins.c
r3d5701e r9fb8f01 10 10 // Created On : Fri Jul 21 16:21:03 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Nov 21 16:31:39201913 // Update Count : 10112 // Last Modified On : Tue Jun 25 18:06:52 2019 13 // Update Count : 97 14 14 // 15 15 … … 69 69 70 70 // universal typed pointer constant 71 static inline forall( dtype DT ) DT * intptr( uintptr_t addr ) { return (DT *)addr; } 71 // Compiler issue: there is a problem with anonymous types that do not have a size. 72 static inline forall( dtype DT | sized(DT) ) DT * intptr( uintptr_t addr ) { return (DT *)addr; } 72 73 73 74 // exponentiation operator implementation -
libcfa/prelude/extras.regx
r3d5701e r9fb8f01 19 19 typedef.* uint32_t; 20 20 typedef.* uint64_t; 21 typedef.* __uint_least16_t;22 typedef.* __uint_least32_t;23 21 typedef.* char16_t; 24 22 typedef.* char32_t; 25 23 typedef.* wchar_t; 24 extern.*\*malloc\(.*\).* 25 extern.* free\(.*\).* 26 extern.* exit\(.*\).* 27 extern.* atexit\(.*\).* 28 extern.* abort\(.*\).* 29 extern.* printf\(.*\).* -
libcfa/prelude/prototypes.awk
r3d5701e r9fb8f01 10 10 # Created On : Sat May 16 07:57:37 2015 11 11 # Last Modified By : Peter A. Buhr 12 # Last Modified On : Sat Feb 8 09:46:58 202013 # Update Count : 3 612 # Last Modified On : Thu Jun 6 20:46:28 2019 13 # Update Count : 34 14 14 # 15 15 … … 17 17 18 18 BEGIN { 19 FS = "[( )]"19 FS = "[( )]" 20 20 # order so string search is longest string 21 21 i=-1 … … 84 84 85 85 /BT_FN/ { 86 for (i = 1; i <= NF; i += 1) {87 if( match($i, "BT_FN") != 0 ) {88 prototypes[$i] = $i89 }86 for (i = 1; i <= NF; i++) { 87 if( match($i, "BT_FN") != 0 ) { 88 prototypes[$i] = $i 89 } 90 90 } 91 }91 } 92 92 93 93 END { … … 103 103 104 104 for ( prototype in prototypes ) { 105 # printf( "//\"%s\"\n", prototype ) 106 if ( index( "BT_LAST", prototype ) == 1 ) { 107 continue 105 # printf( "//\"%s\"\n", prototype ) 106 if ( index( "BT_LAST", prototype ) == 1 ) { 107 continue 108 } # if 109 110 printf( "#define %s(NAME) FUNC_SIMPLE(", prototype ) 111 112 if ( sub( "BT_FN_", "", prototype ) == 0 ) { 113 printf( "\n********** BAD MACRO NAME \"%s\" **********\n", prototype ) 114 exit 0 115 } # if 116 117 # generate function return type as macro 118 for ( t = 0; t < N; t += 1 ) { # find longest match 119 type = types[t]; 120 if ( index( prototype, type ) == 1 ) { # found match 121 printf( "BT_%s, NAME", type ) 122 sub( type, "", prototype ) 123 break; 108 124 } # if 125 } # for 109 126 110 printf( "#define %s(NAME) FUNC_SIMPLE(", prototype ) 111 112 if ( sub( "BT_FN_", "", prototype ) == 0 ) { 113 printf( "\n********** BAD MACRO NAME \"%s\" **********\n", prototype ) 127 # generate function parameter types as macro 128 if ( index( prototype, "VAR" ) != 2 ) { # C-style empty parameters ? 129 for ( p = 0; length( prototype ) > 0; p += 1 ) { # until all parameters types are removed 130 sub( "_", "", prototype) # remove "_" 131 printf( ", ", type ) 132 temp = prototype 133 for ( t = 0; t < N; t += 1 ) { # find longest match 134 type = types[t]; 135 if ( index( prototype, type ) == 1 ) { # found match 136 printf( "BT_%s", type ) 137 sub( type, "", prototype ) 138 break; 139 } # if 140 } # for 141 if ( temp == prototype ) { # no match found for parameter in macro table 142 printf( "\n********** MISSING TYPE \"%s\" **********\n", prototype ) 114 143 exit 0 115 } # if 116 117 # generate function return type as macro 118 for ( t = 0; t < N; t += 1 ) { # find longest match 119 type = types[t]; 120 if ( index( prototype, type ) == 1 ) { # found match 121 printf( "BT_%s, NAME", type ) 122 sub( type, "", prototype ) 123 break; 124 } # if 144 } # if 125 145 } # for 126 127 # generate function parameter types as macro 128 if ( index( prototype, "VAR" ) != 2 ) { # C-style empty parameters ? 129 for ( p = 0; length( prototype ) > 0; p += 1 ) { # until all parameters types are removed 130 sub( "_", "", prototype) # remove "_" 131 printf( ", ", type ) 132 temp = prototype 133 for ( t = 0; t < N; t += 1 ) { # find longest match 134 type = types[t]; 135 if ( index( prototype, type ) == 1 ) { # found match 136 printf( "BT_%s", type ) 137 sub( type, "", prototype ) 138 break; 139 } # if 140 } # for 141 if ( temp == prototype ) { # no match found for parameter in macro table 142 printf( "\n********** MISSING TYPE \"%s\" **********\n", prototype ) 143 exit 0 144 } # if 145 } # for 146 } # if 147 printf( ")\n" ) 146 } # if 147 printf( ")\n" ) 148 148 } # for 149 149 -
libcfa/prelude/sync-builtins.cf
r3d5701e r9fb8f01 1 1 char __sync_fetch_and_add(volatile char *, char,...); 2 char __sync_fetch_and_add_1(volatile char *, char,...); 2 3 signed char __sync_fetch_and_add(volatile signed char *, signed char,...); 4 signed char __sync_fetch_and_add_1(volatile signed char *, signed char,...); 3 5 unsigned char __sync_fetch_and_add(volatile unsigned char *, unsigned char,...); 6 unsigned char __sync_fetch_and_add_1(volatile unsigned char *, unsigned char,...); 4 7 signed short __sync_fetch_and_add(volatile signed short *, signed short,...); 8 signed short __sync_fetch_and_add_2(volatile signed short *, signed short,...); 5 9 unsigned short __sync_fetch_and_add(volatile unsigned short *, unsigned short,...); 10 unsigned short __sync_fetch_and_add_2(volatile unsigned short *, unsigned short,...); 6 11 signed int __sync_fetch_and_add(volatile signed int *, signed int,...); 12 signed int __sync_fetch_and_add_4(volatile signed int *, signed int,...); 7 13 unsigned int __sync_fetch_and_add(volatile unsigned int *, unsigned int,...); 8 signed long int __sync_fetch_and_add(volatile signed long int *, signed long int,...); 9 unsigned long int __sync_fetch_and_add(volatile unsigned long int *, unsigned long int,...); 14 unsigned int __sync_fetch_and_add_4(volatile unsigned int *, unsigned int,...); 10 15 signed long long int __sync_fetch_and_add(volatile signed long long int *, signed long long int,...); 16 signed long long int __sync_fetch_and_add_8(volatile signed long long int *, signed long long int,...); 11 17 unsigned long long int __sync_fetch_and_add(volatile unsigned long long int *, unsigned long long int,...); 18 unsigned long long int __sync_fetch_and_add_8(volatile unsigned long long int *, unsigned long long int,...); 12 19 #if defined(__SIZEOF_INT128__) 13 20 signed __int128 __sync_fetch_and_add(volatile signed __int128 *, signed __int128,...); 21 signed __int128 __sync_fetch_and_add_16(volatile signed __int128 *, signed __int128,...); 14 22 unsigned __int128 __sync_fetch_and_add(volatile unsigned __int128 *, unsigned __int128,...); 23 unsigned __int128 __sync_fetch_and_add_16(volatile unsigned __int128 *, unsigned __int128,...); 15 24 #endif 16 25 17 26 char __sync_fetch_and_sub(volatile char *, char,...); 27 char __sync_fetch_and_sub_1(volatile char *, char,...); 18 28 signed char __sync_fetch_and_sub(volatile signed char *, signed char,...); 29 signed char __sync_fetch_and_sub_1(volatile signed char *, signed char,...); 19 30 unsigned char __sync_fetch_and_sub(volatile unsigned char *, unsigned char,...); 31 unsigned char __sync_fetch_and_sub_1(volatile unsigned char *, unsigned char,...); 20 32 signed short __sync_fetch_and_sub(volatile signed short *, signed short,...); 33 signed short __sync_fetch_and_sub_2(volatile signed short *, signed short,...); 21 34 unsigned short __sync_fetch_and_sub(volatile unsigned short *, unsigned short,...); 35 unsigned short __sync_fetch_and_sub_2(volatile unsigned short *, unsigned short,...); 22 36 signed int __sync_fetch_and_sub(volatile signed int *, signed int,...); 37 signed int __sync_fetch_and_sub_4(volatile signed int *, signed int,...); 23 38 unsigned int __sync_fetch_and_sub(volatile unsigned int *, unsigned int,...); 24 signed long int __sync_fetch_and_sub(volatile signed long int *, signed long int,...); 25 unsigned long int __sync_fetch_and_sub(volatile unsigned long int *, unsigned long int,...); 39 unsigned int __sync_fetch_and_sub_4(volatile unsigned int *, unsigned int,...); 26 40 signed long long int __sync_fetch_and_sub(volatile signed long long int *, signed long long int,...); 41 signed long long int __sync_fetch_and_sub_8(volatile signed long long int *, signed long long int,...); 27 42 unsigned long long int __sync_fetch_and_sub(volatile unsigned long long int *, unsigned long long int,...); 43 unsigned long long int __sync_fetch_and_sub_8(volatile unsigned long long int *, unsigned long long int,...); 28 44 #if defined(__SIZEOF_INT128__) 29 45 signed __int128 __sync_fetch_and_sub(volatile signed __int128 *, signed __int128,...); 46 signed __int128 __sync_fetch_and_sub_16(volatile signed __int128 *, signed __int128,...); 30 47 unsigned __int128 __sync_fetch_and_sub(volatile unsigned __int128 *, unsigned __int128,...); 48 unsigned __int128 __sync_fetch_and_sub_16(volatile unsigned __int128 *, unsigned __int128,...); 31 49 #endif 32 50 33 51 char __sync_fetch_and_or(volatile char *, char,...); 52 char __sync_fetch_and_or_1(volatile char *, char,...); 34 53 signed char __sync_fetch_and_or(volatile signed char *, signed char,...); 54 signed char __sync_fetch_and_or_1(volatile signed char *, signed char,...); 35 55 unsigned char __sync_fetch_and_or(volatile unsigned char *, unsigned char,...); 56 unsigned char __sync_fetch_and_or_1(volatile unsigned char *, unsigned char,...); 36 57 signed short __sync_fetch_and_or(volatile signed short *, signed short,...); 58 signed short __sync_fetch_and_or_2(volatile signed short *, signed short,...); 37 59 unsigned short __sync_fetch_and_or(volatile unsigned short *, unsigned short,...); 60 unsigned short __sync_fetch_and_or_2(volatile unsigned short *, unsigned short,...); 38 61 signed int __sync_fetch_and_or(volatile signed int *, signed int,...); 62 signed int __sync_fetch_and_or_4(volatile signed int *, signed int,...); 39 63 unsigned int __sync_fetch_and_or(volatile unsigned int *, unsigned int,...); 40 signed long int __sync_fetch_and_or(volatile signed long int *, signed long int,...); 41 unsigned long int __sync_fetch_and_or(volatile unsigned long int *, unsigned long int,...); 64 unsigned int __sync_fetch_and_or_4(volatile unsigned int *, unsigned int,...); 42 65 signed long long int __sync_fetch_and_or(volatile signed long long int *, signed long long int,...); 66 signed long long int __sync_fetch_and_or_8(volatile signed long long int *, signed long long int,...); 43 67 unsigned long long int __sync_fetch_and_or(volatile unsigned long long int *, unsigned long long int,...); 68 unsigned long long int __sync_fetch_and_or_8(volatile unsigned long long int *, unsigned long long int,...); 44 69 #if defined(__SIZEOF_INT128__) 45 70 signed __int128 __sync_fetch_and_or(volatile signed __int128 *, signed __int128,...); 71 signed __int128 __sync_fetch_and_or_16(volatile signed __int128 *, signed __int128,...); 46 72 unsigned __int128 __sync_fetch_and_or(volatile unsigned __int128 *, unsigned __int128,...); 73 unsigned __int128 __sync_fetch_and_or_16(volatile unsigned __int128 *, unsigned __int128,...); 47 74 #endif 48 75 49 76 char __sync_fetch_and_and(volatile char *, char,...); 77 char __sync_fetch_and_and_1(volatile char *, char,...); 50 78 signed char __sync_fetch_and_and(volatile signed char *, signed char,...); 79 signed char __sync_fetch_and_and_1(volatile signed char *, signed char,...); 51 80 unsigned char __sync_fetch_and_and(volatile unsigned char *, unsigned char,...); 81 unsigned char __sync_fetch_and_and_1(volatile unsigned char *, unsigned char,...); 52 82 signed short __sync_fetch_and_and(volatile signed short *, signed short,...); 83 signed short __sync_fetch_and_and_2(volatile signed short *, signed short,...); 53 84 unsigned short __sync_fetch_and_and(volatile unsigned short *, unsigned short,...); 85 unsigned short __sync_fetch_and_and_2(volatile unsigned short *, unsigned short,...); 54 86 signed int __sync_fetch_and_and(volatile signed int *, signed int,...); 87 signed int __sync_fetch_and_and_4(volatile signed int *, signed int,...); 55 88 unsigned int __sync_fetch_and_and(volatile unsigned int *, unsigned int,...); 56 signed long int __sync_fetch_and_and(volatile signed long int *, signed long int,...); 57 unsigned long int __sync_fetch_and_and(volatile unsigned long int *, unsigned long int,...); 89 unsigned int __sync_fetch_and_and_4(volatile unsigned int *, unsigned int,...); 58 90 signed long long int __sync_fetch_and_and(volatile signed long long int *, signed long long int,...); 91 signed long long int __sync_fetch_and_and_8(volatile signed long long int *, signed long long int,...); 59 92 unsigned long long int __sync_fetch_and_and(volatile unsigned long long int *, unsigned long long int,...); 93 unsigned long long int __sync_fetch_and_and_8(volatile unsigned long long int *, unsigned long long int,...); 60 94 #if defined(__SIZEOF_INT128__) 61 95 signed __int128 __sync_fetch_and_and(volatile signed __int128 *, signed __int128,...); 96 signed __int128 __sync_fetch_and_and_16(volatile signed __int128 *, signed __int128,...); 62 97 unsigned __int128 __sync_fetch_and_and(volatile unsigned __int128 *, unsigned __int128,...); 98 unsigned __int128 __sync_fetch_and_and_16(volatile unsigned __int128 *, unsigned __int128,...); 63 99 #endif 64 100 65 101 char __sync_fetch_and_xor(volatile char *, char,...); 102 char __sync_fetch_and_xor_1(volatile char *, char,...); 66 103 signed char __sync_fetch_and_xor(volatile signed char *, signed char,...); 104 signed char __sync_fetch_and_xor_1(volatile signed char *, signed char,...); 67 105 unsigned char __sync_fetch_and_xor(volatile unsigned char *, unsigned char,...); 106 unsigned char __sync_fetch_and_xor_1(volatile unsigned char *, unsigned char,...); 68 107 signed short __sync_fetch_and_xor(volatile signed short *, signed short,...); 108 signed short __sync_fetch_and_xor_2(volatile signed short *, signed short,...); 69 109 unsigned short __sync_fetch_and_xor(volatile unsigned short *, unsigned short,...); 110 unsigned short __sync_fetch_and_xor_2(volatile unsigned short *, unsigned short,...); 70 111 signed int __sync_fetch_and_xor(volatile signed int *, signed int,...); 112 signed int __sync_fetch_and_xor_4(volatile signed int *, signed int,...); 71 113 unsigned int __sync_fetch_and_xor(volatile unsigned int *, unsigned int,...); 72 signed long int __sync_fetch_and_xor(volatile signed long int *, signed long int,...); 73 unsigned long int __sync_fetch_and_xor(volatile unsigned long int *, unsigned long int,...); 114 unsigned int __sync_fetch_and_xor_4(volatile unsigned int *, unsigned int,...); 74 115 signed long long int __sync_fetch_and_xor(volatile signed long long int *, signed long long int,...); 116 signed long long int __sync_fetch_and_xor_8(volatile signed long long int *, signed long long int,...); 75 117 unsigned long long int __sync_fetch_and_xor(volatile unsigned long long int *, unsigned long long int,...); 118 unsigned long long int __sync_fetch_and_xor_8(volatile unsigned long long int *, unsigned long long int,...); 76 119 #if defined(__SIZEOF_INT128__) 77 120 signed __int128 __sync_fetch_and_xor(volatile signed __int128 *, signed __int128,...); 121 signed __int128 __sync_fetch_and_xor_16(volatile signed __int128 *, signed __int128,...); 78 122 unsigned __int128 __sync_fetch_and_xor(volatile unsigned __int128 *, unsigned __int128,...); 123 unsigned __int128 __sync_fetch_and_xor_16(volatile unsigned __int128 *, unsigned __int128,...); 79 124 #endif 80 125 81 126 char __sync_fetch_and_nand(volatile char *, char,...); 127 char __sync_fetch_and_nand_1(volatile char *, char,...); 82 128 signed char __sync_fetch_and_nand(volatile signed char *, signed char,...); 129 signed char __sync_fetch_and_nand_1(volatile signed char *, signed char,...); 83 130 unsigned char __sync_fetch_and_nand(volatile unsigned char *, unsigned char,...); 131 unsigned char __sync_fetch_and_nand_1(volatile unsigned char *, unsigned char,...); 84 132 signed short __sync_fetch_and_nand(volatile signed short *, signed short,...); 133 signed short __sync_fetch_and_nand_2(volatile signed short *, signed short,...); 85 134 unsigned short __sync_fetch_and_nand(volatile unsigned short *, unsigned short,...); 135 unsigned short __sync_fetch_and_nand_2(volatile unsigned short *, unsigned short,...); 86 136 signed int __sync_fetch_and_nand(volatile signed int *, signed int,...); 137 signed int __sync_fetch_and_nand_4(volatile signed int *, signed int,...); 87 138 unsigned int __sync_fetch_and_nand(volatile unsigned int *, unsigned int,...); 88 signed long int __sync_fetch_and_nand(volatile signed long int *, signed long int,...); 89 unsigned long int __sync_fetch_and_nand(volatile unsigned long int *, unsigned long int,...); 139 unsigned int __sync_fetch_and_nand_4(volatile unsigned int *, unsigned int,...); 90 140 signed long long int __sync_fetch_and_nand(volatile signed long long int *, signed long long int,...); 141 signed long long int __sync_fetch_and_nand_8(volatile signed long long int *, signed long long int,...); 91 142 unsigned long long int __sync_fetch_and_nand(volatile unsigned long long int *, unsigned long long int,...); 143 unsigned long long int __sync_fetch_and_nand_8(volatile unsigned long long int *, unsigned long long int,...); 92 144 #if defined(__SIZEOF_INT128__) 93 145 signed __int128 __sync_fetch_and_nand(volatile signed __int128 *, signed __int128,...); 146 signed __int128 __sync_fetch_and_nand_16(volatile signed __int128 *, signed __int128,...); 94 147 unsigned __int128 __sync_fetch_and_nand(volatile unsigned __int128 *, unsigned __int128,...); 148 unsigned __int128 __sync_fetch_and_nand_16(volatile unsigned __int128 *, unsigned __int128,...); 95 149 #endif 96 150 97 151 char __sync_add_and_fetch(volatile char *, char,...); 152 char __sync_add_and_fetch_1(volatile char *, char,...); 98 153 signed char __sync_add_and_fetch(volatile signed char *, signed char,...); 154 signed char __sync_add_and_fetch_1(volatile signed char *, signed char,...); 99 155 unsigned char __sync_add_and_fetch(volatile unsigned char *, unsigned char,...); 156 unsigned char __sync_add_and_fetch_1(volatile unsigned char *, unsigned char,...); 100 157 signed short __sync_add_and_fetch(volatile signed short *, signed short,...); 158 signed short __sync_add_and_fetch_2(volatile signed short *, signed short,...); 101 159 unsigned short __sync_add_and_fetch(volatile unsigned short *, unsigned short,...); 160 unsigned short __sync_add_and_fetch_2(volatile unsigned short *, unsigned short,...); 102 161 signed int __sync_add_and_fetch(volatile signed int *, signed int,...); 162 signed int __sync_add_and_fetch_4(volatile signed int *, signed int,...); 103 163 signed int __sync_add_and_fetch(volatile signed int *, signed int,...); 104 signed long int __sync_add_and_fetch(volatile signed long int *, signed long int,...); 105 unsigned long int __sync_add_and_fetch(volatile unsigned long int *, unsigned long int,...); 164 signed int __sync_add_and_fetch_4(volatile signed int *, signed int,...); 106 165 signed long long int __sync_add_and_fetch(volatile signed long long int *, signed long long int,...); 166 signed long long int __sync_add_and_fetch_8(volatile signed long long int *, signed long long int,...); 107 167 unsigned long long int __sync_add_and_fetch(volatile unsigned long long int *, unsigned long long int,...); 168 unsigned long long int __sync_add_and_fetch_8(volatile unsigned long long int *, unsigned long long int,...); 108 169 #if defined(__SIZEOF_INT128__) 109 170 signed __int128 __sync_add_and_fetch(volatile signed __int128 *, signed __int128,...); 171 signed __int128 __sync_add_and_fetch_16(volatile signed __int128 *, signed __int128,...); 110 172 unsigned __int128 __sync_add_and_fetch(volatile unsigned __int128 *, unsigned __int128,...); 173 unsigned __int128 __sync_add_and_fetch_16(volatile unsigned __int128 *, unsigned __int128,...); 111 174 #endif 112 175 113 176 char __sync_sub_and_fetch(volatile char *, char,...); 177 char __sync_sub_and_fetch_1(volatile char *, char,...); 114 178 signed char __sync_sub_and_fetch(volatile signed char *, signed char,...); 179 signed char __sync_sub_and_fetch_1(volatile signed char *, signed char,...); 115 180 unsigned char __sync_sub_and_fetch(volatile unsigned char *, unsigned char,...); 181 unsigned char __sync_sub_and_fetch_1(volatile unsigned char *, unsigned char,...); 116 182 signed short __sync_sub_and_fetch(volatile signed short *, signed short,...); 183 signed short __sync_sub_and_fetch_2(volatile signed short *, signed short,...); 117 184 unsigned short __sync_sub_and_fetch(volatile unsigned short *, unsigned short,...); 185 unsigned short __sync_sub_and_fetch_2(volatile unsigned short *, unsigned short,...); 118 186 signed int __sync_sub_and_fetch(volatile signed int *, signed int,...); 187 signed int __sync_sub_and_fetch_4(volatile signed int *, signed int,...); 119 188 unsigned int __sync_sub_and_fetch(volatile unsigned int *, unsigned int,...); 120 signed long int __sync_sub_and_fetch(volatile signed long int *, signed long int,...); 121 unsigned long int __sync_sub_and_fetch(volatile unsigned long int *, unsigned long int,...); 189 unsigned int __sync_sub_and_fetch_4(volatile unsigned int *, unsigned int,...); 122 190 signed long long int __sync_sub_and_fetch(volatile signed long long int *, signed long long int,...); 191 signed long long int __sync_sub_and_fetch_8(volatile signed long long int *, signed long long int,...); 123 192 unsigned long long int __sync_sub_and_fetch(volatile unsigned long long int *, unsigned long long int,...); 193 unsigned long long int __sync_sub_and_fetch_8(volatile unsigned long long int *, unsigned long long int,...); 124 194 #if defined(__SIZEOF_INT128__) 125 195 signed __int128 __sync_sub_and_fetch(volatile signed __int128 *, signed __int128,...); 196 signed __int128 __sync_sub_and_fetch_16(volatile signed __int128 *, signed __int128,...); 126 197 unsigned __int128 __sync_sub_and_fetch(volatile unsigned __int128 *, unsigned __int128,...); 198 unsigned __int128 __sync_sub_and_fetch_16(volatile unsigned __int128 *, unsigned __int128,...); 127 199 #endif 128 200 129 201 char __sync_or_and_fetch(volatile char *, char,...); 202 char __sync_or_and_fetch_1(volatile char *, char,...); 130 203 signed char __sync_or_and_fetch(volatile signed char *, signed char,...); 204 signed char __sync_or_and_fetch_1(volatile signed char *, signed char,...); 131 205 unsigned char __sync_or_and_fetch(volatile unsigned char *, unsigned char,...); 206 unsigned char __sync_or_and_fetch_1(volatile unsigned char *, unsigned char,...); 132 207 signed short __sync_or_and_fetch(volatile signed short *, signed short,...); 208 signed short __sync_or_and_fetch_2(volatile signed short *, signed short,...); 133 209 unsigned short __sync_or_and_fetch(volatile unsigned short *, unsigned short,...); 210 unsigned short __sync_or_and_fetch_2(volatile unsigned short *, unsigned short,...); 134 211 signed int __sync_or_and_fetch(volatile signed int *, signed int,...); 212 signed int __sync_or_and_fetch_4(volatile signed int *, signed int,...); 135 213 unsigned int __sync_or_and_fetch(volatile unsigned int *, unsigned int,...); 136 signed long int __sync_or_and_fetch(volatile signed long int *, signed long int,...); 137 unsigned long int __sync_or_and_fetch(volatile unsigned long int *, unsigned long int,...); 214 unsigned int __sync_or_and_fetch_4(volatile unsigned int *, unsigned int,...); 138 215 signed long long int __sync_or_and_fetch(volatile signed long long int *, signed long long int,...); 216 signed long long int __sync_or_and_fetch_8(volatile signed long long int *, signed long long int,...); 139 217 unsigned long long int __sync_or_and_fetch(volatile unsigned long long int *, unsigned long long int,...); 218 unsigned long long int __sync_or_and_fetch_8(volatile unsigned long long int *, unsigned long long int,...); 140 219 #if defined(__SIZEOF_INT128__) 141 220 signed __int128 __sync_or_and_fetch(volatile signed __int128 *, signed __int128,...); 221 signed __int128 __sync_or_and_fetch_16(volatile signed __int128 *, signed __int128,...); 142 222 unsigned __int128 __sync_or_and_fetch(volatile unsigned __int128 *, unsigned __int128,...); 223 unsigned __int128 __sync_or_and_fetch_16(volatile unsigned __int128 *, unsigned __int128,...); 143 224 #endif 144 225 145 226 char __sync_and_and_fetch(volatile char *, char,...); 227 char __sync_and_and_fetch_1(volatile char *, char,...); 146 228 signed char __sync_and_and_fetch(volatile signed char *, signed char,...); 229 signed char __sync_and_and_fetch_1(volatile signed char *, signed char,...); 147 230 unsigned char __sync_and_and_fetch(volatile unsigned char *, unsigned char,...); 231 unsigned char __sync_and_and_fetch_1(volatile unsigned char *, unsigned char,...); 148 232 signed short __sync_and_and_fetch(volatile signed short *, signed short,...); 233 signed short __sync_and_and_fetch_2(volatile signed short *, signed short,...); 149 234 unsigned short __sync_and_and_fetch(volatile unsigned short *, unsigned short,...); 235 unsigned short __sync_and_and_fetch_2(volatile unsigned short *, unsigned short,...); 150 236 signed int __sync_and_and_fetch(volatile signed int *, signed int,...); 237 signed int __sync_and_and_fetch_4(volatile signed int *, signed int,...); 151 238 unsigned int __sync_and_and_fetch(volatile unsigned int *, unsigned int,...); 152 signed long int __sync_and_and_fetch(volatile signed long int *, signed long int,...); 153 unsigned long int __sync_and_and_fetch(volatile unsigned long int *, unsigned long int,...); 239 unsigned int __sync_and_and_fetch_4(volatile unsigned int *, unsigned int,...); 154 240 signed long long int __sync_and_and_fetch(volatile signed long long int *, signed long long int,...); 241 signed long long int __sync_and_and_fetch_8(volatile signed long long int *, signed long long int,...); 155 242 unsigned long long int __sync_and_and_fetch(volatile unsigned long long int *, unsigned long long int,...); 243 unsigned long long int __sync_and_and_fetch_8(volatile unsigned long long int *, unsigned long long int,...); 156 244 #if defined(__SIZEOF_INT128__) 157 245 signed __int128 __sync_and_and_fetch(volatile signed __int128 *, signed __int128,...); 246 signed __int128 __sync_and_and_fetch_16(volatile signed __int128 *, signed __int128,...); 158 247 unsigned __int128 __sync_and_and_fetch(volatile unsigned __int128 *, unsigned __int128,...); 248 unsigned __int128 __sync_and_and_fetch_16(volatile unsigned __int128 *, unsigned __int128,...); 159 249 #endif 160 250 161 251 char __sync_xor_and_fetch(volatile char *, char,...); 252 char __sync_xor_and_fetch_1(volatile char *, char,...); 162 253 signed char __sync_xor_and_fetch(volatile signed char *, signed char,...); 254 signed char __sync_xor_and_fetch_1(volatile signed char *, signed char,...); 163 255 unsigned char __sync_xor_and_fetch(volatile unsigned char *, unsigned char,...); 256 unsigned char __sync_xor_and_fetch_1(volatile unsigned char *, unsigned char,...); 164 257 signed short __sync_xor_and_fetch(volatile signed short *, signed short,...); 258 signed short __sync_xor_and_fetch_2(volatile signed short *, signed short,...); 165 259 unsigned short __sync_xor_and_fetch(volatile unsigned short *, unsigned short,...); 260 unsigned short __sync_xor_and_fetch_2(volatile unsigned short *, unsigned short,...); 166 261 signed int __sync_xor_and_fetch(volatile signed int *, signed int,...); 262 signed int __sync_xor_and_fetch_4(volatile signed int *, signed int,...); 167 263 unsigned int __sync_xor_and_fetch(volatile unsigned int *, unsigned int,...); 168 signed long int __sync_xor_and_fetch(volatile signed long int *, signed long int,...); 169 unsigned long int __sync_xor_and_fetch(volatile unsigned long int *, unsigned long int,...); 264 unsigned int __sync_xor_and_fetch_4(volatile unsigned int *, unsigned int,...); 170 265 signed long long int __sync_xor_and_fetch(volatile signed long long int *, signed long long int,...); 266 signed long long int __sync_xor_and_fetch_8(volatile signed long long int *, signed long long int,...); 171 267 unsigned long long int __sync_xor_and_fetch(volatile unsigned long long int *, unsigned long long int,...); 268 unsigned long long int __sync_xor_and_fetch_8(volatile unsigned long long int *, unsigned long long int,...); 172 269 #if defined(__SIZEOF_INT128__) 173 270 signed __int128 __sync_xor_and_fetch(volatile signed __int128 *, signed __int128,...); 271 signed __int128 __sync_xor_and_fetch_16(volatile signed __int128 *, signed __int128,...); 174 272 unsigned __int128 __sync_xor_and_fetch(volatile unsigned __int128 *, unsigned __int128,...); 273 unsigned __int128 __sync_xor_and_fetch_16(volatile unsigned __int128 *, unsigned __int128,...); 175 274 #endif 176 275 177 276 char __sync_nand_and_fetch(volatile char *, char,...); 277 char __sync_nand_and_fetch_1(volatile char *, char,...); 178 278 signed char __sync_nand_and_fetch(volatile signed char *, signed char,...); 279 signed char __sync_nand_and_fetch_1(volatile signed char *, signed char,...); 179 280 unsigned char __sync_nand_and_fetch(volatile unsigned char *, unsigned char,...); 281 unsigned char __sync_nand_and_fetch_1(volatile unsigned char *, unsigned char,...); 180 282 signed short __sync_nand_and_fetch(volatile signed short *, signed short,...); 283 signed short __sync_nand_and_fetch_2(volatile signed short *, signed short,...); 181 284 unsigned short __sync_nand_and_fetch(volatile unsigned short *, unsigned short,...); 285 unsigned short __sync_nand_and_fetch_2(volatile unsigned short *, unsigned short,...); 182 286 signed int __sync_nand_and_fetch(volatile signed int *, signed int,...); 287 signed int __sync_nand_and_fetch_4(volatile signed int *, signed int,...); 183 288 unsigned int __sync_nand_and_fetch(volatile unsigned int *, unsigned int,...); 184 signed long int __sync_nand_and_fetch(volatile signed long int *, signed long int,...); 185 unsigned long int __sync_nand_and_fetch(volatile unsigned long int *, unsigned long int,...); 289 unsigned int __sync_nand_and_fetch_4(volatile unsigned int *, unsigned int,...); 186 290 signed long long int __sync_nand_and_fetch(volatile signed long long int *, signed long long int,...); 291 signed long long int __sync_nand_and_fetch_8(volatile signed long long int *, signed long long int,...); 187 292 unsigned long long int __sync_nand_and_fetch(volatile unsigned long long int *, unsigned long long int,...); 293 unsigned long long int __sync_nand_and_fetch_8(volatile unsigned long long int *, unsigned long long int,...); 188 294 #if defined(__SIZEOF_INT128__) 189 295 signed __int128 __sync_nand_and_fetch(volatile signed __int128 *, signed __int128,...); 296 signed __int128 __sync_nand_and_fetch_16(volatile signed __int128 *, signed __int128,...); 190 297 unsigned __int128 __sync_nand_and_fetch(volatile unsigned __int128 *, unsigned __int128,...); 298 unsigned __int128 __sync_nand_and_fetch_16(volatile unsigned __int128 *, unsigned __int128,...); 191 299 #endif 192 300 193 301 _Bool __sync_bool_compare_and_swap(volatile char *, char, char,...); 302 _Bool __sync_bool_compare_and_swap_1(volatile char *, char, char,...); 194 303 _Bool __sync_bool_compare_and_swap(volatile signed char *, signed char, signed char,...); 304 _Bool __sync_bool_compare_and_swap_1(volatile signed char *, signed char, signed char,...); 195 305 _Bool __sync_bool_compare_and_swap(volatile unsigned char *, unsigned char, unsigned char,...); 306 _Bool __sync_bool_compare_and_swap_1(volatile unsigned char *, unsigned char, unsigned char,...); 196 307 _Bool __sync_bool_compare_and_swap(volatile short *, signed short, signed short,...); 308 _Bool __sync_bool_compare_and_swap_2(volatile short *, signed short, signed short,...); 197 309 _Bool __sync_bool_compare_and_swap(volatile short *, unsigned short, unsigned short,...); 310 _Bool __sync_bool_compare_and_swap_2(volatile short *, unsigned short, unsigned short,...); 198 311 _Bool __sync_bool_compare_and_swap(volatile signed int *, signed int, signed int,...); 312 _Bool __sync_bool_compare_and_swap_4(volatile signed int *, signed int, signed int,...); 199 313 _Bool __sync_bool_compare_and_swap(volatile unsigned int *, unsigned int, unsigned int,...); 200 _Bool __sync_bool_compare_and_swap(volatile signed long int *, signed long int, signed long int,...); 201 _Bool __sync_bool_compare_and_swap(volatile unsigned long int *, unsigned long int, unsigned long int,...); 314 _Bool __sync_bool_compare_and_swap_4(volatile unsigned int *, unsigned int, unsigned int,...); 202 315 _Bool __sync_bool_compare_and_swap(volatile signed long long int *, signed long long int, signed long long int,...); 316 _Bool __sync_bool_compare_and_swap_8(volatile signed long long int *, signed long long int, signed long long int,...); 203 317 _Bool __sync_bool_compare_and_swap(volatile unsigned long long int *, unsigned long long int, unsigned long long int,...); 318 _Bool __sync_bool_compare_and_swap_8(volatile unsigned long long int *, unsigned long long int, unsigned long long int,...); 204 319 #if defined(__SIZEOF_INT128__) 205 320 _Bool __sync_bool_compare_and_swap(volatile signed __int128 *, signed __int128, signed __int128,...); 321 _Bool __sync_bool_compare_and_swap_16(volatile signed __int128 *, signed __int128, signed __int128,...); 206 322 _Bool __sync_bool_compare_and_swap(volatile unsigned __int128 *, unsigned __int128, unsigned __int128,...); 323 _Bool __sync_bool_compare_and_swap_16(volatile unsigned __int128 *, unsigned __int128, unsigned __int128,...); 207 324 #endif 208 325 forall(dtype T) _Bool __sync_bool_compare_and_swap(T * volatile *, T *, T*, ...); 209 326 210 327 char __sync_val_compare_and_swap(volatile char *, char, char,...); 328 char __sync_val_compare_and_swap_1(volatile char *, char, char,...); 211 329 signed char __sync_val_compare_and_swap(volatile signed char *, signed char, signed char,...); 330 signed char __sync_val_compare_and_swap_1(volatile signed char *, signed char, signed char,...); 212 331 unsigned char __sync_val_compare_and_swap(volatile unsigned char *, unsigned char, unsigned char,...); 332 unsigned char __sync_val_compare_and_swap_1(volatile unsigned char *, unsigned char, unsigned char,...); 213 333 signed short __sync_val_compare_and_swap(volatile signed short *, signed short, signed short,...); 334 signed short __sync_val_compare_and_swap_2(volatile signed short *, signed short, signed short,...); 214 335 unsigned short __sync_val_compare_and_swap(volatile unsigned short *, unsigned short, unsigned short,...); 336 unsigned short __sync_val_compare_and_swap_2(volatile unsigned short *, unsigned short, unsigned short,...); 215 337 signed int __sync_val_compare_and_swap(volatile signed int *, signed int, signed int,...); 338 signed int __sync_val_compare_and_swap_4(volatile signed int *, signed int, signed int,...); 216 339 unsigned int __sync_val_compare_and_swap(volatile unsigned int *, unsigned int, unsigned int,...); 217 signed long int __sync_val_compare_and_swap(volatile signed long int *, signed long int, signed long int,...); 218 unsigned long int __sync_val_compare_and_swap(volatile unsigned long int *, unsigned long int, unsigned long int,...); 340 unsigned int __sync_val_compare_and_swap_4(volatile unsigned int *, unsigned int, unsigned int,...); 219 341 signed long long int __sync_val_compare_and_swap(volatile signed long long int *, signed long long int, signed long long int,...); 342 signed long long int __sync_val_compare_and_swap_8(volatile signed long long int *, signed long long int, signed long long int,...); 220 343 unsigned long long int __sync_val_compare_and_swap(volatile unsigned long long int *, unsigned long long int, unsigned long long int,...); 344 unsigned long long int __sync_val_compare_and_swap_8(volatile unsigned long long int *, unsigned long long int, unsigned long long int,...); 221 345 #if defined(__SIZEOF_INT128__) 222 346 signed __int128 __sync_val_compare_and_swap(volatile signed __int128 *, signed __int128, signed __int128,...); 347 signed __int128 __sync_val_compare_and_swap_16(volatile signed __int128 *, signed __int128, signed __int128,...); 223 348 unsigned __int128 __sync_val_compare_and_swap(volatile unsigned __int128 *, unsigned __int128, unsigned __int128,...); 349 unsigned __int128 __sync_val_compare_and_swap_16(volatile unsigned __int128 *, unsigned __int128, unsigned __int128,...); 224 350 #endif 225 351 forall(dtype T) T * __sync_val_compare_and_swap(T * volatile *, T *, T*,...); 226 352 227 353 char __sync_lock_test_and_set(volatile char *, char,...); 354 char __sync_lock_test_and_set_1(volatile char *, char,...); 228 355 signed char __sync_lock_test_and_set(volatile signed char *, signed char,...); 356 signed char __sync_lock_test_and_set_1(volatile signed char *, signed char,...); 229 357 unsigned char __sync_lock_test_and_set(volatile unsigned char *, unsigned char,...); 358 unsigned char __sync_lock_test_and_set_1(volatile unsigned char *, unsigned char,...); 230 359 signed short __sync_lock_test_and_set(volatile signed short *, signed short,...); 360 signed short __sync_lock_test_and_set_2(volatile signed short *, signed short,...); 231 361 unsigned short __sync_lock_test_and_set(volatile unsigned short *, unsigned short,...); 362 unsigned short __sync_lock_test_and_set_2(volatile unsigned short *, unsigned short,...); 232 363 signed int __sync_lock_test_and_set(volatile signed int *, signed int,...); 364 signed int __sync_lock_test_and_set_4(volatile signed int *, signed int,...); 233 365 unsigned int __sync_lock_test_and_set(volatile unsigned int *, unsigned int,...); 234 signed long int __sync_lock_test_and_set(volatile signed long int *, signed long int,...); 235 unsigned long int __sync_lock_test_and_set(volatile unsigned long int *, unsigned long int,...); 366 unsigned int __sync_lock_test_and_set_4(volatile unsigned int *, unsigned int,...); 236 367 signed long long int __sync_lock_test_and_set(volatile signed long long int *, signed long long int,...); 368 signed long long int __sync_lock_test_and_set_8(volatile signed long long int *, signed long long int,...); 237 369 unsigned long long int __sync_lock_test_and_set(volatile unsigned long long int *, unsigned long long int,...); 370 unsigned long long int __sync_lock_test_and_set_8(volatile unsigned long long int *, unsigned long long int,...); 238 371 #if defined(__SIZEOF_INT128__) 239 372 signed __int128 __sync_lock_test_and_set(volatile signed __int128 *, signed __int128,...); 373 signed __int128 __sync_lock_test_and_set_16(volatile signed __int128 *, signed __int128,...); 240 374 unsigned __int128 __sync_lock_test_and_set(volatile unsigned __int128 *, unsigned __int128,...); 375 unsigned __int128 __sync_lock_test_and_set_16(volatile unsigned __int128 *, unsigned __int128,...); 241 376 #endif 242 377 243 378 void __sync_lock_release(volatile char *,...); 379 void __sync_lock_release_1(volatile char *,...); 244 380 void __sync_lock_release(volatile signed char *,...); 381 void __sync_lock_release_1(volatile signed char *,...); 245 382 void __sync_lock_release(volatile unsigned char *,...); 383 void __sync_lock_release_1(volatile unsigned char *,...); 246 384 void __sync_lock_release(volatile signed short *,...); 385 void __sync_lock_release_2(volatile signed short *,...); 247 386 void __sync_lock_release(volatile unsigned short *,...); 387 void __sync_lock_release_2(volatile unsigned short *,...); 248 388 void __sync_lock_release(volatile signed int *,...); 389 void __sync_lock_release_4(volatile signed int *,...); 249 390 void __sync_lock_release(volatile unsigned int *,...); 250 void __sync_lock_release(volatile signed long int *,...); 251 void __sync_lock_release(volatile unsigned long int *,...); 391 void __sync_lock_release_4(volatile unsigned int *,...); 252 392 void __sync_lock_release(volatile signed long long int *,...); 393 void __sync_lock_release_8(volatile signed long long int *,...); 253 394 void __sync_lock_release(volatile unsigned long long int *,...); 395 void __sync_lock_release_8(volatile unsigned long long int *,...); 254 396 #if defined(__SIZEOF_INT128__) 255 397 void __sync_lock_release(volatile signed __int128 *,...); 398 void __sync_lock_release_16(volatile signed __int128 *,...); 256 399 void __sync_lock_release(volatile unsigned __int128 *,...); 400 void __sync_lock_release_16(volatile unsigned __int128 *,...); 257 401 #endif 258 402 … … 270 414 _Bool __atomic_test_and_set(volatile signed int *, int); 271 415 _Bool __atomic_test_and_set(volatile unsigned int *, int); 272 _Bool __atomic_test_and_set(volatile signed long int *, int);273 _Bool __atomic_test_and_set(volatile unsigned long int *, int);274 416 _Bool __atomic_test_and_set(volatile signed long long int *, int); 275 417 _Bool __atomic_test_and_set(volatile unsigned long long int *, int); … … 287 429 void __atomic_clear(volatile signed int *, int); 288 430 void __atomic_clear(volatile unsigned int *, int); 289 void __atomic_clear(volatile signed long int *, int);290 void __atomic_clear(volatile unsigned long int *, int);291 431 void __atomic_clear(volatile signed long long int *, int); 292 432 void __atomic_clear(volatile unsigned long long int *, int); … … 296 436 #endif 297 437 298 _Bool __atomic_exchange_n(volatile _Bool *, _Bool, int);299 void __atomic_exchange(volatile _Bool *, volatile _Bool *, volatile _Bool *, int);300 438 char __atomic_exchange_n(volatile char *, char, int); 439 char __atomic_exchange_1(volatile char *, char, int); 301 440 void __atomic_exchange(volatile char *, volatile char *, volatile char *, int); 302 441 signed char __atomic_exchange_n(volatile signed char *, signed char, int); 442 signed char __atomic_exchange_1(volatile signed char *, signed char, int); 303 443 void __atomic_exchange(volatile signed char *, volatile signed char *, volatile signed char *, int); 304 444 unsigned char __atomic_exchange_n(volatile unsigned char *, unsigned char, int); 445 unsigned char __atomic_exchange_1(volatile unsigned char *, unsigned char, int); 305 446 void __atomic_exchange(volatile unsigned char *, volatile unsigned char *, volatile unsigned char *, int); 306 447 signed short __atomic_exchange_n(volatile signed short *, signed short, int); 448 signed short __atomic_exchange_2(volatile signed short *, signed short, int); 307 449 void __atomic_exchange(volatile signed short *, volatile signed short *, volatile signed short *, int); 308 450 unsigned short __atomic_exchange_n(volatile unsigned short *, unsigned short, int); 451 unsigned short __atomic_exchange_2(volatile unsigned short *, unsigned short, int); 309 452 void __atomic_exchange(volatile unsigned short *, volatile unsigned short *, volatile unsigned short *, int); 310 453 signed int __atomic_exchange_n(volatile signed int *, signed int, int); 454 signed int __atomic_exchange_4(volatile signed int *, signed int, int); 311 455 void __atomic_exchange(volatile signed int *, volatile signed int *, volatile signed int *, int); 312 456 unsigned int __atomic_exchange_n(volatile unsigned int *, unsigned int, int); 457 unsigned int __atomic_exchange_4(volatile unsigned int *, unsigned int, int); 313 458 void __atomic_exchange(volatile unsigned int *, volatile unsigned int *, volatile unsigned int *, int); 314 signed long int __atomic_exchange_n(volatile signed long int *, signed long int, int);315 void __atomic_exchange(volatile signed long int *, volatile signed long int *, volatile signed long int *, int);316 unsigned long int __atomic_exchange_n(volatile unsigned long int *, unsigned long int, int);317 void __atomic_exchange(volatile unsigned long int *, volatile unsigned long int *, volatile unsigned long int *, int);318 459 signed long long int __atomic_exchange_n(volatile signed long long int *, signed long long int, int); 460 signed long long int __atomic_exchange_8(volatile signed long long int *, signed long long int, int); 319 461 void __atomic_exchange(volatile signed long long int *, volatile signed long long int *, volatile signed long long int *, int); 320 462 unsigned long long int __atomic_exchange_n(volatile unsigned long long int *, unsigned long long int, int); 463 unsigned long long int __atomic_exchange_8(volatile unsigned long long int *, unsigned long long int, int); 321 464 void __atomic_exchange(volatile unsigned long long int *, volatile unsigned long long int *, volatile unsigned long long int *, int); 322 465 #if defined(__SIZEOF_INT128__) 323 466 signed __int128 __atomic_exchange_n(volatile signed __int128 *, signed __int128, int); 467 signed __int128 __atomic_exchange_16(volatile signed __int128 *, signed __int128, int); 324 468 void __atomic_exchange(volatile signed __int128 *, volatile signed __int128 *, volatile signed __int128 *, int); 325 469 unsigned __int128 __atomic_exchange_n(volatile unsigned __int128 *, unsigned __int128, int); 470 unsigned __int128 __atomic_exchange_16(volatile unsigned __int128 *, unsigned __int128, int); 326 471 void __atomic_exchange(volatile unsigned __int128 *, volatile unsigned __int128 *, volatile unsigned __int128 *, int); 327 472 #endif … … 332 477 void __atomic_load(const volatile _Bool *, volatile _Bool *, int); 333 478 char __atomic_load_n(const volatile char *, int); 479 char __atomic_load_1(const volatile char *, int); 334 480 void __atomic_load(const volatile char *, volatile char *, int); 335 481 signed char __atomic_load_n(const volatile signed char *, int); 482 signed char __atomic_load_1(const volatile signed char *, int); 336 483 void __atomic_load(const volatile signed char *, volatile signed char *, int); 337 484 unsigned char __atomic_load_n(const volatile unsigned char *, int); 485 unsigned char __atomic_load_1(const volatile unsigned char *, int); 338 486 void __atomic_load(const volatile unsigned char *, volatile unsigned char *, int); 339 487 signed short __atomic_load_n(const volatile signed short *, int); 488 signed short __atomic_load_2(const volatile signed short *, int); 340 489 void __atomic_load(const volatile signed short *, volatile signed short *, int); 341 490 unsigned short __atomic_load_n(const volatile unsigned short *, int); 491 unsigned short __atomic_load_2(const volatile unsigned short *, int); 342 492 void __atomic_load(const volatile unsigned short *, volatile unsigned short *, int); 343 493 signed int __atomic_load_n(const volatile signed int *, int); 494 signed int __atomic_load_4(const volatile signed int *, int); 344 495 void __atomic_load(const volatile signed int *, volatile signed int *, int); 345 496 unsigned int __atomic_load_n(const volatile unsigned int *, int); 497 unsigned int __atomic_load_4(const volatile unsigned int *, int); 346 498 void __atomic_load(const volatile unsigned int *, volatile unsigned int *, int); 347 signed long int __atomic_load_n(const volatile signed long int *, int);348 void __atomic_load(const volatile signed long int *, volatile signed long int *, int);349 unsigned long int __atomic_load_n(const volatile unsigned long int *, int);350 void __atomic_load(const volatile unsigned long int *, volatile unsigned long int *, int);351 499 signed long long int __atomic_load_n(const volatile signed long long int *, int); 500 signed long long int __atomic_load_8(const volatile signed long long int *, int); 352 501 void __atomic_load(const volatile signed long long int *, volatile signed long long int *, int); 353 502 unsigned long long int __atomic_load_n(const volatile unsigned long long int *, int); 503 unsigned long long int __atomic_load_8(const volatile unsigned long long int *, int); 354 504 void __atomic_load(const volatile unsigned long long int *, volatile unsigned long long int *, int); 355 505 #if defined(__SIZEOF_INT128__) 356 506 signed __int128 __atomic_load_n(const volatile signed __int128 *, int); 507 signed __int128 __atomic_load_16(const volatile signed __int128 *, int); 357 508 void __atomic_load(const volatile signed __int128 *, volatile signed __int128 *, int); 358 509 unsigned __int128 __atomic_load_n(const volatile unsigned __int128 *, int); 510 unsigned __int128 __atomic_load_16(const volatile unsigned __int128 *, int); 359 511 void __atomic_load(const volatile unsigned __int128 *, volatile unsigned __int128 *, int); 360 512 #endif … … 363 515 364 516 _Bool __atomic_compare_exchange_n(volatile char *, char *, char, _Bool, int, int); 517 _Bool __atomic_compare_exchange_1(volatile char *, char *, char, _Bool, int, int); 365 518 _Bool __atomic_compare_exchange (volatile char *, char *, char *, _Bool, int, int); 366 519 _Bool __atomic_compare_exchange_n(volatile signed char *, signed char *, signed char, _Bool, int, int); 520 _Bool __atomic_compare_exchange_1(volatile signed char *, signed char *, signed char, _Bool, int, int); 367 521 _Bool __atomic_compare_exchange (volatile signed char *, signed char *, signed char *, _Bool, int, int); 368 522 _Bool __atomic_compare_exchange_n(volatile unsigned char *, unsigned char *, unsigned char, _Bool, int, int); 523 _Bool __atomic_compare_exchange_1(volatile unsigned char *, unsigned char *, unsigned char, _Bool, int, int); 369 524 _Bool __atomic_compare_exchange (volatile unsigned char *, unsigned char *, unsigned char *, _Bool, int, int); 370 525 _Bool __atomic_compare_exchange_n(volatile signed short *, signed short *, signed short, _Bool, int, int); 526 _Bool __atomic_compare_exchange_2(volatile signed short *, signed short *, signed short, _Bool, int, int); 371 527 _Bool __atomic_compare_exchange (volatile signed short *, signed short *, signed short *, _Bool, int, int); 372 528 _Bool __atomic_compare_exchange_n(volatile unsigned short *, unsigned short *, unsigned short, _Bool, int, int); 529 _Bool __atomic_compare_exchange_2(volatile unsigned short *, unsigned short *, unsigned short, _Bool, int, int); 373 530 _Bool __atomic_compare_exchange (volatile unsigned short *, unsigned short *, unsigned short *, _Bool, int, int); 374 531 _Bool __atomic_compare_exchange_n(volatile signed int *, signed int *, signed int, _Bool, int, int); 532 _Bool __atomic_compare_exchange_4(volatile signed int *, signed int *, signed int, _Bool, int, int); 375 533 _Bool __atomic_compare_exchange (volatile signed int *, signed int *, signed int *, _Bool, int, int); 376 534 _Bool __atomic_compare_exchange_n(volatile unsigned int *, unsigned int *, unsigned int, _Bool, int, int); 535 _Bool __atomic_compare_exchange_4(volatile unsigned int *, unsigned int *, unsigned int, _Bool, int, int); 377 536 _Bool __atomic_compare_exchange (volatile unsigned int *, unsigned int *, unsigned int *, _Bool, int, int); 378 _Bool __atomic_compare_exchange_n(volatile signed long int *, signed long int *, signed long int, _Bool, int, int);379 _Bool __atomic_compare_exchange (volatile signed long int *, signed long int *, signed long int *, _Bool, int, int);380 _Bool __atomic_compare_exchange_n(volatile unsigned long int *, unsigned long int *, unsigned long int, _Bool, int, int);381 _Bool __atomic_compare_exchange (volatile unsigned long int *, unsigned long int *, unsigned long int *, _Bool, int, int);382 537 _Bool __atomic_compare_exchange_n(volatile signed long long int *, signed long long int *, signed long long int, _Bool, int, int); 538 _Bool __atomic_compare_exchange_8(volatile signed long long int *, signed long long int *, signed long long int, _Bool, int, int); 383 539 _Bool __atomic_compare_exchange (volatile signed long long int *, signed long long int *, signed long long int *, _Bool, int, int); 384 540 _Bool __atomic_compare_exchange_n(volatile unsigned long long int *, unsigned long long int *, unsigned long long int, _Bool, int, int); 541 _Bool __atomic_compare_exchange_8(volatile unsigned long long int *, unsigned long long int *, unsigned long long int, _Bool, int, int); 385 542 _Bool __atomic_compare_exchange (volatile unsigned long long int *, unsigned long long int *, unsigned long long int *, _Bool, int, int); 386 543 #if defined(__SIZEOF_INT128__) 387 544 _Bool __atomic_compare_exchange_n (volatile signed __int128 *, signed __int128 *, signed __int128, _Bool, int, int); 545 _Bool __atomic_compare_exchange_16(volatile signed __int128 *, signed __int128 *, signed __int128, _Bool, int, int); 388 546 _Bool __atomic_compare_exchange (volatile signed __int128 *, signed __int128 *, signed __int128 *, _Bool, int, int); 389 547 _Bool __atomic_compare_exchange_n (volatile unsigned __int128 *, unsigned __int128 *, unsigned __int128, _Bool, int, int); 548 _Bool __atomic_compare_exchange_16(volatile unsigned __int128 *, unsigned __int128 *, unsigned __int128, _Bool, int, int); 390 549 _Bool __atomic_compare_exchange (volatile unsigned __int128 *, unsigned __int128 *, unsigned __int128 *, _Bool, int, int); 391 550 #endif … … 396 555 void __atomic_store(volatile _Bool *, _Bool *, int); 397 556 void __atomic_store_n(volatile char *, char, int); 557 void __atomic_store_1(volatile char *, char, int); 398 558 void __atomic_store(volatile char *, char *, int); 399 559 void __atomic_store_n(volatile signed char *, signed char, int); 560 void __atomic_store_1(volatile signed char *, signed char, int); 400 561 void __atomic_store(volatile signed char *, signed char *, int); 401 562 void __atomic_store_n(volatile unsigned char *, unsigned char, int); 563 void __atomic_store_1(volatile unsigned char *, unsigned char, int); 402 564 void __atomic_store(volatile unsigned char *, unsigned char *, int); 403 565 void __atomic_store_n(volatile signed short *, signed short, int); 566 void __atomic_store_2(volatile signed short *, signed short, int); 404 567 void __atomic_store(volatile signed short *, signed short *, int); 405 568 void __atomic_store_n(volatile unsigned short *, unsigned short, int); 569 void __atomic_store_2(volatile unsigned short *, unsigned short, int); 406 570 void __atomic_store(volatile unsigned short *, unsigned short *, int); 407 571 void __atomic_store_n(volatile signed int *, signed int, int); 572 void __atomic_store_4(volatile signed int *, signed int, int); 408 573 void __atomic_store(volatile signed int *, signed int *, int); 409 574 void __atomic_store_n(volatile unsigned int *, unsigned int, int); 575 void __atomic_store_4(volatile unsigned int *, unsigned int, int); 410 576 void __atomic_store(volatile unsigned int *, unsigned int *, int); 411 void __atomic_store_n(volatile signed long int *, signed long int, int);412 void __atomic_store(volatile signed long int *, signed long int *, int);413 void __atomic_store_n(volatile unsigned long int *, unsigned long int, int);414 void __atomic_store(volatile unsigned long int *, unsigned long int *, int);415 577 void __atomic_store_n(volatile signed long long int *, signed long long int, int); 578 void __atomic_store_8(volatile signed long long int *, signed long long int, int); 416 579 void __atomic_store(volatile signed long long int *, signed long long int *, int); 417 580 void __atomic_store_n(volatile unsigned long long int *, unsigned long long int, int); 581 void __atomic_store_8(volatile unsigned long long int *, unsigned long long int, int); 418 582 void __atomic_store(volatile unsigned long long int *, unsigned long long int *, int); 419 583 #if defined(__SIZEOF_INT128__) 420 584 void __atomic_store_n(volatile signed __int128 *, signed __int128, int); 585 void __atomic_store_16(volatile signed __int128 *, signed __int128, int); 421 586 void __atomic_store(volatile signed __int128 *, signed __int128 *, int); 422 587 void __atomic_store_n(volatile unsigned __int128 *, unsigned __int128, int); 588 void __atomic_store_16(volatile unsigned __int128 *, unsigned __int128, int); 423 589 void __atomic_store(volatile unsigned __int128 *, unsigned __int128 *, int); 424 590 #endif … … 427 593 428 594 char __atomic_add_fetch (volatile char *, char, int); 595 char __atomic_add_fetch_1(volatile char *, char, int); 429 596 signed char __atomic_add_fetch (volatile signed char *, signed char, int); 597 signed char __atomic_add_fetch_1(volatile signed char *, signed char, int); 430 598 unsigned char __atomic_add_fetch (volatile unsigned char *, unsigned char, int); 599 unsigned char __atomic_add_fetch_1(volatile unsigned char *, unsigned char, int); 431 600 signed short __atomic_add_fetch (volatile signed short *, signed short, int); 601 signed short __atomic_add_fetch_2(volatile signed short *, signed short, int); 432 602 unsigned short __atomic_add_fetch (volatile unsigned short *, unsigned short, int); 603 unsigned short __atomic_add_fetch_2(volatile unsigned short *, unsigned short, int); 433 604 signed int __atomic_add_fetch (volatile signed int *, signed int, int); 605 signed int __atomic_add_fetch_4(volatile signed int *, signed int, int); 434 606 unsigned int __atomic_add_fetch (volatile unsigned int *, unsigned int, int); 435 signed long int __atomic_add_fetch (volatile signed long int *, signed long int, int); 436 unsigned long int __atomic_add_fetch (volatile unsigned long int *, unsigned long int, int); 607 unsigned int __atomic_add_fetch_4(volatile unsigned int *, unsigned int, int); 437 608 signed long long int __atomic_add_fetch (volatile signed long long int *, signed long long int, int); 609 signed long long int __atomic_add_fetch_8(volatile signed long long int *, signed long long int, int); 438 610 unsigned long long int __atomic_add_fetch (volatile unsigned long long int *, unsigned long long int, int); 611 unsigned long long int __atomic_add_fetch_8(volatile unsigned long long int *, unsigned long long int, int); 439 612 #if defined(__SIZEOF_INT128__) 440 613 signed __int128 __atomic_add_fetch (volatile signed __int128 *, signed __int128, int); 614 signed __int128 __atomic_add_fetch_16(volatile signed __int128 *, signed __int128, int); 441 615 unsigned __int128 __atomic_add_fetch (volatile unsigned __int128 *, unsigned __int128, int); 616 unsigned __int128 __atomic_add_fetch_16(volatile unsigned __int128 *, unsigned __int128, int); 442 617 #endif 443 618 444 619 char __atomic_sub_fetch (volatile char *, char, int); 620 char __atomic_sub_fetch_1(volatile char *, char, int); 445 621 signed char __atomic_sub_fetch (volatile signed char *, signed char, int); 622 signed char __atomic_sub_fetch_1(volatile signed char *, signed char, int); 446 623 unsigned char __atomic_sub_fetch (volatile unsigned char *, unsigned char, int); 624 unsigned char __atomic_sub_fetch_1(volatile unsigned char *, unsigned char, int); 447 625 signed short __atomic_sub_fetch (volatile signed short *, signed short, int); 626 signed short __atomic_sub_fetch_2(volatile signed short *, signed short, int); 448 627 unsigned short __atomic_sub_fetch (volatile unsigned short *, unsigned short, int); 628 unsigned short __atomic_sub_fetch_2(volatile unsigned short *, unsigned short, int); 449 629 signed int __atomic_sub_fetch (volatile signed int *, signed int, int); 630 signed int __atomic_sub_fetch_4(volatile signed int *, signed int, int); 450 631 unsigned int __atomic_sub_fetch (volatile unsigned int *, unsigned int, int); 451 signed long long int __atomic_sub_fetch (volatile signed long int *, signed long int, int); 452 unsigned long long int __atomic_sub_fetch (volatile unsigned long int *, unsigned long int, int); 632 unsigned int __atomic_sub_fetch_4(volatile unsigned int *, unsigned int, int); 453 633 signed long long int __atomic_sub_fetch (volatile signed long long int *, signed long long int, int); 634 signed long long int __atomic_sub_fetch_8(volatile signed long long int *, signed long long int, int); 454 635 unsigned long long int __atomic_sub_fetch (volatile unsigned long long int *, unsigned long long int, int); 636 unsigned long long int __atomic_sub_fetch_8(volatile unsigned long long int *, unsigned long long int, int); 455 637 #if defined(__SIZEOF_INT128__) 456 638 signed __int128 __atomic_sub_fetch (volatile signed __int128 *, signed __int128, int); 639 signed __int128 __atomic_sub_fetch_16(volatile signed __int128 *, signed __int128, int); 457 640 unsigned __int128 __atomic_sub_fetch (volatile unsigned __int128 *, unsigned __int128, int); 641 unsigned __int128 __atomic_sub_fetch_16(volatile unsigned __int128 *, unsigned __int128, int); 458 642 #endif 459 643 460 644 char __atomic_and_fetch (volatile char *, char, int); 645 char __atomic_and_fetch_1(volatile char *, char, int); 461 646 signed char __atomic_and_fetch (volatile signed char *, signed char, int); 647 signed char __atomic_and_fetch_1(volatile signed char *, signed char, int); 462 648 unsigned char __atomic_and_fetch (volatile unsigned char *, unsigned char, int); 649 unsigned char __atomic_and_fetch_1(volatile unsigned char *, unsigned char, int); 463 650 signed short __atomic_and_fetch (volatile signed short *, signed short, int); 651 signed short __atomic_and_fetch_2(volatile signed short *, signed short, int); 464 652 unsigned short __atomic_and_fetch (volatile unsigned short *, unsigned short, int); 653 unsigned short __atomic_and_fetch_2(volatile unsigned short *, unsigned short, int); 465 654 signed int __atomic_and_fetch (volatile signed int *, signed int, int); 655 signed int __atomic_and_fetch_4(volatile signed int *, signed int, int); 466 656 unsigned int __atomic_and_fetch (volatile unsigned int *, unsigned int, int); 467 signed long int __atomic_and_fetch (volatile signed long int *, signed long int, int); 468 unsigned long int __atomic_and_fetch (volatile unsigned long int *, unsigned long int, int); 657 unsigned int __atomic_and_fetch_4(volatile unsigned int *, unsigned int, int); 469 658 signed long long int __atomic_and_fetch (volatile signed long long int *, signed long long int, int); 659 signed long long int __atomic_and_fetch_8(volatile signed long long int *, signed long long int, int); 470 660 unsigned long long int __atomic_and_fetch (volatile unsigned long long int *, unsigned long long int, int); 661 unsigned long long int __atomic_and_fetch_8(volatile unsigned long long int *, unsigned long long int, int); 471 662 #if defined(__SIZEOF_INT128__) 472 663 signed __int128 __atomic_and_fetch (volatile signed __int128 *, signed __int128, int); 664 signed __int128 __atomic_and_fetch_16(volatile signed __int128 *, signed __int128, int); 473 665 unsigned __int128 __atomic_and_fetch (volatile unsigned __int128 *, unsigned __int128, int); 666 unsigned __int128 __atomic_and_fetch_16(volatile unsigned __int128 *, unsigned __int128, int); 474 667 #endif 475 668 476 669 char __atomic_nand_fetch (volatile char *, char, int); 670 char __atomic_nand_fetch_1(volatile char *, char, int); 477 671 signed char __atomic_nand_fetch (volatile signed char *, signed char, int); 672 signed char __atomic_nand_fetch_1(volatile signed char *, signed char, int); 478 673 unsigned char __atomic_nand_fetch (volatile unsigned char *, unsigned char, int); 674 unsigned char __atomic_nand_fetch_1(volatile unsigned char *, unsigned char, int); 479 675 signed short __atomic_nand_fetch (volatile signed short *, signed short, int); 676 signed short __atomic_nand_fetch_2(volatile signed short *, signed short, int); 480 677 unsigned short __atomic_nand_fetch (volatile unsigned short *, unsigned short, int); 678 unsigned short __atomic_nand_fetch_2(volatile unsigned short *, unsigned short, int); 481 679 signed int __atomic_nand_fetch (volatile signed int *, signed int, int); 680 signed int __atomic_nand_fetch_4(volatile signed int *, signed int, int); 482 681 unsigned int __atomic_nand_fetch (volatile unsigned int *, unsigned int, int); 483 signed long int __atomic_nand_fetch (volatile signed long int *, signed long int, int); 484 unsigned long int __atomic_nand_fetch (volatile unsigned long int *, unsigned long int, int); 682 unsigned int __atomic_nand_fetch_4(volatile unsigned int *, unsigned int, int); 485 683 signed long long int __atomic_nand_fetch (volatile signed long long int *, signed long long int, int); 684 signed long long int __atomic_nand_fetch_8(volatile signed long long int *, signed long long int, int); 486 685 unsigned long long int __atomic_nand_fetch (volatile unsigned long long int *, unsigned long long int, int); 686 unsigned long long int __atomic_nand_fetch_8(volatile unsigned long long int *, unsigned long long int, int); 487 687 #if defined(__SIZEOF_INT128__) 488 688 signed __int128 __atomic_nand_fetch (volatile signed __int128 *, signed __int128, int); 689 signed __int128 __atomic_nand_fetch_16(volatile signed __int128 *, signed __int128, int); 489 690 unsigned __int128 __atomic_nand_fetch (volatile unsigned __int128 *, unsigned __int128, int); 691 unsigned __int128 __atomic_nand_fetch_16(volatile unsigned __int128 *, unsigned __int128, int); 490 692 #endif 491 693 492 694 char __atomic_xor_fetch (volatile char *, char, int); 695 char __atomic_xor_fetch_1(volatile char *, char, int); 493 696 signed char __atomic_xor_fetch (volatile signed char *, signed char, int); 697 signed char __atomic_xor_fetch_1(volatile signed char *, signed char, int); 494 698 unsigned char __atomic_xor_fetch (volatile unsigned char *, unsigned char, int); 699 unsigned char __atomic_xor_fetch_1(volatile unsigned char *, unsigned char, int); 495 700 signed short __atomic_xor_fetch (volatile signed short *, signed short, int); 701 signed short __atomic_xor_fetch_2(volatile signed short *, signed short, int); 496 702 unsigned short __atomic_xor_fetch (volatile unsigned short *, unsigned short, int); 703 unsigned short __atomic_xor_fetch_2(volatile unsigned short *, unsigned short, int); 497 704 signed int __atomic_xor_fetch (volatile signed int *, signed int, int); 705 signed int __atomic_xor_fetch_4(volatile signed int *, signed int, int); 498 706 unsigned int __atomic_xor_fetch (volatile unsigned int *, unsigned int, int); 499 signed long int __atomic_xor_fetch (volatile signed long int *, signed long int, int); 500 unsigned long int __atomic_xor_fetch (volatile unsigned long int *, unsigned long int, int); 707 unsigned int __atomic_xor_fetch_4(volatile unsigned int *, unsigned int, int); 501 708 signed long long int __atomic_xor_fetch (volatile signed long long int *, signed long long int, int); 709 signed long long int __atomic_xor_fetch_8(volatile signed long long int *, signed long long int, int); 502 710 unsigned long long int __atomic_xor_fetch (volatile unsigned long long int *, unsigned long long int, int); 711 unsigned long long int __atomic_xor_fetch_8(volatile unsigned long long int *, unsigned long long int, int); 503 712 #if defined(__SIZEOF_INT128__) 504 713 signed __int128 __atomic_xor_fetch (volatile signed __int128 *, signed __int128, int); 714 signed __int128 __atomic_xor_fetch_16(volatile signed __int128 *, signed __int128, int); 505 715 unsigned __int128 __atomic_xor_fetch (volatile unsigned __int128 *, unsigned __int128, int); 716 unsigned __int128 __atomic_xor_fetch_16(volatile unsigned __int128 *, unsigned __int128, int); 506 717 #endif 507 718 508 719 char __atomic_or_fetch (volatile char *, char, int); 720 char __atomic_or_fetch_1(volatile char *, char, int); 509 721 signed char __atomic_or_fetch (volatile signed char *, signed char, int); 722 signed char __atomic_or_fetch_1(volatile signed char *, signed char, int); 510 723 unsigned char __atomic_or_fetch (volatile unsigned char *, unsigned char, int); 724 unsigned char __atomic_or_fetch_1(volatile unsigned char *, unsigned char, int); 511 725 signed short __atomic_or_fetch (volatile signed short *, signed short, int); 726 signed short __atomic_or_fetch_2(volatile signed short *, signed short, int); 512 727 unsigned short __atomic_or_fetch (volatile unsigned short *, unsigned short, int); 728 unsigned short __atomic_or_fetch_2(volatile unsigned short *, unsigned short, int); 513 729 signed int __atomic_or_fetch (volatile signed int *, signed int, int); 730 signed int __atomic_or_fetch_4(volatile signed int *, signed int, int); 514 731 unsigned int __atomic_or_fetch (volatile unsigned int *, unsigned int, int); 515 signed long int __atomic_or_fetch (volatile signed long int *, signed long int, int); 516 unsigned long int __atomic_or_fetch (volatile unsigned long int *, unsigned long int, int); 732 unsigned int __atomic_or_fetch_4(volatile unsigned int *, unsigned int, int); 517 733 signed long long int __atomic_or_fetch (volatile signed long long int *, signed long long int, int); 734 signed long long int __atomic_or_fetch_8(volatile signed long long int *, signed long long int, int); 518 735 unsigned long long int __atomic_or_fetch (volatile unsigned long long int *, unsigned long long int, int); 736 unsigned long long int __atomic_or_fetch_8(volatile unsigned long long int *, unsigned long long int, int); 519 737 #if defined(__SIZEOF_INT128__) 520 738 signed __int128 __atomic_or_fetch (volatile signed __int128 *, signed __int128, int); 739 signed __int128 __atomic_or_fetch_16(volatile signed __int128 *, signed __int128, int); 521 740 unsigned __int128 __atomic_or_fetch (volatile unsigned __int128 *, unsigned __int128, int); 741 unsigned __int128 __atomic_or_fetch_16(volatile unsigned __int128 *, unsigned __int128, int); 522 742 #endif 523 743 524 744 char __atomic_fetch_add (volatile char *, char, int); 745 char __atomic_fetch_add_1(volatile char *, char, int); 525 746 signed char __atomic_fetch_add (volatile signed char *, signed char, int); 747 signed char __atomic_fetch_add_1(volatile signed char *, signed char, int); 526 748 unsigned char __atomic_fetch_add (volatile unsigned char *, unsigned char, int); 749 unsigned char __atomic_fetch_add_1(volatile unsigned char *, unsigned char, int); 527 750 signed short __atomic_fetch_add (volatile signed short *, signed short, int); 751 signed short __atomic_fetch_add_2(volatile signed short *, signed short, int); 528 752 unsigned short __atomic_fetch_add (volatile unsigned short *, unsigned short, int); 753 unsigned short __atomic_fetch_add_2(volatile unsigned short *, unsigned short, int); 529 754 signed int __atomic_fetch_add (volatile signed int *, signed int, int); 755 signed int __atomic_fetch_add_4(volatile signed int *, signed int, int); 530 756 unsigned int __atomic_fetch_add (volatile unsigned int *, unsigned int, int); 531 signed long int __atomic_fetch_add (volatile signed long int *, signed long int, int); 532 unsigned long int __atomic_fetch_add (volatile unsigned long int *, unsigned long int, int); 757 unsigned int __atomic_fetch_add_4(volatile unsigned int *, unsigned int, int); 533 758 signed long long int __atomic_fetch_add (volatile signed long long int *, signed long long int, int); 759 signed long long int __atomic_fetch_add_8(volatile signed long long int *, signed long long int, int); 534 760 unsigned long long int __atomic_fetch_add (volatile unsigned long long int *, unsigned long long int, int); 761 unsigned long long int __atomic_fetch_add_8(volatile unsigned long long int *, unsigned long long int, int); 535 762 #if defined(__SIZEOF_INT128__) 536 763 signed __int128 __atomic_fetch_add (volatile signed __int128 *, signed __int128, int); 764 signed __int128 __atomic_fetch_add_16(volatile signed __int128 *, signed __int128, int); 537 765 unsigned __int128 __atomic_fetch_add (volatile unsigned __int128 *, unsigned __int128, int); 766 unsigned __int128 __atomic_fetch_add_16(volatile unsigned __int128 *, unsigned __int128, int); 538 767 #endif 539 768 540 769 char __atomic_fetch_sub (volatile char *, char, int); 770 char __atomic_fetch_sub_1(volatile char *, char, int); 541 771 signed char __atomic_fetch_sub (volatile signed char *, signed char, int); 772 signed char __atomic_fetch_sub_1(volatile signed char *, signed char, int); 542 773 unsigned char __atomic_fetch_sub (volatile unsigned char *, unsigned char, int); 774 unsigned char __atomic_fetch_sub_1(volatile unsigned char *, unsigned char, int); 543 775 signed short __atomic_fetch_sub (volatile signed short *, signed short, int); 776 signed short __atomic_fetch_sub_2(volatile signed short *, signed short, int); 544 777 unsigned short __atomic_fetch_sub (volatile unsigned short *, unsigned short, int); 778 unsigned short __atomic_fetch_sub_2(volatile unsigned short *, unsigned short, int); 545 779 signed int __atomic_fetch_sub (volatile signed int *, signed int, int); 780 signed int __atomic_fetch_sub_4(volatile signed int *, signed int, int); 546 781 unsigned int __atomic_fetch_sub (volatile unsigned int *, unsigned int, int); 547 signed long int __atomic_fetch_sub (volatile signed long int *, signed long int, int); 548 unsigned long int __atomic_fetch_sub (volatile unsigned long int *, unsigned long int, int); 782 unsigned int __atomic_fetch_sub_4(volatile unsigned int *, unsigned int, int); 549 783 signed long long int __atomic_fetch_sub (volatile signed long long int *, signed long long int, int); 784 signed long long int __atomic_fetch_sub_8(volatile signed long long int *, signed long long int, int); 550 785 unsigned long long int __atomic_fetch_sub (volatile unsigned long long int *, unsigned long long int, int); 786 unsigned long long int __atomic_fetch_sub_8(volatile unsigned long long int *, unsigned long long int, int); 551 787 #if defined(__SIZEOF_INT128__) 552 788 signed __int128 __atomic_fetch_sub (volatile signed __int128 *, signed __int128, int); 789 signed __int128 __atomic_fetch_sub_16(volatile signed __int128 *, signed __int128, int); 553 790 unsigned __int128 __atomic_fetch_sub (volatile unsigned __int128 *, unsigned __int128, int); 791 unsigned __int128 __atomic_fetch_sub_16(volatile unsigned __int128 *, unsigned __int128, int); 554 792 #endif 555 793 556 794 char __atomic_fetch_and (volatile char *, char, int); 795 char __atomic_fetch_and_1(volatile char *, char, int); 557 796 signed char __atomic_fetch_and (volatile signed char *, signed char, int); 797 signed char __atomic_fetch_and_1(volatile signed char *, signed char, int); 558 798 unsigned char __atomic_fetch_and (volatile unsigned char *, unsigned char, int); 799 unsigned char __atomic_fetch_and_1(volatile unsigned char *, unsigned char, int); 559 800 signed short __atomic_fetch_and (volatile signed short *, signed short, int); 801 signed short __atomic_fetch_and_2(volatile signed short *, signed short, int); 560 802 unsigned short __atomic_fetch_and (volatile unsigned short *, unsigned short, int); 803 unsigned short __atomic_fetch_and_2(volatile unsigned short *, unsigned short, int); 561 804 signed int __atomic_fetch_and (volatile signed int *, signed int, int); 805 signed int __atomic_fetch_and_4(volatile signed int *, signed int, int); 562 806 unsigned int __atomic_fetch_and (volatile unsigned int *, unsigned int, int); 563 signed long int __atomic_fetch_and (volatile signed long int *, signed long int, int); 564 unsigned long int __atomic_fetch_and (volatile unsigned long int *, unsigned long int, int); 807 unsigned int __atomic_fetch_and_4(volatile unsigned int *, unsigned int, int); 565 808 signed long long int __atomic_fetch_and (volatile signed long long int *, signed long long int, int); 809 signed long long int __atomic_fetch_and_8(volatile signed long long int *, signed long long int, int); 566 810 unsigned long long int __atomic_fetch_and (volatile unsigned long long int *, unsigned long long int, int); 811 unsigned long long int __atomic_fetch_and_8(volatile unsigned long long int *, unsigned long long int, int); 567 812 #if defined(__SIZEOF_INT128__) 568 813 signed __int128 __atomic_fetch_and (volatile signed __int128 *, signed __int128, int); 814 signed __int128 __atomic_fetch_and_16(volatile signed __int128 *, signed __int128, int); 569 815 unsigned __int128 __atomic_fetch_and (volatile unsigned __int128 *, unsigned __int128, int); 816 unsigned __int128 __atomic_fetch_and_16(volatile unsigned __int128 *, unsigned __int128, int); 570 817 #endif 571 818 572 819 char __atomic_fetch_nand (volatile char *, char, int); 820 char __atomic_fetch_nand_1(volatile char *, char, int); 573 821 signed char __atomic_fetch_nand (volatile signed char *, signed char, int); 822 signed char __atomic_fetch_nand_1(volatile signed char *, signed char, int); 574 823 unsigned char __atomic_fetch_nand (volatile unsigned char *, unsigned char, int); 824 unsigned char __atomic_fetch_nand_1(volatile unsigned char *, unsigned char, int); 575 825 signed short __atomic_fetch_nand (volatile signed short *, signed short, int); 826 signed short __atomic_fetch_nand_2(volatile signed short *, signed short, int); 576 827 unsigned short __atomic_fetch_nand (volatile unsigned short *, unsigned short, int); 828 unsigned short __atomic_fetch_nand_2(volatile unsigned short *, unsigned short, int); 577 829 signed int __atomic_fetch_nand (volatile signed int *, signed int, int); 830 signed int __atomic_fetch_nand_4(volatile signed int *, signed int, int); 578 831 unsigned int __atomic_fetch_nand (volatile unsigned int *, unsigned int, int); 579 signed long int __atomic_fetch_nand (volatile signed long int *, signed long int, int); 580 unsigned long int __atomic_fetch_nand (volatile unsigned long int *, unsigned long int, int); 832 unsigned int __atomic_fetch_nand_4(volatile unsigned int *, unsigned int, int); 581 833 signed long long int __atomic_fetch_nand (volatile signed long long int *, signed long long int, int); 834 signed long long int __atomic_fetch_nand_8(volatile signed long long int *, signed long long int, int); 582 835 unsigned long long int __atomic_fetch_nand (volatile unsigned long long int *, unsigned long long int, int); 836 unsigned long long int __atomic_fetch_nand_8(volatile unsigned long long int *, unsigned long long int, int); 583 837 #if defined(__SIZEOF_INT128__) 584 838 signed __int128 __atomic_fetch_nand (volatile signed __int128 *, signed __int128, int); 839 signed __int128 __atomic_fetch_nand_16(volatile signed __int128 *, signed __int128, int); 585 840 unsigned __int128 __atomic_fetch_nand (volatile unsigned __int128 *, unsigned __int128, int); 841 unsigned __int128 __atomic_fetch_nand_16(volatile unsigned __int128 *, unsigned __int128, int); 586 842 #endif 587 843 588 844 char __atomic_fetch_xor (volatile char *, char, int); 845 char __atomic_fetch_xor_1(volatile char *, char, int); 589 846 signed char __atomic_fetch_xor (volatile signed char *, signed char, int); 847 signed char __atomic_fetch_xor_1(volatile signed char *, signed char, int); 590 848 unsigned char __atomic_fetch_xor (volatile unsigned char *, unsigned char, int); 849 unsigned char __atomic_fetch_xor_1(volatile unsigned char *, unsigned char, int); 591 850 signed short __atomic_fetch_xor (volatile signed short *, signed short, int); 851 signed short __atomic_fetch_xor_2(volatile signed short *, signed short, int); 592 852 unsigned short __atomic_fetch_xor (volatile unsigned short *, unsigned short, int); 853 unsigned short __atomic_fetch_xor_2(volatile unsigned short *, unsigned short, int); 593 854 signed int __atomic_fetch_xor (volatile signed int *, signed int, int); 855 signed int __atomic_fetch_xor_4(volatile signed int *, signed int, int); 594 856 unsigned int __atomic_fetch_xor (volatile unsigned int *, unsigned int, int); 595 signed long int __atomic_fetch_xor (volatile signed long int *, signed long int, int); 596 unsigned long int __atomic_fetch_xor (volatile unsigned long int *, unsigned long int, int); 857 unsigned int __atomic_fetch_xor_4(volatile unsigned int *, unsigned int, int); 597 858 signed long long int __atomic_fetch_xor (volatile signed long long int *, signed long long int, int); 859 signed long long int __atomic_fetch_xor_8(volatile signed long long int *, signed long long int, int); 598 860 unsigned long long int __atomic_fetch_xor (volatile unsigned long long int *, unsigned long long int, int); 861 unsigned long long int __atomic_fetch_xor_8(volatile unsigned long long int *, unsigned long long int, int); 599 862 #if defined(__SIZEOF_INT128__) 600 863 signed __int128 __atomic_fetch_xor (volatile signed __int128 *, signed __int128, int); 864 signed __int128 __atomic_fetch_xor_16(volatile signed __int128 *, signed __int128, int); 601 865 unsigned __int128 __atomic_fetch_xor (volatile unsigned __int128 *, unsigned __int128, int); 866 unsigned __int128 __atomic_fetch_xor_16(volatile unsigned __int128 *, unsigned __int128, int); 602 867 #endif 603 868 604 869 char __atomic_fetch_or (volatile char *, char, int); 870 char __atomic_fetch_or_1(volatile char *, char, int); 605 871 signed char __atomic_fetch_or (volatile signed char *, signed char, int); 872 signed char __atomic_fetch_or_1(volatile signed char *, signed char, int); 606 873 unsigned char __atomic_fetch_or (volatile unsigned char *, unsigned char, int); 874 unsigned char __atomic_fetch_or_1(volatile unsigned char *, unsigned char, int); 607 875 signed short __atomic_fetch_or (volatile signed short *, signed short, int); 876 signed short __atomic_fetch_or_2(volatile signed short *, signed short, int); 608 877 unsigned short __atomic_fetch_or (volatile unsigned short *, unsigned short, int); 878 unsigned short __atomic_fetch_or_2(volatile unsigned short *, unsigned short, int); 609 879 signed int __atomic_fetch_or (volatile signed int *, signed int, int); 880 signed int __atomic_fetch_or_4(volatile signed int *, signed int, int); 610 881 unsigned int __atomic_fetch_or (volatile unsigned int *, unsigned int, int); 611 signed long int __atomic_fetch_or (volatile signed long int *, signed long int, int); 612 unsigned long int __atomic_fetch_or (volatile unsigned long int *, unsigned long int, int); 882 unsigned int __atomic_fetch_or_4(volatile unsigned int *, unsigned int, int); 613 883 signed long long int __atomic_fetch_or (volatile signed long long int *, signed long long int, int); 884 signed long long int __atomic_fetch_or_8(volatile signed long long int *, signed long long int, int); 614 885 unsigned long long int __atomic_fetch_or (volatile unsigned long long int *, unsigned long long int, int); 886 unsigned long long int __atomic_fetch_or_8(volatile unsigned long long int *, unsigned long long int, int); 615 887 #if defined(__SIZEOF_INT128__) 616 888 signed __int128 __atomic_fetch_or (volatile signed __int128 *, signed __int128, int); 889 signed __int128 __atomic_fetch_or_16(volatile signed __int128 *, signed __int128, int); 617 890 unsigned __int128 __atomic_fetch_or (volatile unsigned __int128 *, unsigned __int128, int); 891 unsigned __int128 __atomic_fetch_or_16(volatile unsigned __int128 *, unsigned __int128, int); 618 892 #endif 619 893 -
libcfa/src/Makefile.am
r3d5701e r9fb8f01 32 32 # use -no-include-stdhdr to prevent rebuild cycles 33 33 # The built sources must not depend on the installed headers 34 AM_CFAFLAGS = -quiet - cfalib -I$(srcdir)/stdhdr $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb)@CONFIG_CFAFLAGS@35 AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC -pthread@ARCH_FLAGS@ @CONFIG_CFLAGS@34 AM_CFAFLAGS = -quiet -in-tree -I$(srcdir)/stdhdr $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb) @CONFIG_CFAFLAGS@ 35 AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC @ARCH_FLAGS@ @CONFIG_CFLAGS@ 36 36 AM_CCASFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@ 37 37 CFACC = @CFACC@ … … 64 64 # add dependency of cfa files 65 65 libobjs = $(addsuffix .lo, $(basename $(filter %.cfa,$(libsrc)))) 66 $(libobjs) : @ LOCAL_CFACC@ @CFACPP@ prelude.cfa66 $(libobjs) : @CFACC@ @CFACPP@ prelude.cfa 67 67 68 68 thread_libobjs = $(addsuffix .lo, $(basename $(filter %.cfa,$(thread_libsrc)))) 69 $(thread_libobjs) : @ LOCAL_CFACC@ @CFACPP@ prelude.cfa69 $(thread_libobjs) : @CFACC@ @CFACPP@ prelude.cfa 70 70 71 71 … … 86 86 87 87 88 if ENABLE_DISTCC 88 prelude.o : prelude.cfa extras.cf gcc-builtins.cf builtins.cf @CFACC@ @CFACPP@ 89 ${AM_V_GEN}$(CFACOMPILE) -quiet -in-tree -XCFA -l ${<} -c -o ${@} 89 90 90 ../prelude/distribution: @LOCAL_CFACC@ @LOCAL_CC1@ @CFACPP@ ../prelude/gcc-builtins.cf ../prelude/builtins.cf ../prelude/extras.cf ../prelude/prelude.cfa ../prelude/bootloader.c $(srcdir)/../../tools/build/push2dist.sh 91 @+make -C ../prelude distribution 91 prelude.lo: prelude.cfa extras.cf gcc-builtins.cf builtins.cf @CFACC@ @CFACPP@ 92 ${AM_V_GEN}$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile \ 93 $(CFACOMPILE) -quiet -in-tree -XCFA -l ${<} -c -o ${@} 92 94 93 prelude.o prelude.lo $(libobjs) $(thread_libobjs) : ../prelude/distribution94 95 endif ENABLE_DISTCC96 97 prelude.o : prelude.cfa extras.cf gcc-builtins.cf builtins.cf @LOCAL_CFACC@ @CFACPP@98 ${AM_V_GEN}$(CFACOMPILE) -quiet -XCFA -l ${<} -c -o ${@}99 100 prelude.lo: prelude.cfa extras.cf gcc-builtins.cf builtins.cf @LOCAL_CFACC@ @CFACPP@101 ${AM_V_GEN}$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile \102 $(CFACOMPILE) -quiet -XCFA -l ${<} -c -o ${@}103 95 104 96 #---------------------------------------------------------------------------------------------------------------- -
libcfa/src/Makefile.in
r3d5701e r9fb8f01 284 284 CFACC = @CFACC@ 285 285 CFACPP = @CFACPP@ 286 CFADIR_HASH = @CFADIR_HASH@287 286 CFA_BINDIR = @CFA_BINDIR@ 288 287 CFA_INCDIR = @CFA_INCDIR@ … … 328 327 LIPO = @LIPO@ 329 328 LN_S = @LN_S@ 330 LOCAL_CC1 = @LOCAL_CC1@331 LOCAL_CFACC = @LOCAL_CFACC@332 329 LTLIBOBJS = @LTLIBOBJS@ 333 330 LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ … … 416 413 LTCFACOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ 417 414 $(LIBTOOLFLAGS) --mode=compile $(CFACC) $(DEFS) \ 418 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(AM_CFLAGS) $(CFAFLAGS) $(CFLAGS) 415 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) \ 416 $(AM_CFLAGS) $(CFLAGS) 419 417 420 418 AM_V_CFA = $(am__v_CFA_@AM_V@) … … 422 420 am__v_CFA_0 = @echo " CFA " $@; 423 421 am__v_CFA_1 = 422 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@) 423 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@) 424 am__v_JAVAC_0 = @echo " JAVAC " $@; 425 am__v_JAVAC_1 = 426 AM_V_GOC = $(am__v_GOC_@AM_V@) 427 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@) 428 am__v_GOC_0 = @echo " GOC " $@; 429 am__v_GOC_1 = 424 430 UPPCC = u++ 425 431 UPPCOMPILE = $(UPPCC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_UPPFLAGS) $(UPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_CFLAGS) $(CFLAGS) … … 428 434 am__v_UPP_0 = @echo " UPP " $@; 429 435 am__v_UPP_1 = 430 AM_V_GOC = $(am__v_GOC_@AM_V@)431 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)432 am__v_GOC_0 = @echo " GOC " $@;433 am__v_GOC_1 =434 AM_V_RUST = $(am__v_RUST_@AM_V@)435 am__v_RUST_ = $(am__v_RUST_@AM_DEFAULT_V@)436 am__v_RUST_0 = @echo " RUST " $@;437 am__v_RUST_1 =438 AM_V_NODEJS = $(am__v_NODEJS_@AM_V@)439 am__v_NODEJS_ = $(am__v_NODEJS_@AM_DEFAULT_V@)440 am__v_NODEJS_0 = @echo " NODEJS " $@;441 am__v_NODEJS_1 =442 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)443 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)444 am__v_JAVAC_0 = @echo " JAVAC " $@;445 am__v_JAVAC_1 =446 436 lib_LTLIBRARIES = libcfa.la libcfathread.la 447 437 gdbwaittarget = "" … … 451 441 # use -no-include-stdhdr to prevent rebuild cycles 452 442 # The built sources must not depend on the installed headers 453 AM_CFAFLAGS = -quiet - cfalib -I$(srcdir)/stdhdr $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb)@CONFIG_CFAFLAGS@454 AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC -pthread@ARCH_FLAGS@ @CONFIG_CFLAGS@443 AM_CFAFLAGS = -quiet -in-tree -I$(srcdir)/stdhdr $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb) @CONFIG_CFAFLAGS@ 444 AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC @ARCH_FLAGS@ @CONFIG_CFLAGS@ 455 445 AM_CCASFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@ 456 446 @BUILDLIB_FALSE@headers_nosrc = … … 947 937 $(LTCFACOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ 948 938 $(am__mv) $$depbase.Tpo $$depbase.Plo 949 $(libobjs) : @ LOCAL_CFACC@ @CFACPP@ prelude.cfa950 $(thread_libobjs) : @ LOCAL_CFACC@ @CFACPP@ prelude.cfa939 $(libobjs) : @CFACC@ @CFACPP@ prelude.cfa 940 $(thread_libobjs) : @CFACC@ @CFACPP@ prelude.cfa 951 941 952 942 -include $(libdeps) … … 954 944 -include $(thread_libdeps) 955 945 956 @ENABLE_DISTCC_TRUE@../prelude/distribution: @LOCAL_CFACC@ @LOCAL_CC1@ @CFACPP@ ../prelude/gcc-builtins.cf ../prelude/builtins.cf ../prelude/extras.cf ../prelude/prelude.cfa ../prelude/bootloader.c $(srcdir)/../../tools/build/push2dist.sh 957 @ENABLE_DISTCC_TRUE@ @+make -C ../prelude distribution 958 959 @ENABLE_DISTCC_TRUE@prelude.o prelude.lo $(libobjs) $(thread_libobjs) : ../prelude/distribution 960 961 prelude.o : prelude.cfa extras.cf gcc-builtins.cf builtins.cf @LOCAL_CFACC@ @CFACPP@ 962 ${AM_V_GEN}$(CFACOMPILE) -quiet -XCFA -l ${<} -c -o ${@} 963 964 prelude.lo: prelude.cfa extras.cf gcc-builtins.cf builtins.cf @LOCAL_CFACC@ @CFACPP@ 946 prelude.o : prelude.cfa extras.cf gcc-builtins.cf builtins.cf @CFACC@ @CFACPP@ 947 ${AM_V_GEN}$(CFACOMPILE) -quiet -in-tree -XCFA -l ${<} -c -o ${@} 948 949 prelude.lo: prelude.cfa extras.cf gcc-builtins.cf builtins.cf @CFACC@ @CFACPP@ 965 950 ${AM_V_GEN}$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile \ 966 $(CFACOMPILE) -quiet - XCFA -l ${<} -c -o ${@}951 $(CFACOMPILE) -quiet -in-tree -XCFA -l ${<} -c -o ${@} 967 952 968 953 #---------------------------------------------------------------------------------------------------------------- -
libcfa/src/assert.cfa
r3d5701e r9fb8f01 10 10 // Created On : Mon Nov 28 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Feb 4 13:00:18 202013 // Update Count : 612 // Last Modified On : Thu Jul 20 15:10:26 2017 13 // Update Count : 2 14 14 // 15 15 … … 17 17 #include <stdarg.h> // varargs 18 18 #include <stdio.h> // fprintf 19 #include <unistd.h> // STDERR_FILENO20 19 #include "bits/debug.hfa" 21 20 … … 26 25 27 26 // called by macro assert in assert.h 28 void __assert_fail( const char assertion[], const char file[], unsigned int line, const char function[]) {29 __cfaabi_ bits_print_safe( STDERR_FILENO,CFA_ASSERT_FMT ".\n", assertion, __progname, function, line, file );27 void __assert_fail( const char *assertion, const char *file, unsigned int line, const char *function ) { 28 __cfaabi_dbg_bits_print_safe( CFA_ASSERT_FMT ".\n", assertion, __progname, function, line, file ); 30 29 abort(); 31 30 } 32 31 33 32 // called by macro assertf 34 void __assert_fail_f( const char assertion[], const char file[], unsigned int line, const char function[], const char fmt[], ... ) {35 __cfaabi_ bits_acquire();36 __cfaabi_ bits_print_nolock( STDERR_FILENO,CFA_ASSERT_FMT ": ", assertion, __progname, function, line, file );33 void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) { 34 __cfaabi_dbg_bits_acquire(); 35 __cfaabi_dbg_bits_print_nolock( CFA_ASSERT_FMT ": ", assertion, __progname, function, line, file ); 37 36 38 37 va_list args; 39 38 va_start( args, fmt ); 40 __cfaabi_ bits_print_vararg( STDERR_FILENO,fmt, args );39 __cfaabi_dbg_bits_print_vararg( fmt, args ); 41 40 va_end( args ); 42 41 43 __cfaabi_ bits_print_nolock( STDERR_FILENO,"\n" );44 __cfaabi_ bits_release();42 __cfaabi_dbg_bits_print_nolock( "\n" ); 43 __cfaabi_dbg_bits_release(); 45 44 abort(); 46 45 } -
libcfa/src/bits/align.hfa
r3d5701e r9fb8f01 10 10 // Created On : Mon Nov 28 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Nov 16 18:58:22 201913 // Update Count : 312 // Last Modified On : Fri Jul 21 23:05:35 2017 13 // Update Count : 2 14 14 // 15 15 // This library is free software; you can redistribute it and/or modify it … … 33 33 34 34 // Minimum size used to align memory boundaries for memory allocations. 35 //#define libAlign() (sizeof(double)) 36 // gcc-7 uses xmms instructions, which require 16 byte alignment. 37 #define libAlign() (16) 35 #define libAlign() (sizeof(double)) 38 36 39 37 // Check for power of 2 -
libcfa/src/bits/containers.hfa
r3d5701e r9fb8f01 10 10 // Created On : Tue Oct 31 16:38:50 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed J an 15 07:42:35 202013 // Update Count : 2812 // Last Modified On : Wed Jun 26 08:52:20 2019 13 // Update Count : 4 14 14 15 15 #pragma once … … 44 44 45 45 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) { 47 47 return ((typeof(this.data))this.data)[idx]; 48 48 } 49 49 50 50 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) { 52 52 return ((typeof(this.data))this.data)[idx]; 53 53 } 54 54 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 ) { 57 57 return ((typeof(this.data))this.data); 58 58 } 59 59 60 60 forall(dtype T | sized(T)) 61 static inline T * end( const __small_array(T) & this ) {61 static inline T* end( const __small_array(T) & this ) { 62 62 return ((typeof(this.data))this.data) + this.size; 63 63 } … … 70 70 #ifdef __cforall 71 71 trait is_node(dtype T) { 72 T *& get_next( T& );72 T*& get_next( T& ); 73 73 }; 74 74 #endif … … 97 97 forall(dtype T) 98 98 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; 121 122 } 122 123 #endif … … 144 145 145 146 #ifdef __cforall 146 static inline forall( dtype T | is_node(T) ) { 147 void ?{}( __queue(T) & this ) with( this ) { 148 head{ 1p }; 149 tail{ &head }; 150 verify(*tail == 1p); 151 } 152 153 void append( __queue(T) & this, T * val ) with( this ) { 154 verify(tail != 0p); 155 verify(*tail == 1p); 156 *tail = val; 157 tail = &get_next( *val ); 158 *tail = 1p; 159 } 160 161 T * pop_head( __queue(T) & this ) { 162 verify(*this.tail == 1p); 163 T * head = this.head; 164 if( head != 1p ) { 165 this.head = get_next( *head ); 166 if( get_next( *head ) == 1p ) { 167 this.tail = &this.head; 168 } 169 get_next( *head ) = 0p; 170 verify(*this.tail == 1p); 171 return head; 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; 172 168 } 173 verify(*this.tail == 1p); 174 return 0p; 175 } 176 177 T * remove( __queue(T) & this, T ** it ) with( this ) { 178 T * val = *it; 179 verify( val ); 180 181 (*it) = get_next( *val ); 182 183 if( tail == &get_next( *val ) ) { 184 tail = it; 185 } 186 187 get_next( *val ) = 0p; 188 189 verify( (head == 1p) == (&head == tail) ); 190 verify( *tail == 1p ); 191 return val; 192 } 193 194 int ?!=?( const __queue(T) & this, __attribute__((unused)) zero_t zero ) { 195 return this.head != 0; 196 } 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; 197 195 } 198 196 #endif … … 225 223 226 224 #ifdef __cforall 227 forall(dtype T ) 225 226 forall(dtype T | sized(T)) 228 227 static inline [void] ?{}( __dllist(T) & this, * [T * & next, T * & prev] ( T & ) __get ) { 229 this.head{ 0p};228 this.head{ NULL }; 230 229 this.__get = __get; 231 230 } … … 233 232 #define next 0 234 233 #define prev 1 235 static inline forall(dtype T) { 236 void push_front( __dllist(T) & this, T & node ) with( this ) { 237 verify(__get); 238 if ( head ) { 239 __get( node ).next = head; 240 __get( node ).prev = __get( *head ).prev; 241 // inserted node must be consistent before it is seen 242 // prevent code movement across barrier 243 asm( "" : : : "memory" ); 244 __get( *head ).prev = &node; 245 T & _prev = *__get( node ).prev; 246 __get( _prev ).next = &node; 247 } else { 248 __get( node ).next = &node; 249 __get( node ).prev = &node; 250 } 251 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 252 241 // prevent code movement across barrier 253 242 asm( "" : : : "memory" ); 254 head = &node; 255 } 256 257 void remove( __dllist(T) & this, T & node ) with( this ) { 258 verify(__get); 259 if ( &node == head ) { 260 if ( __get( *head ).next == head ) { 261 head = 0p; 262 } else { 263 head = __get( *head ).next; 264 } 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; 265 263 } 266 __get( *__get( node ).next ).prev = __get( node ).prev; 267 __get( *__get( node ).prev ).next = __get( node ).next; 268 __get( node ).next = 0p; 269 __get( node ).prev = 0p; 270 } 271 272 int ?!=?( const __dllist(T) & this, __attribute__((unused)) zero_t zero ) { 273 return this.head != 0; 274 } 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; 275 277 } 276 278 #undef next … … 284 286 285 287 #endif 286 287 // Local Variables: //288 // tab-width: 4 //289 // End: // -
libcfa/src/bits/debug.cfa
r3d5701e r9fb8f01 10 10 // Created On : Thu Mar 30 12:30:01 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 13:03:16 202013 // Update Count : 1112 // Last Modified On : Sun Jul 14 22:17:35 2019 13 // Update Count : 4 14 14 // 15 15 … … 27 27 28 28 extern "C" { 29 void __cfaabi_bits_write( int fd, const char in_buffer[], int len ) { 29 30 void __cfaabi_dbg_bits_write( const char *in_buffer, int len ) { 30 31 // ensure all data is written 31 32 for ( int count = 0, retcode; count < len; count += retcode ) { … … 33 34 34 35 for ( ;; ) { 35 retcode = write( fd, in_buffer, len - count );36 retcode = write( STDERR_FILENO, in_buffer, len - count ); 36 37 37 38 // not a timer interrupt ? … … 43 44 } 44 45 45 void __cfaabi_ bits_acquire() __attribute__((__weak__)) {}46 void __cfaabi_ bits_release() __attribute__((__weak__)) {}46 void __cfaabi_dbg_bits_acquire() __attribute__((__weak__)) {} 47 void __cfaabi_dbg_bits_release() __attribute__((__weak__)) {} 47 48 48 void __cfaabi_ bits_print_safe ( int fd, const char fmt[], ... ) __attribute__(( format(printf, 2, 3) )) {49 void __cfaabi_dbg_bits_print_safe ( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) )) { 49 50 va_list args; 50 51 51 52 va_start( args, fmt ); 52 __cfaabi_ bits_acquire();53 __cfaabi_dbg_bits_acquire(); 53 54 54 55 int len = vsnprintf( buffer, buffer_size, fmt, args ); 55 __cfaabi_ bits_write( fd,buffer, len );56 __cfaabi_dbg_bits_write( buffer, len ); 56 57 57 __cfaabi_ bits_release();58 __cfaabi_dbg_bits_release(); 58 59 va_end( args ); 59 60 } 60 61 61 void __cfaabi_ bits_print_nolock( int fd, const char fmt[], ... ) __attribute__(( format(printf, 2, 3) )) {62 void __cfaabi_dbg_bits_print_nolock( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) )) { 62 63 va_list args; 63 64 … … 65 66 66 67 int len = vsnprintf( buffer, buffer_size, fmt, args ); 67 __cfaabi_ bits_write( fd,buffer, len );68 __cfaabi_dbg_bits_write( buffer, len ); 68 69 69 70 va_end( args ); 70 71 } 71 72 72 void __cfaabi_ bits_print_vararg( int fd,const char fmt[], va_list args ) {73 void __cfaabi_dbg_bits_print_vararg( const char fmt[], va_list args ) { 73 74 int len = vsnprintf( buffer, buffer_size, fmt, args ); 74 __cfaabi_ bits_write( fd,buffer, len );75 __cfaabi_dbg_bits_write( buffer, len ); 75 76 } 76 77 77 void __cfaabi_ bits_print_buffer( int fd, char in_buffer[], int in_buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 4, 5) )) {78 void __cfaabi_dbg_bits_print_buffer( char in_buffer[], int in_buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 3, 4) )) { 78 79 va_list args; 79 80 … … 81 82 82 83 int len = vsnprintf( in_buffer, in_buffer_size, fmt, args ); 83 __cfaabi_ bits_write( fd,in_buffer, len );84 __cfaabi_dbg_bits_write( in_buffer, len ); 84 85 85 86 va_end( args ); -
libcfa/src/bits/debug.hfa
r3d5701e r9fb8f01 10 10 // Created On : Mon Nov 28 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Feb 4 12:29:21 202013 // Update Count : 912 // Last Modified On : Thu Feb 8 12:35:19 2018 13 // Update Count : 2 14 14 // 15 15 … … 21 21 #define __cfaabi_dbg_ctx __PRETTY_FUNCTION__ 22 22 #define __cfaabi_dbg_ctx2 , __PRETTY_FUNCTION__ 23 #define __cfaabi_dbg_ctx_param const char caller[]24 #define __cfaabi_dbg_ctx_param2 , const char caller[]23 #define __cfaabi_dbg_ctx_param const char * caller 24 #define __cfaabi_dbg_ctx_param2 , const char * caller 25 25 #else 26 26 #define __cfaabi_dbg_debug_do(...) … … 38 38 #include <stdio.h> 39 39 40 extern void __cfaabi_bits_write( int fd, const char buffer[], int len );41 extern void __cfaabi_bits_acquire();42 extern void __cfaabi_bits_release();43 extern void __cfaabi_bits_print_safe ( int fd, const char fmt[], ... ) __attribute__(( format(printf, 2, 3) ));44 extern void __cfaabi_bits_print_nolock( int fd, const char fmt[], ... ) __attribute__(( format(printf, 2, 3) ));45 extern void __cfaabi_bits_print_vararg( int fd,const char fmt[], va_list arg );46 extern void __cfaabi_bits_print_buffer( int fd, char buffer[], int buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 4, 5) ));40 extern void __cfaabi_dbg_bits_write( const char *buffer, int len ); 41 extern void __cfaabi_dbg_bits_acquire(); 42 extern void __cfaabi_dbg_bits_release(); 43 extern void __cfaabi_dbg_bits_print_safe ( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) )); 44 extern void __cfaabi_dbg_bits_print_nolock( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) )); 45 extern void __cfaabi_dbg_bits_print_vararg( const char fmt[], va_list arg ); 46 extern void __cfaabi_dbg_bits_print_buffer( char buffer[], int buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 3, 4) )); 47 47 #ifdef __cforall 48 48 } … … 50 50 51 51 #ifdef __CFA_DEBUG_PRINT__ 52 #define __cfaabi_dbg_write( buffer, len ) __cfaabi_ bits_write( STDERR_FILENO,buffer, len )53 #define __cfaabi_dbg_acquire() __cfaabi_ bits_acquire()54 #define __cfaabi_dbg_release() __cfaabi_ bits_release()55 #define __cfaabi_dbg_print_safe(...) __cfaabi_ bits_print_safe (__VA_ARGS__)56 #define __cfaabi_dbg_print_nolock(...) __cfaabi_ bits_print_nolock (__VA_ARGS__)57 #define __cfaabi_dbg_print_buffer(...) __cfaabi_ bits_print_buffer (__VA_ARGS__)58 #define __cfaabi_dbg_print_buffer_decl(...) char __dbg_text[256]; int __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_ bits_write( __dbg_text, __dbg_len );59 #define __cfaabi_dbg_print_buffer_local(...) __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_dbg_ write( __dbg_text, __dbg_len );52 #define __cfaabi_dbg_write( buffer, len ) __cfaabi_dbg_bits_write( buffer, len ) 53 #define __cfaabi_dbg_acquire() __cfaabi_dbg_bits_acquire() 54 #define __cfaabi_dbg_release() __cfaabi_dbg_bits_release() 55 #define __cfaabi_dbg_print_safe(...) __cfaabi_dbg_bits_print_safe (__VA_ARGS__) 56 #define __cfaabi_dbg_print_nolock(...) __cfaabi_dbg_bits_print_nolock (__VA_ARGS__) 57 #define __cfaabi_dbg_print_buffer(...) __cfaabi_dbg_bits_print_buffer (__VA_ARGS__) 58 #define __cfaabi_dbg_print_buffer_decl(...) char __dbg_text[256]; int __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_dbg_bits_write( __dbg_text, __dbg_len ); 59 #define __cfaabi_dbg_print_buffer_local(...) __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_dbg_bits_write( __dbg_text, __dbg_len ); 60 60 #else 61 61 #define __cfaabi_dbg_write(...) ((void)0) -
libcfa/src/bits/defs.hfa
r3d5701e r9fb8f01 10 10 // Created On : Thu Nov 9 13:24:10 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jan 28 22:38:27 202013 // Update Count : 912 // Last Modified On : Thu Feb 8 16:22:41 2018 13 // Update Count : 8 14 14 // 15 15 … … 34 34 35 35 #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__ )); 36 void abort ( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )); 38 37 extern "C" { 39 38 #endif … … 48 47 #define OPTIONAL_THREAD __attribute__((weak)) 49 48 #endif 50 51 static inline long long rdtscl(void) {52 unsigned int lo, hi;53 __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));54 return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 );55 } -
libcfa/src/bits/locks.hfa
r3d5701e r9fb8f01 10 10 // Created On : Tue Oct 31 15:14:38 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 13:03:19 202013 // Update Count : 1 112 // Last Modified On : Sat Aug 11 15:42:24 2018 13 // Update Count : 10 14 14 // 15 15 … … 54 54 55 55 #ifdef __CFA_DEBUG__ 56 void __cfaabi_dbg_record(__spinlock_t & this, const char prev_name[]);56 void __cfaabi_dbg_record(__spinlock_t & this, const char * prev_name); 57 57 #else 58 58 #define __cfaabi_dbg_record(x, y) 59 59 #endif 60 60 } 61 62 extern void yield( unsigned int ); 61 63 62 64 static inline void ?{}( __spinlock_t & this ) { … … 66 68 // Lock the spinlock, return false if already acquired 67 69 static inline bool try_lock ( __spinlock_t & this __cfaabi_dbg_ctx_param2 ) { 68 disable_interrupts();69 70 bool result = (this.lock == 0) && (__atomic_test_and_set( &this.lock, __ATOMIC_ACQUIRE ) == 0); 70 71 if( result ) { 72 disable_interrupts(); 71 73 __cfaabi_dbg_record( this, caller ); 72 } else {73 enable_interrupts_noPoll();74 74 } 75 75 return result; … … 83 83 #endif 84 84 85 disable_interrupts();86 85 for ( unsigned int i = 1;; i += 1 ) { 87 86 if ( (this.lock == 0) && (__atomic_test_and_set( &this.lock, __ATOMIC_ACQUIRE ) == 0) ) break; … … 99 98 #endif 100 99 } 100 disable_interrupts(); 101 101 __cfaabi_dbg_record( this, caller ); 102 102 } 103 103 104 104 static inline void unlock( __spinlock_t & this ) { 105 enable_interrupts_noPoll(); 105 106 __atomic_clear( &this.lock, __ATOMIC_RELEASE ); 106 enable_interrupts_noPoll();107 107 } 108 108 -
libcfa/src/bits/signal.hfa
r3d5701e r9fb8f01 37 37 38 38 act.sa_sigaction = (void (*)(int, siginfo_t *, void *))handler; 39 sigemptyset( &act.sa_mask );40 sigaddset( &act.sa_mask, SIGALRM ); // disabled during signal handler41 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 delivery47 sigaddset( &act.sa_mask, SIGTERM );48 sigaddset( &act.sa_mask, SIGINT );49 39 act.sa_flags = flags; 50 40 51 if ( sigaction( sig, &act, 0p) == -1 ) {41 if ( sigaction( sig, &act, NULL ) == -1 ) { 52 42 __cfaabi_dbg_print_buffer_decl( 53 43 " __cfaabi_sigaction( sig:%d, handler:%p, flags:%d ), problem installing signal handler, error(%d) %s.\n", … … 55 45 ); 56 46 _exit( EXIT_FAILURE ); 57 } // if47 } 58 48 } 49 50 // Sigaction wrapper : restore default handler 51 static void __cfaabi_sigdefault( int sig ) { 52 struct sigaction act; 53 54 act.sa_handler = SIG_DFL; 55 act.sa_flags = 0; 56 sigemptyset( &act.sa_mask ); 57 58 if ( sigaction( sig, &act, NULL ) == -1 ) { 59 __cfaabi_dbg_print_buffer_decl( 60 " __cfaabi_sigdefault( sig:%d ), problem reseting signal handler, error(%d) %s.\n", 61 sig, errno, strerror( errno ) 62 ); 63 _exit( EXIT_FAILURE ); 64 } 65 } -
libcfa/src/clock.hfa
r3d5701e r9fb8f01 10 10 // Created On : Thu Apr 12 14:36:06 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jan 6 12:49:58 202013 // Update Count : 912 // Last Modified On : Thu Jun 13 21:21:13 2019 13 // Update Count : 8 14 14 // 15 15 16 16 #include <time.hfa> 17 17 18 18 19 //######################### C time ######################### … … 25 26 static inline tm * localtime_r( time_t tp, tm * result ) { return localtime_r( &tp, result ); } 26 27 28 27 29 //######################### Clock ######################### 28 30 29 31 struct Clock { // private 30 32 Duration offset; // for virtual clock: contains offset from real-time 33 int clocktype; // implementation only -1 (virtual), CLOCK_REALTIME 31 34 }; 32 35 33 36 static inline { 37 void resetClock( Clock & clk ) with( clk ) { 38 clocktype = CLOCK_REALTIME_COARSE; 39 } // Clock::resetClock 40 34 41 void resetClock( Clock & clk, Duration adj ) with( clk ) { 42 clocktype = -1; 35 43 offset = adj + __timezone`s; // timezone (global) is (UTC - local time) in seconds 36 44 } // resetClock 37 45 46 void ?{}( Clock & clk ) { resetClock( clk ); } 38 47 void ?{}( Clock & clk, Duration adj ) { resetClock( clk, adj ); } 39 48 … … 80 89 return ret; 81 90 } // getTime 82 83 Time getCPUTime() {84 timespec ts;85 clock_gettime( CLOCK_THREAD_CPUTIME_ID, &ts );86 return (Time){ ts };87 } // getCPUTime88 91 } // distribution 89 92 -
libcfa/src/concurrency/CtxSwitch-arm.S
r3d5701e r9fb8f01 13 13 .text 14 14 .align 2 15 .global __cfactx_switch16 .type __cfactx_switch, %function15 .global CtxSwitch 16 .type CtxSwitch, %function 17 17 18 __cfactx_switch:18 CtxSwitch: 19 19 @ save callee-saved registers: r4-r8, r10, r11, r13(sp) (plus r9 depending on platform specification) 20 20 @ I've seen reference to 31 registers on 64-bit, if this is the case, more need to be saved … … 52 52 mov r15, r14 53 53 #endif // R9_SPECIAL 54 54 55 55 .text 56 56 .align 2 57 .global __cfactx_invoke_stub58 .type __cfactx_invoke_stub, %function57 .global CtxInvokeStub 58 .type CtxInvokeStub, %function 59 59 60 __cfactx_invoke_stub:60 CtxInvokeStub: 61 61 ldmfd r13!, {r0-r1} 62 62 mov r15, r1 -
libcfa/src/concurrency/CtxSwitch-i386.S
r3d5701e r9fb8f01 43 43 .text 44 44 .align 2 45 .globl __cfactx_switch46 .type __cfactx_switch, @function47 __cfactx_switch:45 .globl CtxSwitch 46 .type CtxSwitch, @function 47 CtxSwitch: 48 48 49 49 // Copy the "from" context argument from the stack to register eax … … 83 83 84 84 ret 85 .size __cfactx_switch, .-__cfactx_switch85 .size CtxSwitch, .-CtxSwitch 86 86 87 87 // Local Variables: // -
libcfa/src/concurrency/CtxSwitch-x86_64.S
r3d5701e r9fb8f01 44 44 .text 45 45 .align 2 46 .globl __cfactx_switch47 .type __cfactx_switch, @function48 __cfactx_switch:46 .globl CtxSwitch 47 .type CtxSwitch, @function 48 CtxSwitch: 49 49 50 50 // Save volatile registers on the stack. … … 77 77 78 78 ret 79 .size __cfactx_switch, .-__cfactx_switch79 .size CtxSwitch, .-CtxSwitch 80 80 81 81 //----------------------------------------------------------------------------- … … 83 83 .text 84 84 .align 2 85 .globl __cfactx_invoke_stub86 .type __cfactx_invoke_stub, @function87 __cfactx_invoke_stub:85 .globl CtxInvokeStub 86 .type CtxInvokeStub, @function 87 CtxInvokeStub: 88 88 movq %rbx, %rdi 89 movq %r12, %rsi 90 jmp *%r13 91 .size __cfactx_invoke_stub, .-__cfactx_invoke_stub 89 jmp *%r12 90 .size CtxInvokeStub, .-CtxInvokeStub 92 91 93 92 // Local Variables: // -
libcfa/src/concurrency/alarm.cfa
r3d5701e r9fb8f01 10 10 // Created On : Fri Jun 2 11:31:25 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Jan 5 08:41:36 202013 // Update Count : 6 912 // Last Modified On : Fri May 25 06:25:47 2018 13 // Update Count : 67 14 14 // 15 15 … … 39 39 40 40 void __kernel_set_timer( Duration alarm ) { 41 verifyf(alarm >= 1`us || alarm == 0, "Setting timer to < 1us (%jins)", alarm `ns);42 setitimer( ITIMER_REAL, &(itimerval){ alarm }, 0p);41 verifyf(alarm >= 1`us || alarm == 0, "Setting timer to < 1us (%jins)", alarm.tv); 42 setitimer( ITIMER_REAL, &(itimerval){ alarm }, NULL ); 43 43 } 44 44 … … 47 47 //============================================================================================= 48 48 49 void ?{}( alarm_node_t & this, $thread* thrd, Time alarm, Duration period ) with( this ) {49 void ?{}( alarm_node_t & this, thread_desc * thrd, Time alarm, Duration period ) with( this ) { 50 50 this.thrd = thrd; 51 51 this.alarm = alarm; … … 113 113 this->tail = &this->head; 114 114 } 115 head->next = 0p;115 head->next = NULL; 116 116 } 117 117 verify( validate( this ) ); … … 127 127 this->tail = it; 128 128 } 129 n->next = 0p;129 n->next = NULL; 130 130 131 131 verify( validate( this ) ); -
libcfa/src/concurrency/alarm.hfa
r3d5701e r9fb8f01 23 23 #include "time.hfa" 24 24 25 struct $thread;25 struct thread_desc; 26 26 struct processor; 27 27 … … 43 43 44 44 union { 45 $thread* thrd; // thrd who created event45 thread_desc * thrd; // thrd who created event 46 46 processor * proc; // proc who created event 47 47 }; … … 53 53 typedef alarm_node_t ** __alarm_it_t; 54 54 55 void ?{}( alarm_node_t & this, $thread* thrd, Time alarm, Duration period );55 void ?{}( alarm_node_t & this, thread_desc * thrd, Time alarm, Duration period ); 56 56 void ?{}( alarm_node_t & this, processor * proc, Time alarm, Duration period ); 57 57 void ^?{}( alarm_node_t & this ); -
libcfa/src/concurrency/coroutine.cfa
r3d5701e r9fb8f01 10 10 // Created On : Mon Nov 28 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 12:29:25 202013 // Update Count : 1612 // Last Modified On : Fri Mar 30 17:20:57 2018 13 // Update Count : 9 14 14 // 15 15 … … 37 37 38 38 extern "C" { 39 void _CtxCoroutine_Unwind(struct _Unwind_Exception * storage, struct $coroutine*) __attribute__ ((__noreturn__));39 void _CtxCoroutine_Unwind(struct _Unwind_Exception * storage, struct coroutine_desc *) __attribute__ ((__noreturn__)); 40 40 static void _CtxCoroutine_UnwindCleanup(_Unwind_Reason_Code, struct _Unwind_Exception *) __attribute__ ((__noreturn__)); 41 41 static void _CtxCoroutine_UnwindCleanup(_Unwind_Reason_Code, struct _Unwind_Exception *) { … … 89 89 } 90 90 91 void ?{}( $coroutine & this, const char name[], void * storage, size_t storageSize ) with( this ) {92 (this.context){ 0p, 0p};91 void ?{}( coroutine_desc & this, const char * name, void * storage, size_t storageSize ) with( this ) { 92 (this.context){NULL, NULL}; 93 93 (this.stack){storage, storageSize}; 94 94 this.name = name; 95 95 state = Start; 96 starter = 0p;97 last = 0p;98 cancellation = 0p;99 } 100 101 void ^?{}( $coroutine& this) {96 starter = NULL; 97 last = NULL; 98 cancellation = NULL; 99 } 100 101 void ^?{}(coroutine_desc& this) { 102 102 if(this.state != Halted && this.state != Start && this.state != Primed) { 103 $coroutine* src = TL_GET( this_thread )->curr_cor;104 $coroutine* dst = &this;103 coroutine_desc * src = TL_GET( this_thread )->curr_cor; 104 coroutine_desc * dst = &this; 105 105 106 106 struct _Unwind_Exception storage; … … 115 115 } 116 116 117 $ctx_switch( src, dst );117 CoroutineCtxSwitch( src, dst ); 118 118 } 119 119 } … … 123 123 forall(dtype T | is_coroutine(T)) 124 124 void prime(T& cor) { 125 $coroutine* this = get_coroutine(cor);125 coroutine_desc* this = get_coroutine(cor); 126 126 assert(this->state == Start); 127 127 … … 131 131 132 132 [void *, size_t] __stack_alloc( size_t storageSize ) { 133 const size_t stack_data_size = libCeiling( sizeof(__stack_t), 16 ); // minimum alignment133 static const size_t stack_data_size = libCeiling( sizeof(__stack_t), 16 ); // minimum alignment 134 134 assert(__page_size != 0l); 135 135 size_t size = libCeiling( storageSize, 16 ) + stack_data_size; … … 157 157 158 158 void __stack_prepare( __stack_info_t * this, size_t create_size ) { 159 const size_t stack_data_size = libCeiling( sizeof(__stack_t), 16 ); // minimum alignment159 static const size_t stack_data_size = libCeiling( sizeof(__stack_t), 16 ); // minimum alignment 160 160 bool userStack; 161 161 void * storage; … … 187 187 // is not inline (We can't inline Cforall in C) 188 188 extern "C" { 189 void __cfactx_cor_leave( struct $coroutine * src ) { 190 $coroutine * starter = src->cancellation != 0 ? src->last : src->starter; 189 void __suspend_internal(void) { 190 suspend(); 191 } 192 193 void __leave_coroutine( coroutine_desc * src ) { 194 coroutine_desc * starter = src->cancellation != 0 ? src->last : src->starter; 191 195 192 196 src->state = Halted; … … 201 205 src->name, src, starter->name, starter ); 202 206 203 $ctx_switch( src, starter ); 204 } 205 206 struct $coroutine * __cfactx_cor_finish(void) { 207 struct $coroutine * cor = kernelTLS.this_thread->curr_cor; 208 209 if(cor->state == Primed) { 210 suspend(); 211 } 212 213 cor->state = Active; 214 215 return cor; 207 CoroutineCtxSwitch( src, starter ); 216 208 } 217 209 } -
libcfa/src/concurrency/coroutine.hfa
r3d5701e r9fb8f01 10 10 // Created On : Mon Nov 28 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 12:29:26 202013 // Update Count : 1112 // Last Modified On : Fri Jun 21 17:49:39 2019 13 // Update Count : 9 14 14 // 15 15 … … 25 25 trait is_coroutine(dtype T) { 26 26 void main(T & this); 27 $coroutine* get_coroutine(T & this);27 coroutine_desc * get_coroutine(T & this); 28 28 }; 29 29 30 #define DECL_COROUTINE(X) static inline $coroutine* get_coroutine(X& this) { return &this.__cor; } void main(X& this)30 #define DECL_COROUTINE(X) static inline coroutine_desc* get_coroutine(X& this) { return &this.__cor; } void main(X& this) 31 31 32 32 //----------------------------------------------------------------------------- … … 35 35 // void ^?{}( coStack_t & this ); 36 36 37 void ?{}( $coroutine & this, const char name[], void * storage, size_t storageSize );38 void ^?{}( $coroutine& this );37 void ?{}( coroutine_desc & this, const char * name, void * storage, size_t storageSize ); 38 void ^?{}( coroutine_desc & this ); 39 39 40 static inline void ?{}( $coroutine & this) { this{ "Anonymous Coroutine", 0p, 0 }; }41 static inline void ?{}( $coroutine & this, size_t stackSize) { this{ "Anonymous Coroutine", 0p, stackSize }; }42 static inline void ?{}( $coroutine& this, void * storage, size_t storageSize ) { this{ "Anonymous Coroutine", storage, storageSize }; }43 static inline void ?{}( $coroutine & this, const char name[]) { this{ name, 0p, 0 }; }44 static inline void ?{}( $coroutine & this, const char name[], size_t stackSize ) { this{ name, 0p, stackSize }; }40 static inline void ?{}( coroutine_desc & this) { this{ "Anonymous Coroutine", NULL, 0 }; } 41 static inline void ?{}( coroutine_desc & this, size_t stackSize) { this{ "Anonymous Coroutine", NULL, stackSize }; } 42 static inline void ?{}( coroutine_desc & this, void * storage, size_t storageSize ) { this{ "Anonymous Coroutine", storage, storageSize }; } 43 static inline void ?{}( coroutine_desc & this, const char * name) { this{ name, NULL, 0 }; } 44 static inline void ?{}( coroutine_desc & this, const char * name, size_t stackSize ) { this{ name, NULL, stackSize }; } 45 45 46 46 //----------------------------------------------------------------------------- … … 54 54 void prime(T & cor); 55 55 56 static inline struct $coroutine* active_coroutine() { return TL_GET( this_thread )->curr_cor; }56 static inline struct coroutine_desc * active_coroutine() { return TL_GET( this_thread )->curr_cor; } 57 57 58 58 //----------------------------------------------------------------------------- … … 61 61 // Start coroutine routines 62 62 extern "C" { 63 void __cfactx_invoke_coroutine(void (*main)(void *), void * this); 63 forall(dtype T | is_coroutine(T)) 64 void CtxInvokeCoroutine(T * this); 64 65 65 forall(dtype T)66 void __cfactx_start(void (*main)(T &), struct $coroutine * cor, T & this, void (*invoke)(void (*main)(void *), void*));66 forall(dtype T | is_coroutine(T)) 67 void CtxStart(T * this, void ( *invoke)(T *)); 67 68 68 extern void _ _cfactx_coroutine_unwind(struct _Unwind_Exception * storage, struct $coroutine*) __attribute__ ((__noreturn__));69 extern void _CtxCoroutine_Unwind(struct _Unwind_Exception * storage, struct coroutine_desc *) __attribute__ ((__noreturn__)); 69 70 70 extern void __cfactx_switch( struct __stack_context_t * from, struct __stack_context_t * to ) asm ("__cfactx_switch");71 extern void CtxSwitch( struct __stack_context_t * from, struct __stack_context_t * to ) asm ("CtxSwitch"); 71 72 } 72 73 73 74 // Private wrappers for context switch and stack creation 74 75 // Wrapper for co 75 static inline void $ctx_switch( $coroutine * src, $coroutine * dst ) __attribute__((nonnull (1, 2))) {76 static inline void CoroutineCtxSwitch(coroutine_desc* src, coroutine_desc* dst) { 76 77 // set state of current coroutine to inactive 77 78 src->state = src->state == Halted ? Halted : Inactive; … … 82 83 // context switch to specified coroutine 83 84 verify( dst->context.SP ); 84 __cfactx_switch( &src->context, &dst->context );85 // when __cfactx_switch returns we are back in the src coroutine85 CtxSwitch( &src->context, &dst->context ); 86 // when CtxSwitch returns we are back in the src coroutine 86 87 87 88 // set state of new coroutine to active 88 89 src->state = Active; 89 90 90 if( unlikely(src->cancellation != 0p) ) {91 _ _cfactx_coroutine_unwind(src->cancellation, src);91 if( unlikely(src->cancellation != NULL) ) { 92 _CtxCoroutine_Unwind(src->cancellation, src); 92 93 } 93 94 } … … 102 103 // will also migrate which means this value will 103 104 // stay in syn with the TLS 104 $coroutine* src = TL_GET( this_thread )->curr_cor;105 coroutine_desc * src = TL_GET( this_thread )->curr_cor; 105 106 106 107 assertf( src->last != 0, … … 113 114 src->name, src, src->last->name, src->last ); 114 115 115 $ctx_switch( src, src->last );116 CoroutineCtxSwitch( src, src->last ); 116 117 } 117 118 … … 124 125 // will also migrate which means this value will 125 126 // stay in syn with the TLS 126 $coroutine* src = TL_GET( this_thread )->curr_cor;127 $coroutine* dst = get_coroutine(cor);127 coroutine_desc * src = TL_GET( this_thread )->curr_cor; 128 coroutine_desc * dst = get_coroutine(cor); 128 129 129 if( unlikely(dst->context.SP == 0p) ) { 130 TL_GET( this_thread )->curr_cor = dst; 130 if( unlikely(dst->context.SP == NULL) ) { 131 131 __stack_prepare(&dst->stack, 65000); 132 __cfactx_start(main, dst, cor, __cfactx_invoke_coroutine); 133 TL_GET( this_thread )->curr_cor = src; 132 CtxStart(&cor, CtxInvokeCoroutine); 134 133 } 135 134 … … 147 146 148 147 // always done for performance testing 149 $ctx_switch( src, dst );148 CoroutineCtxSwitch( src, dst ); 150 149 151 150 return cor; 152 151 } 153 152 154 static inline void resume( $coroutine * dst ) __attribute__((nonnull (1))) {153 static inline void resume(coroutine_desc * dst) { 155 154 // optimization : read TLS once and reuse it 156 155 // Safety note: this is preemption safe since if … … 158 157 // will also migrate which means this value will 159 158 // stay in syn with the TLS 160 $coroutine* src = TL_GET( this_thread )->curr_cor;159 coroutine_desc * src = TL_GET( this_thread )->curr_cor; 161 160 162 161 // not resuming self ? … … 172 171 173 172 // always done for performance testing 174 $ctx_switch( src, dst );173 CoroutineCtxSwitch( src, dst ); 175 174 } 176 175 -
libcfa/src/concurrency/invoke.c
r3d5701e r9fb8f01 29 29 // Called from the kernel when starting a coroutine or task so must switch back to user mode. 30 30 31 extern struct $coroutine * __cfactx_cor_finish(void);32 extern void __ cfactx_cor_leave ( struct $coroutine* );33 extern void __ cfactx_thrd_leave();34 31 extern void __suspend_internal(void); 32 extern void __leave_coroutine( struct coroutine_desc * ); 33 extern void __finish_creation( struct thread_desc * ); 34 extern void __leave_thread_monitor( struct thread_desc * this ); 35 35 extern void disable_interrupts() OPTIONAL_THREAD; 36 36 extern void enable_interrupts( __cfaabi_dbg_ctx_param ); 37 37 38 void __cfactx_invoke_coroutine(38 void CtxInvokeCoroutine( 39 39 void (*main)(void *), 40 struct coroutine_desc *(*get_coroutine)(void *), 40 41 void *this 41 42 ) { 42 // Finish setting up the coroutine by setting its state 43 struct $coroutine * cor = __cfactx_cor_finish(); 43 struct coroutine_desc* cor = get_coroutine( this ); 44 44 45 // Call the main of the coroutine 45 if(cor->state == Primed) { 46 __suspend_internal(); 47 } 48 49 cor->state = Active; 50 46 51 main( this ); 47 52 48 53 //Final suspend, should never return 49 __ cfactx_cor_leave( cor );54 __leave_coroutine( cor ); 50 55 __cabi_abort( "Resumed dead coroutine" ); 51 56 } 52 57 53 static _Unwind_Reason_Code _ _cfactx_coroutine_unwindstop(58 static _Unwind_Reason_Code _CtxCoroutine_UnwindStop( 54 59 __attribute((__unused__)) int version, 55 60 _Unwind_Action actions, … … 62 67 // We finished unwinding the coroutine, 63 68 // leave it 64 __ cfactx_cor_leave( param );69 __leave_coroutine( param ); 65 70 __cabi_abort( "Resumed dead coroutine" ); 66 71 } … … 70 75 } 71 76 72 void _ _cfactx_coroutine_unwind(struct _Unwind_Exception * storage, struct $coroutine* cor) __attribute__ ((__noreturn__));73 void _ _cfactx_coroutine_unwind(struct _Unwind_Exception * storage, struct $coroutine* cor) {74 _Unwind_Reason_Code ret = _Unwind_ForcedUnwind( storage, _ _cfactx_coroutine_unwindstop, cor );77 void _CtxCoroutine_Unwind(struct _Unwind_Exception * storage, struct coroutine_desc * cor) __attribute__ ((__noreturn__)); 78 void _CtxCoroutine_Unwind(struct _Unwind_Exception * storage, struct coroutine_desc * cor) { 79 _Unwind_Reason_Code ret = _Unwind_ForcedUnwind( storage, _CtxCoroutine_UnwindStop, cor ); 75 80 printf("UNWIND ERROR %d after force unwind\n", ret); 76 81 abort(); 77 82 } 78 83 79 void __cfactx_invoke_thread( 84 void CtxInvokeThread( 85 void (*dtor)(void *), 80 86 void (*main)(void *), 87 struct thread_desc *(*get_thread)(void *), 81 88 void *this 82 89 ) { 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 83 97 // Officially start the thread by enabling preemption 84 98 enable_interrupts( __cfaabi_dbg_ctx ); … … 94 108 // The order of these 4 operations is very important 95 109 //Final suspend, should never return 96 __ cfactx_thrd_leave();110 __leave_thread_monitor( thrd ); 97 111 __cabi_abort( "Resumed dead thread" ); 98 112 } 99 113 100 void __cfactx_start( 114 115 void CtxStart( 101 116 void (*main)(void *), 102 struct $coroutine * cor,117 struct coroutine_desc *(*get_coroutine)(void *), 103 118 void *this, 104 119 void (*invoke)(void *) 105 120 ) { 121 struct coroutine_desc * cor = get_coroutine( this ); 106 122 struct __stack_t * stack = cor->stack.storage; 107 123 … … 122 138 123 139 fs->dummyReturn = NULL; 124 fs->argument[0] = main; // argument to invoke 125 fs->argument[1] = this; // argument to invoke 140 fs->argument[0] = this; // argument to invoke 126 141 fs->rturn = invoke; 127 142 … … 140 155 141 156 fs->dummyReturn = NULL; 142 fs->rturn = __cfactx_invoke_stub; 143 fs->fixedRegisters[0] = main; 144 fs->fixedRegisters[1] = this; 145 fs->fixedRegisters[2] = invoke; 157 fs->rturn = CtxInvokeStub; 158 fs->fixedRegisters[0] = this; 159 fs->fixedRegisters[1] = invoke; 146 160 147 161 #elif defined( __ARM_ARCH ) 148 #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 149 163 struct FakeStack { 150 164 float fpRegs[16]; // floating point registers … … 158 172 struct FakeStack *fs = (struct FakeStack *)cor->context.SP; 159 173 160 fs->intRegs[8] = __cfactx_invoke_stub;174 fs->intRegs[8] = CtxInvokeStub; 161 175 fs->arg[0] = this; 162 176 fs->arg[1] = invoke; -
libcfa/src/concurrency/invoke.h
r3d5701e r9fb8f01 10 10 // Created On : Tue Jan 17 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Dec 5 16:26:03 201913 // Update Count : 4 412 // Last Modified On : Sat Jun 22 18:19:13 2019 13 // Update Count : 40 14 14 // 15 15 … … 46 46 #ifdef __cforall 47 47 extern "Cforall" { 48 extern __attribute__((aligned(128)))thread_local struct KernelThreadData {49 struct $thread* volatile this_thread;48 extern thread_local struct KernelThreadData { 49 struct thread_desc * volatile this_thread; 50 50 struct processor * volatile this_processor; 51 51 … … 55 55 volatile bool in_progress; 56 56 } preemption_state; 57 58 uint32_t rand_seed;59 57 } kernelTLS __attribute__ ((tls_model ( "initial-exec" ))); 60 58 } … … 92 90 }; 93 91 94 enum coroutine_state { Halted, Start, Primed, Inactive, Active, Rerun }; 95 enum __Preemption_Reason { __NO_PREEMPTION, __ALARM_PREEMPTION, __POLL_PREEMPTION, __MANUAL_PREEMPTION }; 96 97 struct $coroutine { 98 // context that is switch during a __cfactx_switch 92 enum coroutine_state { Halted, Start, Inactive, Active, Primed }; 93 94 struct coroutine_desc { 95 // context that is switch during a CtxSwitch 99 96 struct __stack_context_t context; 100 97 … … 109 106 110 107 // first coroutine to resume this one 111 struct $coroutine* starter;108 struct coroutine_desc * starter; 112 109 113 110 // last coroutine to resume this one 114 struct $coroutine* last;111 struct coroutine_desc * last; 115 112 116 113 // If non-null stack must be unwound with this exception … … 128 125 }; 129 126 130 struct $monitor{127 struct monitor_desc { 131 128 // spinlock to protect internal data 132 129 struct __spinlock_t lock; 133 130 134 131 // current owner of the monitor 135 struct $thread* owner;132 struct thread_desc * owner; 136 133 137 134 // queue of threads that are blocked waiting for the monitor 138 __queue_t(struct $thread) entry_queue;135 __queue_t(struct thread_desc) entry_queue; 139 136 140 137 // stack of conditions to run next once we exit the monitor … … 153 150 struct __monitor_group_t { 154 151 // currently held monitors 155 __cfa_anonymous_object( __small_array_t( $monitor*) );152 __cfa_anonymous_object( __small_array_t(monitor_desc*) ); 156 153 157 154 // last function that acquired monitors … … 159 156 }; 160 157 161 struct $thread{158 struct thread_desc { 162 159 // Core threading fields 163 // context that is switch during a __cfactx_switch160 // context that is switch during a CtxSwitch 164 161 struct __stack_context_t context; 165 162 166 163 // current execution status for coroutine 167 volatile int state; 168 enum __Preemption_Reason preempted; 164 enum coroutine_state state; 169 165 170 166 //SKULLDUGGERY errno is not save in the thread data structure because returnToKernel appears to be the only function to require saving and restoring it 171 167 172 168 // coroutine body used to store context 173 struct $coroutineself_cor;169 struct coroutine_desc self_cor; 174 170 175 171 // current active context 176 struct $coroutine* curr_cor;172 struct coroutine_desc * curr_cor; 177 173 178 174 // monitor body used for mutual exclusion 179 struct $monitorself_mon;175 struct monitor_desc self_mon; 180 176 181 177 // pointer to monitor with sufficient lifetime for current monitors 182 struct $monitor* self_mon_p;178 struct monitor_desc * self_mon_p; 183 179 184 180 // pointer to the cluster on which the thread is running … … 190 186 // Link lists fields 191 187 // instrusive link field for threads 192 struct $thread* next;188 struct thread_desc * next; 193 189 194 190 struct { 195 struct $thread* next;196 struct $thread* prev;191 struct thread_desc * next; 192 struct thread_desc * prev; 197 193 } node; 198 194 }; … … 200 196 #ifdef __cforall 201 197 extern "Cforall" { 202 static inline $thread *& get_next( $thread & this ) __attribute__((const)) {198 static inline thread_desc *& get_next( thread_desc & this ) { 203 199 return this.next; 204 200 } 205 201 206 static inline [ $thread *&, $thread *& ] __get( $thread & this ) __attribute__((const)) {202 static inline [thread_desc *&, thread_desc *& ] __get( thread_desc & this ) { 207 203 return this.node.[next, prev]; 208 204 } 209 205 210 206 static inline void ?{}(__monitor_group_t & this) { 211 (this.data){ 0p};207 (this.data){NULL}; 212 208 (this.size){0}; 213 209 (this.func){NULL}; 214 210 } 215 211 216 static inline void ?{}(__monitor_group_t & this, struct $monitor** data, __lock_size_t size, fptr_t func) {212 static inline void ?{}(__monitor_group_t & this, struct monitor_desc ** data, __lock_size_t size, fptr_t func) { 217 213 (this.data){data}; 218 214 (this.size){size}; … … 220 216 } 221 217 222 static inline bool ?==?( const __monitor_group_t & lhs, const __monitor_group_t & rhs ) __attribute__((const)){218 static inline bool ?==?( const __monitor_group_t & lhs, const __monitor_group_t & rhs ) { 223 219 if( (lhs.data != 0) != (rhs.data != 0) ) return false; 224 220 if( lhs.size != rhs.size ) return false; … … 254 250 255 251 // assembler routines that performs the context switch 256 extern void __cfactx_invoke_stub( void );257 extern void __cfactx_switch( struct __stack_context_t * from, struct __stack_context_t * to ) asm ("__cfactx_switch");252 extern void CtxInvokeStub( void ); 253 extern void CtxSwitch( struct __stack_context_t * from, struct __stack_context_t * to ) asm ("CtxSwitch"); 258 254 // void CtxStore ( void * this ) asm ("CtxStore"); 259 255 // void CtxRet ( void * dst ) asm ("CtxRet"); -
libcfa/src/concurrency/kernel.cfa
r3d5701e r9fb8f01 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Feb 4 13:03:15 202013 // Update Count : 5812 // Last Modified On : Thu Jun 20 17:21:23 2019 13 // Update Count : 25 14 14 // 15 15 … … 26 26 #include <signal.h> 27 27 #include <unistd.h> 28 #include <limits.h> // PTHREAD_STACK_MIN29 #include <sys/mman.h> // mprotect30 28 } 31 29 … … 42 40 //----------------------------------------------------------------------------- 43 41 // Some assembly required 44 #if defined( __i386 )42 #if defined( __i386 ) 45 43 #define CtxGet( ctx ) \ 46 44 __asm__ volatile ( \ … … 110 108 //----------------------------------------------------------------------------- 111 109 //Start and stop routine for the kernel, declared first to make sure they run first 112 static void __kernel_startup (void)__attribute__(( constructor( STARTUP_PRIORITY_KERNEL ) ));113 static void __kernel_shutdown(void) __attribute__(( destructor ( STARTUP_PRIORITY_KERNEL ) ));110 static void kernel_startup(void) __attribute__(( constructor( STARTUP_PRIORITY_KERNEL ) )); 111 static void kernel_shutdown(void) __attribute__(( destructor ( STARTUP_PRIORITY_KERNEL ) )); 114 112 115 113 //----------------------------------------------------------------------------- … … 117 115 KERNEL_STORAGE(cluster, mainCluster); 118 116 KERNEL_STORAGE(processor, mainProcessor); 119 KERNEL_STORAGE( $thread, mainThread);117 KERNEL_STORAGE(thread_desc, mainThread); 120 118 KERNEL_STORAGE(__stack_t, mainThreadCtx); 121 119 122 120 cluster * mainCluster; 123 121 processor * mainProcessor; 124 $thread* mainThread;122 thread_desc * mainThread; 125 123 126 124 extern "C" { 127 struct { __dllist_t(cluster) list; __spinlock_t lock; } __cfa_dbg_global_clusters;125 struct { __dllist_t(cluster) list; __spinlock_t lock; } __cfa_dbg_global_clusters; 128 126 } 129 127 … … 133 131 // Global state 134 132 thread_local struct KernelThreadData kernelTLS __attribute__ ((tls_model ( "initial-exec" ))) = { 135 NULL, // cannot use 0p136 133 NULL, 137 { 1, false, false },138 6u //this should be seeded better but due to a bug calling rdtsc doesn't work134 NULL, 135 { 1, false, false } 139 136 }; 140 137 … … 142 139 // Struct to steal stack 143 140 struct current_stack_info_t { 144 __stack_t * storage; // pointer to stack object145 void * base;// base of stack146 void * limit;// stack grows towards stack limit147 void * context;// address of cfa_context_t141 __stack_t * storage; // pointer to stack object 142 void *base; // base of stack 143 void *limit; // stack grows towards stack limit 144 void *context; // address of cfa_context_t 148 145 }; 149 146 … … 164 161 // Main thread construction 165 162 166 void ?{}( $coroutine& this, current_stack_info_t * info) with( this ) {163 void ?{}( coroutine_desc & this, current_stack_info_t * info) with( this ) { 167 164 stack.storage = info->storage; 168 165 with(*stack.storage) { … … 174 171 name = "Main Thread"; 175 172 state = Start; 176 starter = 0p;177 last = 0p;178 cancellation = 0p;179 } 180 181 void ?{}( $thread& this, current_stack_info_t * info) with( this ) {173 starter = NULL; 174 last = NULL; 175 cancellation = NULL; 176 } 177 178 void ?{}( thread_desc & this, current_stack_info_t * info) with( this ) { 182 179 state = Start; 183 180 self_cor{ info }; … … 187 184 self_mon.recursion = 1; 188 185 self_mon_p = &self_mon; 189 next = 0p;190 191 node.next = 0p;192 node.prev = 0p;186 next = NULL; 187 188 node.next = NULL; 189 node.prev = NULL; 193 190 doregister(curr_cluster, this); 194 191 … … 208 205 } 209 206 210 static void * __invoke_processor(void * arg); 211 212 void ?{}(processor & this, const char name[], cluster & cltr) with( this ) { 207 static void start(processor * this); 208 void ?{}(processor & this, const char * name, cluster & cltr) with( this ) { 213 209 this.name = name; 214 210 this.cltr = &cltr; 215 211 terminated{ 0 }; 216 destroyer = 0p;217 212 do_terminate = false; 218 preemption_alarm = 0p;213 preemption_alarm = NULL; 219 214 pending_preemption = false; 220 215 runner.proc = &this; … … 222 217 idleLock{}; 223 218 224 __cfaabi_dbg_print_safe("Kernel : Starting core %p\n", &this); 225 226 this.stack = __create_pthread( &this.kernel_thread, __invoke_processor, (void *)&this ); 227 228 __cfaabi_dbg_print_safe("Kernel : core %p started\n", &this); 219 start( &this ); 229 220 } 230 221 … … 240 231 } 241 232 242 pthread_join( kernel_thread, 0p ); 243 free( this.stack ); 244 } 245 246 void ?{}(cluster & this, const char name[], Duration preemption_rate) with( this ) { 233 pthread_join( kernel_thread, NULL ); 234 } 235 236 void ?{}(cluster & this, const char * name, Duration preemption_rate) with( this ) { 247 237 this.name = name; 248 238 this.preemption_rate = preemption_rate; … … 264 254 // Kernel Scheduling logic 265 255 //============================================================================================= 266 static $thread * __next_thread(cluster * this);267 static void __run_thread(processor * this, $thread * dst);268 static void __halt(processor * this);256 static void runThread(processor * this, thread_desc * dst); 257 static void finishRunning(processor * this); 258 static void halt(processor * this); 269 259 270 260 //Main of the processor contexts 271 261 void main(processorCtx_t & runner) { 272 // Because of a bug, we couldn't initialized the seed on construction273 // Do it here274 kernelTLS.rand_seed ^= rdtscl();275 276 262 processor * this = runner.proc; 277 263 verify(this); … … 287 273 __cfaabi_dbg_print_safe("Kernel : core %p started\n", this); 288 274 289 $thread * readyThread = 0p; 290 for( unsigned int spin_count = 0; ! __atomic_load_n(&this->do_terminate, __ATOMIC_SEQ_CST); spin_count++ ) { 291 readyThread = __next_thread( this->cltr ); 292 293 if(readyThread) { 294 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled ); 295 /* paranoid */ verifyf( readyThread->state == Inactive || readyThread->state == Start || readyThread->preempted != __NO_PREEMPTION, "state : %d, preempted %d\n", readyThread->state, readyThread->preempted); 296 /* paranoid */ verifyf( readyThread->next == 0p, "Expected null got %p", readyThread->next ); 297 298 __run_thread(this, readyThread); 299 300 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled ); 275 thread_desc * readyThread = NULL; 276 for( unsigned int spin_count = 0; ! __atomic_load_n(&this->do_terminate, __ATOMIC_SEQ_CST); spin_count++ ) 277 { 278 readyThread = nextThread( this->cltr ); 279 280 if(readyThread) 281 { 282 verify( ! kernelTLS.preemption_state.enabled ); 283 284 runThread(this, readyThread); 285 286 verify( ! kernelTLS.preemption_state.enabled ); 287 288 //Some actions need to be taken from the kernel 289 finishRunning(this); 301 290 302 291 spin_count = 0; 303 } else { 292 } 293 else 294 { 304 295 // spin(this, &spin_count); 305 __halt(this);296 halt(this); 306 297 } 307 298 } … … 323 314 // runThread runs a thread by context switching 324 315 // from the processor coroutine to the target thread 325 static void __run_thread(processor * this, $thread * thrd_dst) { 326 $coroutine * proc_cor = get_coroutine(this->runner); 316 static void runThread(processor * this, thread_desc * thrd_dst) { 317 coroutine_desc * proc_cor = get_coroutine(this->runner); 318 319 // Reset the terminating actions here 320 this->finish.action_code = No_Action; 327 321 328 322 // Update global state 329 323 kernelTLS.this_thread = thrd_dst; 330 324 331 // set state of processor coroutine to inactive 332 verify(proc_cor->state == Active); 333 proc_cor->state = Inactive; 334 335 // Actually run the thread 336 RUNNING: while(true) { 337 if(unlikely(thrd_dst->preempted)) { 338 thrd_dst->preempted = __NO_PREEMPTION; 339 verify(thrd_dst->state == Active || thrd_dst->state == Rerun); 340 } else { 341 verify(thrd_dst->state == Start || thrd_dst->state == Primed || thrd_dst->state == Inactive); 342 thrd_dst->state = Active; 325 // set state of processor coroutine to inactive and the thread to active 326 proc_cor->state = proc_cor->state == Halted ? Halted : Inactive; 327 thrd_dst->state = Active; 328 329 // set context switch to the thread that the processor is executing 330 verify( thrd_dst->context.SP ); 331 CtxSwitch( &proc_cor->context, &thrd_dst->context ); 332 // when CtxSwitch returns we are back in the processor coroutine 333 334 // set state of processor coroutine to active and the thread to inactive 335 thrd_dst->state = thrd_dst->state == Halted ? Halted : Inactive; 336 proc_cor->state = Active; 337 } 338 339 // KERNEL_ONLY 340 static void returnToKernel() { 341 coroutine_desc * proc_cor = get_coroutine(kernelTLS.this_processor->runner); 342 thread_desc * thrd_src = kernelTLS.this_thread; 343 344 // set state of current coroutine to inactive 345 thrd_src->state = thrd_src->state == Halted ? Halted : Inactive; 346 proc_cor->state = Active; 347 int local_errno = *__volatile_errno(); 348 #if defined( __i386 ) || defined( __x86_64 ) 349 __x87_store; 350 #endif 351 352 // set new coroutine that the processor is executing 353 // and context switch to it 354 verify( proc_cor->context.SP ); 355 CtxSwitch( &thrd_src->context, &proc_cor->context ); 356 357 // set state of new coroutine to active 358 proc_cor->state = proc_cor->state == Halted ? Halted : Inactive; 359 thrd_src->state = Active; 360 361 #if defined( __i386 ) || defined( __x86_64 ) 362 __x87_load; 363 #endif 364 *__volatile_errno() = local_errno; 365 } 366 367 // KERNEL_ONLY 368 // Once a thread has finished running, some of 369 // its final actions must be executed from the kernel 370 static void finishRunning(processor * this) with( this->finish ) { 371 verify( ! kernelTLS.preemption_state.enabled ); 372 choose( action_code ) { 373 case No_Action: 374 break; 375 case Release: 376 unlock( *lock ); 377 case Schedule: 378 ScheduleThread( thrd ); 379 case Release_Schedule: 380 unlock( *lock ); 381 ScheduleThread( thrd ); 382 case Release_Multi: 383 for(int i = 0; i < lock_count; i++) { 384 unlock( *locks[i] ); 343 385 } 344 345 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled ); 346 347 // set context switch to the thread that the processor is executing 348 verify( thrd_dst->context.SP ); 349 __cfactx_switch( &proc_cor->context, &thrd_dst->context ); 350 // when __cfactx_switch returns we are back in the processor coroutine 351 352 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled ); 353 354 355 // We just finished running a thread, there are a few things that could have happened. 356 // 1 - Regular case : the thread has blocked and now one has scheduled it yet. 357 // 2 - Racy case : the thread has blocked but someone has already tried to schedule it. 358 // 3 - Polite Racy case : the thread has blocked, someone has already tried to schedule it, but the thread is nice and wants to go through the ready-queue any way 359 // 4 - Preempted 360 // In case 1, we may have won a race so we can't write to the state again. 361 // In case 2, we lost the race so we now own the thread. 362 // In case 3, we lost the race but can just reschedule the thread. 363 364 if(unlikely(thrd_dst->preempted != __NO_PREEMPTION)) { 365 // The thread was preempted, reschedule it and reset the flag 366 __schedule_thread( thrd_dst ); 367 break RUNNING; 386 case Release_Multi_Schedule: 387 for(int i = 0; i < lock_count; i++) { 388 unlock( *locks[i] ); 368 389 } 369 370 // set state of processor coroutine to active and the thread to inactive 371 static_assert(sizeof(thrd_dst->state) == sizeof(int)); 372 enum coroutine_state old_state = __atomic_exchange_n(&thrd_dst->state, Inactive, __ATOMIC_SEQ_CST); 373 switch(old_state) { 374 case Halted: 375 // The thread has halted, it should never be scheduled/run again, leave it back to Halted and move on 376 thrd_dst->state = Halted; 377 378 // We may need to wake someone up here since 379 unpark( this->destroyer ); 380 this->destroyer = 0p; 381 break RUNNING; 382 case Active: 383 // This is case 1, the regular case, nothing more is needed 384 break RUNNING; 385 case Rerun: 386 // This is case 2, the racy case, someone tried to run this thread before it finished blocking 387 // In this case, just run it again. 388 continue RUNNING; 389 default: 390 // This makes no sense, something is wrong abort 391 abort("Finished running a thread that was Inactive/Start/Primed %d\n", old_state); 390 for(int i = 0; i < thrd_count; i++) { 391 ScheduleThread( thrds[i] ); 392 392 } 393 } 394 395 // Just before returning to the processor, set the processor coroutine to active 396 proc_cor->state = Active; 397 } 398 399 // KERNEL_ONLY 400 void returnToKernel() { 401 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled ); 402 $coroutine * proc_cor = get_coroutine(kernelTLS.this_processor->runner); 403 $thread * thrd_src = kernelTLS.this_thread; 404 405 // Run the thread on this processor 406 { 407 int local_errno = *__volatile_errno(); 408 #if defined( __i386 ) || defined( __x86_64 ) 409 __x87_store; 410 #endif 411 verify( proc_cor->context.SP ); 412 __cfactx_switch( &thrd_src->context, &proc_cor->context ); 413 #if defined( __i386 ) || defined( __x86_64 ) 414 __x87_load; 415 #endif 416 *__volatile_errno() = local_errno; 417 } 418 419 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled ); 393 case Callback: 394 callback(); 395 default: 396 abort("KERNEL ERROR: Unexpected action to run after thread"); 397 } 420 398 } 421 399 … … 424 402 // This is the entry point for processors (kernel threads) 425 403 // It effectively constructs a coroutine by stealing the pthread stack 426 static void * __invoke_processor(void * arg) {404 static void * CtxInvokeProcessor(void * arg) { 427 405 processor * proc = (processor *) arg; 428 406 kernelTLS.this_processor = proc; 429 kernelTLS.this_thread = 0p;407 kernelTLS.this_thread = NULL; 430 408 kernelTLS.preemption_state.[enabled, disable_count] = [false, 1]; 431 409 // SKULLDUGGERY: We want to create a context for the processor coroutine … … 440 418 441 419 //Set global state 442 kernelTLS.this_thread = 0p;420 kernelTLS.this_thread = NULL; 443 421 444 422 //We now have a proper context from which to schedule threads … … 456 434 __cfaabi_dbg_print_safe("Kernel : core %p main ended (%p)\n", proc, &proc->runner); 457 435 458 return 0p; 459 } 460 461 static void Abort( int ret, const char func[] ) { 462 if ( ret ) { // pthread routines return errno values 463 abort( "%s : internal error, error(%d) %s.", func, ret, strerror( ret ) ); 464 } // if 465 } // Abort 466 467 void * __create_pthread( pthread_t * pthread, void * (*start)(void *), void * arg ) { 468 pthread_attr_t attr; 469 470 Abort( pthread_attr_init( &attr ), "pthread_attr_init" ); // initialize attribute 471 472 size_t stacksize; 473 // default stack size, normally defined by shell limit 474 Abort( pthread_attr_getstacksize( &attr, &stacksize ), "pthread_attr_getstacksize" ); 475 assert( stacksize >= PTHREAD_STACK_MIN ); 476 477 void * stack; 478 __cfaabi_dbg_debug_do( 479 stack = memalign( __page_size, stacksize + __page_size ); 480 // pthread has no mechanism to create the guard page in user supplied stack. 481 if ( mprotect( stack, __page_size, PROT_NONE ) == -1 ) { 482 abort( "mprotect : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) ); 483 } // if 484 ); 485 __cfaabi_dbg_no_debug_do( 486 stack = malloc( stacksize ); 487 ); 488 489 Abort( pthread_attr_setstack( &attr, stack, stacksize ), "pthread_attr_setstack" ); 490 491 Abort( pthread_create( pthread, &attr, start, arg ), "pthread_create" ); 492 return stack; 436 return NULL; 437 } 438 439 static void start(processor * this) { 440 __cfaabi_dbg_print_safe("Kernel : Starting core %p\n", this); 441 442 pthread_create( &this->kernel_thread, NULL, CtxInvokeProcessor, (void*)this ); 443 444 __cfaabi_dbg_print_safe("Kernel : core %p started\n", this); 493 445 } 494 446 495 447 // KERNEL_ONLY 496 static void __kernel_first_resume( processor * this ) { 497 $thread * src = mainThread; 498 $coroutine * dst = get_coroutine(this->runner); 499 500 verify( ! kernelTLS.preemption_state.enabled ); 501 502 kernelTLS.this_thread->curr_cor = dst; 448 void kernel_first_resume( processor * this ) { 449 thread_desc * src = mainThread; 450 coroutine_desc * dst = get_coroutine(this->runner); 451 452 verify( ! kernelTLS.preemption_state.enabled ); 453 503 454 __stack_prepare( &dst->stack, 65000 ); 504 __cfactx_start(main, dst, this->runner, __cfactx_invoke_coroutine);455 CtxStart(&this->runner, CtxInvokeCoroutine); 505 456 506 457 verify( ! kernelTLS.preemption_state.enabled ); … … 514 465 // context switch to specified coroutine 515 466 verify( dst->context.SP ); 516 __cfactx_switch( &src->context, &dst->context ); 517 // when __cfactx_switch returns we are back in the src coroutine 518 519 mainThread->curr_cor = &mainThread->self_cor; 467 CtxSwitch( &src->context, &dst->context ); 468 // when CtxSwitch returns we are back in the src coroutine 520 469 521 470 // set state of new coroutine to active … … 526 475 527 476 // KERNEL_ONLY 528 static void __kernel_last_resume( processor * this ) {529 $coroutine* src = &mainThread->self_cor;530 $coroutine* dst = get_coroutine(this->runner);477 void kernel_last_resume( processor * this ) { 478 coroutine_desc * src = &mainThread->self_cor; 479 coroutine_desc * dst = get_coroutine(this->runner); 531 480 532 481 verify( ! kernelTLS.preemption_state.enabled ); … … 535 484 536 485 // context switch to the processor 537 __cfactx_switch( &src->context, &dst->context );486 CtxSwitch( &src->context, &dst->context ); 538 487 } 539 488 540 489 //----------------------------------------------------------------------------- 541 490 // Scheduler routines 491 542 492 // KERNEL ONLY 543 void __schedule_thread( $thread * thrd ) with( *thrd->curr_cluster ) { 544 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled ); 545 /* paranoid */ #if defined( __CFA_WITH_VERIFY__ ) 546 /* paranoid */ if( thrd->state == Inactive || thrd->state == Start ) assertf( thrd->preempted == __NO_PREEMPTION, 547 "Error inactive thread marked as preempted, state %d, preemption %d\n", thrd->state, thrd->preempted ); 548 /* paranoid */ if( thrd->preempted != __NO_PREEMPTION ) assertf(thrd->state == Active || thrd->state == Rerun, 549 "Error preempted thread marked as not currently running, state %d, preemption %d\n", thrd->state, thrd->preempted ); 550 /* paranoid */ #endif 551 /* paranoid */ verifyf( thrd->next == 0p, "Expected null got %p", thrd->next ); 552 553 lock ( ready_queue_lock __cfaabi_dbg_ctx2 ); 554 bool was_empty = !(ready_queue != 0); 555 append( ready_queue, thrd ); 493 void ScheduleThread( thread_desc * thrd ) { 494 verify( thrd ); 495 verify( thrd->state != Halted ); 496 497 verify( ! kernelTLS.preemption_state.enabled ); 498 499 verifyf( thrd->next == NULL, "Expected null got %p", thrd->next ); 500 501 with( *thrd->curr_cluster ) { 502 lock ( ready_queue_lock __cfaabi_dbg_ctx2 ); 503 bool was_empty = !(ready_queue != 0); 504 append( ready_queue, thrd ); 505 unlock( ready_queue_lock ); 506 507 if(was_empty) { 508 lock (proc_list_lock __cfaabi_dbg_ctx2); 509 if(idles) { 510 wake_fast(idles.head); 511 } 512 unlock (proc_list_lock); 513 } 514 else if( struct processor * idle = idles.head ) { 515 wake_fast(idle); 516 } 517 518 } 519 520 verify( ! kernelTLS.preemption_state.enabled ); 521 } 522 523 // KERNEL ONLY 524 thread_desc * nextThread(cluster * this) with( *this ) { 525 verify( ! kernelTLS.preemption_state.enabled ); 526 lock( ready_queue_lock __cfaabi_dbg_ctx2 ); 527 thread_desc * head = pop_head( ready_queue ); 556 528 unlock( ready_queue_lock ); 557 558 if(was_empty) { 559 lock (proc_list_lock __cfaabi_dbg_ctx2); 560 if(idles) { 561 wake_fast(idles.head); 562 } 563 unlock (proc_list_lock); 564 } 565 else if( struct processor * idle = idles.head ) { 566 wake_fast(idle); 567 } 568 569 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled ); 529 verify( ! kernelTLS.preemption_state.enabled ); 530 return head; 531 } 532 533 void BlockInternal() { 534 disable_interrupts(); 535 verify( ! kernelTLS.preemption_state.enabled ); 536 returnToKernel(); 537 verify( ! kernelTLS.preemption_state.enabled ); 538 enable_interrupts( __cfaabi_dbg_ctx ); 539 } 540 541 void BlockInternal( __spinlock_t * lock ) { 542 disable_interrupts(); 543 with( *kernelTLS.this_processor ) { 544 finish.action_code = Release; 545 finish.lock = lock; 546 } 547 548 verify( ! kernelTLS.preemption_state.enabled ); 549 returnToKernel(); 550 verify( ! kernelTLS.preemption_state.enabled ); 551 552 enable_interrupts( __cfaabi_dbg_ctx ); 553 } 554 555 void BlockInternal( thread_desc * thrd ) { 556 disable_interrupts(); 557 with( * kernelTLS.this_processor ) { 558 finish.action_code = Schedule; 559 finish.thrd = thrd; 560 } 561 562 verify( ! kernelTLS.preemption_state.enabled ); 563 returnToKernel(); 564 verify( ! kernelTLS.preemption_state.enabled ); 565 566 enable_interrupts( __cfaabi_dbg_ctx ); 567 } 568 569 void BlockInternal( __spinlock_t * lock, thread_desc * thrd ) { 570 assert(thrd); 571 disable_interrupts(); 572 with( * kernelTLS.this_processor ) { 573 finish.action_code = Release_Schedule; 574 finish.lock = lock; 575 finish.thrd = thrd; 576 } 577 578 verify( ! kernelTLS.preemption_state.enabled ); 579 returnToKernel(); 580 verify( ! kernelTLS.preemption_state.enabled ); 581 582 enable_interrupts( __cfaabi_dbg_ctx ); 583 } 584 585 void BlockInternal(__spinlock_t * locks [], unsigned short count) { 586 disable_interrupts(); 587 with( * kernelTLS.this_processor ) { 588 finish.action_code = Release_Multi; 589 finish.locks = locks; 590 finish.lock_count = count; 591 } 592 593 verify( ! kernelTLS.preemption_state.enabled ); 594 returnToKernel(); 595 verify( ! kernelTLS.preemption_state.enabled ); 596 597 enable_interrupts( __cfaabi_dbg_ctx ); 598 } 599 600 void BlockInternal(__spinlock_t * locks [], unsigned short lock_count, thread_desc * thrds [], unsigned short thrd_count) { 601 disable_interrupts(); 602 with( *kernelTLS.this_processor ) { 603 finish.action_code = Release_Multi_Schedule; 604 finish.locks = locks; 605 finish.lock_count = lock_count; 606 finish.thrds = thrds; 607 finish.thrd_count = thrd_count; 608 } 609 610 verify( ! kernelTLS.preemption_state.enabled ); 611 returnToKernel(); 612 verify( ! kernelTLS.preemption_state.enabled ); 613 614 enable_interrupts( __cfaabi_dbg_ctx ); 615 } 616 617 void BlockInternal(__finish_callback_fptr_t callback) { 618 disable_interrupts(); 619 with( *kernelTLS.this_processor ) { 620 finish.action_code = Callback; 621 finish.callback = callback; 622 } 623 624 verify( ! kernelTLS.preemption_state.enabled ); 625 returnToKernel(); 626 verify( ! kernelTLS.preemption_state.enabled ); 627 628 enable_interrupts( __cfaabi_dbg_ctx ); 570 629 } 571 630 572 631 // KERNEL ONLY 573 static $thread * __next_thread(cluster * this) with( *this ) { 574 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled ); 575 576 lock( ready_queue_lock __cfaabi_dbg_ctx2 ); 577 $thread * head = pop_head( ready_queue ); 578 unlock( ready_queue_lock ); 579 580 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled ); 581 return head; 582 } 583 584 void unpark( $thread * thrd ) { 585 if( !thrd ) return; 586 587 disable_interrupts(); 588 static_assert(sizeof(thrd->state) == sizeof(int)); 589 enum coroutine_state old_state = __atomic_exchange_n(&thrd->state, Rerun, __ATOMIC_SEQ_CST); 590 switch(old_state) { 591 case Active: 592 // Wake won the race, the thread will reschedule/rerun itself 593 break; 594 case Inactive: 595 /* paranoid */ verify( ! thrd->preempted != __NO_PREEMPTION ); 596 597 // Wake lost the race, 598 thrd->state = Inactive; 599 __schedule_thread( thrd ); 600 break; 601 case Rerun: 602 abort("More than one thread attempted to schedule thread %p\n", thrd); 603 break; 604 case Halted: 605 case Start: 606 case Primed: 607 default: 608 // This makes no sense, something is wrong abort 609 abort(); 610 } 611 enable_interrupts( __cfaabi_dbg_ctx ); 612 } 613 614 void park( void ) { 615 /* paranoid */ verify( kernelTLS.preemption_state.enabled ); 616 disable_interrupts(); 617 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled ); 618 /* paranoid */ verify( kernelTLS.this_thread->preempted == __NO_PREEMPTION ); 632 void LeaveThread(__spinlock_t * lock, thread_desc * thrd) { 633 verify( ! kernelTLS.preemption_state.enabled ); 634 with( * kernelTLS.this_processor ) { 635 finish.action_code = thrd ? Release_Schedule : Release; 636 finish.lock = lock; 637 finish.thrd = thrd; 638 } 619 639 620 640 returnToKernel(); 621 622 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );623 enable_interrupts( __cfaabi_dbg_ctx );624 /* paranoid */ verify( kernelTLS.preemption_state.enabled );625 626 }627 628 // KERNEL ONLY629 void __leave_thread() {630 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );631 returnToKernel();632 abort();633 }634 635 // KERNEL ONLY636 bool force_yield( __Preemption_Reason reason ) {637 /* paranoid */ verify( kernelTLS.preemption_state.enabled );638 disable_interrupts();639 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );640 641 $thread * thrd = kernelTLS.this_thread;642 /* paranoid */ verify(thrd->state == Active || thrd->state == Rerun);643 644 // SKULLDUGGERY: It is possible that we are preempting this thread just before645 // it was going to park itself. If that is the case and it is already using the646 // intrusive fields then we can't use them to preempt the thread647 // If that is the case, abandon the preemption.648 bool preempted = false;649 if(thrd->next == 0p) {650 preempted = true;651 thrd->preempted = reason;652 returnToKernel();653 }654 655 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );656 enable_interrupts_noPoll();657 /* paranoid */ verify( kernelTLS.preemption_state.enabled );658 659 return preempted;660 641 } 661 642 … … 665 646 //----------------------------------------------------------------------------- 666 647 // Kernel boot procedures 667 static void __kernel_startup(void) {648 static void kernel_startup(void) { 668 649 verify( ! kernelTLS.preemption_state.enabled ); 669 650 __cfaabi_dbg_print_safe("Kernel : Starting\n"); … … 683 664 // SKULLDUGGERY: the mainThread steals the process main thread 684 665 // which will then be scheduled by the mainProcessor normally 685 mainThread = ( $thread*)&storage_mainThread;666 mainThread = (thread_desc *)&storage_mainThread; 686 667 current_stack_info_t info; 687 668 info.storage = (__stack_t*)&storage_mainThreadCtx; … … 695 676 void ?{}(processorCtx_t & this, processor * proc) { 696 677 (this.__cor){ "Processor" }; 697 this.__cor.starter = 0p;678 this.__cor.starter = NULL; 698 679 this.proc = proc; 699 680 } … … 704 685 terminated{ 0 }; 705 686 do_terminate = false; 706 preemption_alarm = 0p;687 preemption_alarm = NULL; 707 688 pending_preemption = false; 708 689 kernel_thread = pthread_self(); … … 726 707 // Add the main thread to the ready queue 727 708 // once resume is called on mainProcessor->runner the mainThread needs to be scheduled like any normal thread 728 __schedule_thread(mainThread);709 ScheduleThread(mainThread); 729 710 730 711 // SKULLDUGGERY: Force a context switch to the main processor to set the main thread's context to the current UNIX 731 // context. Hence, the main thread does not begin through __cfactx_invoke_thread, like all other threads. The trick here is that712 // context. Hence, the main thread does not begin through CtxInvokeThread, like all other threads. The trick here is that 732 713 // mainThread is on the ready queue when this call is made. 733 __kernel_first_resume( kernelTLS.this_processor );714 kernel_first_resume( kernelTLS.this_processor ); 734 715 735 716 … … 743 724 } 744 725 745 static void __kernel_shutdown(void) {726 static void kernel_shutdown(void) { 746 727 __cfaabi_dbg_print_safe("\n--------------------------------------------------\nKernel : Shutting down\n"); 747 728 … … 754 735 // which is currently here 755 736 __atomic_store_n(&mainProcessor->do_terminate, true, __ATOMIC_RELEASE); 756 __kernel_last_resume( kernelTLS.this_processor );737 kernel_last_resume( kernelTLS.this_processor ); 757 738 mainThread->self_cor.state = Halted; 758 739 … … 780 761 // Kernel Quiescing 781 762 //============================================================================================= 782 static void __halt(processor * this) with( *this ) {763 static void halt(processor * this) with( *this ) { 783 764 // verify( ! __atomic_load_n(&do_terminate, __ATOMIC_SEQ_CST) ); 784 765 … … 822 803 sigemptyset( &mask ); 823 804 sigaddset( &mask, SIGALRM ); // block SIGALRM signals 824 sigaddset( &mask, SIGUSR1 ); // block SIGALRM signals 825 sigsuspend( &mask ); // block the processor to prevent further damage during abort 826 _exit( EXIT_FAILURE ); // if processor unblocks before it is killed, terminate it 805 sigsuspend( &mask ); // block the processor to prevent further damage during abort 806 _exit( EXIT_FAILURE ); // if processor unblocks before it is killed, terminate it 827 807 } 828 808 else { … … 835 815 836 816 void kernel_abort_msg( void * kernel_data, char * abort_text, int abort_text_size ) { 837 $thread* thrd = kernel_data;817 thread_desc * thrd = kernel_data; 838 818 839 819 if(thrd) { 840 820 int len = snprintf( abort_text, abort_text_size, "Error occurred while executing thread %.256s (%p)", thrd->self_cor.name, thrd ); 841 __cfaabi_ bits_write( STDERR_FILENO,abort_text, len );821 __cfaabi_dbg_bits_write( abort_text, len ); 842 822 843 823 if ( &thrd->self_cor != thrd->curr_cor ) { 844 824 len = snprintf( abort_text, abort_text_size, " in coroutine %.256s (%p).\n", thrd->curr_cor->name, thrd->curr_cor ); 845 __cfaabi_ bits_write( STDERR_FILENO,abort_text, len );825 __cfaabi_dbg_bits_write( abort_text, len ); 846 826 } 847 827 else { 848 __cfaabi_ bits_write( STDERR_FILENO,".\n", 2 );828 __cfaabi_dbg_bits_write( ".\n", 2 ); 849 829 } 850 830 } 851 831 else { 852 832 int len = snprintf( abort_text, abort_text_size, "Error occurred outside of any thread.\n" ); 853 __cfaabi_ bits_write( STDERR_FILENO,abort_text, len );833 __cfaabi_dbg_bits_write( abort_text, len ); 854 834 } 855 835 } … … 862 842 863 843 extern "C" { 864 void __cfaabi_ bits_acquire() {844 void __cfaabi_dbg_bits_acquire() { 865 845 lock( kernel_debug_lock __cfaabi_dbg_ctx2 ); 866 846 } 867 847 868 void __cfaabi_ bits_release() {848 void __cfaabi_dbg_bits_release() { 869 849 unlock( kernel_debug_lock ); 870 850 } … … 891 871 892 872 // atomically release spin lock and block 893 unlock( lock ); 894 park(); 873 BlockInternal( &lock ); 895 874 } 896 875 else { … … 900 879 901 880 void V(semaphore & this) with( this ) { 902 $thread * thrd = 0p;881 thread_desc * thrd = NULL; 903 882 lock( lock __cfaabi_dbg_ctx2 ); 904 883 count += 1; … … 911 890 912 891 // make new owner 913 unpark( thrd );892 WakeThread( thrd ); 914 893 } 915 894 … … 928 907 } 929 908 930 void doregister( cluster * cltr, $thread& thrd ) {909 void doregister( cluster * cltr, thread_desc & thrd ) { 931 910 lock (cltr->thread_list_lock __cfaabi_dbg_ctx2); 932 911 cltr->nthreads += 1; … … 935 914 } 936 915 937 void unregister( cluster * cltr, $thread& thrd ) {916 void unregister( cluster * cltr, thread_desc & thrd ) { 938 917 lock (cltr->thread_list_lock __cfaabi_dbg_ctx2); 939 918 remove(cltr->threads, thrd ); … … 960 939 __cfaabi_dbg_debug_do( 961 940 extern "C" { 962 void __cfaabi_dbg_record(__spinlock_t & this, const char prev_name[]) {941 void __cfaabi_dbg_record(__spinlock_t & this, const char * prev_name) { 963 942 this.prev_name = prev_name; 964 943 this.prev_thrd = kernelTLS.this_thread; … … 969 948 //----------------------------------------------------------------------------- 970 949 // Debug 971 bool threading_enabled(void) __attribute__((const)){950 bool threading_enabled(void) { 972 951 return true; 973 952 } -
libcfa/src/concurrency/kernel.hfa
r3d5701e r9fb8f01 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 12:29:26 202013 // Update Count : 2212 // Last Modified On : Sat Jun 22 11:39:17 2019 13 // Update Count : 16 14 14 // 15 15 … … 20 20 #include "invoke.h" 21 21 #include "time_t.hfa" 22 #include "coroutine.hfa"23 22 24 23 extern "C" { … … 32 31 __spinlock_t lock; 33 32 int count; 34 __queue_t( $thread) waiting;33 __queue_t(thread_desc) waiting; 35 34 }; 36 35 … … 44 43 // Processor 45 44 extern struct cluster * mainCluster; 45 46 enum FinishOpCode { No_Action, Release, Schedule, Release_Schedule, Release_Multi, Release_Multi_Schedule, Callback }; 47 48 typedef void (*__finish_callback_fptr_t)(void); 49 50 //TODO use union, many of these fields are mutually exclusive (i.e. MULTI vs NOMULTI) 51 struct FinishAction { 52 FinishOpCode action_code; 53 /* 54 // Union of possible actions 55 union { 56 // Option 1 : locks and threads 57 struct { 58 // 1 thread or N thread 59 union { 60 thread_desc * thrd; 61 struct { 62 thread_desc ** thrds; 63 unsigned short thrd_count; 64 }; 65 }; 66 // 1 lock or N lock 67 union { 68 __spinlock_t * lock; 69 struct { 70 __spinlock_t ** locks; 71 unsigned short lock_count; 72 }; 73 }; 74 }; 75 // Option 2 : action pointer 76 __finish_callback_fptr_t callback; 77 }; 78 /*/ 79 thread_desc * thrd; 80 thread_desc ** thrds; 81 unsigned short thrd_count; 82 __spinlock_t * lock; 83 __spinlock_t ** locks; 84 unsigned short lock_count; 85 __finish_callback_fptr_t callback; 86 //*/ 87 }; 88 static inline void ?{}(FinishAction & this) { 89 this.action_code = No_Action; 90 this.thrd = NULL; 91 this.lock = NULL; 92 } 93 static inline void ^?{}(FinishAction &) {} 46 94 47 95 // Processor … … 67 115 // RunThread data 68 116 // Action to do after a thread is ran 69 $thread * destroyer;117 struct FinishAction finish; 70 118 71 119 // Preemption data … … 85 133 // Termination synchronisation 86 134 semaphore terminated; 87 88 // pthread Stack89 void * stack;90 135 91 136 // Link lists fields … … 101 146 }; 102 147 103 void ?{}(processor & this, const char name[], struct cluster & cltr);148 void ?{}(processor & this, const char * name, struct cluster & cltr); 104 149 void ^?{}(processor & this); 105 150 106 151 static inline void ?{}(processor & this) { this{ "Anonymous Processor", *mainCluster}; } 107 152 static inline void ?{}(processor & this, struct cluster & cltr) { this{ "Anonymous Processor", cltr}; } 108 static inline void ?{}(processor & this, const char name[]) { this{name, *mainCluster }; } 109 110 static inline [processor *&, processor *& ] __get( processor & this ) __attribute__((const)) { return this.node.[next, prev]; } 153 static inline void ?{}(processor & this, const char * name) { this{name, *mainCluster }; } 154 155 static inline [processor *&, processor *& ] __get( processor & this ) { 156 return this.node.[next, prev]; 157 } 111 158 112 159 //----------------------------------------------------------------------------- … … 117 164 118 165 // Ready queue for threads 119 __queue_t( $thread) ready_queue;166 __queue_t(thread_desc) ready_queue; 120 167 121 168 // Name of the cluster … … 133 180 // List of threads 134 181 __spinlock_t thread_list_lock; 135 __dllist_t(struct $thread) threads;182 __dllist_t(struct thread_desc) threads; 136 183 unsigned int nthreads; 137 184 … … 144 191 extern Duration default_preemption(); 145 192 146 void ?{} (cluster & this, const char name[], Duration preemption_rate);193 void ?{} (cluster & this, const char * name, Duration preemption_rate); 147 194 void ^?{}(cluster & this); 148 195 149 196 static inline void ?{} (cluster & this) { this{"Anonymous Cluster", default_preemption()}; } 150 197 static inline void ?{} (cluster & this, Duration preemption_rate) { this{"Anonymous Cluster", preemption_rate}; } 151 static inline void ?{} (cluster & this, const char name[]) { this{name, default_preemption()}; } 152 153 static inline [cluster *&, cluster *& ] __get( cluster & this ) __attribute__((const)) { return this.node.[next, prev]; } 198 static inline void ?{} (cluster & this, const char * name) { this{name, default_preemption()}; } 199 200 static inline [cluster *&, cluster *& ] __get( cluster & this ) { 201 return this.node.[next, prev]; 202 } 154 203 155 204 static inline struct processor * active_processor() { return TL_GET( this_processor ); } // UNSAFE -
libcfa/src/concurrency/kernel_private.hfa
r3d5701e r9fb8f01 10 10 // Created On : Mon Feb 13 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Nov 30 19:25:02 201913 // Update Count : 812 // Last Modified On : Thu Mar 29 14:06:40 2018 13 // Update Count : 3 14 14 // 15 15 … … 31 31 } 32 32 33 void __schedule_thread( $thread * ) __attribute__((nonnull (1))); 33 void ScheduleThread( thread_desc * ); 34 static inline void WakeThread( thread_desc * thrd ) { 35 if( !thrd ) return; 36 37 disable_interrupts(); 38 ScheduleThread( thrd ); 39 enable_interrupts( __cfaabi_dbg_ctx ); 40 } 41 thread_desc * nextThread(cluster * this); 34 42 35 43 //Block current thread and release/wake-up the following resources 36 void __leave_thread() __attribute__((noreturn)); 44 void BlockInternal(void); 45 void BlockInternal(__spinlock_t * lock); 46 void BlockInternal(thread_desc * thrd); 47 void BlockInternal(__spinlock_t * lock, thread_desc * thrd); 48 void BlockInternal(__spinlock_t * locks [], unsigned short count); 49 void BlockInternal(__spinlock_t * locks [], unsigned short count, thread_desc * thrds [], unsigned short thrd_count); 50 void BlockInternal(__finish_callback_fptr_t callback); 51 void LeaveThread(__spinlock_t * lock, thread_desc * thrd); 37 52 38 53 //----------------------------------------------------------------------------- 39 54 // Processor 40 55 void main(processorCtx_t *); 41 42 void * __create_pthread( pthread_t *, void * (*)(void *), void * );43 56 44 57 static inline void wake_fast(processor * this) { … … 71 84 // Threads 72 85 extern "C" { 73 void __cfactx_invoke_thread(void (*main)(void *), void * this); 86 forall(dtype T | is_thread(T)) 87 void CtxInvokeThread(T * this); 74 88 } 75 89 90 extern void ThreadCtxSwitch(coroutine_desc * src, coroutine_desc * dst); 91 76 92 __cfaabi_dbg_debug_do( 77 extern void __cfaabi_dbg_thread_register ( $thread* thrd );78 extern void __cfaabi_dbg_thread_unregister( $thread* thrd );93 extern void __cfaabi_dbg_thread_register ( thread_desc * thrd ); 94 extern void __cfaabi_dbg_thread_unregister( thread_desc * thrd ); 79 95 ) 80 96 … … 83 99 #define KERNEL_STORAGE(T,X) static char storage_##X[sizeof(T)] 84 100 85 static inline uint32_t __tls_rand() {86 kernelTLS.rand_seed ^= kernelTLS.rand_seed << 6;87 kernelTLS.rand_seed ^= kernelTLS.rand_seed >> 21;88 kernelTLS.rand_seed ^= kernelTLS.rand_seed << 7;89 return kernelTLS.rand_seed;90 }91 92 101 93 102 void doregister( struct cluster & cltr ); 94 103 void unregister( struct cluster & cltr ); 95 104 96 void doregister( struct cluster * cltr, struct $thread& thrd );97 void unregister( struct cluster * cltr, struct $thread& thrd );105 void doregister( struct cluster * cltr, struct thread_desc & thrd ); 106 void unregister( struct cluster * cltr, struct thread_desc & thrd ); 98 107 99 108 void doregister( struct cluster * cltr, struct processor * proc ); -
libcfa/src/concurrency/monitor.cfa
r3d5701e r9fb8f01 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // $monitor.c --7 // monitor_desc.c -- 8 8 // 9 9 // Author : Thierry Delisle 10 10 // Created On : Thd Feb 23 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 4 07:55:14 201913 // Update Count : 1012 // Last Modified On : Fri Mar 30 14:30:26 2018 13 // Update Count : 9 14 14 // 15 15 … … 27 27 //----------------------------------------------------------------------------- 28 28 // Forward declarations 29 static inline void __set_owner ( $monitor * this, $thread* owner );30 static inline void __set_owner ( $monitor * storage [], __lock_size_t count, $thread* owner );31 static inline void set_mask ( $monitor* storage [], __lock_size_t count, const __waitfor_mask_t & mask );32 static inline void reset_mask( $monitor* this );33 34 static inline $thread * next_thread( $monitor* this );35 static inline bool is_accepted( $monitor* this, const __monitor_group_t & monitors );29 static inline void set_owner ( monitor_desc * this, thread_desc * owner ); 30 static inline void set_owner ( monitor_desc * storage [], __lock_size_t count, thread_desc * owner ); 31 static inline void set_mask ( monitor_desc * storage [], __lock_size_t count, const __waitfor_mask_t & mask ); 32 static inline void reset_mask( monitor_desc * this ); 33 34 static inline thread_desc * next_thread( monitor_desc * this ); 35 static inline bool is_accepted( monitor_desc * this, const __monitor_group_t & monitors ); 36 36 37 37 static inline void lock_all ( __spinlock_t * locks [], __lock_size_t count ); 38 static inline void lock_all ( $monitor* source [], __spinlock_t * /*out*/ locks [], __lock_size_t count );38 static inline void lock_all ( monitor_desc * source [], __spinlock_t * /*out*/ locks [], __lock_size_t count ); 39 39 static inline void unlock_all( __spinlock_t * locks [], __lock_size_t count ); 40 static inline void unlock_all( $monitor* locks [], __lock_size_t count );41 42 static inline void save ( $monitor* ctx [], __lock_size_t count, __spinlock_t * locks [], unsigned int /*out*/ recursions [], __waitfor_mask_t /*out*/ masks [] );43 static inline void restore( $monitor* ctx [], __lock_size_t count, __spinlock_t * locks [], unsigned int /*in */ recursions [], __waitfor_mask_t /*in */ masks [] );44 45 static inline void init ( __lock_size_t count, $monitor* monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] );46 static inline void init_push( __lock_size_t count, $monitor* monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] );47 48 static inline $thread* check_condition ( __condition_criterion_t * );40 static inline void unlock_all( monitor_desc * locks [], __lock_size_t count ); 41 42 static inline void save ( monitor_desc * ctx [], __lock_size_t count, __spinlock_t * locks [], unsigned int /*out*/ recursions [], __waitfor_mask_t /*out*/ masks [] ); 43 static inline void restore( monitor_desc * ctx [], __lock_size_t count, __spinlock_t * locks [], unsigned int /*in */ recursions [], __waitfor_mask_t /*in */ masks [] ); 44 45 static inline void init ( __lock_size_t count, monitor_desc * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] ); 46 static inline void init_push( __lock_size_t count, monitor_desc * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] ); 47 48 static inline thread_desc * check_condition ( __condition_criterion_t * ); 49 49 static inline void brand_condition ( condition & ); 50 static inline [ $thread *, int] search_entry_queue( const __waitfor_mask_t &, $monitor* monitors [], __lock_size_t count );50 static inline [thread_desc *, int] search_entry_queue( const __waitfor_mask_t &, monitor_desc * monitors [], __lock_size_t count ); 51 51 52 52 forall(dtype T | sized( T )) 53 53 static inline __lock_size_t insert_unique( T * array [], __lock_size_t & size, T * val ); 54 54 static inline __lock_size_t count_max ( const __waitfor_mask_t & mask ); 55 static inline __lock_size_t aggregate ( $monitor* storage [], const __waitfor_mask_t & mask );55 static inline __lock_size_t aggregate ( monitor_desc * storage [], const __waitfor_mask_t & mask ); 56 56 57 57 //----------------------------------------------------------------------------- … … 68 68 69 69 #define monitor_ctx( mons, cnt ) /* Define that create the necessary struct for internal/external scheduling operations */ \ 70 $monitor** monitors = mons; /* Save the targeted monitors */ \70 monitor_desc ** monitors = mons; /* Save the targeted monitors */ \ 71 71 __lock_size_t count = cnt; /* Save the count to a local variable */ \ 72 72 unsigned int recursions[ count ]; /* Save the current recursion levels to restore them later */ \ … … 80 80 //----------------------------------------------------------------------------- 81 81 // Enter/Leave routines 82 // Enter single monitor 83 static void __enter( $monitor * this, const __monitor_group_t & group ) { 84 // Lock the monitor spinlock 85 lock( this->lock __cfaabi_dbg_ctx2 ); 86 // Interrupts disable inside critical section 87 $thread * thrd = kernelTLS.this_thread; 88 89 __cfaabi_dbg_print_safe( "Kernel : %10p Entering mon %p (%p)\n", thrd, this, this->owner); 90 91 if( !this->owner ) { 92 // No one has the monitor, just take it 93 __set_owner( this, thrd ); 94 95 __cfaabi_dbg_print_safe( "Kernel : mon is free \n" ); 96 } 97 else if( this->owner == thrd) { 98 // We already have the monitor, just note how many times we took it 99 this->recursion += 1; 100 101 __cfaabi_dbg_print_safe( "Kernel : mon already owned \n" ); 102 } 103 else if( is_accepted( this, group) ) { 104 // Some one was waiting for us, enter 105 __set_owner( this, thrd ); 106 107 // Reset mask 108 reset_mask( this ); 109 110 __cfaabi_dbg_print_safe( "Kernel : mon accepts \n" ); 111 } 112 else { 113 __cfaabi_dbg_print_safe( "Kernel : blocking \n" ); 114 115 // Some one else has the monitor, wait in line for it 116 /* paranoid */ verify( thrd->next == 0p ); 117 append( this->entry_queue, thrd ); 118 /* paranoid */ verify( thrd->next == 1p ); 119 120 unlock( this->lock ); 121 park(); 82 83 84 extern "C" { 85 // Enter single monitor 86 static void __enter_monitor_desc( monitor_desc * this, const __monitor_group_t & group ) { 87 // Lock the monitor spinlock 88 lock( this->lock __cfaabi_dbg_ctx2 ); 89 // Interrupts disable inside critical section 90 thread_desc * thrd = kernelTLS.this_thread; 91 92 __cfaabi_dbg_print_safe( "Kernel : %10p Entering mon %p (%p)\n", thrd, this, this->owner); 93 94 if( !this->owner ) { 95 // No one has the monitor, just take it 96 set_owner( this, thrd ); 97 98 __cfaabi_dbg_print_safe( "Kernel : mon is free \n" ); 99 } 100 else if( this->owner == thrd) { 101 // We already have the monitor, just note how many times we took it 102 this->recursion += 1; 103 104 __cfaabi_dbg_print_safe( "Kernel : mon already owned \n" ); 105 } 106 else if( is_accepted( this, group) ) { 107 // Some one was waiting for us, enter 108 set_owner( this, thrd ); 109 110 // Reset mask 111 reset_mask( this ); 112 113 __cfaabi_dbg_print_safe( "Kernel : mon accepts \n" ); 114 } 115 else { 116 __cfaabi_dbg_print_safe( "Kernel : blocking \n" ); 117 118 // Some one else has the monitor, wait in line for it 119 append( this->entry_queue, thrd ); 120 121 BlockInternal( &this->lock ); 122 123 __cfaabi_dbg_print_safe( "Kernel : %10p Entered mon %p\n", thrd, this); 124 125 // BlockInternal will unlock spinlock, no need to unlock ourselves 126 return; 127 } 122 128 123 129 __cfaabi_dbg_print_safe( "Kernel : %10p Entered mon %p\n", thrd, this); 124 130 125 /* paranoid */ verifyf( kernelTLS.this_thread == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", kernelTLS.this_thread, this->owner, this->recursion, this ); 126 return; 127 } 128 129 __cfaabi_dbg_print_safe( "Kernel : %10p Entered mon %p\n", thrd, this); 130 131 /* paranoid */ verifyf( kernelTLS.this_thread == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", kernelTLS.this_thread, this->owner, this->recursion, this ); 132 /* paranoid */ verify( this->lock.lock ); 133 134 // Release the lock and leave 135 unlock( this->lock ); 136 return; 137 } 138 139 static void __dtor_enter( $monitor * this, fptr_t func ) { 140 // Lock the monitor spinlock 141 lock( this->lock __cfaabi_dbg_ctx2 ); 142 // Interrupts disable inside critical section 143 $thread * thrd = kernelTLS.this_thread; 144 145 __cfaabi_dbg_print_safe( "Kernel : %10p Entering dtor for mon %p (%p)\n", thrd, this, this->owner); 146 147 148 if( !this->owner ) { 149 __cfaabi_dbg_print_safe( "Kernel : Destroying free mon %p\n", this); 150 151 // No one has the monitor, just take it 152 __set_owner( this, thrd ); 153 154 verifyf( kernelTLS.this_thread == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", kernelTLS.this_thread, this->owner, this->recursion, this ); 155 131 // Release the lock and leave 156 132 unlock( this->lock ); 157 133 return; 158 134 } 159 else if( this->owner == thrd) { 160 // We already have the monitor... but where about to destroy it so the nesting will fail 161 // Abort! 162 abort( "Attempt to destroy monitor %p by thread \"%.256s\" (%p) in nested mutex.", this, thrd->self_cor.name, thrd ); 163 } 164 165 __lock_size_t count = 1; 166 $monitor ** monitors = &this; 167 __monitor_group_t group = { &this, 1, func }; 168 if( is_accepted( this, group) ) { 169 __cfaabi_dbg_print_safe( "Kernel : mon accepts dtor, block and signal it \n" ); 170 171 // Wake the thread that is waiting for this 172 __condition_criterion_t * urgent = pop( this->signal_stack ); 173 /* paranoid */ verify( urgent ); 174 175 // Reset mask 176 reset_mask( this ); 177 178 // Create the node specific to this wait operation 179 wait_ctx_primed( thrd, 0 ) 180 181 // Some one else has the monitor, wait for him to finish and then run 135 136 static void __enter_monitor_dtor( monitor_desc * this, fptr_t func ) { 137 // Lock the monitor spinlock 138 lock( this->lock __cfaabi_dbg_ctx2 ); 139 // Interrupts disable inside critical section 140 thread_desc * thrd = kernelTLS.this_thread; 141 142 __cfaabi_dbg_print_safe( "Kernel : %10p Entering dtor for mon %p (%p)\n", thrd, this, this->owner); 143 144 145 if( !this->owner ) { 146 __cfaabi_dbg_print_safe( "Kernel : Destroying free mon %p\n", this); 147 148 // No one has the monitor, just take it 149 set_owner( this, thrd ); 150 151 unlock( this->lock ); 152 return; 153 } 154 else if( this->owner == thrd) { 155 // We already have the monitor... but where about to destroy it so the nesting will fail 156 // Abort! 157 abort( "Attempt to destroy monitor %p by thread \"%.256s\" (%p) in nested mutex.", this, thrd->self_cor.name, thrd ); 158 } 159 160 __lock_size_t count = 1; 161 monitor_desc ** monitors = &this; 162 __monitor_group_t group = { &this, 1, func }; 163 if( is_accepted( this, group) ) { 164 __cfaabi_dbg_print_safe( "Kernel : mon accepts dtor, block and signal it \n" ); 165 166 // Wake the thread that is waiting for this 167 __condition_criterion_t * urgent = pop( this->signal_stack ); 168 verify( urgent ); 169 170 // Reset mask 171 reset_mask( this ); 172 173 // Create the node specific to this wait operation 174 wait_ctx_primed( thrd, 0 ) 175 176 // Some one else has the monitor, wait for him to finish and then run 177 BlockInternal( &this->lock, urgent->owner->waiting_thread ); 178 179 // Some one was waiting for us, enter 180 set_owner( this, thrd ); 181 } 182 else { 183 __cfaabi_dbg_print_safe( "Kernel : blocking \n" ); 184 185 wait_ctx( thrd, 0 ) 186 this->dtor_node = &waiter; 187 188 // Some one else has the monitor, wait in line for it 189 append( this->entry_queue, thrd ); 190 BlockInternal( &this->lock ); 191 192 // BlockInternal will unlock spinlock, no need to unlock ourselves 193 return; 194 } 195 196 __cfaabi_dbg_print_safe( "Kernel : Destroying %p\n", this); 197 198 } 199 200 // Leave single monitor 201 void __leave_monitor_desc( monitor_desc * this ) { 202 // Lock the monitor spinlock 203 lock( this->lock __cfaabi_dbg_ctx2 ); 204 205 __cfaabi_dbg_print_safe( "Kernel : %10p Leaving mon %p (%p)\n", kernelTLS.this_thread, this, this->owner); 206 207 verifyf( kernelTLS.this_thread == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", kernelTLS.this_thread, this->owner, this->recursion, this ); 208 209 // Leaving a recursion level, decrement the counter 210 this->recursion -= 1; 211 212 // If we haven't left the last level of recursion 213 // it means we don't need to do anything 214 if( this->recursion != 0) { 215 __cfaabi_dbg_print_safe( "Kernel : recursion still %d\n", this->recursion); 216 unlock( this->lock ); 217 return; 218 } 219 220 // Get the next thread, will be null on low contention monitor 221 thread_desc * new_owner = next_thread( this ); 222 223 // We can now let other threads in safely 182 224 unlock( this->lock ); 183 225 184 // Release the next thread 185 /* paranoid */ verifyf( urgent->owner->waiting_thread == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", kernelTLS.this_thread, this->owner, this->recursion, this ); 186 unpark( urgent->owner->waiting_thread ); 187 188 // Park current thread waiting 189 park(); 190 191 // Some one was waiting for us, enter 192 /* paranoid */ verifyf( kernelTLS.this_thread == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", kernelTLS.this_thread, this->owner, this->recursion, this ); 193 } 194 else { 195 __cfaabi_dbg_print_safe( "Kernel : blocking \n" ); 196 197 wait_ctx( thrd, 0 ) 198 this->dtor_node = &waiter; 199 200 // Some one else has the monitor, wait in line for it 201 /* paranoid */ verify( thrd->next == 0p ); 202 append( this->entry_queue, thrd ); 203 /* paranoid */ verify( thrd->next == 1p ); 204 unlock( this->lock ); 205 206 // Park current thread waiting 207 park(); 208 209 /* paranoid */ verifyf( kernelTLS.this_thread == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", kernelTLS.this_thread, this->owner, this->recursion, this ); 210 return; 211 } 212 213 __cfaabi_dbg_print_safe( "Kernel : Destroying %p\n", this); 214 215 } 216 217 // Leave single monitor 218 void __leave( $monitor * this ) { 219 // Lock the monitor spinlock 220 lock( this->lock __cfaabi_dbg_ctx2 ); 221 222 __cfaabi_dbg_print_safe( "Kernel : %10p Leaving mon %p (%p)\n", kernelTLS.this_thread, this, this->owner); 223 224 /* paranoid */ verifyf( kernelTLS.this_thread == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", kernelTLS.this_thread, this->owner, this->recursion, this ); 225 226 // Leaving a recursion level, decrement the counter 227 this->recursion -= 1; 228 229 // If we haven't left the last level of recursion 230 // it means we don't need to do anything 231 if( this->recursion != 0) { 232 __cfaabi_dbg_print_safe( "Kernel : recursion still %d\n", this->recursion); 233 unlock( this->lock ); 234 return; 235 } 236 237 // Get the next thread, will be null on low contention monitor 238 $thread * new_owner = next_thread( this ); 239 240 // Check the new owner is consistent with who we wake-up 241 // new_owner might be null even if someone owns the monitor when the owner is still waiting for another monitor 242 /* paranoid */ verifyf( !new_owner || new_owner == this->owner, "Expected owner to be %p, got %p (m: %p)", new_owner, this->owner, this ); 243 244 // We can now let other threads in safely 245 unlock( this->lock ); 246 247 //We need to wake-up the thread 248 /* paranoid */ verifyf( !new_owner || new_owner == this->owner, "Expected owner to be %p, got %p (m: %p)", new_owner, this->owner, this ); 249 unpark( new_owner ); 250 } 251 252 // Leave single monitor for the last time 253 void __dtor_leave( $monitor * this ) { 254 __cfaabi_dbg_debug_do( 255 if( TL_GET( this_thread ) != this->owner ) { 256 abort( "Destroyed monitor %p has inconsistent owner, expected %p got %p.\n", this, TL_GET( this_thread ), this->owner); 257 } 258 if( this->recursion != 1 ) { 259 abort( "Destroyed monitor %p has %d outstanding nested calls.\n", this, this->recursion - 1); 260 } 261 ) 262 } 263 264 extern "C" { 226 //We need to wake-up the thread 227 WakeThread( new_owner ); 228 } 229 230 // Leave single monitor for the last time 231 void __leave_dtor_monitor_desc( monitor_desc * this ) { 232 __cfaabi_dbg_debug_do( 233 if( TL_GET( this_thread ) != this->owner ) { 234 abort( "Destroyed monitor %p has inconsistent owner, expected %p got %p.\n", this, TL_GET( this_thread ), this->owner); 235 } 236 if( this->recursion != 1 ) { 237 abort( "Destroyed monitor %p has %d outstanding nested calls.\n", this, this->recursion - 1); 238 } 239 ) 240 } 241 265 242 // Leave the thread monitor 266 243 // last routine called by a thread. 267 244 // Should never return 268 void __cfactx_thrd_leave() { 269 $thread * thrd = TL_GET( this_thread ); 270 $monitor * this = &thrd->self_mon; 245 void __leave_thread_monitor( thread_desc * thrd ) { 246 monitor_desc * this = &thrd->self_mon; 271 247 272 248 // Lock the monitor now … … 275 251 disable_interrupts(); 276 252 277 thrd->s tate = Halted;278 279 /* paranoid */verifyf( thrd == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", thrd, this->owner, this->recursion, this );253 thrd->self_cor.state = Halted; 254 255 verifyf( thrd == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", thrd, this->owner, this->recursion, this ); 280 256 281 257 // Leaving a recursion level, decrement the counter … … 287 263 288 264 // Fetch the next thread, can be null 289 $thread * new_owner = next_thread( this ); 290 291 // Release the monitor lock 292 unlock( this->lock ); 293 294 // Unpark the next owner if needed 295 /* paranoid */ verifyf( !new_owner || new_owner == this->owner, "Expected owner to be %p, got %p (m: %p)", new_owner, this->owner, this ); 296 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled ); 297 /* paranoid */ verify( ! kernelTLS.this_processor->destroyer ); 298 /* paranoid */ verify( thrd->state == Halted ); 299 300 kernelTLS.this_processor->destroyer = new_owner; 301 302 // Leave the thread 303 __leave_thread(); 265 thread_desc * new_owner = next_thread( this ); 266 267 // Leave the thread, this will unlock the spinlock 268 // Use leave thread instead of BlockInternal which is 269 // specialized for this case and supports null new_owner 270 LeaveThread( &this->lock, new_owner ); 304 271 305 272 // Control flow should never reach here! … … 311 278 static inline void enter( __monitor_group_t monitors ) { 312 279 for( __lock_size_t i = 0; i < monitors.size; i++) { 313 __enter ( monitors[i], monitors );280 __enter_monitor_desc( monitors[i], monitors ); 314 281 } 315 282 } … … 317 284 // Leave multiple monitor 318 285 // relies on the monitor array being sorted 319 static inline void leave( $monitor* monitors [], __lock_size_t count) {286 static inline void leave(monitor_desc * monitors [], __lock_size_t count) { 320 287 for( __lock_size_t i = count - 1; i >= 0; i--) { 321 __leave ( monitors[i] );288 __leave_monitor_desc( monitors[i] ); 322 289 } 323 290 } … … 325 292 // Ctor for monitor guard 326 293 // Sorts monitors before entering 327 void ?{}( monitor_guard_t & this, $monitor* m [], __lock_size_t count, fptr_t func ) {328 $thread* thrd = TL_GET( this_thread );294 void ?{}( monitor_guard_t & this, monitor_desc * m [], __lock_size_t count, fptr_t func ) { 295 thread_desc * thrd = TL_GET( this_thread ); 329 296 330 297 // Store current array … … 366 333 // Ctor for monitor guard 367 334 // Sorts monitors before entering 368 void ?{}( monitor_dtor_guard_t & this, $monitor* m [], fptr_t func ) {335 void ?{}( monitor_dtor_guard_t & this, monitor_desc * m [], fptr_t func ) { 369 336 // optimization 370 $thread* thrd = TL_GET( this_thread );337 thread_desc * thrd = TL_GET( this_thread ); 371 338 372 339 // Store current array … … 379 346 (thrd->monitors){m, 1, func}; 380 347 381 __ dtor_enter( this.m, func );348 __enter_monitor_dtor( this.m, func ); 382 349 } 383 350 … … 385 352 void ^?{}( monitor_dtor_guard_t & this ) { 386 353 // Leave the monitors in order 387 __ dtor_leave( this.m );354 __leave_dtor_monitor_desc( this.m ); 388 355 389 356 // Restore thread context … … 393 360 //----------------------------------------------------------------------------- 394 361 // Internal scheduling types 395 void ?{}(__condition_node_t & this, $thread* waiting_thread, __lock_size_t count, uintptr_t user_info ) {362 void ?{}(__condition_node_t & this, thread_desc * waiting_thread, __lock_size_t count, uintptr_t user_info ) { 396 363 this.waiting_thread = waiting_thread; 397 364 this.count = count; 398 this.next = 0p;365 this.next = NULL; 399 366 this.user_info = user_info; 400 367 } … … 402 369 void ?{}(__condition_criterion_t & this ) with( this ) { 403 370 ready = false; 404 target = 0p;405 owner = 0p;406 next = 0p;407 } 408 409 void ?{}(__condition_criterion_t & this, $monitor* target, __condition_node_t & owner ) {371 target = NULL; 372 owner = NULL; 373 next = NULL; 374 } 375 376 void ?{}(__condition_criterion_t & this, monitor_desc * target, __condition_node_t & owner ) { 410 377 this.ready = false; 411 378 this.target = target; 412 379 this.owner = &owner; 413 this.next = 0p;380 this.next = NULL; 414 381 } 415 382 … … 420 387 421 388 // Check that everything is as expected 422 assertf( this.monitors != 0p, "Waiting with no monitors (%p)", this.monitors );389 assertf( this.monitors != NULL, "Waiting with no monitors (%p)", this.monitors ); 423 390 verifyf( this.monitor_count != 0, "Waiting with 0 monitors (%"PRIiFAST16")", this.monitor_count ); 424 391 verifyf( this.monitor_count < 32u, "Excessive monitor count (%"PRIiFAST16")", this.monitor_count ); … … 432 399 // Append the current wait operation to the ones already queued on the condition 433 400 // We don't need locks for that since conditions must always be waited on inside monitor mutual exclusion 434 /* paranoid */ verify( waiter.next == 0p );435 401 append( this.blocked, &waiter ); 436 /* paranoid */ verify( waiter.next == 1p );437 402 438 403 // Lock all monitors (aggregates the locks as well) … … 441 406 // Find the next thread(s) to run 442 407 __lock_size_t thread_count = 0; 443 $thread* threads[ count ];408 thread_desc * threads[ count ]; 444 409 __builtin_memset( threads, 0, sizeof( threads ) ); 445 410 … … 449 414 // Remove any duplicate threads 450 415 for( __lock_size_t i = 0; i < count; i++) { 451 $thread* new_owner = next_thread( monitors[i] );416 thread_desc * new_owner = next_thread( monitors[i] ); 452 417 insert_unique( threads, thread_count, new_owner ); 453 418 } 454 419 455 // Unlock the locks, we don't need them anymore456 for(int i = 0; i < count; i++) {457 unlock( *locks[i] );458 }459 460 // Wake the threads461 for(int i = 0; i < thread_count; i++) {462 unpark( threads[i] );463 }464 465 420 // Everything is ready to go to sleep 466 park();421 BlockInternal( locks, count, threads, thread_count ); 467 422 468 423 // We are back, restore the owners and recursions … … 479 434 //Some more checking in debug 480 435 __cfaabi_dbg_debug_do( 481 $thread* this_thrd = TL_GET( this_thread );436 thread_desc * this_thrd = TL_GET( this_thread ); 482 437 if ( this.monitor_count != this_thrd->monitors.size ) { 483 438 abort( "Signal on condition %p made with different number of monitor(s), expected %zi got %zi", &this, this.monitor_count, this_thrd->monitors.size ); … … 494 449 495 450 // Lock all monitors 496 lock_all( this.monitors, 0p, count );451 lock_all( this.monitors, NULL, count ); 497 452 498 453 //Pop the head of the waiting queue … … 516 471 517 472 //Check that everything is as expected 518 verifyf( this.monitors != 0p, "Waiting with no monitors (%p)", this.monitors );473 verifyf( this.monitors != NULL, "Waiting with no monitors (%p)", this.monitors ); 519 474 verifyf( this.monitor_count != 0, "Waiting with 0 monitors (%"PRIiFAST16")", this.monitor_count ); 520 475 … … 533 488 534 489 //Find the thread to run 535 $thread * signallee = pop_head( this.blocked )->waiting_thread; 536 /* paranoid */ verify( signallee->next == 0p ); 537 __set_owner( monitors, count, signallee ); 490 thread_desc * signallee = pop_head( this.blocked )->waiting_thread; 491 set_owner( monitors, count, signallee ); 538 492 539 493 __cfaabi_dbg_print_buffer_decl( "Kernel : signal_block condition %p (s: %p)\n", &this, signallee ); 540 494 541 // unlock all the monitors542 unlock_all( locks, count );543 544 // unpark the thread we signalled545 unpark( signallee );546 547 495 //Everything is ready to go to sleep 548 park();496 BlockInternal( locks, count, &signallee, 1 ); 549 497 550 498 … … 587 535 // Create one! 588 536 __lock_size_t max = count_max( mask ); 589 $monitor* mon_storage[max];537 monitor_desc * mon_storage[max]; 590 538 __builtin_memset( mon_storage, 0, sizeof( mon_storage ) ); 591 539 __lock_size_t actual_count = aggregate( mon_storage, mask ); … … 605 553 { 606 554 // Check if the entry queue 607 $thread* next; int index;555 thread_desc * next; int index; 608 556 [next, index] = search_entry_queue( mask, monitors, count ); 609 557 … … 615 563 verifyf( accepted.size == 1, "ERROR: Accepted dtor has more than 1 mutex parameter." ); 616 564 617 $monitor* mon2dtor = accepted[0];565 monitor_desc * mon2dtor = accepted[0]; 618 566 verifyf( mon2dtor->dtor_node, "ERROR: Accepted monitor has no dtor_node." ); 619 567 … … 641 589 642 590 // Set the owners to be the next thread 643 __set_owner( monitors, count, next ); 644 645 // unlock all the monitors 646 unlock_all( locks, count ); 647 648 // unpark the thread we signalled 649 unpark( next ); 650 651 //Everything is ready to go to sleep 652 park(); 591 set_owner( monitors, count, next ); 592 593 // Everything is ready to go to sleep 594 BlockInternal( locks, count, &next, 1 ); 653 595 654 596 // We are back, restore the owners and recursions … … 688 630 } 689 631 690 // unlock all the monitors691 unlock_all( locks, count );692 693 632 //Everything is ready to go to sleep 694 park();633 BlockInternal( locks, count ); 695 634 696 635 … … 709 648 // Utilities 710 649 711 static inline void __set_owner( $monitor * this, $thread* owner ) {712 / * paranoid */ verify( this->lock.lock);650 static inline void set_owner( monitor_desc * this, thread_desc * owner ) { 651 // __cfaabi_dbg_print_safe( "Kernal : Setting owner of %p to %p ( was %p)\n", this, owner, this->owner ); 713 652 714 653 //Pass the monitor appropriately … … 719 658 } 720 659 721 static inline void __set_owner( $monitor * monitors [], __lock_size_t count, $thread * owner ) { 722 /* paranoid */ verify ( monitors[0]->lock.lock ); 723 /* paranoid */ verifyf( monitors[0]->owner == kernelTLS.this_thread, "Expected owner to be %p, got %p (r: %i, m: %p)", kernelTLS.this_thread, monitors[0]->owner, monitors[0]->recursion, monitors[0] ); 724 monitors[0]->owner = owner; 725 monitors[0]->recursion = 1; 660 static inline void set_owner( monitor_desc * monitors [], __lock_size_t count, thread_desc * owner ) { 661 monitors[0]->owner = owner; 662 monitors[0]->recursion = 1; 726 663 for( __lock_size_t i = 1; i < count; i++ ) { 727 /* paranoid */ verify ( monitors[i]->lock.lock ); 728 /* paranoid */ verifyf( monitors[i]->owner == kernelTLS.this_thread, "Expected owner to be %p, got %p (r: %i, m: %p)", kernelTLS.this_thread, monitors[i]->owner, monitors[i]->recursion, monitors[i] ); 729 monitors[i]->owner = owner; 730 monitors[i]->recursion = 0; 731 } 732 } 733 734 static inline void set_mask( $monitor * storage [], __lock_size_t count, const __waitfor_mask_t & mask ) { 664 monitors[i]->owner = owner; 665 monitors[i]->recursion = 0; 666 } 667 } 668 669 static inline void set_mask( monitor_desc * storage [], __lock_size_t count, const __waitfor_mask_t & mask ) { 735 670 for( __lock_size_t i = 0; i < count; i++) { 736 671 storage[i]->mask = mask; … … 738 673 } 739 674 740 static inline void reset_mask( $monitor* this ) {741 this->mask.accepted = 0p;742 this->mask.data = 0p;675 static inline void reset_mask( monitor_desc * this ) { 676 this->mask.accepted = NULL; 677 this->mask.data = NULL; 743 678 this->mask.size = 0; 744 679 } 745 680 746 static inline $thread * next_thread( $monitor* this ) {681 static inline thread_desc * next_thread( monitor_desc * this ) { 747 682 //Check the signaller stack 748 683 __cfaabi_dbg_print_safe( "Kernel : mon %p AS-stack top %p\n", this, this->signal_stack.top); … … 752 687 //regardless of if we are ready to baton pass, 753 688 //we need to set the monitor as in use 754 /* paranoid */ verifyf( !this->owner || kernelTLS.this_thread == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", kernelTLS.this_thread, this->owner, this->recursion, this ); 755 __set_owner( this, urgent->owner->waiting_thread ); 689 set_owner( this, urgent->owner->waiting_thread ); 756 690 757 691 return check_condition( urgent ); … … 760 694 // No signaller thread 761 695 // Get the next thread in the entry_queue 762 $thread * new_owner = pop_head( this->entry_queue ); 763 /* paranoid */ verifyf( !this->owner || kernelTLS.this_thread == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", kernelTLS.this_thread, this->owner, this->recursion, this ); 764 /* paranoid */ verify( !new_owner || new_owner->next == 0p ); 765 __set_owner( this, new_owner ); 696 thread_desc * new_owner = pop_head( this->entry_queue ); 697 set_owner( this, new_owner ); 766 698 767 699 return new_owner; 768 700 } 769 701 770 static inline bool is_accepted( $monitor* this, const __monitor_group_t & group ) {702 static inline bool is_accepted( monitor_desc * this, const __monitor_group_t & group ) { 771 703 __acceptable_t * it = this->mask.data; // Optim 772 704 __lock_size_t count = this->mask.size; … … 790 722 } 791 723 792 static inline void init( __lock_size_t count, $monitor* monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] ) {724 static inline void init( __lock_size_t count, monitor_desc * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] ) { 793 725 for( __lock_size_t i = 0; i < count; i++) { 794 726 (criteria[i]){ monitors[i], waiter }; … … 798 730 } 799 731 800 static inline void init_push( __lock_size_t count, $monitor* monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] ) {732 static inline void init_push( __lock_size_t count, monitor_desc * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] ) { 801 733 for( __lock_size_t i = 0; i < count; i++) { 802 734 (criteria[i]){ monitors[i], waiter }; … … 814 746 } 815 747 816 static inline void lock_all( $monitor* source [], __spinlock_t * /*out*/ locks [], __lock_size_t count ) {748 static inline void lock_all( monitor_desc * source [], __spinlock_t * /*out*/ locks [], __lock_size_t count ) { 817 749 for( __lock_size_t i = 0; i < count; i++ ) { 818 750 __spinlock_t * l = &source[i]->lock; … … 828 760 } 829 761 830 static inline void unlock_all( $monitor* locks [], __lock_size_t count ) {762 static inline void unlock_all( monitor_desc * locks [], __lock_size_t count ) { 831 763 for( __lock_size_t i = 0; i < count; i++ ) { 832 764 unlock( locks[i]->lock ); … … 835 767 836 768 static inline void save( 837 $monitor* ctx [],769 monitor_desc * ctx [], 838 770 __lock_size_t count, 839 771 __attribute((unused)) __spinlock_t * locks [], … … 848 780 849 781 static inline void restore( 850 $monitor* ctx [],782 monitor_desc * ctx [], 851 783 __lock_size_t count, 852 784 __spinlock_t * locks [], … … 866 798 // 2 - Checks if all the monitors are ready to run 867 799 // if so return the thread to run 868 static inline $thread* check_condition( __condition_criterion_t * target ) {800 static inline thread_desc * check_condition( __condition_criterion_t * target ) { 869 801 __condition_node_t * node = target->owner; 870 802 unsigned short count = node->count; … … 884 816 } 885 817 886 __cfaabi_dbg_print_safe( "Kernel : Runing %i (%p)\n", ready2run, ready2run ? node->waiting_thread : 0p);887 return ready2run ? node->waiting_thread : 0p;818 __cfaabi_dbg_print_safe( "Kernel : Runing %i (%p)\n", ready2run, ready2run ? node->waiting_thread : NULL ); 819 return ready2run ? node->waiting_thread : NULL; 888 820 } 889 821 890 822 static inline void brand_condition( condition & this ) { 891 $thread* thrd = TL_GET( this_thread );823 thread_desc * thrd = TL_GET( this_thread ); 892 824 if( !this.monitors ) { 893 825 // __cfaabi_dbg_print_safe( "Branding\n" ); 894 assertf( thrd->monitors.data != 0p, "No current monitor to brand condition %p", thrd->monitors.data );826 assertf( thrd->monitors.data != NULL, "No current monitor to brand condition %p", thrd->monitors.data ); 895 827 this.monitor_count = thrd->monitors.size; 896 828 897 this.monitors = ( $monitor**)malloc( this.monitor_count * sizeof( *this.monitors ) );829 this.monitors = (monitor_desc **)malloc( this.monitor_count * sizeof( *this.monitors ) ); 898 830 for( int i = 0; i < this.monitor_count; i++ ) { 899 831 this.monitors[i] = thrd->monitors[i]; … … 902 834 } 903 835 904 static inline [ $thread *, int] search_entry_queue( const __waitfor_mask_t & mask, $monitor* monitors [], __lock_size_t count ) {905 906 __queue_t( $thread) & entry_queue = monitors[0]->entry_queue;836 static inline [thread_desc *, int] search_entry_queue( const __waitfor_mask_t & mask, monitor_desc * monitors [], __lock_size_t count ) { 837 838 __queue_t(thread_desc) & entry_queue = monitors[0]->entry_queue; 907 839 908 840 // For each thread in the entry-queue 909 for( $thread** thrd_it = &entry_queue.head;910 *thrd_it != 1p;841 for( thread_desc ** thrd_it = &entry_queue.head; 842 *thrd_it; 911 843 thrd_it = &(*thrd_it)->next 912 844 ) { … … 951 883 } 952 884 953 static inline __lock_size_t aggregate( $monitor* storage [], const __waitfor_mask_t & mask ) {885 static inline __lock_size_t aggregate( monitor_desc * storage [], const __waitfor_mask_t & mask ) { 954 886 __lock_size_t size = 0; 955 887 for( __lock_size_t i = 0; i < mask.size; i++ ) { -
libcfa/src/concurrency/monitor.hfa
r3d5701e r9fb8f01 10 10 // Created On : Thd Feb 23 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 4 07:55:32 201913 // Update Count : 1 112 // Last Modified On : Sat Oct 7 18:06:45 2017 13 // Update Count : 10 14 14 // 15 15 … … 23 23 24 24 trait is_monitor(dtype T) { 25 $monitor* get_monitor( T & );25 monitor_desc * get_monitor( T & ); 26 26 void ^?{}( T & mutex ); 27 27 }; 28 28 29 static inline void ?{}( $monitor& this) with( this ) {29 static inline void ?{}(monitor_desc & this) with( this ) { 30 30 lock{}; 31 31 entry_queue{}; 32 32 signal_stack{}; 33 owner = 0p;33 owner = NULL; 34 34 recursion = 0; 35 mask.accepted = 0p;36 mask.data = 0p;35 mask.accepted = NULL; 36 mask.data = NULL; 37 37 mask.size = 0; 38 dtor_node = 0p;38 dtor_node = NULL; 39 39 } 40 40 41 static inline void ^?{}($monitor & ) {}42 43 41 struct monitor_guard_t { 44 $monitor** m;42 monitor_desc ** m; 45 43 __lock_size_t count; 46 44 __monitor_group_t prev; 47 45 }; 48 46 49 void ?{}( monitor_guard_t & this, $monitor** m, __lock_size_t count, void (*func)() );47 void ?{}( monitor_guard_t & this, monitor_desc ** m, __lock_size_t count, void (*func)() ); 50 48 void ^?{}( monitor_guard_t & this ); 51 49 52 50 struct monitor_dtor_guard_t { 53 $monitor* m;51 monitor_desc * m; 54 52 __monitor_group_t prev; 55 53 }; 56 54 57 void ?{}( monitor_dtor_guard_t & this, $monitor** m, void (*func)() );55 void ?{}( monitor_dtor_guard_t & this, monitor_desc ** m, void (*func)() ); 58 56 void ^?{}( monitor_dtor_guard_t & this ); 59 57 … … 72 70 73 71 // The monitor this criterion concerns 74 $monitor* target;72 monitor_desc * target; 75 73 76 74 // The parent node to which this criterion belongs … … 87 85 struct __condition_node_t { 88 86 // Thread that needs to be woken when all criteria are met 89 $thread* waiting_thread;87 thread_desc * waiting_thread; 90 88 91 89 // Array of criteria (Criterions are contiguous in memory) … … 106 104 } 107 105 108 void ?{}(__condition_node_t & this, $thread* waiting_thread, __lock_size_t count, uintptr_t user_info );106 void ?{}(__condition_node_t & this, thread_desc * waiting_thread, __lock_size_t count, uintptr_t user_info ); 109 107 void ?{}(__condition_criterion_t & this ); 110 void ?{}(__condition_criterion_t & this, $monitor* target, __condition_node_t * owner );108 void ?{}(__condition_criterion_t & this, monitor_desc * target, __condition_node_t * owner ); 111 109 112 110 struct condition { … … 115 113 116 114 // Array of monitor pointers (Monitors are NOT contiguous in memory) 117 $monitor** monitors;115 monitor_desc ** monitors; 118 116 119 117 // Number of monitors in the array … … 122 120 123 121 static inline void ?{}( condition & this ) { 124 this.monitors = 0p;122 this.monitors = NULL; 125 123 this.monitor_count = 0; 126 124 } … … 133 131 bool signal ( condition & this ); 134 132 bool signal_block( condition & this ); 135 static inline bool is_empty ( condition & this ) { return this.blocked.head == 1p; }133 static inline bool is_empty ( condition & this ) { return !this.blocked.head; } 136 134 uintptr_t front ( condition & this ); 137 135 -
libcfa/src/concurrency/mutex.cfa
r3d5701e r9fb8f01 11 11 // Author : Thierry Delisle 12 12 // Created On : Fri May 25 01:37:11 2018 13 // Last Modified By : Peter A. Buhr14 // Last Modified On : Wed Dec 4 09:16:39 201915 // Update Count : 113 // Last Modified By : Thierry Delisle 14 // Last Modified On : Fri May 25 01:37:51 2018 15 // Update Count : 0 16 16 // 17 17 … … 40 40 if( is_locked ) { 41 41 append( blocked_threads, kernelTLS.this_thread ); 42 unlock( lock ); 43 park(); 42 BlockInternal( &lock ); 44 43 } 45 44 else { … … 63 62 lock( this.lock __cfaabi_dbg_ctx2 ); 64 63 this.is_locked = (this.blocked_threads != 0); 65 unpark(64 WakeThread( 66 65 pop_head( this.blocked_threads ) 67 66 ); … … 74 73 this.lock{}; 75 74 this.blocked_threads{}; 76 this.owner = 0p;75 this.owner = NULL; 77 76 this.recursion_count = 0; 78 77 } … … 84 83 void lock(recursive_mutex_lock & this) with(this) { 85 84 lock( lock __cfaabi_dbg_ctx2 ); 86 if( owner == 0p) {85 if( owner == NULL ) { 87 86 owner = kernelTLS.this_thread; 88 87 recursion_count = 1; … … 95 94 else { 96 95 append( blocked_threads, kernelTLS.this_thread ); 97 unlock( lock ); 98 park(); 96 BlockInternal( &lock ); 99 97 } 100 98 } … … 103 101 bool ret = false; 104 102 lock( lock __cfaabi_dbg_ctx2 ); 105 if( owner == 0p) {103 if( owner == NULL ) { 106 104 owner = kernelTLS.this_thread; 107 105 recursion_count = 1; … … 120 118 recursion_count--; 121 119 if( recursion_count == 0 ) { 122 $thread* thrd = pop_head( blocked_threads );120 thread_desc * thrd = pop_head( blocked_threads ); 123 121 owner = thrd; 124 122 recursion_count = (thrd ? 1 : 0); 125 unpark( thrd );123 WakeThread( thrd ); 126 124 } 127 125 unlock( lock ); … … 140 138 void notify_one(condition_variable & this) with(this) { 141 139 lock( lock __cfaabi_dbg_ctx2 ); 142 unpark(140 WakeThread( 143 141 pop_head( this.blocked_threads ) 144 142 ); … … 149 147 lock( lock __cfaabi_dbg_ctx2 ); 150 148 while(this.blocked_threads) { 151 unpark(149 WakeThread( 152 150 pop_head( this.blocked_threads ) 153 151 ); … … 159 157 lock( this.lock __cfaabi_dbg_ctx2 ); 160 158 append( this.blocked_threads, kernelTLS.this_thread ); 161 unlock( this.lock ); 162 park(); 159 BlockInternal( &this.lock ); 163 160 } 164 161 … … 167 164 lock( this.lock __cfaabi_dbg_ctx2 ); 168 165 append( this.blocked_threads, kernelTLS.this_thread ); 169 unlock(l); 170 unlock(this.lock); 171 park(); 166 void __unlock(void) { 167 unlock(l); 168 unlock(this.lock); 169 } 170 BlockInternal( __unlock ); 172 171 lock(l); 173 172 } -
libcfa/src/concurrency/mutex.hfa
r3d5701e r9fb8f01 11 11 // Author : Thierry Delisle 12 12 // Created On : Fri May 25 01:24:09 2018 13 // Last Modified By : Peter A. Buhr14 // Last Modified On : Wed Dec 4 09:16:53 201915 // Update Count : 113 // Last Modified By : Thierry Delisle 14 // Last Modified On : Fri May 25 01:24:12 2018 15 // Update Count : 0 16 16 // 17 17 … … 36 36 37 37 // List of blocked threads 38 __queue_t(struct $thread) blocked_threads;38 __queue_t(struct thread_desc) blocked_threads; 39 39 40 40 // Locked flag … … 55 55 56 56 // List of blocked threads 57 __queue_t(struct $thread) blocked_threads;57 __queue_t(struct thread_desc) blocked_threads; 58 58 59 59 // Current thread owning the lock 60 struct $thread* owner;60 struct thread_desc * owner; 61 61 62 62 // Number of recursion level … … 83 83 84 84 // List of blocked threads 85 __queue_t(struct $thread) blocked_threads;85 __queue_t(struct thread_desc) blocked_threads; 86 86 }; 87 87 … … 110 110 111 111 static inline void ?{}(lock_scope(L) & this) { 112 this.locks = 0p;112 this.locks = NULL; 113 113 this.count = 0; 114 114 } -
libcfa/src/concurrency/preemption.cfa
r3d5701e r9fb8f01 10 10 // Created On : Mon Jun 5 14:20:42 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Dec 5 16:34:05 201913 // Update Count : 4312 // Last Modified On : Tue Jun 5 17:35:49 2018 13 // Update Count : 37 14 14 // 15 15 … … 24 24 #include <string.h> 25 25 #include <unistd.h> 26 #include <limits.h> // PTHREAD_STACK_MIN27 26 } 28 27 … … 39 38 // FwdDeclarations : timeout handlers 40 39 static void preempt( processor * this ); 41 static void timeout( $thread* this );40 static void timeout( thread_desc * this ); 42 41 43 42 // FwdDeclarations : Signal handlers … … 65 64 event_kernel_t * event_kernel; // kernel public handle to even kernel 66 65 static pthread_t alarm_thread; // pthread handle to alarm thread 67 static void * alarm_stack; // pthread stack for alarm thread68 66 69 67 static void ?{}(event_kernel_t & this) with( this ) { … … 83 81 // Get next expired node 84 82 static inline alarm_node_t * get_expired( alarm_list_t * alarms, Time currtime ) { 85 if( !alarms->head ) return 0p;// If no alarms return null86 if( alarms->head->alarm >= currtime ) return 0p;// If alarms head not expired return null87 return pop(alarms); // Otherwise just pop head83 if( !alarms->head ) return NULL; // If no alarms return null 84 if( alarms->head->alarm >= currtime ) return NULL; // If alarms head not expired return null 85 return pop(alarms); // Otherwise just pop head 88 86 } 89 87 90 88 // Tick one frame of the Discrete Event Simulation for alarms 91 89 static void tick_preemption() { 92 alarm_node_t * node = 0p;// Used in the while loop but cannot be declared in the while condition93 alarm_list_t * alarms = &event_kernel->alarms; // Local copy for ease of reading94 Time currtime = __kernel_get_time(); // Check current time once soeverything "happens at once"90 alarm_node_t * node = NULL; // Used in the while loop but cannot be declared in the while condition 91 alarm_list_t * alarms = &event_kernel->alarms; // Local copy for ease of reading 92 Time currtime = __kernel_get_time(); // Check current time once so we everything "happens at once" 95 93 96 94 //Loop throught every thing expired … … 184 182 185 183 // Enable interrupts by decrementing the counter 186 // If counter reaches 0, execute any pending __cfactx_switch184 // If counter reaches 0, execute any pending CtxSwitch 187 185 void enable_interrupts( __cfaabi_dbg_ctx_param ) { 188 186 processor * proc = kernelTLS.this_processor; // Cache the processor now since interrupts can start happening after the atomic store 187 thread_desc * thrd = kernelTLS.this_thread; // Cache the thread now since interrupts can start happening after the atomic store 189 188 190 189 with( kernelTLS.preemption_state ){ … … 208 207 if( proc->pending_preemption ) { 209 208 proc->pending_preemption = false; 210 force_yield( __POLL_PREEMPTION);209 BlockInternal( thrd ); 211 210 } 212 211 } … … 218 217 219 218 // Disable interrupts by incrementint the counter 220 // Don't execute any pending __cfactx_switch even if counter reaches 0219 // Don't execute any pending CtxSwitch even if counter reaches 0 221 220 void enable_interrupts_noPoll() { 222 221 unsigned short prev = kernelTLS.preemption_state.disable_count; … … 244 243 sigaddset( &mask, sig ); 245 244 246 if ( pthread_sigmask( SIG_UNBLOCK, &mask, 0p) == -1 ) {245 if ( pthread_sigmask( SIG_UNBLOCK, &mask, NULL ) == -1 ) { 247 246 abort( "internal error, pthread_sigmask" ); 248 247 } … … 255 254 sigaddset( &mask, sig ); 256 255 257 if ( pthread_sigmask( SIG_BLOCK, &mask, 0p) == -1 ) {256 if ( pthread_sigmask( SIG_BLOCK, &mask, NULL ) == -1 ) { 258 257 abort( "internal error, pthread_sigmask" ); 259 258 } … … 267 266 268 267 // reserved for future use 269 static void timeout( $thread* this ) {268 static void timeout( thread_desc * this ) { 270 269 //TODO : implement waking threads 271 270 } 272 271 273 272 // KERNEL ONLY 274 // Check if a __cfactx_switch signal handler shoud defer273 // Check if a CtxSwitch signal handler shoud defer 275 274 // If true : preemption is safe 276 275 // If false : preemption is unsafe and marked as pending … … 302 301 303 302 // Setup proper signal handlers 304 __cfaabi_sigaction( SIGUSR1, sigHandler_ctxSwitch, SA_SIGINFO | SA_RESTART ); // __cfactx_switch handler303 __cfaabi_sigaction( SIGUSR1, sigHandler_ctxSwitch, SA_SIGINFO | SA_RESTART ); // CtxSwitch handler 305 304 306 305 signal_block( SIGALRM ); 307 306 308 alarm_stack = __create_pthread( &alarm_thread, alarm_loop, 0p);307 pthread_create( &alarm_thread, NULL, alarm_loop, NULL ); 309 308 } 310 309 … … 317 316 sigset_t mask; 318 317 sigfillset( &mask ); 319 sigprocmask( SIG_BLOCK, &mask, 0p);318 sigprocmask( SIG_BLOCK, &mask, NULL ); 320 319 321 320 // Notify the alarm thread of the shutdown … … 324 323 325 324 // Wait for the preemption thread to finish 326 327 pthread_join( alarm_thread, 0p ); 328 free( alarm_stack ); 325 pthread_join( alarm_thread, NULL ); 329 326 330 327 // Preemption is now fully stopped … … 383 380 static_assert( sizeof( sigset_t ) == sizeof( cxt->uc_sigmask ), "Expected cxt->uc_sigmask to be of sigset_t" ); 384 381 #endif 385 if ( pthread_sigmask( SIG_SETMASK, (sigset_t *)&(cxt->uc_sigmask), 0p) == -1 ) {382 if ( pthread_sigmask( SIG_SETMASK, (sigset_t *)&(cxt->uc_sigmask), NULL ) == -1 ) { 386 383 abort( "internal error, sigprocmask" ); 387 384 } … … 393 390 // Preemption can occur here 394 391 395 force_yield( __ALARM_PREEMPTION ); // Do the actual __cfactx_switch392 BlockInternal( kernelTLS.this_thread ); // Do the actual CtxSwitch 396 393 } 397 394 … … 402 399 sigset_t mask; 403 400 sigfillset(&mask); 404 if ( pthread_sigmask( SIG_BLOCK, &mask, 0p) == -1 ) {401 if ( pthread_sigmask( SIG_BLOCK, &mask, NULL ) == -1 ) { 405 402 abort( "internal error, pthread_sigmask" ); 406 403 } … … 423 420 {__cfaabi_dbg_print_buffer_decl( " KERNEL: Spurious wakeup %d.\n", err );} 424 421 continue; 425 case EINVAL :422 case EINVAL : 426 423 abort( "Timeout was invalid." ); 427 424 default: … … 456 453 EXIT: 457 454 __cfaabi_dbg_print_safe( "Kernel : Preemption thread stopping\n" ); 458 return 0p;455 return NULL; 459 456 } 460 457 … … 469 466 sigset_t oldset; 470 467 int ret; 471 ret = pthread_sigmask(0, 0p, &oldset);468 ret = pthread_sigmask(0, NULL, &oldset); 472 469 if(ret != 0) { abort("ERROR sigprocmask returned %d", ret); } 473 470 -
libcfa/src/concurrency/thread.cfa
r3d5701e r9fb8f01 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 4 09:17:49 201913 // Update Count : 912 // Last Modified On : Fri Mar 30 17:19:52 2018 13 // Update Count : 8 14 14 // 15 15 … … 23 23 #include "invoke.h" 24 24 25 extern "C" { 26 #include <fenv.h> 27 #include <stddef.h> 28 } 29 30 //extern volatile thread_local processor * this_processor; 31 25 32 //----------------------------------------------------------------------------- 26 33 // Thread ctors and dtors 27 void ?{}( $thread& this, const char * const name, cluster & cl, void * storage, size_t storageSize ) with( this ) {28 context{ 0p, 0p};34 void ?{}(thread_desc & this, const char * const name, cluster & cl, void * storage, size_t storageSize ) with( this ) { 35 context{ NULL, NULL }; 29 36 self_cor{ name, storage, storageSize }; 30 37 state = Start; 31 preempted = __NO_PREEMPTION;32 38 curr_cor = &self_cor; 33 39 self_mon.owner = &this; … … 35 41 self_mon_p = &self_mon; 36 42 curr_cluster = &cl; 37 next = 0p;43 next = NULL; 38 44 39 node.next = 0p;40 node.prev = 0p;45 node.next = NULL; 46 node.prev = NULL; 41 47 doregister(curr_cluster, this); 42 48 … … 44 50 } 45 51 46 void ^?{}( $thread& this) with( this ) {52 void ^?{}(thread_desc& this) with( this ) { 47 53 unregister(curr_cluster, this); 48 54 ^self_cor{}; 49 55 } 50 56 51 //-----------------------------------------------------------------------------52 // Starting and stopping threads53 forall( dtype T | is_thread(T) )54 void __thrd_start( T & this, void (*main_p)(T &) ) {55 $thread * this_thrd = get_thread(this);56 57 disable_interrupts();58 __cfactx_start(main_p, get_coroutine(this), this, __cfactx_invoke_thread);59 60 this_thrd->context.[SP, FP] = this_thrd->self_cor.context.[SP, FP];61 verify( this_thrd->context.SP );62 63 __schedule_thread(this_thrd);64 enable_interrupts( __cfaabi_dbg_ctx );65 }66 67 //-----------------------------------------------------------------------------68 // Support for threads that don't ues the thread keyword69 57 forall( dtype T | sized(T) | is_thread(T) | { void ?{}(T&); } ) 70 58 void ?{}( scoped(T)& this ) with( this ) { 71 59 handle{}; 72 __thrd_start(handle , main);60 __thrd_start(handle); 73 61 } 74 62 … … 76 64 void ?{}( scoped(T)& this, P params ) with( this ) { 77 65 handle{ params }; 78 __thrd_start(handle , main);66 __thrd_start(handle); 79 67 } 80 68 … … 84 72 } 85 73 74 //----------------------------------------------------------------------------- 75 // Starting and stopping threads 76 forall( dtype T | is_thread(T) ) 77 void __thrd_start( T& this ) { 78 thread_desc * this_thrd = get_thread(this); 79 thread_desc * curr_thrd = TL_GET( this_thread ); 80 81 disable_interrupts(); 82 CtxStart(&this, CtxInvokeThread); 83 this_thrd->context.[SP, FP] = this_thrd->self_cor.context.[SP, FP]; 84 verify( this_thrd->context.SP ); 85 CtxSwitch( &curr_thrd->context, &this_thrd->context ); 86 87 ScheduleThread(this_thrd); 88 enable_interrupts( __cfaabi_dbg_ctx ); 89 } 90 91 extern "C" { 92 // KERNEL ONLY 93 void __finish_creation(thread_desc * this) { 94 // set new coroutine that the processor is executing 95 // and context switch to it 96 verify( kernelTLS.this_thread != this ); 97 verify( kernelTLS.this_thread->context.SP ); 98 CtxSwitch( &this->context, &kernelTLS.this_thread->context ); 99 } 100 } 101 102 void yield( void ) { 103 // Safety note : This could cause some false positives due to preemption 104 verify( TL_GET( preemption_state.enabled ) ); 105 BlockInternal( TL_GET( this_thread ) ); 106 // Safety note : This could cause some false positives due to preemption 107 verify( TL_GET( preemption_state.enabled ) ); 108 } 109 110 void yield( unsigned times ) { 111 for( unsigned i = 0; i < times; i++ ) { 112 yield(); 113 } 114 } 115 86 116 // Local Variables: // 87 117 // mode: c // -
libcfa/src/concurrency/thread.hfa
r3d5701e r9fb8f01 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 4 09:18:14201913 // Update Count : 612 // Last Modified On : Fri Jun 21 17:51:33 2019 13 // Update Count : 5 14 14 // 15 15 … … 28 28 void ^?{}(T& mutex this); 29 29 void main(T& this); 30 $thread* get_thread(T& this);30 thread_desc* get_thread(T& this); 31 31 }; 32 32 33 // define that satisfies the trait without using the thread keyword 34 #define DECL_THREAD(X) $thread* get_thread(X& this) __attribute__((const)) { return &this.__thrd; } void main(X& this) 35 36 // Inline getters for threads/coroutines/monitors 37 forall( dtype T | is_thread(T) ) 38 static inline $coroutine* get_coroutine(T & this) __attribute__((const)) { return &get_thread(this)->self_cor; } 33 #define DECL_THREAD(X) thread_desc* get_thread(X& this) { return &this.__thrd; } void main(X& this) 39 34 40 35 forall( dtype T | is_thread(T) ) 41 static inline $monitor * get_monitor (T & this) __attribute__((const)) { return &get_thread(this)->self_mon; } 36 static inline coroutine_desc* get_coroutine(T & this) { 37 return &get_thread(this)->self_cor; 38 } 42 39 43 static inline $coroutine* get_coroutine($thread * this) __attribute__((const)) { return &this->self_cor; } 44 static inline $monitor * get_monitor ($thread * this) __attribute__((const)) { return &this->self_mon; } 40 forall( dtype T | is_thread(T) ) 41 static inline monitor_desc* get_monitor(T & this) { 42 return &get_thread(this)->self_mon; 43 } 45 44 46 //----------------------------------------------------------------------------- 47 // forward declarations needed for threads 45 static inline coroutine_desc* get_coroutine(thread_desc * this) { 46 return &this->self_cor; 47 } 48 49 static inline monitor_desc* get_monitor(thread_desc * this) { 50 return &this->self_mon; 51 } 52 48 53 extern struct cluster * mainCluster; 49 54 50 55 forall( dtype T | is_thread(T) ) 51 void __thrd_start( T & this , void (*)(T &));56 void __thrd_start( T & this ); 52 57 53 58 //----------------------------------------------------------------------------- 54 59 // Ctors and dtors 55 void ?{}( $thread& this, const char * const name, struct cluster & cl, void * storage, size_t storageSize );56 void ^?{}( $thread& this);60 void ?{}(thread_desc & this, const char * const name, struct cluster & cl, void * storage, size_t storageSize ); 61 void ^?{}(thread_desc & this); 57 62 58 static inline void ?{}( $thread & this) { this{ "Anonymous Thread", *mainCluster, 0p, 65000 }; }59 static inline void ?{}( $thread & this, size_t stackSize ) { this{ "Anonymous Thread", *mainCluster, 0p, stackSize }; }60 static inline void ?{}( $thread& this, void * storage, size_t storageSize ) { this{ "Anonymous Thread", *mainCluster, storage, storageSize }; }61 static inline void ?{}( $thread & this, struct cluster & cl ) { this{ "Anonymous Thread", cl, 0p, 65000 }; }62 static inline void ?{}( $thread & this, struct cluster & cl, size_t stackSize ) { this{ "Anonymous Thread", cl, 0p, stackSize }; }63 static inline void ?{}( $thread& this, struct cluster & cl, void * storage, size_t storageSize ) { this{ "Anonymous Thread", cl, storage, storageSize }; }64 static inline void ?{}( $thread & this, const char * const name) { this{ name, *mainCluster, 0p, 65000 }; }65 static inline void ?{}( $thread & this, const char * const name, struct cluster & cl ) { this{ name, cl, 0p, 65000 }; }66 static inline void ?{}( $thread & this, const char * const name, struct cluster & cl, size_t stackSize ) { this{ name, cl, 0p, stackSize }; }63 static inline void ?{}(thread_desc & this) { this{ "Anonymous Thread", *mainCluster, NULL, 65000 }; } 64 static inline void ?{}(thread_desc & this, size_t stackSize ) { this{ "Anonymous Thread", *mainCluster, NULL, stackSize }; } 65 static inline void ?{}(thread_desc & this, void * storage, size_t storageSize ) { this{ "Anonymous Thread", *mainCluster, storage, storageSize }; } 66 static inline void ?{}(thread_desc & this, struct cluster & cl ) { this{ "Anonymous Thread", cl, NULL, 65000 }; } 67 static inline void ?{}(thread_desc & this, struct cluster & cl, size_t stackSize ) { this{ "Anonymous Thread", cl, NULL, stackSize }; } 68 static inline void ?{}(thread_desc & this, struct cluster & cl, void * storage, size_t storageSize ) { this{ "Anonymous Thread", cl, storage, storageSize }; } 69 static inline void ?{}(thread_desc & this, const char * const name) { this{ name, *mainCluster, NULL, 65000 }; } 70 static inline void ?{}(thread_desc & this, const char * const name, struct cluster & cl ) { this{ name, cl, NULL, 65000 }; } 71 static inline void ?{}(thread_desc & this, const char * const name, struct cluster & cl, size_t stackSize ) { this{ name, cl, NULL, stackSize }; } 67 72 68 73 //----------------------------------------------------------------------------- … … 83 88 void ^?{}( scoped(T)& this ); 84 89 85 //----------------------------------------------------------------------------- 86 // Thread getters 87 static inline struct $thread * active_thread () { return TL_GET( this_thread ); } 90 void yield(); 91 void yield( unsigned times ); 88 92 89 //----------------------------------------------------------------------------- 90 // Scheduler API 91 92 //---------- 93 // Park thread: block until corresponding call to unpark, won't block if unpark is already called 94 void park( void ); 95 96 //---------- 97 // Unpark a thread, if the thread is already blocked, schedule it 98 // if the thread is not yet block, signal that it should rerun immediately 99 void unpark( $thread * this ); 100 101 forall( dtype T | is_thread(T) ) 102 static inline void unpark( T & this ) { if(!&this) return; unpark( get_thread( this ) );} 103 104 //---------- 105 // Yield: force thread to block and be rescheduled 106 bool force_yield( enum __Preemption_Reason ); 107 108 static inline void yield() { 109 force_yield(__MANUAL_PREEMPTION); 110 } 111 112 // Yield: yield N times 113 static inline void yield( unsigned times ) { 114 for( times ) { 115 yield(); 116 } 117 } 93 static inline struct thread_desc * active_thread () { return TL_GET( this_thread ); } 118 94 119 95 // Local Variables: // -
libcfa/src/exception.c
r3d5701e r9fb8f01 69 69 70 70 71 // This macro should be the only thing that needs to change across machines. 72 // Used in the personality function, way downin termination.71 // This macro should be the only thing that needs to change across machines. Used in the personality function, way down 72 // in termination. 73 73 // struct _Unwind_Context * -> _Unwind_Reason_Code(*)(exception_t *) 74 74 #define MATCHER_FROM_CONTEXT(ptr_to_context) \ … … 102 102 } 103 103 104 // Do we control where exceptions get thrown even with concurency? 105 // If not these are not quite thread safe, the cleanup hook has to 106 // be added after the node is built but before it is made the top node. 104 // Do we control where exceptions get thrown even with concurency? If not these are not quite thread safe, the cleanup 105 // hook has to be added after the node is built but before it is made the top node. 107 106 108 107 void __cfaabi_ehm__try_resume_setup(struct __cfaabi_ehm__try_resume_node * node, … … 213 212 _Unwind_Reason_Code ret = _Unwind_RaiseException( &this_exception_storage ); 214 213 215 // If we reach here it means something happened. For resumption to work we need to find a way 216 // to return back to here. Most of them will probably boil down to setting a global flag and 217 // making the phase 1 either stop or fail. Causing an error on purpose may help avoiding 218 // unnecessary work but it might have some weird side effects. If we just pretend no handler 219 // was found that would work but may be expensive for no reason since we will always search 220 // the whole stack. 214 // If we reach here it means something happened. For resumption to work we need to find a way to return back to 215 // here. Most of them will probably boil down to setting a global flag and making the phase 1 either stop or 216 // fail. Causing an error on purpose may help avoiding unnecessary work but it might have some weird side 217 // effects. If we just pretend no handler was found that would work but may be expensive for no reason since we 218 // will always search the whole stack. 221 219 222 220 if( ret == _URC_END_OF_STACK ) { 223 // No proper handler was found. This can be handled in many ways, C++ calls std::terminate.224 // Here weforce unwind the stack, basically raising a cancellation.221 // No proper handler was found. This can be handled in several way. C++ calls std::terminate Here we 222 // force unwind the stack, basically raising a cancellation. 225 223 printf("Uncaught exception %p\n", &this_exception_storage); 226 224 … … 230 228 } 231 229 232 // We did not simply reach the end of the stack without finding a handler. This is an error.230 // We did not simply reach the end of the stack without finding a handler. Something wen't wrong 233 231 printf("UNWIND ERROR %d after raise exception\n", ret); 234 232 abort(); … … 248 246 } 249 247 250 #pragma GCC push_options 251 #pragma GCC optimize("O0") 252 253 // This is our personality routine. For every stack frame annotated with 254 // ".cfi_personality 0x3,__gcfa_personality_v0" this function will be called twice when unwinding. 255 // Once in the search phase and once in the cleanup phase. 248 #if defined(PIC) 249 #warning Exceptions not yet supported when using Position-Independent Code 250 __attribute__((noinline)) 251 void __cfaabi_ehm__try_terminate(void (*try_block)(), 252 void (*catch_block)(int index, exception_t * except), 253 __attribute__((unused)) int (*match_block)(exception_t * except)) { 254 abort(); 255 } 256 #else 257 // This is our personality routine. For every stack frame anotated with ".cfi_personality 0x3,__gcfa_personality_v0". 258 // This function will be called twice when unwinding. Once in the search phased and once in the cleanup phase. 256 259 _Unwind_Reason_Code __gcfa_personality_v0 ( 257 260 int version, _Unwind_Action actions, unsigned long long exceptionClass, … … 261 264 262 265 //__cfaabi_dbg_print_safe("CFA: 0x%lx\n", _Unwind_GetCFA(context)); 263 __cfaabi_dbg_print_safe("Personality function (%d, %x, %llu, %p, %p):", 264 version, actions, exceptionClass, unwind_exception, context); 266 __cfaabi_dbg_print_safe("Personality function (%d, %x, %llu, %p, %p):", version, actions, exceptionClass, unwind_exception, context); 265 267 266 268 // If we've reached the end of the stack then there is nothing much we can do... … … 289 291 // Get the instuction pointer and a reading pointer into the exception table 290 292 lsda_header_info lsd_info; 291 const unsigned char * cur_ptr = parse_lsda_header( context, lsd, &lsd_info);293 const unsigned char * cur_ptr = parse_lsda_header( context, lsd, &lsd_info); 292 294 _Unwind_Ptr instruction_ptr = _Unwind_GetIP( context ); 293 295 … … 300 302 301 303 // Decode the common stuff we have in here 302 cur_ptr = read_encoded_value (0, lsd_info.call_site_encoding, cur_ptr, &callsite_start);303 cur_ptr = read_encoded_value (0, lsd_info.call_site_encoding, cur_ptr, &callsite_len);304 cur_ptr = read_encoded_value (0, lsd_info.call_site_encoding, cur_ptr, &callsite_landing_pad);305 cur_ptr = read_uleb128 (cur_ptr, &callsite_action);304 cur_ptr = read_encoded_value (0, lsd_info.call_site_encoding, cur_ptr, &callsite_start); 305 cur_ptr = read_encoded_value (0, lsd_info.call_site_encoding, cur_ptr, &callsite_len); 306 cur_ptr = read_encoded_value (0, lsd_info.call_site_encoding, cur_ptr, &callsite_landing_pad); 307 cur_ptr = read_uleb128 (cur_ptr, &callsite_action); 306 308 307 309 // Have we reach the correct frame info yet? … … 314 316 void * ep = (void*)lsd_info.Start + callsite_start + callsite_len; 315 317 void * ip = (void*)instruction_ptr; 316 __cfaabi_dbg_print_safe("\nfound %p - %p (%p, %p, %p), looking for %p\n", 317 bp, ep, ls, cs, cl, ip); 318 __cfaabi_dbg_print_safe("\nfound %p - %p (%p, %p, %p), looking for %p\n", bp, ep, ls, cs, cl, ip); 318 319 #endif // __CFA_DEBUG_PRINT__ 319 320 continue; 320 321 } 321 322 322 // Have we gone too far ?323 // Have we gone too far 323 324 if( lsd_info.Start + callsite_start > instruction_ptr ) { 324 325 printf(" gone too far"); … … 330 331 // Which phase are we in 331 332 if (actions & _UA_SEARCH_PHASE) { 332 // In search phase, these means we found a potential handler we must check.333 334 // We have arbitrarily decided that 0 means nothing to do and 1 means there is335 // a potential handler. This doesn't seem to conflict the gcc default behavior.333 // Search phase, this means we probably found a potential handler and must check if it is a match 334 335 // If we have arbitrarily decided that 0 means nothing to do and 1 means there is a potential handler 336 // This doesn't seem to conflict the gcc default behavior 336 337 if (callsite_action != 0) { 337 338 // Now we want to run some code to see if the handler matches … … 350 351 // The current apprach uses one exception table entry per try block 351 352 _uleb128_t imatcher; 352 // Get the relative offset to the {...}? 353 cur_ptr = read_uleb128(cur_ptr, &imatcher); 353 // Get the relative offset to the 354 cur_ptr = read_uleb128 (cur_ptr, &imatcher); 355 356 // Get a function pointer from the relative offset and call it 357 // _Unwind_Reason_Code (*matcher)() = (_Unwind_Reason_Code (*)())lsd_info.LPStart + imatcher; 354 358 355 359 _Unwind_Reason_Code (*matcher)(exception_t *) = … … 410 414 } 411 415 412 // Try statements are hoisted out see comments for details. While this could probably be unique413 // and simply linked fromlibcfa but there is one problem left, see the exception table for details416 // Try statements are hoisted out see comments for details. With this could probably be unique and simply linked from 417 // libcfa but there is one problem left, see the exception table for details 414 418 __attribute__((noinline)) 415 419 void __cfaabi_ehm__try_terminate(void (*try_block)(), … … 424 428 // assembly works. 425 429 426 // Setup the personality routine and exception table. 427 #ifdef __PIC__ 428 asm volatile (".cfi_personality 0x9b,CFA.ref.__gcfa_personality_v0"); 429 asm volatile (".cfi_lsda 0x1b, .LLSDACFA2"); 430 #else 430 // Setup the personality routine 431 431 asm volatile (".cfi_personality 0x3,__gcfa_personality_v0"); 432 // Setup the exception table 432 433 asm volatile (".cfi_lsda 0x3, .LLSDACFA2"); 433 #endif434 434 435 435 // Label which defines the start of the area for which the handler is setup. … … 442 442 asm volatile goto ("" : : : : CATCH ); 443 443 444 // Normal return for when there is no throw.444 // Normal return 445 445 return; 446 446 … … 459 459 } 460 460 461 // Exception table data we need to generate. While this is almost generic, the custom data refers 462 // to {*}try_terminate, which is no way generic. Some more works need to be done if we want to 463 // have a single call to the try routine. 464 465 #ifdef __PIC__ 461 // Exception table data we need to generate. While this is almost generic, the custom data refers to foo_try_match try 462 // match, which is no way generic. Some more works need to be done if we want to have a single call to the try routine. 463 466 464 #if defined( __i386 ) || defined( __x86_64 ) 467 465 asm ( 468 // HEADER466 //HEADER 469 467 ".LFECFA1:\n" 470 468 " .globl __gcfa_personality_v0\n" 471 469 " .section .gcc_except_table,\"a\",@progbits\n" 472 // TABLE HEADER (important field is the BODY length at the end) 473 ".LLSDACFA2:\n" 470 ".LLSDACFA2:\n" //TABLE header 474 471 " .byte 0xff\n" 475 472 " .byte 0xff\n" 476 473 " .byte 0x1\n" 477 " .uleb128 .LLSDACSECFA2-.LLSDACSBCFA2\n" 478 // BODY (language specific data) 479 // This uses language specific data and can be modified arbitrarily 480 // We use handled area offset, handled area length, 481 // handler landing pad offset and 1 (action code, gcc seems to use 0). 482 ".LLSDACSBCFA2:\n" 483 " .uleb128 .TRYSTART-__cfaabi_ehm__try_terminate\n" 484 " .uleb128 .TRYEND-.TRYSTART\n" 485 " .uleb128 .CATCH-__cfaabi_ehm__try_terminate\n" 486 " .uleb128 1\n" 487 ".LLSDACSECFA2:\n" 488 // TABLE FOOTER 489 " .text\n" 490 " .size __cfaabi_ehm__try_terminate, .-__cfaabi_ehm__try_terminate\n" 491 ); 492 493 // Somehow this piece of helps with the resolution of debug symbols. 494 __attribute__((unused)) static const int dummy = 0; 495 496 asm ( 497 // Add a hidden symbol which points at the function. 498 " .hidden CFA.ref.__gcfa_personality_v0\n" 499 " .weak CFA.ref.__gcfa_personality_v0\n" 500 // No clue what this does specifically 501 " .section .data.rel.local.CFA.ref.__gcfa_personality_v0,\"awG\",@progbits,CFA.ref.__gcfa_personality_v0,comdat\n" 502 " .align 8\n" 503 " .type CFA.ref.__gcfa_personality_v0, @object\n" 504 " .size CFA.ref.__gcfa_personality_v0, 8\n" 505 "CFA.ref.__gcfa_personality_v0:\n" 506 #if defined( __x86_64 ) 507 " .quad __gcfa_personality_v0\n" 508 #else // then __i386 509 " .long __gcfa_personality_v0\n" 510 #endif 511 ); 512 #else 513 #error Exception Handling: unknown architecture for position independent code. 514 #endif // __i386 || __x86_64 515 #else // __PIC__ 516 #if defined( __i386 ) || defined( __x86_64 ) 517 asm ( 518 // HEADER 519 ".LFECFA1:\n" 520 " .globl __gcfa_personality_v0\n" 521 " .section .gcc_except_table,\"a\",@progbits\n" 522 // TABLE HEADER (important field is the BODY length at the end) 523 ".LLSDACFA2:\n" 524 " .byte 0xff\n" 525 " .byte 0xff\n" 526 " .byte 0x1\n" 527 " .uleb128 .LLSDACSECFA2-.LLSDACSBCFA2\n" 528 // BODY (language specific data) 529 ".LLSDACSBCFA2:\n" 530 // Handled area start (relative to start of function) 531 " .uleb128 .TRYSTART-__cfaabi_ehm__try_terminate\n" 532 // Handled area length 533 " .uleb128 .TRYEND-.TRYSTART\n" 534 // Handler landing pad address (relative to start of function) 535 " .uleb128 .CATCH-__cfaabi_ehm__try_terminate\n" 536 // Action code, gcc seems to always use 0. 537 " .uleb128 1\n" 538 // TABLE FOOTER 539 ".LLSDACSECFA2:\n" 540 " .text\n" 474 " .uleb128 .LLSDACSECFA2-.LLSDACSBCFA2\n" // BODY length 475 // Body uses language specific data and therefore could be modified arbitrarily 476 ".LLSDACSBCFA2:\n" // BODY start 477 " .uleb128 .TRYSTART-__cfaabi_ehm__try_terminate\n" // Handled area start (relative to start of function) 478 " .uleb128 .TRYEND-.TRYSTART\n" // Handled area length 479 " .uleb128 .CATCH-__cfaabi_ehm__try_terminate\n" // Hanlder landing pad adress (relative to start of function) 480 " .uleb128 1\n" // Action code, gcc seems to use always 0 481 ".LLSDACSECFA2:\n" // BODY end 482 " .text\n" // TABLE footer 541 483 " .size __cfaabi_ehm__try_terminate, .-__cfaabi_ehm__try_terminate\n" 542 484 " .ident \"GCC: (Ubuntu 6.2.0-3ubuntu11~16.04) 6.2.0 20160901\"\n" 543 " .section .note.GNU-stack,\"x\",@progbits\n"485 // " .section .note.GNU-stack,\"x\",@progbits\n" 544 486 ); 545 #else546 #error Exception Handling: unknown architecture for position dependent code.547 487 #endif // __i386 || __x86_64 548 #endif // __PIC__ 549 550 #pragma GCC pop_options 488 #endif //PIC -
libcfa/src/executor.cfa
r3d5701e r9fb8f01 8 8 #include <stdio.h> 9 9 10 forall( dtype T )11 monitor Buffer { // unbounded buffer12 __queue_t( T ) queue; // unbounded list of work requests13 condition delay;14 }; // Buffer15 forall( dtype T | is_node(T) ) { 10 forall( otype T | is_node(T) | is_monitor(T) ) { 11 monitor Buffer { // unbounded buffer 12 __queue_t( T ) queue; // unbounded list of work requests 13 condition delay; 14 }; // Buffer 15 16 16 void insert( Buffer( T ) & mutex buf, T * elem ) with(buf) { 17 17 append( queue, elem ); // insert element into buffer … … 20 20 21 21 T * remove( Buffer( T ) & mutex buf ) with(buf) { 22 if ( queue.head != 0) wait( delay ); // no request to process ? => wait23 //return pop_head( queue );22 if ( ! queue ) wait( delay ); // no request to process ? => wait 23 return pop_head( queue ); 24 24 } // remove 25 25 } // distribution -
libcfa/src/fstream.cfa
r3d5701e r9fb8f01 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 7 19:01:01 202013 // Update Count : 3 6312 // Last Modified On : Mon Jul 15 18:11:26 2019 13 // Update Count : 349 14 14 // 15 15 … … 32 32 33 33 void ?{}( ofstream & os, void * file ) { 34 os.$file = file; 35 os.$sepDefault = true; 36 os.$sepOnOff = false; 37 os.$nlOnOff = true; 38 os.$prt = false; 39 os.$sawNL = false; 40 $sepSetCur( os, sepGet( os ) ); 34 os.file = file; 35 os.sepDefault = true; 36 os.sepOnOff = false; 37 os.nlOnOff = true; 38 os.prt = false; 39 os.sawNL = false; 41 40 sepSet( os, " " ); 41 sepSetCur( os, sepGet( os ) ); 42 42 sepSetTuple( os, ", " ); 43 43 } // ?{} 44 44 45 45 // private 46 bool $sepPrt( ofstream & os ) { $setNL( os, false ); return os.$sepOnOff; }47 void $sepReset( ofstream & os ) { os.$sepOnOff = os.$sepDefault; }48 void $sepReset( ofstream & os, bool reset ) { os.$sepDefault = reset; os.$sepOnOff = os.$sepDefault; }49 const char * $sepGetCur( ofstream & os ) { return os.$sepCur; }50 void $sepSetCur( ofstream & os, const char sepCur[] ) { os.$sepCur = sepCur; }51 bool $getNL( ofstream & os ) { return os.$sawNL; }52 void $setNL( ofstream & os, bool state ) { os.$sawNL = state; }53 bool $getANL( ofstream & os ) { return os.$nlOnOff; }54 bool $getPrt( ofstream & os ) { return os.$prt; }55 void $setPrt( ofstream & os, bool state ) { os.$prt = state; }46 bool sepPrt( ofstream & os ) { setNL( os, false ); return os.sepOnOff; } 47 void sepReset( ofstream & os ) { os.sepOnOff = os.sepDefault; } 48 void sepReset( ofstream & os, bool reset ) { os.sepDefault = reset; os.sepOnOff = os.sepDefault; } 49 const char * sepGetCur( ofstream & os ) { return os.sepCur; } 50 void sepSetCur( ofstream & os, const char * sepCur ) { os.sepCur = sepCur; } 51 bool getNL( ofstream & os ) { return os.sawNL; } 52 void setNL( ofstream & os, bool state ) { os.sawNL = state; } 53 bool getANL( ofstream & os ) { return os.nlOnOff; } 54 bool getPrt( ofstream & os ) { return os.prt; } 55 void setPrt( ofstream & os, bool state ) { os.prt = state; } 56 56 57 57 // public 58 void ?{}( ofstream & os ) { os. $file = 0p; }59 60 void ?{}( ofstream & os, const char name[], const char mode[]) {58 void ?{}( ofstream & os ) { os.file = 0; } 59 60 void ?{}( ofstream & os, const char * name, const char * mode ) { 61 61 open( os, name, mode ); 62 62 } // ?{} 63 63 64 void ?{}( ofstream & os, const char name[]) {64 void ?{}( ofstream & os, const char * name ) { 65 65 open( os, name, "w" ); 66 66 } // ?{} 67 67 68 void ^?{}( ofstream & os ) { 69 close( os ); 70 } // ^?{} 71 72 void sepOn( ofstream & os ) { os.$sepOnOff = ! $getNL( os ); } 73 void sepOff( ofstream & os ) { os.$sepOnOff = false; } 68 void sepOn( ofstream & os ) { os.sepOnOff = ! getNL( os ); } 69 void sepOff( ofstream & os ) { os.sepOnOff = false; } 74 70 75 71 bool sepDisable( ofstream & os ) { 76 bool temp = os. $sepDefault;77 os. $sepDefault = false;78 $sepReset( os );72 bool temp = os.sepDefault; 73 os.sepDefault = false; 74 sepReset( os ); 79 75 return temp; 80 76 } // sepDisable 81 77 82 78 bool sepEnable( ofstream & os ) { 83 bool temp = os. $sepDefault;84 os. $sepDefault = true;85 if ( os. $sepOnOff ) $sepReset( os );// start of line ?79 bool temp = os.sepDefault; 80 os.sepDefault = true; 81 if ( os.sepOnOff ) sepReset( os ); // start of line ? 86 82 return temp; 87 83 } // sepEnable 88 84 89 void nlOn( ofstream & os ) { os. $nlOnOff = true; }90 void nlOff( ofstream & os ) { os. $nlOnOff = false; }91 92 const char * sepGet( ofstream & os ) { return os. $separator; }93 void sepSet( ofstream & os, const char s[]) {85 void nlOn( ofstream & os ) { os.nlOnOff = true; } 86 void nlOff( ofstream & os ) { os.nlOnOff = false; } 87 88 const char * sepGet( ofstream & os ) { return os.separator; } 89 void sepSet( ofstream & os, const char * s ) { 94 90 assert( s ); 95 strncpy( os. $separator, s, sepSize - 1 );96 os. $separator[sepSize - 1] = '\0';91 strncpy( os.separator, s, sepSize - 1 ); 92 os.separator[sepSize - 1] = '\0'; 97 93 } // sepSet 98 94 99 const char * sepGetTuple( ofstream & os ) { return os. $tupleSeparator; }100 void sepSetTuple( ofstream & os, const char s[]) {95 const char * sepGetTuple( ofstream & os ) { return os.tupleSeparator; } 96 void sepSetTuple( ofstream & os, const char * s ) { 101 97 assert( s ); 102 strncpy( os. $tupleSeparator, s, sepSize - 1 );103 os. $tupleSeparator[sepSize - 1] = '\0';98 strncpy( os.tupleSeparator, s, sepSize - 1 ); 99 os.tupleSeparator[sepSize - 1] = '\0'; 104 100 } // sepSet 105 101 106 102 void ends( ofstream & os ) { 107 if ( $getANL( os ) ) nl( os );108 else $setPrt( os, false ); // turn off103 if ( getANL( os ) ) nl( os ); 104 else setPrt( os, false ); // turn off 109 105 if ( &os == &exit ) exit( EXIT_FAILURE ); 110 106 if ( &os == &abort ) abort(); … … 112 108 113 109 int fail( ofstream & os ) { 114 return os. $file == 0 || ferror( (FILE *)(os.$file) );110 return os.file == 0 || ferror( (FILE *)(os.file) ); 115 111 } // fail 116 112 117 113 int flush( ofstream & os ) { 118 return fflush( (FILE *)(os. $file) );114 return fflush( (FILE *)(os.file) ); 119 115 } // flush 120 116 121 void open( ofstream & os, const char name[], const char mode[]) {117 void open( ofstream & os, const char * name, const char * mode ) { 122 118 FILE * file = fopen( name, mode ); 123 119 #ifdef __CFA_DEBUG__ 124 if ( file == 0 p) {120 if ( file == 0 ) { 125 121 abort | IO_MSG "open output file \"" | name | "\"" | nl | strerror( errno ); 126 122 } // if … … 129 125 } // open 130 126 131 void open( ofstream & os, const char name[]) {127 void open( ofstream & os, const char * name ) { 132 128 open( os, name, "w" ); 133 129 } // open 134 130 135 131 void close( ofstream & os ) { 136 if ( (FILE *)(os. $file) == stdout || (FILE *)(os.$file) == stderr ) return;137 138 if ( fclose( (FILE *)(os. $file) ) == EOF ) {132 if ( (FILE *)(os.file) == stdout || (FILE *)(os.file) == stderr ) return; 133 134 if ( fclose( (FILE *)(os.file) ) == EOF ) { 139 135 abort | IO_MSG "close output" | nl | strerror( errno ); 140 136 } // if 141 137 } // close 142 138 143 ofstream & write( ofstream & os, const char data[], size_t size ) {139 ofstream & write( ofstream & os, const char * data, size_t size ) { 144 140 if ( fail( os ) ) { 145 141 abort | IO_MSG "attempt write I/O on failed stream"; 146 142 } // if 147 143 148 if ( fwrite( data, 1, size, (FILE *)(os. $file) ) != size ) {144 if ( fwrite( data, 1, size, (FILE *)(os.file) ) != size ) { 149 145 abort | IO_MSG "write" | nl | strerror( errno ); 150 146 } // if … … 155 151 va_list args; 156 152 va_start( args, format ); 157 int len = vfprintf( (FILE *)(os. $file), format, args );153 int len = vfprintf( (FILE *)(os.file), format, args ); 158 154 if ( len == EOF ) { 159 if ( ferror( (FILE *)(os. $file) ) ) {155 if ( ferror( (FILE *)(os.file) ) ) { 160 156 abort | IO_MSG "invalid write"; 161 157 } // if … … 163 159 va_end( args ); 164 160 165 $setPrt( os, true );// called in output cascade166 $sepReset( os );// reset separator161 setPrt( os, true ); // called in output cascade 162 sepReset( os ); // reset separator 167 163 return len; 168 164 } // fmt 169 165 170 static ofstream soutFile = { (FILE *) stdout};166 static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_) }; 171 167 ofstream & sout = soutFile, & stdout = soutFile; 172 static ofstream serrFile = { (FILE *) stderr};168 static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_) }; 173 169 ofstream & serr = serrFile, & stderr = serrFile; 174 170 175 static ofstream exitFile = { (FILE *) stdout};171 static ofstream exitFile = { (FILE *)(&_IO_2_1_stdout_) }; 176 172 ofstream & exit = exitFile; 177 static ofstream abortFile = { (FILE *) stderr};173 static ofstream abortFile = { (FILE *)(&_IO_2_1_stderr_) }; 178 174 ofstream & abort = abortFile; 179 175 … … 184 180 // private 185 181 void ?{}( ifstream & is, void * file ) { 186 is. $file = file;187 is. $nlOnOff = false;182 is.file = file; 183 is.nlOnOff = false; 188 184 } // ?{} 189 185 190 186 // public 191 void ?{}( ifstream & is ) { is.$file = 0p; }192 193 void ?{}( ifstream & is, const char name[], const char mode[]) {187 void ?{}( ifstream & is ) { is.file = 0; } 188 189 void ?{}( ifstream & is, const char * name, const char * mode ) { 194 190 open( is, name, mode ); 195 191 } // ?{} 196 192 197 void ?{}( ifstream & is, const char name[]) {193 void ?{}( ifstream & is, const char * name ) { 198 194 open( is, name, "r" ); 199 195 } // ?{} 200 196 201 void ^?{}( ifstream & is ) { 202 close( is ); 203 } // ^?{} 204 205 void nlOn( ifstream & os ) { os.$nlOnOff = true; } 206 void nlOff( ifstream & os ) { os.$nlOnOff = false; } 207 bool getANL( ifstream & os ) { return os.$nlOnOff; } 197 void nlOn( ifstream & os ) { os.nlOnOff = true; } 198 void nlOff( ifstream & os ) { os.nlOnOff = false; } 199 bool getANL( ifstream & os ) { return os.nlOnOff; } 208 200 209 201 int fail( ifstream & is ) { 210 return is. $file == 0p || ferror( (FILE *)(is.$file) );202 return is.file == 0 || ferror( (FILE *)(is.file) ); 211 203 } // fail 212 204 213 205 int eof( ifstream & is ) { 214 return feof( (FILE *)(is. $file) );206 return feof( (FILE *)(is.file) ); 215 207 } // eof 216 208 217 void open( ifstream & is, const char name[], const char mode[]) {209 void open( ifstream & is, const char * name, const char * mode ) { 218 210 FILE * file = fopen( name, mode ); 219 211 #ifdef __CFA_DEBUG__ 220 if ( file == 0 p) {212 if ( file == 0 ) { 221 213 abort | IO_MSG "open input file \"" | name | "\"" | nl | strerror( errno ); 222 214 } // if 223 215 #endif // __CFA_DEBUG__ 224 is. $file = file;225 } // open 226 227 void open( ifstream & is, const char name[]) {216 is.file = file; 217 } // open 218 219 void open( ifstream & is, const char * name ) { 228 220 open( is, name, "r" ); 229 221 } // open 230 222 231 223 void close( ifstream & is ) { 232 if ( (FILE *)(is. $file) == stdin ) return;233 234 if ( fclose( (FILE *)(is. $file) ) == EOF ) {224 if ( (FILE *)(is.file) == stdin ) return; 225 226 if ( fclose( (FILE *)(is.file) ) == EOF ) { 235 227 abort | IO_MSG "close input" | nl | strerror( errno ); 236 228 } // if … … 242 234 } // if 243 235 244 if ( fread( data, size, 1, (FILE *)(is. $file) ) == 0 ) {236 if ( fread( data, size, 1, (FILE *)(is.file) ) == 0 ) { 245 237 abort | IO_MSG "read" | nl | strerror( errno ); 246 238 } // if … … 253 245 } // if 254 246 255 if ( ungetc( c, (FILE *)(is. $file) ) == EOF ) {247 if ( ungetc( c, (FILE *)(is.file) ) == EOF ) { 256 248 abort | IO_MSG "ungetc" | nl | strerror( errno ); 257 249 } // if … … 263 255 264 256 va_start( args, format ); 265 int len = vfscanf( (FILE *)(is. $file), format, args );257 int len = vfscanf( (FILE *)(is.file), format, args ); 266 258 if ( len == EOF ) { 267 if ( ferror( (FILE *)(is. $file) ) ) {259 if ( ferror( (FILE *)(is.file) ) ) { 268 260 abort | IO_MSG "invalid read"; 269 261 } // if … … 273 265 } // fmt 274 266 275 static ifstream sinFile = { (FILE *)stdin }; 267 268 static ifstream sinFile = { (FILE *)(&_IO_2_1_stdin_) }; 276 269 ifstream & sin = sinFile, & stdin = sinFile; 277 270 -
libcfa/src/fstream.hfa
r3d5701e r9fb8f01 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Feb 17 08:29:23 202013 // Update Count : 1 7512 // Last Modified On : Mon Jul 15 18:10:23 2019 13 // Update Count : 167 14 14 // 15 15 … … 24 24 enum { sepSize = 16 }; 25 25 struct ofstream { 26 void * $file;27 bool $sepDefault;28 bool $sepOnOff;29 bool $nlOnOff;30 bool $prt; // print text31 bool $sawNL;32 const char * $sepCur;33 char $separator[sepSize];34 char $tupleSeparator[sepSize];26 void * file; 27 bool sepDefault; 28 bool sepOnOff; 29 bool nlOnOff; 30 bool prt; // print text 31 bool sawNL; 32 const char * sepCur; 33 char separator[sepSize]; 34 char tupleSeparator[sepSize]; 35 35 }; // ofstream 36 36 37 37 // private 38 bool $sepPrt( ofstream & );39 void $sepReset( ofstream & );40 void $sepReset( ofstream &, bool );41 const char * $sepGetCur( ofstream & );42 void $sepSetCur( ofstream &, const char []);43 bool $getNL( ofstream & );44 void $setNL( ofstream &, bool );45 bool $getANL( ofstream & );46 bool $getPrt( ofstream & );47 void $setPrt( ofstream &, bool );38 bool sepPrt( ofstream & ); 39 void sepReset( ofstream & ); 40 void sepReset( ofstream &, bool ); 41 const char * sepGetCur( ofstream & ); 42 void sepSetCur( ofstream &, const char * ); 43 bool getNL( ofstream & ); 44 void setNL( ofstream &, bool ); 45 bool getANL( ofstream & ); 46 bool getPrt( ofstream & ); 47 void setPrt( ofstream &, bool ); 48 48 49 49 // public … … 56 56 57 57 const char * sepGet( ofstream & ); 58 void sepSet( ofstream &, const char []);58 void sepSet( ofstream &, const char * ); 59 59 const char * sepGetTuple( ofstream & ); 60 void sepSetTuple( ofstream &, const char []);60 void sepSetTuple( ofstream &, const char * ); 61 61 62 62 void ends( ofstream & os ); 63 63 int fail( ofstream & ); 64 64 int flush( ofstream & ); 65 void open( ofstream &, const char name[], const char mode[]);66 void open( ofstream &, const char name[]);65 void open( ofstream &, const char * name, const char * mode ); 66 void open( ofstream &, const char * name ); 67 67 void close( ofstream & ); 68 ofstream & write( ofstream &, const char data[], size_t size );69 int fmt( ofstream &, const char format[], ... ) __attribute__(( format(printf, 2, 3) ));68 ofstream & write( ofstream &, const char * data, size_t size ); 69 int fmt( ofstream &, const char format[], ... ); 70 70 71 71 void ?{}( ofstream & os ); 72 void ?{}( ofstream & os, const char name[], const char mode[] ); 73 void ?{}( ofstream & os, const char name[] ); 74 void ^?{}( ofstream & os ); 72 void ?{}( ofstream & os, const char * name, const char * mode ); 73 void ?{}( ofstream & os, const char * name ); 75 74 76 75 extern ofstream & sout, & stdout, & serr, & stderr; // aliases … … 82 81 83 82 struct ifstream { 84 void * $file;85 bool $nlOnOff;83 void * file; 84 bool nlOnOff; 86 85 }; // ifstream 87 86 … … 92 91 int fail( ifstream & is ); 93 92 int eof( ifstream & is ); 94 void open( ifstream & is, const char name[], const char mode[]);95 void open( ifstream & is, const char name[]);93 void open( ifstream & is, const char * name, const char * mode ); 94 void open( ifstream & is, const char * name ); 96 95 void close( ifstream & is ); 97 96 ifstream & read( ifstream & is, char * data, size_t size ); 98 97 ifstream & ungetc( ifstream & is, char c ); 99 int fmt( ifstream &, const char format[], ... ) __attribute__(( format(scanf, 2, 3) ));98 int fmt( ifstream &, const char format[], ... ); 100 99 101 100 void ?{}( ifstream & is ); 102 void ?{}( ifstream & is, const char name[], const char mode[] ); 103 void ?{}( ifstream & is, const char name[] ); 104 void ^?{}( ifstream & is ); 101 void ?{}( ifstream & is, const char * name, const char * mode ); 102 void ?{}( ifstream & is, const char * name ); 105 103 106 104 extern ifstream & sin, & stdin; // aliases -
libcfa/src/gmp.hfa
r3d5701e r9fb8f01 10 10 // Created On : Tue Apr 19 08:43:43 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : S un Feb 9 09:56:54 202013 // Update Count : 3112 // Last Modified On : Sat Jul 13 15:25:05 2019 13 // Update Count : 27 14 14 // 15 15 … … 24 24 25 25 static inline { 26 // constructor , zero_t/one_t are unnecessary because of relationship with signed/unsigned int26 // constructor 27 27 void ?{}( Int & this ) { mpz_init( this.mpz ); } 28 28 void ?{}( Int & this, Int init ) { mpz_init_set( this.mpz, init.mpz ); } 29 void ?{}( Int & this, zero_t ) { mpz_init_set_si( this.mpz, 0 ); } 30 void ?{}( Int & this, one_t ) { mpz_init_set_si( this.mpz, 1 ); } 29 31 void ?{}( Int & this, signed long int init ) { mpz_init_set_si( this.mpz, init ); } 30 32 void ?{}( Int & this, unsigned long int init ) { mpz_init_set_ui( this.mpz, init ); } 31 void ?{}( Int & this, const char val[]) { if ( mpz_init_set_str( this.mpz, val, 0 ) ) abort(); }33 void ?{}( Int & this, const char * val ) { if ( mpz_init_set_str( this.mpz, val, 0 ) ) abort(); } 32 34 void ^?{}( Int & this ) { mpz_clear( this.mpz ); } 33 35 … … 35 37 Int ?`mp( signed long int init ) { return (Int){ init }; } 36 38 Int ?`mp( unsigned long int init ) { return (Int){ init }; } 37 Int ?`mp( const char init[]) { return (Int){ init }; }39 Int ?`mp( const char * init ) { return (Int){ init }; } 38 40 39 41 // assignment … … 41 43 Int ?=?( Int & lhs, long int rhs ) { mpz_set_si( lhs.mpz, rhs ); return lhs; } 42 44 Int ?=?( Int & lhs, unsigned long int rhs ) { mpz_set_ui( lhs.mpz, rhs ); return lhs; } 43 Int ?=?( Int & lhs, const char rhs[]) { if ( mpz_set_str( lhs.mpz, rhs, 0 ) ) { abort | "invalid string conversion"; } return lhs; }45 Int ?=?( Int & lhs, const char * rhs ) { if ( mpz_set_str( lhs.mpz, rhs, 0 ) ) { abort | "invalid string conversion"; } return lhs; } 44 46 45 47 char ?=?( char & lhs, Int rhs ) { char val = mpz_get_si( rhs.mpz ); lhs = val; return lhs; } … … 263 265 forall( dtype ostype | ostream( ostype ) ) { 264 266 ostype & ?|?( ostype & os, Int mp ) { 265 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );267 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 266 268 gmp_printf( "%Zd", mp.mpz ); 267 269 sepOn( os ); -
libcfa/src/heap.cfa
r3d5701e r9fb8f01 10 10 // Created On : Tue Dec 19 21:58:35 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 10:04:51 202013 // Update Count : 64812 // Last Modified On : Wed Jul 24 13:12:45 2019 13 // Update Count : 550 14 14 // 15 15 … … 18 18 #include <stdio.h> // snprintf, fileno 19 19 #include <errno.h> // errno 20 #include <string.h> // memset, memcpy21 20 extern "C" { 22 21 #include <sys/mman.h> // mmap, munmap … … 28 27 #include "bits/locks.hfa" // __spinlock_t 29 28 #include "startup.hfa" // STARTUP_PRIORITY_MEMORY 30 //#include "stdlib.hfa" // bsearchl29 #include "stdlib.hfa" // bsearchl 31 30 #include "malloc.h" 32 31 33 #define MIN(x, y) (y > x ? x : y)34 32 35 33 static bool traceHeap = false; 36 34 37 inline bool traceHeap() { return traceHeap; } 35 inline bool traceHeap() { 36 return traceHeap; 37 } // traceHeap 38 38 39 39 bool traceHeapOn() { … … 49 49 } // traceHeapOff 50 50 51 bool traceHeapTerm() { return false; } 52 53 54 static bool prtFree = false; 55 56 inline bool prtFree() { 57 return prtFree; 58 } // prtFree 59 60 bool prtFreeOn() { 61 bool temp = prtFree; 62 prtFree = true; 51 52 static bool checkFree = false; 53 54 inline bool checkFree() { 55 return checkFree; 56 } // checkFree 57 58 bool checkFreeOn() { 59 bool temp = checkFree; 60 checkFree = true; 63 61 return temp; 64 } // prtFreeOn65 66 bool prtFreeOff() {67 bool temp = prtFree;68 prtFree = false;62 } // checkFreeOn 63 64 bool checkFreeOff() { 65 bool temp = checkFree; 66 checkFree = false; 69 67 return temp; 70 } // prtFreeOff 68 } // checkFreeOff 69 70 71 // static bool traceHeapTerm = false; 72 73 // inline bool traceHeapTerm() { 74 // return traceHeapTerm; 75 // } // traceHeapTerm 76 77 // bool traceHeapTermOn() { 78 // bool temp = traceHeapTerm; 79 // traceHeapTerm = true; 80 // return temp; 81 // } // traceHeapTermOn 82 83 // bool traceHeapTermOff() { 84 // bool temp = traceHeapTerm; 85 // traceHeapTerm = false; 86 // return temp; 87 // } // traceHeapTermOff 71 88 72 89 73 90 enum { 74 // Define the default extension heap amount in units of bytes. When the uC++ supplied heap reaches the brk address, 75 // the brk address is extended by the extension amount. 91 __CFA_DEFAULT_MMAP_START__ = (512 * 1024 + 1), 76 92 __CFA_DEFAULT_HEAP_EXPANSION__ = (1 * 1024 * 1024), 77 78 // Define the mmap crossover point during allocation. Allocations less than this amount are allocated from buckets;79 // values greater than or equal to this value are mmap from the operating system.80 __CFA_DEFAULT_MMAP_START__ = (512 * 1024 + 1),81 93 }; 82 94 … … 93 105 static unsigned int allocFree; // running total of allocations minus frees 94 106 95 static void prtUnfreed() {107 static void checkUnfreed() { 96 108 if ( allocFree != 0 ) { 97 109 // DO NOT USE STREAMS AS THEY MAY BE UNAVAILABLE AT THIS POINT. 98 char helpText[512];99 int len = snprintf( helpText, sizeof(helpText), "CFA warning (UNIX pid:%ld) : program terminating with %u(0x%x) bytes of storage allocated but not freed.\n"100 "Possible cause is unfreed storage allocated by the program or system/library routines called from the program.\n",101 (long int)getpid(), allocFree, allocFree ); // always print the UNIX pid102 __cfaabi_bits_write( STDERR_FILENO, helpText, len ); // print debug/nodebug103 } // if 104 } // prtUnfreed110 // char helpText[512]; 111 // int len = snprintf( helpText, sizeof(helpText), "CFA warning (UNIX pid:%ld) : program terminating with %u(0x%x) bytes of storage allocated but not freed.\n" 112 // "Possible cause is unfreed storage allocated by the program or system/library routines called from the program.\n", 113 // (long int)getpid(), allocFree, allocFree ); // always print the UNIX pid 114 // __cfaabi_dbg_bits_write( helpText, len ); 115 } // if 116 } // checkUnfreed 105 117 106 118 extern "C" { … … 111 123 void heapAppStop() { // called by __cfaabi_appready_startdown 112 124 fclose( stdin ); fclose( stdout ); 113 prtUnfreed();125 checkUnfreed(); 114 126 } // heapAppStop 115 127 } // extern "C" 116 128 #endif // __CFA_DEBUG__ 117 118 129 119 130 // statically allocated variables => zero filled. … … 123 134 static unsigned int maxBucketsUsed; // maximum number of buckets in use 124 135 136 137 // #comment TD : This defined is significantly different from the __ALIGN__ define from locks.hfa 138 #define ALIGN 16 125 139 126 140 #define SPINLOCK 0 … … 133 147 // Recursive definitions: HeapManager needs size of bucket array and bucket area needs sizeof HeapManager storage. 134 148 // Break recusion by hardcoding number of buckets and statically checking number is correct after bucket array defined. 135 enum { NoBucketSizes = 9 1}; // number of buckets sizes149 enum { NoBucketSizes = 93 }; // number of buckets sizes 136 150 137 151 struct HeapManager { … … 180 194 } kind; // Kind 181 195 } header; // Header 182 char pad[ libAlign()- sizeof( Header )];196 char pad[ALIGN - sizeof( Header )]; 183 197 char data[0]; // storage 184 198 }; // Storage 185 199 186 static_assert( libAlign() >= sizeof( Storage ), "libAlign()< sizeof( Storage )" );200 static_assert( ALIGN >= sizeof( Storage ), "ALIGN < sizeof( Storage )" ); 187 201 188 202 struct FreeHeader { … … 214 228 #define __STATISTICS__ 215 229 216 // Bucket size must be multiple of 16.217 230 // Powers of 2 are common allocation sizes, so make powers of 2 generate the minimum required size. 218 231 static const unsigned int bucketSizes[] @= { // different bucket sizes 219 16, 32, 48, 64 + sizeof(HeapManager.Storage), // 4 220 96, 112, 128 + sizeof(HeapManager.Storage), // 3 221 160, 192, 224, 256 + sizeof(HeapManager.Storage), // 4 222 320, 384, 448, 512 + sizeof(HeapManager.Storage), // 4 223 640, 768, 896, 1_024 + sizeof(HeapManager.Storage), // 4 224 1_536, 2_048 + sizeof(HeapManager.Storage), // 2 225 2_560, 3_072, 3_584, 4_096 + sizeof(HeapManager.Storage), // 4 226 6_144, 8_192 + sizeof(HeapManager.Storage), // 2 227 9_216, 10_240, 11_264, 12_288, 13_312, 14_336, 15_360, 16_384 + sizeof(HeapManager.Storage), // 8 228 18_432, 20_480, 22_528, 24_576, 26_624, 28_672, 30_720, 32_768 + sizeof(HeapManager.Storage), // 8 229 36_864, 40_960, 45_056, 49_152, 53_248, 57_344, 61_440, 65_536 + sizeof(HeapManager.Storage), // 8 230 73_728, 81_920, 90_112, 98_304, 106_496, 114_688, 122_880, 131_072 + sizeof(HeapManager.Storage), // 8 231 147_456, 163_840, 180_224, 196_608, 212_992, 229_376, 245_760, 262_144 + sizeof(HeapManager.Storage), // 8 232 294_912, 327_680, 360_448, 393_216, 425_984, 458_752, 491_520, 524_288 + sizeof(HeapManager.Storage), // 8 233 655_360, 786_432, 917_504, 1_048_576 + sizeof(HeapManager.Storage), // 4 234 1_179_648, 1_310_720, 1_441_792, 1_572_864, 1_703_936, 1_835_008, 1_966_080, 2_097_152 + sizeof(HeapManager.Storage), // 8 235 2_621_440, 3_145_728, 3_670_016, 4_194_304 + sizeof(HeapManager.Storage), // 4 232 16, 32, 48, 64, 233 64 + sizeof(HeapManager.Storage), 96, 112, 128, 128 + sizeof(HeapManager.Storage), 160, 192, 224, 234 256 + sizeof(HeapManager.Storage), 320, 384, 448, 512 + sizeof(HeapManager.Storage), 640, 768, 896, 235 1_024 + sizeof(HeapManager.Storage), 1_536, 2_048 + sizeof(HeapManager.Storage), 2_560, 3_072, 3_584, 4_096 + sizeof(HeapManager.Storage), 6_144, 236 8_192 + sizeof(HeapManager.Storage), 9_216, 10_240, 11_264, 12_288, 13_312, 14_336, 15_360, 237 16_384 + sizeof(HeapManager.Storage), 18_432, 20_480, 22_528, 24_576, 26_624, 28_672, 30_720, 238 32_768 + sizeof(HeapManager.Storage), 36_864, 40_960, 45_056, 49_152, 53_248, 57_344, 61_440, 239 65_536 + sizeof(HeapManager.Storage), 73_728, 81_920, 90_112, 98_304, 106_496, 114_688, 122_880, 240 131_072 + sizeof(HeapManager.Storage), 147_456, 163_840, 180_224, 196_608, 212_992, 229_376, 245_760, 241 262_144 + sizeof(HeapManager.Storage), 294_912, 327_680, 360_448, 393_216, 425_984, 458_752, 491_520, 242 524_288 + sizeof(HeapManager.Storage), 655_360, 786_432, 917_504, 1_048_576 + sizeof(HeapManager.Storage), 1_179_648, 1_310_720, 1_441_792, 243 1_572_864, 1_703_936, 1_835_008, 1_966_080, 2_097_152 + sizeof(HeapManager.Storage), 2_621_440, 3_145_728, 3_670_016, 244 4_194_304 + sizeof(HeapManager.Storage) 236 245 }; 237 246 … … 242 251 static unsigned char lookup[LookupSizes]; // O(1) lookup for small sizes 243 252 #endif // FASTLOOKUP 244 245 253 static int mmapFd = -1; // fake or actual fd for anonymous file 254 255 246 256 #ifdef __CFA_DEBUG__ 247 257 static bool heapBoot = 0; // detect recursion during boot … … 249 259 static HeapManager heapManager __attribute__(( aligned (128) )) @= {}; // size of cache line to prevent false sharing 250 260 261 // #comment TD : The return type of this function should be commented 262 static inline bool setMmapStart( size_t value ) { 263 if ( value < pageSize || bucketSizes[NoBucketSizes - 1] < value ) return true; 264 mmapStart = value; // set global 265 266 // find the closest bucket size less than or equal to the mmapStart size 267 maxBucketsUsed = bsearchl( (unsigned int)mmapStart, bucketSizes, NoBucketSizes ); // binary search 268 assert( maxBucketsUsed < NoBucketSizes ); // subscript failure ? 269 assert( mmapStart <= bucketSizes[maxBucketsUsed] ); // search failure ? 270 return false; 271 } // setMmapStart 272 273 274 static void ?{}( HeapManager & manager ) with ( manager ) { 275 pageSize = sysconf( _SC_PAGESIZE ); 276 277 for ( unsigned int i = 0; i < NoBucketSizes; i += 1 ) { // initialize the free lists 278 freeLists[i].blockSize = bucketSizes[i]; 279 } // for 280 281 #ifdef FASTLOOKUP 282 unsigned int idx = 0; 283 for ( unsigned int i = 0; i < LookupSizes; i += 1 ) { 284 if ( i > bucketSizes[idx] ) idx += 1; 285 lookup[i] = idx; 286 } // for 287 #endif // FASTLOOKUP 288 289 if ( setMmapStart( default_mmap_start() ) ) { 290 abort( "HeapManager : internal error, mmap start initialization failure." ); 291 } // if 292 heapExpand = default_heap_expansion(); 293 294 char * End = (char *)sbrk( 0 ); 295 sbrk( (char *)libCeiling( (long unsigned int)End, libAlign() ) - End ); // move start of heap to multiple of alignment 296 heapBegin = heapEnd = sbrk( 0 ); // get new start point 297 } // HeapManager 298 299 300 static void ^?{}( HeapManager & ) { 301 #ifdef __STATISTICS__ 302 // if ( traceHeapTerm() ) { 303 // printStats(); 304 // if ( checkfree() ) checkFree( heapManager, true ); 305 // } // if 306 #endif // __STATISTICS__ 307 } // ~HeapManager 308 309 310 static void memory_startup( void ) __attribute__(( constructor( STARTUP_PRIORITY_MEMORY ) )); 311 void memory_startup( void ) { 312 #ifdef __CFA_DEBUG__ 313 if ( unlikely( heapBoot ) ) { // check for recursion during system boot 314 // DO NOT USE STREAMS AS THEY MAY BE UNAVAILABLE AT THIS POINT. 315 abort( "boot() : internal error, recursively invoked during system boot." ); 316 } // if 317 heapBoot = true; 318 #endif // __CFA_DEBUG__ 319 320 //assert( heapManager.heapBegin != 0 ); 321 //heapManager{}; 322 if ( heapManager.heapBegin == 0 ) heapManager{}; 323 } // memory_startup 324 325 static void memory_shutdown( void ) __attribute__(( destructor( STARTUP_PRIORITY_MEMORY ) )); 326 void memory_shutdown( void ) { 327 ^heapManager{}; 328 } // memory_shutdown 329 251 330 252 331 #ifdef __STATISTICS__ 253 // Heap statistics counters. 254 static unsigned long long int mmap_storage; 332 static unsigned long long int mmap_storage; // heap statistics counters 255 333 static unsigned int mmap_calls; 256 334 static unsigned long long int munmap_storage; … … 270 348 static unsigned long long int realloc_storage; 271 349 static unsigned int realloc_calls; 272 // Statistics file descriptor (changed by malloc_stats_fd). 273 static int statfd = STDERR_FILENO; // default stderr 350 351 static int statfd; // statistics file descriptor (changed by malloc_stats_fd) 352 274 353 275 354 // Use "write" because streams may be shutdown when calls are made. 276 355 static void printStats() { 277 356 char helpText[512]; 278 __cfaabi_ bits_print_buffer( STDERR_FILENO,helpText, sizeof(helpText),357 __cfaabi_dbg_bits_print_buffer( helpText, sizeof(helpText), 279 358 "\nHeap statistics:\n" 280 359 " malloc: calls %u / storage %llu\n" … … 326 405 sbrk_calls, sbrk_storage 327 406 ); 328 __cfaabi_bits_write( fileno( stream ), helpText, len ); // ensures all bytes written or exit 329 return len; 407 return write( fileno( stream ), helpText, len ); // -1 => error 330 408 } // printStatsXML 331 409 #endif // __STATISTICS__ 332 410 333 334 //static inline void noMemory() {335 //abort( "Heap memory exhausted at %zu bytes.\n"336 //"Possible cause is very large memory allocation and/or large amount of unfreed storage allocated by the program or system/library routines.",337 //((char *)(sbrk( 0 )) - (char *)(heapManager.heapBegin)) );338 //} // noMemory411 // #comment TD : Is this the samething as Out-of-Memory? 412 static inline void noMemory() { 413 abort( "Heap memory exhausted at %zu bytes.\n" 414 "Possible cause is very large memory allocation and/or large amount of unfreed storage allocated by the program or system/library routines.", 415 ((char *)(sbrk( 0 )) - (char *)(heapManager.heapBegin)) ); 416 } // noMemory 339 417 340 418 341 419 static inline void checkAlign( size_t alignment ) { 342 if ( alignment < libAlign() || ! libPow2( alignment ) ) {343 abort( "Alignment %zu for memory allocation is less than %d and/or not a power of 2.", alignment, libAlign());420 if ( alignment < sizeof(void *) || ! libPow2( alignment ) ) { 421 abort( "Alignment %zu for memory allocation is less than sizeof(void *) and/or not a power of 2.", alignment ); 344 422 } // if 345 423 } // checkAlign … … 353 431 354 432 355 // thunk problem 433 static inline void checkHeader( bool check, const char * name, void * addr ) { 434 if ( unlikely( check ) ) { // bad address ? 435 abort( "Attempt to %s storage %p with address outside the heap.\n" 436 "Possible cause is duplicate free on same block or overwriting of memory.", 437 name, addr ); 438 } // if 439 } // checkHeader 440 441 // #comment TD : function should be commented and/or have a more evocative name 442 // this isn't either a check or a constructor which is what I would expect this function to be 443 static inline void fakeHeader( HeapManager.Storage.Header *& header, size_t & size, size_t & alignment ) { 444 if ( unlikely( (header->kind.fake.alignment & 1) == 1 ) ) { // fake header ? 445 size_t offset = header->kind.fake.offset; 446 alignment = header->kind.fake.alignment & -2; // remove flag from value 447 #ifdef __CFA_DEBUG__ 448 checkAlign( alignment ); // check alignment 449 #endif // __CFA_DEBUG__ 450 header = (HeapManager.Storage.Header *)((char *)header - offset); 451 } // if 452 } // fakeHeader 453 454 // #comment TD : Why is this a define 455 #define headerAddr( addr ) ((HeapManager.Storage.Header *)( (char *)addr - sizeof(HeapManager.Storage) )) 456 457 static inline bool headers( const char * name, void * addr, HeapManager.Storage.Header *& header, HeapManager.FreeHeader *& freeElem, size_t & size, size_t & alignment ) with ( heapManager ) { 458 header = headerAddr( addr ); 459 460 if ( unlikely( heapEnd < addr ) ) { // mmapped ? 461 fakeHeader( header, size, alignment ); 462 size = header->kind.real.blockSize & -3; // mmap size 463 return true; 464 } // if 465 466 #ifdef __CFA_DEBUG__ 467 checkHeader( addr < heapBegin || header < (HeapManager.Storage.Header *)heapBegin, name, addr ); // bad low address ? 468 #endif // __CFA_DEBUG__ 469 470 // #comment TD : This code looks weird... 471 // It's called as the first statement of both branches of the last if, with the same parameters in all cases 472 473 // header may be safe to dereference 474 fakeHeader( header, size, alignment ); 475 #ifdef __CFA_DEBUG__ 476 checkHeader( header < (HeapManager.Storage.Header *)heapBegin || (HeapManager.Storage.Header *)heapEnd < header, name, addr ); // bad address ? (offset could be + or -) 477 #endif // __CFA_DEBUG__ 478 479 freeElem = (HeapManager.FreeHeader *)((size_t)header->kind.real.home & -3); 480 #ifdef __CFA_DEBUG__ 481 if ( freeElem < &freeLists[0] || &freeLists[NoBucketSizes] <= freeElem ) { 482 abort( "Attempt to %s storage %p with corrupted header.\n" 483 "Possible cause is duplicate free on same block or overwriting of header information.", 484 name, addr ); 485 } // if 486 #endif // __CFA_DEBUG__ 487 size = freeElem->blockSize; 488 return false; 489 } // headers 490 491 492 static inline void * extend( size_t size ) with ( heapManager ) { 493 lock( extlock __cfaabi_dbg_ctx2 ); 494 ptrdiff_t rem = heapRemaining - size; 495 if ( rem < 0 ) { 496 // If the size requested is bigger than the current remaining storage, increase the size of the heap. 497 498 size_t increase = libCeiling( size > heapExpand ? size : heapExpand, libAlign() ); 499 if ( sbrk( increase ) == (void *)-1 ) { 500 unlock( extlock ); 501 errno = ENOMEM; 502 return 0; 503 } // if 504 #ifdef __STATISTICS__ 505 sbrk_calls += 1; 506 sbrk_storage += increase; 507 #endif // __STATISTICS__ 508 #ifdef __CFA_DEBUG__ 509 // Set new memory to garbage so subsequent uninitialized usages might fail. 510 memset( (char *)heapEnd + heapRemaining, '\377', increase ); 511 #endif // __CFA_DEBUG__ 512 rem = heapRemaining + increase - size; 513 } // if 514 515 HeapManager.Storage * block = (HeapManager.Storage *)heapEnd; 516 heapRemaining = rem; 517 heapEnd = (char *)heapEnd + size; 518 unlock( extlock ); 519 return block; 520 } // extend 521 522 356 523 size_t Bsearchl( unsigned int key, const unsigned int * vals, size_t dim ) { 357 524 size_t l = 0, m, h = dim; … … 368 535 369 536 370 static inline bool setMmapStart( size_t value ) { // true => mmapped, false => sbrk371 if ( value < pageSize || bucketSizes[NoBucketSizes - 1] < value ) return true;372 mmapStart = value; // set global373 374 // find the closest bucket size less than or equal to the mmapStart size375 maxBucketsUsed = Bsearchl( (unsigned int)mmapStart, bucketSizes, NoBucketSizes ); // binary search376 assert( maxBucketsUsed < NoBucketSizes ); // subscript failure ?377 assert( mmapStart <= bucketSizes[maxBucketsUsed] ); // search failure ?378 return false;379 } // setMmapStart380 381 382 static inline void checkHeader( bool check, const char name[], void * addr ) {383 if ( unlikely( check ) ) { // bad address ?384 abort( "Attempt to %s storage %p with address outside the heap.\n"385 "Possible cause is duplicate free on same block or overwriting of memory.",386 name, addr );387 } // if388 } // checkHeader389 390 391 static inline void fakeHeader( HeapManager.Storage.Header *& header, size_t & alignment ) {392 if ( unlikely( (header->kind.fake.alignment & 1) == 1 ) ) { // fake header ?393 size_t offset = header->kind.fake.offset;394 alignment = header->kind.fake.alignment & -2; // remove flag from value395 #ifdef __CFA_DEBUG__396 checkAlign( alignment ); // check alignment397 #endif // __CFA_DEBUG__398 header = (HeapManager.Storage.Header *)((char *)header - offset);399 } // if400 } // fakeHeader401 402 403 // <-------+----------------------------------------------------> bsize (bucket size)404 // |header |addr405 //==================================================================================406 // | alignment407 // <-----------------<------------+-----------------------------> bsize (bucket size)408 // |fake-header | addr409 #define headerAddr( addr ) ((HeapManager.Storage.Header *)( (char *)addr - sizeof(HeapManager.Storage) ))410 411 // <-------<<--------------------- dsize ---------------------->> bsize (bucket size)412 // |header |addr413 //==================================================================================414 // | alignment415 // <------------------------------<<---------- dsize --------->>> bsize (bucket size)416 // |fake-header |addr417 #define dataStorage( bsize, addr, header ) (bsize - ( (char *)addr - (char *)header ))418 419 420 static inline bool headers( const char name[] __attribute__(( unused )), void * addr, HeapManager.Storage.Header *& header, HeapManager.FreeHeader *& freeElem, size_t & size, size_t & alignment ) with ( heapManager ) {421 header = headerAddr( addr );422 423 if ( unlikely( heapEnd < addr ) ) { // mmapped ?424 fakeHeader( header, alignment );425 size = header->kind.real.blockSize & -3; // mmap size426 return true;427 } // if428 429 #ifdef __CFA_DEBUG__430 checkHeader( addr < heapBegin || header < (HeapManager.Storage.Header *)heapBegin, name, addr ); // bad low address ?431 #endif // __CFA_DEBUG__432 433 // header may be safe to dereference434 fakeHeader( header, alignment );435 #ifdef __CFA_DEBUG__436 checkHeader( header < (HeapManager.Storage.Header *)heapBegin || (HeapManager.Storage.Header *)heapEnd < header, name, addr ); // bad address ? (offset could be + or -)437 #endif // __CFA_DEBUG__438 439 freeElem = (HeapManager.FreeHeader *)((size_t)header->kind.real.home & -3);440 #ifdef __CFA_DEBUG__441 if ( freeElem < &freeLists[0] || &freeLists[NoBucketSizes] <= freeElem ) {442 abort( "Attempt to %s storage %p with corrupted header.\n"443 "Possible cause is duplicate free on same block or overwriting of header information.",444 name, addr );445 } // if446 #endif // __CFA_DEBUG__447 size = freeElem->blockSize;448 return false;449 } // headers450 451 452 static inline void * extend( size_t size ) with ( heapManager ) {453 lock( extlock __cfaabi_dbg_ctx2 );454 ptrdiff_t rem = heapRemaining - size;455 if ( rem < 0 ) {456 // If the size requested is bigger than the current remaining storage, increase the size of the heap.457 458 size_t increase = libCeiling( size > heapExpand ? size : heapExpand, libAlign() );459 if ( sbrk( increase ) == (void *)-1 ) {460 unlock( extlock );461 errno = ENOMEM;462 return 0p;463 } // if464 #ifdef __STATISTICS__465 sbrk_calls += 1;466 sbrk_storage += increase;467 #endif // __STATISTICS__468 #ifdef __CFA_DEBUG__469 // Set new memory to garbage so subsequent uninitialized usages might fail.470 memset( (char *)heapEnd + heapRemaining, '\377', increase );471 #endif // __CFA_DEBUG__472 rem = heapRemaining + increase - size;473 } // if474 475 HeapManager.Storage * block = (HeapManager.Storage *)heapEnd;476 heapRemaining = rem;477 heapEnd = (char *)heapEnd + size;478 unlock( extlock );479 return block;480 } // extend481 482 483 537 static inline void * doMalloc( size_t size ) with ( heapManager ) { 484 538 HeapManager.Storage * block; // pointer to new block of storage … … 487 541 // along with the block and is a multiple of the alignment size. 488 542 489 if ( unlikely( size > ~0ul - sizeof(HeapManager.Storage) ) ) return 0p;490 543 size_t tsize = size + sizeof(HeapManager.Storage); 491 544 if ( likely( tsize < mmapStart ) ) { // small size => sbrk … … 520 573 block = freeElem->freeList.pop(); 521 574 #endif // SPINLOCK 522 if ( unlikely( block == 0 p ) ) {// no free block ?575 if ( unlikely( block == 0 ) ) { // no free block ? 523 576 #if defined( SPINLOCK ) 524 577 unlock( freeElem->lock ); … … 529 582 530 583 block = (HeapManager.Storage *)extend( tsize ); // mutual exclusion on call 531 if ( unlikely( block == 0 p ) ) return 0p;532 #if defined( SPINLOCK )584 if ( unlikely( block == 0 ) ) return 0; 585 #if defined( SPINLOCK ) 533 586 } else { 534 587 freeElem->freeList = block->header.kind.real.next; 535 588 unlock( freeElem->lock ); 536 #endif // SPINLOCK589 #endif // SPINLOCK 537 590 } // if 538 591 539 592 block->header.kind.real.home = freeElem; // pointer back to free list of apropriate size 540 593 } else { // large size => mmap 541 if ( unlikely( size > ~0ul - pageSize ) ) return 0p;542 594 tsize = libCeiling( tsize, pageSize ); // must be multiple of page size 543 595 #ifdef __STATISTICS__ … … 557 609 } // if 558 610 559 void * a ddr= &(block->data); // adjust off header to user bytes611 void * area = &(block->data); // adjust off header to user bytes 560 612 561 613 #ifdef __CFA_DEBUG__ 562 assert( ((uintptr_t)a ddr& (libAlign() - 1)) == 0 ); // minimum alignment ?614 assert( ((uintptr_t)area & (libAlign() - 1)) == 0 ); // minimum alignment ? 563 615 __atomic_add_fetch( &allocFree, tsize, __ATOMIC_SEQ_CST ); 564 616 if ( traceHeap() ) { 565 617 enum { BufferSize = 64 }; 566 618 char helpText[BufferSize]; 567 int len = snprintf( helpText, BufferSize, "%p = Malloc( %zu ) (allocated %zu)\n", a ddr, size, tsize );568 // int len = snprintf( helpText, BufferSize, "Malloc %p %zu\n", a ddr, size );569 __cfaabi_ bits_write( STDERR_FILENO, helpText, len ); // print debug/nodebug619 int len = snprintf( helpText, BufferSize, "%p = Malloc( %zu ) (allocated %zu)\n", area, size, tsize ); 620 // int len = snprintf( helpText, BufferSize, "Malloc %p %zu\n", area, size ); 621 __cfaabi_dbg_bits_write( helpText, len ); 570 622 } // if 571 623 #endif // __CFA_DEBUG__ 572 624 573 return a ddr;625 return area; 574 626 } // doMalloc 575 627 … … 577 629 static inline void doFree( void * addr ) with ( heapManager ) { 578 630 #ifdef __CFA_DEBUG__ 579 if ( unlikely( heapManager.heapBegin == 0 p) ) {631 if ( unlikely( heapManager.heapBegin == 0 ) ) { 580 632 abort( "doFree( %p ) : internal error, called before heap is initialized.", addr ); 581 633 } // if … … 623 675 char helpText[BufferSize]; 624 676 int len = snprintf( helpText, sizeof(helpText), "Free( %p ) size:%zu\n", addr, size ); 625 __cfaabi_ bits_write( STDERR_FILENO, helpText, len ); // print debug/nodebug677 __cfaabi_dbg_bits_write( helpText, len ); 626 678 } // if 627 679 #endif // __CFA_DEBUG__ … … 629 681 630 682 631 size_t prtFree( HeapManager & manager ) with ( manager ) {683 size_t checkFree( HeapManager & manager ) with ( manager ) { 632 684 size_t total = 0; 633 685 #ifdef __STATISTICS__ 634 __cfaabi_ bits_acquire();635 __cfaabi_ bits_print_nolock( STDERR_FILENO,"\nBin lists (bin size : free blocks on list)\n" );686 __cfaabi_dbg_bits_acquire(); 687 __cfaabi_dbg_bits_print_nolock( "\nBin lists (bin size : free blocks on list)\n" ); 636 688 #endif // __STATISTICS__ 637 689 for ( unsigned int i = 0; i < maxBucketsUsed; i += 1 ) { … … 642 694 643 695 #if defined( SPINLOCK ) 644 for ( HeapManager.Storage * p = freeLists[i].freeList; p != 0 p; p = p->header.kind.real.next ) {696 for ( HeapManager.Storage * p = freeLists[i].freeList; p != 0; p = p->header.kind.real.next ) { 645 697 #else 646 for ( HeapManager.Storage * p = freeLists[i].freeList.top(); p != 0 p; p = p->header.kind.real.next.top ) {698 for ( HeapManager.Storage * p = freeLists[i].freeList.top(); p != 0; p = p->header.kind.real.next.top ) { 647 699 #endif // SPINLOCK 648 700 total += size; … … 653 705 654 706 #ifdef __STATISTICS__ 655 __cfaabi_ bits_print_nolock( STDERR_FILENO,"%7zu, %-7u ", size, N );656 if ( (i + 1) % 8 == 0 ) __cfaabi_ bits_print_nolock( STDERR_FILENO,"\n" );707 __cfaabi_dbg_bits_print_nolock( "%7zu, %-7u ", size, N ); 708 if ( (i + 1) % 8 == 0 ) __cfaabi_dbg_bits_print_nolock( "\n" ); 657 709 #endif // __STATISTICS__ 658 710 } // for 659 711 #ifdef __STATISTICS__ 660 __cfaabi_ bits_print_nolock( STDERR_FILENO,"\ntotal free blocks:%zu\n", total );661 __cfaabi_ bits_release();712 __cfaabi_dbg_bits_print_nolock( "\ntotal free blocks:%zu\n", total ); 713 __cfaabi_dbg_bits_release(); 662 714 #endif // __STATISTICS__ 663 715 return (char *)heapEnd - (char *)heapBegin - total; 664 } // prtFree 665 666 667 static void ?{}( HeapManager & manager ) with ( manager ) { 668 pageSize = sysconf( _SC_PAGESIZE ); 669 670 for ( unsigned int i = 0; i < NoBucketSizes; i += 1 ) { // initialize the free lists 671 freeLists[i].blockSize = bucketSizes[i]; 672 } // for 673 674 #ifdef FASTLOOKUP 675 unsigned int idx = 0; 676 for ( unsigned int i = 0; i < LookupSizes; i += 1 ) { 677 if ( i > bucketSizes[idx] ) idx += 1; 678 lookup[i] = idx; 679 } // for 680 #endif // FASTLOOKUP 681 682 if ( setMmapStart( default_mmap_start() ) ) { 683 abort( "HeapManager : internal error, mmap start initialization failure." ); 684 } // if 685 heapExpand = default_heap_expansion(); 686 687 char * end = (char *)sbrk( 0 ); 688 sbrk( (char *)libCeiling( (long unsigned int)end, libAlign() ) - end ); // move start of heap to multiple of alignment 689 heapBegin = heapEnd = sbrk( 0 ); // get new start point 690 } // HeapManager 691 692 693 static void ^?{}( HeapManager & ) { 694 #ifdef __STATISTICS__ 695 if ( traceHeapTerm() ) { 696 printStats(); 697 // if ( prtfree() ) prtFree( heapManager, true ); 698 } // if 699 #endif // __STATISTICS__ 700 } // ~HeapManager 701 702 703 static void memory_startup( void ) __attribute__(( constructor( STARTUP_PRIORITY_MEMORY ) )); 704 void memory_startup( void ) { 705 #ifdef __CFA_DEBUG__ 706 if ( unlikely( heapBoot ) ) { // check for recursion during system boot 707 // DO NOT USE STREAMS AS THEY MAY BE UNAVAILABLE AT THIS POINT. 708 abort( "boot() : internal error, recursively invoked during system boot." ); 709 } // if 710 heapBoot = true; 711 #endif // __CFA_DEBUG__ 712 713 //assert( heapManager.heapBegin != 0 ); 714 //heapManager{}; 715 if ( heapManager.heapBegin == 0p ) heapManager{}; 716 } // memory_startup 717 718 static void memory_shutdown( void ) __attribute__(( destructor( STARTUP_PRIORITY_MEMORY ) )); 719 void memory_shutdown( void ) { 720 ^heapManager{}; 721 } // memory_shutdown 716 } // checkFree 722 717 723 718 724 719 static inline void * mallocNoStats( size_t size ) { // necessary for malloc statistics 725 720 //assert( heapManager.heapBegin != 0 ); 726 if ( unlikely( heapManager.heapBegin == 0 p) ) heapManager{}; // called before memory_startup ?727 void * a ddr= doMalloc( size );728 if ( unlikely( a ddr == 0p) ) errno = ENOMEM; // POSIX729 return a ddr;721 if ( unlikely( heapManager.heapBegin == 0 ) ) heapManager{}; // called before memory_startup ? 722 void * area = doMalloc( size ); 723 if ( unlikely( area == 0 ) ) errno = ENOMEM; // POSIX 724 return area; 730 725 } // mallocNoStats 731 732 733 static inline void * callocNoStats( size_t noOfElems, size_t elemSize ) {734 size_t size = noOfElems * elemSize;735 char * addr = (char *)mallocNoStats( size );736 if ( unlikely( addr == 0p ) ) return 0p;737 738 HeapManager.Storage.Header * header;739 HeapManager.FreeHeader * freeElem;740 size_t bsize, alignment;741 bool mapped __attribute__(( unused )) = headers( "calloc", addr, header, freeElem, bsize, alignment );742 #ifndef __CFA_DEBUG__743 // Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero.744 if ( ! mapped )745 #endif // __CFA_DEBUG__746 // Zero entire data space even when > than size => realloc without a new allocation and zero fill works.747 // <-------00000000000000000000000000000000000000000000000000000> bsize (bucket size)748 // `-header`-addr `-size749 memset( addr, '\0', bsize - sizeof(HeapManager.Storage) ); // set to zeros750 751 header->kind.real.blockSize |= 2; // mark as zero filled752 return addr;753 } // callocNoStats754 726 755 727 … … 771 743 // subtract libAlign() because it is already the minimum alignment 772 744 // add sizeof(Storage) for fake header 773 char * addr = (char *)mallocNoStats( size + alignment - libAlign() + sizeof(HeapManager.Storage) ); 774 if ( unlikely( addr == 0p ) ) return addr; 745 // #comment TD : this is the only place that calls doMalloc without calling mallocNoStats, why ? 746 char * area = (char *)doMalloc( size + alignment - libAlign() + sizeof(HeapManager.Storage) ); 747 if ( unlikely( area == 0 ) ) return area; 775 748 776 749 // address in the block of the "next" alignment address 777 char * user = (char *)libCeiling( (uintptr_t)(a ddr+ sizeof(HeapManager.Storage)), alignment );750 char * user = (char *)libCeiling( (uintptr_t)(area + sizeof(HeapManager.Storage)), alignment ); 778 751 779 752 // address of header from malloc 780 HeapManager.Storage.Header * realHeader = headerAddr( a ddr);753 HeapManager.Storage.Header * realHeader = headerAddr( area ); 781 754 // address of fake header * before* the alignment location 782 755 HeapManager.Storage.Header * fakeHeader = headerAddr( user ); … … 788 761 return user; 789 762 } // memalignNoStats 790 791 792 static inline void * cmemalignNoStats( size_t alignment, size_t noOfElems, size_t elemSize ) {793 size_t size = noOfElems * elemSize;794 char * addr = (char *)memalignNoStats( alignment, size );795 if ( unlikely( addr == 0p ) ) return 0p;796 HeapManager.Storage.Header * header;797 HeapManager.FreeHeader * freeElem;798 size_t bsize;799 bool mapped __attribute__(( unused )) = headers( "cmemalign", addr, header, freeElem, bsize, alignment );800 #ifndef __CFA_DEBUG__801 // Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero.802 if ( ! mapped )803 #endif // __CFA_DEBUG__804 memset( addr, '\0', dataStorage( bsize, addr, header ) ); // set to zeros805 header->kind.real.blockSize |= 2; // mark as zero filled806 807 return addr;808 } // cmemalignNoStats809 763 810 764 … … 820 774 extern "C" { 821 775 // The malloc() function allocates size bytes and returns a pointer to the allocated memory. The memory is not 822 // initialized. If size is 0, then malloc() returns either 0p, or a unique pointer value that can later be776 // initialized. If size is 0, then malloc() returns either NULL, or a unique pointer value that can later be 823 777 // successfully passed to free(). 824 778 void * malloc( size_t size ) { … … 832 786 833 787 // The calloc() function allocates memory for an array of nmemb elements of size bytes each and returns a pointer to 834 // the allocated memory. The memory is set to zero. If nmemb or size is 0, then calloc() returns either 0p, or a788 // the allocated memory. The memory is set to zero. If nmemb or size is 0, then calloc() returns either NULL, or a 835 789 // unique pointer value that can later be successfully passed to free(). 836 790 void * calloc( size_t noOfElems, size_t elemSize ) { 791 size_t size = noOfElems * elemSize; 837 792 #ifdef __STATISTICS__ 838 793 __atomic_add_fetch( &calloc_calls, 1, __ATOMIC_SEQ_CST ); 839 __atomic_add_fetch( &calloc_storage, noOfElems * elemSize, __ATOMIC_SEQ_CST ); 840 #endif // __STATISTICS__ 841 842 return callocNoStats( noOfElems, elemSize ); 794 __atomic_add_fetch( &calloc_storage, size, __ATOMIC_SEQ_CST ); 795 #endif // __STATISTICS__ 796 797 char * area = (char *)mallocNoStats( size ); 798 if ( unlikely( area == 0 ) ) return 0; 799 800 HeapManager.Storage.Header * header; 801 HeapManager.FreeHeader * freeElem; 802 size_t asize, alignment; 803 bool mapped __attribute__(( unused )) = headers( "calloc", area, header, freeElem, asize, alignment ); 804 #ifndef __CFA_DEBUG__ 805 // Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero. 806 if ( ! mapped ) 807 #endif // __CFA_DEBUG__ 808 memset( area, '\0', asize - sizeof(HeapManager.Storage) ); // set to zeros 809 810 header->kind.real.blockSize |= 2; // mark as zero filled 811 return area; 843 812 } // calloc 813 814 // #comment TD : Document this function 815 void * cmemalign( size_t alignment, size_t noOfElems, size_t elemSize ) { 816 size_t size = noOfElems * elemSize; 817 #ifdef __STATISTICS__ 818 __atomic_add_fetch( &cmemalign_calls, 1, __ATOMIC_SEQ_CST ); 819 __atomic_add_fetch( &cmemalign_storage, size, __ATOMIC_SEQ_CST ); 820 #endif // __STATISTICS__ 821 822 char * area = (char *)memalignNoStats( alignment, size ); 823 if ( unlikely( area == 0 ) ) return 0; 824 HeapManager.Storage.Header * header; 825 HeapManager.FreeHeader * freeElem; 826 size_t asize; 827 bool mapped __attribute__(( unused )) = headers( "cmemalign", area, header, freeElem, asize, alignment ); 828 #ifndef __CFA_DEBUG__ 829 // Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero. 830 if ( ! mapped ) 831 #endif // __CFA_DEBUG__ 832 memset( area, '\0', asize - ( (char *)area - (char *)header ) ); // set to zeros 833 header->kind.real.blockSize |= 2; // mark as zero filled 834 835 return area; 836 } // cmemalign 844 837 845 838 // The realloc() function changes the size of the memory block pointed to by ptr to size bytes. The contents will be 846 839 // unchanged in the range from the start of the region up to the minimum of the old and new sizes. If the new size 847 // is larger than the old size, the added memory will not be initialized. If ptr is 0p, then the call is848 // equivalent to malloc(size), for all values of size; if size is equal to zero, and ptr is not 0p, then the call849 // is equivalent to free(ptr). Unless ptr is 0p, it must have been returned by an earlier call to malloc(),840 // is larger than the old size, the added memory will not be initialized. If ptr is NULL, then the call is 841 // equivalent to malloc(size), for all values of size; if size is equal to zero, and ptr is not NULL, then the call 842 // is equivalent to free(ptr). Unless ptr is NULL, it must have been returned by an earlier call to malloc(), 850 843 // calloc() or realloc(). If the area pointed to was moved, a free(ptr) is done. 851 void * realloc( void * oaddr, size_t size ) {844 void * realloc( void * addr, size_t size ) { 852 845 #ifdef __STATISTICS__ 853 846 __atomic_add_fetch( &realloc_calls, 1, __ATOMIC_SEQ_CST ); 854 847 #endif // __STATISTICS__ 855 848 856 // If size is equal to 0, either NULL or a pointer suitable to be passed to free() is returned. 857 if ( unlikely( size == 0 ) ) { free( oaddr ); return mallocNoStats( size ); } // special cases 858 if ( unlikely( oaddr == 0p ) ) return mallocNoStats( size ); 849 if ( unlikely( addr == 0 ) ) return mallocNoStats( size ); // special cases 850 if ( unlikely( size == 0 ) ) { free( addr ); return 0; } 859 851 860 852 HeapManager.Storage.Header * header; 861 853 HeapManager.FreeHeader * freeElem; 862 size_t bsize, oalign = 0; 863 headers( "realloc", oaddr, header, freeElem, bsize, oalign ); 864 865 size_t odsize = dataStorage( bsize, oaddr, header ); // data storage available in bucket 866 if ( size <= odsize && odsize <= size * 2 ) { // allow up to 50% wasted storage in smaller size 867 // Do not know size of original allocation => cannot do 0 fill for any additional space because do not know 868 // where to start filling, i.e., do not overwrite existing values in space. 869 // 854 size_t asize, alignment = 0; 855 headers( "realloc", addr, header, freeElem, asize, alignment ); 856 857 size_t usize = asize - ( (char *)addr - (char *)header ); // compute the amount of user storage in the block 858 if ( usize >= size ) { // already sufficient storage 870 859 // This case does not result in a new profiler entry because the previous one still exists and it must match with 871 860 // the free for this memory. Hence, this realloc does not appear in the profiler output. 872 return oaddr;861 return addr; 873 862 } // if 874 863 … … 877 866 #endif // __STATISTICS__ 878 867 879 // change size and copy old content to new storage 880 881 void * naddr; 882 if ( unlikely( oalign != 0 ) ) { // previous request memalign? 883 if ( unlikely( header->kind.real.blockSize & 2 ) ) { // previous request zero fill 884 naddr = cmemalignNoStats( oalign, 1, size ); // create new aligned area 885 } else { 886 naddr = memalignNoStats( oalign, size ); // create new aligned area 887 } // if 868 void * area; 869 if ( unlikely( alignment != 0 ) ) { // previous request memalign? 870 area = memalign( alignment, size ); // create new aligned area 888 871 } else { 889 if ( unlikely( header->kind.real.blockSize & 2 ) ) { // previous request zero fill 890 naddr = callocNoStats( 1, size ); // create new area 891 } else { 892 naddr = mallocNoStats( size ); // create new area 893 } // if 872 area = mallocNoStats( size ); // create new area 894 873 } // if 895 if ( unlikely( naddr == 0p ) ) return 0p; 896 897 headers( "realloc", naddr, header, freeElem, bsize, oalign ); 898 size_t ndsize = dataStorage( bsize, naddr, header ); // data storage avilable in bucket 899 // To preserve prior fill, the entire bucket must be copied versus the size. 900 memcpy( naddr, oaddr, MIN( odsize, ndsize ) ); // copy bytes 901 free( oaddr ); 902 return naddr; 874 if ( unlikely( area == 0 ) ) return 0; 875 if ( unlikely( header->kind.real.blockSize & 2 ) ) { // previous request zero fill (calloc/cmemalign) ? 876 assert( (header->kind.real.blockSize & 1) == 0 ); 877 bool mapped __attribute__(( unused )) = headers( "realloc", area, header, freeElem, asize, alignment ); 878 #ifndef __CFA_DEBUG__ 879 // Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero. 880 if ( ! mapped ) 881 #endif // __CFA_DEBUG__ 882 memset( (char *)area + usize, '\0', asize - ( (char *)area - (char *)header ) - usize ); // zero-fill back part 883 header->kind.real.blockSize |= 2; // mark new request as zero fill 884 } // if 885 memcpy( area, addr, usize ); // copy bytes 886 free( addr ); 887 return area; 903 888 } // realloc 889 904 890 905 891 // The obsolete function memalign() allocates size bytes and returns a pointer to the allocated memory. The memory … … 911 897 #endif // __STATISTICS__ 912 898 913 return memalignNoStats( alignment, size ); 899 void * area = memalignNoStats( alignment, size ); 900 901 return area; 914 902 } // memalign 915 916 917 // The cmemalign() function is the same as calloc() with memory alignment.918 void * cmemalign( size_t alignment, size_t noOfElems, size_t elemSize ) {919 #ifdef __STATISTICS__920 __atomic_add_fetch( &cmemalign_calls, 1, __ATOMIC_SEQ_CST );921 __atomic_add_fetch( &cmemalign_storage, noOfElems * elemSize, __ATOMIC_SEQ_CST );922 #endif // __STATISTICS__923 924 return cmemalignNoStats( alignment, noOfElems, elemSize );925 } // cmemalign926 903 927 904 // The function aligned_alloc() is the same as memalign(), except for the added restriction that size should be a … … 934 911 // The function posix_memalign() allocates size bytes and places the address of the allocated memory in *memptr. The 935 912 // address of the allocated memory will be a multiple of alignment, which must be a power of two and a multiple of 936 // sizeof(void *). If size is 0, then posix_memalign() returns either 0p, or a unique pointer value that can later913 // sizeof(void *). If size is 0, then posix_memalign() returns either NULL, or a unique pointer value that can later 937 914 // be successfully passed to free(3). 938 915 int posix_memalign( void ** memptr, size_t alignment, size_t size ) { 939 916 if ( alignment < sizeof(void *) || ! libPow2( alignment ) ) return EINVAL; // check alignment 940 917 * memptr = memalign( alignment, size ); 941 if ( unlikely( * memptr == 0 p) ) return ENOMEM;918 if ( unlikely( * memptr == 0 ) ) return ENOMEM; 942 919 return 0; 943 920 } // posix_memalign … … 952 929 // The free() function frees the memory space pointed to by ptr, which must have been returned by a previous call to 953 930 // malloc(), calloc() or realloc(). Otherwise, or if free(ptr) has already been called before, undefined behavior 954 // occurs. If ptr is 0p, no operation is performed.931 // occurs. If ptr is NULL, no operation is performed. 955 932 void free( void * addr ) { 956 933 #ifdef __STATISTICS__ … … 958 935 #endif // __STATISTICS__ 959 936 960 if ( unlikely( addr == 0p ) ) { // special case 961 // #ifdef __CFA_DEBUG__ 962 // if ( traceHeap() ) { 963 // #define nullmsg "Free( 0x0 ) size:0\n" 964 // // Do not debug print free( 0p ), as it can cause recursive entry from sprintf. 965 // __cfaabi_dbg_write( nullmsg, sizeof(nullmsg) - 1 ); 966 // } // if 967 // #endif // __CFA_DEBUG__ 937 // #comment TD : To decrease nesting I would but the special case in the 938 // else instead, plus it reads more naturally to have the 939 // short / normal case instead 940 if ( unlikely( addr == 0 ) ) { // special case 941 #ifdef __CFA_DEBUG__ 942 if ( traceHeap() ) { 943 #define nullmsg "Free( 0x0 ) size:0\n" 944 // Do not debug print free( 0 ), as it can cause recursive entry from sprintf. 945 __cfaabi_dbg_bits_write( nullmsg, sizeof(nullmsg) - 1 ); 946 } // if 947 #endif // __CFA_DEBUG__ 968 948 return; 969 949 } // exit … … 972 952 } // free 973 953 974 975 // The malloc_alignment() function returns the alignment of the allocation. 954 // The mallopt() function adjusts parameters that control the behavior of the memory-allocation functions (see 955 // malloc(3)). The param argument specifies the parameter to be modified, and value specifies the new value for that 956 // parameter. 957 int mallopt( int option, int value ) { 958 choose( option ) { 959 case M_TOP_PAD: 960 if ( setHeapExpand( value ) ) fallthru default; 961 case M_MMAP_THRESHOLD: 962 if ( setMmapStart( value ) ) fallthru default; 963 default: 964 // #comment TD : 1 for unsopported feels wrong 965 return 1; // success, or unsupported 966 } // switch 967 return 0; // error 968 } // mallopt 969 970 // The malloc_trim() function attempts to release free memory at the top of the heap (by calling sbrk(2) with a 971 // suitable argument). 972 int malloc_trim( size_t ) { 973 return 0; // => impossible to release memory 974 } // malloc_trim 975 976 // The malloc_usable_size() function returns the number of usable bytes in the block pointed to by ptr, a pointer to 977 // a block of memory allocated by malloc(3) or a related function. 978 size_t malloc_usable_size( void * addr ) { 979 if ( unlikely( addr == 0 ) ) return 0; // null allocation has 0 size 980 981 HeapManager.Storage.Header * header; 982 HeapManager.FreeHeader * freeElem; 983 size_t size, alignment; 984 985 headers( "malloc_usable_size", addr, header, freeElem, size, alignment ); 986 size_t usize = size - ( (char *)addr - (char *)header ); // compute the amount of user storage in the block 987 return usize; 988 } // malloc_usable_size 989 990 991 // The malloc_alignment() function returns the alignment of the allocation. 976 992 size_t malloc_alignment( void * addr ) { 977 if ( unlikely( addr == 0 p) ) return libAlign(); // minimum alignment978 HeapManager.Storage.Header * header = headerAddr( addr);993 if ( unlikely( addr == 0 ) ) return libAlign(); // minimum alignment 994 HeapManager.Storage.Header * header = (HeapManager.Storage.Header *)( (char *)addr - sizeof(HeapManager.Storage) ); 979 995 if ( (header->kind.fake.alignment & 1) == 1 ) { // fake header ? 980 996 return header->kind.fake.alignment & -2; // remove flag from value … … 985 1001 986 1002 987 // The malloc_zero_fill() function returns true if the allocation is zero filled, i.e., initially allocated by calloc().1003 // The malloc_zero_fill() function returns true if the allocation is zero filled, i.e., initially allocated by calloc(). 988 1004 bool malloc_zero_fill( void * addr ) { 989 if ( unlikely( addr == 0p ) ) return false; // null allocation is not zero fill 990 HeapManager.Storage.Header * header = headerAddr( addr ); 1005 if ( unlikely( addr == 0 ) ) return false; // null allocation is not zero fill 1006 1007 HeapManager.Storage.Header * header = (HeapManager.Storage.Header *)( (char *)addr - sizeof(HeapManager.Storage) ); 991 1008 if ( (header->kind.fake.alignment & 1) == 1 ) { // fake header ? 992 1009 header = (HeapManager.Storage.Header *)((char *)header - header->kind.fake.offset); … … 996 1013 997 1014 998 // The malloc_usable_size() function returns the number of usable bytes in the block pointed to by ptr, a pointer to 999 // a block of memory allocated by malloc(3) or a related function. 1000 size_t malloc_usable_size( void * addr ) { 1001 if ( unlikely( addr == 0p ) ) return 0; // null allocation has 0 size 1002 HeapManager.Storage.Header * header; 1003 HeapManager.FreeHeader * freeElem; 1004 size_t bsize, alignment; 1005 1006 headers( "malloc_usable_size", addr, header, freeElem, bsize, alignment ); 1007 return dataStorage( bsize, addr, header ); // data storage in bucket 1008 } // malloc_usable_size 1009 1010 1011 // The malloc_stats() function prints (on default standard error) statistics about memory allocated by malloc(3) and 1012 // related functions. 1015 // The malloc_stats() function prints (on default standard error) statistics about memory allocated by malloc(3) and 1016 // related functions. 1013 1017 void malloc_stats( void ) { 1014 1018 #ifdef __STATISTICS__ 1015 1019 printStats(); 1016 if ( prtFree() ) prtFree( heapManager );1020 if ( checkFree() ) checkFree( heapManager ); 1017 1021 #endif // __STATISTICS__ 1018 1022 } // malloc_stats 1019 1023 1020 1024 // The malloc_stats_fd() function changes the file descripter where malloc_stats() writes the statistics. 1021 int malloc_stats_fd( int fd __attribute__(( unused ))) {1025 int malloc_stats_fd( int fd ) { 1022 1026 #ifdef __STATISTICS__ 1023 1027 int temp = statfd; … … 1029 1033 } // malloc_stats_fd 1030 1034 1031 1032 // The mallopt() function adjusts parameters that control the behavior of the memory-allocation functions (see1033 // malloc(3)). The param argument specifies the parameter to be modified, and value specifies the new value for that1034 // parameter.1035 int mallopt( int option, int value ) {1036 choose( option ) {1037 case M_TOP_PAD:1038 if ( setHeapExpand( value ) ) return 1;1039 case M_MMAP_THRESHOLD:1040 if ( setMmapStart( value ) ) return 1;1041 } // switch1042 return 0; // error, unsupported1043 } // mallopt1044 1045 // The malloc_trim() function attempts to release free memory at the top of the heap (by calling sbrk(2) with a1046 // suitable argument).1047 int malloc_trim( size_t ) {1048 return 0; // => impossible to release memory1049 } // malloc_trim1050 1051 1052 1035 // The malloc_info() function exports an XML string that describes the current state of the memory-allocation 1053 1036 // implementation in the caller. The string is printed on the file stream stream. The exported string includes 1054 1037 // information about all arenas (see malloc(3)). 1055 1038 int malloc_info( int options, FILE * stream ) { 1056 if ( options != 0 ) { errno = EINVAL; return -1; }1057 1039 return printStatsXML( stream ); 1058 1040 } // malloc_info … … 1064 1046 // structure is returned as the function result. (It is the caller's responsibility to free(3) this memory.) 1065 1047 void * malloc_get_state( void ) { 1066 return 0 p; // unsupported1048 return 0; // unsupported 1067 1049 } // malloc_get_state 1068 1050 … … 1076 1058 1077 1059 1078 // Must have CFA linkage to overload with C linkage realloc.1079 void * realloc( void * oaddr, size_t nalign, size_t size ) {1080 #ifdef __STATISTICS__1081 __atomic_add_fetch( &realloc_calls, 1, __ATOMIC_SEQ_CST );1082 #endif // __STATISTICS__1083 1084 // If size is equal to 0, either NULL or a pointer suitable to be passed to free() is returned.1085 if ( unlikely( size == 0 ) ) { free( oaddr ); return mallocNoStats( size ); } // special cases1086 if ( unlikely( oaddr == 0p ) ) return mallocNoStats( size );1087 1088 if ( unlikely( nalign == 0 ) ) nalign = libAlign(); // reset alignment to minimum1089 #ifdef __CFA_DEBUG__1090 else1091 checkAlign( nalign ); // check alignment1092 #endif // __CFA_DEBUG__1093 1094 HeapManager.Storage.Header * header;1095 HeapManager.FreeHeader * freeElem;1096 size_t bsize, oalign = 0;1097 headers( "realloc", oaddr, header, freeElem, bsize, oalign );1098 size_t odsize = dataStorage( bsize, oaddr, header ); // data storage available in bucket1099 1100 if ( oalign != 0 && (uintptr_t)oaddr % nalign == 0 ) { // has alignment and just happens to work out1101 headerAddr( oaddr )->kind.fake.alignment = nalign | 1; // update alignment (could be the same)1102 return realloc( oaddr, size );1103 } // if1104 1105 #ifdef __STATISTICS__1106 __atomic_add_fetch( &realloc_storage, size, __ATOMIC_SEQ_CST );1107 #endif // __STATISTICS__1108 1109 // change size and copy old content to new storage1110 1111 void * naddr;1112 if ( unlikely( header->kind.real.blockSize & 2 ) ) { // previous request zero fill1113 naddr = cmemalignNoStats( nalign, 1, size ); // create new aligned area1114 } else {1115 naddr = memalignNoStats( nalign, size ); // create new aligned area1116 } // if1117 1118 headers( "realloc", naddr, header, freeElem, bsize, oalign );1119 size_t ndsize = dataStorage( bsize, naddr, header ); // data storage avilable in bucket1120 // To preserve prior fill, the entire bucket must be copied versus the size.1121 memcpy( naddr, oaddr, MIN( odsize, ndsize ) ); // copy bytes1122 free( oaddr );1123 return naddr;1124 } // realloc1125 1126 1127 1060 // Local Variables: // 1128 1061 // tab-width: 4 // -
libcfa/src/interpose.cfa
r3d5701e r9fb8f01 10 10 // Created On : Wed Mar 29 16:10:31 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Feb 17 10:18:53 202013 // Update Count : 1 6612 // Last Modified On : Sun Jul 14 22:57:16 2019 13 // Update Count : 116 14 14 // 15 15 … … 29 29 #include "bits/signal.hfa" // sigHandler_? 30 30 #include "startup.hfa" // STARTUP_PRIORITY_CORE 31 #include <assert.h>32 31 33 32 //============================================================================================= … … 41 40 42 41 typedef void (* generic_fptr_t)(void); 43 generic_fptr_t interpose_symbol( const char symbol[], const char version[]) {42 generic_fptr_t interpose_symbol( const char * symbol, const char * version ) { 44 43 const char * error; 45 44 … … 96 95 void __cfaabi_interpose_startup(void) __attribute__(( constructor( STARTUP_PRIORITY_CORE ) )); 97 96 void __cfaabi_interpose_startup( void ) { 98 const char *version = 0p;97 const char *version = NULL; 99 98 100 99 preload_libgcc(); … … 106 105 #pragma GCC diagnostic pop 107 106 108 // As a precaution (and necessity), errors that result in termination are delivered on a separate stack because109 // task stacks might be very small (4K) and the signal delivery corrupts memory to the point that a clean110 // shutdown is impossible. Also, when a stack overflow encounters the non-accessible sentinel page (debug only)111 // and generates a segment fault, the signal cannot be delivered on the sentinel page. Finally, calls to abort112 // print a stack trace that uses substantial stack space.113 114 #define MINSTKSZ SIGSTKSZ * 8115 static char stack[MINSTKSZ] __attribute__(( aligned (16) ));116 static stack_t ss;117 118 ss.ss_sp = stack;119 ss.ss_size = MINSTKSZ;120 ss.ss_flags = 0;121 if ( sigaltstack( &ss, 0p ) == -1 ) {122 abort( "__cfaabi_interpose_startup : internal error, sigaltstack error(%d) %s.", errno, strerror( errno ) );123 } // if124 125 107 // Failure handler 126 __cfaabi_sigaction( SIGSEGV, sigHandler_segv, SA_SIGINFO | SA_ONSTACK ); 127 __cfaabi_sigaction( SIGBUS , sigHandler_segv, SA_SIGINFO | SA_ONSTACK ); 128 __cfaabi_sigaction( SIGILL , sigHandler_ill , SA_SIGINFO | SA_ONSTACK ); 129 __cfaabi_sigaction( SIGFPE , sigHandler_fpe , SA_SIGINFO | SA_ONSTACK ); 130 __cfaabi_sigaction( SIGTERM, sigHandler_term, SA_SIGINFO | SA_ONSTACK | SA_RESETHAND ); // one shot handler, return to default 131 __cfaabi_sigaction( SIGINT , sigHandler_term, SA_SIGINFO | SA_ONSTACK | SA_RESETHAND ); 132 __cfaabi_sigaction( SIGABRT, sigHandler_term, SA_SIGINFO | SA_ONSTACK | SA_RESETHAND ); 133 __cfaabi_sigaction( SIGHUP , sigHandler_term, SA_SIGINFO | SA_ONSTACK | SA_RESETHAND ); // terminal hangup 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 ); 134 115 } 135 116 } … … 142 123 void exit( int status, const char fmt[], ... ) __attribute__(( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ )); 143 124 void abort( const char fmt[], ... ) __attribute__(( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )); 144 void abort( bool signalAbort, const char fmt[], ... ) __attribute__(( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ ));145 125 146 126 extern "C" { 147 127 void abort( void ) __attribute__(( __nothrow__, __leaf__, __noreturn__ )) { 148 abort( false, "%s", "");128 abort( NULL ); 149 129 } 150 130 … … 152 132 va_list argp; 153 133 va_start( argp, fmt ); 154 abort( f alse, fmt, argp );134 abort( fmt, argp ); 155 135 va_end( argp ); 156 136 } … … 161 141 } 162 142 163 void * kernel_abort( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return 0p; } 164 void kernel_abort_msg( void * data, char buffer[], int size ) __attribute__(( __nothrow__, __leaf__, __weak__ )) {} 165 // See concurrency/kernel.cfa for strong definition used in multi-processor mode. 143 void * kernel_abort ( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return NULL; } 144 void kernel_abort_msg( void * data, char * buffer, int size ) __attribute__(( __nothrow__, __leaf__, __weak__ )) {} 166 145 int kernel_abort_lastframe( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return 4; } 167 146 168 147 enum { abort_text_size = 1024 }; 169 148 static char abort_text[ abort_text_size ]; 170 171 static void __cfaabi_backtrace( int start ) { 172 enum { Frames = 50, }; // maximum number of stack frames 173 int last = kernel_abort_lastframe(); // skip last N stack frames 149 static int abort_lastframe; 150 151 void exit( int status, const char fmt[], ... ) __attribute__(( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ )) { 152 va_list args; 153 va_start( args, fmt ); 154 vfprintf( stderr, fmt, args ); 155 va_end( args ); 156 __cabi_libc.exit( status ); 157 } 158 159 void abort( const char fmt[], ... ) __attribute__(( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )) { 160 void * kernel_data = kernel_abort(); // must be done here to lock down kernel 161 int len; 162 163 abort_lastframe = kernel_abort_lastframe(); 164 len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid) 165 __cfaabi_dbg_bits_write( abort_text, len ); 166 167 if ( fmt ) { 168 va_list args; 169 va_start( args, fmt ); 170 171 len = vsnprintf( abort_text, abort_text_size, fmt, args ); 172 va_end( args ); 173 __cfaabi_dbg_bits_write( abort_text, len ); 174 175 if ( fmt[strlen( fmt ) - 1] != '\n' ) { // add optional newline if missing at the end of the format text 176 __cfaabi_dbg_bits_write( "\n", 1 ); 177 } 178 } 179 180 kernel_abort_msg( kernel_data, abort_text, abort_text_size ); 181 __cabi_libc.abort(); 182 } 183 184 static void __cfaabi_backtrace() { 185 enum { 186 Frames = 50, // maximum number of stack frames 187 Start = 8, // skip first N stack frames 188 }; 174 189 175 190 void * array[Frames]; 176 191 size_t size = backtrace( array, Frames ); 177 char ** messages = backtrace_symbols( array, size ); // does not demangle names 178 179 *index( messages[0], '(' ) = '\0'; // find executable name 180 __cfaabi_bits_print_nolock( STDERR_FILENO, "Stack back trace for: %s\n", messages[0]); 181 182 for ( unsigned int i = start; i < size - last && messages != 0p; i += 1 ) { 183 char * name = 0p, * offset_begin = 0p, * offset_end = 0p; 184 185 for ( char * p = messages[i]; *p; p += 1 ) { // find parantheses and +offset 186 //__cfaabi_bits_print_nolock( "X %s\n", p); 192 char ** messages = backtrace_symbols( array, size ); 193 194 // find executable name 195 *index( messages[0], '(' ) = '\0'; 196 __cfaabi_dbg_bits_print_nolock( "Stack back trace for: %s\n", messages[0]); 197 198 for ( int i = Start; i < size - abort_lastframe && messages != NULL; i += 1 ) { 199 char * name = NULL, * offset_begin = NULL, * offset_end = NULL; 200 201 for ( char * p = messages[i]; *p; ++p ) { 202 //__cfaabi_dbg_bits_print_nolock( "X %s\n", p); 203 // find parantheses and +offset 187 204 if ( *p == '(' ) { 188 205 name = p; … … 195 212 } 196 213 197 // if line contains symbol ,print it198 int frameNo = i - start;214 // if line contains symbol print it 215 int frameNo = i - Start; 199 216 if ( name && offset_begin && offset_end && name < offset_begin ) { 200 *name++ = '\0'; // delimit strings 217 // delimit strings 218 *name++ = '\0'; 201 219 *offset_begin++ = '\0'; 202 220 *offset_end++ = '\0'; 203 221 204 __cfaabi_ bits_print_nolock( STDERR_FILENO,"(%i) %s : %s + %s %s\n", frameNo, messages[i], name, offset_begin, offset_end);222 __cfaabi_dbg_bits_print_nolock( "(%i) %s : %s + %s %s\n", frameNo, messages[i], name, offset_begin, offset_end); 205 223 } else { // otherwise, print the whole line 206 __cfaabi_ bits_print_nolock( STDERR_FILENO,"(%i) %s\n", frameNo, messages[i] );224 __cfaabi_dbg_bits_print_nolock( "(%i) %s\n", frameNo, messages[i] ); 207 225 } 208 226 } … … 210 228 } 211 229 212 void exit( int status, const char fmt[], ... ) {213 va_list args;214 va_start( args, fmt );215 vfprintf( stderr, fmt, args );216 va_end( args );217 __cabi_libc.exit( status );218 }219 220 void abort( bool signalAbort, const char fmt[], ... ) {221 void * kernel_data = kernel_abort(); // must be done here to lock down kernel222 int len;223 224 signal( SIGABRT, SIG_DFL ); // prevent final "real" abort from recursing to handler225 226 len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid)227 __cfaabi_bits_write( STDERR_FILENO, abort_text, len );228 229 assert( fmt );230 va_list args;231 va_start( args, fmt );232 233 len = vsnprintf( abort_text, abort_text_size, fmt, args );234 va_end( args );235 __cfaabi_bits_write( STDERR_FILENO, abort_text, len );236 237 if ( fmt[strlen( fmt ) - 1] != '\n' ) { // add optional newline if missing at the end of the format text238 __cfaabi_dbg_write( "\n", 1 );239 } // if240 kernel_abort_msg( kernel_data, abort_text, abort_text_size );241 242 __cfaabi_backtrace( signalAbort ? 4 : 2 );243 244 __cabi_libc.abort(); // print stack trace in handler245 }246 247 void abort( const char fmt[], ... ) {248 va_list args;249 va_start( args, fmt );250 abort( false, fmt, args );251 va_end( args );252 }253 254 230 void sigHandler_segv( __CFA_SIGPARMS__ ) { 255 if ( sfp->si_addr == 0p ) { 256 abort( true, "Null pointer (0p) dereference.\n" ); 257 } else { 258 abort( true, "%s at memory location %p.\n" 259 "Possible cause is reading outside the address space or writing to a protected area within the address space with an invalid pointer or subscript.\n", 260 (sig == SIGSEGV ? "Segment fault" : "Bus error"), sfp->si_addr ); 261 } 231 abort( "Addressing invalid memory at location %p\n" 232 "Possible cause is reading outside the address space or writing to a protected area within the address space with an invalid pointer or subscript.\n", 233 sfp->si_addr ); 262 234 } 263 235 264 236 void sigHandler_ill( __CFA_SIGPARMS__ ) { 265 abort( true,"Executing illegal instruction at location %p.\n"237 abort( "Executing illegal instruction at location %p.\n" 266 238 "Possible cause is stack corruption.\n", 267 239 sfp->si_addr ); … … 279 251 default: msg = "unknown"; 280 252 } // choose 281 abort( true, "Computation error %s at location %p.\n", msg, sfp->si_addr ); 253 abort( "Computation error %s at location %p.\n", msg, sfp->si_addr ); 254 } 255 256 void sigHandler_abrt( __CFA_SIGPARMS__ ) { 257 __cfaabi_backtrace(); 258 259 // reset default signal handler 260 __cfaabi_sigdefault( SIGABRT ); 261 262 raise( SIGABRT ); 282 263 } 283 264 284 265 void sigHandler_term( __CFA_SIGPARMS__ ) { 285 abort( true, "Application interrupted by signal: %s.\n", strsignal( sig ));266 abort( "Application stopped by %s signal.", sig == SIGINT ? "an interrupt (SIGINT)" : "a terminate (SIGTERM)" ); 286 267 } 287 268 -
libcfa/src/iostream.cfa
r3d5701e r9fb8f01 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 20 15:53:23 202013 // Update Count : 82 912 // Last Modified On : Sat Jul 13 08:07:59 2019 13 // Update Count : 821 14 14 // 15 15 … … 19 19 #include <stdio.h> 20 20 #include <stdbool.h> // true/false 21 #include <stdint.h> // UINT64_MAX22 21 //#include <string.h> // strlen, strcmp 23 22 extern size_t strlen (const char *__s) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); … … 36 35 forall( dtype ostype | ostream( ostype ) ) { 37 36 ostype & ?|?( ostype & os, zero_t ) { 38 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );37 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 39 38 fmt( os, "%d", 0n ); 40 39 return os; … … 45 44 46 45 ostype & ?|?( ostype & os, one_t ) { 47 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );46 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 48 47 fmt( os, "%d", 1n ); 49 48 return os; … … 54 53 55 54 ostype & ?|?( ostype & os, bool b ) { 56 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );55 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 57 56 fmt( os, "%s", b ? "true" : "false" ); 58 57 return os; … … 64 63 ostype & ?|?( ostype & os, char c ) { 65 64 fmt( os, "%c", c ); 66 if ( c == '\n' ) $setNL( os, true );65 if ( c == '\n' ) setNL( os, true ); 67 66 return sepOff( os ); 68 67 } // ?|? … … 72 71 73 72 ostype & ?|?( ostype & os, signed char sc ) { 74 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );73 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 75 74 fmt( os, "%hhd", sc ); 76 75 return os; … … 81 80 82 81 ostype & ?|?( ostype & os, unsigned char usc ) { 83 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );82 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 84 83 fmt( os, "%hhu", usc ); 85 84 return os; … … 90 89 91 90 ostype & ?|?( ostype & os, short int si ) { 92 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );91 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 93 92 fmt( os, "%hd", si ); 94 93 return os; … … 99 98 100 99 ostype & ?|?( ostype & os, unsigned short int usi ) { 101 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );100 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 102 101 fmt( os, "%hu", usi ); 103 102 return os; … … 108 107 109 108 ostype & ?|?( ostype & os, int i ) { 110 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );109 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 111 110 fmt( os, "%d", i ); 112 111 return os; … … 117 116 118 117 ostype & ?|?( ostype & os, unsigned int ui ) { 119 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );118 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 120 119 fmt( os, "%u", ui ); 121 120 return os; … … 126 125 127 126 ostype & ?|?( ostype & os, long int li ) { 128 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );127 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 129 128 fmt( os, "%ld", li ); 130 129 return os; … … 135 134 136 135 ostype & ?|?( ostype & os, unsigned long int uli ) { 137 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );136 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 138 137 fmt( os, "%lu", uli ); 139 138 return os; … … 144 143 145 144 ostype & ?|?( ostype & os, long long int lli ) { 146 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );145 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 147 146 fmt( os, "%lld", lli ); 148 147 return os; … … 153 152 154 153 ostype & ?|?( ostype & os, unsigned long long int ulli ) { 155 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );154 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 156 155 fmt( os, "%llu", ulli ); 157 156 return os; … … 160 159 (ostype &)(os | ulli); ends( os ); 161 160 } // ?|? 162 163 #if defined( __SIZEOF_INT128__ )164 // UINT64_MAX 18_446_744_073_709_551_615_ULL165 #define P10_UINT64 10_000_000_000_000_000_000_ULL // 19 zeroes166 167 static void base10_128( ostype & os, unsigned int128 val ) {168 if ( val > UINT64_MAX ) {169 base10_128( os, val / P10_UINT64 ); // recursive170 fmt( os, "%.19lu", (uint64_t)(val % P10_UINT64) );171 } else {172 fmt( os, "%lu", (uint64_t)val );173 } // if174 } // base10_128175 176 static void base10_128( ostype & os, int128 val ) {177 if ( val < 0 ) {178 fmt( os, "-" ); // leading negative sign179 val = -val;180 } // if181 base10_128( os, (unsigned int128)val ); // print zero/positive value182 } // base10_128183 184 ostype & ?|?( ostype & os, int128 llli ) {185 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );186 base10_128( os, llli );187 return os;188 } // ?|?189 void & ?|?( ostype & os, int128 llli ) {190 (ostype &)(os | llli); ends( os );191 } // ?|?192 193 ostype & ?|?( ostype & os, unsigned int128 ullli ) {194 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );195 base10_128( os, ullli );196 return os;197 } // ?|?198 void & ?|?( ostype & os, unsigned int128 ullli ) {199 (ostype &)(os | ullli); ends( os );200 } // ?|?201 #endif // __SIZEOF_INT128__202 161 203 162 #define PrintWithDP( os, format, val, ... ) \ … … 216 175 217 176 ostype & ?|?( ostype & os, float f ) { 218 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );177 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 219 178 PrintWithDP( os, "%g", f ); 220 179 return os; … … 225 184 226 185 ostype & ?|?( ostype & os, double d ) { 227 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );186 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 228 187 PrintWithDP( os, "%.*lg", d, DBL_DIG ); 229 188 return os; … … 234 193 235 194 ostype & ?|?( ostype & os, long double ld ) { 236 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );195 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 237 196 PrintWithDP( os, "%.*Lg", ld, LDBL_DIG ); 238 197 return os; … … 243 202 244 203 ostype & ?|?( ostype & os, float _Complex fc ) { 245 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );204 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 246 205 // os | crealf( fc ) | nonl; 247 206 PrintWithDP( os, "%g", crealf( fc ) ); … … 255 214 256 215 ostype & ?|?( ostype & os, double _Complex dc ) { 257 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );216 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 258 217 // os | creal( dc ) | nonl; 259 218 PrintWithDP( os, "%.*lg", creal( dc ), DBL_DIG ); … … 267 226 268 227 ostype & ?|?( ostype & os, long double _Complex ldc ) { 269 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );228 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 270 229 // os | creall( ldc ) || nonl; 271 230 PrintWithDP( os, "%.*Lg", creall( ldc ), LDBL_DIG ); … … 278 237 } // ?|? 279 238 280 ostype & ?|?( ostype & os, const char str[]) {239 ostype & ?|?( ostype & os, const char * str ) { 281 240 enum { Open = 1, Close, OpenClose }; 282 241 static const unsigned char mask[256] @= { … … 298 257 // first character IS NOT spacing or closing punctuation => add left separator 299 258 unsigned char ch = str[0]; // must make unsigned 300 if ( $sepPrt( os ) && mask[ ch ] != Close && mask[ ch ] != OpenClose ) {301 fmt( os, "%s", $sepGetCur( os ) );259 if ( sepPrt( os ) && mask[ ch ] != Close && mask[ ch ] != OpenClose ) { 260 fmt( os, "%s", sepGetCur( os ) ); 302 261 } // if 303 262 304 263 // if string starts line, must reset to determine open state because separator is off 305 $sepReset( os );// reset separator264 sepReset( os ); // reset separator 306 265 307 266 // last character IS spacing or opening punctuation => turn off separator for next item 308 267 size_t len = strlen( str ); 309 268 ch = str[len - 1]; // must make unsigned 310 if ( $sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) {269 if ( sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) { 311 270 sepOn( os ); 312 271 } else { 313 272 sepOff( os ); 314 273 } // if 315 if ( ch == '\n' ) $setNL( os, true ); // check *AFTER* $sepPrt call above as it resets NL flag274 if ( ch == '\n' ) setNL( os, true ); // check *AFTER* sepPrt call above as it resets NL flag 316 275 return write( os, str, len ); 317 276 } // ?|? 318 319 void ?|?( ostype & os, const char str[] ) { 277 void ?|?( ostype & os, const char * str ) { 320 278 (ostype &)(os | str); ends( os ); 321 279 } // ?|? 322 280 323 281 // ostype & ?|?( ostype & os, const char16_t * str ) { 324 // if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );282 // if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 325 283 // fmt( os, "%ls", str ); 326 284 // return os; … … 329 287 // #if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous 330 288 // ostype & ?|?( ostype & os, const char32_t * str ) { 331 // if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );289 // if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 332 290 // fmt( os, "%ls", str ); 333 291 // return os; … … 336 294 337 295 // ostype & ?|?( ostype & os, const wchar_t * str ) { 338 // if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );296 // if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 339 297 // fmt( os, "%ls", str ); 340 298 // return os; … … 342 300 343 301 ostype & ?|?( ostype & os, const void * p ) { 344 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );302 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 345 303 fmt( os, "%p", p ); 346 304 return os; … … 357 315 void ?|?( ostype & os, ostype & (* manip)( ostype & ) ) { 358 316 (ostype &)(manip( os )); 359 if ( $getPrt( os ) ) ends( os );// something printed ?360 $setPrt( os, false ); // turn off317 if ( getPrt( os ) ) ends( os ); // something printed ? 318 setPrt( os, false ); // turn off 361 319 } // ?|? 362 320 … … 371 329 ostype & nl( ostype & os ) { 372 330 (ostype &)(os | '\n'); 373 $setPrt( os, false ); // turn off374 $setNL( os, true );331 setPrt( os, false ); // turn off 332 setNL( os, true ); 375 333 flush( os ); 376 334 return sepOff( os ); // prepare for next line … … 378 336 379 337 ostype & nonl( ostype & os ) { 380 $setPrt( os, false ); // turn off338 setPrt( os, false ); // turn off 381 339 return os; 382 340 } // nonl … … 417 375 ostype & ?|?( ostype & os, T arg, Params rest ) { 418 376 (ostype &)(os | arg); // print first argument 419 $sepSetCur( os, sepGetTuple( os ) );// switch to tuple separator377 sepSetCur( os, sepGetTuple( os ) ); // switch to tuple separator 420 378 (ostype &)(os | rest); // print remaining arguments 421 $sepSetCur( os, sepGet( os ) ); // switch to regular separator379 sepSetCur( os, sepGet( os ) ); // switch to regular separator 422 380 return os; 423 381 } // ?|? … … 425 383 // (ostype &)(?|?( os, arg, rest )); ends( os ); 426 384 (ostype &)(os | arg); // print first argument 427 $sepSetCur( os, sepGetTuple( os ) );// switch to tuple separator385 sepSetCur( os, sepGetTuple( os ) ); // switch to tuple separator 428 386 (ostype &)(os | rest); // print remaining arguments 429 $sepSetCur( os, sepGet( os ) ); // switch to regular separator387 sepSetCur( os, sepGet( os ) ); // switch to regular separator 430 388 ends( os ); 431 389 } // ?|? … … 456 414 forall( dtype ostype | ostream( ostype ) ) { \ 457 415 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ 458 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \416 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); \ 459 417 \ 460 418 if ( f.base == 'b' || f.base == 'B' ) { /* bespoke binary format */ \ … … 505 463 \ 506 464 if ( ! f.flags.pc ) { /* no precision */ \ 465 /* printf( "%s\n", &fmtstr[star] ); */ \ 507 466 fmtstr[sizeof(IFMTNP)-2] = f.base; /* sizeof includes '\0' */ \ 508 /* printf( "%s %c %c\n", &fmtstr[star], f.base, CODE ); */ \509 467 fmt( os, &fmtstr[star], f.wd, f.val ); \ 510 468 } else { /* precision */ \ 511 469 fmtstr[sizeof(IFMTP)-2] = f.base; /* sizeof includes '\0' */ \ 512 /* printf( "%s %c %c\n", &fmtstr[star], f.base, CODE); */ \470 /* printf( "%s\n", &fmtstr[star] ); */ \ 513 471 fmt( os, &fmtstr[star], f.wd, f.pc, f.val ); \ 514 472 } /* if */ \ … … 528 486 IntegralFMTImpl( signed long long int, 'd', "% *ll ", "% *.*ll " ) 529 487 IntegralFMTImpl( unsigned long long int, 'u', "% *ll ", "% *.*ll " ) 530 531 532 #if defined( __SIZEOF_INT128__ )533 // Default prefix for non-decimal prints is 0b, 0, 0x.534 #define IntegralFMTImpl128( T, SIGNED, CODE, IFMTNP, IFMTP ) \535 forall( dtype ostype | ostream( ostype ) ) \536 static void base10_128( ostype & os, _Ostream_Manip(T) fmt ) { \537 if ( fmt.val > UINT64_MAX ) { \538 fmt.val /= P10_UINT64; \539 base10_128( os, fmt ); /* recursive */ \540 _Ostream_Manip(unsigned long long int) fmt2 @= { (uint64_t)(fmt.val % P10_UINT64), 0, 19, 'u', { .all : 0 } }; \541 fmt2.flags.nobsdp = true; \542 printf( "fmt2 %c %lld %d\n", fmt2.base, fmt2.val, fmt2.all ); \543 sepOff( os ); \544 (ostype &)(os | fmt2); \545 } else { \546 printf( "fmt %c %lld %d\n", fmt.base, fmt.val, fmt.all ); \547 (ostype &)(os | fmt); \548 } /* if */ \549 } /* base10_128 */ \550 forall( dtype ostype | ostream( ostype ) ) { \551 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \552 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \553 \554 if ( f.base == 'b' | f.base == 'o' | f.base == 'x' | f.base == 'X' ) { \555 unsigned long long int msig = (unsigned long long int)(f.val >> 64); \556 unsigned long long int lsig = (unsigned long long int)(f.val); \557 _Ostream_Manip(SIGNED long long int) fmt @= { msig, f.wd, f.pc, f.base, { .all : f.all } }; \558 _Ostream_Manip(unsigned long long int) fmt2 @= { lsig, 0, 0, f.base, { .all : 0 } }; \559 if ( msig == 0 ) { \560 fmt.val = lsig; \561 (ostype &)(os | fmt); \562 } else { \563 fmt2.flags.pad0 = fmt2.flags.nobsdp = true; \564 if ( f.base == 'b' ) { \565 if ( f.wd > 64 ) fmt.wd = f.wd - 64; \566 fmt2.wd = 64; \567 (ostype &)(os | fmt | "" | fmt2); \568 } else if ( f.base == 'o' ) { \569 fmt.val = (unsigned long long int)fmt.val >> 2; \570 if ( f.wd > 21 ) fmt.wd = f.wd - 21; \571 fmt2.wd = 1; \572 fmt2.val = ((msig & 0x3) << 1) + 1; \573 (ostype &)(os | fmt | "" | fmt2); \574 sepOff( os ); \575 fmt2.wd = 21; \576 fmt2.val = lsig & 0x7fffffffffffffff; \577 (ostype &)(os | fmt2); \578 } else { \579 if ( f.flags.left ) { \580 if ( f.wd > 16 ) fmt2.wd = f.wd - 16; \581 fmt.wd = 16; \582 } else { \583 if ( f.wd > 16 ) fmt.wd = f.wd - 16; \584 fmt2.wd = 16; \585 } /* if */ \586 (ostype &)(os | fmt | "" | fmt2); \587 } /* if */ \588 } /* if */ \589 } else { \590 base10_128( os, f ); \591 } /* if */ \592 return os; \593 } /* ?|? */ \594 void ?|?( ostype & os, _Ostream_Manip(T) f ) { (ostype &)(os | f); ends( os ); } \595 } // distribution596 597 IntegralFMTImpl128( int128, signed, 'd', "% *ll ", "% *.*ll " )598 IntegralFMTImpl128( unsigned int128, unsigned, 'u', "% *ll ", "% *.*ll " )599 #endif // __SIZEOF_INT128__600 488 601 489 //*********************************** floating point *********************************** … … 625 513 forall( dtype ostype | ostream( ostype ) ) { \ 626 514 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ 627 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \515 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); \ 628 516 char fmtstr[sizeof(DFMTP)]; /* sizeof includes '\0' */ \ 629 517 if ( ! f.flags.pc ) memcpy( &fmtstr, DFMTNP, sizeof(DFMTNP) ); \ … … 648 536 return os; \ 649 537 } /* ?|? */ \ 650 \651 538 void ?|?( ostype & os, _Ostream_Manip(T) f ) { (ostype &)(os | f); ends( os ); } \ 652 539 } // distribution … … 668 555 } // if 669 556 670 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );557 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 671 558 672 559 #define CFMTNP "% * " … … 684 571 return os; 685 572 } // ?|? 686 687 573 void ?|?( ostype & os, _Ostream_Manip(char) f ) { (ostype &)(os | f); ends( os ); } 688 574 } // distribution … … 706 592 } // if 707 593 708 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );594 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 709 595 710 596 #define SFMTNP "% * " … … 730 616 return os; 731 617 } // ?|? 732 733 618 void ?|?( ostype & os, _Ostream_Manip(const char *) f ) { (ostype &)(os | f); ends( os ); } 734 619 } // distribution … … 850 735 } // ?|? 851 736 852 // istype & ?|?( istype & is, const char fmt[]) {737 // istype & ?|?( istype & is, const char * fmt ) { 853 738 // fmt( is, fmt, "" ); 854 739 // return is; -
libcfa/src/iostream.hfa
r3d5701e r9fb8f01 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 20 15:30:56 202013 // Update Count : 33 712 // Last Modified On : Fri Jul 12 12:08:38 2019 13 // Update Count : 334 14 14 // 15 15 … … 24 24 trait ostream( dtype ostype ) { 25 25 // private 26 bool $sepPrt( ostype & ); // get separator state (on/off)27 void $sepReset( ostype & ); // set separator state to default state28 void $sepReset( ostype &, bool ); // set separator and default state29 const char * $sepGetCur( ostype & );// get current separator string30 void $sepSetCur( ostype &, const char []); // set current separator string31 bool $getNL( ostype & );// check newline32 void $setNL( ostype &, bool ); // saw newline33 bool $getANL( ostype & ); // get auto newline (on/off)34 bool $getPrt( ostype & ); // get fmt called in output cascade35 void $setPrt( ostype &, bool ); // set fmt called in output cascade26 bool sepPrt( ostype & ); // get separator state (on/off) 27 void sepReset( ostype & ); // set separator state to default state 28 void sepReset( ostype &, bool ); // set separator and default state 29 const char * sepGetCur( ostype & ); // get current separator string 30 void sepSetCur( ostype &, const char * ); // set current separator string 31 bool getNL( ostype & ); // check newline 32 void setNL( ostype &, bool ); // saw newline 33 bool getANL( ostype & ); // get auto newline (on/off) 34 bool getPrt( ostype & ); // get fmt called in output cascade 35 void setPrt( ostype &, bool ); // set fmt called in output cascade 36 36 // public 37 37 void sepOn( ostype & ); // turn separator state on … … 43 43 44 44 const char * sepGet( ostype & ); // get separator string 45 void sepSet( ostype &, const char []); // set separator to string (15 character maximum)45 void sepSet( ostype &, const char * ); // set separator to string (15 character maximum) 46 46 const char * sepGetTuple( ostype & ); // get tuple separator string 47 void sepSetTuple( ostype &, const char [] );// set tuple separator to string (15 character maximum)47 void sepSetTuple( ostype &, const char * ); // set tuple separator to string (15 character maximum) 48 48 49 49 void ends( ostype & os ); // end of output statement 50 50 int fail( ostype & ); 51 51 int flush( ostype & ); 52 void open( ostype & os, const char name[], const char mode[]);52 void open( ostype & os, const char * name, const char * mode ); 53 53 void close( ostype & os ); 54 ostype & write( ostype &, const char [], size_t );54 ostype & write( ostype &, const char *, size_t ); 55 55 int fmt( ostype &, const char format[], ... ) __attribute__(( format(printf, 2, 3) )); 56 56 }; // ostream … … 98 98 ostype & ?|?( ostype &, unsigned long long int ); 99 99 void ?|?( ostype &, unsigned long long int ); 100 #if defined( __SIZEOF_INT128__ )101 ostype & ?|?( ostype &, int128 );102 void ?|?( ostype &, int128 );103 ostype & ?|?( ostype &, unsigned int128 );104 void ?|?( ostype &, unsigned int128 );105 #endif // __SIZEOF_INT128__106 100 107 101 ostype & ?|?( ostype &, float ); … … 119 113 void ?|?( ostype &, long double _Complex ); 120 114 121 ostype & ?|?( ostype &, const char []);122 void ?|?( ostype &, const char []);115 ostype & ?|?( ostype &, const char * ); 116 void ?|?( ostype &, const char * ); 123 117 // ostype & ?|?( ostype &, const char16_t * ); 124 118 #if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous … … 212 206 IntegralFMTDecl( signed long long int, 'd' ) 213 207 IntegralFMTDecl( unsigned long long int, 'u' ) 214 #if defined( __SIZEOF_INT128__ )215 IntegralFMTDecl( int128, 'd' )216 IntegralFMTDecl( unsigned int128, 'u' )217 #endif218 208 219 209 //*********************************** floating point *********************************** … … 266 256 267 257 static inline { 268 _Ostream_Manip(const char *) bin( const char s[]) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'b', { .all : 0 } }; }269 _Ostream_Manip(const char *) oct( const char s[]) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'o', { .all : 0 } }; }270 _Ostream_Manip(const char *) hex( const char s[]) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'x', { .all : 0 } }; }271 _Ostream_Manip(const char *) wd( unsigned int w, const char s[]) { return (_Ostream_Manip(const char *))@{ s, w, 0, 's', { .all : 0 } }; }272 _Ostream_Manip(const char *) wd( unsigned int w, unsigned char pc, const char s[]) { return (_Ostream_Manip(const char *))@{ s, w, pc, 's', { .flags.pc : true } }; }258 _Ostream_Manip(const char *) bin( const char * s ) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'b', { .all : 0 } }; } 259 _Ostream_Manip(const char *) oct( const char * s ) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'o', { .all : 0 } }; } 260 _Ostream_Manip(const char *) hex( const char * s ) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'x', { .all : 0 } }; } 261 _Ostream_Manip(const char *) wd( unsigned int w, const char * s ) { return (_Ostream_Manip(const char *))@{ s, w, 0, 's', { .all : 0 } }; } 262 _Ostream_Manip(const char *) wd( unsigned int w, unsigned char pc, const char * s ) { return (_Ostream_Manip(const char *))@{ s, w, pc, 's', { .flags.pc : true } }; } 273 263 _Ostream_Manip(const char *) & wd( unsigned int w, _Ostream_Manip(const char *) & fmt ) { fmt.wd = w; return fmt; } 274 264 _Ostream_Manip(const char *) & wd( unsigned int w, unsigned char pc, _Ostream_Manip(const char *) & fmt ) { fmt.wd = w; fmt.pc = pc; fmt.flags.pc = true; return fmt; } … … 291 281 int fail( istype & ); 292 282 int eof( istype & ); 293 void open( istype & is, const char name[]);283 void open( istype & is, const char * name ); 294 284 void close( istype & is ); 295 285 istype & read( istype &, char *, size_t ); … … 326 316 istype & ?|?( istype &, long double _Complex & ); 327 317 328 // istype & ?|?( istype &, const char []);318 // istype & ?|?( istype &, const char * ); 329 319 istype & ?|?( istype &, char * ); 330 320 … … 353 343 static inline { 354 344 _Istream_Cstr skip( unsigned int n ) { return (_Istream_Cstr){ 0p, 0p, n, { .all : 0 } }; } 355 _Istream_Cstr skip( const char scanset[]) { return (_Istream_Cstr){ 0p, scanset, -1, { .all : 0 } }; }356 _Istream_Cstr incl( const char scanset[], char * s ) { return (_Istream_Cstr){ s, scanset, -1, { .flags.inex : false } }; }357 _Istream_Cstr & incl( const char scanset[], _Istream_Cstr & fmt ) { fmt.scanset = scanset; fmt.flags.inex = false; return fmt; }358 _Istream_Cstr excl( const char scanset[], char * s ) { return (_Istream_Cstr){ s, scanset, -1, { .flags.inex : true } }; }359 _Istream_Cstr & excl( const char scanset[], _Istream_Cstr & fmt ) { fmt.scanset = scanset; fmt.flags.inex = true; return fmt; }360 _Istream_Cstr ignore( const char s[]) { return (_Istream_Cstr)@{ s, 0p, -1, { .flags.ignore : true } }; }345 _Istream_Cstr skip( const char * scanset ) { return (_Istream_Cstr){ 0p, scanset, -1, { .all : 0 } }; } 346 _Istream_Cstr incl( const char * scanset, char * s ) { return (_Istream_Cstr){ s, scanset, -1, { .flags.inex : false } }; } 347 _Istream_Cstr & incl( const char * scanset, _Istream_Cstr & fmt ) { fmt.scanset = scanset; fmt.flags.inex = false; return fmt; } 348 _Istream_Cstr excl( const char * scanset, char * s ) { return (_Istream_Cstr){ s, scanset, -1, { .flags.inex : true } }; } 349 _Istream_Cstr & excl( const char * scanset, _Istream_Cstr & fmt ) { fmt.scanset = scanset; fmt.flags.inex = true; return fmt; } 350 _Istream_Cstr ignore( const char * s ) { return (_Istream_Cstr)@{ s, 0p, -1, { .flags.ignore : true } }; } 361 351 _Istream_Cstr & ignore( _Istream_Cstr & fmt ) { fmt.flags.ignore = true; return fmt; } 362 _Istream_Cstr wdi( unsigned int w, char s[]) { return (_Istream_Cstr)@{ s, 0p, w, { .all : 0 } }; }352 _Istream_Cstr wdi( unsigned int w, char * s ) { return (_Istream_Cstr)@{ s, 0p, w, { .all : 0 } }; } 363 353 _Istream_Cstr & wdi( unsigned int w, _Istream_Cstr & fmt ) { fmt.wd = w; return fmt; } 364 354 } // distribution -
libcfa/src/math.hfa
r3d5701e r9fb8f01 10 10 // Created On : Mon Apr 18 23:37:04 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 10:27:11 202013 // Update Count : 11 712 // Last Modified On : Fri Jul 13 11:02:15 2018 13 // Update Count : 116 14 14 // 15 15 … … 51 51 static inline long double fdim( long double x, long double y ) { return fdiml( x, y ); } 52 52 53 static inline float nan( const char tag[]) { return nanf( tag ); }54 // extern "C" { double nan( const char []); }55 static inline long double nan( const char tag[]) { return nanl( tag ); }53 static inline float nan( const char * tag ) { return nanf( tag ); } 54 // extern "C" { double nan( const char * ); } 55 static inline long double nan( const char * tag ) { return nanl( tag ); } 56 56 57 57 //---------------------- Exponential ---------------------- -
libcfa/src/rational.cfa
r3d5701e r9fb8f01 10 10 // Created On : Wed Apr 6 17:54:28 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 8 17:56:36 202013 // Update Count : 18 712 // Last Modified On : Fri Jul 12 18:12:08 2019 13 // Update Count : 184 14 14 // 15 15 … … 56 56 } // rational 57 57 58 void ?{}( Rational(RationalImpl) & r, zero_t ) {59 r{ (RationalImpl){0}, (RationalImpl){1} };60 } // rational61 62 void ?{}( Rational(RationalImpl) & r, one_t ) {63 r{ (RationalImpl){1}, (RationalImpl){1} };64 } // rational65 58 66 59 // getter for numerator/denominator -
libcfa/src/startup.cfa
r3d5701e r9fb8f01 10 10 // Created On : Tue Jul 24 16:21:57 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 13:03:18 202013 // Update Count : 3012 // Last Modified On : Wed Jul 25 16:42:01 2018 13 // Update Count : 11 14 14 // 15 15 16 #include <time.h> // tzset17 16 #include "startup.hfa" 17 #include <unistd.h> 18 18 19 19 20 extern "C" { 20 void __cfaabi_appready_startup( void ) __attribute__(( constructor( STARTUP_PRIORITY_APPREADY ) ));21 static void __cfaabi_appready_startup( void ) __attribute__(( constructor( STARTUP_PRIORITY_APPREADY ) )); 21 22 void __cfaabi_appready_startup( void ) { 22 tzset(); // initialize time global variables23 23 #ifdef __CFA_DEBUG__ 24 24 extern void heapAppStart(); … … 27 27 } // __cfaabi_appready_startup 28 28 29 void __cfaabi_appready_shutdown( void ) __attribute__(( destructor( STARTUP_PRIORITY_APPREADY ) ));29 static void __cfaabi_appready_shutdown( void ) __attribute__(( destructor( STARTUP_PRIORITY_APPREADY ) )); 30 30 void __cfaabi_appready_shutdown( void ) { 31 31 #ifdef __CFA_DEBUG__ … … 41 41 struct __spinlock_t; 42 42 extern "C" { 43 void __cfaabi_dbg_record(struct __spinlock_t & this, const char prev_name[]) __attribute__(( weak )) {}43 void __cfaabi_dbg_record(struct __spinlock_t & this, const char * prev_name) __attribute__(( weak )) {} 44 44 } 45 45 -
libcfa/src/stdhdr/assert.h
r3d5701e r9fb8f01 10 10 // Created On : Mon Jul 4 23:25:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 12:58:49 202013 // Update Count : 1 512 // Last Modified On : Mon Jul 31 23:09:32 2017 13 // Update Count : 13 14 14 // 15 15 … … 27 27 #define assertf( expr, fmt, ... ) ((expr) ? ((void)0) : __assert_fail_f(__VSTRINGIFY__(expr), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, ## __VA_ARGS__ )) 28 28 29 void __assert_fail_f( const char assertion[], const char file[], unsigned int line, const char function[], const char fmt[], ... ) __attribute__((noreturn, format( printf, 5, 6) ));29 void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) __attribute__((noreturn, format( printf, 5, 6) )); 30 30 #endif 31 31 -
libcfa/src/stdhdr/bfdlink.h
r3d5701e r9fb8f01 10 10 // Created On : Tue Jul 18 07:26:04 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 7 19:05:08 202013 // Update Count : 612 // Last Modified On : Sun Jul 22 13:49:30 2018 13 // Update Count : 4 14 14 // 15 15 16 16 // include file uses the CFA keyword "with". 17 17 #if ! defined( with ) // nesting ? 18 #define with ` `with// make keyword an identifier18 #define with `with` // make keyword an identifier 19 19 #define __CFA_BFDLINK_H__ 20 20 #endif -
libcfa/src/stdhdr/hwloc.h
r3d5701e r9fb8f01 10 10 // Created On : Tue Jul 18 07:45:00 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 7 19:05:18 202013 // Update Count : 612 // Last Modified On : Sun Jul 22 13:49:58 2018 13 // Update Count : 4 14 14 // 15 15 16 16 // include file uses the CFA keyword "thread". 17 17 #if ! defined( thread ) // nesting ? 18 #define thread ` `thread// make keyword an identifier18 #define thread `thread` // make keyword an identifier 19 19 #define __CFA_HWLOC_H__ 20 20 #endif -
libcfa/src/stdhdr/krb5.h
r3d5701e r9fb8f01 10 10 // Created On : Tue Jul 18 07:55:44 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 7 19:05:35 202013 // Update Count : 612 // Last Modified On : Sun Jul 22 13:50:24 2018 13 // Update Count : 4 14 14 // 15 15 16 16 // include file uses the CFA keyword "enable". 17 17 #if ! defined( enable ) // nesting ? 18 #define enable ` `enable// make keyword an identifier18 #define enable `enable` // make keyword an identifier 19 19 #define __CFA_KRB5_H__ 20 20 #endif -
libcfa/src/stdhdr/math.h
r3d5701e r9fb8f01 10 10 // Created On : Mon Jul 4 23:25:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 7 19:05:27 202013 // Update Count : 1 512 // Last Modified On : Thu Feb 22 18:16:07 2018 13 // Update Count : 13 14 14 // 15 15 16 16 extern "C" { 17 17 #if ! defined( exception ) // nesting ? 18 #define exception ` `exception// make keyword an identifier18 #define exception `exception` // make keyword an identifier 19 19 #define __CFA_MATH_H__ 20 20 #endif -
libcfa/src/stdhdr/sys/ucontext.h
r3d5701e r9fb8f01 10 10 // Created On : Thu Feb 8 23:48:16 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 7 19:05:41 202013 // Update Count : 612 // Last Modified On : Thu Feb 8 23:50:44 2018 13 // Update Count : 4 14 14 // 15 15 16 16 #if ! defined( ftype ) // nesting ? 17 #define ftype ` `ftype// make keyword an identifier17 #define ftype `ftype` // make keyword an identifier 18 18 #define __CFA_UCONTEXT_H__ 19 19 #endif -
libcfa/src/stdlib.cfa
r3d5701e r9fb8f01 10 10 // Created On : Thu Jan 28 17:10:29 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 08:27:08 202013 // Update Count : 4 8612 // Last Modified On : Mon Jun 24 17:34:44 2019 13 // Update Count : 462 14 14 // 15 15 … … 21 21 #include <string.h> // memcpy, memset 22 22 #include <malloc.h> // malloc_usable_size 23 //#include <math.h> // fabsf, fabs, fabsl23 #include <math.h> // fabsf, fabs, fabsl 24 24 #include <complex.h> // _Complex_I 25 25 #include <assert.h> … … 27 27 //--------------------------------------- 28 28 29 forall( dtype T | sized(T) ) { 30 T * alloc_set( T ptr[], size_t dim, char fill ) { // realloc array with fill 31 size_t olen = malloc_usable_size( ptr ); // current allocation 32 void * nptr = (void *)realloc( (void *)ptr, dim * sizeof(T) ); // C realloc 33 size_t nlen = malloc_usable_size( nptr ); // new allocation 34 if ( nlen > olen ) { // larger ? 35 memset( (char *)nptr + olen, (int)fill, nlen - olen ); // initialize added storage 36 } // if 37 return (T *)nptr; 38 } // alloc_set 39 40 T * alloc_align_set( T ptr[], size_t align, char fill ) { // aligned realloc with fill 41 size_t olen = malloc_usable_size( ptr ); // current allocation 42 void * nptr = (void *)realloc( (void *)ptr, align, sizeof(T) ); // CFA realloc 43 // char * nptr = alloc_align( ptr, align ); 44 size_t nlen = malloc_usable_size( nptr ); // new allocation 45 if ( nlen > olen ) { // larger ? 46 memset( (char *)nptr + olen, (int)fill, nlen - olen ); // initialize added storage 47 } // if 48 return (T *)nptr; 49 } // alloc_align_set 50 } // distribution 29 // resize, non-array types 30 forall( dtype T | sized(T) ) T * alloc( T ptr[], size_t dim, char fill ) { 31 size_t olen = malloc_usable_size( ptr ); // current allocation 32 char * nptr = (void *)realloc( (void *)ptr, dim * (size_t)sizeof(T) ); // C realloc 33 size_t nlen = malloc_usable_size( nptr ); // new allocation 34 if ( nlen > olen ) { // larger ? 35 memset( nptr + olen, (int)fill, nlen - olen ); // initialize added storage 36 } // 37 return (T *)nptr; 38 } // alloc 51 39 52 40 // allocation/deallocation and constructor/destructor, non-array types 53 41 forall( dtype T | sized(T), ttype Params | { void ?{}( T &, Params ); } ) 54 42 T * new( Params p ) { 55 return &(*malloc()){ p }; // run constructor43 return &(*malloc()){ p }; // run constructor 56 44 } // new 57 45 … … 59 47 void delete( T * ptr ) { 60 48 if ( ptr ) { // ignore null 61 ^(*ptr){}; // run destructor49 ^(*ptr){}; // run destructor 62 50 free( ptr ); 63 51 } // if … … 67 55 void delete( T * ptr, Params rest ) { 68 56 if ( ptr ) { // ignore null 69 ^(*ptr){}; // run destructor57 ^(*ptr){}; // run destructor 70 58 free( ptr ); 71 59 } // if … … 107 95 //--------------------------------------- 108 96 109 float _Complex strto( const char sptr[], char ** eptr ) {97 float _Complex strto( const char * sptr, char ** eptr ) { 110 98 float re, im; 111 99 char * eeptr; … … 118 106 } // strto 119 107 120 double _Complex strto( const char sptr[], char ** eptr ) {108 double _Complex strto( const char * sptr, char ** eptr ) { 121 109 double re, im; 122 110 char * eeptr; … … 129 117 } // strto 130 118 131 long double _Complex strto( const char sptr[], char ** eptr ) {119 long double _Complex strto( const char * sptr, char ** eptr ) { 132 120 long double re, im; 133 121 char * eeptr; -
libcfa/src/stdlib.hfa
r3d5701e r9fb8f01 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 08:27:01 202013 // Update Count : 40112 // Last Modified On : Tue Jul 23 14:14:59 2019 13 // Update Count : 373 14 14 // 15 15 … … 25 25 void * memset( void * dest, int fill, size_t size ); // string.h 26 26 void * memcpy( void * dest, const void * src, size_t size ); // string.h 27 void * cmemalign( size_t alignment, size_t noOfElems, size_t elemSize ); // CFA heap27 void * cmemalign( size_t alignment, size_t noOfElems, size_t elemSize ); // CFA 28 28 } // extern "C" 29 30 void * realloc( void * oaddr, size_t nalign, size_t size ); // CFA heap31 29 32 30 //--------------------------------------- … … 52 50 } // calloc 53 51 54 T * realloc( T * ptr, size_t size ) { // CFA realloc, eliminate return-type cast 55 return (T *)(void *)realloc( (void *)ptr, size ); // C realloc 52 T * realloc( T * ptr, size_t size ) { 53 if ( unlikely( ptr == 0 ) ) return malloc(); 54 return (T *)(void *)realloc( (void *)ptr, size ); 56 55 } // realloc 57 56 58 57 T * memalign( size_t align ) { 59 return (T *)memalign( align, sizeof(T) ); // C memalign58 return (T *)memalign( align, sizeof(T) ); 60 59 } // memalign 61 60 62 T * cmemalign( size_t align, size_t dim ) {63 return (T *)cmemalign( align, dim, sizeof(T) ); // CFA cmemalign64 } // cmemalign65 66 61 T * aligned_alloc( size_t align ) { 67 return (T *)aligned_alloc( align, sizeof(T) ); // C aligned_alloc62 return (T *)aligned_alloc( align, sizeof(T) ); 68 63 } // aligned_alloc 69 64 … … 72 67 } // posix_memalign 73 68 69 74 70 // Cforall dynamic allocation 75 71 … … 78 74 } // alloc 79 75 76 T * alloc( char fill ) { 77 T * ptr; 78 if ( _Alignof(T) <= libAlign() ) ptr = (T *)(void *)malloc( (size_t)sizeof(T) ); // C malloc 79 else ptr = (T *)memalign( _Alignof(T), sizeof(T) ); 80 return (T *)memset( ptr, (int)fill, sizeof(T) ); // initialize with fill value 81 } // alloc 82 80 83 T * alloc( size_t dim ) { 81 if ( _Alignof(T) <= libAlign() ) return (T *)(void *)malloc( dim * (size_t)sizeof(T) ); 84 if ( _Alignof(T) <= libAlign() ) return (T *)(void *)malloc( dim * (size_t)sizeof(T) ); // C malloc 82 85 else return (T *)memalign( _Alignof(T), dim * sizeof(T) ); 83 86 } // alloc 84 87 85 T * alloc( T ptr[], size_t dim ) { // realloc 86 return (T *)(void *)realloc( (void *)ptr, dim * sizeof(T) ); // C realloc 87 } // alloc 88 89 T * alloc_set( char fill ) { 90 return (T *)memset( (T *)alloc(), (int)fill, sizeof(T) ); // initialize with fill value 91 } // alloc 92 93 T * alloc_set( T fill ) { 94 return (T *)memcpy( (T *)alloc(), &fill, sizeof(T) ); // initialize with fill value 95 } // alloc 96 97 T * alloc_set( size_t dim, char fill ) { 88 T * alloc( size_t dim, char fill ) { 98 89 return (T *)memset( (T *)alloc( dim ), (int)fill, dim * sizeof(T) ); // initialize with fill value 99 90 } // alloc 100 91 101 T * alloc_set( size_t dim, T fill ) { 102 T * r = (T *)alloc( dim ); 103 for ( i; dim ) { memcpy( &r[i], &fill, sizeof(T) ); } // initialize with fill value 104 return r; 105 } // alloc 106 107 T * alloc_set( size_t dim, const T fill[] ) { 108 return (T *)memcpy( (T *)alloc( dim ), fill, dim * sizeof(T) ); // initialize with fill value 109 } // alloc 110 } // distribution 111 112 forall( dtype T | sized(T) ) { 113 T * alloc_set( T ptr[], size_t dim, char fill ); // realloc array with fill 114 } // distribution 115 116 static inline forall( dtype T | sized(T) ) { 117 T * alloc_align( size_t align ) { 92 T * alloc( T ptr[], size_t dim ) { 93 return realloc( ptr, dim * sizeof(T) ); 94 } // alloc 95 } // distribution 96 97 98 static inline forall( dtype T | sized(T) ) { 99 T * align_alloc( size_t align ) { 118 100 return (T *)memalign( align, sizeof(T) ); 119 } // alloc_align 120 121 T * alloc_align( size_t align, size_t dim ) { 101 } // align_alloc 102 103 T * align_alloc( size_t align, char fill ) { 104 T * ptr = (T *)memalign( align, sizeof(T) ); 105 return (T *)memset( ptr, (int)fill, sizeof(T) ); 106 } // align_alloc 107 108 T * align_alloc( size_t align, size_t dim ) { 122 109 return (T *)memalign( align, dim * sizeof(T) ); 123 } // alloc_align 124 125 T * alloc_align( T ptr[], size_t align ) { // aligned realloc array 126 return (T *)(void *)realloc( (void *)ptr, align, sizeof(T) ); // CFA realloc 127 } // alloc_align 128 129 T * alloc_align( T ptr[], size_t align, size_t dim ) { // aligned realloc array 130 return (T *)(void *)realloc( (void *)ptr, align, dim * sizeof(T) ); // CFA realloc 131 } // alloc_align 132 133 T * alloc_align_set( size_t align, char fill ) { 134 return (T *)memset( (T *)alloc_align( align ), (int)fill, sizeof(T) ); // initialize with fill value 135 } // alloc_align 136 137 T * alloc_align_set( size_t align, T fill ) { 138 return (T *)memcpy( (T *)alloc_align( align ), &fill, sizeof(T) ); // initialize with fill value 139 } // alloc_align 140 141 T * alloc_align_set( size_t align, size_t dim, char fill ) { 142 return (T *)memset( (T *)alloc_align( align, dim ), (int)fill, dim * sizeof(T) ); // initialize with fill value 143 } // alloc_align 144 145 T * alloc_align_set( size_t align, size_t dim, T fill ) { 146 T * r = (T *)alloc_align( align, dim ); 147 for ( i; dim ) { memcpy( &r[i], &fill, sizeof(T) ); } // initialize with fill value 148 return r; 149 } // alloc_align 150 151 T * alloc_align_set( size_t align, size_t dim, const T fill[] ) { 152 return (T *)memcpy( (T *)alloc_align( align, dim ), fill, dim * sizeof(T) ); 153 } // alloc_align 154 } // distribution 155 156 forall( dtype T | sized(T) ) { 157 T * alloc_align_set( T ptr[], size_t align, size_t dim, char fill ); // aligned realloc array with fill 158 } // distribution 110 } // align_alloc 111 112 T * align_alloc( size_t align, size_t dim, char fill ) { 113 if ( fill == '\0' ) { 114 return (T *)cmemalign( align, dim, sizeof(T) ); 115 } else { 116 return (T *)memset( (T *)memalign( align, dim * sizeof(T) ), (int)fill, dim * sizeof(T) ); 117 } // if 118 } // align_alloc 119 } // distribution 120 121 forall( dtype T | sized(T) ) T * alloc( T ptr[], size_t dim, char fill ); 122 159 123 160 124 static inline forall( dtype T | sized(T) ) { 161 125 // data, non-array types 126 162 127 T * memset( T * dest, char fill ) { 163 128 return (T *)memset( dest, fill, sizeof(T) ); … … 171 136 static inline forall( dtype T | sized(T) ) { 172 137 // data, array types 138 173 139 T * amemset( T dest[], char fill, size_t dim ) { 174 140 return (T *)(void *)memset( dest, fill, dim * sizeof(T) ); // C memset … … 193 159 194 160 static inline { 195 int strto( const char sptr[], char ** eptr, int base ) { return (int)strtol( sptr, eptr, base ); }196 unsigned int strto( const char sptr[], char ** eptr, int base ) { return (unsigned int)strtoul( sptr, eptr, base ); }197 long int strto( const char sptr[], char ** eptr, int base ) { return strtol( sptr, eptr, base ); }198 unsigned long int strto( const char sptr[], char ** eptr, int base ) { return strtoul( sptr, eptr, base ); }199 long long int strto( const char sptr[], char ** eptr, int base ) { return strtoll( sptr, eptr, base ); }200 unsigned long long int strto( const char sptr[], char ** eptr, int base ) { return strtoull( sptr, eptr, base ); }201 202 float strto( const char sptr[], char ** eptr ) { return strtof( sptr, eptr ); }203 double strto( const char sptr[], char ** eptr ) { return strtod( sptr, eptr ); }204 long double strto( const char sptr[], char ** eptr ) { return strtold( sptr, eptr ); }205 } // distribution 206 207 float _Complex strto( const char sptr[], char ** eptr );208 double _Complex strto( const char sptr[], char ** eptr );209 long double _Complex strto( const char sptr[], char ** eptr );161 int strto( const char * sptr, char ** eptr, int base ) { return (int)strtol( sptr, eptr, base ); } 162 unsigned int strto( const char * sptr, char ** eptr, int base ) { return (unsigned int)strtoul( sptr, eptr, base ); } 163 long int strto( const char * sptr, char ** eptr, int base ) { return strtol( sptr, eptr, base ); } 164 unsigned long int strto( const char * sptr, char ** eptr, int base ) { return strtoul( sptr, eptr, base ); } 165 long long int strto( const char * sptr, char ** eptr, int base ) { return strtoll( sptr, eptr, base ); } 166 unsigned long long int strto( const char * sptr, char ** eptr, int base ) { return strtoull( sptr, eptr, base ); } 167 168 float strto( const char * sptr, char ** eptr ) { return strtof( sptr, eptr ); } 169 double strto( const char * sptr, char ** eptr ) { return strtod( sptr, eptr ); } 170 long double strto( const char * sptr, char ** eptr ) { return strtold( sptr, eptr ); } 171 } // distribution 172 173 float _Complex strto( const char * sptr, char ** eptr ); 174 double _Complex strto( const char * sptr, char ** eptr ); 175 long double _Complex strto( const char * sptr, char ** eptr ); 210 176 211 177 static inline { 212 int ato( const char sptr[] ) { return (int)strtol( sptr, 0p, 10 ); }213 unsigned int ato( const char sptr[] ) { return (unsigned int)strtoul( sptr, 0p, 10 ); }214 long int ato( const char sptr[] ) { return strtol( sptr, 0p, 10 ); }215 unsigned long int ato( const char sptr[] ) { return strtoul( sptr, 0p, 10 ); }216 long long int ato( const char sptr[] ) { return strtoll( sptr, 0p, 10 ); }217 unsigned long long int ato( const char sptr[] ) { return strtoull( sptr, 0p, 10 ); }218 219 float ato( const char sptr[] ) { return strtof( sptr, 0p); }220 double ato( const char sptr[] ) { return strtod( sptr, 0p); }221 long double ato( const char sptr[] ) { return strtold( sptr, 0p); }222 223 float _Complex ato( const char sptr[] ) { return strto( sptr, 0p); }224 double _Complex ato( const char sptr[] ) { return strto( sptr, 0p); }225 long double _Complex ato( const char sptr[] ) { return strto( sptr, 0p); }178 int ato( const char * sptr ) { return (int)strtol( sptr, 0, 10 ); } 179 unsigned int ato( const char * sptr ) { return (unsigned int)strtoul( sptr, 0, 10 ); } 180 long int ato( const char * sptr ) { return strtol( sptr, 0, 10 ); } 181 unsigned long int ato( const char * sptr ) { return strtoul( sptr, 0, 10 ); } 182 long long int ato( const char * sptr ) { return strtoll( sptr, 0, 10 ); } 183 unsigned long long int ato( const char * sptr ) { return strtoull( sptr, 0, 10 ); } 184 185 float ato( const char * sptr ) { return strtof( sptr, 0 ); } 186 double ato( const char * sptr ) { return strtod( sptr, 0 ); } 187 long double ato( const char * sptr ) { return strtold( sptr, 0 ); } 188 189 float _Complex ato( const char * sptr ) { return strto( sptr, NULL ); } 190 double _Complex ato( const char * sptr ) { return strto( sptr, NULL ); } 191 long double _Complex ato( const char * sptr ) { return strto( sptr, NULL ); } 226 192 } // distribution 227 193 -
libcfa/src/time.cfa
r3d5701e r9fb8f01 10 10 // Created On : Tue Mar 27 13:33:14 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 08:24:18 202013 // Update Count : 7012 // Last Modified On : Sat Jul 13 08:41:55 2019 13 // Update Count : 65 14 14 // 15 15 … … 33 33 forall( dtype ostype | ostream( ostype ) ) { 34 34 ostype & ?|?( ostype & os, Duration dur ) with( dur ) { 35 (ostype &)(os | t n/ TIMEGRAN); // print seconds36 long int ns = (t n < 0 ? -tn : tn) % TIMEGRAN; // compute nanoseconds35 (ostype &)(os | tv / TIMEGRAN); // print seconds 36 long int ns = (tv < 0 ? -tv : tv) % TIMEGRAN; // compute nanoseconds 37 37 if ( ns != 0 ) { // some ? 38 38 char buf[16]; … … 52 52 53 53 #ifdef __CFA_DEBUG__ 54 static void tabort( int year, int month, int day, int hour, int min, int sec, int 64_tnsec ) {54 static void tabort( int year, int month, int day, int hour, int min, int sec, int nsec ) { 55 55 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."; 57 57 } // tabort 58 58 #endif // __CFA_DEBUG__ 59 59 60 void ?{}( Time & time, int year, int month, int day, int hour, int min, int sec, int 64_tnsec ) with( time ) {60 void ?{}( Time & time, int year, int month, int day, int hour, int min, int sec, int nsec ) with( time ) { 61 61 tm tm; 62 62 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 64 64 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__ 66 70 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__ 67 76 tm.tm_mday = day; // mktime uses range 1-31 68 77 tm.tm_hour = hour; 69 78 tm.tm_min = min; 70 79 tm.tm_sec = sec; 71 tm.tm_isdst = -1; // let mktime determine if alternate timezone is in effect72 80 time_t epochsec = mktime( &tm ); 73 81 #ifdef __CFA_DEBUG__ 74 if ( epochsec <= (time_t)-1 ) { // MUST BE LESS THAN OR EQUAL!82 if ( epochsec == (time_t)-1 ) { 75 83 tabort( year, month, day, hour, min, sec, nsec ); 76 84 } // if 77 85 #endif // __CFA_DEBUG__ 78 t n= (int64_t)(epochsec) * TIMEGRAN + nsec; // convert to nanoseconds86 tv = (int64_t)(epochsec) * TIMEGRAN + nsec; // convert to nanoseconds 79 87 #ifdef __CFA_DEBUG__ 80 if ( t n> 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. 81 89 tabort( year, month, day, hour, min, sec, nsec ); 82 90 } // if … … 85 93 86 94 char * yy_mm_dd( Time time, char * buf ) with( time ) { 87 time_t s = t n/ TIMEGRAN;95 time_t s = tv / TIMEGRAN; 88 96 tm tm; 89 97 gmtime_r( &s, &tm ); // tm_mon <= 11, tm_mday <= 31 … … 100 108 101 109 char * mm_dd_yy( Time time, char * buf ) with( time ) { 102 time_t s = t n/ TIMEGRAN;110 time_t s = tv / TIMEGRAN; 103 111 tm tm; 104 112 gmtime_r( &s, &tm ); // tm_mon <= 11, tm_mday <= 31 … … 115 123 116 124 char * dd_mm_yy( Time time, char * buf ) with( time ) { 117 time_t s = t n/ TIMEGRAN;125 time_t s = tv / TIMEGRAN; 118 126 tm tm; 119 127 gmtime_r( &s, &tm ); // tm_mon <= 11, tm_mday <= 31 … … 129 137 } // dd_mm_yy 130 138 131 size_t strftime( char buf[], size_t size, const char fmt[], Time time ) with( time ) {132 time_t s = t n/ TIMEGRAN;139 size_t strftime( char * buf, size_t size, const char * fmt, Time time ) with( time ) { 140 time_t s = tv / TIMEGRAN; 133 141 tm tm; 134 142 gmtime_r( &s, &tm ); … … 139 147 ostype & ?|?( ostype & os, Time time ) with( time ) { 140 148 char buf[32]; // at least 26 141 time_t s = t n/ TIMEGRAN;149 time_t s = tv / TIMEGRAN; 142 150 ctime_r( &s, (char *)&buf ); // 26 characters: "Wed Jun 30 21:49:08 1993\n" 143 151 buf[24] = '\0'; // remove trailing '\n' 144 long int ns = (t n < 0 ? -tn : tn) % TIMEGRAN; // compute nanoseconds152 long int ns = (tv < 0 ? -tv : tv) % TIMEGRAN; // compute nanoseconds 145 153 if ( ns == 0 ) { // none ? 146 154 (ostype &)(os | buf); // print date/time/year -
libcfa/src/time.hfa
r3d5701e r9fb8f01 10 10 // Created On : Wed Mar 14 23:18:57 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 08:24:32 202013 // Update Count : 6 5412 // Last Modified On : Sat Sep 22 12:25:34 2018 13 // Update Count : 643 14 14 // 15 15 … … 32 32 Duration ?=?( Duration & dur, __attribute__((unused)) zero_t ) { return dur{ 0 }; } 33 33 34 Duration +?( Duration rhs ) with( rhs ) { return (Duration)@{ +tn}; }35 Duration ?+?( Duration & lhs, Duration rhs ) { return (Duration)@{ lhs.t n + rhs.tn}; }34 Duration +?( Duration rhs ) with( rhs ) { return (Duration)@{ +tv }; } 35 Duration ?+?( Duration & lhs, Duration rhs ) { return (Duration)@{ lhs.tv + rhs.tv }; } 36 36 Duration ?+=?( Duration & lhs, Duration rhs ) { lhs = lhs + rhs; return lhs; } 37 37 38 Duration -?( Duration rhs ) with( rhs ) { return (Duration)@{ -t n}; }39 Duration ?-?( Duration & lhs, Duration rhs ) { return (Duration)@{ lhs.t n - rhs.tn}; }38 Duration -?( Duration rhs ) with( rhs ) { return (Duration)@{ -tv }; } 39 Duration ?-?( Duration & lhs, Duration rhs ) { return (Duration)@{ lhs.tv - rhs.tv }; } 40 40 Duration ?-=?( Duration & lhs, Duration rhs ) { lhs = lhs - rhs; return lhs; } 41 41 42 Duration ?*?( Duration lhs, int64_t rhs ) { return (Duration)@{ lhs.t n* rhs }; }43 Duration ?*?( int64_t lhs, Duration rhs ) { return (Duration)@{ lhs * rhs.t n}; }42 Duration ?*?( Duration lhs, int64_t rhs ) { return (Duration)@{ lhs.tv * rhs }; } 43 Duration ?*?( int64_t lhs, Duration rhs ) { return (Duration)@{ lhs * rhs.tv }; } 44 44 Duration ?*=?( Duration & lhs, int64_t rhs ) { lhs = lhs * rhs; return lhs; } 45 45 46 int64_t ?/?( Duration lhs, Duration rhs ) { return lhs.t n / rhs.tn; }47 Duration ?/?( Duration lhs, int64_t rhs ) { return (Duration)@{ lhs.t n/ 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 }; } 48 48 Duration ?/=?( Duration & lhs, int64_t rhs ) { lhs = lhs / rhs; return lhs; } 49 double div( Duration lhs, Duration rhs ) { return (double)lhs.t n / (double)rhs.tn; }50 51 Duration ?%?( Duration lhs, Duration rhs ) { return (Duration)@{ lhs.t n % 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 }; } 52 52 Duration ?%=?( Duration & lhs, Duration rhs ) { lhs = lhs % rhs; return lhs; } 53 53 54 bool ?==?( Duration lhs, Duration rhs ) { return lhs.t n == rhs.tn; }55 bool ?!=?( Duration lhs, Duration rhs ) { return lhs.t n != rhs.tn; }56 bool ?<? ( Duration lhs, Duration rhs ) { return lhs.t n < rhs.tn; }57 bool ?<=?( Duration lhs, Duration rhs ) { return lhs.t n <= rhs.tn; }58 bool ?>? ( Duration lhs, Duration rhs ) { return lhs.t n > rhs.tn; }59 bool ?>=?( Duration lhs, Duration rhs ) { return lhs.t n >= rhs.tn; }60 61 bool ?==?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.t n== 0; }62 bool ?!=?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.t n!= 0; }63 bool ?<? ( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.t n< 0; }64 bool ?<=?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.t n<= 0; }65 bool ?>? ( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.t n> 0; }66 bool ?>=?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.t n>= 0; }67 68 Duration abs( Duration rhs ) { return rhs.t n>= 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; } 69 69 70 70 Duration ?`ns( int64_t nsec ) { return (Duration)@{ nsec }; } … … 82 82 Duration ?`w( double weeks ) { return (Duration)@{ weeks * (7LL * 24LL * 60LL * 60LL * TIMEGRAN) }; } 83 83 84 int64_t ?`ns( Duration dur ) { return dur.t n; }85 int64_t ?`us( Duration dur ) { return dur.t n/ (TIMEGRAN / 1_000_000LL); }86 int64_t ?`ms( Duration dur ) { return dur.t n/ (TIMEGRAN / 1_000LL); }87 int64_t ?`s( Duration dur ) { return dur.t n/ TIMEGRAN; }88 int64_t ?`m( Duration dur ) { return dur.t n/ (60LL * TIMEGRAN); }89 int64_t ?`h( Duration dur ) { return dur.t n/ (60LL * 60LL * TIMEGRAN); }90 int64_t ?`d( Duration dur ) { return dur.t n/ (24LL * 60LL * 60LL * TIMEGRAN); }91 int64_t ?`w( Duration dur ) { return dur.t n/ (7LL * 24LL * 60LL * 60LL * TIMEGRAN); }92 93 Duration max( Duration lhs, Duration rhs ) { return (lhs.t n < rhs.tn) ? rhs : lhs;}94 Duration min( Duration lhs, Duration rhs ) { return !(rhs.t n < 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;} 95 95 } // distribution 96 96 … … 143 143 //######################### Time ######################### 144 144 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 );145 void ?{}( Time & time, int year, int month = 0, int day = 0, int hour = 0, int min = 0, int sec = 0, int nsec = 0 ); 146 146 static inline { 147 147 Time ?=?( Time & time, __attribute__((unused)) zero_t ) { return time{ 0 }; } 148 148 149 void ?{}( Time & time, timeval t ) with( time ) { t n= (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; } 150 150 Time ?=?( Time & time, timeval t ) with( time ) { 151 t n= (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); 152 152 return time; 153 153 } // ?=? 154 154 155 void ?{}( Time & time, timespec t ) with( time ) { t n= (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; } 156 156 Time ?=?( Time & time, timespec t ) with( time ) { 157 t n= (int64_t)t.tv_sec * TIMEGRAN + t.tv_nsec;157 tv = (int64_t)t.tv_sec * TIMEGRAN + t.tv_nsec; 158 158 return time; 159 159 } // ?=? 160 160 161 Time ?+?( Time & lhs, Duration rhs ) { return (Time)@{ lhs.t n + rhs.tn}; }161 Time ?+?( Time & lhs, Duration rhs ) { return (Time)@{ lhs.tv + rhs.tv }; } 162 162 Time ?+?( Duration lhs, Time rhs ) { return rhs + lhs; } 163 163 Time ?+=?( Time & lhs, Duration rhs ) { lhs = lhs + rhs; return lhs; } 164 164 165 Duration ?-?( Time lhs, Time rhs ) { return (Duration)@{ lhs.t n - rhs.tn}; }166 Time ?-?( Time lhs, Duration rhs ) { return (Time)@{ lhs.t n - 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 }; } 167 167 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; } 176 174 } // distribution 177 175 … … 191 189 } // dmy 192 190 193 size_t strftime( char buf[], size_t size, const char fmt[], Time time );191 size_t strftime( char * buf, size_t size, const char * fmt, Time time ); 194 192 195 193 //------------------------- timeval (cont) ------------------------- 196 194 197 195 static inline void ?{}( timeval & t, Time time ) with( t, time ) { 198 tv_sec = t n/ TIMEGRAN; // seconds199 tv_usec = t n% TIMEGRAN / (TIMEGRAN / 1_000_000LL); // microseconds196 tv_sec = tv / TIMEGRAN; // seconds 197 tv_usec = tv % TIMEGRAN / (TIMEGRAN / 1_000_000LL); // microseconds 200 198 } // ?{} 201 199 … … 203 201 204 202 static inline void ?{}( timespec & t, Time time ) with( t, time ) { 205 tv_sec = t n/ TIMEGRAN; // seconds206 tv_nsec = t n% TIMEGRAN; // nanoseconds203 tv_sec = tv / TIMEGRAN; // seconds 204 tv_nsec = tv % TIMEGRAN; // nanoseconds 207 205 } // ?{} 208 206 -
libcfa/src/time_t.hfa
r3d5701e r9fb8f01 10 10 // Created On : Tue Apr 10 14:42:03 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Jan 5 08:22:46 202013 // Update Count : 712 // Last Modified On : Fri Apr 13 07:51:47 2018 13 // Update Count : 6 14 14 // 15 15 … … 20 20 21 21 struct Duration { // private 22 int64_t t n; // nanoseconds22 int64_t tv; // nanoseconds 23 23 }; // Duration 24 24 25 static inline void ?{}( Duration & dur ) with( dur ) { t n= 0; }26 static inline void ?{}( Duration & dur, __attribute__((unused)) zero_t ) with( dur ) { t n= 0; }25 static inline void ?{}( Duration & dur ) with( dur ) { tv = 0; } 26 static inline void ?{}( Duration & dur, __attribute__((unused)) zero_t ) with( dur ) { tv = 0; } 27 27 28 28 … … 30 30 31 31 struct Time { // private 32 uint64_t t n; // nanoseconds since UNIX epoch32 uint64_t tv; // nanoseconds since UNIX epoch 33 33 }; // Time 34 34 35 static inline void ?{}( Time & time ) with( time ) { t n= 0; }36 static inline void ?{}( Time & time, __attribute__((unused)) zero_t ) with( time ) { t n= 0; }35 static inline void ?{}( Time & time ) with( time ) { tv = 0; } 36 static inline void ?{}( Time & time, __attribute__((unused)) zero_t ) with( time ) { tv = 0; } 37 37 38 38 // Local Variables: // -
longrun_tests/Makefile.am
r3d5701e r9fb8f01 42 42 -I$(abs_top_srcdir)/tests \ 43 43 -I$(srcdir) \ 44 -DTEST_$(shell cat .type | tr a-z A-Z) 44 -DTEST_$(shell cat .type | tr a-z A-Z) \ 45 -in-tree 45 46 46 47 TESTS = block coroutine create disjoint enter enter3 processor stack wait yield -
longrun_tests/Makefile.in
r3d5701e r9fb8f01 348 348 CCDEPMODE = @CCDEPMODE@ 349 349 CFACC = @CFACC@ 350 CFACC_INSTALL = @CFACC_INSTALL@351 350 CFACPP = @CFACPP@ 352 351 CFA_BACKEND_CC = @CFA_BACKEND_CC@ … … 379 378 FGREP = @FGREP@ 380 379 GREP = @GREP@ 381 HAS_DISTCC = @HAS_DISTCC@382 380 HOST_FLAGS = @HOST_FLAGS@ 383 381 INSTALL = @INSTALL@ … … 486 484 LTCFACOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ 487 485 $(LIBTOOLFLAGS) --mode=compile $(CFACC) $(DEFS) \ 488 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(AM_CFLAGS) $(CFAFLAGS) $(CFLAGS) 486 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) \ 487 $(AM_CFLAGS) $(CFLAGS) 489 488 490 489 AM_V_CFA = $(am__v_CFA_@AM_V@) … … 492 491 am__v_CFA_0 = @echo " CFA " $@; 493 492 am__v_CFA_1 = 493 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@) 494 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@) 495 am__v_JAVAC_0 = @echo " JAVAC " $@; 496 am__v_JAVAC_1 = 497 AM_V_GOC = $(am__v_GOC_@AM_V@) 498 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@) 499 am__v_GOC_0 = @echo " GOC " $@; 500 am__v_GOC_1 = 494 501 UPPCC = u++ 495 502 UPPCOMPILE = $(UPPCC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_UPPFLAGS) $(UPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_CFLAGS) $(CFLAGS) … … 498 505 am__v_UPP_0 = @echo " UPP " $@; 499 506 am__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_PY = $(am__v_PY_@AM_V@)505 am__v_PY_ = $(am__v_PY_@AM_DEFAULT_V@)506 am__v_PY_0 = @echo " PYTHON " $@;507 am__v_PY_1 =508 AM_V_RUST = $(am__v_RUST_@AM_V@)509 am__v_RUST_ = $(am__v_RUST_@AM_DEFAULT_V@)510 am__v_RUST_0 = @echo " RUST " $@;511 am__v_RUST_1 =512 AM_V_NODEJS = $(am__v_NODEJS_@AM_V@)513 am__v_NODEJS_ = $(am__v_NODEJS_@AM_DEFAULT_V@)514 am__v_NODEJS_0 = @echo " NODEJS " $@;515 am__v_NODEJS_1 =516 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)517 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)518 am__v_JAVAC_0 = @echo " JAVAC " $@;519 am__v_JAVAC_1 =520 507 repeats = 10 521 508 max_time = 600 … … 537 524 -I$(abs_top_srcdir)/tests \ 538 525 -I$(srcdir) \ 539 -DTEST_$(shell cat .type | tr a-z A-Z) 526 -DTEST_$(shell cat .type | tr a-z A-Z) \ 527 -in-tree 540 528 541 529 TESTS = block coroutine create disjoint enter enter3 processor stack wait yield -
src/AST/Convert.cpp
r3d5701e r9fb8f01 10 10 // Created On : Thu May 09 15::37::05 2019 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 11 21:39:32201913 // Update Count : 3312 // Last Modified On : Thu Jul 25 22:21:46 2019 13 // Update Count : 13 14 14 // 15 15 … … 245 245 auto decl = new StructDecl( 246 246 node->name, 247 (AggregateDecl::Aggregate)node->kind,247 node->kind, 248 248 get<Attribute>().acceptL( node->attributes ), 249 249 LinkageSpec::Spec( node->linkage.val ) … … 675 675 676 676 const ast::Expr * visit( const ast::KeywordCastExpr * node ) override final { 677 AggregateDecl::Aggregate castTarget = (AggregateDecl::Aggregate)node->target; 678 assert( AggregateDecl::Generator <= castTarget && castTarget <= AggregateDecl::Thread ); 677 KeywordCastExpr::Target castTarget = KeywordCastExpr::NUMBER_OF_TARGETS; 678 switch (node->target) { 679 case ast::KeywordCastExpr::Coroutine: 680 castTarget = KeywordCastExpr::Coroutine; 681 break; 682 case ast::KeywordCastExpr::Thread: 683 castTarget = KeywordCastExpr::Thread; 684 break; 685 case ast::KeywordCastExpr::Monitor: 686 castTarget = KeywordCastExpr::Monitor; 687 break; 688 default: 689 break; 690 } 691 assert ( castTarget < KeywordCastExpr::NUMBER_OF_TARGETS ); 679 692 auto expr = visitBaseExpr( node, 680 693 new KeywordCastExpr( … … 874 887 auto expr = visitBaseExpr( node, 875 888 new AsmExpr( 876 new std::string(node->inout),889 get<Expression>().accept1(node->inout), 877 890 get<Expression>().accept1(node->constraint), 878 891 get<Expression>().accept1(node->operand) … … 1223 1236 cv( node ), 1224 1237 node->name, 1225 node->kind == ast::Type Decl::Ftype,1238 node->kind == ast::TypeVar::Ftype, 1226 1239 get<Attribute>().acceptL( node->attributes ) 1227 1240 }; … … 1491 1504 old->location, 1492 1505 old->name, 1493 (ast::AggregateDecl::Aggregate)old->kind,1506 old->kind, 1494 1507 GET_ACCEPT_V(attributes, Attribute), 1495 1508 { old->linkage.val } … … 1578 1591 { old->storageClasses.val }, 1579 1592 GET_ACCEPT_1(base, Type), 1580 (ast::Type Decl::Kind)(unsigned)old->kind,1593 (ast::TypeVar::Kind)(unsigned)old->kind, 1581 1594 old->sized, 1582 1595 GET_ACCEPT_1(init, Type) … … 2032 2045 } 2033 2046 2034 virtual void visit( const KeywordCastExpr * old ) override final { 2035 ast::AggregateDecl::Aggregate castTarget = (ast::AggregateDecl::Aggregate)old->target; 2036 assert( ast::AggregateDecl::Generator <= castTarget && castTarget <= ast::AggregateDecl::Thread ); 2047 virtual void visit( const KeywordCastExpr * old) override final { 2048 ast::KeywordCastExpr::Target castTarget = ast::KeywordCastExpr::NUMBER_OF_TARGETS; 2049 switch (old->target) { 2050 case KeywordCastExpr::Coroutine: 2051 castTarget = ast::KeywordCastExpr::Coroutine; 2052 break; 2053 case KeywordCastExpr::Thread: 2054 castTarget = ast::KeywordCastExpr::Thread; 2055 break; 2056 case KeywordCastExpr::Monitor: 2057 castTarget = ast::KeywordCastExpr::Monitor; 2058 break; 2059 default: 2060 break; 2061 } 2062 assert ( castTarget < ast::KeywordCastExpr::NUMBER_OF_TARGETS ); 2037 2063 this->node = visitBaseExpr( old, 2038 2064 new ast::KeywordCastExpr( … … 2232 2258 new ast::AsmExpr( 2233 2259 old->location, 2234 old->inout,2260 GET_ACCEPT_1(inout, Expr), 2235 2261 GET_ACCEPT_1(constraint, Expr), 2236 2262 GET_ACCEPT_1(operand, Expr) … … 2561 2587 ty = new ast::TypeInstType{ 2562 2588 old->name, 2563 old->isFtype ? ast::Type Decl::Ftype : ast::TypeDecl::Dtype,2589 old->isFtype ? ast::TypeVar::Ftype : ast::TypeVar::Dtype, 2564 2590 cv( old ), 2565 2591 GET_ACCEPT_V( attributes, Attribute ) -
src/AST/Decl.cpp
r3d5701e r9fb8f01 9 9 // Author : Aaron B. Moss 10 10 // Created On : Thu May 9 10:00:00 2019 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Dec 13 16:23:15201913 // Update Count : 2011 // Last Modified By : Aaron B. Moss 12 // Last Modified On : Thu May 9 10:00:00 2019 13 // Update Count : 1 14 14 // 15 15 … … 18 18 #include <cassert> // for assert, strict_dynamic_cast 19 19 #include <iostream> 20 #include <string> 20 21 #include <unordered_map> 21 22 … … 26 27 #include "Node.hpp" // for readonly 27 28 #include "Type.hpp" // for readonly 29 #include "Parser/ParseNode.h" // for DeclarationNode 28 30 29 31 namespace ast { … … 54 56 // --- TypeDecl 55 57 56 const char * TypeDecl::typeString() const { 57 static const char * kindNames[] = { "sized data type", "sized object type", "sized function type", "sized tuple type" }; 58 static_assert( sizeof(kindNames)/sizeof(kindNames[0]) == TypeDecl::NUMBER_OF_KINDS, "typeString: kindNames is out of sync." ); 59 assertf( kind < TypeDecl::NUMBER_OF_KINDS, "TypeDecl kind is out of bounds." ); 60 return sized ? kindNames[ kind ] : &kindNames[ kind ][ sizeof("sized") ]; // sizeof includes '\0' 58 std::string TypeDecl::typeString() const { 59 static const std::string kindNames[] = { "object type", "function type", "tuple type" }; 60 assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, 61 "typeString: kindNames is out of sync." ); 62 assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." ); 63 return (sized ? "sized " : "") + kindNames[ kind ]; 61 64 } 62 65 63 const char *TypeDecl::genTypeString() const {64 static const char * kindNames[] = { "dtype", "otype", "ftype", "ttype" };65 static_assert( sizeof(kindNames)/sizeof(kindNames[0]) == TypeDecl::NUMBER_OF_KINDS, "genTypeString: kindNames is out of sync." );66 assertf( kind < TypeDecl::NUMBER_OF_KINDS, "TypeDeclkind is out of bounds." );66 std::string TypeDecl::genTypeString() const { 67 static const std::string kindNames[] = { "dtype", "ftype", "ttype" }; 68 assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "genTypeString: kindNames is out of sync." ); 69 assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." ); 67 70 return kindNames[ kind ]; 68 71 } … … 70 73 std::ostream & operator<< ( std::ostream & out, const TypeDecl::Data & data ) { 71 74 return out << data.kind << ", " << data.isComplete; 72 }73 74 // --- AggregateDecl75 76 // These must harmonize with the corresponding AggregateDecl::Aggregate enumerations.77 static const char * aggregateNames[] = { "struct", "union", "enum", "exception", "trait", "generator", "coroutine", "monitor", "thread", "NoAggregateName" };78 79 const char * AggregateDecl::aggrString( AggregateDecl::Aggregate aggr ) {80 return aggregateNames[aggr];81 75 } 82 76 -
src/AST/Decl.hpp
r3d5701e r9fb8f01 9 9 // Author : Aaron B. Moss 10 10 // Created On : Thu May 9 10:00:00 2019 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Dec 13 17:38:33201913 // Update Count : 2911 // Last Modified By : Aaron B. Moss 12 // Last Modified On : Thu May 9 10:00:00 2019 13 // Update Count : 1 14 14 // 15 15 … … 20 20 #include <unordered_map> 21 21 #include <vector> 22 #include <algorithm>23 22 24 23 #include "FunctionSpec.hpp" … … 28 27 #include "ParseNode.hpp" 29 28 #include "StorageClasses.hpp" 29 #include "TypeVar.hpp" 30 30 #include "Visitor.hpp" 31 #include "Common/utility.h" 32 #include "Common/SemanticError.h" // error_str 31 #include "Parser/ParseNode.h" // for DeclarationNode::Aggregate 33 32 34 33 // Must be included in *all* AST classes; should be #undef'd at the end of the file … … 126 125 std::vector< ptr<Expr> > withExprs; 127 126 128 FunctionDecl( const CodeLocation & loc, const std::string & name, FunctionType * type,127 FunctionDecl( const CodeLocation & loc, const std::string &name, FunctionType * type, 129 128 CompoundStmt * stmts, Storage::Classes storage = {}, Linkage::Spec linkage = Linkage::C, 130 129 std::vector<ptr<Attribute>>&& attrs = {}, Function::Specs fs = {}) … … 137 136 bool has_body() const { return stmts; } 138 137 139 const DeclWithType * accept( Visitor & v ) const override { return v.visit( this ); }138 const DeclWithType * accept( Visitor &v ) const override { return v.visit( this ); } 140 139 private: 141 140 FunctionDecl * clone() const override { return new FunctionDecl( *this ); } … … 155 154 156 155 /// Produces a name for the kind of alias 157 virtual const char *typeString() const = 0;156 virtual std::string typeString() const = 0; 158 157 159 158 private: … … 164 163 /// Cforall type variable: `dtype T` 165 164 class TypeDecl final : public NamedTypeDecl { 166 public: 167 enum Kind { Dtype, Otype, Ftype, Ttype, NUMBER_OF_KINDS }; 168 169 Kind kind; 165 public: 166 TypeVar::Kind kind; 170 167 bool sized; 171 168 ptr<Type> init; … … 173 170 /// Data extracted from a type decl 174 171 struct Data { 175 Kind kind;172 TypeVar::Kind kind; 176 173 bool isComplete; 177 174 178 Data() : kind( NUMBER_OF_KINDS), isComplete( false ) {}175 Data() : kind( (TypeVar::Kind)-1 ), isComplete( false ) {} 179 176 Data( const TypeDecl * d ) : kind( d->kind ), isComplete( d->sized ) {} 180 Data( Kind k, bool c ) : kind( k ), isComplete( c ) {}177 Data( TypeVar::Kind k, bool c ) : kind( k ), isComplete( c ) {} 181 178 Data( const Data & d1, const Data & d2 ) 182 : kind( d1.kind ), isComplete( d1.isComplete || d2.isComplete ) {} 183 184 bool operator==( const Data & o ) const { return kind == o.kind && isComplete == o.isComplete; } 185 bool operator!=( const Data & o ) const { return !(*this == o); } 179 : kind( d1.kind ), isComplete( d1.isComplete || d2.isComplete ) {} 180 181 bool operator== ( const Data & o ) const { 182 return kind == o.kind && isComplete == o.isComplete; 183 } 184 bool operator!= ( const Data & o ) const { return !(*this == o); } 186 185 }; 187 186 188 TypeDecl( const CodeLocation & loc, const std::string & name, Storage::Classes storage, Type* b,189 Kind k, bool s, Type* i = nullptr )190 : NamedTypeDecl( loc, name, storage, b ), kind( k ), sized( k ==Ttype || s ),191 init( i ) {}192 193 const char *typeString() const override;187 TypeDecl( const CodeLocation& loc, const std::string& name, Storage::Classes storage, Type* b, 188 TypeVar::Kind k, bool s, Type* i = nullptr ) 189 : NamedTypeDecl( loc, name, storage, b ), kind( k ), sized( k == TypeVar::Ttype || s ), 190 init( i ) {} 191 192 std::string typeString() const override; 194 193 /// Produces a name for generated code 195 const char *genTypeString() const;194 std::string genTypeString() const; 196 195 197 196 /// convenience accessor to match Type::isComplete() … … 199 198 200 199 const Decl * accept( Visitor & v ) const override { return v.visit( this ); } 201 private:200 private: 202 201 TypeDecl * clone() const override { return new TypeDecl{ *this }; } 203 202 MUTATE_FRIEND … … 213 212 : NamedTypeDecl( loc, name, storage, b, spec ) {} 214 213 215 const char *typeString() const override { return "typedef"; }214 std::string typeString() const override { return "typedef"; } 216 215 217 216 const Decl * accept( Visitor & v ) const override { return v.visit( this ); } … … 224 223 class AggregateDecl : public Decl { 225 224 public: 226 enum Aggregate { Struct, Union, Enum, Exception, Trait, Generator, Coroutine, Monitor, Thread, NoAggregate };227 static const char * aggrString( Aggregate aggr );228 229 225 std::vector<ptr<Decl>> members; 230 226 std::vector<ptr<TypeDecl>> params; … … 241 237 242 238 /// Produces a name for the kind of aggregate 243 virtual const char *typeString() const = 0;239 virtual std::string typeString() const = 0; 244 240 245 241 private: … … 251 247 class StructDecl final : public AggregateDecl { 252 248 public: 253 Aggregate kind;249 DeclarationNode::Aggregate kind; 254 250 255 251 StructDecl( const CodeLocation& loc, const std::string& name, 256 Aggregate kind =Struct,252 DeclarationNode::Aggregate kind = DeclarationNode::Struct, 257 253 std::vector<ptr<Attribute>>&& attrs = {}, Linkage::Spec linkage = Linkage::Cforall ) 258 254 : AggregateDecl( loc, name, std::move(attrs), linkage ), kind( kind ) {} 259 255 260 bool is_coroutine() { return kind == Coroutine; }261 bool is_monitor() { return kind == Monitor; }262 bool is_thread() { return kind == Thread; }263 264 const Decl * accept( Visitor & v ) const override { return v.visit( this ); } 265 266 const char * typeString() const override { return aggrString( kind ); }256 bool is_coroutine() { return kind == DeclarationNode::Coroutine; } 257 bool is_monitor() { return kind == DeclarationNode::Monitor; } 258 bool is_thread() { return kind == DeclarationNode::Thread; } 259 260 const Decl * accept( Visitor & v ) const override { return v.visit( this ); } 261 262 std::string typeString() const override { return "struct"; } 267 263 268 264 private: … … 280 276 const Decl * accept( Visitor& v ) const override { return v.visit( this ); } 281 277 282 const char * typeString() const override { return aggrString( Union ); }278 std::string typeString() const override { return "union"; } 283 279 284 280 private: … … 299 295 const Decl * accept( Visitor & v ) const override { return v.visit( this ); } 300 296 301 const char * typeString() const override { return aggrString( Enum ); }297 std::string typeString() const override { return "enum"; } 302 298 303 299 private: … … 318 314 const Decl * accept( Visitor & v ) const override { return v.visit( this ); } 319 315 320 const char *typeString() const override { return "trait"; }316 std::string typeString() const override { return "trait"; } 321 317 322 318 private: … … 344 340 ptr<AsmStmt> stmt; 345 341 346 AsmDecl( const CodeLocation & loc, AsmStmt * stmt )342 AsmDecl( const CodeLocation & loc, AsmStmt *stmt ) 347 343 : Decl( loc, "", {}, {} ), stmt(stmt) {} 348 344 349 const AsmDecl * accept( Visitor & v ) const override { return v.visit( this ); }350 private: 351 AsmDecl * clone() const override { return new AsmDecl( *this ); }345 const AsmDecl * accept( Visitor &v ) const override { return v.visit( this ); } 346 private: 347 AsmDecl *clone() const override { return new AsmDecl( *this ); } 352 348 MUTATE_FRIEND 353 349 }; … … 361 357 : Decl( loc, "", {}, {} ), cond( condition ), msg( msg ) {} 362 358 363 const StaticAssertDecl * accept( Visitor & v ) const override { return v.visit( this ); }359 const StaticAssertDecl * accept( Visitor &v ) const override { return v.visit( this ); } 364 360 private: 365 361 StaticAssertDecl * clone() const override { return new StaticAssertDecl( *this ); } -
src/AST/Expr.cpp
r3d5701e r9fb8f01 9 9 // Author : Aaron B. Moss 10 10 // Created On : Wed May 15 17:00:00 2019 11 // Last Modified By : Peter A. Buhr11 // Last Modified By : Andrew Beach 12 12 // Created On : Thr Jun 13 13:38:00 2019 13 // Update Count : 613 // Update Count : 2 14 14 // 15 15 … … 141 141 // --- KeywordCastExpr 142 142 143 const char * KeywordCastExpr::targetString() const { 144 return AggregateDecl::aggrString( target ); 143 const std::string & KeywordCastExpr::targetString() const { 144 static const std::string targetStrs[] = { 145 "coroutine", "thread", "monitor" 146 }; 147 static_assert( 148 (sizeof(targetStrs) / sizeof(targetStrs[0])) == ((unsigned long)NUMBER_OF_TARGETS), 149 "Each KeywordCastExpr::Target should have a corresponding string representation" 150 ); 151 return targetStrs[(unsigned long)target]; 145 152 } 146 153 -
src/AST/Expr.hpp
r3d5701e r9fb8f01 9 9 // Author : Aaron B. Moss 10 10 // Created On : Fri May 10 10:30:00 2019 11 // Last Modified By : Peter A. Buhr11 // Last Modified By : Aaron B. Moss 12 12 // Created On : Fri May 10 10:30:00 2019 13 // Update Count : 713 // Update Count : 1 14 14 // 15 15 … … 26 26 #include "Fwd.hpp" // for UniqueId 27 27 #include "Label.hpp" 28 #include "Decl.hpp"29 28 #include "ParseNode.hpp" 30 29 #include "Visitor.hpp" … … 301 300 public: 302 301 ptr<Expr> arg; 303 ast::AggregateDecl::Aggregatetarget;304 305 KeywordCastExpr( const CodeLocation & loc, const Expr * a, ast::AggregateDecl::Aggregatet )302 enum Target { Coroutine, Thread, Monitor, NUMBER_OF_TARGETS } target; 303 304 KeywordCastExpr( const CodeLocation & loc, const Expr * a, Target t ) 306 305 : Expr( loc ), arg( a ), target( t ) {} 307 306 308 307 /// Get a name for the target type 309 const char *targetString() const;308 const std::string& targetString() const; 310 309 311 310 const Expr * accept( Visitor & v ) const override { return v.visit( this ); } … … 557 556 class AsmExpr final : public Expr { 558 557 public: 559 std::stringinout;558 ptr<Expr> inout; 560 559 ptr<Expr> constraint; 561 560 ptr<Expr> operand; 562 561 563 AsmExpr( const CodeLocation & loc, const std::string &io, const Expr * con, const Expr * op )562 AsmExpr( const CodeLocation & loc, const Expr * io, const Expr * con, const Expr * op ) 564 563 : Expr( loc ), inout( io ), constraint( con ), operand( op ) {} 565 564 -
src/AST/Pass.impl.hpp
r3d5701e r9fb8f01 1300 1300 maybe_accept( node, &AsmExpr::result ); 1301 1301 } 1302 maybe_accept( node, &AsmExpr::inout ); 1302 1303 maybe_accept( node, &AsmExpr::constraint ); 1303 1304 maybe_accept( node, &AsmExpr::operand ); -
src/AST/Print.cpp
r3d5701e r9fb8f01 1011 1011 os << "Asm Expression:" << endl; 1012 1012 ++indent; 1013 if ( !node->inout.empty() ) os << "[" << node->inout << "] ";1013 if ( node->inout ) node->inout->accept( *this ); 1014 1014 if ( node->constraint ) node->constraint->accept( *this ); 1015 1015 if ( node->operand ) node->operand->accept( *this ); … … 1359 1359 preprint( node ); 1360 1360 os << "instance of type " << node->name 1361 << " (" << (node->kind == ast::Type Decl::Ftype ? "" : "not ") << "function type)";1361 << " (" << (node->kind == ast::TypeVar::Ftype ? "" : "not ") << "function type)"; 1362 1362 print( node->params ); 1363 1363 -
src/AST/Type.cpp
r3d5701e r9fb8f01 9 9 // Author : Aaron B. Moss 10 10 // Created On : Mon May 13 15:00:00 2019 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sun Dec 15 16:56:28201913 // Update Count : 411 // Last Modified By : Aaron B. Moss 12 // Last Modified On : Mon May 13 15:00:00 2019 13 // Update Count : 1 14 14 // 15 15 … … 48 48 // --- BasicType 49 49 50 // GENERATED START, DO NOT EDIT 51 // GENERATED BY BasicTypes-gen.cc 52 const char * BasicType::typeNames[] = { 50 const char *BasicType::typeNames[] = { 53 51 "_Bool", 54 52 "char", … … 88 86 "_Float128x _Complex", 89 87 }; 90 // GENERATED END 88 static_assert( 89 sizeof(BasicType::typeNames)/sizeof(BasicType::typeNames[0]) == BasicType::NUMBER_OF_BASIC_TYPES, 90 "Each basic type name should have a corresponding kind enum value" 91 ); 91 92 92 93 // --- FunctionType -
src/AST/Type.hpp
r3d5701e r9fb8f01 9 9 // Author : Aaron B. Moss 10 10 // Created On : Thu May 9 10:00:00 2019 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Dec 11 21:56:46201913 // Update Count : 511 // Last Modified By : Aaron B. Moss 12 // Last Modified On : Thu May 9 10:00:00 2019 13 // Update Count : 1 14 14 // 15 15 … … 26 26 #include "Fwd.hpp" 27 27 #include "Node.hpp" // for Node, ptr, ptr_base 28 #include "TypeVar.hpp" 28 29 #include "Visitor.hpp" 29 30 … … 422 423 public: 423 424 readonly<TypeDecl> base; 424 Type Decl::Kind kind;425 TypeVar::Kind kind; 425 426 426 427 TypeInstType( const std::string& n, const TypeDecl * b, CV::Qualifiers q = {}, 427 428 std::vector<ptr<Attribute>> && as = {} ) 428 429 : ReferenceToType( n, q, std::move(as) ), base( b ), kind( b->kind ) {} 429 TypeInstType( const std::string& n, Type Decl::Kind k, CV::Qualifiers q = {},430 TypeInstType( const std::string& n, TypeVar::Kind k, CV::Qualifiers q = {}, 430 431 std::vector<ptr<Attribute>> && as = {} ) 431 432 : ReferenceToType( n, q, std::move(as) ), base(), kind( k ) {} -
src/AST/TypeEnvironment.cpp
r3d5701e r9fb8f01 9 9 // Author : Aaron B. Moss 10 10 // Created On : Wed May 29 11:00:00 2019 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Dec 11 21:49:13201913 // Update Count : 411 // Last Modified By : Aaron B. Moss 12 // Last Modified On : Wed May 29 11:00:00 2019 13 // Update Count : 1 14 14 // 15 15 … … 240 240 return true; 241 241 } else if ( auto typeInst = dynamic_cast< const TypeInstType * >( type ) ) { 242 return typeInst->kind == Type Decl::Ftype;242 return typeInst->kind == TypeVar::Ftype; 243 243 } else return false; 244 244 } … … 248 248 bool tyVarCompatible( const TypeDecl::Data & data, const Type * type ) { 249 249 switch ( data.kind ) { 250 case Type Decl::Dtype:250 case TypeVar::Dtype: 251 251 // to bind to an object type variable, the type must not be a function type. 252 252 // if the type variable is specified to be a complete type then the incoming … … 254 254 // xxx - should this also check that type is not a tuple type and that it's not a ttype? 255 255 return ! isFtype( type ) && ( ! data.isComplete || type->isComplete() ); 256 case Type Decl::Ftype:256 case TypeVar::Ftype: 257 257 return isFtype( type ); 258 case Type Decl::Ttype:258 case TypeVar::Ttype: 259 259 // ttype unifies with any tuple type 260 260 return dynamic_cast< const TupleType * >( type ) || Tuples::isTtype( type ); -
src/AST/TypeEnvironment.hpp
r3d5701e r9fb8f01 9 9 // Author : Aaron B. Moss 10 10 // Created On : Wed May 29 11:00:00 2019 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Dec 11 21:55:54201913 // Update Count : 311 // Last Modified By : Aaron B. Moss 12 // Last Modified On : Wed May 29 11:00:00 2019 13 // Update Count : 1 14 14 // 15 15 … … 28 28 #include "Type.hpp" 29 29 #include "TypeSubstitution.hpp" 30 #include "TypeVar.hpp" 30 31 #include "Common/Indenter.h" 31 32 #include "ResolvExpr/WidenMode.h" … … 106 107 /// Singleton class constructor from substitution 107 108 EqvClass( const std::string & v, const Type * b ) 108 : vars{ v }, bound( b ), allowWidening( false ), data( Type Decl::Dtype, false ) {}109 : vars{ v }, bound( b ), allowWidening( false ), data( TypeVar::Dtype, false ) {} 109 110 110 111 /// Single-var constructor (strips qualifiers from bound type) -
src/AST/module.mk
r3d5701e r9fb8f01 10 10 ## Author : Thierry Delisle 11 11 ## Created On : Thu May 09 16:05:36 2019 12 ## Last Modified By : Peter A. Buhr13 ## Last Modified On : Sat Dec 14 07:29:10 201914 ## Update Count : 312 ## Last Modified By : 13 ## Last Modified On : 14 ## Update Count : 15 15 ############################################################################### 16 16 … … 34 34 AST/TypeSubstitution.cpp 35 35 36 37 36 38 SRC += $(SRC_AST) 37 39 SRCDEMANGLE += $(SRC_AST) -
src/BasicTypes-gen.cc
r3d5701e r9fb8f01 273 273 274 274 275 #define Type HTOP_SRCDIR "src/SynTree/Type.h"276 resetInput( file, Type H, buffer, code, str );277 278 if ( (start = str.find( STARTMK )) == string::npos ) Abort( "start", Type H);275 #define Type TOP_SRCDIR "src/SynTree/Type.h" 276 resetInput( file, Type, buffer, code, str ); 277 278 if ( (start = str.find( STARTMK )) == string::npos ) Abort( "start", Type ); 279 279 start += sizeof( STARTMK ); // includes newline 280 280 code << str.substr( 0, start ); … … 289 289 code << "\t"; // indentation for end marker 290 290 291 if ( (start = str.find( ENDMK, start + 1 )) == string::npos ) Abort( "end", Type H);291 if ( (start = str.find( ENDMK, start + 1 )) == string::npos ) Abort( "end", Type ); 292 292 code << str.substr( start ); 293 293 294 output( file, Type H, code );294 output( file, Type, code ); 295 295 // cout << code.str(); 296 296 297 297 298 #define TypeC TOP_SRCDIR "src/SynTree/Type.cc"299 resetInput( file, TypeC, buffer, code, str );300 301 if ( (start = str.find( STARTMK )) == string::npos ) Abort( "start", TypeC );302 start += sizeof( STARTMK ); // includes newline303 code << str.substr( 0, start );304 305 code << BYMK << endl;306 code << "const char * BasicType::typeNames[] = {" << endl;307 for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) {308 code << "\t\"" << graph[r].type << "\"," << endl;309 } // for310 code << "};" << endl;311 312 if ( (start = str.find( ENDMK, start + 1 )) == string::npos ) Abort( "end", TypeC );313 code << str.substr( start );314 315 output( file, TypeC, code );316 // cout << code.str();317 318 319 298 // TEMPORARY DURING CHANGE OVER 320 #define Type H_AST TOP_SRCDIR "src/AST/Type.hpp"321 resetInput( file, Type H_AST, buffer, code, str );322 323 if ( (start = str.find( STARTMK )) == string::npos ) Abort( "start", Type H_AST );299 #define TypeAST TOP_SRCDIR "src/AST/Type.hpp" 300 resetInput( file, TypeAST, buffer, code, str ); 301 302 if ( (start = str.find( STARTMK )) == string::npos ) Abort( "start", TypeAST ); 324 303 start += sizeof( STARTMK ); // includes newline 325 304 code << str.substr( 0, start ); … … 334 313 code << "\t"; // indentation for end marker 335 314 336 if ( (start = str.find( ENDMK, start + 1 )) == string::npos ) Abort( "end", Type H_AST );315 if ( (start = str.find( ENDMK, start + 1 )) == string::npos ) Abort( "end", TypeAST ); 337 316 code << str.substr( start ); 338 317 339 output( file, TypeH_AST, code ); 340 // cout << code.str(); 341 342 343 #define TypeC_AST TOP_SRCDIR "src/AST/Type.cpp" 344 resetInput( file, TypeC_AST, buffer, code, str ); 345 346 if ( (start = str.find( STARTMK )) == string::npos ) Abort( "start", TypeC_AST ); 347 start += sizeof( STARTMK ); // includes newline 348 code << str.substr( 0, start ); 349 350 code << BYMK << endl; 351 code << "const char * BasicType::typeNames[] = {" << endl; 352 for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { 353 code << "\t\"" << graph[r].type << "\"," << endl; 354 } // for 355 code << "};" << endl; 356 357 if ( (start = str.find( ENDMK, start + 1 )) == string::npos ) Abort( "end", TypeC_AST ); 358 code << str.substr( start ); 359 360 output( file, TypeC_AST, code ); 318 output( file, TypeAST, code ); 361 319 // cout << code.str(); 362 320 -
src/CodeGen/CodeGenerator.cc
r3d5701e r9fb8f01 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sun Feb 16 08:32:48 202013 // Update Count : 53211 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr May 2 10:47:00 2019 13 // Update Count : 497 14 14 // 15 15 #include "CodeGenerator.h" … … 23 23 #include "InitTweak/InitTweak.h" // for getPointerBase 24 24 #include "OperatorTable.h" // for OperatorInfo, operatorLookup 25 #include " SynTree/LinkageSpec.h"// for Spec, Intrinsic25 #include "Parser/LinkageSpec.h" // for Spec, Intrinsic 26 26 #include "SynTree/Attribute.h" // for Attribute 27 27 #include "SynTree/BaseSyntaxNode.h" // for BaseSyntaxNode … … 39 39 int CodeGenerator::tabsize = 4; 40 40 41 // The kinds of statements that would ideally be followed by whitespace.41 // the kinds of statements that would ideally be followed by whitespace 42 42 bool wantSpacing( Statement * stmt) { 43 43 return dynamic_cast< IfStmt * >( stmt ) || dynamic_cast< CompoundStmt * >( stmt ) || … … 78 78 } 79 79 80 // Using updateLocation at the beginning of a node and endl within a node should become the method of formating. 80 /* Using updateLocation at the beginning of a node and endl 81 * within a node should become the method of formating. 82 */ 81 83 void CodeGenerator::updateLocation( CodeLocation const & to ) { 82 84 // skip if linemarks shouldn't appear or if codelocation is unset … … 93 95 } else { 94 96 output << "\n# " << to.first_line << " \"" << to.filename 95 << "\"\n" << indent;97 << "\"\n" << indent; 96 98 currentLocation = to; 97 99 } … … 129 131 130 132 void CodeGenerator::genAttributes( list< Attribute * > & attributes ) { 131 if ( attributes.empty() ) return;133 if ( attributes.empty() ) return; 132 134 output << "__attribute__ (("; 133 135 for ( list< Attribute * >::iterator attr( attributes.begin() );; ) { … … 138 140 output << ")"; 139 141 } // if 140 if ( ++attr == attributes.end() ) break;142 if ( ++attr == attributes.end() ) break; 141 143 output << ","; // separator 142 144 } // for … … 163 165 previsit( (BaseSyntaxNode *)node ); 164 166 GuardAction( [this, node](){ 165 if ( options.printExprTypes && node->result ) {166 output << " /* " << genType( node->result, "", options ) << " */ ";167 }168 } );167 if ( options.printExprTypes && node->result ) { 168 output << " /* " << genType( node->result, "", options ) << " */ "; 169 } 170 } ); 169 171 } 170 172 … … 196 198 // deleted decls should never be used, so don't print them 197 199 if ( objectDecl->isDeleted && options.genC ) return; 198 199 // gcc allows an empty declarator (no name) for bit-fields and C states: 6.7.2.1 Structure and union specifiers, 200 // point 4, page 113: If the (bit field) value is zero, the declaration shall have no declarator. For anything 201 // else, the anonymous name refers to the anonymous object for plan9 inheritance. 202 if ( objectDecl->get_name().empty() && options.genC && ! objectDecl->get_bitfieldWidth() ) { 200 if (objectDecl->get_name().empty() && options.genC ) { 203 201 // only generate an anonymous name when generating C code, otherwise it clutters the output too much 204 202 static UniqueName name = { "__anonymous_object" }; 205 203 objectDecl->set_name( name.newName() ); 206 // Stops unused parameter warnings.207 if ( options.anonymousUnused ) {208 objectDecl->attributes.push_back( new Attribute( "unused" ) );209 }204 // Stops unused parameter warnings. 205 if ( options.anonymousUnused ) { 206 objectDecl->attributes.push_back( new Attribute( "unused" ) ); 207 } 210 208 } 211 209 … … 397 395 extension( applicationExpr ); 398 396 if ( VariableExpr * varExpr = dynamic_cast< VariableExpr* >( applicationExpr->get_function() ) ) { 399 const OperatorInfo *opInfo;400 if ( varExpr->get_var()->get_linkage() == LinkageSpec::Intrinsic && ( opInfo = operatorLookup( varExpr->get_var()->get_name() )) ) {397 OperatorInfo opInfo; 398 if ( varExpr->get_var()->get_linkage() == LinkageSpec::Intrinsic && operatorLookup( varExpr->get_var()->get_name(), opInfo ) ) { 401 399 std::list< Expression* >::iterator arg = applicationExpr->get_args().begin(); 402 switch ( opInfo ->type ) {400 switch ( opInfo.type ) { 403 401 case OT_INDEX: 404 402 assert( applicationExpr->get_args().size() == 2 ); … … 421 419 output << "("; 422 420 (*arg++)->accept( *visitor ); 423 output << ") /* " << opInfo ->inputName << " */";421 output << ") /* " << opInfo.inputName << " */"; 424 422 } else if ( applicationExpr->get_args().size() == 2 ) { 425 423 // intrinsic two parameter constructors are essentially bitwise assignment 426 424 output << "("; 427 425 (*arg++)->accept( *visitor ); 428 output << opInfo ->symbol;426 output << opInfo.symbol; 429 427 (*arg)->accept( *visitor ); 430 output << ") /* " << opInfo ->inputName << " */";428 output << ") /* " << opInfo.inputName << " */"; 431 429 } else { 432 430 // no constructors with 0 or more than 2 parameters … … 439 437 assert( applicationExpr->get_args().size() == 1 ); 440 438 output << "("; 441 output << opInfo ->symbol;439 output << opInfo.symbol; 442 440 (*arg)->accept( *visitor ); 443 441 output << ")"; … … 448 446 assert( applicationExpr->get_args().size() == 1 ); 449 447 (*arg)->accept( *visitor ); 450 output << opInfo ->symbol;448 output << opInfo.symbol; 451 449 break; 452 450 … … 457 455 output << "("; 458 456 (*arg++)->accept( *visitor ); 459 output << opInfo ->symbol;457 output << opInfo.symbol; 460 458 (*arg)->accept( *visitor ); 461 459 output << ")"; … … 484 482 extension( untypedExpr ); 485 483 if ( NameExpr * nameExpr = dynamic_cast< NameExpr* >( untypedExpr->function ) ) { 486 const OperatorInfo * opInfo = operatorLookup( nameExpr->name );487 if ( op Info) {484 OperatorInfo opInfo; 485 if ( operatorLookup( nameExpr->name, opInfo ) ) { 488 486 std::list< Expression* >::iterator arg = untypedExpr->args.begin(); 489 switch ( opInfo ->type ) {487 switch ( opInfo.type ) { 490 488 case OT_INDEX: 491 489 assert( untypedExpr->args.size() == 2 ); … … 506 504 output << "("; 507 505 (*arg++)->accept( *visitor ); 508 output << ") /* " << opInfo ->inputName << " */";506 output << ") /* " << opInfo.inputName << " */"; 509 507 } else if ( untypedExpr->get_args().size() == 2 ) { 510 508 // intrinsic two parameter constructors are essentially bitwise assignment 511 509 output << "("; 512 510 (*arg++)->accept( *visitor ); 513 output << opInfo ->symbol;511 output << opInfo.symbol; 514 512 (*arg)->accept( *visitor ); 515 output << ") /* " << opInfo ->inputName << " */";513 output << ") /* " << opInfo.inputName << " */"; 516 514 } else { 517 515 // no constructors with 0 or more than 2 parameters … … 519 517 output << "("; 520 518 (*arg++)->accept( *visitor ); 521 output << opInfo ->symbol << "{ ";519 output << opInfo.symbol << "{ "; 522 520 genCommaList( arg, untypedExpr->args.end() ); 523 output << "}) /* " << opInfo ->inputName << " */";521 output << "}) /* " << opInfo.inputName << " */"; 524 522 } // if 525 523 break; … … 530 528 assert( untypedExpr->args.size() == 1 ); 531 529 output << "("; 532 output << opInfo ->symbol;530 output << opInfo.symbol; 533 531 (*arg)->accept( *visitor ); 534 532 output << ")"; … … 539 537 assert( untypedExpr->args.size() == 1 ); 540 538 (*arg)->accept( *visitor ); 541 output << opInfo ->symbol;539 output << opInfo.symbol; 542 540 break; 543 541 … … 547 545 output << "("; 548 546 (*arg++)->accept( *visitor ); 549 output << opInfo ->symbol;547 output << opInfo.symbol; 550 548 (*arg)->accept( *visitor ); 551 549 output << ")"; … … 579 577 void CodeGenerator::postvisit( NameExpr * nameExpr ) { 580 578 extension( nameExpr ); 581 const OperatorInfo * opInfo = operatorLookup( nameExpr->name );582 if ( op Info) {583 if ( opInfo ->type == OT_CONSTANT ) {584 output << opInfo ->symbol;579 OperatorInfo opInfo; 580 if ( operatorLookup( nameExpr->name, opInfo ) ) { 581 if ( opInfo.type == OT_CONSTANT ) { 582 output << opInfo.symbol; 585 583 } else { 586 output << opInfo ->outputName;584 output << opInfo.outputName; 587 585 } 588 586 } else { … … 652 650 void CodeGenerator::postvisit( VariableExpr * variableExpr ) { 653 651 extension( variableExpr ); 654 const OperatorInfo *opInfo;655 if ( variableExpr->get_var()->get_linkage() == LinkageSpec::Intrinsic && (opInfo = operatorLookup( variableExpr->get_var()->get_name() )) && opInfo->type == OT_CONSTANT ) {656 output << opInfo ->symbol;652 OperatorInfo opInfo; 653 if ( variableExpr->get_var()->get_linkage() == LinkageSpec::Intrinsic && operatorLookup( variableExpr->get_var()->get_name(), opInfo ) && opInfo.type == OT_CONSTANT ) { 654 output << opInfo.symbol; 657 655 } else { 658 656 output << mangleName( variableExpr->get_var() ); … … 784 782 785 783 void CodeGenerator::postvisit( AsmExpr * asmExpr ) { 786 if ( !asmExpr->inout.empty() ) {784 if ( asmExpr->get_inout() ) { 787 785 output << "[ "; 788 output << asmExpr->inout;786 asmExpr->get_inout()->accept( *visitor ); 789 787 output << " ] "; 790 788 } // if 791 asmExpr-> constraint->accept( *visitor );789 asmExpr->get_constraint()->accept( *visitor ); 792 790 output << " ( "; 793 asmExpr-> operand->accept( *visitor );791 asmExpr->get_operand()->accept( *visitor ); 794 792 output << " )"; 795 793 } … … 1009 1007 case BranchStmt::FallThroughDefault: 1010 1008 assertf( ! options.genC, "fallthru should not reach code generation." ); 1011 output << "fallthru";1009 output << "fallthru"; 1012 1010 break; 1013 1011 } // switch … … 1033 1031 1034 1032 output << ((throwStmt->get_kind() == ThrowStmt::Terminate) ? 1035 "throw" : "throwResume");1033 "throw" : "throwResume"); 1036 1034 if (throwStmt->get_expr()) { 1037 1035 output << " "; … … 1048 1046 1049 1047 output << ((stmt->get_kind() == CatchStmt::Terminate) ? 1050 "catch" : "catchResume");1048 "catch" : "catchResume"); 1051 1049 output << "( "; 1052 1050 stmt->decl->accept( *visitor ); … … 1185 1183 1186 1184 std::string genName( DeclarationWithType * decl ) { 1187 const OperatorInfo * opInfo = operatorLookup( decl->get_name() );1188 if ( op Info) {1189 return opInfo ->outputName;1185 CodeGen::OperatorInfo opInfo; 1186 if ( operatorLookup( decl->get_name(), opInfo ) ) { 1187 return opInfo.outputName; 1190 1188 } else { 1191 1189 return decl->get_name(); -
src/CodeGen/CodeGenerator.h
r3d5701e r9fb8f01 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sun Feb 16 03:58:31 202013 // Update Count : 6211 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue Apr 30 12:01:00 2019 13 // Update Count : 57 14 14 // 15 15 … … 29 29 namespace CodeGen { 30 30 struct CodeGenerator : public WithShortCircuiting, public WithGuards, public WithVisitorRef<CodeGenerator> { 31 static int tabsize;31 static int tabsize; 32 32 33 33 CodeGenerator( std::ostream &os, bool pretty = false, bool genC = false, bool lineMarks = false, bool printExprTypes = false ); … … 104 104 void postvisit( AsmStmt * ); 105 105 void postvisit( DirectiveStmt * ); 106 void postvisit( AsmDecl * ); // special: statement in declaration context106 void postvisit( AsmDecl * ); // special: statement in declaration context 107 107 void postvisit( IfStmt * ); 108 108 void postvisit( SwitchStmt * ); … … 147 147 LabelPrinter printLabels; 148 148 Options options; 149 public:149 public: 150 150 LineEnder endl; 151 private:151 private: 152 152 153 153 CodeLocation currentLocation; … … 162 162 template< class Iterator > 163 163 void CodeGenerator::genCommaList( Iterator begin, Iterator end ) { 164 if ( begin == end ) return;164 if ( begin == end ) return; 165 165 for ( ;; ) { 166 166 (*begin++)->accept( *visitor ); 167 if ( begin == end ) break;167 if ( begin == end ) break; 168 168 output << ", "; // separator 169 169 } // for -
src/CodeGen/FixMain.h
r3d5701e r9fb8f01 10 10 // Created On : Thr Jan 12 14:11:09 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Feb 16 03:24:32 202013 // Update Count : 512 // Last Modified On : Fri Jul 21 22:16:59 2017 13 // Update Count : 1 14 14 // 15 15 … … 19 19 #include <memory> 20 20 21 #include " SynTree/LinkageSpec.h"21 #include "Parser/LinkageSpec.h" 22 22 23 23 class FunctionDecl; … … 42 42 static std::unique_ptr<FunctionDecl> main_signature; 43 43 }; 44 } // namespace CodeGen44 }; -
src/CodeGen/FixNames.cc
r3d5701e r9fb8f01 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Dec 13 23:39:14 201913 // Update Count : 2 111 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Jun 28 15:26:00 2017 13 // Update Count : 20 14 14 // 15 15 … … 22 22 #include "Common/SemanticError.h" // for SemanticError 23 23 #include "FixMain.h" // for FixMain 24 #include "Parser/LinkageSpec.h" // for Cforall, isMangled 24 25 #include "SymTab/Mangler.h" // for Mangler 25 #include "SynTree/LinkageSpec.h" // for Cforall, isMangled26 26 #include "SynTree/Constant.h" // for Constant 27 27 #include "SynTree/Declaration.h" // for FunctionDecl, ObjectDecl, Declarat... -
src/CodeGen/GenType.cc
r3d5701e r9fb8f01 335 335 typeString = "_Atomic " + typeString; 336 336 } // if 337 if ( type->get_lvalue() && ! options.genC ) { 338 // when not generating C code, print lvalue for debugging. 339 typeString = "lvalue " + typeString; 340 } 337 341 } 338 342 } // namespace CodeGen -
src/CodeGen/GenType.h
r3d5701e r9fb8f01 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sun Feb 16 04:11:40 202013 // Update Count : 511 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue Apr 30 11:47:00 2019 13 // Update Count : 3 14 14 // 15 15 … … 25 25 std::string genType( Type *type, const std::string &baseString, const Options &options ); 26 26 std::string genType( Type *type, const std::string &baseString, bool pretty = false, bool genC = false, bool lineMarks = false ); 27 std::string genPrettyType( Type * type, const std::string & baseString );27 std::string genPrettyType( Type * type, const std::string & baseString ); 28 28 } // namespace CodeGen 29 29 -
src/CodeGen/Generate.cc
r3d5701e r9fb8f01 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sun Feb 16 03:01:51 202013 // Update Count : 911 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Aug 18 15:39:00 2017 13 // Update Count : 7 14 14 // 15 15 #include "Generate.h" … … 22 22 #include "GenType.h" // for genPrettyType 23 23 #include "Common/PassVisitor.h" // for PassVisitor 24 #include " SynTree/LinkageSpec.h"// for isBuiltin, isGeneratable24 #include "Parser/LinkageSpec.h" // for isBuiltin, isGeneratable 25 25 #include "SynTree/BaseSyntaxNode.h" // for BaseSyntaxNode 26 26 #include "SynTree/Declaration.h" // for Declaration … … 64 64 void generate( BaseSyntaxNode * node, std::ostream & os ) { 65 65 if ( Type * type = dynamic_cast< Type * >( node ) ) { 66 os << genPrettyType( type, "" );66 os << CodeGen::genPrettyType( type, "" ); 67 67 } else { 68 68 PassVisitor<CodeGenerator> cgv( os, true, false, false, false ); -
src/CodeGen/OperatorTable.cc
r3d5701e r9fb8f01 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 18 15:55:01 202013 // Update Count : 5512 // Last Modified On : Sat Jul 15 17:12:22 2017 13 // Update Count : 15 14 14 // 15 15 … … 17 17 #include <map> // for map, _Rb_tree_const_iterator, map<>::const_iterator 18 18 #include <utility> // for pair 19 using namespace std;20 19 21 20 #include "OperatorTable.h" … … 23 22 24 23 namespace CodeGen { 25 const OperatorInfo CodeGen::tableValues[] ={26 // inputName symbol outputName friendlyName type27 { "?[?]", "", "_operator_index", "Index", OT_INDEX},28 { "?{}", "=", "_constructor", "Constructor", OT_CTOR},29 { "^?{}", "", "_destructor", "Destructor", OT_DTOR},30 { "?()", "", "_operator_call", "Call Operator", OT_CALL},31 { "?++", "++", "_operator_postincr", "Postfix Increment", OT_POSTFIXASSIGN},32 { "?--", "--", "_operator_postdecr", "Postfix Decrement", OT_POSTFIXASSIGN},33 { "*?", "*", "_operator_deref", "Dereference", OT_PREFIX},34 { "+?", "+", "_operator_unaryplus", "Plus", OT_PREFIX},35 { "-?", "-", "_operator_unaryminus", "Minus", OT_PREFIX},36 { "~?", "~", "_operator_bitnot", "Bitwise Not", OT_PREFIX},37 { "!?", "!", "_operator_lognot", "Logical Not", OT_PREFIX},38 { "++?", "++", "_operator_preincr", "Prefix Increment", OT_PREFIXASSIGN},39 { "--?", "--", "_operator_predecr", "Prefix Decrement", OT_PREFIXASSIGN},40 { "?\\?", "\\", "_operator_exponential", "Exponentiation", OT_INFIX},41 { "?*?", "*", "_operator_multiply", "Multiplication", OT_INFIX},42 { "?/?", "/", "_operator_divide", "Division", OT_INFIX},43 { "?%?", "%", "_operator_modulus", "Modulo", OT_INFIX},44 { "?+?", "+", "_operator_add", "Addition", OT_INFIX},45 { "?-?", "-", "_operator_subtract", "Substraction", OT_INFIX},46 { "?<<?", "<<", "_operator_shiftleft", "Shift Left", OT_INFIX},47 { "?>>?", ">>", "_operator_shiftright", "Shift Right", OT_INFIX},48 { "?<?", "<", "_operator_less", "Less-than", OT_INFIX},49 { "?>?", ">", "_operator_greater", "Greater-than", OT_INFIX},50 { "?<=?", "<=", "_operator_lessequal", "Less-than-or-Equal", OT_INFIX},51 { "?>=?", ">=", "_operator_greaterequal", "Greater-than-or-Equal", OT_INFIX},52 { "?==?", "==", "_operator_equal", "Equality", OT_INFIX},53 { "?!=?", "!=", "_operator_notequal", "Not-Equal", OT_INFIX},54 { "?&?", "&", "_operator_bitand", "Bitwise And", OT_INFIX},55 { "?^?", "^", "_operator_bitxor", "Bitwise Xor", OT_INFIX},56 { "?|?", "|", "_operator_bitor", "Bitwise Or", OT_INFIX},57 { "?=?", "=", "_operator_assign", "Assignment", OT_INFIXASSIGN},58 { "?\\=?", "\\=", "_operator_expassign", "Exponentiation Assignment", OT_INFIXASSIGN},59 { "?*=?", "*=", "_operator_multassign", "Multiplication Assignment", OT_INFIXASSIGN},60 { "?/=?", "/=", "_operator_divassign", "Division Assignment", OT_INFIXASSIGN},61 { "?%=?", "%=", "_operator_modassign", "Modulo Assignment", OT_INFIXASSIGN},62 { "?+=?", "+=", "_operator_addassign", "Addition Assignment", OT_INFIXASSIGN},63 { "?-=?", "-=", "_operator_subassign", "Substrction Assignment", OT_INFIXASSIGN},64 { "?<<=?", "<<=", "_operator_shiftleftassign", "Shift Left Assignment", OT_INFIXASSIGN},65 { "?>>=?", ">>=", "_operator_shiftrightassign", "Shift Right Assignment", OT_INFIXASSIGN},66 { "?&=?", "&=", "_operator_bitandassign", "Bitwise And Assignment", OT_INFIXASSIGN},67 { "?^=?", "^=", "_operator_bitxorassign", "Bitwise Xor Assignment", OT_INFIXASSIGN},68 { "?|=?", "|=", "_operator_bitorassign", "Bitwise Or Assignment", OT_INFIXASSIGN},69 }; // tableValues24 namespace { 25 const OperatorInfo tableValues[] = { 26 { "?[?]", "", "_operator_index", OT_INDEX }, 27 { "?{}", "=", "_constructor", OT_CTOR }, 28 { "^?{}", "", "_destructor", OT_DTOR }, 29 { "?()", "", "_operator_call", OT_CALL }, 30 { "?++", "++", "_operator_postincr", OT_POSTFIXASSIGN }, 31 { "?--", "--", "_operator_postdecr", OT_POSTFIXASSIGN }, 32 { "*?", "*", "_operator_deref", OT_PREFIX }, 33 { "+?", "+", "_operator_unaryplus", OT_PREFIX }, 34 { "-?", "-", "_operator_unaryminus", OT_PREFIX }, 35 { "~?", "~", "_operator_bitnot", OT_PREFIX }, 36 { "!?", "!", "_operator_lognot", OT_PREFIX }, 37 { "++?", "++", "_operator_preincr", OT_PREFIXASSIGN }, 38 { "--?", "--", "_operator_predecr", OT_PREFIXASSIGN }, 39 { "?\\?", "\\", "_operator_exponential", OT_INFIX }, 40 { "?*?", "*", "_operator_multiply", OT_INFIX }, 41 { "?/?", "/", "_operator_divide", OT_INFIX }, 42 { "?%?", "%", "_operator_modulus", OT_INFIX }, 43 { "?+?", "+", "_operator_add", OT_INFIX }, 44 { "?-?", "-", "_operator_subtract", OT_INFIX }, 45 { "?<<?", "<<", "_operator_shiftleft", OT_INFIX }, 46 { "?>>?", ">>", "_operator_shiftright", OT_INFIX }, 47 { "?<?", "<", "_operator_less", OT_INFIX }, 48 { "?>?", ">", "_operator_greater", OT_INFIX }, 49 { "?<=?", "<=", "_operator_lessequal", OT_INFIX }, 50 { "?>=?", ">=", "_operator_greaterequal", OT_INFIX }, 51 { "?==?", "==", "_operator_equal", OT_INFIX }, 52 { "?!=?", "!=", "_operator_notequal", OT_INFIX }, 53 { "?&?", "&", "_operator_bitand", OT_INFIX }, 54 { "?^?", "^", "_operator_bitxor", OT_INFIX }, 55 { "?|?", "|", "_operator_bitor", OT_INFIX }, 56 { "?=?", "=", "_operator_assign", OT_INFIXASSIGN }, 57 { "?\\=?", "\\=", "_operator_expassign", OT_INFIXASSIGN }, 58 { "?*=?", "*=", "_operator_multassign", OT_INFIXASSIGN }, 59 { "?/=?", "/=", "_operator_divassign", OT_INFIXASSIGN }, 60 { "?%=?", "%=", "_operator_modassign", OT_INFIXASSIGN }, 61 { "?+=?", "+=", "_operator_addassign", OT_INFIXASSIGN }, 62 { "?-=?", "-=", "_operator_subassign", OT_INFIXASSIGN }, 63 { "?<<=?", "<<=", "_operator_shiftleftassign", OT_INFIXASSIGN }, 64 { "?>>=?", ">>=", "_operator_shiftrightassign", OT_INFIXASSIGN }, 65 { "?&=?", "&=", "_operator_bitandassign", OT_INFIXASSIGN }, 66 { "?^=?", "^=", "_operator_bitxorassign", OT_INFIXASSIGN }, 67 { "?|=?", "|=", "_operator_bitorassign", OT_INFIXASSIGN }, 68 }; 70 69 71 std::map< std::string, OperatorInfo > CodeGen::table;70 const int numOps = sizeof( tableValues ) / sizeof( OperatorInfo ); 72 71 73 CodeGen::CodeGen() { 74 enum { numOps = sizeof( tableValues ) / sizeof( OperatorInfo ) }; 75 for ( int i = 0; i < numOps; i += 1 ) { 76 table[ tableValues[i].inputName ] = tableValues[i]; 77 } // for 72 std::map< std::string, OperatorInfo > table; 73 74 void initialize() { 75 for ( int i = 0; i < numOps; ++i ) { 76 table[ tableValues[i].inputName ] = tableValues[i]; 77 } // for 78 } 79 } // namespace 80 81 bool operatorLookup( const std::string & funcName, OperatorInfo & info ) { 82 static bool init = false; 83 if ( ! init ) { 84 initialize(); 85 } // if 86 87 std::map< std::string, OperatorInfo >::const_iterator i = table.find( funcName ); 88 if ( i == table.end() ) { 89 if ( isPrefix( funcName, "?`" ) ) { 90 // handle literal suffixes, which are user-defined postfix operators 91 info.inputName = funcName; 92 info.symbol = funcName.substr(2); 93 info.outputName = toString( "__operator_literal_", info.symbol ); 94 info.type = OT_POSTFIX; 95 return true; 96 } 97 return false; 98 } else { 99 info = i->second; 100 return true; 101 } // if 78 102 } 79 103 80 const OperatorInfo * operatorLookup( const string & funcName ) { 81 if ( funcName.find_first_of( "?^*+-!", 0, 1 ) == string::npos ) return nullptr; // prefilter 82 const OperatorInfo * ret = &CodeGen::table.find( funcName )->second; // must be in the table 83 assert( ret ); 84 return ret; 104 bool isOperator( const std::string & funcName ) { 105 OperatorInfo info; 106 return operatorLookup( funcName, info ); 85 107 } 86 108 87 bool isOperator( const string & funcName ) { 88 return operatorLookup( funcName ) != nullptr; 89 } 90 91 string operatorFriendlyName( const string & funcName ) { 92 const OperatorInfo * info = operatorLookup( funcName ); 93 if ( info ) return info->friendlyName; 94 return ""; 95 } 96 97 bool isConstructor( const string & funcName ) { 98 const OperatorInfo * info = operatorLookup( funcName ); 99 if ( info ) return info->type == OT_CTOR; 109 /// determines if a given function name is one of the operator types between [begin, end) 110 template<typename Iterator> 111 bool isOperatorType( const std::string & funcName, Iterator begin, Iterator end ) { 112 OperatorInfo info; 113 if ( operatorLookup( funcName, info ) ) { 114 return std::find( begin, end, info.type ) != end; 115 } 100 116 return false; 101 117 } 102 118 103 bool isDestructor( const string & funcName ) { 104 const OperatorInfo * info = operatorLookup( funcName ); 105 if ( info ) return info->type == OT_DTOR; 106 return false; 119 bool isConstructor( const std::string & funcName ) { 120 static OperatorType types[] = { OT_CTOR }; 121 return isOperatorType( funcName, std::begin(types), std::end(types) ); 107 122 } 108 123 109 bool isCtorDtor( const string & funcName ) { 110 const OperatorInfo * info = operatorLookup( funcName ); 111 if ( info ) return info->type <= OT_CONSTRUCTOR; 112 return false; 124 bool isDestructor( const std::string & funcName ) { 125 static OperatorType types[] = { OT_DTOR }; 126 return isOperatorType( funcName, std::begin(types), std::end(types) ); 113 127 } 114 128 115 bool isAssignment( const string & funcName ) { 116 const OperatorInfo * info = operatorLookup( funcName ); 117 if ( info ) return info->type > OT_CONSTRUCTOR && info->type <= OT_ASSIGNMENT; 118 return false; 129 bool isAssignment( const std::string & funcName ) { 130 static OperatorType types[] = { OT_PREFIXASSIGN, OT_POSTFIXASSIGN, OT_INFIXASSIGN }; 131 return isOperatorType( funcName, std::begin(types), std::end(types) ); 119 132 } 120 133 121 bool isCtorDtorAssign( const string & funcName ) { 122 const OperatorInfo * info = operatorLookup( funcName ); 123 if ( info ) return info->type <= OT_ASSIGNMENT; 124 return false; 134 bool isCtorDtor( const std::string & funcName ) { 135 static OperatorType types[] = { OT_CTOR, OT_DTOR }; 136 return isOperatorType( funcName, std::begin(types), std::end(types) ); 125 137 } 126 138 127 CodeGen codegen; // initialize singleton package 139 bool isCtorDtorAssign( const std::string & funcName ) { 140 static OperatorType types[] = { OT_CTOR, OT_DTOR, OT_PREFIXASSIGN, OT_POSTFIXASSIGN, OT_INFIXASSIGN }; 141 return isOperatorType( funcName, std::begin(types), std::end(types) ); 142 } 128 143 } // namespace CodeGen 129 144 130 145 // Local Variables: // 131 146 // tab-width: 4 // 147 // mode: c++ // 148 // compile-command: "make install" // 132 149 // End: // -
src/CodeGen/OperatorTable.h
r3d5701e r9fb8f01 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Feb 16 08:13:34 202013 // Update Count : 2612 // Last Modified On : Fri Jul 21 22:17:11 2017 13 // Update Count : 6 14 14 // 15 15 … … 17 17 18 18 #include <string> 19 #include <map>20 19 21 20 namespace CodeGen { 22 21 enum OperatorType { 22 OT_INDEX, 23 23 OT_CTOR, 24 24 OT_DTOR, 25 OT_CONSTRUCTOR = OT_DTOR, 25 OT_CALL, 26 OT_PREFIX, 27 OT_POSTFIX, 28 OT_INFIX, 26 29 OT_PREFIXASSIGN, 27 30 OT_POSTFIXASSIGN, 28 31 OT_INFIXASSIGN, 29 OT_ASSIGNMENT = OT_INFIXASSIGN,30 OT_CALL,31 OT_PREFIX,32 OT_INFIX,33 OT_POSTFIX,34 OT_INDEX,35 32 OT_LABELADDRESS, 36 33 OT_CONSTANT … … 41 38 std::string symbol; 42 39 std::string outputName; 43 std::string friendlyName;44 40 OperatorType type; 45 41 }; 46 42 47 class CodeGen {48 friend const OperatorInfo * operatorLookup( const std::string & funcName );49 50 static const OperatorInfo tableValues[];51 static std::map< std::string, OperatorInfo > table;52 public:53 CodeGen();54 }; // CodeGen55 56 43 bool isOperator( const std::string & funcName ); 57 const OperatorInfo * operatorLookup( const std::string & funcName ); 58 std::string operatorFriendlyName( const std::string & funcName ); 44 bool operatorLookup( const std::string & funcName, OperatorInfo & info ); 59 45 60 46 bool isConstructor( const std::string & ); -
src/CodeGen/Options.h
r3d5701e r9fb8f01 9 9 // Author : Andrew Beach 10 10 // Created On : Tue Apr 30 11:36:00 2019 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sat Feb 15 18:37:06 202013 // Update Count : 311 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr May 2 10:45:00 2019 13 // Update Count : 2 14 14 // 15 15 16 16 #pragma once 17 17 18 struct Options { 19 // External Options: Same thoughout a pass. 20 bool pretty; 21 bool genC; 22 bool lineMarks; 23 bool printExprTypes; 18 namespace CodeGen { 19 struct Options { 20 // External Options: Same thoughout a pass. 21 bool pretty; 22 bool genC; 23 bool lineMarks; 24 bool printExprTypes; 24 25 25 // Internal Options: Changed on some recurisive calls.26 bool anonymousUnused = false;26 // Internal Options: Changed on some recurisive calls. 27 bool anonymousUnused = false; 27 28 28 Options(bool pretty, bool genC, bool lineMarks, bool printExprTypes) :29 pretty(pretty), genC(genC), lineMarks(lineMarks), printExprTypes(printExprTypes)29 Options(bool pretty, bool genC, bool lineMarks, bool printExprTypes) : 30 pretty(pretty), genC(genC), lineMarks(lineMarks), printExprTypes(printExprTypes) 30 31 {} 31 }; 32 }; 33 } // namespace CodeGen 32 34 33 35 // Local Variables: // -
src/CodeGen/module.mk
r3d5701e r9fb8f01 11 11 ## Created On : Mon Jun 1 17:49:17 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Sat Dec 14 07:29:42 201914 ## Update Count : 413 ## Last Modified On : Tue Jun 2 11:17:02 2015 14 ## Update Count : 3 15 15 ############################################################################### 16 16 … … 24 24 CodeGen/OperatorTable.cc 25 25 26 26 27 SRC += $(SRC_CODEGEN) CodeGen/Generate.cc CodeGen/FixNames.cc 27 28 SRCDEMANGLE += $(SRC_CODEGEN) -
src/CodeTools/DeclStats.cc
r3d5701e r9fb8f01 9 9 // Author : Aaron Moss 10 10 // Created On : Wed Jan 31 16:40:00 2016 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Dec 13 23:39:33 201913 // Update Count : 211 // Last Modified By : Aaron Moss 12 // Last Modified On : Wed Jan 31 16:40:00 2016 13 // Update Count : 1 14 14 // 15 15 … … 26 26 #include "Common/VectorMap.h" // for VectorMap 27 27 #include "GenPoly/GenPoly.h" // for hasPolyBase 28 #include " SynTree/LinkageSpec.h"// for ::NoOfSpecs, Spec28 #include "Parser/LinkageSpec.h" // for ::NoOfSpecs, Spec 29 29 #include "SynTree/Declaration.h" // for FunctionDecl, TypeDecl, Declaration 30 30 #include "SynTree/Expression.h" // for UntypedExpr, Expression -
src/CodeTools/ResolvProtoDump.cc
r3d5701e r9fb8f01 9 9 // Author : Aaron Moss 10 10 // Created On : Tue Sep 11 09:04:00 2018 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sat Feb 15 13:50:11 202013 // Update Count : 311 // Last Modified By : Aaron Moss 12 // Last Modified On : Tue Sep 11 09:04:00 2018 13 // Update Count : 1 14 14 // 15 15 … … 182 182 183 183 // replace operator names 184 const CodeGen::OperatorInfo * opInfo = CodeGen::operatorLookup( name );185 if ( opInfo) {184 CodeGen::OperatorInfo info; 185 if ( CodeGen::operatorLookup( name, info ) ) { 186 186 ss << new_prefix(pre, ""); 187 op_name( opInfo->outputName, ss );187 op_name( info.outputName, ss ); 188 188 return; 189 189 } -
src/Common/Debug.h
r3d5701e r9fb8f01 9 9 // Author : Rob Schluntz 10 10 // Created On : Fri Sep 1 11:09:14 2017 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Dec 13 23:39:42 201913 // Update Count : 311 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri Sep 1 11:09:36 2017 13 // Update Count : 2 14 14 // 15 15 … … 21 21 22 22 #include "CodeGen/Generate.h" 23 #include " SynTree/LinkageSpec.h"23 #include "Parser/LinkageSpec.h" 24 24 #include "SynTree/Declaration.h" 25 25 -
src/Common/PassVisitor.impl.h
r3d5701e r9fb8f01 2452 2452 2453 2453 indexerScopedAccept( node->result , *this ); 2454 maybeAccept_impl ( node->inout , *this ); 2454 2455 maybeAccept_impl ( node->constraint, *this ); 2455 2456 maybeAccept_impl ( node->operand , *this ); … … 2463 2464 2464 2465 indexerScopedAccept( node->result , *this ); 2466 maybeAccept_impl ( node->inout , *this ); 2465 2467 maybeAccept_impl ( node->constraint, *this ); 2466 2468 maybeAccept_impl ( node->operand , *this ); … … 2475 2477 indexerScopedMutate( node->env , *this ); 2476 2478 indexerScopedMutate( node->result , *this ); 2479 maybeMutate_impl ( node->inout , *this ); 2477 2480 maybeMutate_impl ( node->constraint, *this ); 2478 2481 maybeMutate_impl ( node->operand , *this ); … … 3302 3305 VISIT_START( node ); 3303 3306 3304 indexerAdd Union( node->name );3307 indexerAddStruct( node->name ); 3305 3308 3306 3309 { … … 3317 3320 VISIT_START( node ); 3318 3321 3319 indexerAdd Union( node->name );3322 indexerAddStruct( node->name ); 3320 3323 3321 3324 { … … 3332 3335 MUTATE_START( node ); 3333 3336 3334 indexerAdd Union( node->name );3337 indexerAddStruct( node->name ); 3335 3338 3336 3339 { -
src/Common/SemanticError.cc
r3d5701e r9fb8f01 149 149 // Helpers 150 150 namespace ErrorHelpers { 151 Colors colors = Colors::Auto;152 153 static inline bool with_colors() {154 return colors == Colors::Auto ? isatty( STDERR_FILENO ) : bool(colors);155 }156 157 151 const std::string & error_str() { 158 static std::string str = with_colors() ? "\e[31merror:\e[39m " : "error: ";152 static std::string str = isatty( STDERR_FILENO ) ? "\e[31merror:\e[39m " : "error: "; 159 153 return str; 160 154 } 161 155 162 156 const std::string & warning_str() { 163 static std::string str = with_colors() ? "\e[95mwarning:\e[39m " : "warning: ";157 static std::string str = isatty( STDERR_FILENO ) ? "\e[95mwarning:\e[39m " : "warning: "; 164 158 return str; 165 159 } 166 160 167 161 const std::string & bold_ttycode() { 168 static std::string str = with_colors() ? "\e[1m" : "";162 static std::string str = isatty( STDERR_FILENO ) ? "\e[1m" : ""; 169 163 return str; 170 164 } 171 165 172 166 const std::string & reset_font_ttycode() { 173 static std::string str = with_colors() ? "\e[0m" : "";167 static std::string str = isatty( STDERR_FILENO ) ? "\e[0m" : ""; 174 168 return str; 175 169 } -
src/Common/SemanticError.h
r3d5701e r9fb8f01 49 49 struct WarningData { 50 50 const char * const name; 51 const char * const message; 51 52 const Severity default_severity; 52 const char * const message;53 53 }; 54 54 55 55 constexpr WarningData WarningFormats[] = { 56 {"self-assign" , Severity::Warn , "self assignment of expression: %s" }, 57 {"reference-conversion" , Severity::Warn , "rvalue to reference conversion of rvalue: %s" }, 58 {"qualifiers-zero_t-one_t", Severity::Warn , "questionable use of type qualifier %s with %s" }, 59 {"aggregate-forward-decl" , Severity::Warn , "forward declaration of nested aggregate: %s" }, 60 {"superfluous-decl" , Severity::Warn , "declaration does not allocate storage: %s" }, 61 {"gcc-attributes" , Severity::Warn , "invalid attribute: %s" }, 62 {"c++-like-copy" , Severity::Warn , "Constructor from reference is not a valid copy constructor" }, 56 {"self-assign" , "self assignment of expression: %s" , Severity::Warn}, 57 {"reference-conversion" , "rvalue to reference conversion of rvalue: %s" , Severity::Warn}, 58 {"qualifiers-zero_t-one_t", "questionable use of type qualifier %s with %s", Severity::Warn}, 59 {"aggregate-forward-decl" , "forward declaration of nested aggregate: %s" , Severity::Warn}, 60 {"superfluous-decl" , "declaration does not allocate storage: %s" , Severity::Warn}, 61 {"gcc-attributes" , "invalid attribute: %s" , Severity::Warn}, 63 62 }; 64 63 … … 70 69 SuperfluousDecl, 71 70 GccAttributes, 72 CppCopy,73 71 NUMBER_OF_WARNINGS, // This MUST be the last warning 74 72 }; … … 99 97 // Helpers 100 98 namespace ErrorHelpers { 101 enum class Colors {102 Never = false,103 Always = true,104 Auto,105 };106 107 extern Colors colors;108 109 99 const std::string & error_str(); 110 100 const std::string & warning_str(); -
src/Common/Stats/Time.h
r3d5701e r9fb8f01 9 9 // Author : Thierry Delisle 10 10 // Created On : Fri Mar 01 15:14:11 2019 11 // Last Modified By : Andrew Beach11 // Last Modified By : 12 12 // Last Modified On : 13 13 // Update Count : … … 41 41 f(); 42 42 } 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 }49 43 # else 50 44 void StartGlobal(); … … 65 59 func(); 66 60 } 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 }74 61 # endif 75 62 } -
src/Common/utility.h
r3d5701e r9fb8f01 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 11 13:00:36 202013 // Update Count : 5012 // Last Modified On : Wed Jul 24 14:28:19 2019 13 // Update Count : 41 14 14 // 15 15 … … 29 29 #include <utility> 30 30 #include <vector> 31 #include <cstring> // memcmp32 31 33 32 #include "Common/Indenter.h" … … 265 264 } 266 265 267 // determines if pref is a prefix of str268 static inline bool isPrefix( const std::string & str, const std::string & pref , unsigned int start = 0) {266 /// determines if `pref` is a prefix of `str` 267 static inline bool isPrefix( const std::string & str, const std::string & pref ) { 269 268 if ( pref.size() > str.size() ) return false; 270 return 0 == memcmp( str.c_str() + start, pref.c_str(), pref.size() );271 // return prefix == full.substr(0, prefix.size()); // for future, requires c++17269 auto its = std::mismatch( pref.begin(), pref.end(), str.begin() ); 270 return its.first == pref.end(); 272 271 } 273 272 -
src/Concurrency/Keywords.cc
r3d5701e r9fb8f01 11 11 // Last Modified By : 12 12 // Last Modified On : 13 // Update Count : 1013 // Update Count : 5 14 14 // 15 15 … … 24 24 #include "CodeGen/OperatorTable.h" // for isConstructor 25 25 #include "InitTweak/InitTweak.h" // for getPointerBase 26 #include " SynTree/LinkageSpec.h"// for Cforall26 #include "Parser/LinkageSpec.h" // for Cforall 27 27 #include "SynTree/Constant.h" // for Constant 28 28 #include "SynTree/Declaration.h" // for StructDecl, FunctionDecl, ObjectDecl … … 53 53 public: 54 54 55 ConcurrentSueKeyword( std::string&& type_name, std::string&& field_name, std::string&& getter_name, std::string&& context_error, bool needs_main, AggregateDecl::Aggregatecast_target ) :55 ConcurrentSueKeyword( std::string&& type_name, std::string&& field_name, std::string&& getter_name, std::string&& context_error, bool needs_main, KeywordCastExpr::Target cast_target ) : 56 56 type_name( type_name ), field_name( field_name ), getter_name( getter_name ), context_error( context_error ), needs_main( needs_main ), cast_target( cast_target ) {} 57 57 … … 59 59 60 60 Declaration * postmutate( StructDecl * decl ); 61 DeclarationWithType * postmutate( FunctionDecl * decl );62 61 63 62 void handle( StructDecl * ); … … 76 75 const std::string context_error; 77 76 bool needs_main; 78 AggregateDecl::Aggregate cast_target; 79 80 StructDecl * type_decl = nullptr; 81 FunctionDecl * dtor_decl = nullptr; 77 KeywordCastExpr::Target cast_target; 78 79 StructDecl* type_decl = nullptr; 82 80 }; 83 81 … … 88 86 // int data; int data; 89 87 // a_struct_t more_data; a_struct_t more_data; 90 // => $thread__thrd_d;88 // => thread_desc __thrd_d; 91 89 // }; }; 92 // static inline $thread* get_thread( MyThread * this ) { return &this->__thrd_d; }90 // static inline thread_desc * get_thread( MyThread * this ) { return &this->__thrd_d; } 93 91 // 94 92 class ThreadKeyword final : public ConcurrentSueKeyword { … … 96 94 97 95 ThreadKeyword() : ConcurrentSueKeyword( 98 " $thread",96 "thread_desc", 99 97 "__thrd", 100 98 "get_thread", 101 "thread keyword requires threads to be in scope, add #include <thread.hfa> \n",99 "thread keyword requires threads to be in scope, add #include <thread.hfa>", 102 100 true, 103 AggregateDecl::Thread101 KeywordCastExpr::Thread 104 102 ) 105 103 {} … … 120 118 // int data; int data; 121 119 // a_struct_t more_data; a_struct_t more_data; 122 // => $coroutine__cor_d;120 // => coroutine_desc __cor_d; 123 121 // }; }; 124 // static inline $coroutine* get_coroutine( MyCoroutine * this ) { return &this->__cor_d; }122 // static inline coroutine_desc * get_coroutine( MyCoroutine * this ) { return &this->__cor_d; } 125 123 // 126 124 class CoroutineKeyword final : public ConcurrentSueKeyword { … … 128 126 129 127 CoroutineKeyword() : ConcurrentSueKeyword( 130 " $coroutine",128 "coroutine_desc", 131 129 "__cor", 132 130 "get_coroutine", 133 "coroutine keyword requires coroutines to be in scope, add #include <coroutine.hfa> \n",131 "coroutine keyword requires coroutines to be in scope, add #include <coroutine.hfa>", 134 132 true, 135 AggregateDecl::Coroutine133 KeywordCastExpr::Coroutine 136 134 ) 137 135 {} … … 152 150 // int data; int data; 153 151 // a_struct_t more_data; a_struct_t more_data; 154 // => $monitor__mon_d;152 // => monitor_desc __mon_d; 155 153 // }; }; 156 // static inline $monitor* get_coroutine( MyMonitor * this ) { return &this->__cor_d; }154 // static inline monitor_desc * get_coroutine( MyMonitor * this ) { return &this->__cor_d; } 157 155 // 158 156 class MonitorKeyword final : public ConcurrentSueKeyword { … … 160 158 161 159 MonitorKeyword() : ConcurrentSueKeyword( 162 " $monitor",160 "monitor_desc", 163 161 "__mon", 164 162 "get_monitor", 165 "monitor keyword requires monitors to be in scope, add #include <monitor.hfa> \n",163 "monitor keyword requires monitors to be in scope, add #include <monitor.hfa>", 166 164 false, 167 AggregateDecl::Monitor165 KeywordCastExpr::Monitor 168 166 ) 169 167 {} … … 182 180 //Handles mutex routines definitions : 183 181 // void foo( A * mutex a, B * mutex b, int i ) { void foo( A * a, B * b, int i ) { 184 // $monitor* __monitors[] = { get_monitor(a), get_monitor(b) };182 // monitor_desc * __monitors[] = { get_monitor(a), get_monitor(b) }; 185 183 // monitor_guard_t __guard = { __monitors, 2 }; 186 184 // /*Some code*/ => /*Some code*/ … … 221 219 //Handles mutex routines definitions : 222 220 // void foo( A * mutex a, B * mutex b, int i ) { void foo( A * a, B * b, int i ) { 223 // $monitor* __monitors[] = { get_monitor(a), get_monitor(b) };221 // monitor_desc * __monitors[] = { get_monitor(a), get_monitor(b) }; 224 222 // monitor_guard_t __guard = { __monitors, 2 }; 225 223 // /*Some code*/ => /*Some code*/ … … 286 284 } 287 285 288 DeclarationWithType * ConcurrentSueKeyword::postmutate( FunctionDecl * decl ) {289 if( !type_decl ) return decl;290 if( !CodeGen::isDestructor( decl->name ) ) return decl;291 292 auto params = decl->type->parameters;293 if( params.size() != 1 ) return decl;294 295 auto type = dynamic_cast<ReferenceType*>( params.front()->get_type() );296 if( !type ) return decl;297 298 auto stype = dynamic_cast<StructInstType*>( type->base );299 if( !stype ) return decl;300 if( stype->baseStruct != type_decl ) return decl;301 302 if( !dtor_decl ) dtor_decl = decl;303 return decl;304 }305 306 286 Expression * ConcurrentSueKeyword::postmutate( KeywordCastExpr * cast ) { 307 287 if ( cast_target == cast->target ) { 308 // convert (thread &)t to ( $thread&)*get_thread(t), etc.288 // convert (thread &)t to (thread_desc &)*get_thread(t), etc. 309 289 if( !type_decl ) SemanticError( cast, context_error ); 310 if( !dtor_decl ) SemanticError( cast, context_error ); 311 assert( cast->result == nullptr ); 312 cast->set_result( new ReferenceType( noQualifiers, new StructInstType( noQualifiers, type_decl ) ) ); 313 cast->concrete_target.field = field_name; 314 cast->concrete_target.getter = getter_name; 290 Expression * arg = cast->arg; 291 cast->arg = nullptr; 292 delete cast; 293 return new CastExpr( 294 UntypedExpr::createDeref( 295 new UntypedExpr( new NameExpr( getter_name ), { arg } ) 296 ), 297 new ReferenceType( 298 noQualifiers, 299 new StructInstType( noQualifiers, type_decl ) ) 300 ); 315 301 } 316 302 return cast; … … 322 308 323 309 if( !type_decl ) SemanticError( decl, context_error ); 324 if( !dtor_decl ) SemanticError( decl, context_error );325 310 326 311 FunctionDecl * func = forwardDeclare( decl ); … … 377 362 get_type, 378 363 nullptr, 379 { new Attribute("const") },364 noAttributes, 380 365 Type::Inline 381 366 ); … … 516 501 void MutexKeyword::postvisit(StructDecl* decl) { 517 502 518 if( decl->name == " $monitor" && decl->body ) {503 if( decl->name == "monitor_desc" && decl->body ) { 519 504 assert( !monitor_decl ); 520 505 monitor_decl = decl; … … 612 597 ); 613 598 614 // $monitor* __monitors[] = { get_monitor(a), get_monitor(b) };599 //monitor_desc * __monitors[] = { get_monitor(a), get_monitor(b) }; 615 600 body->push_front( new DeclStmt( monitors) ); 616 601 } … … 673 658 ); 674 659 675 // $monitor* __monitors[] = { get_monitor(a), get_monitor(b) };660 //monitor_desc * __monitors[] = { get_monitor(a), get_monitor(b) }; 676 661 body->push_front( new DeclStmt( monitors) ); 677 662 } … … 681 666 //============================================================================================= 682 667 void ThreadStarter::previsit( StructDecl * decl ) { 683 if( decl->name == " $thread" && decl->body ) {668 if( decl->name == "thread_desc" && decl->body ) { 684 669 assert( !thread_decl ); 685 670 thread_decl = decl; … … 716 701 new UntypedExpr( 717 702 new NameExpr( "__thrd_start" ), 718 { new VariableExpr( param ) , new NameExpr("main")}703 { new VariableExpr( param ) } 719 704 ) 720 705 ) -
src/Concurrency/Waitfor.cc
r3d5701e r9fb8f01 11 11 // Last Modified By : 12 12 // Last Modified On : 13 // Update Count : 1213 // Update Count : 7 14 14 // 15 15 … … 23 23 #include "Common/PassVisitor.h" // for PassVisitor 24 24 #include "Common/SemanticError.h" // for SemanticError 25 #include "Common/UniqueName.h" // for UniqueName26 25 #include "Common/utility.h" // for deleteAll, map_range 27 26 #include "CodeGen/OperatorTable.h" // for isConstructor 28 27 #include "InitTweak/InitTweak.h" // for getPointerBase 28 #include "Parser/LinkageSpec.h" // for Cforall 29 29 #include "ResolvExpr/Resolver.h" // for findVoidExpression 30 #include "SynTree/LinkageSpec.h" // for Cforall31 30 #include "SynTree/Constant.h" // for Constant 32 31 #include "SynTree/Declaration.h" // for StructDecl, FunctionDecl, ObjectDecl … … 42 41 void foo() { 43 42 while( true ) { 44 when( a < 1 ) waitfor( f :a ) { bar(); }43 when( a < 1 ) waitfor( f, a ) { bar(); } 45 44 or timeout( swagl() ); 46 or waitfor( g :a ) { baz(); }47 or waitfor( ^?{} :a ) { break; }45 or waitfor( g, a ) { baz(); } 46 or waitfor( ^?{}, a ) { break; } 48 47 or waitfor( ^?{} ) { break; } 49 48 } … … 244 243 decl_mask = decl; 245 244 } 246 else if( decl->name == " $monitor" ) {245 else if( decl->name == "monitor_desc" ) { 247 246 assert( !decl_monitor ); 248 247 decl_monitor = decl; -
src/ControlStruct/ExceptTranslate.cc
r3d5701e r9fb8f01 10 10 // Created On : Wed Jun 14 16:49:00 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 13 23:40:15201913 // Update Count : 1 212 // Last Modified On : Wed Feb 13 18:15:29 2019 13 // Update Count : 11 14 14 // 15 15 … … 24 24 #include "Common/SemanticError.h" // for SemanticError 25 25 #include "Common/utility.h" // for CodeLocation 26 #include " SynTree/LinkageSpec.h"// for Cforall26 #include "Parser/LinkageSpec.h" // for Cforall 27 27 #include "SynTree/Attribute.h" // for Attribute 28 28 #include "SynTree/Constant.h" // for Constant -
src/ControlStruct/LabelFixer.cc
r3d5701e r9fb8f01 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Tue Jan 21 10:32:00 202013 // Update Count : 1 6011 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 11 22:26:02 2019 13 // Update Count : 159 14 14 // 15 15 … … 21 21 #include "ControlStruct/LabelGenerator.h" // for LabelGenerator 22 22 #include "LabelFixer.h" 23 #include "MLEMutator.h" // for M ultiLevelExitMutator23 #include "MLEMutator.h" // for MLEMutator 24 24 #include "SynTree/Declaration.h" // for FunctionDecl 25 25 #include "SynTree/Expression.h" // for NameExpr, Expression, Unty... … … 44 44 45 45 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 ); 49 48 } 50 49 … … 76 75 77 76 78 // Sets the definition of the labelTable entry to be the provided statement for every label in79 // 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 80 79 Label LabelFixer::setLabelsDef( std::list< Label > & llabel, Statement * definition ) { 81 80 assert( definition != 0 ); 82 81 assert( llabel.size() > 0 ); 82 83 Entry * e = new Entry( definition ); 83 84 84 85 for ( std::list< Label >::iterator i = llabel.begin(); i != llabel.end(); i++ ) { … … 86 87 l.set_statement( definition ); // attach statement to the label to be used later 87 88 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 90 90 // undefined and unused until now, add an entry 91 labelTable[ l ] = new Entry( definition );91 labelTable[ l ] = e; 92 92 } else if ( labelTable[ l ]->defined() ) { 93 93 // 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 { 97 96 // used previously, but undefined until now -> link with this entry 98 // Question: Is changing objects important?99 97 delete labelTable[ l ]; 100 labelTable[ l ] = new Entry( definition );98 labelTable[ l ] = e; 101 99 } // if 102 100 } // for 103 101 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 106 103 return labelTable[ llabel.front() ]->get_label(); 107 104 } -
src/ControlStruct/MLEMutator.cc
r3d5701e r9fb8f01 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Wed Jan 22 11:50:00 202013 // Update Count : 2 2311 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 8 17:08:25 2018 13 // Update Count : 219 14 14 // 15 15 … … 33 33 34 34 namespace ControlStruct { 35 M ultiLevelExitMutator::~MultiLevelExitMutator() {35 MLEMutator::~MLEMutator() { 36 36 delete targetTable; 37 37 targetTable = 0; 38 38 } 39 39 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 ); } 61 47 } // namespace 62 63 void MultiLevelExitMutator::premutate( FunctionDecl * ) {64 visit_children = false;65 }66 48 67 49 // break labels have to come after the statement they break out of, so mutate a statement, then if they inform us 68 50 // through the breakLabel field tha they need a place to jump to on a break statement, add the break label to the 69 51 // body of statements 70 void M ultiLevelExitMutator::fixBlock( std::list< Statement * > &kids, bool caseClause ) {52 void MLEMutator::fixBlock( std::list< Statement * > &kids, bool caseClause ) { 71 53 SemanticErrorException errors; 72 54 … … 99 81 } 100 82 101 void M ultiLevelExitMutator::premutate( CompoundStmt *cmpndStmt ) {83 void MLEMutator::premutate( CompoundStmt *cmpndStmt ) { 102 84 visit_children = false; 103 85 bool labeledBlock = !(cmpndStmt->labels.empty()); … … 136 118 } 137 119 } 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 ) { 145 125 std::string originalTarget = branchStmt->originalTarget; 146 126 … … 250 230 } 251 231 252 Statement *MultiLevelExitMutator::mutateLoop( Statement *bodyLoop, Entry &e ) { 232 Statement *MLEMutator::mutateLoop( Statement *bodyLoop, Entry &e ) { 233 // ensure loop body is a block 234 CompoundStmt *newBody; 235 if ( ! (newBody = dynamic_cast<CompoundStmt *>( bodyLoop )) ) { 236 newBody = new CompoundStmt(); 237 newBody->get_kids().push_back( bodyLoop ); 238 } // if 239 253 240 // only generate these when needed 254 if( !e.isContUsed() && !e.isBreakUsed() ) return bodyLoop;255 256 // ensure loop body is a block257 CompoundStmt * newBody = new CompoundStmt();258 newBody->get_kids().push_back( bodyLoop );259 241 260 242 if ( e.isContUsed() ) { … … 273 255 274 256 template< typename LoopClass > 275 void M ultiLevelExitMutator::prehandleLoopStmt( LoopClass * loopStmt ) {257 void MLEMutator::prehandleLoopStmt( LoopClass * loopStmt ) { 276 258 // remember this as the most recent enclosing loop, then mutate the body of the loop -- this will determine 277 259 // whether brkLabel and contLabel are used with branch statements and will recursively do the same to nested … … 284 266 285 267 template< typename LoopClass > 286 Statement * M ultiLevelExitMutator::posthandleLoopStmt( LoopClass * loopStmt ) {268 Statement * MLEMutator::posthandleLoopStmt( LoopClass * loopStmt ) { 287 269 assert( ! enclosingControlStructures.empty() ); 288 270 Entry &e = enclosingControlStructures.back(); … … 295 277 } 296 278 297 void M ultiLevelExitMutator::premutate( WhileStmt * whileStmt ) {279 void MLEMutator::premutate( WhileStmt * whileStmt ) { 298 280 return prehandleLoopStmt( whileStmt ); 299 281 } 300 282 301 void M ultiLevelExitMutator::premutate( ForStmt * forStmt ) {283 void MLEMutator::premutate( ForStmt * forStmt ) { 302 284 return prehandleLoopStmt( forStmt ); 303 285 } 304 286 305 Statement * M ultiLevelExitMutator::postmutate( WhileStmt * whileStmt ) {287 Statement * MLEMutator::postmutate( WhileStmt * whileStmt ) { 306 288 return posthandleLoopStmt( whileStmt ); 307 289 } 308 290 309 Statement * M ultiLevelExitMutator::postmutate( ForStmt * forStmt ) {291 Statement * MLEMutator::postmutate( ForStmt * forStmt ) { 310 292 return posthandleLoopStmt( forStmt ); 311 293 } 312 294 313 void M ultiLevelExitMutator::premutate( IfStmt * ifStmt ) {295 void MLEMutator::premutate( IfStmt * ifStmt ) { 314 296 // generate a label for breaking out of a labeled if 315 297 bool labeledBlock = !(ifStmt->get_labels().empty()); … … 321 303 } 322 304 323 Statement * M ultiLevelExitMutator::postmutate( IfStmt * ifStmt ) {305 Statement * MLEMutator::postmutate( IfStmt * ifStmt ) { 324 306 bool labeledBlock = !(ifStmt->get_labels().empty()); 325 307 if ( labeledBlock ) { … … 331 313 } 332 314 333 void MultiLevelExitMutator::premutate( TryStmt * tryStmt ) { 334 // generate a label for breaking out of a labeled if 335 bool labeledBlock = !(tryStmt->get_labels().empty()); 336 if ( labeledBlock ) { 337 Label brkLabel = generator->newLabel("blockBreak", tryStmt); 338 enclosingControlStructures.push_back( Entry( tryStmt, brkLabel ) ); 339 GuardAction( [this]() { enclosingControlStructures.pop_back(); } ); 340 } // if 341 } 342 343 Statement * MultiLevelExitMutator::postmutate( TryStmt * tryStmt ) { 344 bool labeledBlock = !(tryStmt->get_labels().empty()); 345 if ( labeledBlock ) { 346 if ( ! enclosingControlStructures.back().useBreakExit().empty() ) { 347 set_breakLabel( enclosingControlStructures.back().useBreakExit() ); 348 } // if 349 } // if 350 return tryStmt; 351 } 352 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 ) { 315 void MLEMutator::premutate( CaseStmt *caseStmt ) { 369 316 visit_children = false; 370 317 … … 405 352 } 406 353 407 void M ultiLevelExitMutator::premutate( SwitchStmt *switchStmt ) {354 void MLEMutator::premutate( SwitchStmt *switchStmt ) { 408 355 // generate a label for breaking out of a labeled switch 409 356 Label brkLabel = generator->newLabel("switchBreak", switchStmt); … … 431 378 } 432 379 433 Statement * M ultiLevelExitMutator::postmutate( SwitchStmt * switchStmt ) {380 Statement * MLEMutator::postmutate( SwitchStmt * switchStmt ) { 434 381 Entry &e = enclosingControlStructures.back(); 435 382 assert ( e == switchStmt ); -
src/ControlStruct/MLEMutator.h
r3d5701e r9fb8f01 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Wed Jan 22 11:50:00 202013 // Update Count : 4 811 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 8 16:42:32 2018 13 // Update Count : 41 14 14 // 15 15 … … 30 30 class LabelGenerator; 31 31 32 class MultiLevelExitMutator : public WithVisitorRef<MultiLevelExitMutator>, 33 public WithShortCircuiting, public WithGuards { 32 class MLEMutator : public WithVisitorRef<MLEMutator>, public WithShortCircuiting, public WithGuards { 34 33 public: 35 34 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(); 41 37 42 38 void premutate( CompoundStmt *cmpndStmt ); … … 51 47 void premutate( SwitchStmt *switchStmt ); 52 48 Statement * postmutate( SwitchStmt *switchStmt ); 53 void premutate( ReturnStmt *returnStmt );54 void premutate( TryStmt *tryStmt );55 Statement * postmutate( TryStmt *tryStmt );56 void premutate( FinallyStmt *finallyStmt );57 49 58 50 Statement *mutateLoop( Statement *bodyLoop, Entry &e ); … … 81 73 explicit Entry( SwitchStmt *stmt, Label breakExit, Label fallDefaultExit ) : 82 74 stmt( stmt ), breakExit( breakExit ), fallDefaultExit( fallDefaultExit ) {} 83 84 explicit Entry( TryStmt *stmt, Label breakExit ) :85 stmt( stmt ), breakExit( breakExit ) {}86 75 87 76 bool operator==( const Statement *other ) { return stmt == other; } … … 116 105 Label breakLabel; 117 106 LabelGenerator *generator; 118 bool inFinally = false;119 107 120 108 template< typename LoopClass > -
src/ControlStruct/Mutate.cc
r3d5701e r9fb8f01 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Feb 16 03:22:07 202013 // Update Count : 1012 // Last Modified On : Thu Aug 4 11:39:08 2016 13 // Update Count : 9 14 14 // 15 15 … … 37 37 mutateAll( translationUnit, formut ); 38 38 } 39 } // namespace Co ntrolStruct39 } // namespace CodeGen 40 40 41 41 // Local Variables: // -
src/GenPoly/Box.cc
r3d5701e r9fb8f01 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 13 23:40:34 201913 // Update Count : 34 712 // Last Modified On : Wed Jun 21 15:49:59 2017 13 // Update Count : 346 14 14 // 15 15 … … 37 37 #include "InitTweak/InitTweak.h" // for getFunctionName, isAssignment 38 38 #include "Lvalue.h" // for generalizedLvalue 39 #include "Parser/LinkageSpec.h" // for C, Spec, Cforall, Intrinsic 39 40 #include "ResolvExpr/TypeEnvironment.h" // for EqvClass 40 41 #include "ResolvExpr/typeops.h" // for typesCompatible … … 43 44 #include "SymTab/Indexer.h" // for Indexer 44 45 #include "SymTab/Mangler.h" // for Mangler 45 #include "SynTree/LinkageSpec.h" // for C, Spec, Cforall, Intrinsic46 46 #include "SynTree/Attribute.h" // for Attribute 47 47 #include "SynTree/Constant.h" // for Constant … … 837 837 deref->args.push_back( new CastExpr( new VariableExpr( param ), new PointerType( Type::Qualifiers(), arg->get_type()->clone() ) ) ); 838 838 deref->result = arg->get_type()->clone(); 839 deref->result->set_lvalue( true ); 839 840 return deref; 840 841 } // if -
src/GenPoly/Lvalue.cc
r3d5701e r9fb8f01 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 13 23:14:38 201913 // Update Count : 712 // Last Modified On : Fri Mar 17 09:11:18 2017 13 // Update Count : 5 14 14 // 15 15 … … 17 17 #include <string> // for string 18 18 19 #include "Common/UniqueName.h"20 19 #include "Common/PassVisitor.h" 21 20 #include "GenPoly.h" // for isPolyType … … 23 22 24 23 #include "InitTweak/InitTweak.h" 24 #include "Parser/LinkageSpec.h" // for Spec, isBuiltin, Intrinsic 25 25 #include "ResolvExpr/TypeEnvironment.h" // for AssertionSet, OpenVarSet 26 26 #include "ResolvExpr/Unify.h" // for unify 27 27 #include "ResolvExpr/typeops.h" 28 28 #include "SymTab/Indexer.h" // for Indexer 29 #include "SynTree/LinkageSpec.h" // for Spec, isBuiltin, Intrinsic30 29 #include "SynTree/Declaration.h" // for Declaration, FunctionDecl 31 30 #include "SynTree/Expression.h" // for Expression, ConditionalExpr … … 55 54 delete ret->result; 56 55 ret->result = base->clone(); 56 ret->result->set_lvalue( true ); 57 57 return ret; 58 58 } else { … … 61 61 } 62 62 63 struct ReferenceConversions final : public WithStmtsToAdd , public WithGuards{63 struct ReferenceConversions final : public WithStmtsToAdd { 64 64 Expression * postmutate( CastExpr * castExpr ); 65 65 Expression * postmutate( AddressExpr * addrExpr ); … … 72 72 73 73 struct FixIntrinsicResult final : public WithGuards { 74 enum {75 NoSkip,76 Skip,77 SkipInProgress78 } skip = NoSkip;79 80 void premutate( AsmExpr * ) { GuardValue( skip ); skip = Skip; }81 void premutate( ApplicationExpr * ) { GuardValue( skip ); skip = (skip == Skip) ? SkipInProgress : NoSkip; }82 83 84 74 Expression * postmutate( ApplicationExpr * appExpr ); 85 75 void premutate( FunctionDecl * funcDecl ); … … 173 163 174 164 Expression * FixIntrinsicResult::postmutate( ApplicationExpr * appExpr ) { 175 if ( skip != SkipInProgress &&isIntrinsicReference( appExpr ) ) {165 if ( isIntrinsicReference( appExpr ) ) { 176 166 // eliminate reference types from intrinsic applications - now they return lvalues 177 167 ReferenceType * result = strict_dynamic_cast< ReferenceType * >( appExpr->result ); 178 168 appExpr->result = result->base->clone(); 169 appExpr->result->set_lvalue( true ); 179 170 if ( ! inIntrinsic ) { 180 171 // when not in an intrinsic function, add a cast to … … 445 436 delete ret->result; 446 437 ret->result = castExpr->result; 447 assert( ret->get_lvalue()); // ensure result is lvalue438 ret->result->set_lvalue( true ); // ensure result is lvalue 448 439 castExpr->env = nullptr; 449 440 castExpr->arg = nullptr; -
src/GenPoly/Specialize.cc
r3d5701e r9fb8f01 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 13 23:40:49 201913 // Update Count : 3 212 // Last Modified On : Thu Mar 16 07:53:59 2017 13 // Update Count : 31 14 14 // 15 15 … … 27 27 #include "GenPoly.h" // for getFunctionType 28 28 #include "InitTweak/InitTweak.h" // for isIntrinsicCallExpr 29 #include "Parser/LinkageSpec.h" // for C 29 30 #include "ResolvExpr/FindOpenVars.h" // for findOpenVars 30 31 #include "ResolvExpr/TypeEnvironment.h" // for OpenVarSet, AssertionSet 31 32 #include "Specialize.h" 32 #include "SynTree/LinkageSpec.h" // for C33 33 #include "SynTree/Attribute.h" // for Attribute 34 34 #include "SynTree/Declaration.h" // for FunctionDecl, DeclarationWit... -
src/InitTweak/FixGlobalInit.cc
r3d5701e r9fb8f01 10 10 // Created On : Mon May 04 15:14:56 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 13 23:41:10 201913 // Update Count : 1 912 // Last Modified On : Thu Mar 16 07:53:11 2017 13 // Update Count : 18 14 14 // 15 15 … … 23 23 #include "Common/UniqueName.h" // for UniqueName 24 24 #include "InitTweak.h" // for isIntrinsicSingleArgCallStmt 25 #include " SynTree/LinkageSpec.h"// for C25 #include "Parser/LinkageSpec.h" // for C 26 26 #include "SynTree/Attribute.h" // for Attribute 27 27 #include "SynTree/Constant.h" // for Constant -
src/InitTweak/FixInit.cc
r3d5701e r9fb8f01 10 10 // Created On : Wed Jan 13 16:29:30 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Feb 16 04:17:07 202013 // Update Count : 8212 // Last Modified On : Wed Feb 13 18:15:56 2019 13 // Update Count : 76 14 14 // 15 15 #include "FixInit.h" … … 38 38 #include "GenPoly/GenPoly.h" // for getFunctionType 39 39 #include "InitTweak.h" // for getFunctionName, getCallArg 40 #include "Parser/LinkageSpec.h" // for C, Spec, Cforall, isBuiltin 40 41 #include "ResolvExpr/Resolver.h" // for findVoidExpression 41 42 #include "ResolvExpr/typeops.h" // for typesCompatible … … 43 44 #include "SymTab/Indexer.h" // for Indexer 44 45 #include "SymTab/Mangler.h" // for Mangler 45 #include "SynTree/LinkageSpec.h" // for C, Spec, Cforall, isBuiltin46 46 #include "SynTree/Attribute.h" // for Attribute 47 47 #include "SynTree/Constant.h" // for Constant … … 745 745 } 746 746 747 // to prevent warnings ( '_unq0'may be used uninitialized in this function),747 // to prevent warnings (‘_unq0’ may be used uninitialized in this function), 748 748 // insert an appropriate zero initializer for UniqueExpr temporaries. 749 749 Initializer * makeInit( Type * t ) { -
src/InitTweak/FixInit.h
r3d5701e r9fb8f01 10 10 // Created On : Wed Jan 13 16:29:30 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : S un Feb 16 07:54:50 202013 // Update Count : 812 // Last Modified On : Sat Jul 22 09:31:06 2017 13 // Update Count : 6 14 14 // 15 15 … … 22 22 23 23 namespace InitTweak { 24 /// replace constructor initializers with expression statements and unwrap basic C-style initializers 24 /// replace constructor initializers with expression statements 25 /// and unwrap basic C-style initializers 25 26 void fix( std::list< Declaration * > & translationUnit, bool inLibrary ); 26 27 } // namespace -
src/InitTweak/GenInit.cc
r3d5701e r9fb8f01 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 13 23:15:10 201913 // Update Count : 18 412 // Last Modified On : Fri Mar 17 09:12:36 2017 13 // Update Count : 183 14 14 // 15 15 #include "GenInit.h" … … 34 34 #include "GenPoly/ScopedSet.h" // for ScopedSet, ScopedSet<>::const_iter... 35 35 #include "InitTweak.h" // for isConstExpr, InitExpander, checkIn... 36 #include "Parser/LinkageSpec.h" // for isOverridable, C 36 37 #include "ResolvExpr/Resolver.h" 37 38 #include "SymTab/Autogen.h" // for genImplicitCall 38 39 #include "SymTab/Mangler.h" // for Mangler 39 #include "SynTree/LinkageSpec.h" // for isOverridable, C40 40 #include "SynTree/Declaration.h" // for ObjectDecl, DeclarationWithType 41 41 #include "SynTree/Expression.h" // for VariableExpr, UntypedExpr, Address... -
src/InitTweak/InitTweak.cc
r3d5701e r9fb8f01 10 10 // Created On : Fri May 13 11:26:36 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 13 23:15:52201913 // Update Count : 812 // Last Modified On : Thu Jul 25 22:21:48 2019 13 // Update Count : 7 14 14 // 15 15 … … 33 33 #include "GenPoly/GenPoly.h" // for getFunctionType 34 34 #include "InitTweak.h" 35 #include "Parser/LinkageSpec.h" // for Spec, isBuiltin, Intrinsic 35 36 #include "ResolvExpr/typeops.h" // for typesCompatibleIgnoreQualifiers 36 37 #include "SymTab/Autogen.h" 37 38 #include "SymTab/Indexer.h" // for Indexer 38 #include "SynTree/LinkageSpec.h" // for Spec, isBuiltin, Intrinsic39 39 #include "SynTree/Attribute.h" // for Attribute 40 40 #include "SynTree/Constant.h" // for Constant -
src/MakeLibCfa.cc
r3d5701e r9fb8f01 10 10 // Created On : Sat May 16 10:33:33 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Feb 1 6 03:49:49 202013 // Update Count : 4 512 // Last Modified On : Sun Feb 17 21:08:09 2019 13 // Update Count : 41 14 14 // 15 15 … … 23 23 #include "Common/SemanticError.h" // for SemanticError 24 24 #include "Common/UniqueName.h" // for UniqueName 25 #include " SynTree/LinkageSpec.h"// for Spec, Intrinsic, C25 #include "Parser/LinkageSpec.h" // for Spec, Intrinsic, C 26 26 #include "SynTree/Declaration.h" // for FunctionDecl, ObjectDecl, Declara... 27 27 #include "SynTree/Expression.h" // for NameExpr, UntypedExpr, VariableExpr … … 96 96 97 97 FunctionDecl *funcDecl = origFuncDecl->clone(); 98 const CodeGen::OperatorInfo *opInfo;99 opInfo = CodeGen::operatorLookup( funcDecl->get_name());100 assert( opInfo);98 CodeGen::OperatorInfo opInfo; 99 bool lookResult = CodeGen::operatorLookup( funcDecl->get_name(), opInfo ); 100 assert( lookResult ); 101 101 assert( ! funcDecl->get_statements() ); 102 102 // build a recursive call - this is okay, as the call will actually be codegen'd using operator syntax … … 120 120 121 121 Statement * stmt = nullptr; 122 switch ( opInfo ->type ) {122 switch ( opInfo.type ) { 123 123 case CodeGen::OT_INDEX: 124 124 case CodeGen::OT_CALL: -
src/Makefile.in
r3d5701e r9fb8f01 212 212 SymTab/Indexer.$(OBJEXT) SymTab/Mangler.$(OBJEXT) \ 213 213 SymTab/ManglerCommon.$(OBJEXT) SymTab/Validate.$(OBJEXT) 214 am__objects_7 = SynTree/AddressExpr.$(OBJEXT) \ 215 SynTree/AggregateDecl.$(OBJEXT) \ 216 SynTree/ApplicationExpr.$(OBJEXT) SynTree/ArrayType.$(OBJEXT) \ 217 SynTree/AttrType.$(OBJEXT) SynTree/Attribute.$(OBJEXT) \ 218 SynTree/BasicType.$(OBJEXT) SynTree/CommaExpr.$(OBJEXT) \ 219 SynTree/CompoundStmt.$(OBJEXT) SynTree/Constant.$(OBJEXT) \ 220 SynTree/DeclReplacer.$(OBJEXT) SynTree/DeclStmt.$(OBJEXT) \ 214 am__objects_7 = SynTree/Type.$(OBJEXT) SynTree/VoidType.$(OBJEXT) \ 215 SynTree/BasicType.$(OBJEXT) SynTree/PointerType.$(OBJEXT) \ 216 SynTree/ArrayType.$(OBJEXT) SynTree/ReferenceType.$(OBJEXT) \ 217 SynTree/FunctionType.$(OBJEXT) \ 218 SynTree/ReferenceToType.$(OBJEXT) SynTree/TupleType.$(OBJEXT) \ 219 SynTree/TypeofType.$(OBJEXT) SynTree/AttrType.$(OBJEXT) \ 220 SynTree/VarArgsType.$(OBJEXT) SynTree/ZeroOneType.$(OBJEXT) \ 221 SynTree/Constant.$(OBJEXT) SynTree/Expression.$(OBJEXT) \ 222 SynTree/TupleExpr.$(OBJEXT) SynTree/CommaExpr.$(OBJEXT) \ 223 SynTree/TypeExpr.$(OBJEXT) SynTree/ApplicationExpr.$(OBJEXT) \ 224 SynTree/AddressExpr.$(OBJEXT) SynTree/Statement.$(OBJEXT) \ 225 SynTree/CompoundStmt.$(OBJEXT) SynTree/DeclStmt.$(OBJEXT) \ 221 226 SynTree/Declaration.$(OBJEXT) \ 222 227 SynTree/DeclarationWithType.$(OBJEXT) \ 223 SynTree/Expression.$(OBJEXT) SynTree/FunctionDecl.$(OBJEXT) \ 224 SynTree/FunctionType.$(OBJEXT) SynTree/Initializer.$(OBJEXT) \ 225 SynTree/LinkageSpec.$(OBJEXT) SynTree/NamedTypeDecl.$(OBJEXT) \ 226 SynTree/ObjectDecl.$(OBJEXT) SynTree/PointerType.$(OBJEXT) \ 227 SynTree/ReferenceToType.$(OBJEXT) \ 228 SynTree/ReferenceType.$(OBJEXT) SynTree/Statement.$(OBJEXT) \ 229 SynTree/TupleExpr.$(OBJEXT) SynTree/TupleType.$(OBJEXT) \ 230 SynTree/Type.$(OBJEXT) SynTree/TypeDecl.$(OBJEXT) \ 231 SynTree/TypeExpr.$(OBJEXT) SynTree/TypeSubstitution.$(OBJEXT) \ 232 SynTree/TypeofType.$(OBJEXT) SynTree/VarArgsType.$(OBJEXT) \ 233 SynTree/VoidType.$(OBJEXT) SynTree/ZeroOneType.$(OBJEXT) 228 SynTree/ObjectDecl.$(OBJEXT) SynTree/FunctionDecl.$(OBJEXT) \ 229 SynTree/AggregateDecl.$(OBJEXT) \ 230 SynTree/NamedTypeDecl.$(OBJEXT) SynTree/TypeDecl.$(OBJEXT) \ 231 SynTree/Initializer.$(OBJEXT) \ 232 SynTree/TypeSubstitution.$(OBJEXT) SynTree/Attribute.$(OBJEXT) \ 233 SynTree/DeclReplacer.$(OBJEXT) SynTree/TopLvalue.$(OBJEXT) 234 234 am__objects_8 = CompilationState.$(OBJEXT) $(am__objects_1) \ 235 235 $(am__objects_2) Concurrency/Keywords.$(OBJEXT) \ 236 236 $(am__objects_3) $(am__objects_4) GenPoly/GenPoly.$(OBJEXT) \ 237 237 GenPoly/Lvalue.$(OBJEXT) InitTweak/GenInit.$(OBJEXT) \ 238 InitTweak/InitTweak.$(OBJEXT) $(am__objects_5) \239 $(am__objects_ 6) SymTab/Demangle.$(OBJEXT) $(am__objects_7) \240 Tuples/TupleAssignment.$(OBJEXT) \238 InitTweak/InitTweak.$(OBJEXT) Parser/LinkageSpec.$(OBJEXT) \ 239 $(am__objects_5) $(am__objects_6) SymTab/Demangle.$(OBJEXT) \ 240 $(am__objects_7) Tuples/TupleAssignment.$(OBJEXT) \ 241 241 Tuples/TupleExpansion.$(OBJEXT) Tuples/Explode.$(OBJEXT) \ 242 242 Tuples/Tuples.$(OBJEXT) Validate/HandleAttributes.$(OBJEXT) \ … … 261 261 InitTweak/GenInit.$(OBJEXT) InitTweak/FixInit.$(OBJEXT) \ 262 262 InitTweak/FixGlobalInit.$(OBJEXT) \ 263 InitTweak/InitTweak.$(OBJEXT) Parser/ DeclarationNode.$(OBJEXT) \264 Parser/ ExpressionNode.$(OBJEXT) \265 Parser/ InitializerNode.$(OBJEXT) Parser/ParseNode.$(OBJEXT) \266 Parser/ StatementNode.$(OBJEXT) Parser/TypeData.$(OBJEXT) \267 Parser/ TypedefTable.$(OBJEXT) Parser/lex.$(OBJEXT) \268 Parser/ parser.$(OBJEXT) Parser/parserutility.$(OBJEXT) \263 InitTweak/InitTweak.$(OBJEXT) Parser/parser.$(OBJEXT) \ 264 Parser/lex.$(OBJEXT) Parser/TypedefTable.$(OBJEXT) \ 265 Parser/ParseNode.$(OBJEXT) Parser/DeclarationNode.$(OBJEXT) \ 266 Parser/ExpressionNode.$(OBJEXT) Parser/StatementNode.$(OBJEXT) \ 267 Parser/InitializerNode.$(OBJEXT) Parser/TypeData.$(OBJEXT) \ 268 Parser/LinkageSpec.$(OBJEXT) Parser/parserutility.$(OBJEXT) \ 269 269 $(am__objects_5) ResolvExpr/AlternativePrinter.$(OBJEXT) \ 270 270 $(am__objects_6) $(am__objects_7) \ … … 411 411 CCDEPMODE = @CCDEPMODE@ 412 412 CFACC = @CFACC@ 413 CFACC_INSTALL = @CFACC_INSTALL@414 413 CFACPP = @CFACPP@ 415 414 CFA_BACKEND_CC = @CFA_BACKEND_CC@ … … 442 441 FGREP = @FGREP@ 443 442 GREP = @GREP@ 444 HAS_DISTCC = @HAS_DISTCC@445 443 HOST_FLAGS = @HOST_FLAGS@ 446 444 INSTALL = @INSTALL@ … … 559 557 InitTweak/GenInit.cc InitTweak/FixInit.cc \ 560 558 InitTweak/FixGlobalInit.cc InitTweak/InitTweak.cc \ 561 Parser/ DeclarationNode.cc Parser/ExpressionNode.cc \562 Parser/ InitializerNode.cc Parser/ParseNode.cc \563 Parser/ StatementNode.cc Parser/TypeData.cc \564 Parser/ TypedefTable.cc Parser/lex.ll Parser/parser.yy\565 Parser/ parserutility.cc $(SRC_RESOLVEXPR)\566 ResolvExpr/AlternativePrinter.cc $(SRC_SYMTAB) $(SRC_SYNTREE)\567 Tuples/TupleAssignment.cc Tuples/TupleExpansion.cc \568 Tuples/ Explode.cc Tuples/Tuples.cc \559 Parser/parser.yy Parser/lex.ll Parser/TypedefTable.cc \ 560 Parser/ParseNode.cc Parser/DeclarationNode.cc \ 561 Parser/ExpressionNode.cc Parser/StatementNode.cc \ 562 Parser/InitializerNode.cc Parser/TypeData.cc \ 563 Parser/LinkageSpec.cc Parser/parserutility.cc \ 564 $(SRC_RESOLVEXPR) ResolvExpr/AlternativePrinter.cc \ 565 $(SRC_SYMTAB) $(SRC_SYNTREE) Tuples/TupleAssignment.cc \ 566 Tuples/TupleExpansion.cc Tuples/Explode.cc Tuples/Tuples.cc \ 569 567 Validate/HandleAttributes.cc Validate/FindSpecialDecls.cc \ 570 568 Virtual/ExpandCasts.cc … … 572 570 Concurrency/Keywords.cc $(SRC_COMMON) $(SRC_CONTROLSTRUCT) \ 573 571 GenPoly/GenPoly.cc GenPoly/Lvalue.cc InitTweak/GenInit.cc \ 574 InitTweak/InitTweak.cc $(SRC_RESOLVEXPR) $(SRC_SYMTAB) \ 575 SymTab/Demangle.cc $(SRC_SYNTREE) Tuples/TupleAssignment.cc \ 576 Tuples/TupleExpansion.cc Tuples/Explode.cc Tuples/Tuples.cc \ 572 InitTweak/InitTweak.cc Parser/LinkageSpec.cc $(SRC_RESOLVEXPR) \ 573 $(SRC_SYMTAB) SymTab/Demangle.cc $(SRC_SYNTREE) \ 574 Tuples/TupleAssignment.cc Tuples/TupleExpansion.cc \ 575 Tuples/Explode.cc Tuples/Tuples.cc \ 577 576 Validate/HandleAttributes.cc Validate/FindSpecialDecls.cc 578 577 MAINTAINERCLEANFILES = ${libdir}/${notdir ${cfa_cpplib_PROGRAMS}} … … 662 661 663 662 SRC_SYNTREE = \ 663 SynTree/Type.cc \ 664 SynTree/VoidType.cc \ 665 SynTree/BasicType.cc \ 666 SynTree/PointerType.cc \ 667 SynTree/ArrayType.cc \ 668 SynTree/ReferenceType.cc \ 669 SynTree/FunctionType.cc \ 670 SynTree/ReferenceToType.cc \ 671 SynTree/TupleType.cc \ 672 SynTree/TypeofType.cc \ 673 SynTree/AttrType.cc \ 674 SynTree/VarArgsType.cc \ 675 SynTree/ZeroOneType.cc \ 676 SynTree/Constant.cc \ 677 SynTree/Expression.cc \ 678 SynTree/TupleExpr.cc \ 679 SynTree/CommaExpr.cc \ 680 SynTree/TypeExpr.cc \ 681 SynTree/ApplicationExpr.cc \ 664 682 SynTree/AddressExpr.cc \ 665 SynTree/AggregateDecl.cc \ 666 SynTree/ApplicationExpr.cc \ 667 SynTree/ArrayType.cc \ 668 SynTree/AttrType.cc \ 669 SynTree/Attribute.cc \ 670 SynTree/BasicType.cc \ 671 SynTree/CommaExpr.cc \ 683 SynTree/Statement.cc \ 672 684 SynTree/CompoundStmt.cc \ 673 SynTree/Constant.cc \674 SynTree/DeclReplacer.cc \675 685 SynTree/DeclStmt.cc \ 676 686 SynTree/Declaration.cc \ 677 687 SynTree/DeclarationWithType.cc \ 678 SynTree/ Expression.cc \688 SynTree/ObjectDecl.cc \ 679 689 SynTree/FunctionDecl.cc \ 680 SynTree/FunctionType.cc \ 690 SynTree/AggregateDecl.cc \ 691 SynTree/NamedTypeDecl.cc \ 692 SynTree/TypeDecl.cc \ 681 693 SynTree/Initializer.cc \ 682 SynTree/LinkageSpec.cc \683 SynTree/NamedTypeDecl.cc \684 SynTree/ObjectDecl.cc \685 SynTree/PointerType.cc \686 SynTree/ReferenceToType.cc \687 SynTree/ReferenceType.cc \688 SynTree/Statement.cc \689 SynTree/TupleExpr.cc \690 SynTree/TupleType.cc \691 SynTree/Type.cc \692 SynTree/TypeDecl.cc \693 SynTree/TypeExpr.cc \694 694 SynTree/TypeSubstitution.cc \ 695 SynTree/TypeofType.cc \ 696 SynTree/VarArgsType.cc \ 697 SynTree/VoidType.cc \ 698 SynTree/ZeroOneType.cc 695 SynTree/Attribute.cc \ 696 SynTree/DeclReplacer.cc \ 697 SynTree/TopLvalue.cc 699 698 700 699 … … 869 868 InitTweak/InitTweak.$(OBJEXT): InitTweak/$(am__dirstamp) \ 870 869 InitTweak/$(DEPDIR)/$(am__dirstamp) 870 Parser/$(am__dirstamp): 871 @$(MKDIR_P) Parser 872 @: > Parser/$(am__dirstamp) 873 Parser/$(DEPDIR)/$(am__dirstamp): 874 @$(MKDIR_P) Parser/$(DEPDIR) 875 @: > Parser/$(DEPDIR)/$(am__dirstamp) 876 Parser/LinkageSpec.$(OBJEXT): Parser/$(am__dirstamp) \ 877 Parser/$(DEPDIR)/$(am__dirstamp) 871 878 ResolvExpr/$(am__dirstamp): 872 879 @$(MKDIR_P) ResolvExpr … … 949 956 @$(MKDIR_P) SynTree/$(DEPDIR) 950 957 @: > SynTree/$(DEPDIR)/$(am__dirstamp) 958 SynTree/Type.$(OBJEXT): SynTree/$(am__dirstamp) \ 959 SynTree/$(DEPDIR)/$(am__dirstamp) 960 SynTree/VoidType.$(OBJEXT): SynTree/$(am__dirstamp) \ 961 SynTree/$(DEPDIR)/$(am__dirstamp) 962 SynTree/BasicType.$(OBJEXT): SynTree/$(am__dirstamp) \ 963 SynTree/$(DEPDIR)/$(am__dirstamp) 964 SynTree/PointerType.$(OBJEXT): SynTree/$(am__dirstamp) \ 965 SynTree/$(DEPDIR)/$(am__dirstamp) 966 SynTree/ArrayType.$(OBJEXT): SynTree/$(am__dirstamp) \ 967 SynTree/$(DEPDIR)/$(am__dirstamp) 968 SynTree/ReferenceType.$(OBJEXT): SynTree/$(am__dirstamp) \ 969 SynTree/$(DEPDIR)/$(am__dirstamp) 970 SynTree/FunctionType.$(OBJEXT): SynTree/$(am__dirstamp) \ 971 SynTree/$(DEPDIR)/$(am__dirstamp) 972 SynTree/ReferenceToType.$(OBJEXT): SynTree/$(am__dirstamp) \ 973 SynTree/$(DEPDIR)/$(am__dirstamp) 974 SynTree/TupleType.$(OBJEXT): SynTree/$(am__dirstamp) \ 975 SynTree/$(DEPDIR)/$(am__dirstamp) 976 SynTree/TypeofType.$(OBJEXT): SynTree/$(am__dirstamp) \ 977 SynTree/$(DEPDIR)/$(am__dirstamp) 978 SynTree/AttrType.$(OBJEXT): SynTree/$(am__dirstamp) \ 979 SynTree/$(DEPDIR)/$(am__dirstamp) 980 SynTree/VarArgsType.$(OBJEXT): SynTree/$(am__dirstamp) \ 981 SynTree/$(DEPDIR)/$(am__dirstamp) 982 SynTree/ZeroOneType.$(OBJEXT): SynTree/$(am__dirstamp) \ 983 SynTree/$(DEPDIR)/$(am__dirstamp) 984 SynTree/Constant.$(OBJEXT): SynTree/$(am__dirstamp) \ 985 SynTree/$(DEPDIR)/$(am__dirstamp) 986 SynTree/Expression.$(OBJEXT): SynTree/$(am__dirstamp) \ 987 SynTree/$(DEPDIR)/$(am__dirstamp) 988 SynTree/TupleExpr.$(OBJEXT): SynTree/$(am__dirstamp) \ 989 SynTree/$(DEPDIR)/$(am__dirstamp) 990 SynTree/CommaExpr.$(OBJEXT): SynTree/$(am__dirstamp) \ 991 SynTree/$(DEPDIR)/$(am__dirstamp) 992 SynTree/TypeExpr.$(OBJEXT): SynTree/$(am__dirstamp) \ 993 SynTree/$(DEPDIR)/$(am__dirstamp) 994 SynTree/ApplicationExpr.$(OBJEXT): SynTree/$(am__dirstamp) \ 995 SynTree/$(DEPDIR)/$(am__dirstamp) 951 996 SynTree/AddressExpr.$(OBJEXT): SynTree/$(am__dirstamp) \ 952 997 SynTree/$(DEPDIR)/$(am__dirstamp) 998 SynTree/Statement.$(OBJEXT): SynTree/$(am__dirstamp) \ 999 SynTree/$(DEPDIR)/$(am__dirstamp) 1000 SynTree/CompoundStmt.$(OBJEXT): SynTree/$(am__dirstamp) \ 1001 SynTree/$(DEPDIR)/$(am__dirstamp) 1002 SynTree/DeclStmt.$(OBJEXT): SynTree/$(am__dirstamp) \ 1003 SynTree/$(DEPDIR)/$(am__dirstamp) 1004 SynTree/Declaration.$(OBJEXT): SynTree/$(am__dirstamp) \ 1005 SynTree/$(DEPDIR)/$(am__dirstamp) 1006 SynTree/DeclarationWithType.$(OBJEXT): SynTree/$(am__dirstamp) \ 1007 SynTree/$(DEPDIR)/$(am__dirstamp) 1008 SynTree/ObjectDecl.$(OBJEXT): SynTree/$(am__dirstamp) \ 1009 SynTree/$(DEPDIR)/$(am__dirstamp) 1010 SynTree/FunctionDecl.$(OBJEXT): SynTree/$(am__dirstamp) \ 1011 SynTree/$(DEPDIR)/$(am__dirstamp) 953 1012 SynTree/AggregateDecl.$(OBJEXT): SynTree/$(am__dirstamp) \ 954 1013 SynTree/$(DEPDIR)/$(am__dirstamp) 955 SynTree/ApplicationExpr.$(OBJEXT): SynTree/$(am__dirstamp) \ 956 SynTree/$(DEPDIR)/$(am__dirstamp) 957 SynTree/ArrayType.$(OBJEXT): SynTree/$(am__dirstamp) \ 958 SynTree/$(DEPDIR)/$(am__dirstamp) 959 SynTree/AttrType.$(OBJEXT): SynTree/$(am__dirstamp) \ 1014 SynTree/NamedTypeDecl.$(OBJEXT): SynTree/$(am__dirstamp) \ 1015 SynTree/$(DEPDIR)/$(am__dirstamp) 1016 SynTree/TypeDecl.$(OBJEXT): SynTree/$(am__dirstamp) \ 1017 SynTree/$(DEPDIR)/$(am__dirstamp) 1018 SynTree/Initializer.$(OBJEXT): SynTree/$(am__dirstamp) \ 1019 SynTree/$(DEPDIR)/$(am__dirstamp) 1020 SynTree/TypeSubstitution.$(OBJEXT): SynTree/$(am__dirstamp) \ 960 1021 SynTree/$(DEPDIR)/$(am__dirstamp) 961 1022 SynTree/Attribute.$(OBJEXT): SynTree/$(am__dirstamp) \ 962 1023 SynTree/$(DEPDIR)/$(am__dirstamp) 963 SynTree/BasicType.$(OBJEXT): SynTree/$(am__dirstamp) \964 SynTree/$(DEPDIR)/$(am__dirstamp)965 SynTree/CommaExpr.$(OBJEXT): SynTree/$(am__dirstamp) \966 SynTree/$(DEPDIR)/$(am__dirstamp)967 SynTree/CompoundStmt.$(OBJEXT): SynTree/$(am__dirstamp) \968 SynTree/$(DEPDIR)/$(am__dirstamp)969 SynTree/Constant.$(OBJEXT): SynTree/$(am__dirstamp) \970 SynTree/$(DEPDIR)/$(am__dirstamp)971 1024 SynTree/DeclReplacer.$(OBJEXT): SynTree/$(am__dirstamp) \ 972 1025 SynTree/$(DEPDIR)/$(am__dirstamp) 973 SynTree/DeclStmt.$(OBJEXT): SynTree/$(am__dirstamp) \ 974 SynTree/$(DEPDIR)/$(am__dirstamp) 975 SynTree/Declaration.$(OBJEXT): SynTree/$(am__dirstamp) \ 976 SynTree/$(DEPDIR)/$(am__dirstamp) 977 SynTree/DeclarationWithType.$(OBJEXT): SynTree/$(am__dirstamp) \ 978 SynTree/$(DEPDIR)/$(am__dirstamp) 979 SynTree/Expression.$(OBJEXT): SynTree/$(am__dirstamp) \ 980 SynTree/$(DEPDIR)/$(am__dirstamp) 981 SynTree/FunctionDecl.$(OBJEXT): SynTree/$(am__dirstamp) \ 982 SynTree/$(DEPDIR)/$(am__dirstamp) 983 SynTree/FunctionType.$(OBJEXT): SynTree/$(am__dirstamp) \ 984 SynTree/$(DEPDIR)/$(am__dirstamp) 985 SynTree/Initializer.$(OBJEXT): SynTree/$(am__dirstamp) \ 986 SynTree/$(DEPDIR)/$(am__dirstamp) 987 SynTree/LinkageSpec.$(OBJEXT): SynTree/$(am__dirstamp) \ 988 SynTree/$(DEPDIR)/$(am__dirstamp) 989 SynTree/NamedTypeDecl.$(OBJEXT): SynTree/$(am__dirstamp) \ 990 SynTree/$(DEPDIR)/$(am__dirstamp) 991 SynTree/ObjectDecl.$(OBJEXT): SynTree/$(am__dirstamp) \ 992 SynTree/$(DEPDIR)/$(am__dirstamp) 993 SynTree/PointerType.$(OBJEXT): SynTree/$(am__dirstamp) \ 994 SynTree/$(DEPDIR)/$(am__dirstamp) 995 SynTree/ReferenceToType.$(OBJEXT): SynTree/$(am__dirstamp) \ 996 SynTree/$(DEPDIR)/$(am__dirstamp) 997 SynTree/ReferenceType.$(OBJEXT): SynTree/$(am__dirstamp) \ 998 SynTree/$(DEPDIR)/$(am__dirstamp) 999 SynTree/Statement.$(OBJEXT): SynTree/$(am__dirstamp) \ 1000 SynTree/$(DEPDIR)/$(am__dirstamp) 1001 SynTree/TupleExpr.$(OBJEXT): SynTree/$(am__dirstamp) \ 1002 SynTree/$(DEPDIR)/$(am__dirstamp) 1003 SynTree/TupleType.$(OBJEXT): SynTree/$(am__dirstamp) \ 1004 SynTree/$(DEPDIR)/$(am__dirstamp) 1005 SynTree/Type.$(OBJEXT): SynTree/$(am__dirstamp) \ 1006 SynTree/$(DEPDIR)/$(am__dirstamp) 1007 SynTree/TypeDecl.$(OBJEXT): SynTree/$(am__dirstamp) \ 1008 SynTree/$(DEPDIR)/$(am__dirstamp) 1009 SynTree/TypeExpr.$(OBJEXT): SynTree/$(am__dirstamp) \ 1010 SynTree/$(DEPDIR)/$(am__dirstamp) 1011 SynTree/TypeSubstitution.$(OBJEXT): SynTree/$(am__dirstamp) \ 1012 SynTree/$(DEPDIR)/$(am__dirstamp) 1013 SynTree/TypeofType.$(OBJEXT): SynTree/$(am__dirstamp) \ 1014 SynTree/$(DEPDIR)/$(am__dirstamp) 1015 SynTree/VarArgsType.$(OBJEXT): SynTree/$(am__dirstamp) \ 1016 SynTree/$(DEPDIR)/$(am__dirstamp) 1017 SynTree/VoidType.$(OBJEXT): SynTree/$(am__dirstamp) \ 1018 SynTree/$(DEPDIR)/$(am__dirstamp) 1019 SynTree/ZeroOneType.$(OBJEXT): SynTree/$(am__dirstamp) \ 1026 SynTree/TopLvalue.$(OBJEXT): SynTree/$(am__dirstamp) \ 1020 1027 SynTree/$(DEPDIR)/$(am__dirstamp) 1021 1028 Tuples/$(am__dirstamp): … … 1134 1141 InitTweak/FixGlobalInit.$(OBJEXT): InitTweak/$(am__dirstamp) \ 1135 1142 InitTweak/$(DEPDIR)/$(am__dirstamp) 1136 Parser/$(am__dirstamp): 1137 @$(MKDIR_P) Parser 1138 @: > Parser/$(am__dirstamp) 1139 Parser/$(DEPDIR)/$(am__dirstamp): 1140 @$(MKDIR_P) Parser/$(DEPDIR) 1141 @: > Parser/$(DEPDIR)/$(am__dirstamp) 1143 Parser/parser.hh: Parser/parser.cc 1144 @if test ! -f $@; then rm -f Parser/parser.cc; else :; fi 1145 @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) Parser/parser.cc; else :; fi 1146 Parser/parser.$(OBJEXT): Parser/$(am__dirstamp) \ 1147 Parser/$(DEPDIR)/$(am__dirstamp) 1148 Parser/lex.$(OBJEXT): Parser/$(am__dirstamp) \ 1149 Parser/$(DEPDIR)/$(am__dirstamp) 1150 Parser/TypedefTable.$(OBJEXT): Parser/$(am__dirstamp) \ 1151 Parser/$(DEPDIR)/$(am__dirstamp) 1152 Parser/ParseNode.$(OBJEXT): Parser/$(am__dirstamp) \ 1153 Parser/$(DEPDIR)/$(am__dirstamp) 1142 1154 Parser/DeclarationNode.$(OBJEXT): Parser/$(am__dirstamp) \ 1143 1155 Parser/$(DEPDIR)/$(am__dirstamp) 1144 1156 Parser/ExpressionNode.$(OBJEXT): Parser/$(am__dirstamp) \ 1145 1157 Parser/$(DEPDIR)/$(am__dirstamp) 1158 Parser/StatementNode.$(OBJEXT): Parser/$(am__dirstamp) \ 1159 Parser/$(DEPDIR)/$(am__dirstamp) 1146 1160 Parser/InitializerNode.$(OBJEXT): Parser/$(am__dirstamp) \ 1147 1161 Parser/$(DEPDIR)/$(am__dirstamp) 1148 Parser/ParseNode.$(OBJEXT): Parser/$(am__dirstamp) \1149 Parser/$(DEPDIR)/$(am__dirstamp)1150 Parser/StatementNode.$(OBJEXT): Parser/$(am__dirstamp) \1151 Parser/$(DEPDIR)/$(am__dirstamp)1152 1162 Parser/TypeData.$(OBJEXT): Parser/$(am__dirstamp) \ 1153 Parser/$(DEPDIR)/$(am__dirstamp)1154 Parser/TypedefTable.$(OBJEXT): Parser/$(am__dirstamp) \1155 Parser/$(DEPDIR)/$(am__dirstamp)1156 Parser/lex.$(OBJEXT): Parser/$(am__dirstamp) \1157 Parser/$(DEPDIR)/$(am__dirstamp)1158 Parser/parser.hh: Parser/parser.cc1159 @if test ! -f $@; then rm -f Parser/parser.cc; else :; fi1160 @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) Parser/parser.cc; else :; fi1161 Parser/parser.$(OBJEXT): Parser/$(am__dirstamp) \1162 1163 Parser/$(DEPDIR)/$(am__dirstamp) 1163 1164 Parser/parserutility.$(OBJEXT): Parser/$(am__dirstamp) \ … … 1270 1271 @AMDEP_TRUE@@am__include@ @am__quote@Parser/$(DEPDIR)/ExpressionNode.Po@am__quote@ 1271 1272 @AMDEP_TRUE@@am__include@ @am__quote@Parser/$(DEPDIR)/InitializerNode.Po@am__quote@ 1273 @AMDEP_TRUE@@am__include@ @am__quote@Parser/$(DEPDIR)/LinkageSpec.Po@am__quote@ 1272 1274 @AMDEP_TRUE@@am__include@ @am__quote@Parser/$(DEPDIR)/ParseNode.Po@am__quote@ 1273 1275 @AMDEP_TRUE@@am__include@ @am__quote@Parser/$(DEPDIR)/StatementNode.Po@am__quote@ … … 1328 1330 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/FunctionType.Po@am__quote@ 1329 1331 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/Initializer.Po@am__quote@ 1330 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/LinkageSpec.Po@am__quote@1331 1332 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/NamedTypeDecl.Po@am__quote@ 1332 1333 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/ObjectDecl.Po@am__quote@ … … 1335 1336 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/ReferenceType.Po@am__quote@ 1336 1337 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/Statement.Po@am__quote@ 1338 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/TopLvalue.Po@am__quote@ 1337 1339 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/TupleExpr.Po@am__quote@ 1338 1340 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/TupleType.Po@am__quote@ -
src/Parser/DeclarationNode.cc
r3d5701e r9fb8f01 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Dec 16 15:32:22201913 // Update Count : 11 3312 // Last Modified On : Thu Jul 25 22:17:10 2019 13 // Update Count : 1116 14 14 // 15 15 … … 24 24 #include "Common/UniqueName.h" // for UniqueName 25 25 #include "Common/utility.h" // for maybeClone, maybeBuild, CodeLocation 26 #include "Parser/LinkageSpec.h" // for Spec, linkageName, Cforall 26 27 #include "Parser/ParseNode.h" // for DeclarationNode, ExpressionNode 27 #include "SynTree/LinkageSpec.h" // for Spec, linkageName, Cforall28 28 #include "SynTree/Attribute.h" // for Attribute 29 29 #include "SynTree/Declaration.h" // for TypeDecl, ObjectDecl, Declaration … … 47 47 const char * DeclarationNode::signednessNames[] = { "signed", "unsigned", "NoSignednessNames" }; 48 48 const char * DeclarationNode::lengthNames[] = { "short", "long", "long long", "NoLengthNames" }; 49 const char * DeclarationNode::aggregateNames[] = { "struct", "union", "trait", "coroutine", "monitor", "thread", "NoAggregateNames" }; 50 const char * DeclarationNode::typeClassNames[] = { "otype", "dtype", "ftype", "NoTypeClassNames" }; 49 51 const char * DeclarationNode::builtinTypeNames[] = { "__builtin_va_list", "__auto_type", "zero_t", "one_t", "NoBuiltinTypeNames" }; 50 52 … … 57 59 58 60 // variable.name = nullptr; 59 variable.tyClass = TypeDecl::NUMBER_OF_KINDS;61 variable.tyClass = NoTypeClass; 60 62 variable.assertions = nullptr; 61 63 variable.initializer = nullptr; … … 133 135 134 136 if ( linkage != LinkageSpec::Cforall ) { 135 os << LinkageSpec:: name( linkage ) << " ";137 os << LinkageSpec::linkageName( linkage ) << " "; 136 138 } // if 137 139 … … 265 267 } 266 268 267 DeclarationNode * DeclarationNode::newAggregate( Aggregate Decl::Aggregatekind, const string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) {269 DeclarationNode * DeclarationNode::newAggregate( Aggregate kind, const string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) { 268 270 DeclarationNode * newnode = new DeclarationNode; 269 271 newnode->type = new TypeData( TypeData::Aggregate ); … … 311 313 } // DeclarationNode::newFromTypeGen 312 314 313 DeclarationNode * DeclarationNode::newTypeParam( Type Decl::Kindtc, const string * name ) {315 DeclarationNode * DeclarationNode::newTypeParam( TypeClass tc, const string * name ) { 314 316 DeclarationNode * newnode = new DeclarationNode; 315 317 newnode->type = nullptr; … … 326 328 newnode->type = new TypeData( TypeData::Aggregate ); 327 329 newnode->type->aggregate.name = name; 328 newnode->type->aggregate.kind = AggregateDecl::Trait;330 newnode->type->aggregate.kind = Trait; 329 331 newnode->type->aggregate.params = params; 330 332 newnode->type->aggregate.fields = asserts; … … 336 338 newnode->type = new TypeData( TypeData::AggregateInst ); 337 339 newnode->type->aggInst.aggregate = new TypeData( TypeData::Aggregate ); 338 newnode->type->aggInst.aggregate->aggregate.kind = AggregateDecl::Trait;340 newnode->type->aggInst.aggregate->aggregate.kind = Trait; 339 341 newnode->type->aggInst.aggregate->aggregate.name = name; 340 342 newnode->type->aggInst.params = params; … … 669 671 670 672 DeclarationNode * DeclarationNode::addAssertions( DeclarationNode * assertions ) { 671 if ( variable.tyClass != TypeDecl::NUMBER_OF_KINDS) {673 if ( variable.tyClass != NoTypeClass ) { 672 674 if ( variable.assertions ) { 673 675 variable.assertions->appendList( assertions ); … … 874 876 875 877 DeclarationNode * DeclarationNode::addTypeInitializer( DeclarationNode * init ) { 876 assertf( variable.tyClass != TypeDecl::NUMBER_OF_KINDS, "Called addTypeInitializer on something that isn't a type variable." );878 assertf( variable.tyClass != NoTypeClass, "Called addTypeInitializer on something that isn't a type variable." ); 877 879 variable.initializer = init; 878 880 return this; … … 1073 1075 } // if 1074 1076 1075 if ( variable.tyClass != TypeDecl::NUMBER_OF_KINDS) {1077 if ( variable.tyClass != NoTypeClass ) { 1076 1078 // otype is internally converted to dtype + otype parameters 1077 1079 static const TypeDecl::Kind kindMap[] = { TypeDecl::Dtype, TypeDecl::Dtype, TypeDecl::Ftype, TypeDecl::Ttype }; 1078 static_assert( sizeof(kindMap)/sizeof(kindMap[0]) == TypeDecl::NUMBER_OF_KINDS, "DeclarationNode::build: kindMap is out of sync." );1080 assertf( sizeof(kindMap)/sizeof(kindMap[0]) == NoTypeClass, "DeclarationNode::build: kindMap is out of sync." ); 1079 1081 assertf( variable.tyClass < sizeof(kindMap)/sizeof(kindMap[0]), "Variable's tyClass is out of bounds." ); 1080 TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ], variable.tyClass == TypeDecl::Otype, variable.initializer ? variable.initializer->buildType() : nullptr );1082 TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ], variable.tyClass == Otype, variable.initializer ? variable.initializer->buildType() : nullptr ); 1081 1083 buildList( variable.assertions, ret->get_assertions() ); 1082 1084 return ret; -
src/Parser/ExpressionNode.cc
r3d5701e r9fb8f01 10 10 // Created On : Sat May 16 13:17:07 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 18 21:14:58201913 // Update Count : 9 8112 // Last Modified On : Sun Aug 4 20:57:55 2019 13 // Update Count : 978 14 14 // 15 15 … … 265 265 static const BasicType::Kind kind[2][12] = { 266 266 { BasicType::Float, BasicType::Double, BasicType::LongDouble, BasicType::uuFloat80, BasicType::uuFloat128, BasicType::uFloat16, BasicType::uFloat32, BasicType::uFloat32x, BasicType::uFloat64, BasicType::uFloat64x, BasicType::uFloat128, BasicType::uFloat128x }, 267 { BasicType::FloatComplex, BasicType::DoubleComplex, BasicType::LongDoubleComplex, BasicType::NUMBER_OF_BASIC_TYPES, BasicType::NUMBER_OF_BASIC_TYPES, BasicType::uFloat16Complex, BasicType::uFloat32Complex, BasicType::uFloat32xComplex, BasicType::uFloat64Complex, BasicType::uFloat64xComplex, BasicType::uFloat128Complex, BasicType::uFloat128xComplex },267 { BasicType::FloatComplex, BasicType::DoubleComplex, BasicType::LongDoubleComplex, (BasicType::Kind)-1, (BasicType::Kind)-1, BasicType::uFloat16Complex, BasicType::uFloat32Complex, BasicType::uFloat32xComplex, BasicType::uFloat64Complex, BasicType::uFloat64xComplex, BasicType::uFloat128Complex, BasicType::uFloat128xComplex }, 268 268 }; 269 269 … … 374 374 375 375 Expression * build_field_name_FLOATING_DECIMALconstant( const string & str ) { 376 if ( str[str.size() -1] != '.' ) SemanticError( yylloc, "invalid tuple index " + str );376 if ( str[str.size()-1] != '.' ) SemanticError( yylloc, "invalid tuple index " + str ); 377 377 Expression * ret = build_constantInteger( *new string( str.substr( 0, str.size()-1 ) ) ); 378 378 delete &str; … … 434 434 } // build_cast 435 435 436 Expression * build_keyword_cast( AggregateDecl::Aggregatetarget, ExpressionNode * expr_node ) {436 Expression * build_keyword_cast( KeywordCastExpr::Target target, ExpressionNode * expr_node ) { 437 437 return new KeywordCastExpr( maybeMoveBuild< Expression >(expr_node), target ); 438 438 } -
src/Parser/ParseNode.h
r3d5701e r9fb8f01 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 7 17:56:02 202013 // Update Count : 8 9112 // Last Modified On : Thu Jul 25 22:17:10 2019 13 // Update Count : 876 14 14 // 15 15 … … 28 28 #include "Common/UniqueName.h" // for UniqueName 29 29 #include "Common/utility.h" // for maybeClone, maybeBuild 30 #include "SynTree/LinkageSpec.h" // for Spec 31 #include "SynTree/Declaration.h" // for Aggregate 30 #include "Parser/LinkageSpec.h" // for Spec 32 31 #include "SynTree/Expression.h" // for Expression, ConstantExpr (ptr only) 33 32 #include "SynTree/Label.h" // for Label … … 185 184 186 185 Expression * build_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ); 187 Expression * build_keyword_cast( AggregateDecl::Aggregatetarget, ExpressionNode * expr_node );186 Expression * build_keyword_cast( KeywordCastExpr::Target target, ExpressionNode * expr_node ); 188 187 Expression * build_virtual_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ); 189 188 Expression * build_fieldSel( ExpressionNode * expr_node, Expression * member ); … … 218 217 enum Length { Short, Long, LongLong, NoLength }; 219 218 static const char * lengthNames[]; 219 enum Aggregate { Struct, Union, Exception, Trait, Coroutine, Monitor, Thread, NoAggregate }; 220 static const char * aggregateNames[]; 221 enum TypeClass { Otype, Dtype, Ftype, Ttype, NoTypeClass }; 222 static const char * typeClassNames[]; 220 223 enum BuiltinType { Valist, AutoType, Zero, One, NoBuiltinType }; 221 224 static const char * builtinTypeNames[]; … … 234 237 static DeclarationNode * newQualifiedType( DeclarationNode *, DeclarationNode * ); 235 238 static DeclarationNode * newFunction( const std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body ); 236 static DeclarationNode * newAggregate( Aggregate Decl::Aggregatekind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body );239 static DeclarationNode * newAggregate( Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ); 237 240 static DeclarationNode * newEnum( const std::string * name, DeclarationNode * constants, bool body ); 238 241 static DeclarationNode * newEnumConstant( const std::string * name, ExpressionNode * constant ); 239 242 static DeclarationNode * newName( const std::string * ); 240 243 static DeclarationNode * newFromTypeGen( const std::string *, ExpressionNode * params ); 241 static DeclarationNode * newTypeParam( Type Decl::Kind, const std::string * );244 static DeclarationNode * newTypeParam( TypeClass, const std::string * ); 242 245 static DeclarationNode * newTrait( const std::string * name, DeclarationNode * params, DeclarationNode * asserts ); 243 246 static DeclarationNode * newTraitUse( const std::string * name, ExpressionNode * params ); … … 309 312 struct Variable_t { 310 313 // const std::string * name; 311 TypeDecl::KindtyClass;314 DeclarationNode::TypeClass tyClass; 312 315 DeclarationNode * assertions; 313 316 DeclarationNode * initializer; … … 449 452 * out++ = result; 450 453 } else { 451 SemanticError( cur->location, "type specifier declaration in forall clause is currently unimplemented.");454 assertf(false, "buildList unknown type"); 452 455 } // if 453 456 } catch( SemanticErrorException & e ) { -
src/Parser/ParserTypes.h
r3d5701e r9fb8f01 10 10 // Created On : Sat Sep 22 08:58:10 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 15 11:04:40 202013 // Update Count : 35 112 // Last Modified On : Sat Jul 22 09:33:28 2017 13 // Update Count : 350 14 14 // 15 15 … … 27 27 // current location in the input 28 28 extern int yylineno; 29 extern char * yyfilename;29 extern char *yyfilename; 30 30 31 31 struct Location { 32 char * file;32 char *file; 33 33 int line; 34 34 }; // Location 35 35 36 36 struct Token { 37 std::string * str; // must be pointer as used in union37 std::string *str; // must be pointer as used in union 38 38 Location loc; 39 39 -
src/Parser/TypeData.cc
r3d5701e r9fb8f01 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Dec 16 07:56:46201913 // Update Count : 6 6212 // Last Modified On : Wed Feb 13 18:16:23 2019 13 // Update Count : 649 14 14 // 15 15 … … 67 67 case Aggregate: 68 68 // aggregate = new Aggregate_t; 69 aggregate.kind = AggregateDecl::NoAggregate;69 aggregate.kind = DeclarationNode::NoAggregate; 70 70 aggregate.name = nullptr; 71 71 aggregate.params = nullptr; … … 345 345 break; 346 346 case Aggregate: 347 os << AggregateDecl::aggrString( aggregate.kind )<< ' ' << *aggregate.name << endl;347 os << DeclarationNode::aggregateNames[ aggregate.kind ] << ' ' << *aggregate.name << endl; 348 348 if ( aggregate.params ) { 349 349 os << string( indent + 2, ' ' ) << "with type parameters" << endl; … … 489 489 for ( typename ForallList::iterator i = outputList.begin(); i != outputList.end(); ++i, n = (DeclarationNode*)n->get_next() ) { 490 490 TypeDecl * td = static_cast<TypeDecl *>(*i); 491 if ( n->variable.tyClass == TypeDecl::Otype ) {491 if ( n->variable.tyClass == DeclarationNode::Otype ) { 492 492 // add assertion parameters to `type' tyvars in reverse order 493 493 // add dtor: void ^?{}(T *) … … 522 522 switch ( td->kind ) { 523 523 case TypeData::Unknown: 524 // fill in implicit int525 return new BasicType( buildQualifiers( td ), BasicType::SignedInt );524 // fill in implicit int 525 return new BasicType( buildQualifiers( td ), BasicType::SignedInt ); 526 526 case TypeData::Basic: 527 return buildBasicType( td );527 return buildBasicType( td ); 528 528 case TypeData::Pointer: 529 return buildPointer( td );529 return buildPointer( td ); 530 530 case TypeData::Array: 531 return buildArray( td );531 return buildArray( td ); 532 532 case TypeData::Reference: 533 return buildReference( td );533 return buildReference( td ); 534 534 case TypeData::Function: 535 return buildFunction( td );535 return buildFunction( td ); 536 536 case TypeData::AggregateInst: 537 return buildAggInst( td );537 return buildAggInst( td ); 538 538 case TypeData::EnumConstant: 539 // the name gets filled in later -- by SymTab::Validate540 return new EnumInstType( buildQualifiers( td ), "" );539 // the name gets filled in later -- by SymTab::Validate 540 return new EnumInstType( buildQualifiers( td ), "" ); 541 541 case TypeData::SymbolicInst: 542 return buildSymbolicInst( td );542 return buildSymbolicInst( td ); 543 543 case TypeData::Tuple: 544 return buildTuple( td );544 return buildTuple( td ); 545 545 case TypeData::Typeof: 546 546 case TypeData::Basetypeof: 547 return buildTypeof( td );547 return buildTypeof( td ); 548 548 case TypeData::Builtin: 549 switch ( td->builtintype ) { 550 case DeclarationNode::Zero: 551 return new ZeroType( noQualifiers ); 552 case DeclarationNode::One: 553 return new OneType( noQualifiers ); 554 default: 555 return new VarArgsType( buildQualifiers( td ) ); 556 } // switch 549 if (td->builtintype == DeclarationNode::Zero) { 550 return new ZeroType( noQualifiers ); 551 } 552 else if (td->builtintype == DeclarationNode::One) { 553 return new OneType( noQualifiers ); 554 } 555 else { 556 return new VarArgsType( buildQualifiers( td ) ); 557 } 557 558 case TypeData::GlobalScope: 558 return new GlobalScopeType();559 case TypeData::Qualified:560 return new QualifiedType( buildQualifiers( td ), typebuild( td->qualified.parent ), typebuild( td->qualified.child ) );559 return new GlobalScopeType(); 560 case TypeData::Qualified: 561 return new QualifiedType( buildQualifiers( td ), typebuild( td->qualified.parent ), typebuild( td->qualified.child ) ); 561 562 case TypeData::Symbolic: 562 563 case TypeData::Enum: 563 564 case TypeData::Aggregate: 564 assert( false );565 assert( false ); 565 566 } // switch 566 567 … … 767 768 AggregateDecl * at; 768 769 switch ( td->aggregate.kind ) { 769 case AggregateDecl::Struct:770 case AggregateDecl::Coroutine:771 case AggregateDecl::Monitor:772 case AggregateDecl::Thread:770 case DeclarationNode::Struct: 771 case DeclarationNode::Coroutine: 772 case DeclarationNode::Monitor: 773 case DeclarationNode::Thread: 773 774 at = new StructDecl( *td->aggregate.name, td->aggregate.kind, attributes, linkage ); 774 775 buildForall( td->aggregate.params, at->get_parameters() ); 775 776 break; 776 case AggregateDecl::Union:777 case DeclarationNode::Union: 777 778 at = new UnionDecl( *td->aggregate.name, attributes, linkage ); 778 779 buildForall( td->aggregate.params, at->get_parameters() ); 779 780 break; 780 case AggregateDecl::Trait:781 case DeclarationNode::Trait: 781 782 at = new TraitDecl( *td->aggregate.name, attributes, linkage ); 782 783 buildList( td->aggregate.params, at->get_parameters() ); … … 808 809 AggregateDecl * typedecl = buildAggregate( type, attributes, linkage ); 809 810 switch ( type->aggregate.kind ) { 810 case AggregateDecl::Struct:811 case AggregateDecl::Coroutine:812 case AggregateDecl::Monitor:813 case AggregateDecl::Thread:811 case DeclarationNode::Struct: 812 case DeclarationNode::Coroutine: 813 case DeclarationNode::Monitor: 814 case DeclarationNode::Thread: 814 815 ret = new StructInstType( buildQualifiers( type ), (StructDecl *)typedecl ); 815 816 break; 816 case AggregateDecl::Union:817 case DeclarationNode::Union: 817 818 ret = new UnionInstType( buildQualifiers( type ), (UnionDecl *)typedecl ); 818 819 break; 819 case AggregateDecl::Trait:820 case DeclarationNode::Trait: 820 821 assert( false ); 821 822 //ret = new TraitInstType( buildQualifiers( type ), (TraitDecl *)typedecl ); … … 826 827 } else { 827 828 switch ( type->aggregate.kind ) { 828 case AggregateDecl::Struct:829 case AggregateDecl::Coroutine:830 case AggregateDecl::Monitor:831 case AggregateDecl::Thread:829 case DeclarationNode::Struct: 830 case DeclarationNode::Coroutine: 831 case DeclarationNode::Monitor: 832 case DeclarationNode::Thread: 832 833 ret = new StructInstType( buildQualifiers( type ), *type->aggregate.name ); 833 834 break; 834 case AggregateDecl::Union:835 case DeclarationNode::Union: 835 836 ret = new UnionInstType( buildQualifiers( type ), *type->aggregate.name ); 836 837 break; 837 case AggregateDecl::Trait:838 case DeclarationNode::Trait: 838 839 ret = new TraitInstType( buildQualifiers( type ), *type->aggregate.name ); 839 840 break; … … 862 863 case TypeData::Aggregate: { 863 864 switch ( type->aggregate.kind ) { 864 case AggregateDecl::Struct:865 case AggregateDecl::Coroutine:866 case AggregateDecl::Monitor:867 case AggregateDecl::Thread:865 case DeclarationNode::Struct: 866 case DeclarationNode::Coroutine: 867 case DeclarationNode::Monitor: 868 case DeclarationNode::Thread: 868 869 ret = new StructInstType( buildQualifiers( type ), *type->aggregate.name ); 869 870 break; 870 case AggregateDecl::Union:871 case DeclarationNode::Union: 871 872 ret = new UnionInstType( buildQualifiers( type ), *type->aggregate.name ); 872 873 break; 873 case AggregateDecl::Trait:874 case DeclarationNode::Trait: 874 875 ret = new TraitInstType( buildQualifiers( type ), *type->aggregate.name ); 875 876 break; -
src/Parser/TypeData.h
r3d5701e r9fb8f01 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 13 23:42:35 201913 // Update Count : 19 912 // Last Modified On : Thu Nov 1 20:56:46 2018 13 // Update Count : 196 14 14 // 15 15 … … 21 21 22 22 #include "ParseNode.h" // for DeclarationNode, DeclarationNode::Ag... 23 #include " SynTree/LinkageSpec.h"// for Spec23 #include "Parser/LinkageSpec.h" // for Spec 24 24 #include "SynTree/Type.h" // for Type, ReferenceToType (ptr only) 25 25 #include "SynTree/SynTree.h" // for Visitor Nodes … … 30 30 31 31 struct Aggregate_t { 32 AggregateDecl::Aggregate kind;32 DeclarationNode::Aggregate kind; 33 33 const std::string * name = nullptr; 34 34 DeclarationNode * params = nullptr; -
src/Parser/TypedefTable.cc
r3d5701e r9fb8f01 10 10 // Created On : Sat May 16 15:20:13 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 15 08:06:36 202013 // Update Count : 25 912 // Last Modified On : Wed Jul 25 15:32:35 2018 13 // Update Count : 258 14 14 // 15 15 … … 47 47 } // TypedefTable::~TypedefTable 48 48 49 bool TypedefTable::exists( const string & identifier ) const{49 bool TypedefTable::exists( const string & identifier ) { 50 50 return kindTable.find( identifier ) != kindTable.end(); 51 51 } // TypedefTable::exists 52 52 53 bool TypedefTable::existsCurr( const string & identifier ) const{53 bool TypedefTable::existsCurr( const string & identifier ) { 54 54 return kindTable.findAt( kindTable.currentScope() - 1, identifier ) != kindTable.end(); 55 55 } // TypedefTable::exists -
src/Parser/TypedefTable.h
r3d5701e r9fb8f01 10 10 // Created On : Sat May 16 15:24:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 15 08:06:37 202013 // Update Count : 11 712 // Last Modified On : Wed Jul 25 15:33:55 2018 13 // Update Count : 114 14 14 // 15 15 … … 30 30 ~TypedefTable(); 31 31 32 bool exists( const std::string & identifier ) const;33 bool existsCurr( const std::string & identifier ) const;32 bool exists( const std::string & identifier ); 33 bool existsCurr( const std::string & identifier ); 34 34 int isKind( const std::string & identifier ) const; 35 35 void makeTypedef( const std::string & name, int kind = TYPEDEFname ); -
src/Parser/lex.ll
r3d5701e r9fb8f01 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : S at Feb 15 11:05:50 202013 * Update Count : 7 3712 * Last Modified On : Sun Aug 4 20:53:47 2019 13 * Update Count : 719 14 14 */ 15 15 … … 42 42 #include "ParseNode.h" 43 43 #include "TypedefTable.h" 44 45 string * build_postfix_name( string * name );46 44 47 45 char *yyfilename; … … 332 330 /* identifier */ 333 331 {identifier} { IDENTIFIER_RETURN(); } 334 "` `"{identifier} {// CFA335 yytext[yyleng ] = '\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?) 336 334 IDENTIFIER_RETURN(); 337 335 } … … 434 432 "?"({op_unary_pre_post}|"()"|"[?]"|"{}") { IDENTIFIER_RETURN(); } 435 433 "^?{}" { IDENTIFIER_RETURN(); } 436 "?`"{identifier} { // postfix operator 437 yylval.tok.str = new string( &yytext[2] ); // remove ?` 438 yylval.tok.str = build_postfix_name( yylval.tok.str ); // add prefix 439 RETURN_LOCN( typedefTable.isKind( *yylval.tok.str ) ); 440 } 434 "?`"{identifier} { IDENTIFIER_RETURN(); } // postfix operator 441 435 "?"{op_binary_over}"?" { IDENTIFIER_RETURN(); } // binary 442 436 /* -
src/Parser/module.mk
r3d5701e r9fb8f01 11 11 ## Created On : Sat May 16 15:29:09 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Sat Dec 14 07:34:47 201914 ## Update Count : 10 713 ## Last Modified On : Wed Jun 28 21:58:29 2017 14 ## Update Count : 104 15 15 ############################################################################### 16 16 … … 19 19 AM_YFLAGS = -d -t -v 20 20 21 SRC += \ 21 SRC += Parser/parser.yy \ 22 Parser/lex.ll \ 23 Parser/TypedefTable.cc \ 24 Parser/ParseNode.cc \ 22 25 Parser/DeclarationNode.cc \ 23 26 Parser/ExpressionNode.cc \ 27 Parser/StatementNode.cc \ 24 28 Parser/InitializerNode.cc \ 25 Parser/ParseNode.cc \26 Parser/StatementNode.cc \27 29 Parser/TypeData.cc \ 28 Parser/TypedefTable.cc \ 29 Parser/lex.ll \ 30 Parser/parser.yy \ 30 Parser/LinkageSpec.cc \ 31 31 Parser/parserutility.cc 32 32 33 SRCDEMANGLE += \ 34 Parser/LinkageSpec.cc 35 36 33 37 MOSTLYCLEANFILES += Parser/lex.cc Parser/parser.cc Parser/parser.hh Parser/parser.output -
src/Parser/parser.yy
r3d5701e r9fb8f01 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 21 14:47:29 202013 // Update Count : 4 46812 // Last Modified On : Sun Aug 4 21:48:23 2019 13 // Update Count : 4364 14 14 // 15 15 … … 51 51 using namespace std; 52 52 53 #include "SynTree/Declaration.h"54 53 #include "ParseNode.h" 55 54 #include "TypedefTable.h" 56 55 #include "TypeData.h" 57 #include " SynTree/LinkageSpec.h"56 #include "LinkageSpec.h" 58 57 #include "Common/SemanticError.h" // error_str 59 58 #include "Common/utility.h" // for maybeMoveBuild, maybeBuild, CodeLo... … … 166 165 } // rebindForall 167 166 168 string * build_postfix_name( string * name ) { 169 *name = string("__postfix_func_") + *name; 170 return name; 167 NameExpr * build_postfix_name( const string * name ) { 168 NameExpr * new_name = build_varref( new string( "?`" + *name ) ); 169 delete name; 170 return new_name; 171 171 } // build_postfix_name 172 172 … … 210 210 } // if 211 211 } // forCtrl 212 212 213 213 214 bool forall = false, yyy = false; // aggregate have one or more forall qualifiers ? … … 236 237 ExpressionNode * en; 237 238 DeclarationNode * decl; 238 AggregateDecl::Aggregate aggKey;239 TypeDecl::Kindtclass;239 DeclarationNode::Aggregate aggKey; 240 DeclarationNode::TypeClass tclass; 240 241 StatementNode * sn; 241 242 WaitForStmt * wfs; … … 322 323 %type<op> ptrref_operator unary_operator assignment_operator 323 324 %type<en> primary_expression postfix_expression unary_expression 324 %type<en> cast_expression _list cast_expressionexponential_expression multiplicative_expression additive_expression325 %type<en> cast_expression exponential_expression multiplicative_expression additive_expression 325 326 %type<en> shift_expression relational_expression equality_expression 326 327 %type<en> AND_expression exclusive_OR_expression inclusive_OR_expression … … 364 365 %type<decl> abstract_parameter_declaration 365 366 366 %type<aggKey> aggregate_key aggregate_data aggregate_control367 %type<aggKey> aggregate_key 367 368 %type<decl> aggregate_type aggregate_type_nobody 368 369 … … 578 579 | '(' compound_statement ')' // GCC, lambda expression 579 580 { $$ = 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 ) ); } 580 591 | type_name '.' identifier // CFA, nested type 581 592 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } … … 631 642 | postfix_expression '(' argument_expression_list ')' 632 643 { $$ = new ExpressionNode( build_func( $1, $3 ) ); } 633 | postfix_expression '`' identifier // CFA, postfix call634 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( build_postfix_name( $3 ) ) ), $1 ) ); }635 | constant '`' identifier // CFA, postfix call636 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( build_postfix_name( $3 ) ) ), $1 ) ); }637 | string_literal '`' identifier // CFA, postfix call638 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( build_postfix_name( $3 ) ) ), new ExpressionNode( $1 ) ) ); }639 644 | postfix_expression '.' identifier 640 645 { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); } … … 645 650 | postfix_expression '.' '[' field_name_list ']' // CFA, tuple field selector 646 651 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); } 647 | postfix_expression '.' aggregate_control648 { $$ = new ExpressionNode( build_keyword_cast( $3, $1 ) ); }649 652 | postfix_expression ARROW identifier 650 653 { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); } … … 661 664 | '(' type_no_function ')' '@' '{' initializer_list_opt comma_opt '}' // CFA, explicit C compound-literal 662 665 { $$ = new ExpressionNode( build_compoundLiteral( $2, (new InitializerNode( $6, true ))->set_maybeConstructed( false ) ) ); } 663 | '^' primary_expression '{' argument_expression_list '}' // CFA , destructor call666 | '^' primary_expression '{' argument_expression_list '}' // CFA 664 667 { 665 668 Token fn; … … 674 677 | argument_expression 675 678 | argument_expression_list ',' argument_expression 676 { $$ = (ExpressionNode *)( $1->set_last( $3 )); }679 { $$ = (ExpressionNode *)( $1->set_last( $3 )); } 677 680 ; 678 681 … … 686 689 field_name_list: // CFA, tuple field selector 687 690 field 688 | field_name_list ',' field { $$ = (ExpressionNode *) ($1->set_last( $3 )); }691 | field_name_list ',' field { $$ = (ExpressionNode *)$1->set_last( $3 ); } 689 692 ; 690 693 … … 790 793 | '(' type_no_function ')' cast_expression 791 794 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 792 | '(' aggregate_control '&' ')' cast_expression // CFA 793 { $$ = new ExpressionNode( build_keyword_cast( $2, $5 ) ); } 795 // keyword cast cannot be grouped because of reduction in aggregate_key 796 | '(' GENERATOR '&' ')' cast_expression // CFA 797 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Coroutine, $5 ) ); } 798 | '(' COROUTINE '&' ')' cast_expression // CFA 799 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Coroutine, $5 ) ); } 800 | '(' THREAD '&' ')' cast_expression // CFA 801 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Thread, $5 ) ); } 802 | '(' MONITOR '&' ')' cast_expression // CFA 803 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Monitor, $5 ) ); } 794 804 // VIRTUAL cannot be opt because of look ahead issues 795 805 | '(' VIRTUAL ')' cast_expression // CFA … … 955 965 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $3 ) ) ); } 956 966 | '[' push assignment_expression pop ',' tuple_expression_list ']' 957 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *) ($3->set_last( $6 ) ) )); }967 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)$3->set_last( $6 ) ) ); } 958 968 ; 959 969 … … 961 971 assignment_expression_opt 962 972 | tuple_expression_list ',' assignment_expression_opt 963 { $$ = (ExpressionNode *) ($1->set_last( $3 )); }973 { $$ = (ExpressionNode *)$1->set_last( $3 ); } 964 974 ; 965 975 … … 1185 1195 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1186 1196 OperKinds::LThan, $1->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1187 | '=' comma_expression // CFA1188 { $$ = forCtrl( $2, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),1189 OperKinds::LEThan, $2->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }1190 1197 | comma_expression inclexcl comma_expression // CFA 1191 1198 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } … … 1195 1202 { $$ = forCtrl( $3, $1, new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1196 1203 OperKinds::LThan, $3->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1197 | comma_expression ';' '=' comma_expression // CFA1198 { $$ = forCtrl( $4, $1, new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),1199 OperKinds::LEThan, $4->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }1200 1204 | comma_expression ';' comma_expression inclexcl comma_expression // CFA 1201 1205 { $$ = forCtrl( $3, $1, $3->clone(), $4, $5, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } … … 1302 1306 WAITFOR '(' cast_expression ')' 1303 1307 { $$ = $3; } 1304 // | WAITFOR '(' cast_expression ',' argument_expression_list ')' 1305 // { $$ = (ExpressionNode *)$3->set_last( $5 ); } 1306 | WAITFOR '(' cast_expression_list ':' argument_expression_list ')' 1307 { $$ = (ExpressionNode *)($3->set_last( $5 )); } 1308 ; 1309 1310 cast_expression_list: 1311 cast_expression 1312 | cast_expression_list ',' cast_expression 1313 { $$ = (ExpressionNode *)($1->set_last( $3 )); } 1308 | WAITFOR '(' cast_expression ',' argument_expression_list ')' 1309 { $$ = (ExpressionNode *)$3->set_last( $5 ); } 1314 1310 ; 1315 1311 … … 1422 1418 asm_operand 1423 1419 | asm_operands_list ',' asm_operand 1424 { $$ = (ExpressionNode *) ($1->set_last( $3 )); }1420 { $$ = (ExpressionNode *)$1->set_last( $3 ); } 1425 1421 ; 1426 1422 1427 1423 asm_operand: // GCC 1428 1424 string_literal '(' constant_expression ')' 1429 { $$ = new ExpressionNode( new AsmExpr( nullptr, $1, maybeMoveBuild< Expression >( $3 ) ) ); }1430 | '[' IDENTIFIER']' string_literal '(' constant_expression ')'1431 { $$ = new ExpressionNode( new AsmExpr( $2, $4, maybeMoveBuild< Expression >( $6 ) ) ); }1425 { $$ = new ExpressionNode( new AsmExpr( maybeMoveBuild< Expression >( (ExpressionNode *)nullptr ), $1, maybeMoveBuild< Expression >( $3 ) ) ); } 1426 | '[' constant_expression ']' string_literal '(' constant_expression ')' 1427 { $$ = new ExpressionNode( new AsmExpr( maybeMoveBuild< Expression >( $2 ), $4, maybeMoveBuild< Expression >( $6 ) ) ); } 1432 1428 ; 1433 1429 … … 1438 1434 { $$ = new ExpressionNode( $1 ); } 1439 1435 | asm_clobbers_list_opt ',' string_literal 1440 { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( $3 ) )); } 1436 // set_last returns ParseNode * 1437 { $$ = (ExpressionNode *)$1->set_last( new ExpressionNode( $3 ) ); } 1441 1438 ; 1442 1439 … … 1589 1586 // type_specifier can resolve to just TYPEDEFname (e.g., typedef int T; int f( T );). Therefore this must be 1590 1587 // flattened to allow lookahead to the '(' without having to reduce identifier_or_type_name. 1591 cfa_abstract_tuple identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')' attribute_list_opt1588 cfa_abstract_tuple identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')' 1592 1589 // To obtain LR(1 ), this rule must be factored out from function return type (see cfa_abstract_declarator). 1593 { $$ = DeclarationNode::newFunction( $2, $1, $5, 0 ) ->addQualifiers( $8 ); }1594 | cfa_function_return identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')' attribute_list_opt1595 { $$ = DeclarationNode::newFunction( $2, $1, $5, 0 ) ->addQualifiers( $8 ); }1590 { $$ = DeclarationNode::newFunction( $2, $1, $5, 0 ); } 1591 | cfa_function_return identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')' 1592 { $$ = DeclarationNode::newFunction( $2, $1, $5, 0 ); } 1596 1593 ; 1597 1594 … … 2062 2059 2063 2060 aggregate_key: 2064 aggregate_data2065 | aggregate_control2066 ;2067 2068 aggregate_data:2069 2061 STRUCT 2070 { yyy = true; $$ = AggregateDecl::Struct; }2062 { yyy = true; $$ = DeclarationNode::Struct; } 2071 2063 | UNION 2072 { yyy = true; $$ = AggregateDecl::Union; } 2073 | EXCEPTION // CFA 2074 { yyy = true; $$ = AggregateDecl::Exception; } 2075 ; 2076 2077 aggregate_control: // CFA 2078 GENERATOR 2079 { yyy = true; $$ = AggregateDecl::Coroutine; } 2064 { yyy = true; $$ = DeclarationNode::Union; } 2065 | EXCEPTION 2066 { yyy = true; $$ = DeclarationNode::Exception; } 2067 | GENERATOR 2068 { yyy = true; $$ = DeclarationNode::Coroutine; } 2080 2069 | COROUTINE 2081 { yyy = true; $$ = AggregateDecl::Coroutine; }2070 { yyy = true; $$ = DeclarationNode::Coroutine; } 2082 2071 | MONITOR 2083 { yyy = true; $$ = AggregateDecl::Monitor; }2072 { yyy = true; $$ = DeclarationNode::Monitor; } 2084 2073 | THREAD 2085 { yyy = true; $$ = AggregateDecl::Thread; }2074 { yyy = true; $$ = DeclarationNode::Thread; } 2086 2075 ; 2087 2076 … … 2107 2096 distInl( $3 ); 2108 2097 } 2109 | INLINE aggregate_control ';' // CFA2110 { SemanticError( yylloc, "INLINE aggregate control currently unimplemented." ); $$ = nullptr; }2111 2098 | typedef_declaration ';' // CFA 2112 2099 | cfa_field_declaring_list ';' // CFA, new style field declaration … … 2361 2348 | initializer_list_opt ',' initializer { $$ = (InitializerNode *)( $1->set_last( $3 ) ); } 2362 2349 | initializer_list_opt ',' designation initializer 2363 { $$ = (InitializerNode *)( $1->set_last( $4->set_designators( $3 ) )); }2350 { $$ = (InitializerNode *)( $1->set_last( $4->set_designators( $3 ) ) ); } 2364 2351 ; 2365 2352 … … 2383 2370 designator 2384 2371 | designator_list designator 2385 { $$ = (ExpressionNode *)( $1->set_last( $2 )); }2372 { $$ = (ExpressionNode *)( $1->set_last( $2 ) ); } 2386 2373 //| designator_list designator { $$ = new ExpressionNode( $1, $2 ); } 2387 2374 ; … … 2439 2426 | type_specifier identifier_parameter_declarator 2440 2427 | assertion_list 2441 { $$ = DeclarationNode::newTypeParam( TypeDecl::Dtype, new string( DeclarationNode::anonymous.newName() ) )->addAssertions( $1 ); }2428 { $$ = DeclarationNode::newTypeParam( DeclarationNode::Dtype, new string( DeclarationNode::anonymous.newName() ) )->addAssertions( $1 ); } 2442 2429 ; 2443 2430 2444 2431 type_class: // CFA 2445 2432 OTYPE 2446 { $$ = TypeDecl::Otype; }2433 { $$ = DeclarationNode::Otype; } 2447 2434 | DTYPE 2448 { $$ = TypeDecl::Dtype; }2435 { $$ = DeclarationNode::Dtype; } 2449 2436 | FTYPE 2450 { $$ = TypeDecl::Ftype; }2437 { $$ = DeclarationNode::Ftype; } 2451 2438 | TTYPE 2452 { $$ = TypeDecl::Ttype; }2439 { $$ = DeclarationNode::Ttype; } 2453 2440 ; 2454 2441 … … 2480 2467 { SemanticError( yylloc, toString("Expression generic parameters are currently unimplemented: ", $1->build()) ); $$ = nullptr; } 2481 2468 | type_list ',' type 2482 { $$ = (ExpressionNode *)( $1->set_last( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ) )); }2469 { $$ = (ExpressionNode *)( $1->set_last( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ) ) ); } 2483 2470 | type_list ',' assignment_expression 2484 2471 { SemanticError( yylloc, toString("Expression generic parameters are currently unimplemented: ", $3->build()) ); $$ = nullptr; } … … 2591 2578 { 2592 2579 linkageStack.push( linkage ); // handle nested extern "C"/"Cforall" 2593 linkage = LinkageSpec:: update( yylloc, linkage, $2 );2580 linkage = LinkageSpec::linkageUpdate( yylloc, linkage, $2 ); 2594 2581 } 2595 2582 '{' up external_definition_list_opt down '}' -
src/ResolvExpr/AdjustExprType.cc
r3d5701e r9fb8f01 10 10 // Created On : Sat May 16 23:41:42 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 11 21:43:56 201913 // Update Count : 612 // Last Modified On : Wed Mar 2 17:34:53 2016 13 // Update Count : 4 14 14 // 15 15 … … 133 133 // replace known function-type-variables with pointer-to-function 134 134 if ( const ast::EqvClass * eqvClass = tenv.lookup( inst->name ) ) { 135 if ( eqvClass->data.kind == ast::Type Decl::Ftype ) {135 if ( eqvClass->data.kind == ast::TypeVar::Ftype ) { 136 136 return new ast::PointerType{ inst }; 137 137 } 138 138 } else if ( const ast::NamedTypeDecl * ntDecl = symtab.lookupType( inst->name ) ) { 139 139 if ( auto tyDecl = dynamic_cast< const ast::TypeDecl * >( ntDecl ) ) { 140 if ( tyDecl->kind == ast::Type Decl::Ftype ) {140 if ( tyDecl->kind == ast::TypeVar::Ftype ) { 141 141 return new ast::PointerType{ inst }; 142 142 } -
src/ResolvExpr/AlternativeFinder.cc
r3d5701e r9fb8f01 69 69 void postvisit( CastExpr * castExpr ); 70 70 void postvisit( VirtualCastExpr * castExpr ); 71 void postvisit( KeywordCastExpr * castExpr );72 71 void postvisit( UntypedMemberExpr * memberExpr ); 73 72 void postvisit( MemberExpr * memberExpr ); … … 1256 1255 } 1257 1256 1258 void AlternativeFinder::Finder::postvisit( KeywordCastExpr * castExpr ) {1259 assertf( castExpr->get_result(), "Cast target should have been set in Validate." );1260 auto ref = dynamic_cast<ReferenceType*>(castExpr->get_result());1261 assert(ref);1262 auto inst = dynamic_cast<StructInstType*>(ref->base);1263 assert(inst);1264 auto target = inst->baseStruct;1265 1266 AlternativeFinder finder( indexer, env );1267 1268 auto pick_alternatives = [target, this](AltList & found, bool expect_ref) {1269 for(auto & alt : found) {1270 Type * expr = alt.expr->get_result();1271 if(expect_ref) {1272 auto res = dynamic_cast<ReferenceType*>(expr);1273 if(!res) { continue; }1274 expr = res->base;1275 }1276 1277 if(auto insttype = dynamic_cast<TypeInstType*>(expr)) {1278 auto td = alt.env.lookup(insttype->name);1279 if(!td) { continue; }1280 expr = td->type;1281 }1282 1283 if(auto base = dynamic_cast<StructInstType*>(expr)) {1284 if(base->baseStruct == target) {1285 alternatives.push_back(1286 std::move(alt)1287 );1288 }1289 }1290 }1291 };1292 1293 try {1294 // Attempt 1 : turn (thread&)X into ($thread&)X.__thrd1295 // Clone is purely for memory management1296 std::unique_ptr<Expression> tech1 { new UntypedMemberExpr(new NameExpr(castExpr->concrete_target.field), castExpr->arg->clone()) };1297 1298 // don't prune here, since it's guaranteed all alternatives will have the same type1299 finder.findWithoutPrune( tech1.get() );1300 pick_alternatives(finder.alternatives, false);1301 1302 return;1303 } catch(SemanticErrorException & ) {}1304 1305 // Fallback : turn (thread&)X into ($thread&)get_thread(X)1306 std::unique_ptr<Expression> fallback { UntypedExpr::createDeref( new UntypedExpr(new NameExpr(castExpr->concrete_target.getter), { castExpr->arg->clone() })) };1307 // don't prune here, since it's guaranteed all alternatives will have the same type1308 finder.findWithoutPrune( fallback.get() );1309 1310 pick_alternatives(finder.alternatives, true);1311 1312 // Whatever happens here, we have no more fallbacks1313 }1314 1315 1257 namespace { 1316 1258 /// Gets name from untyped member expression (member must be NameExpr) -
src/ResolvExpr/ConversionCost.cc
r3d5701e r9fb8f01 157 157 if ( typesCompatibleIgnoreQualifiers( src, destAsRef->base, indexer, env ) ) { 158 158 PRINT( std::cerr << "converting compatible base type" << std::endl; ) 159 assert( src->get_lvalue() == srcIsLvalue ); 159 160 if ( srcIsLvalue ) { 160 161 PRINT( -
src/ResolvExpr/PtrsCastable.cc
r3d5701e r9fb8f01 10 10 // Created On : Sun May 17 11:48:00 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 11 21:48:33 201913 // Update Count : 912 // Last Modified On : Wed Mar 2 17:36:18 2016 13 // Update Count : 8 14 14 // 15 15 … … 176 176 if ( const ast::NamedTypeDecl * named = symtab.lookupType( inst->name ) ) { 177 177 if ( auto tyDecl = dynamic_cast< const ast::TypeDecl * >( named ) ) { 178 if ( tyDecl->kind == ast::Type Decl::Ftype ) {178 if ( tyDecl->kind == ast::TypeVar::Ftype ) { 179 179 return -1; 180 180 } 181 181 } 182 182 } else if ( const ast::EqvClass * eqvClass = env.lookup( inst->name ) ) { 183 if ( eqvClass->data.kind == ast::Type Decl::Ftype ) {183 if ( eqvClass->data.kind == ast::TypeVar::Ftype ) { 184 184 return -1; 185 185 } -
src/ResolvExpr/ResolveAssertions.cc
r3d5701e r9fb8f01 156 156 for ( const auto& assn : x.assns ) { 157 157 // compute conversion cost from satisfying decl to assertion 158 assert( !assn.match.adjType->get_lvalue() ); 158 159 k += computeConversionCost( 159 160 assn.match.adjType, assn.decl->get_type(), false, indexer, x.env ); -
src/ResolvExpr/Resolver.cc
r3d5701e r9fb8f01 84 84 void previsit( ThrowStmt * throwStmt ); 85 85 void previsit( CatchStmt * catchStmt ); 86 void postvisit( CatchStmt * catchStmt );87 86 void previsit( WaitForStmt * stmt ); 88 87 … … 486 485 visit_children = false; 487 486 findVoidExpression( asmExpr->operand, indexer ); 487 if ( asmExpr->get_inout() ) { 488 findVoidExpression( asmExpr->inout, indexer ); 489 } // if 488 490 } 489 491 … … 568 570 569 571 void Resolver_old::previsit( CatchStmt * catchStmt ) { 570 // Until we are very sure this invarent (ifs that move between passes have thenPart)571 // holds, check it. This allows a check for when to decode the mangling.572 if ( IfStmt * ifStmt = dynamic_cast<IfStmt *>( catchStmt->body ) ) {573 assert( ifStmt->thenPart );574 }575 // Encode the catchStmt so the condition can see the declaration.576 572 if ( catchStmt->cond ) { 577 IfStmt * ifStmt = new IfStmt( catchStmt->cond, nullptr, catchStmt->body ); 578 catchStmt->cond = nullptr; 579 catchStmt->body = ifStmt; 580 } 581 } 582 583 void Resolver_old::postvisit( CatchStmt * catchStmt ) { 584 // Decode the catchStmt so everything is stored properly. 585 IfStmt * ifStmt = dynamic_cast<IfStmt *>( catchStmt->body ); 586 if ( nullptr != ifStmt && nullptr == ifStmt->thenPart ) { 587 assert( ifStmt->condition ); 588 assert( ifStmt->elsePart ); 589 catchStmt->cond = ifStmt->condition; 590 catchStmt->body = ifStmt->elsePart; 591 ifStmt->condition = nullptr; 592 ifStmt->elsePart = nullptr; 593 delete ifStmt; 573 findSingleExpression( catchStmt->cond, new BasicType( noQualifiers, BasicType::Bool ), indexer ); 594 574 } 595 575 } … … 1386 1366 asmExpr, &ast::AsmExpr::operand, findVoidExpression( asmExpr->operand, symtab ) ); 1387 1367 1368 if ( asmExpr->inout ) { 1369 asmExpr = ast::mutate_field( 1370 asmExpr, &ast::AsmExpr::inout, findVoidExpression( asmExpr->inout, symtab ) ); 1371 } 1372 1388 1373 return asmExpr; 1389 1374 } … … 1489 1474 1490 1475 const ast::CatchStmt * Resolver_new::previsit( const ast::CatchStmt * catchStmt ) { 1491 // TODO: This will need a fix for the decl/cond scoping problem.1492 1476 if ( catchStmt->cond ) { 1493 1477 ast::ptr< ast::Type > boolType = new ast::BasicType{ ast::BasicType::Bool }; -
src/ResolvExpr/Unify.cc
r3d5701e r9fb8f01 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 12:27:10 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Dec 13 23:43:05 201913 // Update Count : 4 611 // Last Modified By : Aaron B. Moss 12 // Last Modified On : Mon Jun 18 11:58:00 2018 13 // Update Count : 43 14 14 // 15 15 … … 32 32 #include "Common/PassVisitor.h" // for PassVisitor 33 33 #include "FindOpenVars.h" // for findOpenVars 34 #include " SynTree/LinkageSpec.h"// for C34 #include "Parser/LinkageSpec.h" // for C 35 35 #include "SynTree/Constant.h" // for Constant 36 36 #include "SynTree/Declaration.h" // for TypeDecl, TypeDecl::Data, Declarati... … … 278 278 #endif 279 279 if ( ( common = commonType( type1, type2, widen.first, widen.second, indexer, env, openVars ) ) ) { 280 common-> tq = tq1.unify( tq2 );280 common->get_qualifiers() = tq1 | tq2; 281 281 #ifdef DEBUG 282 282 std::cerr << "unifyInexact: common type is "; … … 295 295 if ( ( tq1 > tq2 || widen.first ) && ( tq2 > tq1 || widen.second ) ) { 296 296 common = type1->clone(); 297 common-> tq = tq1.unify( tq2 );297 common->get_qualifiers() = tq1 | tq2; 298 298 result = true; 299 299 } else { … … 302 302 } else { 303 303 common = type1->clone(); 304 common-> tq = tq1.unify( tq2 );304 common->get_qualifiers() = tq1 | tq2; 305 305 result = true; 306 306 } // if … … 781 781 if ( const ast::EqvClass * clz = tenv.lookup( typeInst->name ) ) { 782 782 // expand ttype parameter into its actual type 783 if ( clz->data.kind == ast::Type Decl::Ttype && clz->bound ) {783 if ( clz->data.kind == ast::TypeVar::Ttype && clz->bound ) { 784 784 return clz->bound; 785 785 } -
src/SymTab/Autogen.h
r3d5701e r9fb8f01 10 10 // Created On : Sun May 17 21:53:34 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 13 16:38:06 201913 // Update Count : 1 612 // Last Modified On : Sat Jul 22 09:50:25 2017 13 // Update Count : 15 14 14 // 15 15 … … 34 34 #include "SynTree/Expression.h" // for NameExpr, ConstantExpr, UntypedExpr... 35 35 #include "SynTree/Type.h" // for Type, ArrayType, Type::Qualifiers 36 #include "SynTree/Statement.h" // for CompoundStmt, DeclStmt, ExprStmt37 36 38 37 class CompoundStmt; … … 98 97 // type->get_qualifiers() = Type::Qualifiers(); 99 98 Type * castType = addCast->clone(); 100 castType->get_qualifiers() -= Type::Qualifiers( Type:: Const | Type::Volatile | Type::Restrict | Type::Atomic );99 castType->get_qualifiers() -= Type::Qualifiers( Type::Lvalue | Type::Const | Type::Volatile | Type::Restrict | Type::Atomic ); 101 100 // castType->set_lvalue( true ); // xxx - might not need this 102 101 dstParam = new CastExpr( dstParam, new ReferenceType( Type::Qualifiers(), castType ) ); -
src/SymTab/Demangle.cc
r3d5701e r9fb8f01 10 10 // Created On : Thu Jul 19 12:52:41 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 11 15:09:18 202013 // Update Count : 1012 // Last Modified On : Tue Jul 30 13:46:33 2019 13 // Update Count : 3 14 14 // 15 15 … … 19 19 #include "CodeGen/GenType.h" 20 20 #include "Common/PassVisitor.h" 21 #include "Common/utility.h" // isPrefix22 21 #include "Mangler.h" 23 22 #include "SynTree/Type.h" … … 367 366 // type variable types 368 367 for (size_t k = 0; k < TypeDecl::NUMBER_OF_KINDS; ++k) { 369 static const std::string typeVariableNames[] = { "DT", " OT", "FT", "TT", };368 static const std::string typeVariableNames[] = { "DT", "FT", "TT", }; 370 369 static_assert( 371 370 sizeof(typeVariableNames)/sizeof(typeVariableNames[0]) == TypeDecl::NUMBER_OF_KINDS, … … 417 416 418 417 bool StringView::isPrefix(const std::string & pref) { 419 // if ( pref.size() > str.size()-idx ) return false; 420 // auto its = std::mismatch( pref.begin(), pref.end(), std::next(str.begin(), idx) ); 421 // if (its.first == pref.end()) { 422 // idx += pref.size(); 423 // return true; 424 // } 425 426 // This update is untested because there are no tests for this code. 427 if ( ::isPrefix( str, pref, idx ) ) { 418 if ( pref.size() > str.size()-idx ) return false; 419 auto its = std::mismatch( pref.begin(), pref.end(), std::next(str.begin(), idx) ); 420 if (its.first == pref.end()) { 428 421 idx += pref.size(); 429 422 return true; … … 436 429 PRINT( std::cerr << "====== " << str.size() << " " << str << std::endl; ) 437 430 if (str.size() < 2+Encoding::manglePrefix.size()) return false; // +2 for at least _1 suffix 438 if ( ! isPrefix(Encoding::manglePrefix) || ! isdigit(str.back() )) return false;431 if (! isPrefix(Encoding::manglePrefix) || ! isdigit(str.back())) return false; 439 432 440 433 // get name -
src/SymTab/Indexer.cc
r3d5701e r9fb8f01 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 21:37:33 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Dec 13 23:43:19201913 // Update Count : 2 211 // Last Modified By : Aaron B. Moss 12 // Last Modified On : Fri Mar 8 13:55:00 2019 13 // Update Count : 21 14 14 // 15 15 … … 31 31 #include "InitTweak/InitTweak.h" // for isConstructor, isCopyFunction, isC... 32 32 #include "Mangler.h" // for Mangler 33 #include "Parser/LinkageSpec.h" // for isMangled, isOverridable, Spec 33 34 #include "ResolvExpr/typeops.h" // for typesCompatible 34 #include "SynTree/LinkageSpec.h" // for isMangled, isOverridable, Spec35 35 #include "SynTree/Constant.h" // for Constant 36 36 #include "SynTree/Declaration.h" // for DeclarationWithType, FunctionDecl -
src/SymTab/Mangler.cc
r3d5701e r9fb8f01 10 10 // Created On : Sun May 17 21:40:29 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 15 13:55:12 202013 // Update Count : 3312 // Last Modified On : Tue Jul 30 13:46:10 2019 13 // Update Count : 26 14 14 // 15 15 #include "Mangler.h" … … 26 26 #include "Common/SemanticError.h" // for SemanticError 27 27 #include "Common/utility.h" // for toString 28 #include "Parser/LinkageSpec.h" // for Spec, isOverridable, AutoGen, Int... 28 29 #include "ResolvExpr/TypeEnvironment.h" // for TypeEnvironment 29 #include "SynTree/LinkageSpec.h" // for Spec, isOverridable, AutoGen, Int...30 30 #include "SynTree/Declaration.h" // for TypeDecl, DeclarationWithType 31 31 #include "SynTree/Expression.h" // for TypeExpr, Expression, operator<< … … 128 128 } // if 129 129 mangleName << Encoding::manglePrefix; 130 const CodeGen::OperatorInfo * opInfo = CodeGen::operatorLookup( declaration->get_name() );131 if ( op Info) {132 mangleName << opInfo ->outputName.size() << opInfo->outputName;130 CodeGen::OperatorInfo opInfo; 131 if ( operatorLookup( declaration->get_name(), opInfo ) ) { 132 mangleName << opInfo.outputName.size() << opInfo.outputName; 133 133 } else { 134 134 mangleName << declaration->name.size() << declaration->name; … … 471 471 } // if 472 472 mangleName << Encoding::manglePrefix; 473 const CodeGen::OperatorInfo * opInfo = CodeGen::operatorLookup( decl->name );474 if ( op Info) {475 mangleName << opInfo ->outputName.size() << opInfo->outputName;473 CodeGen::OperatorInfo opInfo; 474 if ( operatorLookup( decl->name, opInfo ) ) { 475 mangleName << opInfo.outputName.size() << opInfo.outputName; 476 476 } else { 477 477 mangleName << decl->name.size() << decl->name; … … 654 654 // aside from the assert false. 655 655 assertf(false, "Mangler_new should not visit typedecl: %s", toCString(decl)); 656 assertf( decl->kind < ast::Type Decl::Kind::NUMBER_OF_KINDS, "Unhandled type variable kind: %d", decl->kind );656 assertf( decl->kind < ast::TypeVar::Kind::NUMBER_OF_KINDS, "Unhandled type variable kind: %d", decl->kind ); 657 657 mangleName << Encoding::typeVariables[ decl->kind ] << ( decl->name.length() ) << decl->name; 658 658 } … … 674 674 for ( const ast::TypeDecl * decl : ptype->forall ) { 675 675 switch ( decl->kind ) { 676 case ast::Type Decl::Kind::Dtype:676 case ast::TypeVar::Kind::Dtype: 677 677 dcount++; 678 678 break; 679 case ast::Type Decl::Kind::Ftype:679 case ast::TypeVar::Kind::Ftype: 680 680 fcount++; 681 681 break; 682 case ast::Type Decl::Kind::Ttype:682 case ast::TypeVar::Kind::Ttype: 683 683 vcount++; 684 684 break; -
src/SymTab/ManglerCommon.cc
r3d5701e r9fb8f01 10 10 // Created On : Sun May 17 21:44:03 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 13 14:54:38201913 // Update Count : 2 812 // Last Modified On : Thu Feb 14 17:06:37 2019 13 // Update Count : 26 14 14 // 15 15 … … 88 88 { Type::Atomic, "DA" }, // A is array, so need something unique for atmoic. For now, go with multiletter DA 89 89 { Type::Mutex, "X" }, 90 { Type::Lvalue, "L" }, 90 91 }; 91 92 … … 104 105 const std::string typeVariables[] = { 105 106 "BD", // dtype 106 "BO", // otype107 107 "BF", // ftype 108 108 "BT", // ttype -
src/SymTab/Validate.cc
r3d5701e r9fb8f01 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 21:50:04 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Dec 13 23:43:34201913 // Update Count : 36 311 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 7 6:42:00 2019 13 // Update Count : 360 14 14 // 15 15 … … 69 69 #include "InitTweak/GenInit.h" // for fixReturnStatements 70 70 #include "InitTweak/InitTweak.h" // for isCtorDtorAssign 71 #include "Parser/LinkageSpec.h" // for C 71 72 #include "ResolvExpr/typeops.h" // for typesCompatible 72 73 #include "ResolvExpr/Resolver.h" // for findSingleExpression 73 74 #include "ResolvExpr/ResolveTypeof.h" // for resolveTypeof 74 75 #include "SymTab/Autogen.h" // for SizeType 75 #include "SynTree/LinkageSpec.h" // for C76 76 #include "SynTree/Attribute.h" // for noAttributes, Attribute 77 77 #include "SynTree/Constant.h" // for Constant … … 81 81 #include "SynTree/Label.h" // for operator==, Label 82 82 #include "SynTree/Mutator.h" // for Mutator 83 #include "SynTree/TopLvalue.h" // for assertTopLvalue, clearInnerLvalue 83 84 #include "SynTree/Type.h" // for Type, TypeInstType, EnumInstType 84 85 #include "SynTree/TypeSubstitution.h" // for TypeSubstitution … … 308 309 PassVisitor<FixQualifiedTypes> fixQual; 309 310 311 assertTopLvalue( translationUnit ); 310 312 { 311 313 Stats::Heap::newPass("validate-A"); 312 314 Stats::Time::BlockGuard guard("validate-A"); 313 VerifyCtorDtorAssign::verify( translationUnit ); // must happen before autogen, because autogen examines existing ctor/dtors314 315 acceptAll( translationUnit, hoistDecls ); 315 316 ReplaceTypedef::replaceTypedef( translationUnit ); … … 317 318 acceptAll( translationUnit, epc ); // must happen before VerifyCtorDtorAssign, because void return objects should not exist; before LinkReferenceToTypes_old because it is an indexer and needs correct types for mangling 318 319 } 320 assertTopLvalue( translationUnit ); 319 321 { 320 322 Stats::Heap::newPass("validate-B"); 321 323 Stats::Time::BlockGuard guard("validate-B"); 324 assertTopLvalue( translationUnit ); 322 325 Stats::Time::TimeBlock("Link Reference To Types", [&]() { 323 326 acceptAll( translationUnit, lrt ); // must happen before autogen, because sized flag needs to propagate to generated functions 324 327 }); 328 clearInnerLvalue( translationUnit ); 329 assertTopLvalue( translationUnit ); 325 330 Stats::Time::TimeBlock("Fix Qualified Types", [&]() { 326 331 mutateAll( translationUnit, fixQual ); // must happen after LinkReferenceToTypes_old, because aggregate members are accessed 327 332 }); 333 assertTopLvalue( translationUnit ); 328 334 Stats::Time::TimeBlock("Hoist Structs", [&]() { 329 335 HoistStruct::hoistStruct( translationUnit ); // must happen after EliminateTypedef, so that aggregate typedefs occur in the correct order 330 336 }); 337 assertTopLvalue( translationUnit ); 331 338 Stats::Time::TimeBlock("Eliminate Typedefs", [&]() { 332 339 EliminateTypedef::eliminateTypedef( translationUnit ); // 333 340 }); 334 341 } 342 assertTopLvalue( translationUnit ); 335 343 { 336 344 Stats::Heap::newPass("validate-C"); 337 345 Stats::Time::BlockGuard guard("validate-C"); 338 346 acceptAll( translationUnit, genericParams ); // check as early as possible - can't happen before LinkReferenceToTypes_old 347 VerifyCtorDtorAssign::verify( translationUnit ); // must happen before autogen, because autogen examines existing ctor/dtors 339 348 ReturnChecker::checkFunctionReturns( translationUnit ); 340 349 InitTweak::fixReturnStatements( translationUnit ); // must happen before autogen 341 350 } 351 assertTopLvalue( translationUnit ); 342 352 { 343 353 Stats::Heap::newPass("validate-D"); 344 354 Stats::Time::BlockGuard guard("validate-D"); 355 assertTopLvalue( translationUnit ); 345 356 Stats::Time::TimeBlock("Apply Concurrent Keywords", [&]() { 346 357 Concurrency::applyKeywords( translationUnit ); 347 358 }); 359 clearInnerLvalue( translationUnit ); 360 assertTopLvalue( translationUnit ); 348 361 Stats::Time::TimeBlock("Forall Pointer Decay", [&]() { 349 362 acceptAll( translationUnit, fpd ); // must happen before autogenerateRoutines, after Concurrency::applyKeywords because uniqueIds must be set on declaration before resolution 350 363 }); 364 assertTopLvalue( translationUnit ); 351 365 Stats::Time::TimeBlock("Hoist Control Declarations", [&]() { 352 366 ControlStruct::hoistControlDecls( translationUnit ); // hoist initialization out of for statements; must happen before autogenerateRoutines 353 367 }); 368 assertTopLvalue( translationUnit ); 354 369 Stats::Time::TimeBlock("Generate Autogen routines", [&]() { 355 370 autogenerateRoutines( translationUnit ); // moved up, used to be below compoundLiteral - currently needs EnumAndPointerDecay_old 356 371 }); 357 } 372 clearInnerLvalue( translationUnit ); 373 } 374 assertTopLvalue( translationUnit ); 358 375 { 359 376 Stats::Heap::newPass("validate-E"); 360 377 Stats::Time::BlockGuard guard("validate-E"); 378 assertTopLvalue( translationUnit ); 361 379 Stats::Time::TimeBlock("Implement Mutex Func", [&]() { 362 380 Concurrency::implementMutexFuncs( translationUnit ); 363 381 }); 382 clearInnerLvalue( translationUnit ); 383 assertTopLvalue( translationUnit ); 364 384 Stats::Time::TimeBlock("Implement Thread Start", [&]() { 365 385 Concurrency::implementThreadStarter( translationUnit ); 366 386 }); 387 assertTopLvalue( translationUnit ); 367 388 Stats::Time::TimeBlock("Compound Literal", [&]() { 368 389 mutateAll( translationUnit, compoundliteral ); 369 390 }); 391 assertTopLvalue( translationUnit ); 370 392 Stats::Time::TimeBlock("Resolve With Expressions", [&]() { 371 393 ResolvExpr::resolveWithExprs( translationUnit ); // must happen before FixObjectType because user-code is resolved and may contain with variables 372 394 }); 373 } 395 clearInnerLvalue( translationUnit ); 396 } 397 assertTopLvalue( translationUnit ); 374 398 { 375 399 Stats::Heap::newPass("validate-F"); 376 400 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); 387 } 401 assertTopLvalue( translationUnit ); 402 Stats::Time::TimeBlock("Fix Object Type", [&]() { 403 FixObjectType::fix( translationUnit ); 404 }); 405 assertTopLvalue( translationUnit ); 406 Stats::Time::TimeBlock("Array Length", [&]() { 407 ArrayLength::computeLength( translationUnit ); 408 }); 409 clearInnerLvalue( translationUnit ); 410 assertTopLvalue( translationUnit ); 411 Stats::Time::TimeBlock("Find Special Declarations", [&]() { 412 Validate::findSpecialDecls( translationUnit ); 413 }); 414 assertTopLvalue( translationUnit ); 415 Stats::Time::TimeBlock("Fix Label Address", [&]() { 416 mutateAll( translationUnit, labelAddrFixer ); 417 }); 418 assertTopLvalue( translationUnit ); 419 Stats::Time::TimeBlock("Handle Attributes", [&]() { 420 Validate::handleAttributes( translationUnit ); 421 }); 422 } 423 assertTopLvalue( translationUnit ); 388 424 } 389 425 … … 1044 1080 Type * designatorType = tyDecl->base->stripDeclarator(); 1045 1081 if ( StructInstType * aggDecl = dynamic_cast< StructInstType * >( designatorType ) ) { 1046 declsToAddBefore.push_back( new StructDecl( aggDecl->name, AggregateDecl::Struct, noAttributes, tyDecl->linkage ) );1082 declsToAddBefore.push_back( new StructDecl( aggDecl->name, DeclarationNode::Struct, noAttributes, tyDecl->linkage ) ); 1047 1083 } else if ( UnionInstType * aggDecl = dynamic_cast< UnionInstType * >( designatorType ) ) { 1048 1084 declsToAddBefore.push_back( new UnionDecl( aggDecl->name, noAttributes, tyDecl->linkage ) ); … … 1182 1218 if ( CodeGen::isCtorDtorAssign( funcDecl->get_name() ) ) { // TODO: also check /=, etc. 1183 1219 if ( params.size() == 0 ) { 1184 SemanticError( funcDecl ->location, "Constructors, destructors, and assignment functions require at least one parameter." );1220 SemanticError( funcDecl, "Constructors, destructors, and assignment functions require at least one parameter " ); 1185 1221 } 1186 1222 ReferenceType * refType = dynamic_cast< ReferenceType * >( params.front()->get_type() ); 1187 1223 if ( ! refType ) { 1188 SemanticError( funcDecl ->location, "First parameter of a constructor, destructor, or assignment function must be a reference." );1224 SemanticError( funcDecl, "First parameter of a constructor, destructor, or assignment function must be a reference " ); 1189 1225 } 1190 1226 if ( CodeGen::isCtorDtor( funcDecl->get_name() ) && returnVals.size() != 0 ) { 1191 if(!returnVals.front()->get_type()->isVoid()) { 1192 SemanticError( funcDecl->location, "Constructors and destructors cannot have explicit return values." ); 1193 } 1227 SemanticError( funcDecl, "Constructors and destructors cannot have explicit return values " ); 1194 1228 } 1195 1229 } … … 1300 1334 void FixObjectType::previsit( ObjectDecl * objDecl ) { 1301 1335 Type * new_type = ResolvExpr::resolveTypeof( objDecl->get_type(), indexer ); 1336 new_type->get_qualifiers() -= Type::Lvalue; // even if typeof is lvalue, variable can never have lvalue-qualified type 1302 1337 objDecl->set_type( new_type ); 1303 1338 } … … 1305 1340 void FixObjectType::previsit( FunctionDecl * funcDecl ) { 1306 1341 Type * new_type = ResolvExpr::resolveTypeof( funcDecl->type, indexer ); 1342 new_type->get_qualifiers() -= Type::Lvalue; // even if typeof is lvalue, variable can never have lvalue-qualified type 1307 1343 funcDecl->set_type( new_type ); 1308 1344 } … … 1311 1347 if ( typeDecl->get_base() ) { 1312 1348 Type * new_type = ResolvExpr::resolveTypeof( typeDecl->get_base(), indexer ); 1349 new_type->get_qualifiers() -= Type::Lvalue; // even if typeof is lvalue, variable can never have lvalue-qualified type 1313 1350 typeDecl->set_base( new_type ); 1314 1351 } // if -
src/SynTree/AddressExpr.cc
r3d5701e r9fb8f01 53 53 } // if 54 54 } 55 // result of & is never an lvalue 56 get_result()->set_lvalue( false ); 55 57 } 56 58 } -
src/SynTree/AggregateDecl.cc
r3d5701e r9fb8f01 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 23:56:39 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Mon Dec 16 15:07:20 201913 // Update Count : 3111 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Aug 4 14:22:00 2017 13 // Update Count : 22 14 14 // 15 15 … … 21 21 #include "Common/utility.h" // for printAll, cloneAll, deleteAll 22 22 #include "Declaration.h" // for AggregateDecl, TypeDecl, Declaration 23 #include "Initializer.h" 24 #include "LinkageSpec.h" // for Spec, linkageName, Cforall 23 #include "Parser/LinkageSpec.h" // for Spec, linkageName, Cforall 25 24 #include "Type.h" // for Type, Type::StorageClasses 26 25 27 28 // These must harmonize with the corresponding AggregateDecl::Aggregate enumerations.29 static const char * aggregateNames[] = { "struct", "union", "enum", "exception", "trait", "generator", "coroutine", "monitor", "thread", "NoAggregateName" };30 31 const char * AggregateDecl::aggrString( AggregateDecl::Aggregate aggr ) {32 return aggregateNames[aggr];33 }34 26 35 27 AggregateDecl::AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes, LinkageSpec::Spec linkage ) : Parent( name, Type::StorageClasses(), linkage ), body( false ), attributes( attributes ) { … … 55 47 os << typeString() << " " << name << ":"; 56 48 if ( get_linkage() != LinkageSpec::Cforall ) { 57 os << " " << LinkageSpec:: name( linkage );49 os << " " << LinkageSpec::linkageName( linkage ); 58 50 } // if 59 51 os << " with body " << has_body(); … … 86 78 } 87 79 88 const char * StructDecl::typeString() const { return aggrString( kind ); }80 std::string StructDecl::typeString() const { return "struct"; } 89 81 90 const char * UnionDecl::typeString() const { return aggrString( Union ); }82 std::string UnionDecl::typeString() const { return "union"; } 91 83 92 const char * EnumDecl::typeString() const { return aggrString( Enum ); }84 std::string EnumDecl::typeString() const { return "enum"; } 93 85 94 const char * TraitDecl::typeString() const { return aggrString( Trait ); }86 std::string TraitDecl::typeString() const { return "trait"; } 95 87 96 88 bool EnumDecl::valueOf( Declaration * enumerator, long long int & value ) { -
src/SynTree/ApplicationExpr.cc
r3d5701e r9fb8f01 25 25 #include "Declaration.h" // for Declaration 26 26 #include "Expression.h" // for ParamEntry, ApplicationExpr, Expression 27 #include "InitTweak/InitTweak.h" // for getFunction28 27 #include "ResolvExpr/typeops.h" // for extractResultType 29 28 #include "Type.h" // for Type, PointerType, FunctionType … … 78 77 79 78 bool ApplicationExpr::get_lvalue() const { 80 // from src/GenPoly/Lvalue.cc: isIntrinsicReference 81 static std::set<std::string> lvalueFunctions = { "*?", "?[?]" }; 82 if ( const DeclarationWithType * func = InitTweak::getFunction( this ) ) { 83 return func->linkage == LinkageSpec::Intrinsic && lvalueFunctions.count(func->name); 84 } 85 return false; 79 return result->get_lvalue(); 86 80 } 87 81 -
src/SynTree/ArrayType.cc
r3d5701e r9fb8f01 26 26 ArrayType::ArrayType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes ) 27 27 : Type( tq, attributes ), base( base ), dimension( dimension ), isVarLen( isVarLen ), isStatic( isStatic ) { 28 base->set_lvalue( false ); 28 29 } 29 30 -
src/SynTree/Attribute.h
r3d5701e r9fb8f01 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 13 21:34:08 202013 // Update Count : 4012 // Last Modified On : Sat Jul 22 09:54:14 2017 13 // Update Count : 39 14 14 // 15 15 … … 38 38 virtual ~Attribute(); 39 39 40 const std::string &get_name() const { return name; }40 std::string get_name() const { return name; } 41 41 void set_name( const std::string & newValue ) { name = newValue; } 42 42 std::list< Expression * > & get_parameters() { return parameters; } -
src/SynTree/CommaExpr.cc
r3d5701e r9fb8f01 23 23 CommaExpr::CommaExpr( Expression *arg1, Expression *arg2 ) 24 24 : Expression(), arg1( arg1 ), arg2( arg2 ) { 25 // xxx - result of a comma expression is never an lvalue, so should set lvalue 26 // to false on all result types. Actually doing this causes some strange things 27 // to happen in later passes (particularly, Specialize, Lvalue, and Box). This needs to be looked into. 25 28 set_result( maybeClone( arg2->get_result() ) ); 29 // get_type->set_isLvalue( false ); 26 30 } 27 31 … … 36 40 37 41 bool CommaExpr::get_lvalue() const { 38 // This is wrong by C, but the current implementation uses it. 39 // (ex: Specialize, Lvalue and Box) 40 return arg2->get_lvalue(); 42 // xxx - as above, shouldn't be an lvalue but that information is used anyways. 43 return result->get_lvalue(); 41 44 } 42 45 -
src/SynTree/Declaration.cc
r3d5701e r9fb8f01 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Dec 11 16:39:56 201913 // Update Count : 3611 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 9 14:38:00 2017 13 // Update Count : 25 14 14 // 15 15 … … 24 24 #include "SynTree/Statement.h" // for AsmStmt 25 25 #include "SynTree/SynTree.h" // for UniqueId 26 #include "SynTree/Expression.h"27 26 #include "Type.h" // for Type, Type::StorageClasses 28 27 29 // To canonicalize declarations30 28 static UniqueId lastUniqueId = 0; 31 29 -
src/SynTree/Declaration.h
r3d5701e r9fb8f01 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Dec 13 23:11:22201913 // Update Count : 1 5711 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr May 2 10:47:00 2019 13 // Update Count : 135 14 14 // 15 15 … … 24 24 #include "BaseSyntaxNode.h" // for BaseSyntaxNode 25 25 #include "Mutator.h" // for Mutator 26 #include "LinkageSpec.h" // for Spec, Cforall 26 #include "Parser/LinkageSpec.h" // for Spec, Cforall 27 #include "Parser/ParseNode.h" // for DeclarationNode, DeclarationNode::Ag... 27 28 #include "SynTree.h" // for UniqueId 28 29 #include "SynTree/Type.h" // for Type, Type::StorageClasses, Type::Fu... … … 43 44 bool extension = false; 44 45 45 Declaration( const std::string & name, Type::StorageClasses scs, LinkageSpec::Spec linkage );46 Declaration( const Declaration & other );46 Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage ); 47 Declaration( const Declaration &other ); 47 48 virtual ~Declaration(); 48 49 49 const std::string & get_name() const { return name; }50 const std::string &get_name() const { return name; } 50 51 void set_name( std::string newValue ) { name = newValue; } 51 52 … … 58 59 59 60 bool get_extension() const { return extension; } 60 Declaration * set_extension( bool exten ) { extension = exten; return this; }61 Declaration *set_extension( bool exten ) { extension = exten; return this; } 61 62 62 63 void fixUniqueId( void ); 63 virtual Declaration * clone() const override = 0;64 virtual Declaration *clone() const override = 0; 64 65 virtual void accept( Visitor & v ) override = 0; 65 66 virtual void accept( Visitor & v ) const override = 0; 66 virtual Declaration * acceptMutator( Mutator &m ) override = 0;67 virtual void print( std::ostream & os, Indenter indent = {} ) const override = 0;68 virtual void printShort( std::ostream & os, Indenter indent = {} ) const = 0;67 virtual Declaration *acceptMutator( Mutator &m ) override = 0; 68 virtual void print( std::ostream &os, Indenter indent = {} ) const override = 0; 69 virtual void printShort( std::ostream &os, Indenter indent = {} ) const = 0; 69 70 70 71 UniqueId uniqueId; … … 80 81 int scopeLevel = 0; 81 82 82 Expression * asmName;83 Expression *asmName; 83 84 std::list< Attribute * > attributes; 84 85 bool isDeleted = false; 85 86 86 DeclarationWithType( const std::string & name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, Type::FuncSpecifiers fs );87 DeclarationWithType( const DeclarationWithType & other );87 DeclarationWithType( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, Type::FuncSpecifiers fs ); 88 DeclarationWithType( const DeclarationWithType &other ); 88 89 virtual ~DeclarationWithType(); 89 90 … … 96 97 DeclarationWithType * set_scopeLevel( int newValue ) { scopeLevel = newValue; return this; } 97 98 98 Expression * get_asmName() const { return asmName; }99 DeclarationWithType * set_asmName( Expression * newValue ) { asmName = newValue; return this; }99 Expression *get_asmName() const { return asmName; } 100 DeclarationWithType * set_asmName( Expression *newValue ) { asmName = newValue; return this; } 100 101 101 102 std::list< Attribute * >& get_attributes() { return attributes; } … … 105 106 //void set_functionSpecifiers( Type::FuncSpecifiers newValue ) { fs = newValue; } 106 107 107 virtual DeclarationWithType * clone() const override = 0;108 virtual DeclarationWithType * acceptMutator( Mutator &m ) override = 0;108 virtual DeclarationWithType *clone() const override = 0; 109 virtual DeclarationWithType *acceptMutator( Mutator &m ) override = 0; 109 110 110 111 virtual Type * get_type() const = 0; … … 118 119 typedef DeclarationWithType Parent; 119 120 public: 120 Type * type;121 Initializer * init;122 Expression * bitfieldWidth;123 124 ObjectDecl( const std::string & name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression * bitfieldWidth, Type * type, Initializer *init,121 Type *type; 122 Initializer *init; 123 Expression *bitfieldWidth; 124 125 ObjectDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, 125 126 const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() ); 126 ObjectDecl( const ObjectDecl & other );127 ObjectDecl( const ObjectDecl &other ); 127 128 virtual ~ObjectDecl(); 128 129 129 130 virtual Type * get_type() const override { return type; } 130 virtual void set_type(Type * newType) override { type = newType; }131 132 Initializer * get_init() const { return init; }133 void set_init( Initializer * newValue ) { init = newValue; }134 135 Expression * get_bitfieldWidth() const { return bitfieldWidth; }136 void set_bitfieldWidth( Expression * newValue ) { bitfieldWidth = newValue; }131 virtual void set_type(Type *newType) override { type = newType; } 132 133 Initializer *get_init() const { return init; } 134 void set_init( Initializer *newValue ) { init = newValue; } 135 136 Expression *get_bitfieldWidth() const { return bitfieldWidth; } 137 void set_bitfieldWidth( Expression *newValue ) { bitfieldWidth = newValue; } 137 138 138 139 static ObjectDecl * newObject( const std::string & name, Type * type, Initializer * init ); 139 140 140 virtual ObjectDecl * clone() const override { return new ObjectDecl( *this ); }141 virtual void accept( Visitor & v ) override { v.visit( this ); } 142 virtual void accept( Visitor & v ) const override { v.visit( this ); } 143 virtual DeclarationWithType * acceptMutator( Mutator &m ) override { return m.mutate( this ); }144 virtual void print( std::ostream & os, Indenter indent = {} ) const override;145 virtual void printShort( std::ostream & os, Indenter indent = {} ) const override;141 virtual ObjectDecl *clone() const override { return new ObjectDecl( *this ); } 142 virtual void accept( Visitor & v ) override { v.visit( this ); } 143 virtual void accept( Visitor & v ) const override { v.visit( this ); } 144 virtual DeclarationWithType *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 145 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 146 virtual void printShort( std::ostream &os, Indenter indent = {} ) const override; 146 147 }; 147 148 … … 149 150 typedef DeclarationWithType Parent; 150 151 public: 151 FunctionType * type;152 CompoundStmt * statements;152 FunctionType *type; 153 CompoundStmt *statements; 153 154 std::list< Expression * > withExprs; 154 155 155 FunctionDecl( const std::string & name, Type::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType * type, CompoundStmt *statements,156 FunctionDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements, 156 157 const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() ); 157 FunctionDecl( const FunctionDecl & other );158 FunctionDecl( const FunctionDecl &other ); 158 159 virtual ~FunctionDecl(); 159 160 … … 162 163 163 164 FunctionType * get_functionType() const { return type; } 164 void set_functionType( FunctionType * newValue ) { type = newValue; }165 CompoundStmt * get_statements() const { return statements; }166 void set_statements( CompoundStmt * newValue ) { statements = newValue; }165 void set_functionType( FunctionType *newValue ) { type = newValue; } 166 CompoundStmt *get_statements() const { return statements; } 167 void set_statements( CompoundStmt *newValue ) { statements = newValue; } 167 168 bool has_body() const { return NULL != statements; } 168 169 169 170 static FunctionDecl * newFunction( const std::string & name, FunctionType * type, CompoundStmt * statements ); 170 171 171 virtual FunctionDecl * clone() const override { return new FunctionDecl( *this ); }172 virtual void accept( Visitor & v ) override { v.visit( this ); } 173 virtual void accept( Visitor & v ) const override { v.visit( this ); } 174 virtual DeclarationWithType * acceptMutator( Mutator &m ) override { return m.mutate( this ); }175 virtual void print( std::ostream & os, Indenter indent = {} ) const override;176 virtual void printShort( std::ostream & os, Indenter indent = {} ) const override;172 virtual FunctionDecl *clone() const override { return new FunctionDecl( *this ); } 173 virtual void accept( Visitor & v ) override { v.visit( this ); } 174 virtual void accept( Visitor & v ) const override { v.visit( this ); } 175 virtual DeclarationWithType *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 176 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 177 virtual void printShort( std::ostream &os, Indenter indent = {} ) const override; 177 178 }; 178 179 … … 180 181 typedef Declaration Parent; 181 182 public: 182 Type * base;183 std::list< TypeDecl * > parameters;184 std::list< DeclarationWithType * > assertions;185 186 NamedTypeDecl( const std::string & name, Type::StorageClasses scs, Type *type );187 NamedTypeDecl( const NamedTypeDecl & other );183 Type *base; 184 std::list< TypeDecl* > parameters; 185 std::list< DeclarationWithType* > assertions; 186 187 NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *type ); 188 NamedTypeDecl( const NamedTypeDecl &other ); 188 189 virtual ~NamedTypeDecl(); 189 190 190 Type * get_base() const { return base; }191 void set_base( Type * newValue ) { base = newValue; }192 std::list< TypeDecl* > & get_parameters() { return parameters; }193 std::list< DeclarationWithType * >& get_assertions() { return assertions; }194 195 virtual const char *typeString() const = 0;196 197 virtual NamedTypeDecl * clone() const override = 0;198 virtual void print( std::ostream & os, Indenter indent = {} ) const override;199 virtual void printShort( std::ostream & os, Indenter indent = {} ) const override;191 Type *get_base() const { return base; } 192 void set_base( Type *newValue ) { base = newValue; } 193 std::list< TypeDecl* >& get_parameters() { return parameters; } 194 std::list< DeclarationWithType* >& get_assertions() { return assertions; } 195 196 virtual std::string typeString() const = 0; 197 198 virtual NamedTypeDecl *clone() const override = 0; 199 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 200 virtual void printShort( std::ostream &os, Indenter indent = {} ) const override; 200 201 }; 201 202 … … 203 204 typedef NamedTypeDecl Parent; 204 205 public: 205 enum Kind { Dtype, Otype,Ftype, Ttype, NUMBER_OF_KINDS };206 207 Kind kind;206 enum Kind { Dtype, Ftype, Ttype, NUMBER_OF_KINDS }; 207 208 Type * init; 208 209 bool sized; 209 Type * init;210 210 211 211 /// Data extracted from a type decl 212 212 struct Data { 213 Kind kind;213 TypeDecl::Kind kind; 214 214 bool isComplete; 215 215 216 Data() : kind( NUMBER_OF_KINDS), isComplete( false ) {}217 Data( constTypeDecl * typeDecl ) : Data( typeDecl->get_kind(), typeDecl->isComplete() ) {}216 Data() : kind( (TypeDecl::Kind)-1 ), isComplete( false ) {} 217 Data( TypeDecl * typeDecl ) : Data( typeDecl->get_kind(), typeDecl->isComplete() ) {} 218 218 Data( Kind kind, bool isComplete ) : kind( kind ), isComplete( isComplete ) {} 219 Data( const Data & d1, const Data& d2 )220 : kind( d1.kind ), isComplete( d1.isComplete || d2.isComplete ) {}221 222 bool operator==( const Data & other) const { return kind == other.kind && isComplete == other.isComplete; }223 bool operator!=( const Data & other) const { return !(*this == other);}219 Data( const Data& d1, const Data& d2 ) 220 : kind( d1.kind ), isComplete ( d1.isComplete || d2.isComplete ) {} 221 222 bool operator==(const Data & other) const { return kind == other.kind && isComplete == other.isComplete; } 223 bool operator!=(const Data & other) const { return !(*this == other);} 224 224 }; 225 225 226 TypeDecl( const std::string & name, Type::StorageClasses scs, Type *type, Kind kind, bool sized, Type * init = nullptr );227 TypeDecl( const TypeDecl & other );226 TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, bool sized, Type * init = nullptr ); 227 TypeDecl( const TypeDecl &other ); 228 228 virtual ~TypeDecl(); 229 229 … … 237 237 TypeDecl * set_sized( bool newValue ) { sized = newValue; return this; } 238 238 239 virtual const char * typeString() const override; 240 virtual const char * genTypeString() const; 241 242 virtual TypeDecl * clone() const override { return new TypeDecl( *this ); } 243 virtual void accept( Visitor & v ) override { v.visit( this ); } 244 virtual void accept( Visitor & v ) const override { v.visit( this ); } 245 virtual Declaration * acceptMutator( Mutator & m ) override { return m.mutate( this ); } 246 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 239 virtual std::string typeString() const override; 240 virtual std::string genTypeString() const; 241 242 virtual TypeDecl *clone() const override { return new TypeDecl( *this ); } 243 virtual void accept( Visitor & v ) override { v.visit( this ); } 244 virtual void accept( Visitor & v ) const override { v.visit( this ); } 245 virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 246 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 247 248 Kind kind; 247 249 }; 248 250 … … 250 252 typedef NamedTypeDecl Parent; 251 253 public: 252 TypedefDecl( const std::string & name, CodeLocation location, Type::StorageClasses scs, Type *type, LinkageSpec::Spec spec = LinkageSpec::Cforall )254 TypedefDecl( const std::string &name, CodeLocation location, Type::StorageClasses scs, Type *type, LinkageSpec::Spec spec = LinkageSpec::Cforall ) 253 255 : Parent( name, scs, type ) { set_linkage( spec ); this->location = location; } 254 256 255 TypedefDecl( const TypedefDecl & other ) : Parent( other ) {}256 257 virtual const char *typeString() const override;258 259 virtual TypedefDecl * clone() const override { return new TypedefDecl( *this ); }260 virtual void accept( Visitor & v ) override { v.visit( this ); } 261 virtual void accept( Visitor & v ) const override { v.visit( this ); } 262 virtual Declaration * acceptMutator( Mutator &m ) override { return m.mutate( this ); }257 TypedefDecl( const TypedefDecl &other ) : Parent( other ) {} 258 259 virtual std::string typeString() const override; 260 261 virtual TypedefDecl *clone() const override { return new TypedefDecl( *this ); } 262 virtual void accept( Visitor & v ) override { v.visit( this ); } 263 virtual void accept( Visitor & v ) const override { v.visit( this ); } 264 virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 263 265 private: 264 266 }; … … 267 269 typedef Declaration Parent; 268 270 public: 269 enum Aggregate { Struct, Union, Enum, Exception, Trait, Generator, Coroutine, Monitor, Thread, NoAggregate };270 static const char * aggrString( Aggregate aggr );271 272 271 std::list<Declaration*> members; 273 272 std::list<TypeDecl*> parameters; … … 276 275 AggregateDecl * parent = nullptr; 277 276 278 AggregateDecl( const std::string & name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall );279 AggregateDecl( const AggregateDecl & other );277 AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ); 278 AggregateDecl( const AggregateDecl &other ); 280 279 virtual ~AggregateDecl(); 281 280 … … 289 288 AggregateDecl * set_body( bool body ) { AggregateDecl::body = body; return this; } 290 289 291 virtual void print( std::ostream & os, Indenter indent = {} ) const override final;292 virtual void printShort( std::ostream & os, Indenter indent = {} ) const override;290 virtual void print( std::ostream &os, Indenter indent = {} ) const override final; 291 virtual void printShort( std::ostream &os, Indenter indent = {} ) const override; 293 292 protected: 294 virtual const char *typeString() const = 0;293 virtual std::string typeString() const = 0; 295 294 }; 296 295 … … 298 297 typedef AggregateDecl Parent; 299 298 public: 300 StructDecl( const std::string & name, Aggregate kind =Struct, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ), kind( kind ) {}301 StructDecl( const StructDecl & other ) : Parent( other ), kind( other.kind ) {}302 303 bool is_coroutine() { return kind == Coroutine; }304 bool is_monitor() { return kind == Monitor; }305 bool is_thread() { return kind == Thread; }306 307 virtual StructDecl * clone() const override { return new StructDecl( *this ); }308 virtual void accept( Visitor & v ) override { v.visit( this ); } 309 virtual void accept( Visitor & v ) const override { v.visit( this ); } 310 virtual Declaration * acceptMutator( Mutator &m ) override { return m.mutate( this ); }311 Aggregate kind;312 private: 313 virtual const char *typeString() const override;299 StructDecl( const std::string &name, DeclarationNode::Aggregate kind = DeclarationNode::Struct, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ), kind( kind ) {} 300 StructDecl( const StructDecl &other ) : Parent( other ), kind( other.kind ) {} 301 302 bool is_coroutine() { return kind == DeclarationNode::Coroutine; } 303 bool is_monitor() { return kind == DeclarationNode::Monitor; } 304 bool is_thread() { return kind == DeclarationNode::Thread; } 305 306 virtual StructDecl *clone() const override { return new StructDecl( *this ); } 307 virtual void accept( Visitor & v ) override { v.visit( this ); } 308 virtual void accept( Visitor & v ) const override { v.visit( this ); } 309 virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 310 DeclarationNode::Aggregate kind; 311 private: 312 virtual std::string typeString() const override; 314 313 }; 315 314 … … 317 316 typedef AggregateDecl Parent; 318 317 public: 319 UnionDecl( const std::string & name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ) {}320 UnionDecl( const UnionDecl & other ) : Parent( other ) {}321 322 virtual UnionDecl * clone() const override { return new UnionDecl( *this ); }323 virtual void accept( Visitor & v ) override { v.visit( this ); } 324 virtual void accept( Visitor & v ) const override { v.visit( this ); } 325 virtual Declaration * acceptMutator( Mutator &m ) override { return m.mutate( this ); }326 private: 327 virtual const char *typeString() const override;318 UnionDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ) {} 319 UnionDecl( const UnionDecl &other ) : Parent( other ) {} 320 321 virtual UnionDecl *clone() const override { return new UnionDecl( *this ); } 322 virtual void accept( Visitor & v ) override { v.visit( this ); } 323 virtual void accept( Visitor & v ) const override { v.visit( this ); } 324 virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 325 private: 326 virtual std::string typeString() const override; 328 327 }; 329 328 … … 331 330 typedef AggregateDecl Parent; 332 331 public: 333 EnumDecl( const std::string & name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ) {}334 EnumDecl( const EnumDecl & other ) : Parent( other ) {}332 EnumDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ) {} 333 EnumDecl( const EnumDecl &other ) : Parent( other ) {} 335 334 336 335 bool valueOf( Declaration * enumerator, long long int & value ); 337 336 338 virtual EnumDecl * clone() const override { return new EnumDecl( *this ); }339 virtual void accept( Visitor & v ) override { v.visit( this ); } 340 virtual void accept( Visitor & v ) const override { v.visit( this ); } 341 virtual Declaration * acceptMutator( Mutator &m ) override { return m.mutate( this ); }337 virtual EnumDecl *clone() const override { return new EnumDecl( *this ); } 338 virtual void accept( Visitor & v ) override { v.visit( this ); } 339 virtual void accept( Visitor & v ) const override { v.visit( this ); } 340 virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 342 341 private: 343 342 std::unordered_map< std::string, long long int > enumValues; 344 virtual const char *typeString() const override;343 virtual std::string typeString() const override; 345 344 }; 346 345 … … 348 347 typedef AggregateDecl Parent; 349 348 public: 350 TraitDecl( const std::string & name, const std::list< Attribute * > & attributes, LinkageSpec::Spec linkage ) : Parent( name, attributes, linkage ) {349 TraitDecl( const std::string &name, const std::list< Attribute * > & attributes, LinkageSpec::Spec linkage ) : Parent( name, attributes, linkage ) { 351 350 assertf( attributes.empty(), "attribute unsupported for traits" ); 352 351 } 353 TraitDecl( const TraitDecl & other ) : Parent( other ) {}354 355 virtual TraitDecl * clone() const override { return new TraitDecl( *this ); }356 virtual void accept( Visitor & v ) override { v.visit( this ); } 357 virtual void accept( Visitor & v ) const override { v.visit( this ); } 358 virtual Declaration * acceptMutator( Mutator &m ) override { return m.mutate( this ); }359 private: 360 virtual const char *typeString() const override;352 TraitDecl( const TraitDecl &other ) : Parent( other ) {} 353 354 virtual TraitDecl *clone() const override { return new TraitDecl( *this ); } 355 virtual void accept( Visitor & v ) override { v.visit( this ); } 356 virtual void accept( Visitor & v ) const override { v.visit( this ); } 357 virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 358 private: 359 virtual std::string typeString() const override; 361 360 }; 362 361 … … 380 379 class AsmDecl : public Declaration { 381 380 public: 382 AsmStmt * stmt;383 384 AsmDecl( AsmStmt * stmt );385 AsmDecl( const AsmDecl & other );381 AsmStmt *stmt; 382 383 AsmDecl( AsmStmt *stmt ); 384 AsmDecl( const AsmDecl &other ); 386 385 virtual ~AsmDecl(); 387 386 388 AsmStmt * get_stmt() { return stmt; }389 void set_stmt( AsmStmt * newValue ) { stmt = newValue; }390 391 virtual AsmDecl * clone() const override { return new AsmDecl( *this ); }392 virtual void accept( Visitor & v ) override { v.visit( this ); } 393 virtual void accept( Visitor & v ) const override { v.visit( this ); } 394 virtual AsmDecl * acceptMutator( Mutator &m ) override { return m.mutate( this ); }395 virtual void print( std::ostream & os, Indenter indent = {} ) const override;396 virtual void printShort( std::ostream & os, Indenter indent = {} ) const override;387 AsmStmt *get_stmt() { return stmt; } 388 void set_stmt( AsmStmt *newValue ) { stmt = newValue; } 389 390 virtual AsmDecl *clone() const override { return new AsmDecl( *this ); } 391 virtual void accept( Visitor & v ) override { v.visit( this ); } 392 virtual void accept( Visitor & v ) const override { v.visit( this ); } 393 virtual AsmDecl *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 394 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 395 virtual void printShort( std::ostream &os, Indenter indent = {} ) const override; 397 396 }; 398 397 … … 409 408 virtual void accept( Visitor & v ) override { v.visit( this ); } 410 409 virtual void accept( Visitor & v ) const override { v.visit( this ); } 411 virtual StaticAssertDecl * acceptMutator( Mutator & m ) override { return m.mutate( this ); }412 virtual void print( std::ostream & os, Indenter indent = {} ) const override;413 virtual void printShort( std::ostream & os, Indenter indent = {} ) const override;410 virtual StaticAssertDecl * acceptMutator( Mutator &m ) override { return m.mutate( this ); } 411 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 412 virtual void printShort( std::ostream &os, Indenter indent = {} ) const override; 414 413 }; 415 414 -
src/SynTree/DeclarationWithType.cc
r3d5701e r9fb8f01 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 13 23:45:16 201913 // Update Count : 2 612 // Last Modified On : Thu Mar 16 08:34:35 2017 13 // Update Count : 25 14 14 // 15 15 … … 20 20 #include "Common/utility.h" // for cloneAll, deleteAll, maybeClone 21 21 #include "Declaration.h" // for DeclarationWithType, Declaration 22 #include " LinkageSpec.h"// for Spec23 #include " Expression.h"// for ConstantExpr22 #include "Parser/LinkageSpec.h" // for Spec 23 #include "SynTree/Expression.h" // for ConstantExpr 24 24 #include "Type.h" // for Type, Type::FuncSpecifiers, Type::St... 25 25 -
src/SynTree/Expression.cc
r3d5701e r9fb8f01 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Dec 11 07:55:15201913 // Update Count : 7011 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr Aug 15 13:43:00 2019 13 // Update Count : 64 14 14 // 15 15 … … 19 19 #include <iostream> // for ostream, operator<<, basic_ostream 20 20 #include <list> // for list, _List_iterator, list<>::co... 21 #include <set> // for set22 21 23 22 #include "Common/utility.h" // for maybeClone, cloneAll, deleteAll 23 #include "Declaration.h" // for ObjectDecl, DeclarationWithType 24 24 #include "Expression.h" // for Expression, ImplicitCopyCtorExpr 25 25 #include "InitTweak/InitTweak.h" // for getCallArg, getPointerBase … … 64 64 65 65 bool Expression::get_lvalue() const { 66 assert( !result->get_lvalue() ); 66 67 return false; 67 68 } … … 114 115 assert( var->get_type() ); 115 116 Type * type = var->get_type()->clone(); 117 type->set_lvalue( true ); 116 118 117 119 // xxx - doesn't quite work yet - get different alternatives with the same cost … … 123 125 // long long int value; 124 126 // if ( decl->valueOf( var, value ) ) { 125 // type->set_lvalue( false ); // Would have to move to get_lvalue.127 // type->set_lvalue( false ); 126 128 // } 127 129 // } … … 138 140 139 141 bool VariableExpr::get_lvalue() const { 140 // It isn't always an lvalue, but it is never an rvalue. 141 return true; 142 return result->get_lvalue(); 142 143 } 143 144 … … 276 277 277 278 bool CastExpr::get_lvalue() const { 278 // This is actually wrong by C, but it works with our current set-up. 279 return arg->get_lvalue(); 279 return result->get_lvalue(); 280 280 } 281 281 … … 293 293 } 294 294 295 KeywordCastExpr::KeywordCastExpr( Expression * arg, AggregateDecl::Aggregatetarget ) : Expression(), arg(arg), target( target ) {295 KeywordCastExpr::KeywordCastExpr( Expression * arg, Target target ) : Expression(), arg(arg), target( target ) { 296 296 } 297 297 … … 303 303 } 304 304 305 const char * KeywordCastExpr::targetString() const { 306 return AggregateDecl::aggrString( target ); 305 const std::string & KeywordCastExpr::targetString() const { 306 static const std::string targetStrs[] = { 307 "coroutine", "thread", "monitor" 308 }; 309 static_assert( 310 (sizeof(targetStrs) / sizeof(targetStrs[0])) == ((unsigned long)NUMBER_OF_TARGETS), 311 "Each KeywordCastExpr::Target should have a corresponding string representation" 312 ); 313 return targetStrs[(unsigned long)target]; 307 314 } 308 315 … … 353 360 } 354 361 355 bool UntypedMemberExpr::get_lvalue() const {356 return aggregate->get_lvalue();357 }358 359 362 void UntypedMemberExpr::print( std::ostream & os, Indenter indent ) const { 360 363 os << "Untyped Member Expression, with field: " << std::endl << indent+1; … … 375 378 sub.apply( res ); 376 379 result = res; 380 result->set_lvalue( true ); 377 381 result->get_qualifiers() |= aggregate->result->get_qualifiers(); 378 382 } … … 388 392 389 393 bool MemberExpr::get_lvalue() const { 390 // This is actually wrong by C, but it works with our current set-up.394 assert( result->get_lvalue() ); 391 395 return true; 392 396 } … … 423 427 // if references are still allowed in the AST, dereference returns a reference 424 428 ret->set_result( new ReferenceType( Type::Qualifiers(), ret->get_result() ) ); 429 } else { 430 // references have been removed, in which case dereference returns an lvalue of the base type. 431 ret->result->set_lvalue( true ); 425 432 } 426 433 } … … 440 447 441 448 bool UntypedExpr::get_lvalue() const { 442 // from src/GenPoly/Lvalue.cc: isIntrinsicReference 443 static std::set<std::string> lvalueFunctions = { "*?", "?[?]" }; 444 std::string fname = InitTweak::getFunctionName( const_cast< UntypedExpr * >( this ) ); 445 return lvalueFunctions.count(fname); 449 return result->get_lvalue(); 446 450 } 447 451 … … 506 510 507 511 bool ConditionalExpr::get_lvalue() const { 508 return false;512 return result->get_lvalue(); 509 513 } 510 514 … … 519 523 } 520 524 521 AsmExpr::AsmExpr( const AsmExpr & other ) : Expression( other ), inout( other.inout), constraint( maybeClone( other.constraint ) ), operand( maybeClone( other.operand ) ) {}525 AsmExpr::AsmExpr( const AsmExpr & other ) : Expression( other ), inout( maybeClone( other.inout ) ), constraint( maybeClone( other.constraint ) ), operand( maybeClone( other.operand ) ) {} 522 526 523 527 524 528 void AsmExpr::print( std::ostream & os, Indenter indent ) const { 525 529 os << "Asm Expression: " << std::endl; 526 if ( !inout.empty() ) os << "[" << inout << "] ";530 if ( inout ) inout->print( os, indent+1 ); 527 531 if ( constraint ) constraint->print( os, indent+1 ); 528 532 if ( operand ) operand->print( os, indent+1 ); … … 566 570 567 571 bool ConstructorExpr::get_lvalue() const { 568 return false;572 return result->get_lvalue(); 569 573 } 570 574 … … 578 582 CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : initializer( initializer ) { 579 583 assert( type && initializer ); 584 type->set_lvalue( true ); 580 585 set_result( type ); 581 586 } … … 588 593 589 594 bool CompoundLiteralExpr::get_lvalue() const { 595 assert( result->get_lvalue() ); 590 596 return true; 591 597 } … … 642 648 } 643 649 bool StmtExpr::get_lvalue() const { 644 return false;650 return result->get_lvalue(); 645 651 } 646 652 void StmtExpr::print( std::ostream & os, Indenter indent ) const { -
src/SynTree/Expression.h
r3d5701e r9fb8f01 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Dec 11 16:50:19201913 // Update Count : 6011 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr Aug 15 13:46:00 2019 13 // Update Count : 54 14 14 // 15 15 … … 28 28 #include "Label.h" // for Label 29 29 #include "Mutator.h" // for Mutator 30 #include "Declaration.h" // for Aggregate31 30 #include "SynTree.h" // for UniqueId 32 31 #include "Visitor.h" // for Visitor … … 230 229 public: 231 230 Expression * arg; 232 struct Concrete { 233 std::string field; 234 std::string getter; 235 }; 236 AggregateDecl::Aggregate target; 237 Concrete concrete_target; 238 239 KeywordCastExpr( Expression * arg, AggregateDecl::Aggregate target ); 231 enum Target { 232 Coroutine, Thread, Monitor, NUMBER_OF_TARGETS 233 } target; 234 235 KeywordCastExpr( Expression * arg, Target target ); 240 236 KeywordCastExpr( const KeywordCastExpr & other ); 241 237 virtual ~KeywordCastExpr(); 242 238 243 const char *targetString() const;239 const std::string & targetString() const; 244 240 245 241 virtual KeywordCastExpr * clone() const override { return new KeywordCastExpr( * this ); } … … 278 274 UntypedMemberExpr( const UntypedMemberExpr & other ); 279 275 virtual ~UntypedMemberExpr(); 280 281 bool get_lvalue() const final;282 276 283 277 Expression * get_member() const { return member; } … … 579 573 class AsmExpr : public Expression { 580 574 public: 581 std::stringinout;575 Expression * inout; 582 576 Expression * constraint; 583 577 Expression * operand; 584 578 585 AsmExpr( const std::string * _inout, Expression * constraint, Expression * operand ) : inout( _inout ? *_inout : "" ), constraint( constraint ), operand( operand ) { delete _inout;}579 AsmExpr( Expression * inout, Expression * constraint, Expression * operand ) : inout( inout ), constraint( constraint ), operand( operand ) {} 586 580 AsmExpr( const AsmExpr & other ); 587 virtual ~AsmExpr() { delete constraint; delete operand; }; 581 virtual ~AsmExpr() { delete inout; delete constraint; delete operand; }; 582 583 Expression * get_inout() const { return inout; } 584 void set_inout( Expression * newValue ) { inout = newValue; } 585 586 Expression * get_constraint() const { return constraint; } 587 void set_constraint( Expression * newValue ) { constraint = newValue; } 588 589 Expression * get_operand() const { return operand; } 590 void set_operand( Expression * newValue ) { operand = newValue; } 588 591 589 592 virtual AsmExpr * clone() const override { return new AsmExpr( * this ); } -
src/SynTree/FunctionDecl.cc
r3d5701e r9fb8f01 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Dec 16 15:11:20 201913 // Update Count : 7 712 // Last Modified On : Thu Mar 16 08:33:41 2017 13 // Update Count : 74 14 14 // 15 15 … … 23 23 #include "Common/utility.h" // for maybeClone, printAll 24 24 #include "Declaration.h" // for FunctionDecl, FunctionDecl::Parent 25 #include "Expression.h" 26 #include "LinkageSpec.h" // for Spec, linkageName, Cforall 25 #include "Parser/LinkageSpec.h" // for Spec, linkageName, Cforall 27 26 #include "Statement.h" // for CompoundStmt 28 27 #include "Type.h" // for Type, FunctionType, Type::FuncSpecif... … … 73 72 } // if 74 73 if ( linkage != LinkageSpec::Cforall ) { 75 os << LinkageSpec:: name( linkage ) << " ";74 os << LinkageSpec::linkageName( linkage ) << " "; 76 75 } // if 77 76 -
src/SynTree/NamedTypeDecl.cc
r3d5701e r9fb8f01 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Mon Dec 16 15:11:40 201913 // Update Count : 1 711 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 9 13:28:00 2017 13 // Update Count : 14 14 14 // 15 15 … … 20 20 #include "Common/utility.h" // for printAll, cloneAll, deleteAll, maybe... 21 21 #include "Declaration.h" // for NamedTypeDecl, DeclarationWithType 22 #include " LinkageSpec.h"// for Spec, Cforall, linkageName22 #include "Parser/LinkageSpec.h" // for Spec, Cforall, linkageName 23 23 #include "Type.h" // for Type, Type::StorageClasses 24 24 … … 44 44 45 45 if ( linkage != LinkageSpec::Cforall ) { 46 os << LinkageSpec:: name( linkage ) << " ";46 os << LinkageSpec::linkageName( linkage ) << " "; 47 47 } // if 48 48 get_storageClasses().print( os ); … … 78 78 } 79 79 80 const char *TypedefDecl::typeString() const { return "typedef"; }80 std::string TypedefDecl::typeString() const { return "typedef"; } 81 81 82 82 // Local Variables: // -
src/SynTree/ObjectDecl.cc
r3d5701e r9fb8f01 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Dec 16 15:12:03 201913 // Update Count : 6112 // Last Modified On : Thu Mar 16 08:34:27 2017 13 // Update Count : 59 14 14 // 15 15 … … 23 23 #include "Expression.h" // for Expression 24 24 #include "Initializer.h" // for Initializer 25 #include " LinkageSpec.h"// for Spec, linkageName, Cforall25 #include "Parser/LinkageSpec.h" // for Spec, linkageName, Cforall 26 26 #include "Type.h" // for Type, Type::StorageClasses, Type::Fu... 27 27 … … 48 48 49 49 if ( linkage != LinkageSpec::Cforall ) { 50 os << LinkageSpec:: name( linkage ) << " ";50 os << LinkageSpec::linkageName( linkage ) << " "; 51 51 } // if 52 52 -
src/SynTree/Statement.cc
r3d5701e r9fb8f01 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Mon Jan 20 16:03:00 202013 // Update Count : 7111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Sep 3 20:46:44 2017 13 // Update Count : 68 14 14 // 15 15 … … 46 46 Statement::~Statement() {} 47 47 48 ExprStmt::ExprStmt( Expression * expr ) : Statement(), expr( expr ) {}49 50 ExprStmt::ExprStmt( const ExprStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) {}48 ExprStmt::ExprStmt( Expression *expr ) : Statement(), expr( expr ) {} 49 50 ExprStmt::ExprStmt( const ExprStmt &other ) : Statement( other ), expr( maybeClone( other.expr ) ) {} 51 51 52 52 ExprStmt::~ExprStmt() { … … 54 54 } 55 55 56 void ExprStmt::print( std::ostream & os, Indenter indent ) const {56 void ExprStmt::print( std::ostream &os, Indenter indent ) const { 57 57 os << "Expression Statement:" << endl << indent+1; 58 58 expr->print( os, indent+1 ); … … 60 60 61 61 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 ) {}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 ) {} 63 63 64 64 AsmStmt::AsmStmt( const AsmStmt & other ) : Statement( other ), voltile( other.voltile ), instruction( maybeClone( other.instruction ) ), gotolabels( other.gotolabels ) { … … 75 75 } 76 76 77 void AsmStmt::print( std::ostream & os, Indenter indent ) const {77 void AsmStmt::print( std::ostream &os, Indenter indent ) const { 78 78 os << "Assembler Statement:" << endl; 79 79 os << indent+1 << "instruction: " << endl << indent; … … 96 96 DirectiveStmt::DirectiveStmt( const std::string & directive ) : Statement(), directive( directive ) {} 97 97 98 void DirectiveStmt::print( std::ostream & os, Indenter ) const {98 void DirectiveStmt::print( std::ostream &os, Indenter ) const { 99 99 os << "GCC Directive:" << directive << endl; 100 100 } 101 101 102 102 103 const char * BranchStmt::brType[] = { 104 "Goto", "Break", "Continue", "Fall Through", "Fall Through Default", 105 }; 103 const char *BranchStmt::brType[] = { "Goto", "Break", "Continue" }; 106 104 107 105 BranchStmt::BranchStmt( Label target, Type type ) throw ( SemanticErrorException ) : … … 113 111 } 114 112 115 BranchStmt::BranchStmt( Expression * computedTarget, Type type ) throw ( SemanticErrorException ) :113 BranchStmt::BranchStmt( Expression *computedTarget, Type type ) throw ( SemanticErrorException ) : 116 114 Statement(), computedTarget( computedTarget ), type( type ) { 117 115 if ( type != BranchStmt::Goto || computedTarget == nullptr ) { … … 120 118 } 121 119 122 void BranchStmt::print( std::ostream & os, Indenter indent ) const { 123 assert(type < 5); 120 void BranchStmt::print( std::ostream &os, Indenter indent ) const { 124 121 os << "Branch (" << brType[type] << ")" << endl ; 125 122 if ( target != "" ) os << indent+1 << "with target: " << target << endl; … … 128 125 } 129 126 130 ReturnStmt::ReturnStmt( Expression * expr ) : Statement(), expr( expr ) {}127 ReturnStmt::ReturnStmt( Expression *expr ) : Statement(), expr( expr ) {} 131 128 132 129 ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) {} … … 136 133 } 137 134 138 void ReturnStmt::print( std::ostream & os, Indenter indent ) const {135 void ReturnStmt::print( std::ostream &os, Indenter indent ) const { 139 136 os << "Return Statement, returning: "; 140 137 if ( expr != nullptr ) { … … 145 142 } 146 143 147 IfStmt::IfStmt( Expression * condition, Statement * thenPart, Statement *elsePart, std::list<Statement *> initialization ):144 IfStmt::IfStmt( Expression *condition, Statement *thenPart, Statement *elsePart, std::list<Statement *> initialization ): 148 145 Statement(), condition( condition ), thenPart( thenPart ), elsePart( elsePart ), initialization( initialization ) {} 149 146 … … 160 157 } 161 158 162 void IfStmt::print( std::ostream & os, Indenter indent ) const {159 void IfStmt::print( std::ostream &os, Indenter indent ) const { 163 160 os << "If on condition: " << endl; 164 161 os << indent+1; … … 179 176 thenPart->print( os, indent+1 ); 180 177 181 if ( elsePart != nullptr) {178 if ( elsePart != 0 ) { 182 179 os << indent << "... else: " << endl; 183 180 os << indent+1; … … 186 183 } 187 184 188 SwitchStmt::SwitchStmt( Expression * condition, const std::list<Statement *> & statements ):185 SwitchStmt::SwitchStmt( Expression * condition, const std::list<Statement *> &statements ): 189 186 Statement(), condition( condition ), statements( statements ) { 190 187 } … … 201 198 } 202 199 203 void SwitchStmt::print( std::ostream & os, Indenter indent ) const {200 void SwitchStmt::print( std::ostream &os, Indenter indent ) const { 204 201 os << "Switch on condition: "; 205 202 condition->print( os ); … … 211 208 } 212 209 213 CaseStmt::CaseStmt( Expression * condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticErrorException ) :210 CaseStmt::CaseStmt( Expression *condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticErrorException ) : 214 211 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: " ); 216 213 } 217 214 … … 232 229 } 233 230 234 void CaseStmt::print( std::ostream & os, Indenter indent ) const {231 void CaseStmt::print( std::ostream &os, Indenter indent ) const { 235 232 if ( isDefault() ) os << indent << "Default "; 236 233 else { … … 246 243 } 247 244 248 WhileStmt::WhileStmt( Expression * condition, Statement *body, std::list< Statement * > & initialization, bool isDoWhile ):245 WhileStmt::WhileStmt( Expression *condition, Statement *body, std::list< Statement * > & initialization, bool isDoWhile ): 249 246 Statement(), condition( condition), body( body), initialization( initialization ), isDoWhile( isDoWhile) { 250 247 } … … 259 256 } 260 257 261 void WhileStmt::print( std::ostream & os, Indenter indent ) const {258 void WhileStmt::print( std::ostream &os, Indenter indent ) const { 262 259 os << "While on condition: " << endl ; 263 260 condition->print( os, indent+1 ); … … 265 262 os << indent << "... with body: " << endl; 266 263 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 267 ForStmt::ForStmt( std::list<Statement *> initialization, Expression *condition, Expression *increment, Statement *body ): 271 268 Statement(), initialization( initialization ), condition( condition ), increment( increment ), body( body ) { 272 269 } … … 285 282 } 286 283 287 void ForStmt::print( std::ostream & os, Indenter indent ) const {284 void ForStmt::print( std::ostream &os, Indenter indent ) const { 288 285 Statement::print( os, indent ); // print labels 289 286 … … 308 305 } 309 306 310 if ( body != nullptr) {307 if ( body != 0 ) { 311 308 os << "\n" << indent << "... with body: \n" << indent+1; 312 309 body->print( os, indent+1 ); … … 320 317 } 321 318 322 ThrowStmt::ThrowStmt( const ThrowStmt & other ) :319 ThrowStmt::ThrowStmt( const ThrowStmt &other ) : 323 320 Statement ( other ), kind( other.kind ), expr( maybeClone( other.expr ) ), target( maybeClone( other.target ) ) { 324 321 } … … 329 326 } 330 327 331 void ThrowStmt::print( std::ostream & os, Indenter indent) const {328 void ThrowStmt::print( std::ostream &os, Indenter indent) const { 332 329 if ( target ) os << "Non-Local "; 333 330 os << "Throw Statement, raising: "; … … 339 336 } 340 337 341 TryStmt::TryStmt( CompoundStmt * tryBlock, std::list<CatchStmt *> & handlers, FinallyStmt *finallyBlock ) :338 TryStmt::TryStmt( CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock ) : 342 339 Statement(), block( tryBlock ), handlers( handlers ), finallyBlock( finallyBlock ) { 343 340 } 344 341 345 TryStmt::TryStmt( const TryStmt & other ) : Statement( other ), block( maybeClone( other.block ) ), finallyBlock( maybeClone( other.finallyBlock ) ) {342 TryStmt::TryStmt( const TryStmt &other ) : Statement( other ), block( maybeClone( other.block ) ), finallyBlock( maybeClone( other.finallyBlock ) ) { 346 343 cloneAll( other.handlers, handlers ); 347 344 } … … 353 350 } 354 351 355 void TryStmt::print( std::ostream & os, Indenter indent ) const {352 void TryStmt::print( std::ostream &os, Indenter indent ) const { 356 353 os << "Try Statement" << endl; 357 354 os << indent << "... with block:" << endl << indent+1; … … 366 363 367 364 // finally block 368 if ( finallyBlock != nullptr) {365 if ( finallyBlock != 0 ) { 369 366 os << indent << "... and finally:" << endl << indent+1; 370 367 finallyBlock->print( os, indent+1 ); … … 372 369 } 373 370 374 CatchStmt::CatchStmt( Kind kind, Declaration * decl, Expression * cond, Statement *body ) :371 CatchStmt::CatchStmt( Kind kind, Declaration *decl, Expression *cond, Statement *body ) : 375 372 Statement(), kind ( kind ), decl ( decl ), cond ( cond ), body( body ) { 376 373 assertf( decl, "Catch clause must have a declaration." ); … … 386 383 } 387 384 388 void CatchStmt::print( std::ostream & os, Indenter indent ) const {385 void CatchStmt::print( std::ostream &os, Indenter indent ) const { 389 386 os << "Catch " << ((Terminate == kind) ? "Terminate" : "Resume") << " Statement" << endl; 390 387 … … 404 401 405 402 406 FinallyStmt::FinallyStmt( CompoundStmt * block ) : Statement(), block( block ) {403 FinallyStmt::FinallyStmt( CompoundStmt *block ) : Statement(), block( block ) { 407 404 } 408 405 … … 414 411 } 415 412 416 void FinallyStmt::print( std::ostream & os, Indenter indent ) const {413 void FinallyStmt::print( std::ostream &os, Indenter indent ) const { 417 414 os << "Finally Statement" << endl; 418 415 os << indent << "... with block:" << endl << indent+1; … … 461 458 } 462 459 463 void WaitForStmt::print( std::ostream & os, Indenter indent ) const {460 void WaitForStmt::print( std::ostream &os, Indenter indent ) const { 464 461 os << "Waitfor Statement" << endl; 465 462 indent += 1; … … 517 514 } 518 515 519 void NullStmt::print( std::ostream & os, Indenter indent ) const {516 void NullStmt::print( std::ostream &os, Indenter indent ) const { 520 517 os << "Null Statement" << endl; 521 518 Statement::print( os, indent ); … … 533 530 } 534 531 535 void ImplicitCtorDtorStmt::print( std::ostream & os, Indenter indent ) const {532 void ImplicitCtorDtorStmt::print( std::ostream &os, Indenter indent ) const { 536 533 os << "Implicit Ctor Dtor Statement" << endl; 537 534 os << indent << "... with Ctor/Dtor: "; -
src/SynTree/Statement.h
r3d5701e r9fb8f01 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jan 10 14:13:24 202013 // Update Count : 8 512 // Last Modified On : Tue Mar 12 09:01:53 2019 13 // Update Count : 83 14 14 // 15 15 … … 257 257 Statement * body; 258 258 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 ); 260 260 ForStmt( const ForStmt & other ); 261 261 virtual ~ForStmt(); … … 357 357 FinallyStmt * finallyBlock; 358 358 359 TryStmt( CompoundStmt * tryBlock, std::list<CatchStmt *> & handlers, FinallyStmt * finallyBlock = nullptr);359 TryStmt( CompoundStmt * tryBlock, std::list<CatchStmt *> & handlers, FinallyStmt * finallyBlock = 0 ); 360 360 TryStmt( const TryStmt & other ); 361 361 virtual ~TryStmt(); -
src/SynTree/TupleExpr.cc
r3d5701e r9fb8f01 58 58 59 59 bool TupleExpr::get_lvalue() const { 60 return false;60 return result->get_lvalue(); 61 61 } 62 62 … … 71 71 assertf( type->size() > index, "TupleIndexExpr index out of bounds: tuple size %d, requested index %d in expr %s", type->size(), index, toString( tuple ).c_str() ); 72 72 set_result( (*std::next( type->get_types().begin(), index ))->clone() ); 73 // like MemberExpr, TupleIndexExpr is always an lvalue 74 get_result()->set_lvalue( true ); 73 75 } 74 76 … … 81 83 82 84 bool TupleIndexExpr::get_lvalue() const { 83 return tuple->get_lvalue(); 85 assert( result->get_lvalue() ); 86 return true; 84 87 } 85 88 -
src/SynTree/TupleType.cc
r3d5701e r9fb8f01 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 13 23:44:38 201913 // Update Count : 412 // Last Modified On : Wed Feb 1 17:10:58 2017 13 // Update Count : 3 14 14 // 15 15 … … 20 20 #include "Declaration.h" // for Declaration, ObjectDecl 21 21 #include "Initializer.h" // for ListInit 22 #include " LinkageSpec.h"// for Cforall22 #include "Parser/LinkageSpec.h" // for Cforall 23 23 #include "Type.h" // for TupleType, Type, Type::Qualifiers 24 24 -
src/SynTree/Type.cc
r3d5701e r9fb8f01 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Dec 15 16:52:37 201913 // Update Count : 4 912 // Last Modified On : Sun Aug 4 21:05:07 2019 13 // Update Count : 45 14 14 // 15 15 #include "Type.h" … … 24 24 using namespace std; 25 25 26 // GENERATED START, DO NOT EDIT27 // GENERATED BY BasicTypes-gen.cc28 26 const char * BasicType::typeNames[] = { 29 27 "_Bool", … … 47 45 "float", 48 46 "float _Complex", 47 //"float _Imaginary", 49 48 "_Float32x", 50 49 "_Float32x _Complex", … … 53 52 "double", 54 53 "double _Complex", 54 //"double _Imaginary", 55 55 "_Float64x", 56 56 "_Float64x _Complex", … … 61 61 "long double", 62 62 "long double _Complex", 63 //"long double _Imaginary", 63 64 "_Float128x", 64 65 "_Float128x _Complex", 65 66 }; 66 // GENERATED END 67 static_assert( 68 sizeof(BasicType::typeNames) / sizeof(BasicType::typeNames[0]) == BasicType::NUMBER_OF_BASIC_TYPES, 69 "Each basic type name should have a corresponding kind enum value" 70 ); 67 71 68 72 Type::Type( const Qualifiers &tq, const std::list< Attribute * > & attributes ) : tq( tq ), attributes( attributes ) {} … … 81 85 const char * Type::FuncSpecifiersNames[] = { "inline", "_Noreturn", "fortran" }; 82 86 const char * Type::StorageClassesNames[] = { "extern", "static", "auto", "register", "_Thread_local" }; 83 const char * Type::QualifiersNames[] = { "const", "restrict", "volatile", " mutex", "_Atomic" };87 const char * Type::QualifiersNames[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic" }; 84 88 85 89 Type * Type::stripDeclarator() { -
src/SynTree/Type.h
r3d5701e r9fb8f01 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Wed Sep 4 09:58:00201913 // Update Count : 1 7011 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 14 17:11:24 2019 13 // Update Count : 169 14 14 // 15 15 … … 102 102 }; // StorageClasses 103 103 104 enum { Const = 1 << 0, Restrict = 1 << 1, Volatile = 1 << 2, Mutex = 1 << 3, Atomic = 1 << 4, NumTypeQualifier = 5};104 enum { Const = 1 << 0, Restrict = 1 << 1, Volatile = 1 << 2, Lvalue = 1 << 3, Mutex = 1 << 4, Atomic = 1 << 5, NumTypeQualifier = 6 }; 105 105 static const char * QualifiersNames[]; 106 106 union Qualifiers { 107 enum { Mask = ~ Restrict};107 enum { Mask = ~(Restrict | Lvalue) }; 108 108 unsigned int val; 109 109 struct { … … 111 111 bool is_restrict : 1; 112 112 bool is_volatile : 1; 113 bool is_lvalue : 1; 113 114 bool is_mutex : 1; 114 115 bool is_atomic : 1; … … 130 131 bool operator>( Qualifiers other ) const { return *this != other && *this >= other; } 131 132 BFCommon( Qualifiers, NumTypeQualifier ) 132 133 Qualifiers unify( Qualifiers const & other ) const {134 int or_flags = Mask & (val | other.val);135 int and_flags = val & other.val;136 return Qualifiers( or_flags | and_flags );137 }138 133 }; // Qualifiers 139 134 … … 152 147 bool get_volatile() const { return tq.is_volatile; } 153 148 bool get_restrict() const { return tq.is_restrict; } 149 bool get_lvalue() const { return tq.is_lvalue; } 154 150 bool get_mutex() const { return tq.is_mutex; } 155 151 bool get_atomic() const { return tq.is_atomic; } … … 157 153 void set_volatile( bool newValue ) { tq.is_volatile = newValue; } 158 154 void set_restrict( bool newValue ) { tq.is_restrict = newValue; } 155 void set_lvalue( bool newValue ) { tq.is_lvalue = newValue; } 159 156 void set_mutex( bool newValue ) { tq.is_mutex = newValue; } 160 157 void set_atomic( bool newValue ) { tq.is_atomic = newValue; } -
src/SynTree/TypeDecl.cc
r3d5701e r9fb8f01 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Dec 13 15:26:14 201913 // Update Count : 2111 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 9 14:35:00 2017 13 // Update Count : 6 14 14 // 15 15 … … 21 21 #include "Type.h" // for Type, Type::StorageClasses 22 22 23 TypeDecl::TypeDecl( const std::string & name, Type::StorageClasses scs, Type * type, Kind kind, bool sized, Type * init ) : Parent( name, scs, type ), kind( kind ), sized( kind == Ttype || sized ), init( init) {23 TypeDecl::TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, bool sized, Type * init ) : Parent( name, scs, type ), init( init ), sized( kind == Ttype || sized ), kind( kind ) { 24 24 } 25 25 26 TypeDecl::TypeDecl( const TypeDecl & other ) : Parent( other ), kind( other.kind ), sized( other.sized ), init( maybeClone( other.init )) {26 TypeDecl::TypeDecl( const TypeDecl &other ) : Parent( other ), init( maybeClone( other.init ) ), sized( other.sized ), kind( other.kind ) { 27 27 } 28 28 29 29 TypeDecl::~TypeDecl() { 30 delete init;30 delete init; 31 31 } 32 32 33 const char *TypeDecl::typeString() const {34 static const char * kindNames[] = { "sized data type", "sized object type", "sized function type", "sizedtuple type" };35 static_assert( sizeof(kindNames)/sizeof(kindNames[0]) == TypeDecl::NUMBER_OF_KINDS, "typeString: kindNames is out of sync." );36 assertf( kind < TypeDecl::NUMBER_OF_KINDS, "TypeDeclkind is out of bounds." );37 return isComplete() ? kindNames[ kind ] : &kindNames[ kind ][ sizeof("sized") ]; // sizeof includes '\0'33 std::string TypeDecl::typeString() const { 34 static const std::string kindNames[] = { "object type", "function type", "tuple type" }; 35 assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "typeString: kindNames is out of sync." ); 36 assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." ); 37 return (isComplete() ? "sized " : "") + kindNames[ kind ]; 38 38 } 39 39 40 const char *TypeDecl::genTypeString() const {41 static const char * kindNames[] = { "dtype", "otype", "ftype", "ttype" };42 static_assert( sizeof(kindNames)/sizeof(kindNames[0]) == TypeDecl::NUMBER_OF_KINDS, "genTypeString: kindNames is out of sync." );43 assertf( kind < TypeDecl::NUMBER_OF_KINDS, "TypeDeclkind is out of bounds." );40 std::string TypeDecl::genTypeString() const { 41 static const std::string kindNames[] = { "dtype", "ftype", "ttype" }; 42 assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "genTypeString: kindNames is out of sync." ); 43 assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." ); 44 44 return kindNames[ kind ]; 45 45 } 46 46 47 47 void TypeDecl::print( std::ostream &os, Indenter indent ) const { 48 NamedTypeDecl::print( os, indent );49 if ( init ) {50 os << std::endl << indent << "with type initializer: ";51 init->print( os, indent + 1 );52 } // if 48 NamedTypeDecl::print( os, indent ); 49 if ( init ) { 50 os << std::endl << indent << "with type initializer: "; 51 init->print( os, indent + 1 ); 52 } 53 53 } 54 54 55 55 56 std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data ) { 56 return os << data.kind << ", " << data.isComplete;57 return os << data.kind << ", " << data.isComplete; 57 58 } 58 59 -
src/SynTree/module.mk
r3d5701e r9fb8f01 11 11 ## Created On : Mon Jun 1 17:49:17 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Sat Dec 14 07:26:43 201914 ## Update Count : 213 ## Last Modified On : Mon Jun 1 17:54:09 2015 14 ## Update Count : 1 15 15 ############################################################################### 16 16 17 17 SRC_SYNTREE = \ 18 SynTree/Type.cc \ 19 SynTree/VoidType.cc \ 20 SynTree/BasicType.cc \ 21 SynTree/PointerType.cc \ 22 SynTree/ArrayType.cc \ 23 SynTree/ReferenceType.cc \ 24 SynTree/FunctionType.cc \ 25 SynTree/ReferenceToType.cc \ 26 SynTree/TupleType.cc \ 27 SynTree/TypeofType.cc \ 28 SynTree/AttrType.cc \ 29 SynTree/VarArgsType.cc \ 30 SynTree/ZeroOneType.cc \ 31 SynTree/Constant.cc \ 32 SynTree/Expression.cc \ 33 SynTree/TupleExpr.cc \ 34 SynTree/CommaExpr.cc \ 35 SynTree/TypeExpr.cc \ 36 SynTree/ApplicationExpr.cc \ 18 37 SynTree/AddressExpr.cc \ 19 SynTree/AggregateDecl.cc \ 20 SynTree/ApplicationExpr.cc \ 21 SynTree/ArrayType.cc \ 22 SynTree/AttrType.cc \ 23 SynTree/Attribute.cc \ 24 SynTree/BasicType.cc \ 25 SynTree/CommaExpr.cc \ 38 SynTree/Statement.cc \ 26 39 SynTree/CompoundStmt.cc \ 27 SynTree/Constant.cc \28 SynTree/DeclReplacer.cc \29 40 SynTree/DeclStmt.cc \ 30 41 SynTree/Declaration.cc \ 31 42 SynTree/DeclarationWithType.cc \ 32 SynTree/ Expression.cc \43 SynTree/ObjectDecl.cc \ 33 44 SynTree/FunctionDecl.cc \ 34 SynTree/FunctionType.cc \ 45 SynTree/AggregateDecl.cc \ 46 SynTree/NamedTypeDecl.cc \ 47 SynTree/TypeDecl.cc \ 35 48 SynTree/Initializer.cc \ 36 SynTree/LinkageSpec.cc \37 SynTree/NamedTypeDecl.cc \38 SynTree/ObjectDecl.cc \39 SynTree/PointerType.cc \40 SynTree/ReferenceToType.cc \41 SynTree/ReferenceType.cc \42 SynTree/Statement.cc \43 SynTree/TupleExpr.cc \44 SynTree/TupleType.cc \45 SynTree/Type.cc \46 SynTree/TypeDecl.cc \47 SynTree/TypeExpr.cc \48 49 SynTree/TypeSubstitution.cc \ 49 SynTree/TypeofType.cc \ 50 SynTree/VarArgsType.cc \ 51 SynTree/VoidType.cc \ 52 SynTree/ZeroOneType.cc 50 SynTree/Attribute.cc \ 51 SynTree/DeclReplacer.cc \ 52 SynTree/TopLvalue.cc 53 53 54 54 SRC += $(SRC_SYNTREE) -
src/Tuples/TupleAssignment.cc
r3d5701e r9fb8f01 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 13 23:45:33 201913 // Update Count : 912 // Last Modified On : Fri Mar 17 09:43:03 2017 13 // Update Count : 8 14 14 // 15 15 … … 34 34 #include "InitTweak/GenInit.h" // for genCtorInit 35 35 #include "InitTweak/InitTweak.h" // for getPointerBase, isAssignment 36 #include "Parser/LinkageSpec.h" // for Cforall 36 37 #include "ResolvExpr/Alternative.h" // for AltList, Alternative 37 38 #include "ResolvExpr/AlternativeFinder.h" // for AlternativeFinder, simpleC... … … 40 41 #include "ResolvExpr/TypeEnvironment.h" // for TypeEnvironment 41 42 #include "ResolvExpr/typeops.h" // for combos 42 #include "SynTree/LinkageSpec.h" // for Cforall43 43 #include "SynTree/Declaration.h" // for ObjectDecl 44 44 #include "SynTree/Expression.h" // for Expression, CastExpr, Name... -
src/Tuples/TupleExpansion.cc
r3d5701e r9fb8f01 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Dec 13 23:45:51201913 // Update Count : 2 411 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Jul 19 14:39:00 2019 13 // Update Count : 22 14 14 // 15 15 … … 27 27 #include "Common/utility.h" // for CodeLocation 28 28 #include "InitTweak/InitTweak.h" // for getFunction 29 #include " SynTree/LinkageSpec.h"// for Spec, C, Intrinsic29 #include "Parser/LinkageSpec.h" // for Spec, C, Intrinsic 30 30 #include "SynTree/Constant.h" // for Constant 31 31 #include "SynTree/Declaration.h" // for StructDecl, DeclarationWithType … … 304 304 // produce the TupleType which aggregates the types of the exprs 305 305 std::list< Type * > types; 306 Type::Qualifiers qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type:: Atomic | Type::Mutex );306 Type::Qualifiers qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type::Lvalue | Type::Atomic | Type::Mutex ); 307 307 for ( Expression * expr : exprs ) { 308 308 assert( expr->get_result() ); … … 361 361 const ast::TypeInstType * isTtype( const ast::Type * type ) { 362 362 if ( const ast::TypeInstType * inst = dynamic_cast< const ast::TypeInstType * >( type ) ) { 363 if ( inst->base && inst->base->kind == ast::Type Decl::Ttype ) {363 if ( inst->base && inst->base->kind == ast::TypeVar::Ttype ) { 364 364 return inst; 365 365 } -
src/cfa.make
r3d5701e r9fb8f01 1 2 1 3 CFACOMPILE = $(CFACC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) $(AM_CFLAGS) $(CFLAGS) 2 4 LTCFACOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ 3 5 $(LIBTOOLFLAGS) --mode=compile $(CFACC) $(DEFS) \ 4 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(AM_CFLAGS) $(CFAFLAGS) $(CFLAGS) 6 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) \ 7 $(AM_CFLAGS) $(CFLAGS) 5 8 6 9 AM_V_CFA = $(am__v_CFA_@AM_V@) … … 19 22 $(am__mv) $$depbase.Tpo $$depbase.Plo 20 23 24 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@) 25 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@) 26 am__v_JAVAC_0 = @echo " JAVAC " $@; 27 am__v_JAVAC_1 = 28 29 AM_V_GOC = $(am__v_GOC_@AM_V@) 30 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@) 31 am__v_GOC_0 = @echo " GOC " $@; 32 am__v_GOC_1 = 33 21 34 UPPCC = u++ 22 35 UPPCOMPILE = $(UPPCC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_UPPFLAGS) $(UPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_CFLAGS) $(CFLAGS) … … 26 39 am__v_UPP_0 = @echo " UPP " $@; 27 40 am__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_PY = $(am__v_PY_@AM_V@)35 am__v_PY_ = $(am__v_PY_@AM_DEFAULT_V@)36 am__v_PY_0 = @echo " PYTHON " $@;37 am__v_PY_1 =38 39 AM_V_RUST = $(am__v_RUST_@AM_V@)40 am__v_RUST_ = $(am__v_RUST_@AM_DEFAULT_V@)41 am__v_RUST_0 = @echo " RUST " $@;42 am__v_RUST_1 =43 44 AM_V_NODEJS = $(am__v_NODEJS_@AM_V@)45 am__v_NODEJS_ = $(am__v_NODEJS_@AM_DEFAULT_V@)46 am__v_NODEJS_0 = @echo " NODEJS " $@;47 am__v_NODEJS_1 =48 49 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)50 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)51 am__v_JAVAC_0 = @echo " JAVAC " $@;52 am__v_JAVAC_1 = -
src/main.cc
r3d5701e r9fb8f01 10 10 // Created On : Fri May 15 23:12:02 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 8 08:33:50 202013 // Update Count : 6 3312 // Last Modified On : Fri Aug 23 06:50:08 2019 13 // Update Count : 607 14 14 // 15 15 … … 20 20 #include <cstdio> // for fopen, FILE, fclose, stdin 21 21 #include <cstdlib> // for exit, free, abort, EXIT_F... 22 #include <csignal> // for signal, SIGABRT, SIGSEGV22 #include <csignal> // for signal, SIGABRT, SIGSEGV 23 23 #include <cstring> // for index 24 24 #include <fstream> // for ofstream … … 28 28 #include <list> // for list 29 29 #include <string> // for char_traits, operator<< 30 31 using namespace std;32 33 30 34 31 #include "CompilationState.h" … … 56 53 #include "InitTweak/GenInit.h" // for genInit 57 54 #include "MakeLibCfa.h" // for makeLibCfa 55 #include "Parser/LinkageSpec.h" // for Spec, Cforall, Intrinsic 58 56 #include "Parser/ParseNode.h" // for DeclarationNode, buildList 59 57 #include "Parser/TypedefTable.h" // for TypedefTable … … 61 59 #include "ResolvExpr/Resolver.h" // for resolve 62 60 #include "SymTab/Validate.h" // for validate 63 #include "SynTree/ LinkageSpec.h" // for Spec, Cforall, Intrinsic61 #include "SynTree/TopLvalue.h" // for assertTopLvalue, clearInn... 64 62 #include "SynTree/Declaration.h" // for Declaration 65 63 #include "SynTree/Visitor.h" // for acceptAll … … 67 65 #include "Virtual/ExpandCasts.h" // for expandCasts 68 66 67 68 using namespace std; 69 69 70 70 static void NewPass( const char * const name ) { … … 98 98 static bool waiting_for_gdb = false; // flag to set cfa-cpp to wait for gdb on start 99 99 100 static st ring PreludeDirector = "";100 static std::string PreludeDirector = ""; 101 101 102 102 static void parse_cmdline( int argc, char *argv[] ); … … 105 105 106 106 static void backtrace( int start ) { // skip first N stack frames 107 enum { Frames = 50 , }; // maximum number of stack frames107 enum { Frames = 50 }; 108 108 void * array[Frames]; 109 size_t size = ::backtrace( array, Frames );109 int size = ::backtrace( array, Frames ); 110 110 char ** messages = ::backtrace_symbols( array, size ); // does not demangle names 111 111 … … 114 114 115 115 // skip last 2 stack frames after main 116 for ( unsignedint i = start; i < size - 2 && messages != nullptr; i += 1 ) {116 for ( int i = start; i < size - 2 && messages != nullptr; i += 1 ) { 117 117 char * mangled_name = nullptr, * offset_begin = nullptr, * offset_end = nullptr; 118 119 for ( char * p = messages[i]; *p; p += 1 ) { // find parantheses and +offset 118 for ( char *p = messages[i]; *p; ++p ) { // find parantheses and +offset 120 119 if ( *p == '(' ) { 121 120 mangled_name = p; … … 155 154 } // backtrace 156 155 157 #define SIGPARMS int sig __attribute__(( unused )), siginfo_t * sfp __attribute__(( unused )), ucontext_t * cxt __attribute__(( unused )) 158 159 static void Signal( int sig, void (*handler)(SIGPARMS), int flags ) { 160 struct sigaction act; 161 162 act.sa_sigaction = (void (*)(int, siginfo_t *, void *))handler; 163 act.sa_flags = flags; 164 165 if ( sigaction( sig, &act, nullptr ) == -1 ) { 166 cerr << "*CFA runtime error* problem installing signal handler, error(" << errno << ") " << strerror( errno ) << endl; 167 _exit( EXIT_FAILURE ); 168 } // if 169 } // Signal 170 171 static void sigSegvBusHandler( SIGPARMS ) { 172 if ( sfp->si_addr == nullptr ) { 173 cerr << "Null pointer (nullptr) dereference." << endl; 174 } else { 175 cerr << (sig == SIGSEGV ? "Segment fault" : "Bus error") << " at memory location " << sfp->si_addr << "." << endl 176 << "Possible cause is reading outside the address space or writing to a protected area within the address space with an invalid pointer or subscript." << endl; 177 } // if 156 static void sigSegvBusHandler( int sig_num ) { 157 cerr << "*CFA runtime error* program cfa-cpp terminated with " 158 << (sig_num == SIGSEGV ? "segment fault" : "bus error") 159 << "." << endl; 178 160 backtrace( 2 ); // skip first 2 stack frames 161 //_exit( EXIT_FAILURE ); 179 162 abort(); // cause core dump for debugging 180 163 } // sigSegvBusHandler 181 164 182 static void sigFpeHandler( SIGPARMS ) { 183 const char * msg; 184 185 switch ( sfp->si_code ) { 186 case FPE_INTDIV: case FPE_FLTDIV: msg = "divide by zero"; break; 187 case FPE_FLTOVF: msg = "overflow"; break; 188 case FPE_FLTUND: msg = "underflow"; break; 189 case FPE_FLTRES: msg = "inexact result"; break; 190 case FPE_FLTINV: msg = "invalid operation"; break; 191 default: msg = "unknown"; 192 } // choose 193 cerr << "Computation error " << msg << " at location " << sfp->si_addr << endl 194 << "Possible cause is constant-expression evaluation invalid." << endl; 195 backtrace( 2 ); // skip first 2 stack frames 196 abort(); // cause core dump for debugging 197 } // sigFpeHandler 198 199 static void sigAbortHandler( SIGPARMS ) { 165 static void sigAbortHandler( __attribute__((unused)) int sig_num ) { 200 166 backtrace( 6 ); // skip first 6 stack frames 201 Signal( SIGABRT, (void (*)(SIGPARMS))SIG_DFL, SA_SIGINFO );// reset default signal handler167 signal( SIGABRT, SIG_DFL); // reset default signal handler 202 168 raise( SIGABRT ); // reraise SIGABRT 203 169 } // sigAbortHandler … … 208 174 list< Declaration * > translationUnit; 209 175 210 Signal( SIGSEGV, sigSegvBusHandler, SA_SIGINFO ); 211 Signal( SIGBUS, sigSegvBusHandler, SA_SIGINFO ); 212 Signal( SIGFPE, sigFpeHandler, SA_SIGINFO ); 213 Signal( SIGABRT, sigAbortHandler, SA_SIGINFO ); 214 215 // cout << "main" << endl; 176 signal( SIGSEGV, sigSegvBusHandler ); 177 signal( SIGBUS, sigSegvBusHandler ); 178 signal( SIGABRT, sigAbortHandler ); 179 180 // std::cout << "main" << std::endl; 216 181 // for ( int i = 0; i < argc; i += 1 ) { 217 // cout << '\t' << argv[i] <<endl;182 // std::cout << '\t' << argv[i] << std::endl; 218 183 // } // for 219 184 … … 222 187 223 188 if ( waiting_for_gdb ) { 224 cerr << "Waiting for gdb" <<endl;225 cerr << "run :" <<endl;226 cerr << " gdb attach " << getpid() <<endl;189 std::cerr << "Waiting for gdb" << std::endl; 190 std::cerr << "run :" << std::endl; 191 std::cerr << " gdb attach " << getpid() << std::endl; 227 192 raise(SIGSTOP); 228 193 } // if … … 294 259 Stats::Time::StopBlock(); 295 260 261 //std::cerr << "Post-Parse Check" << std::endl; 262 clearInnerLvalue( translationUnit ); 263 assertTopLvalue( translationUnit ); 264 296 265 // add the assignment statement after the initialization of a type parameter 297 266 PASS( "Validate", SymTab::validate( translationUnit, symtabp ) ); … … 312 281 } // if 313 282 283 assertTopLvalue( translationUnit ); 314 284 PASS( "Fix Labels", ControlStruct::fixLabels( translationUnit ) ); 285 assertTopLvalue( translationUnit ); 315 286 PASS( "Fix Names", CodeGen::fixNames( translationUnit ) ); 287 assertTopLvalue( translationUnit ); 316 288 PASS( "Gen Init", InitTweak::genInit( translationUnit ) ); 289 assertTopLvalue( translationUnit ); 317 290 PASS( "Expand Member Tuples" , Tuples::expandMemberTuples( translationUnit ) ); 291 assertTopLvalue( translationUnit ); 318 292 if ( libcfap ) { 319 293 // generate the bodies of cfa library functions … … 339 313 } // if 340 314 315 assertTopLvalue( translationUnit ); 316 341 317 PASS( "Resolve", ResolvExpr::resolve( translationUnit ) ); 342 318 if ( exprp ) { … … 345 321 } // if 346 322 323 clearInnerLvalue( translationUnit ); 324 assertTopLvalue( translationUnit ); 325 347 326 // fix ObjectDecl - replaces ConstructorInit nodes 348 327 PASS( "Fix Init", InitTweak::fix( translationUnit, buildingLibrary() ) ); 328 clearInnerLvalue( translationUnit ); 329 assertTopLvalue( translationUnit ); 349 330 if ( ctorinitp ) { 350 331 dump ( translationUnit ); … … 353 334 354 335 PASS( "Expand Unique Expr", Tuples::expandUniqueExpr( translationUnit ) ); // xxx - is this the right place for this? want to expand ASAP so tha, sequent passes don't need to worry about double-visiting a unique expr - needs to go after InitTweak::fix so that copy constructed return declarations are reused 336 assertTopLvalue( translationUnit ); 355 337 356 338 PASS( "Translate EHM" , ControlStruct::translateEHM( translationUnit ) ); 339 assertTopLvalue( translationUnit ); 357 340 358 341 PASS( "Gen Waitfor" , Concurrency::generateWaitFor( translationUnit ) ); 342 clearInnerLvalue( translationUnit ); 343 assertTopLvalue( translationUnit ); 359 344 360 345 PASS( "Convert Specializations", GenPoly::convertSpecializations( translationUnit ) ); // needs to happen before tuple types are expanded 346 clearInnerLvalue( translationUnit ); 347 assertTopLvalue( translationUnit ); 361 348 362 349 PASS( "Expand Tuples", Tuples::expandTuples( translationUnit ) ); // xxx - is this the right place for this? 350 assertTopLvalue( translationUnit ); 363 351 364 352 if ( tuplep ) { … … 368 356 369 357 PASS( "Virtual Expand Casts", Virtual::expandCasts( translationUnit ) ); // Must come after translateEHM 358 assertTopLvalue( translationUnit ); 370 359 371 360 PASS( "Instantiate Generics", GenPoly::instantiateGeneric( translationUnit ) ); … … 374 363 return EXIT_SUCCESS; 375 364 } // if 376 365 clearInnerLvalue( translationUnit ); 366 assertTopLvalue( translationUnit ); 377 367 PASS( "Convert L-Value", GenPoly::convertLvalue( translationUnit ) ); 368 clearInnerLvalue( translationUnit ); 369 assertTopLvalue( translationUnit ); 378 370 379 371 if ( bboxp ) { … … 382 374 } // if 383 375 PASS( "Box", GenPoly::box( translationUnit ) ); 376 clearInnerLvalue( translationUnit ); 377 assertTopLvalue( translationUnit ); 384 378 385 379 if ( bcodegenp ) { … … 393 387 394 388 CodeTools::fillLocations( translationUnit ); 389 assertTopLvalue( translationUnit ); 395 390 PASS( "Code Gen", CodeGen::generate( translationUnit, *output, ! genproto, prettycodegenp, true, linemarks ) ); 396 391 … … 424 419 return EXIT_FAILURE; 425 420 } catch ( ... ) { 426 exception_ptr eptr =current_exception();421 std::exception_ptr eptr = std::current_exception(); 427 422 try { 428 423 if (eptr) { 429 rethrow_exception(eptr);424 std::rethrow_exception(eptr); 430 425 } else { 431 cerr << "Exception Uncaught and Unknown" <<endl;432 } // if 433 } catch(const exception& e) {434 cerr << "Uncaught Exception \"" << e.what() << "\"\n";426 std::cerr << "Exception Uncaught and Unknown" << std::endl; 427 } // if 428 } catch(const std::exception& e) { 429 std::cerr << "Uncaught Exception \"" << e.what() << "\"\n"; 435 430 } // try 436 431 return EXIT_FAILURE; … … 443 438 444 439 445 static const char optstring[] = ": c:ghlLmNnpP:S:twW:D:";440 static const char optstring[] = ":hlLmNnpP:S:twW:D:"; 446 441 447 442 enum { PreludeDir = 128 }; 448 443 static struct option long_opts[] = { 449 { "colors", required_argument, nullptr, 'c' },450 { "gdb", no_argument, nullptr, 'g' },451 444 { "help", no_argument, nullptr, 'h' }, 452 445 { "libcfa", no_argument, nullptr, 'l' }, … … 460 453 { "statistics", required_argument, nullptr, 'S' }, 461 454 { "tree", no_argument, nullptr, 't' }, 455 { "gdb", no_argument, nullptr, 'g' }, 462 456 { "", no_argument, nullptr, 0 }, // -w 463 457 { "", no_argument, nullptr, 0 }, // -W … … 467 461 468 462 static const char * description[] = { 469 "diagnostic color: never, always, or auto.", // -c 470 "wait for gdb to attach", // -g 471 "print help message", // -h 472 "generate libcfa.c", // -l 473 "generate line marks", // -L 474 "do not replace main", // -m 475 "do not generate line marks", // -N 476 "do not read prelude", // -n 463 "print help message", // -h 464 "generate libcfa.c", // -l 465 "generate line marks", // -L 466 "do not replace main", // -m 467 "do not generate line marks", // -N 468 "do not read prelude", // -n 477 469 "generate prototypes for prelude functions", // -p 478 "print", // -P470 "print", // -P 479 471 "<directory> prelude directory for debug/nodebug", // no flag 480 472 "<option-list> enable profiling information:\n counters,heap,time,all,none", // -S 481 "building cfa standard lib", // -t 482 "", // -w 483 "", // -W 484 "", // -D 473 "building cfa standard lib", // -t 474 "wait for gdb to attach", // -g 475 "", // -w 476 "", // -W 477 "", // -D 485 478 }; // description 486 479 … … 550 543 while ( (c = getopt_long( argc, argv, optstring, long_opts, nullptr )) != -1 ) { 551 544 switch ( c ) { 552 case 'c': // diagnostic colors553 if ( strcmp( optarg, "always" ) == 0 ) {554 ErrorHelpers::colors = ErrorHelpers::Colors::Always;555 } else if ( strcmp( optarg, "never" ) == 0 ) {556 ErrorHelpers::colors = ErrorHelpers::Colors::Never;557 } else if ( strcmp( optarg, "auto" ) == 0 ) {558 ErrorHelpers::colors = ErrorHelpers::Colors::Auto;559 } // if560 break;561 545 case 'h': // help message 562 546 usage( argv ); // no return -
tests/.expect/alloc-ERROR.txt
r3d5701e r9fb8f01 1 alloc.cfa: 310:1 error: No reasonable alternatives for expression Applying untyped:1 alloc.cfa:265:1 error: No reasonable alternatives for expression Applying untyped: 2 2 Name: ?=? 3 3 ...to: … … 19 19 20 20 21 alloc.cfa: 311:1 error: No reasonable alternatives for expression Applying untyped:21 alloc.cfa:266:1 error: No reasonable alternatives for expression Applying untyped: 22 22 Name: ?=? 23 23 ...to: … … 39 39 40 40 41 alloc.cfa: 312:1 error: No reasonable alternatives for expression Applying untyped:41 alloc.cfa:267:1 error: No reasonable alternatives for expression Applying untyped: 42 42 Name: ?=? 43 43 ...to: … … 50 50 51 51 52 alloc.cfa: 313:1 error: No reasonable alternatives for expression Applying untyped:52 alloc.cfa:268:1 error: No reasonable alternatives for expression Applying untyped: 53 53 Name: ?=? 54 54 ...to: -
tests/.expect/alloc.txt
r3d5701e r9fb8f01 2 2 CFA malloc 0xdeadbeef 3 3 CFA alloc 0xdeadbeef 4 CFA alloc, fill dededede 5 CFA alloc, fill 3 4 CFA alloc, fill ffffffff 6 5 7 6 C array calloc, fill 0 … … 11 10 CFA array alloc, no fill 12 11 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 13 CFA array alloc, fill 0xde 14 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 15 CFA array alloc, fill 0xef 16 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 17 CFA array alloc, fill from array 18 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 12 CFA array alloc, fill 0xff 13 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 19 14 20 C realloc21 0x efefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef15 C realloc 16 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 22 17 CFA realloc 23 0x efefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x101010118 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 24 19 25 CFA resize a rray alloc20 CFA resize alloc 26 21 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 27 22 CFA resize array alloc … … 29 24 CFA resize array alloc 30 25 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 31 CFA resize array alloc32 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede33 CFA resize array alloc34 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef35 26 CFA resize array alloc, fill 36 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 27 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 28 CFA resize array alloc, fill 29 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 30 CFA resize array alloc, fill 31 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 37 32 38 33 C memalign 42 42.5 … … 40 35 CFA posix_memalign 42 42.5 41 36 CFA posix_memalign 42 42.5 42 CFA alloc_align 42 42.5 43 CFA alloc_align 42 42.5 44 CFA alloc_align fill 0xdededede -0x1.ededededededep+494 45 CFA alloc_align fill 42 42.5 46 CFA alloc_align 42 42.5 37 CFA aligned_alloc 42 42.5 38 CFA align_alloc 42 42.5 39 CFA align_alloc fill 0xffffffff -nan 47 40 48 CFA array al loc_align41 CFA array align_alloc 49 42 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 50 CFA array alloc_align, fill 51 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 52 CFA array alloc_align, fill 53 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 54 CFA array alloc_align, fill array 55 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 56 CFA realloc array alloc_align 57 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 43 CFA array align_alloc, fill 44 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 58 45 59 CFA memset 0x dededede -0x1.ededededededep+49460 CFA memcpy 0x dededede -0x1.ededededededep+49446 CFA memset 0xffffffff -nan 47 CFA memcpy 0xffffffff -nan 61 48 62 49 CFA array memset 63 0x dededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494,50 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 64 51 CFA array memcpy 65 0x dededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494, 0xdededede -0x1.ededededededep+494,52 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 66 53 67 54 CFA new initialize -
tests/.expect/attributes.x64.txt
r3d5701e r9fb8f01 784 784 signed int _X4apd7Fi_Fi_i_Fi_i___1(__attribute__ ((unused,unused,unused)) signed int (*__anonymous_object23)(__attribute__ ((unused)) signed int __anonymous_object24), __attribute__ ((unused,unused,unused)) signed int (*__anonymous_object25)(__attribute__ ((unused)) signed int __anonymous_object26)); 785 785 struct Vad { 786 __attribute__ ((unused)) signed int :4;787 __attribute__ ((unused)) signed int :4;788 __attribute__ ((unused,unused)) signed int :6;786 __attribute__ ((unused)) signed int __anonymous_object27:4; 787 __attribute__ ((unused)) signed int __anonymous_object28:4; 788 __attribute__ ((unused,unused)) signed int __anonymous_object29:6; 789 789 }; 790 790 static inline void _X12_constructorFv_S3Vad_autogen___1(struct Vad *_X4_dstS3Vad_1); -
tests/.expect/attributes.x86.txt
r3d5701e r9fb8f01 784 784 signed int _X4apd7Fi_Fi_i_Fi_i___1(__attribute__ ((unused,unused,unused)) signed int (*__anonymous_object23)(__attribute__ ((unused)) signed int __anonymous_object24), __attribute__ ((unused,unused,unused)) signed int (*__anonymous_object25)(__attribute__ ((unused)) signed int __anonymous_object26)); 785 785 struct Vad { 786 __attribute__ ((unused)) signed int :4;787 __attribute__ ((unused)) signed int :4;788 __attribute__ ((unused,unused)) signed int :6;786 __attribute__ ((unused)) signed int __anonymous_object27:4; 787 __attribute__ ((unused)) signed int __anonymous_object28:4; 788 __attribute__ ((unused,unused)) signed int __anonymous_object29:6; 789 789 }; 790 790 static inline void _X12_constructorFv_S3Vad_autogen___1(struct Vad *_X4_dstS3Vad_1); -
tests/.expect/gccExtensions.x64.txt
r3d5701e r9fb8f01 12 12 asm volatile ( "mov %1, %0\n\t" "add $1, %0" : "=" "r" ( _X3dsti_2 ) : : ); 13 13 asm volatile ( "mov %1, %0\n\t" "add $1, %0" : "=r" ( _X3dsti_2 ) : "r" ( _X3srci_2 ) : ); 14 asm ( "mov %1, %0\n\t" "add $1, %0" : "=r" ( _X3dsti_2 ), "=r" ( _X3srci_2 ) : [ src] "r" ( _X3dsti_2 ) : "r0" );14 asm ( "mov %1, %0\n\t" "add $1, %0" : "=r" ( _X3dsti_2 ), "=r" ( _X3srci_2 ) : [ _X3srci_2 ] "r" ( _X3dsti_2 ) : "r0" ); 15 15 L2: L1: asm goto ( "frob %%r5, %1; jc %l[L1]; mov (%2), %%r5" : : "r" ( _X3srci_2 ), "r" ( (&_X3dsti_2) ) : "r5", "memory" : L1, L2 ); 16 16 double _Complex _X2c1Cd_2; -
tests/.expect/gccExtensions.x86.txt
r3d5701e r9fb8f01 12 12 asm volatile ( "mov %1, %0\n\t" "add $1, %0" : "=" "r" ( _X3dsti_2 ) : : ); 13 13 asm volatile ( "mov %1, %0\n\t" "add $1, %0" : "=r" ( _X3dsti_2 ) : "r" ( _X3srci_2 ) : ); 14 asm ( "mov %1, %0\n\t" "add $1, %0" : "=r" ( _X3dsti_2 ), "=r" ( _X3srci_2 ) : [ src] "r" ( _X3dsti_2 ) : "r0" );14 asm ( "mov %1, %0\n\t" "add $1, %0" : "=r" ( _X3dsti_2 ), "=r" ( _X3srci_2 ) : [ _X3srci_2 ] "r" ( _X3dsti_2 ) : "r0" ); 15 15 L2: L1: asm goto ( "frob %%r5, %1; jc %l[L1]; mov (%2), %%r5" : : "r" ( _X3srci_2 ), "r" ( (&_X3dsti_2) ) : "r5", "memory" : L1, L2 ); 16 16 double _Complex _X2c1Cd_2; -
tests/.expect/loopctrl.txt
r3d5701e r9fb8f01 6 6 A 7 7 A A A A A A A A A A 8 A A A A A A A A A A A9 8 B B B B B 10 9 C C C C C … … 13 12 14 13 0 1 2 3 4 5 6 7 8 9 15 0 1 2 3 4 5 6 7 8 9 1016 14 1 3 5 7 9 17 15 10 8 6 4 2 … … 30 28 N N N N N N N N N N 31 29 0 1 2 3 4 5 6 7 8 9 32 0 1 2 3 4 5 6 7 8 9 1033 30 10 9 8 7 6 5 4 3 2 1 34 31 -
tests/.expect/nested-types-ERR1.txt
r3d5701e r9fb8f01 1 nested-types.cfa: 83:1 error: Use of undefined type T1 nested-types.cfa:70:1 error: Use of undefined type T -
tests/.expect/nested-types-ERR2.txt
r3d5701e r9fb8f01 1 nested-types.cfa: 86:1 error: Use of undefined global type Z2 nested-types.cfa: 87:1 error: Qualified type requires an aggregate on the left, but has: signed int3 nested-types.cfa: 88:1 error: Undefined type in qualified type: Qualified Type:1 nested-types.cfa:73:1 error: Use of undefined global type Z 2 nested-types.cfa:74:1 error: Qualified type requires an aggregate on the left, but has: signed int 3 nested-types.cfa:75:1 error: Undefined type in qualified type: Qualified Type: 4 4 instance of struct S with body 1 5 5 instance of type Z (not function type) -
tests/.expect/rational.txt
r3d5701e r9fb8f01 1 1 constructor 2 3/1 4/1 0/1 0/1 1/12 3/1 4/1 0/1 3 3 1/2 5/7 4 4 2/3 -3/2 -
tests/.expect/references.txt
r3d5701e r9fb8f01 36 36 3 37 37 3 9 { 1., 7. }, [1, 2, 3] 38 439 38 Destructing a Y 40 39 Destructing a Y -
tests/.expect/time.txt
r3d5701e r9fb8f01 18 18 Dividing that by 2 gives 2403.5 seconds 19 19 4807 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.am
r3d5701e r9fb8f01 24 24 archiveerrors= 25 25 26 INSTALL_FLAGS=-in-tree 26 27 DEBUG_FLAGS=-debug -O0 27 28 … … 34 35 35 36 # applies to both programs 36 # since automake doesn't have support for CFA we have to37 37 AM_CFLAGS = $(if $(test), 2> $(test), ) \ 38 38 -g \ … … 42 42 -DIN_DIR="${abs_srcdir}/.in/" 43 43 44 # get the desired cfa to test 45 TARGET_CFA = $(if $(filter $(installed),yes), @CFACC_INSTALL@, @CFACC@) 46 47 # adjust CC to current flags 48 CC = $(if $(DISTCC_CFA_PATH),distcc $(DISTCC_CFA_PATH) ${ARCH_FLAGS},$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS}) 49 CFACC = $(CC) 50 51 # get local binary for depedencies 52 CFACCBIN = @CFACC@ 53 54 # adjusted CC but without the actual distcc call 55 CFACCLOCAL = $(if $(DISTCC_CFA_PATH),$(DISTCC_CFA_PATH) ${ARCH_FLAGS},$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS}) 44 AM_CFLAGS += ${DEBUG_FLAGS} ${INSTALL_FLAGS} ${ARCH_FLAGS} 45 CC = @CFACC@ 56 46 57 47 PRETTY_PATH=mkdir -p $(dir $(abspath ${@})) && cd ${srcdir} && … … 67 57 #---------------------------------------------------------------------------------------------------------------- 68 58 all-local : 69 @+${TEST_PY} --debug=${debug} --install=${installed} --archive-errors=${archiveerrors} ${concurrent} ${timeouts} ${quick_test}59 @+${TEST_PY} --debug=${debug} --install=${installed} --archive-errors=${archiveerrors} ${concurrent} ${timeouts} ${quick_test} 70 60 71 61 all-tests : 72 @+${TEST_PY} --debug=${debug} --install=${installed} --archive-errors=${archiveerrors} ${concurrent} ${timeouts} --all # '@' => do not echo command (SILENT), '+' => allows recursive make from within python program62 @+${TEST_PY} --debug=${debug} --install=${installed} --archive-errors=${archiveerrors} ${concurrent} ${timeouts} --all # '@' => do not echo command (SILENT), '+' => allows recursive make from within python program 73 63 74 64 clean-local : … … 97 87 98 88 # Use for all tests, make sure the path are correct and all flags are added 99 CFACOMPILETEST=$(PRETTY_PATH) $(CFACOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) $($(shell echo "${@}_FLAGSCFA" | sed 's/-\|\//_/g')) 89 CFACOMPILETEST=$(PRETTY_PATH) $(CFACOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) $($(shell echo "${@}_FLAGS" | sed 's/-\|\//_/g')) 90 91 # Use for tests that either generate an executable, print directyl to stdout or the make command is expected to fail 92 CFATEST_STDOUT=$(CFACOMPILETEST) -o $(abspath ${@}) 93 94 # Use for tests where the make command is expecte to succeed but the expected.txt should be compared to stderr 95 CFATEST_STDERR=$(CFACOMPILETEST) 2> $(abspath ${@}) 100 96 101 97 #---------------------------------------------------------------------------------------------------------------- 102 98 103 99 # implicit rule so not all test require a rule 104 # split into two steps to support compiling remotely using distcc 105 # don't use distcc to do the linking because distcc doesn't do linking 106 % : %.cfa $(CFACCBIN) 107 $(CFACOMPILETEST) -c -o $(abspath ${@}).o 108 $(CFACCLOCAL) $($(shell echo "${@}_FLAGSLD" | sed 's/-\|\//_/g')) $(abspath ${@}).o -o $(abspath ${@}) 100 % : %.cfa $(CFACC) 101 $(CFATEST_STDOUT) 109 102 110 # implicit rule for c++ test111 # convient for testing the testsuite itself but not actuall used112 103 % : %.cpp 113 104 $(PRETTY_PATH) $(CXXCOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 114 105 115 106 #------------------------------------------------------------------------------ 116 # TARGET S WITHCUSTOM FLAGS107 # TARGET WITH STANDARD RULE BUT CUSTOM FLAGS 117 108 #------------------------------------------------------------------------------ 118 # custom libs 119 gmp_FLAGSLD= -lgmp 109 # Expected failures 110 declarationSpecifier_FLAGS= -CFA -XCFA -p 111 gccExtensions_FLAGS= -CFA -XCFA -p 112 extension_FLAGS= -CFA -XCFA -p 113 attributes_FLAGS= -CFA -XCFA -p 114 functions_FLAGS= -CFA -XCFA -p 115 KRfunctions_FLAGS= -CFA -XCFA -p 116 gmp_FLAGS= -lgmp 120 117 121 118 #------------------------------------------------------------------------------ 122 # Generated code 123 GENERATED_CODE = declarationSpecifier gccExtensions extension attributes functions KRfunctions 124 $(GENERATED_CODE): % : %.cfa $(CFACCBIN) 125 $(CFACOMPILETEST) -CFA -XCFA -p -c -fsyntax-only -o $(abspath ${@}) 126 127 # Use for tests where the make command is expected to succeed but the expected.txt should be compared to stderr 128 EXPECT_STDERR = builtins/sync warnings/self-assignment 129 $(EXPECT_STDERR): % : %.cfa $(CFACCBIN) 130 $(CFACOMPILETEST) -c -fsyntax-only 2> $(abspath ${@}) 119 # Expected failures 120 completeTypeError_FLAGS= -DERR1 131 121 132 122 #------------------------------------------------------------------------------ 133 123 # CUSTOM TARGET 134 124 #------------------------------------------------------------------------------ 135 # expected failures 136 # use custom target since they require a custom define and custom dependencies 137 alloc-ERROR : alloc.cfa $(CFACCBIN) 138 $(CFACOMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@}) 125 typedefRedef-ERR1: typedefRedef.cfa $(CFACC) 126 $(CFATEST_STDOUT) -DERR1 139 127 140 typedefRedef-ERR1 : typedefRedef.cfa $(CFACCBIN)141 $(CFA COMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@})128 alloc-ERROR: alloc.cfa $(CFACC) 129 $(CFATEST_STDOUT) -DERR1 142 130 143 nested-types-ERR1 : nested-types.cfa $(CFACCBIN)144 $(CFA COMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@})131 nested-types-ERR1: nested-types.cfa $(CFACC) 132 $(CFATEST_STDOUT) -DERR1 145 133 146 nested-types-ERR2 : nested-types.cfa $(CFACCBIN)147 $(CFA COMPILETEST) -DERR2 -c -fsyntax-only -o $(abspath ${@})134 nested-types-ERR2: nested-types.cfa $(CFACC) 135 $(CFATEST_STDOUT) -DERR2 148 136 149 raii/ memberCtors-ERR1 : raii/memberCtors.cfa $(CFACCBIN)150 $(CFA COMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@})137 raii/dtor-early-exit-ERR1: raii/dtor-early-exit.cfa $(CFACC) 138 $(CFATEST_STDOUT) -DERR1 151 139 152 raii/ ctor-autogen-ERR1 : raii/ctor-autogen.cfa $(CFACCBIN)153 $(CFA COMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@})140 raii/dtor-early-exit-ERR2: raii/dtor-early-exit.cfa $(CFACC) 141 $(CFATEST_STDOUT) -DERR2 154 142 155 raii/ dtor-early-exit-ERR1 : raii/dtor-early-exit.cfa $(CFACCBIN)156 $(CFA COMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@})143 raii/memberCtors-ERR1: raii/memberCtors.cfa $(CFACC) 144 $(CFATEST_STDOUT) -DERR1 157 145 158 raii/ dtor-early-exit-ERR2 : raii/dtor-early-exit.cfa $(CFACCBIN)159 $(CFA COMPILETEST) -DERR2 -c -fsyntax-only -o $(abspath ${@})146 raii/ctor-autogen-ERR1: raii/ctor-autogen.cfa $(CFACC) 147 $(CFATEST_STDOUT) -DERR1 160 148 161 #------------------------------------------------------------------------------ 162 # Other targets 149 #builtins 150 builtins/sync: builtins/sync.cfa $(CFACC) 151 $(CFATEST_STDERR) -fsyntax-only 152 153 # Warnings 154 warnings/self-assignment: warnings/self-assignment.cfa $(CFACC) 155 $(CFATEST_STDERR) -fsyntax-only -
tests/Makefile.in
r3d5701e r9fb8f01 212 212 AWK = @AWK@ 213 213 BUILD_IN_TREE_FLAGS = @BUILD_IN_TREE_FLAGS@ 214 215 # adjust CC to current flags 216 CC = $(if $(DISTCC_CFA_PATH),distcc $(DISTCC_CFA_PATH) ${ARCH_FLAGS},$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS}) 214 CC = @CFACC@ 217 215 CCAS = @CCAS@ 218 216 CCASDEPMODE = @CCASDEPMODE@ 219 217 CCASFLAGS = @CCASFLAGS@ 220 218 CCDEPMODE = @CCDEPMODE@ 221 CFACC = $(CC) 222 CFACC_INSTALL = @CFACC_INSTALL@ 219 CFACC = @CFACC@ 223 220 CFACPP = @CFACPP@ 224 221 CFA_BACKEND_CC = @CFA_BACKEND_CC@ … … 251 248 FGREP = @FGREP@ 252 249 GREP = @GREP@ 253 HAS_DISTCC = @HAS_DISTCC@254 250 HOST_FLAGS = @HOST_FLAGS@ 255 251 INSTALL = @INSTALL@ … … 358 354 LTCFACOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ 359 355 $(LIBTOOLFLAGS) --mode=compile $(CFACC) $(DEFS) \ 360 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(AM_CFLAGS) $(CFAFLAGS) $(CFLAGS) 356 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) \ 357 $(AM_CFLAGS) $(CFLAGS) 361 358 362 359 AM_V_CFA = $(am__v_CFA_@AM_V@) … … 364 361 am__v_CFA_0 = @echo " CFA " $@; 365 362 am__v_CFA_1 = 363 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@) 364 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@) 365 am__v_JAVAC_0 = @echo " JAVAC " $@; 366 am__v_JAVAC_1 = 367 AM_V_GOC = $(am__v_GOC_@AM_V@) 368 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@) 369 am__v_GOC_0 = @echo " GOC " $@; 370 am__v_GOC_1 = 366 371 UPPCC = u++ 367 372 UPPCOMPILE = $(UPPCC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_UPPFLAGS) $(UPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_CFLAGS) $(CFLAGS) … … 370 375 am__v_UPP_0 = @echo " UPP " $@; 371 376 am__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_PY = $(am__v_PY_@AM_V@)377 am__v_PY_ = $(am__v_PY_@AM_DEFAULT_V@)378 am__v_PY_0 = @echo " PYTHON " $@;379 am__v_PY_1 =380 AM_V_RUST = $(am__v_RUST_@AM_V@)381 am__v_RUST_ = $(am__v_RUST_@AM_DEFAULT_V@)382 am__v_RUST_0 = @echo " RUST " $@;383 am__v_RUST_1 =384 AM_V_NODEJS = $(am__v_NODEJS_@AM_V@)385 am__v_NODEJS_ = $(am__v_NODEJS_@AM_DEFAULT_V@)386 am__v_NODEJS_0 = @echo " NODEJS " $@;387 am__v_NODEJS_1 =388 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)389 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)390 am__v_JAVAC_0 = @echo " JAVAC " $@;391 am__v_JAVAC_1 =392 377 debug = yes 393 378 installed = no 394 379 archiveerrors = 380 INSTALL_FLAGS = -in-tree 395 381 DEBUG_FLAGS = -debug -O0 396 382 quick_test = avl_test operators numericConstants expression enum array typeof cast raii/dtor-early-exit raii/init_once attributes … … 400 386 401 387 # applies to both programs 402 # since automake doesn't have support for CFA we have to 403 AM_CFLAGS = $(if $(test), 2> $(test), ) \ 404 -g \ 405 -Wall \ 406 -Wno-unused-function \ 407 -quiet @CFA_FLAGS@ \ 408 -DIN_DIR="${abs_srcdir}/.in/" 409 410 411 # get the desired cfa to test 412 TARGET_CFA = $(if $(filter $(installed),yes), @CFACC_INSTALL@, @CFACC@) 413 414 # get local binary for depedencies 415 CFACCBIN = @CFACC@ 416 417 # adjusted CC but without the actual distcc call 418 CFACCLOCAL = $(if $(DISTCC_CFA_PATH),$(DISTCC_CFA_PATH) ${ARCH_FLAGS},$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS}) 388 AM_CFLAGS = $(if $(test), 2> $(test), ) -g -Wall -Wno-unused-function \ 389 -quiet @CFA_FLAGS@ -DIN_DIR="${abs_srcdir}/.in/" \ 390 ${DEBUG_FLAGS} ${INSTALL_FLAGS} ${ARCH_FLAGS} 419 391 PRETTY_PATH = mkdir -p $(dir $(abspath ${@})) && cd ${srcdir} && 420 392 avl_test_SOURCES = avltree/avl_test.cfa avltree/avl0.cfa avltree/avl1.cfa avltree/avl2.cfa avltree/avl3.cfa avltree/avl4.cfa avltree/avl-private.cfa … … 425 397 426 398 # Use for all tests, make sure the path are correct and all flags are added 427 CFACOMPILETEST = $(PRETTY_PATH) $(CFACOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) $($(shell echo "${@}_FLAGSCFA" | sed 's/-\|\//_/g')) 399 CFACOMPILETEST = $(PRETTY_PATH) $(CFACOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) $($(shell echo "${@}_FLAGS" | sed 's/-\|\//_/g')) 400 401 # Use for tests that either generate an executable, print directyl to stdout or the make command is expected to fail 402 CFATEST_STDOUT = $(CFACOMPILETEST) -o $(abspath ${@}) 403 404 # Use for tests where the make command is expecte to succeed but the expected.txt should be compared to stderr 405 CFATEST_STDERR = $(CFACOMPILETEST) 2> $(abspath ${@}) 428 406 429 407 #------------------------------------------------------------------------------ 430 # TARGET S WITHCUSTOM FLAGS408 # TARGET WITH STANDARD RULE BUT CUSTOM FLAGS 431 409 #------------------------------------------------------------------------------ 432 # custom libs 433 gmp_FLAGSLD = -lgmp 410 # Expected failures 411 declarationSpecifier_FLAGS = -CFA -XCFA -p 412 gccExtensions_FLAGS = -CFA -XCFA -p 413 extension_FLAGS = -CFA -XCFA -p 414 attributes_FLAGS = -CFA -XCFA -p 415 functions_FLAGS = -CFA -XCFA -p 416 KRfunctions_FLAGS = -CFA -XCFA -p 417 gmp_FLAGS = -lgmp 434 418 435 419 #------------------------------------------------------------------------------ 436 # Generated code 437 GENERATED_CODE = declarationSpecifier gccExtensions extension attributes functions KRfunctions 438 439 # Use for tests where the make command is expected to succeed but the expected.txt should be compared to stderr 440 EXPECT_STDERR = builtins/sync warnings/self-assignment 420 # Expected failures 421 completeTypeError_FLAGS = -DERR1 441 422 all: all-am 442 423 … … 790 771 #---------------------------------------------------------------------------------------------------------------- 791 772 all-local : 792 @+${TEST_PY} --debug=${debug} --install=${installed} --archive-errors=${archiveerrors} ${concurrent} ${timeouts} ${quick_test}773 @+${TEST_PY} --debug=${debug} --install=${installed} --archive-errors=${archiveerrors} ${concurrent} ${timeouts} ${quick_test} 793 774 794 775 all-tests : 795 @+${TEST_PY} --debug=${debug} --install=${installed} --archive-errors=${archiveerrors} ${concurrent} ${timeouts} --all # '@' => do not echo command (SILENT), '+' => allows recursive make from within python program776 @+${TEST_PY} --debug=${debug} --install=${installed} --archive-errors=${archiveerrors} ${concurrent} ${timeouts} --all # '@' => do not echo command (SILENT), '+' => allows recursive make from within python program 796 777 797 778 clean-local : … … 820 801 821 802 # implicit rule so not all test require a rule 822 # split into two steps to support compiling remotely using distcc 823 # don't use distcc to do the linking because distcc doesn't do linking 824 % : %.cfa $(CFACCBIN) 825 $(CFACOMPILETEST) -c -o $(abspath ${@}).o 826 $(CFACCLOCAL) $($(shell echo "${@}_FLAGSLD" | sed 's/-\|\//_/g')) $(abspath ${@}).o -o $(abspath ${@}) 827 828 # implicit rule for c++ test 829 # convient for testing the testsuite itself but not actuall used 803 % : %.cfa $(CFACC) 804 $(CFATEST_STDOUT) 805 830 806 % : %.cpp 831 807 $(PRETTY_PATH) $(CXXCOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@}) 832 $(GENERATED_CODE): % : %.cfa $(CFACCBIN)833 $(CFACOMPILETEST) -CFA -XCFA -p -c -fsyntax-only -o $(abspath ${@})834 $(EXPECT_STDERR): % : %.cfa $(CFACCBIN)835 $(CFACOMPILETEST) -c -fsyntax-only 2> $(abspath ${@})836 808 837 809 #------------------------------------------------------------------------------ 838 810 # CUSTOM TARGET 839 811 #------------------------------------------------------------------------------ 840 # expected failures 841 # use custom target since they require a custom define and custom dependencies 842 alloc-ERROR : alloc.cfa $(CFACCBIN) 843 $(CFACOMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@}) 844 845 typedefRedef-ERR1 : typedefRedef.cfa $(CFACCBIN) 846 $(CFACOMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@}) 847 848 nested-types-ERR1 : nested-types.cfa $(CFACCBIN) 849 $(CFACOMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@}) 850 851 nested-types-ERR2 : nested-types.cfa $(CFACCBIN) 852 $(CFACOMPILETEST) -DERR2 -c -fsyntax-only -o $(abspath ${@}) 853 854 raii/memberCtors-ERR1 : raii/memberCtors.cfa $(CFACCBIN) 855 $(CFACOMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@}) 856 857 raii/ctor-autogen-ERR1 : raii/ctor-autogen.cfa $(CFACCBIN) 858 $(CFACOMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@}) 859 860 raii/dtor-early-exit-ERR1 : raii/dtor-early-exit.cfa $(CFACCBIN) 861 $(CFACOMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@}) 862 863 raii/dtor-early-exit-ERR2 : raii/dtor-early-exit.cfa $(CFACCBIN) 864 $(CFACOMPILETEST) -DERR2 -c -fsyntax-only -o $(abspath ${@}) 865 866 #------------------------------------------------------------------------------ 867 # Other targets 812 typedefRedef-ERR1: typedefRedef.cfa $(CFACC) 813 $(CFATEST_STDOUT) -DERR1 814 815 alloc-ERROR: alloc.cfa $(CFACC) 816 $(CFATEST_STDOUT) -DERR1 817 818 nested-types-ERR1: nested-types.cfa $(CFACC) 819 $(CFATEST_STDOUT) -DERR1 820 821 nested-types-ERR2: nested-types.cfa $(CFACC) 822 $(CFATEST_STDOUT) -DERR2 823 824 raii/dtor-early-exit-ERR1: raii/dtor-early-exit.cfa $(CFACC) 825 $(CFATEST_STDOUT) -DERR1 826 827 raii/dtor-early-exit-ERR2: raii/dtor-early-exit.cfa $(CFACC) 828 $(CFATEST_STDOUT) -DERR2 829 830 raii/memberCtors-ERR1: raii/memberCtors.cfa $(CFACC) 831 $(CFATEST_STDOUT) -DERR1 832 833 raii/ctor-autogen-ERR1: raii/ctor-autogen.cfa $(CFACC) 834 $(CFATEST_STDOUT) -DERR1 835 836 #builtins 837 builtins/sync: builtins/sync.cfa $(CFACC) 838 $(CFATEST_STDERR) -fsyntax-only 839 840 # Warnings 841 warnings/self-assignment: warnings/self-assignment.cfa $(CFACC) 842 $(CFATEST_STDERR) -fsyntax-only 868 843 869 844 # Tell versions [3.59,3.63) of GNU make to not export all variables. -
tests/alloc.cfa
r3d5701e r9fb8f01 10 10 // Created On : Wed Feb 3 07:56:22 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Feb 16 09:21:13 202013 // Update Count : 40512 // Last Modified On : Tue Nov 6 17:50:52 2018 13 // Update Count : 339 14 14 // 15 15 … … 19 19 #include <stdlib.h> // posix_memalign 20 20 #include <fstream.hfa> 21 #include <stdlib.hfa> // access C malloc, realloc21 #include <stdlib.hfa> // access C malloc, realloc 22 22 23 23 int * foo( int * p, int c ) { return p; } … … 27 27 int main( void ) { 28 28 size_t dim = 10; 29 char fill = '\x de';30 int * p , * p1;29 char fill = '\xff'; 30 int * p; 31 31 32 32 // allocation, non-array types 33 33 34 // int & r = malloc(); 35 // r = 0xdeadbeef; 36 // printf( "C malloc %#x\n", r ); 37 // free( &r ); 38 34 39 p = (int *)malloc( sizeof(*p) ); // C malloc, type unsafe 35 40 *p = 0xdeadbeef; … … 47 52 free( p ); 48 53 49 p = alloc _set( fill );// CFA alloc, fill54 p = alloc( fill ); // CFA alloc, fill 50 55 printf( "CFA alloc, fill %08x\n", *p ); 51 free( p );52 53 p = alloc_set( 3 ); // CFA alloc, fill54 printf( "CFA alloc, fill %d\n", *p );55 56 free( p ); 56 57 … … 78 79 free( p ); 79 80 80 p = alloc _set( 2 * dim, fill );// CFA array alloc, fill81 p = alloc( 2 * dim, fill ); // CFA array alloc, fill 81 82 printf( "CFA array alloc, fill %#hhx\n", fill ); 82 83 for ( i; 2 * dim ) { printf( "%#x ", p[i] ); } 83 84 printf( "\n" ); 84 free( p );85 86 p = alloc_set( 2 * dim, 0xdeadbeef ); // CFA array alloc, fill87 printf( "CFA array alloc, fill %#hhx\n", 0xdeadbeef );88 for ( i; 2 * dim ) { printf( "%#x ", p[i] ); }89 printf( "\n" );90 85 // do not free 91 86 92 p1 = alloc_set( 2 * dim, p ); // CFA array alloc, fill93 printf( "CFA array alloc, fill from array\n" );94 for ( i; 2 * dim ) { printf( "%#x %#x, ", p[i], p1[i] ); }95 free( p1 );96 printf( "\n" );97 98 87 99 88 // resize, non-array types … … 101 90 102 91 p = (int *)realloc( p, dim * sizeof(*p) ); // C realloc 103 printf( "C realloc\n" );104 for ( i; dim ) { printf( "%#x ", p[i] ); }105 printf( "\n" );106 // do not free92 for ( i; dim ) { p[i] = 0xdeadbeef; } 93 printf( "C realloc\n" ); 94 for ( i; dim ) { printf( "%#x ", p[i] ); } 95 printf( "\n" ); 107 96 108 97 p = realloc( p, 2 * dim * sizeof(*p) ); // CFA realloc … … 119 108 p = alloc( p, dim ); // CFA resize array alloc 120 109 for ( i; dim ) { p[i] = 0xdeadbeef; } 110 printf( "CFA resize alloc\n" ); 111 for ( i; dim ) { printf( "%#x ", p[i] ); } 112 printf( "\n" ); 113 114 p = alloc( p, 2 * dim ); // CFA resize array alloc 115 for ( i; dim ~ 2 * dim ) { p[i] = 0x1010101; } 121 116 printf( "CFA resize array alloc\n" ); 122 for ( i; dim ) { printf( "%#x ", p[i] ); } 123 printf( "\n" ); 124 // do not free 125 126 p = alloc( p, 2 * dim ); // CFA resize array alloc 127 for ( i; dim ~ 2 * dim ) { p[i] = 0x1010101; } // fill upper part 117 for ( i; 2 * dim ) { printf( "%#x ", p[i] ); } 118 printf( "\n" ); 119 120 p = alloc( p, dim ); // CFA array alloc 128 121 printf( "CFA resize array alloc\n" ); 129 for ( i; 2 * dim ) { printf( "%#x ", p[i] ); } 130 printf( "\n" ); 131 // do not free 132 133 p = alloc( p, dim ); // CFA resize array alloc 134 printf( "CFA resize array alloc\n" ); 135 for ( i; dim ) { printf( "%#x ", p[i] ); } 136 printf( "\n" ); 137 // do not free 138 139 p = alloc_set( p, 3 * dim, fill ); // CFA resize array alloc, fill 140 printf( "CFA resize array alloc\n" ); 141 for ( i; 3 * dim ) { printf( "%#x ", p[i] ); } 142 printf( "\n" ); 143 // do not free 144 145 p = alloc_set( p, dim, fill ); // CFA resize array alloc, fill 146 printf( "CFA resize array alloc\n" ); 147 for ( i; dim ) { printf( "%#x ", p[i] ); } 148 printf( "\n" ); 149 // do not free 150 151 p = alloc_set( p, 3 * dim, fill ); // CFA resize array alloc, fill 122 for ( i; dim ) { printf( "%#x ", p[i] ); } 123 printf( "\n" ); 124 125 free( p ); 126 p = 0; 127 128 p = alloc( p, dim, fill ); // CFA array alloc, fill 152 129 printf( "CFA resize array alloc, fill\n" ); 153 for ( i; 3 * dim ) { printf( "%#x ", p[i] );; } 130 for ( i; dim ) { printf( "%#x ", p[i] ); } 131 printf( "\n" ); 132 133 p = alloc( p, 2 * dim, fill ); // CFA array alloc, fill 134 printf( "CFA resize array alloc, fill\n" ); 135 for ( i; 2 * dim ) { printf( "%#x ", p[i] ); } 136 printf( "\n" ); 137 138 p = alloc( p, dim, fill ); // CFA array alloc, fill 139 printf( "CFA resize array alloc, fill\n" ); 140 for ( i; dim ) { printf( "%#x ", p[i] );; } 154 141 printf( "\n" ); 155 142 free( p ); … … 185 172 free( stp ); 186 173 187 stp = &(*alloc_align( Alignment)){ 42, 42.5 }; // CFA alloc_align 188 assert( (uintptr_t)stp % Alignment == 0 ); 189 printf( "CFA alloc_align %d %g\n", stp->x, stp->y ); 190 free( stp ); 191 192 stp = &(*alloc_align( Alignment )){ 42, 42.5 }; // CFA alloc_align 193 assert( (uintptr_t)stp % Alignment == 0 ); 194 printf( "CFA alloc_align %d %g\n", stp->x, stp->y ); 195 free( stp ); 196 197 stp = alloc_align_set( Alignment, fill ); // CFA memalign, fill 198 assert( (uintptr_t)stp % Alignment == 0 ); 199 printf( "CFA alloc_align fill %#x %a\n", stp->x, stp->y ); 200 free( stp ); 201 202 stp = alloc_align_set( Alignment, (Struct){ 42, 42.5 } ); // CFA memalign, fill 203 assert( (uintptr_t)stp % Alignment == 0 ); 204 printf( "CFA alloc_align fill %d %g\n", stp->x, stp->y ); 205 // do not free 206 207 stp = &(*alloc_align( stp, 4096 )){ 42, 42.5 }; // CFA realign 208 assert( (uintptr_t)stp % 4096 == 0 ); 209 printf( "CFA alloc_align %d %g\n", stp->x, stp->y ); 174 stp = &(*aligned_alloc( Alignment )){ 42, 42.5 }; // CFA aligned_alloc 175 assert( (uintptr_t)stp % Alignment == 0 ); 176 printf( "CFA aligned_alloc %d %g\n", stp->x, stp->y ); 177 free( stp ); 178 179 stp = &(*align_alloc( Alignment )){ 42, 42.5 }; // CFA align_alloc 180 assert( (uintptr_t)stp % Alignment == 0 ); 181 printf( "CFA align_alloc %d %g\n", stp->x, stp->y ); 182 free( stp ); 183 184 stp = align_alloc( Alignment, fill ); // CFA memalign, fill 185 assert( (uintptr_t)stp % Alignment == 0 ); 186 printf( "CFA align_alloc fill %#x %a\n", stp->x, stp->y ); 210 187 free( stp ); 211 188 … … 214 191 printf( "\n" ); 215 192 216 stp = al loc_align( Alignment, dim ); // CFA array memalign193 stp = align_alloc( Alignment, dim ); // CFA array memalign 217 194 assert( (uintptr_t)stp % Alignment == 0 ); 218 195 for ( i; dim ) { stp[i] = (Struct){ 42, 42.5 }; } 219 printf( "CFA array al loc_align\n" );196 printf( "CFA array align_alloc\n" ); 220 197 for ( i; dim ) { printf( "%d %g, ", stp[i].x, stp[i].y ); } 221 198 printf( "\n" ); 222 199 free( stp ); 223 200 224 stp = al loc_align_set( Alignment, dim, fill );// CFA array memalign, fill225 assert( (uintptr_t)stp % Alignment == 0 ); 226 printf( "CFA array al loc_align, fill\n" );201 stp = align_alloc( Alignment, dim, fill ); // CFA array memalign, fill 202 assert( (uintptr_t)stp % Alignment == 0 ); 203 printf( "CFA array align_alloc, fill\n" ); 227 204 for ( i; dim ) { printf( "%#x %a, ", stp[i].x, stp[i].y ); } 228 printf( "\n" );229 free( stp );230 231 stp = alloc_align_set( Alignment, dim, (Struct){ 42, 42.5 } ); // CFA array memalign, fill232 assert( (uintptr_t)stp % Alignment == 0 );233 printf( "CFA array alloc_align, fill\n" );234 for ( i; dim ) { printf( "%d %g, ", stp[i].x, stp[i].y ); }235 printf( "\n" );236 // do not free237 238 stp1 = alloc_align_set( Alignment, dim, stp ); // CFA array memalign, fill239 assert( (uintptr_t)stp % Alignment == 0 );240 printf( "CFA array alloc_align, fill array\n" );241 for ( i; dim ) { printf( "%d %g, ", stp1[i].x, stp1[i].y ); }242 printf( "\n" );243 free( stp1 );244 245 stp = alloc_align( stp, 4096, dim ); // CFA aligned realloc array246 assert( (uintptr_t)stp % 4096 == 0 );247 for ( i; dim ) { stp[i] = (Struct){ 42, 42.5 }; }248 printf( "CFA realloc array alloc_align\n" );249 for ( i; dim ) { printf( "%d %g, ", stp[i].x, stp[i].y ); }250 205 printf( "\n" ); 251 206 free( stp ); -
tests/builtins/sync.cfa
r3d5701e r9fb8f01 4 4 void foo() { 5 5 volatile _Bool * vpB = 0; _Bool vB = 0; 6 volatile char * vpc = 0; char * rpc = 0; char vc = 0; 7 volatile short * vps = 0; short * rps = 0; short vs = 0; 8 volatile int * vpi = 0; int * rpi = 0; int vi = 0; 9 volatile long int * vpl = 0; long int * rpl = 0; long int vl = 0; 10 volatile long long int * vpll = 0; long long int * rpll = 0; long long int vll = 0; 11 #if defined(__SIZEOF_INT128__) 12 volatile __int128 * vplll = 0; __int128 * rplll = 0; __int128 vlll = 0; 6 volatile char * vp1 = 0; char * rp1 = 0; char v1 = 0; 7 volatile short * vp2 = 0; short * rp2 = 0; short v2 = 0; 8 volatile int * vp4 = 0; int * rp4 = 0; int v4 = 0; 9 volatile long long int * vp8 = 0; long long int * rp8 = 0; long long int v8 = 0; 10 #if defined(__SIZEOF_INT128__) 11 volatile __int128 * vp16 = 0; __int128 * rp16 = 0; __int128 v16 = 0; 13 12 #endif 14 13 struct type * volatile * vpp = 0; struct type ** rpp = 0; struct type * vp = 0; 15 14 16 { char ret; ret = __sync_fetch_and_add(vpc, vc); } 17 { short ret; ret = __sync_fetch_and_add(vps, vs); } 18 { int ret; ret = __sync_fetch_and_add(vpi, vi); } 19 { long int ret; ret = __sync_fetch_and_add(vpl, vl); } 20 { long long int ret; ret = __sync_fetch_and_add(vpll, vll); } 21 #if defined(__SIZEOF_INT128__) 22 { __int128 ret; ret = __sync_fetch_and_add(vplll, vlll); } 23 #endif 24 25 { char ret; ret = __sync_fetch_and_sub(vpc, vc); } 26 { short ret; ret = __sync_fetch_and_sub(vps, vs); } 27 { int ret; ret = __sync_fetch_and_sub(vpi, vi); } 28 { long int ret; ret = __sync_fetch_and_sub(vpl, vl); } 29 { long long int ret; ret = __sync_fetch_and_sub(vpll, vll); } 30 #if defined(__SIZEOF_INT128__) 31 { __int128 ret; ret = __sync_fetch_and_sub(vplll, vlll); } 32 #endif 33 34 { char ret; ret = __sync_fetch_and_or(vpc, vc); } 35 { short ret; ret = __sync_fetch_and_or(vps, vs); } 36 { int ret; ret = __sync_fetch_and_or(vpi, vi); } 37 { long int ret; ret = __sync_fetch_and_or(vpl, vl); } 38 { long long int ret; ret = __sync_fetch_and_or(vpll, vll); } 39 #if defined(__SIZEOF_INT128__) 40 { __int128 ret; ret = __sync_fetch_and_or(vplll, vlll); } 41 #endif 42 43 { char ret; ret = __sync_fetch_and_and(vpc, vc); } 44 { short ret; ret = __sync_fetch_and_and(vps, vs); } 45 { int ret; ret = __sync_fetch_and_and(vpi, vi); } 46 { long int ret; ret = __sync_fetch_and_and(vpl, vl); } 47 { long long int ret; ret = __sync_fetch_and_and(vpll, vll); } 48 #if defined(__SIZEOF_INT128__) 49 { __int128 ret; ret = __sync_fetch_and_and(vplll, vlll); } 50 #endif 51 52 { char ret; ret = __sync_fetch_and_xor(vpc, vc); } 53 { short ret; ret = __sync_fetch_and_xor(vps, vs); } 54 { int ret; ret = __sync_fetch_and_xor(vpi, vi); } 55 { long int ret; ret = __sync_fetch_and_xor(vpl, vl); } 56 { long long int ret; ret = __sync_fetch_and_xor(vpll, vll); } 57 #if defined(__SIZEOF_INT128__) 58 { __int128 ret; ret = __sync_fetch_and_xor(vplll, vlll); } 59 #endif 60 61 { char ret; ret = __sync_fetch_and_nand(vpc, vc); } 62 { short ret; ret = __sync_fetch_and_nand(vps, vs); } 63 { int ret; ret = __sync_fetch_and_nand(vpi, vi); } 64 { long int ret; ret = __sync_fetch_and_nand(vpl, vl); } 65 { long long int ret; ret = __sync_fetch_and_nand(vpll, vll); } 66 #if defined(__SIZEOF_INT128__) 67 { __int128 ret; ret = __sync_fetch_and_nand(vplll, vlll); } 68 { __int128 ret; ret = __sync_fetch_and_nand_16(vplll, vlll); } 69 #endif 70 71 { char ret; ret = __sync_add_and_fetch(vpc, vc); } 72 { short ret; ret = __sync_add_and_fetch(vps, vs); } 73 { int ret; ret = __sync_add_and_fetch(vpi, vi); } 74 { long int ret; ret = __sync_add_and_fetch(vpl, vl); } 75 { long long int ret; ret = __sync_add_and_fetch(vpll, vll); } 76 #if defined(__SIZEOF_INT128__) 77 { __int128 ret; ret = __sync_add_and_fetch(vplll, vlll); } 78 #endif 79 80 { char ret; ret = __sync_sub_and_fetch(vpc, vc); } 81 { short ret; ret = __sync_sub_and_fetch(vps, vs); } 82 { int ret; ret = __sync_sub_and_fetch(vpi, vi); } 83 { long int ret; ret = __sync_sub_and_fetch(vpl, vl); } 84 { long long int ret; ret = __sync_sub_and_fetch(vpll, vll); } 85 #if defined(__SIZEOF_INT128__) 86 { __int128 ret; ret = __sync_sub_and_fetch(vplll, vlll); } 87 #endif 88 89 { char ret; ret = __sync_or_and_fetch(vpc, vc); } 90 { short ret; ret = __sync_or_and_fetch(vps, vs); } 91 { int ret; ret = __sync_or_and_fetch(vpi, vi); } 92 { long int ret; ret = __sync_or_and_fetch(vpl, vl); } 93 { long long int ret; ret = __sync_or_and_fetch(vpll, vll); } 94 #if defined(__SIZEOF_INT128__) 95 { __int128 ret; ret = __sync_or_and_fetch(vplll, vlll); } 96 #endif 97 98 { char ret; ret = __sync_and_and_fetch(vpc, vc); } 99 { short ret; ret = __sync_and_and_fetch(vps, vs); } 100 { int ret; ret = __sync_and_and_fetch(vpi, vi); } 101 { long int ret; ret = __sync_and_and_fetch(vpl, vl); } 102 { long long int ret; ret = __sync_and_and_fetch(vpll, vll); } 103 #if defined(__SIZEOF_INT128__) 104 { __int128 ret; ret = __sync_and_and_fetch(vplll, vlll); } 105 #endif 106 107 { char ret; ret = __sync_xor_and_fetch(vpc, vc); } 108 { short ret; ret = __sync_xor_and_fetch(vps, vs); } 109 { int ret; ret = __sync_xor_and_fetch(vpi, vi); } 110 { long int ret; ret = __sync_xor_and_fetch(vpl, vl); } 111 { long long int ret; ret = __sync_xor_and_fetch(vpll, vll); } 112 #if defined(__SIZEOF_INT128__) 113 { __int128 ret; ret = __sync_xor_and_fetch(vplll, vlll); } 114 #endif 115 116 { char ret; ret = __sync_nand_and_fetch(vpc, vc); } 117 { short ret; ret = __sync_nand_and_fetch(vps, vs); } 118 { int ret; ret = __sync_nand_and_fetch(vpi, vi); } 119 { long int ret; ret = __sync_nand_and_fetch(vpl, vl); } 120 { long long int ret; ret = __sync_nand_and_fetch(vpll, vll); } 121 #if defined(__SIZEOF_INT128__) 122 { __int128 ret; ret = __sync_nand_and_fetch(vplll, vlll); } 123 #endif 124 125 { _Bool ret; ret = __sync_bool_compare_and_swap(vpc, vc, vc); } 126 { _Bool ret; ret = __sync_bool_compare_and_swap(vps, vs, vs); } 127 { _Bool ret; ret = __sync_bool_compare_and_swap(vpi, vi, vi); } 128 { _Bool ret; ret = __sync_bool_compare_and_swap(vpl, vl, vl); } 129 { _Bool ret; ret = __sync_bool_compare_and_swap(vpll, vll, vll); } 130 #if defined(__SIZEOF_INT128__) 131 { _Bool ret; ret = __sync_bool_compare_and_swap(vplll, vlll, vlll); } 15 { char ret; ret = __sync_fetch_and_add(vp1, v1); } 16 { char ret; ret = __sync_fetch_and_add_1(vp1, v1); } 17 { short ret; ret = __sync_fetch_and_add(vp2, v2); } 18 { short ret; ret = __sync_fetch_and_add_2(vp2, v2); } 19 { int ret; ret = __sync_fetch_and_add(vp4, v4); } 20 { int ret; ret = __sync_fetch_and_add_4(vp4, v4); } 21 { long long int ret; ret = __sync_fetch_and_add(vp8, v8); } 22 { long long int ret; ret = __sync_fetch_and_add_8(vp8, v8); } 23 #if defined(__SIZEOF_INT128__) 24 { __int128 ret; ret = __sync_fetch_and_add(vp16, v16); } 25 { __int128 ret; ret = __sync_fetch_and_add_16(vp16, v16); } 26 #endif 27 28 { char ret; ret = __sync_fetch_and_sub(vp1, v1); } 29 { char ret; ret = __sync_fetch_and_sub_1(vp1, v1); } 30 { short ret; ret = __sync_fetch_and_sub(vp2, v2); } 31 { short ret; ret = __sync_fetch_and_sub_2(vp2, v2); } 32 { int ret; ret = __sync_fetch_and_sub(vp4, v4); } 33 { int ret; ret = __sync_fetch_and_sub_4(vp4, v4); } 34 { long long int ret; ret = __sync_fetch_and_sub(vp8, v8); } 35 { long long int ret; ret = __sync_fetch_and_sub_8(vp8, v8); } 36 #if defined(__SIZEOF_INT128__) 37 { __int128 ret; ret = __sync_fetch_and_sub(vp16, v16); } 38 { __int128 ret; ret = __sync_fetch_and_sub_16(vp16, v16); } 39 #endif 40 41 { char ret; ret = __sync_fetch_and_or(vp1, v1); } 42 { char ret; ret = __sync_fetch_and_or_1(vp1, v1); } 43 { short ret; ret = __sync_fetch_and_or(vp2, v2); } 44 { short ret; ret = __sync_fetch_and_or_2(vp2, v2); } 45 { int ret; ret = __sync_fetch_and_or(vp4, v4); } 46 { int ret; ret = __sync_fetch_and_or_4(vp4, v4); } 47 { long long int ret; ret = __sync_fetch_and_or(vp8, v8); } 48 { long long int ret; ret = __sync_fetch_and_or_8(vp8, v8); } 49 #if defined(__SIZEOF_INT128__) 50 { __int128 ret; ret = __sync_fetch_and_or(vp16, v16); } 51 { __int128 ret; ret = __sync_fetch_and_or_16(vp16, v16); } 52 #endif 53 54 { char ret; ret = __sync_fetch_and_and(vp1, v1); } 55 { char ret; ret = __sync_fetch_and_and_1(vp1, v1); } 56 { short ret; ret = __sync_fetch_and_and(vp2, v2); } 57 { short ret; ret = __sync_fetch_and_and_2(vp2, v2); } 58 { int ret; ret = __sync_fetch_and_and(vp4, v4); } 59 { int ret; ret = __sync_fetch_and_and_4(vp4, v4); } 60 { long long int ret; ret = __sync_fetch_and_and(vp8, v8); } 61 { long long int ret; ret = __sync_fetch_and_and_8(vp8, v8); } 62 #if defined(__SIZEOF_INT128__) 63 { __int128 ret; ret = __sync_fetch_and_and(vp16, v16); } 64 { __int128 ret; ret = __sync_fetch_and_and_16(vp16, v16); } 65 #endif 66 67 { char ret; ret = __sync_fetch_and_xor(vp1, v1); } 68 { char ret; ret = __sync_fetch_and_xor_1(vp1, v1); } 69 { short ret; ret = __sync_fetch_and_xor(vp2, v2); } 70 { short ret; ret = __sync_fetch_and_xor_2(vp2, v2); } 71 { int ret; ret = __sync_fetch_and_xor(vp4, v4); } 72 { int ret; ret = __sync_fetch_and_xor_4(vp4, v4); } 73 { long long int ret; ret = __sync_fetch_and_xor(vp8, v8); } 74 { long long int ret; ret = __sync_fetch_and_xor_8(vp8, v8); } 75 #if defined(__SIZEOF_INT128__) 76 { __int128 ret; ret = __sync_fetch_and_xor(vp16, v16); } 77 { __int128 ret; ret = __sync_fetch_and_xor_16(vp16, v16); } 78 #endif 79 80 { char ret; ret = __sync_fetch_and_nand(vp1, v1); } 81 { char ret; ret = __sync_fetch_and_nand_1(vp1, v1); } 82 { short ret; ret = __sync_fetch_and_nand(vp2, v2); } 83 { short ret; ret = __sync_fetch_and_nand_2(vp2, v2); } 84 { int ret; ret = __sync_fetch_and_nand(vp4, v4); } 85 { int ret; ret = __sync_fetch_and_nand_4(vp4, v4); } 86 { long long int ret; ret = __sync_fetch_and_nand(vp8, v8); } 87 { long long int ret; ret = __sync_fetch_and_nand_8(vp8, v8); } 88 #if defined(__SIZEOF_INT128__) 89 { __int128 ret; ret = __sync_fetch_and_nand(vp16, v16); } 90 { __int128 ret; ret = __sync_fetch_and_nand_16(vp16, v16); } 91 #endif 92 93 { char ret; ret = __sync_add_and_fetch(vp1, v1); } 94 { char ret; ret = __sync_add_and_fetch_1(vp1, v1); } 95 { short ret; ret = __sync_add_and_fetch(vp2, v2); } 96 { short ret; ret = __sync_add_and_fetch_2(vp2, v2); } 97 { int ret; ret = __sync_add_and_fetch(vp4, v4); } 98 { int ret; ret = __sync_add_and_fetch_4(vp4, v4); } 99 { long long int ret; ret = __sync_add_and_fetch(vp8, v8); } 100 { long long int ret; ret = __sync_add_and_fetch_8(vp8, v8); } 101 #if defined(__SIZEOF_INT128__) 102 { __int128 ret; ret = __sync_add_and_fetch(vp16, v16); } 103 { __int128 ret; ret = __sync_add_and_fetch_16(vp16, v16); } 104 #endif 105 106 { char ret; ret = __sync_sub_and_fetch(vp1, v1); } 107 { char ret; ret = __sync_sub_and_fetch_1(vp1, v1); } 108 { short ret; ret = __sync_sub_and_fetch(vp2, v2); } 109 { short ret; ret = __sync_sub_and_fetch_2(vp2, v2); } 110 { int ret; ret = __sync_sub_and_fetch(vp4, v4); } 111 { int ret; ret = __sync_sub_and_fetch_4(vp4, v4); } 112 { long long int ret; ret = __sync_sub_and_fetch(vp8, v8); } 113 { long long int ret; ret = __sync_sub_and_fetch_8(vp8, v8); } 114 #if defined(__SIZEOF_INT128__) 115 { __int128 ret; ret = __sync_sub_and_fetch(vp16, v16); } 116 { __int128 ret; ret = __sync_sub_and_fetch_16(vp16, v16); } 117 #endif 118 119 { char ret; ret = __sync_or_and_fetch(vp1, v1); } 120 { char ret; ret = __sync_or_and_fetch_1(vp1, v1); } 121 { short ret; ret = __sync_or_and_fetch(vp2, v2); } 122 { short ret; ret = __sync_or_and_fetch_2(vp2, v2); } 123 { int ret; ret = __sync_or_and_fetch(vp4, v4); } 124 { int ret; ret = __sync_or_and_fetch_4(vp4, v4); } 125 { long long int ret; ret = __sync_or_and_fetch(vp8, v8); } 126 { long long int ret; ret = __sync_or_and_fetch_8(vp8, v8); } 127 #if defined(__SIZEOF_INT128__) 128 { __int128 ret; ret = __sync_or_and_fetch(vp16, v16); } 129 { __int128 ret; ret = __sync_or_and_fetch_16(vp16, v16); } 130 #endif 131 132 { char ret; ret = __sync_and_and_fetch(vp1, v1); } 133 { char ret; ret = __sync_and_and_fetch_1(vp1, v1); } 134 { short ret; ret = __sync_and_and_fetch(vp2, v2); } 135 { short ret; ret = __sync_and_and_fetch_2(vp2, v2); } 136 { int ret; ret = __sync_and_and_fetch(vp4, v4); } 137 { int ret; ret = __sync_and_and_fetch_4(vp4, v4); } 138 { long long int ret; ret = __sync_and_and_fetch(vp8, v8); } 139 { long long int ret; ret = __sync_and_and_fetch_8(vp8, v8); } 140 #if defined(__SIZEOF_INT128__) 141 { __int128 ret; ret = __sync_and_and_fetch(vp16, v16); } 142 { __int128 ret; ret = __sync_and_and_fetch_16(vp16, v16); } 143 #endif 144 145 { char ret; ret = __sync_xor_and_fetch(vp1, v1); } 146 { char ret; ret = __sync_xor_and_fetch_1(vp1, v1); } 147 { short ret; ret = __sync_xor_and_fetch(vp2, v2); } 148 { short ret; ret = __sync_xor_and_fetch_2(vp2, v2); } 149 { int ret; ret = __sync_xor_and_fetch(vp4, v4); } 150 { int ret; ret = __sync_xor_and_fetch_4(vp4, v4); } 151 { long long int ret; ret = __sync_xor_and_fetch(vp8, v8); } 152 { long long int ret; ret = __sync_xor_and_fetch_8(vp8, v8); } 153 #if defined(__SIZEOF_INT128__) 154 { __int128 ret; ret = __sync_xor_and_fetch(vp16, v16); } 155 { __int128 ret; ret = __sync_xor_and_fetch_16(vp16, v16); } 156 #endif 157 158 { char ret; ret = __sync_nand_and_fetch(vp1, v1); } 159 { char ret; ret = __sync_nand_and_fetch_1(vp1, v1); } 160 { short ret; ret = __sync_nand_and_fetch(vp2, v2); } 161 { short ret; ret = __sync_nand_and_fetch_2(vp2, v2); } 162 { int ret; ret = __sync_nand_and_fetch(vp4, v4); } 163 { int ret; ret = __sync_nand_and_fetch_4(vp4, v4); } 164 { long long int ret; ret = __sync_nand_and_fetch(vp8, v8); } 165 { long long int ret; ret = __sync_nand_and_fetch_8(vp8, v8); } 166 #if defined(__SIZEOF_INT128__) 167 { __int128 ret; ret = __sync_nand_and_fetch(vp16, v16); } 168 { __int128 ret; ret = __sync_nand_and_fetch_16(vp16, v16); } 169 #endif 170 171 { _Bool ret; ret = __sync_bool_compare_and_swap(vp1, v1, v1); } 172 { _Bool ret; ret = __sync_bool_compare_and_swap_1(vp1, v1, v1); } 173 { _Bool ret; ret = __sync_bool_compare_and_swap(vp2, v2, v2); } 174 { _Bool ret; ret = __sync_bool_compare_and_swap_2(vp2, v2, v2); } 175 { _Bool ret; ret = __sync_bool_compare_and_swap(vp4, v4, v4); } 176 { _Bool ret; ret = __sync_bool_compare_and_swap_4(vp4, v4, v4); } 177 { _Bool ret; ret = __sync_bool_compare_and_swap(vp8, v8, v8); } 178 { _Bool ret; ret = __sync_bool_compare_and_swap_8(vp8, v8, v8); } 179 #if defined(__SIZEOF_INT128__) 180 { _Bool ret; ret = __sync_bool_compare_and_swap(vp16, v16, v16); } 181 { _Bool ret; ret = __sync_bool_compare_and_swap_16(vp16, v16,v16); } 132 182 #endif 133 183 { _Bool ret; ret = __sync_bool_compare_and_swap(vpp, vp, vp); } 134 184 135 { char ret; ret = __sync_val_compare_and_swap(vpc, vc, vc); } 136 { short ret; ret = __sync_val_compare_and_swap(vps, vs, vs); } 137 { int ret; ret = __sync_val_compare_and_swap(vpi, vi, vi); } 138 { long int ret; ret = __sync_val_compare_and_swap(vpl, vl, vl); } 139 { long long int ret; ret = __sync_val_compare_and_swap(vpll, vll, vll); } 140 #if defined(__SIZEOF_INT128__) 141 { __int128 ret; ret = __sync_val_compare_and_swap(vplll, vlll, vlll); } 185 { char ret; ret = __sync_val_compare_and_swap(vp1, v1, v1); } 186 { char ret; ret = __sync_val_compare_and_swap_1(vp1, v1, v1); } 187 { short ret; ret = __sync_val_compare_and_swap(vp2, v2, v2); } 188 { short ret; ret = __sync_val_compare_and_swap_2(vp2, v2, v2); } 189 { int ret; ret = __sync_val_compare_and_swap(vp4, v4, v4); } 190 { int ret; ret = __sync_val_compare_and_swap_4(vp4, v4, v4); } 191 { long long int ret; ret = __sync_val_compare_and_swap(vp8, v8, v8); } 192 { long long int ret; ret = __sync_val_compare_and_swap_8(vp8, v8, v8); } 193 #if defined(__SIZEOF_INT128__) 194 { __int128 ret; ret = __sync_val_compare_and_swap(vp16, v16, v16); } 195 { __int128 ret; ret = __sync_val_compare_and_swap_16(vp16, v16,v16); } 142 196 #endif 143 197 { struct type * ret; ret = __sync_val_compare_and_swap(vpp, vp, vp); } 144 198 145 199 146 { char ret; ret = __sync_lock_test_and_set(vpc, vc); } 147 { short ret; ret = __sync_lock_test_and_set(vps, vs); } 148 { int ret; ret = __sync_lock_test_and_set(vpi, vi); } 149 { long int ret; ret = __sync_lock_test_and_set(vpl, vl); } 150 { long long int ret; ret = __sync_lock_test_and_set(vpll, vll); } 151 #if defined(__SIZEOF_INT128__) 152 { __int128 ret; ret = __sync_lock_test_and_set(vplll, vlll); } 153 #endif 154 155 { __sync_lock_release(vpc); } 156 { __sync_lock_release(vps); } 157 { __sync_lock_release(vpi); } 158 { __sync_lock_release(vpl); } 159 { __sync_lock_release(vpll); } 160 #if defined(__SIZEOF_INT128__) 161 { __sync_lock_release(vplll); } 200 { char ret; ret = __sync_lock_test_and_set(vp1, v1); } 201 { char ret; ret = __sync_lock_test_and_set_1(vp1, v1); } 202 { short ret; ret = __sync_lock_test_and_set(vp2, v2); } 203 { short ret; ret = __sync_lock_test_and_set_2(vp2, v2); } 204 { int ret; ret = __sync_lock_test_and_set(vp4, v4); } 205 { int ret; ret = __sync_lock_test_and_set_4(vp4, v4); } 206 { long long int ret; ret = __sync_lock_test_and_set(vp8, v8); } 207 { long long int ret; ret = __sync_lock_test_and_set_8(vp8, v8); } 208 #if defined(__SIZEOF_INT128__) 209 { __int128 ret; ret = __sync_lock_test_and_set(vp16, v16); } 210 { __int128 ret; ret = __sync_lock_test_and_set_16(vp16, v16); } 211 #endif 212 213 { __sync_lock_release(vp1); } 214 { __sync_lock_release_1(vp1); } 215 { __sync_lock_release(vp2); } 216 { __sync_lock_release_2(vp2); } 217 { __sync_lock_release(vp4); } 218 { __sync_lock_release_4(vp4); } 219 { __sync_lock_release(vp8); } 220 { __sync_lock_release_8(vp8); } 221 #if defined(__SIZEOF_INT128__) 222 { __sync_lock_release(vp16); } 223 { __sync_lock_release_16(vp16); } 162 224 #endif 163 225 … … 168 230 169 231 { _Bool ret; ret = __atomic_test_and_set(vpB, vB); } 170 { _Bool ret; ret = __atomic_test_and_set(vp c, vc); }232 { _Bool ret; ret = __atomic_test_and_set(vp1, v1); } 171 233 { __atomic_clear(vpB, vB); } 172 { __atomic_clear(vpc, vc); } 173 174 { char ret; ret = __atomic_exchange_n(vpc, vc, __ATOMIC_SEQ_CST); } 175 { char ret; __atomic_exchange(vpc, &vc, &ret, __ATOMIC_SEQ_CST); } 176 { short ret; ret = __atomic_exchange_n(vps, vs, __ATOMIC_SEQ_CST); } 177 { short ret; __atomic_exchange(vps, &vs, &ret, __ATOMIC_SEQ_CST); } 178 { int ret; ret = __atomic_exchange_n(vpi, vi, __ATOMIC_SEQ_CST); } 179 { int ret; __atomic_exchange(vpi, &vi, &ret, __ATOMIC_SEQ_CST); } 180 { long int ret; ret = __atomic_exchange_n(vpl, vl, __ATOMIC_SEQ_CST); } 181 { long int ret; __atomic_exchange(vpl, &vl, &ret, __ATOMIC_SEQ_CST); } 182 { long long int ret; ret = __atomic_exchange_n(vpll, vll, __ATOMIC_SEQ_CST); } 183 { long long int ret; __atomic_exchange(vpll, &vll, &ret, __ATOMIC_SEQ_CST); } 184 #if defined(__SIZEOF_INT128__) 185 { __int128 ret; ret = __atomic_exchange_n(vplll, vlll, __ATOMIC_SEQ_CST); } 186 { __int128 ret; __atomic_exchange(vplll, &vlll, &ret, __ATOMIC_SEQ_CST); } 234 { __atomic_clear(vp1, v1); } 235 236 { char ret; ret = __atomic_exchange_n(vp1, v1, __ATOMIC_SEQ_CST); } 237 { char ret; ret = __atomic_exchange_1(vp1, v1, __ATOMIC_SEQ_CST); } 238 { char ret; __atomic_exchange(vp1, &v1, &ret, __ATOMIC_SEQ_CST); } 239 { short ret; ret = __atomic_exchange_n(vp2, v2, __ATOMIC_SEQ_CST); } 240 { short ret; ret = __atomic_exchange_2(vp2, v2, __ATOMIC_SEQ_CST); } 241 { short ret; __atomic_exchange(vp2, &v2, &ret, __ATOMIC_SEQ_CST); } 242 { int ret; ret = __atomic_exchange_n(vp4, v4, __ATOMIC_SEQ_CST); } 243 { int ret; ret = __atomic_exchange_4(vp4, v4, __ATOMIC_SEQ_CST); } 244 { int ret; __atomic_exchange(vp4, &v4, &ret, __ATOMIC_SEQ_CST); } 245 { long long int ret; ret = __atomic_exchange_n(vp8, v8, __ATOMIC_SEQ_CST); } 246 { long long int ret; ret = __atomic_exchange_8(vp8, v8, __ATOMIC_SEQ_CST); } 247 { long long int ret; __atomic_exchange(vp8, &v8, &ret, __ATOMIC_SEQ_CST); } 248 #if defined(__SIZEOF_INT128__) 249 { __int128 ret; ret = __atomic_exchange_n(vp16, v16, __ATOMIC_SEQ_CST); } 250 { __int128 ret; ret = __atomic_exchange_16(vp16, v16, __ATOMIC_SEQ_CST); } 251 { __int128 ret; __atomic_exchange(vp16, &v16, &ret, __ATOMIC_SEQ_CST); } 187 252 #endif 188 253 { struct type * ret; ret = __atomic_exchange_n(vpp, vp, __ATOMIC_SEQ_CST); } 189 254 { struct type * ret; __atomic_exchange(vpp, &vp, &ret, __ATOMIC_SEQ_CST); } 190 255 191 { char ret; ret = __atomic_load_n(vpc, __ATOMIC_SEQ_CST); } 192 { char ret; __atomic_load(vpc, &ret, __ATOMIC_SEQ_CST); } 193 { short ret; ret = __atomic_load_n(vps, __ATOMIC_SEQ_CST); } 194 { short ret; __atomic_load(vps, &ret, __ATOMIC_SEQ_CST); } 195 { int ret; ret = __atomic_load_n(vpi, __ATOMIC_SEQ_CST); } 196 { int ret; __atomic_load(vpi, &ret, __ATOMIC_SEQ_CST); } 197 { long int ret; ret = __atomic_load_n(vpl, __ATOMIC_SEQ_CST); } 198 { long int ret; __atomic_load(vpl, &ret, __ATOMIC_SEQ_CST); } 199 { long long int ret; ret = __atomic_load_n(vpll, __ATOMIC_SEQ_CST); } 200 { long long int ret; __atomic_load(vpll, &ret, __ATOMIC_SEQ_CST); } 201 #if defined(__SIZEOF_INT128__) 202 { __int128 ret; ret = __atomic_load_n(vplll, __ATOMIC_SEQ_CST); } 203 { __int128 ret; __atomic_load(vplll, &ret, __ATOMIC_SEQ_CST); } 256 { char ret; ret = __atomic_load_n(vp1, __ATOMIC_SEQ_CST); } 257 { char ret; ret = __atomic_load_1(vp1, __ATOMIC_SEQ_CST); } 258 { char ret; __atomic_load(vp1, &ret, __ATOMIC_SEQ_CST); } 259 { short ret; ret = __atomic_load_n(vp2, __ATOMIC_SEQ_CST); } 260 { short ret; ret = __atomic_load_2(vp2, __ATOMIC_SEQ_CST); } 261 { short ret; __atomic_load(vp2, &ret, __ATOMIC_SEQ_CST); } 262 { int ret; ret = __atomic_load_n(vp4, __ATOMIC_SEQ_CST); } 263 { int ret; ret = __atomic_load_4(vp4, __ATOMIC_SEQ_CST); } 264 { int ret; __atomic_load(vp4, &ret, __ATOMIC_SEQ_CST); } 265 { long long int ret; ret = __atomic_load_n(vp8, __ATOMIC_SEQ_CST); } 266 { long long int ret; ret = __atomic_load_8(vp8, __ATOMIC_SEQ_CST); } 267 { long long int ret; __atomic_load(vp8, &ret, __ATOMIC_SEQ_CST); } 268 #if defined(__SIZEOF_INT128__) 269 { __int128 ret; ret = __atomic_load_n(vp16, __ATOMIC_SEQ_CST); } 270 { __int128 ret; ret = __atomic_load_16(vp16, __ATOMIC_SEQ_CST); } 271 { __int128 ret; __atomic_load(vp16, &ret, __ATOMIC_SEQ_CST); } 204 272 #endif 205 273 { struct type * ret; ret = __atomic_load_n(vpp, __ATOMIC_SEQ_CST); } 206 274 { struct type * ret; __atomic_load(vpp, &ret, __ATOMIC_SEQ_CST); } 207 275 208 { _Bool ret; ret = __atomic_compare_exchange_n(vpc, rpc, vc, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } 209 { _Bool ret; ret = __atomic_compare_exchange(vpc, rpc, &vc, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } 210 { _Bool ret; ret = __atomic_compare_exchange_n(vps, rps, vs, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } 211 { _Bool ret; ret = __atomic_compare_exchange(vps, rps, &vs, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } 212 { _Bool ret; ret = __atomic_compare_exchange_n(vpi, rpi, vi, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } 213 { _Bool ret; ret = __atomic_compare_exchange(vpi, rpi, &vi, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } 214 { _Bool ret; ret = __atomic_compare_exchange_n(vpl, rpl, vl, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } 215 { _Bool ret; ret = __atomic_compare_exchange(vpl, rpl, &vl, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } 216 { _Bool ret; ret = __atomic_compare_exchange_n(vpll, rpll, vll, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } 217 { _Bool ret; ret = __atomic_compare_exchange(vpll, rpll, &vll, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } 218 #if defined(__SIZEOF_INT128__) 219 { _Bool ret; ret = __atomic_compare_exchange_n(vplll, rplll, vlll, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } 220 { _Bool ret; ret = __atomic_compare_exchange(vplll, rplll, &vlll, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } 276 { _Bool ret; ret = __atomic_compare_exchange_n(vp1, rp1, v1, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } 277 { _Bool ret; ret = __atomic_compare_exchange_1(vp1, rp1, v1, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } 278 { _Bool ret; ret = __atomic_compare_exchange(vp1, rp1, &v1, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } 279 { _Bool ret; ret = __atomic_compare_exchange_n(vp2, rp2, v2, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } 280 { _Bool ret; ret = __atomic_compare_exchange_2(vp2, rp2, v2, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } 281 { _Bool ret; ret = __atomic_compare_exchange(vp2, rp2, &v2, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } 282 { _Bool ret; ret = __atomic_compare_exchange_n(vp4, rp4, v4, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } 283 { _Bool ret; ret = __atomic_compare_exchange_4(vp4, rp4, v4, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } 284 { _Bool ret; ret = __atomic_compare_exchange(vp4, rp4, &v4, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } 285 { _Bool ret; ret = __atomic_compare_exchange_n(vp8, rp8, v8, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } 286 { _Bool ret; ret = __atomic_compare_exchange_8(vp8, rp8, v8, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } 287 { _Bool ret; ret = __atomic_compare_exchange(vp8, rp8, &v8, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } 288 #if defined(__SIZEOF_INT128__) 289 { _Bool ret; ret = __atomic_compare_exchange_n(vp16, rp16, v16, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } 290 { _Bool ret; ret = __atomic_compare_exchange_16(vp16, rp16, v16, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } 291 { _Bool ret; ret = __atomic_compare_exchange(vp16, rp16, &v16, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } 221 292 #endif 222 293 { _Bool ret; ret = __atomic_compare_exchange_n(vpp, rpp, vp, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } 223 294 { _Bool ret; ret = __atomic_compare_exchange(vpp, rpp, &vp, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } 224 295 225 { __atomic_store_n(vpc, vc, __ATOMIC_SEQ_CST); } 226 { __atomic_store(vpc, &vc, __ATOMIC_SEQ_CST); } 227 { __atomic_store_n(vps, vs, __ATOMIC_SEQ_CST); } 228 { __atomic_store(vps, &vs, __ATOMIC_SEQ_CST); } 229 { __atomic_store_n(vpi, vi, __ATOMIC_SEQ_CST); } 230 { __atomic_store(vpi, &vi, __ATOMIC_SEQ_CST); } 231 { __atomic_store_n(vpl, vl, __ATOMIC_SEQ_CST); } 232 { __atomic_store(vpl, &vl, __ATOMIC_SEQ_CST); } 233 { __atomic_store_n(vpll, vll, __ATOMIC_SEQ_CST); } 234 { __atomic_store(vpll, &vll, __ATOMIC_SEQ_CST); } 235 #if defined(__SIZEOF_INT128__) 236 { __atomic_store_n(vplll, vlll, __ATOMIC_SEQ_CST); } 237 { __atomic_store(vplll, &vlll, __ATOMIC_SEQ_CST); } 296 { __atomic_store_n(vp1, v1, __ATOMIC_SEQ_CST); } 297 { __atomic_store_1(vp1, v1, __ATOMIC_SEQ_CST); } 298 { __atomic_store(vp1, &v1, __ATOMIC_SEQ_CST); } 299 { __atomic_store_n(vp2, v2, __ATOMIC_SEQ_CST); } 300 { __atomic_store_2(vp2, v2, __ATOMIC_SEQ_CST); } 301 { __atomic_store(vp2, &v2, __ATOMIC_SEQ_CST); } 302 { __atomic_store_n(vp4, v4, __ATOMIC_SEQ_CST); } 303 { __atomic_store_4(vp4, v4, __ATOMIC_SEQ_CST); } 304 { __atomic_store(vp4, &v4, __ATOMIC_SEQ_CST); } 305 { __atomic_store_n(vp8, v8, __ATOMIC_SEQ_CST); } 306 { __atomic_store_8(vp8, v8, __ATOMIC_SEQ_CST); } 307 { __atomic_store(vp8, &v8, __ATOMIC_SEQ_CST); } 308 #if defined(__SIZEOF_INT128__) 309 { __atomic_store_n(vp16, v16, __ATOMIC_SEQ_CST); } 310 { __atomic_store_16(vp16, v16, __ATOMIC_SEQ_CST); } 311 { __atomic_store(vp16, &v16, __ATOMIC_SEQ_CST); } 238 312 #endif 239 313 { __atomic_store_n(vpp, vp, __ATOMIC_SEQ_CST); } 240 314 { __atomic_store(vpp, &vp, __ATOMIC_SEQ_CST); } 241 315 242 { char ret; ret = __atomic_add_fetch(vpc, vc, __ATOMIC_SEQ_CST); } 243 { short ret; ret = __atomic_add_fetch(vps, vs, __ATOMIC_SEQ_CST); } 244 { int ret; ret = __atomic_add_fetch(vpi, vi, __ATOMIC_SEQ_CST); } 245 { long int ret; ret = __atomic_add_fetch(vpl, vl, __ATOMIC_SEQ_CST); } 246 { long long int ret; ret = __atomic_add_fetch(vpll, vll, __ATOMIC_SEQ_CST); } 247 #if defined(__SIZEOF_INT128__) 248 { __int128 ret; ret = __atomic_add_fetch(vplll, vlll, __ATOMIC_SEQ_CST); } 249 #endif 250 251 { char ret; ret = __atomic_sub_fetch(vpc, vc, __ATOMIC_SEQ_CST); } 252 { short ret; ret = __atomic_sub_fetch(vps, vs, __ATOMIC_SEQ_CST); } 253 { int ret; ret = __atomic_sub_fetch(vpi, vi, __ATOMIC_SEQ_CST); } 254 { long int ret; ret = __atomic_sub_fetch(vpl, vl, __ATOMIC_SEQ_CST); } 255 { long long int ret; ret = __atomic_sub_fetch(vpll, vll, __ATOMIC_SEQ_CST); } 256 #if defined(__SIZEOF_INT128__) 257 { __int128 ret; ret = __atomic_sub_fetch(vplll, vlll, __ATOMIC_SEQ_CST); } 258 #endif 259 260 { char ret; ret = __atomic_and_fetch(vpc, vc, __ATOMIC_SEQ_CST); } 261 { short ret; ret = __atomic_and_fetch(vps, vs, __ATOMIC_SEQ_CST); } 262 { int ret; ret = __atomic_and_fetch(vpi, vi, __ATOMIC_SEQ_CST); } 263 { long int ret; ret = __atomic_and_fetch(vpl, vl, __ATOMIC_SEQ_CST); } 264 { long long int ret; ret = __atomic_and_fetch(vpll, vll, __ATOMIC_SEQ_CST); } 265 #if defined(__SIZEOF_INT128__) 266 { __int128 ret; ret = __atomic_and_fetch(vplll, vlll, __ATOMIC_SEQ_CST); } 267 #endif 268 269 { char ret; ret = __atomic_nand_fetch(vpc, vc, __ATOMIC_SEQ_CST); } 270 { short ret; ret = __atomic_nand_fetch(vps, vs, __ATOMIC_SEQ_CST); } 271 { int ret; ret = __atomic_nand_fetch(vpi, vi, __ATOMIC_SEQ_CST); } 272 { long int ret; ret = __atomic_nand_fetch(vpl, vl, __ATOMIC_SEQ_CST); } 273 { long long int ret; ret = __atomic_nand_fetch(vpll, vll, __ATOMIC_SEQ_CST); } 274 #if defined(__SIZEOF_INT128__) 275 { __int128 ret; ret = __atomic_nand_fetch(vplll, vlll, __ATOMIC_SEQ_CST); } 276 #endif 277 278 { char ret; ret = __atomic_xor_fetch(vpc, vc, __ATOMIC_SEQ_CST); } 279 { short ret; ret = __atomic_xor_fetch(vps, vs, __ATOMIC_SEQ_CST); } 280 { int ret; ret = __atomic_xor_fetch(vpi, vi, __ATOMIC_SEQ_CST); } 281 { long int ret; ret = __atomic_xor_fetch(vpl, vl, __ATOMIC_SEQ_CST); } 282 { long long int ret; ret = __atomic_xor_fetch(vpll, vll, __ATOMIC_SEQ_CST); } 283 #if defined(__SIZEOF_INT128__) 284 { __int128 ret; ret = __atomic_xor_fetch(vplll, vlll, __ATOMIC_SEQ_CST); } 285 #endif 286 287 { char ret; ret = __atomic_or_fetch(vpc, vc, __ATOMIC_SEQ_CST); } 288 { short ret; ret = __atomic_or_fetch(vps, vs, __ATOMIC_SEQ_CST); } 289 { int ret; ret = __atomic_or_fetch(vpi, vi, __ATOMIC_SEQ_CST); } 290 { long int ret; ret = __atomic_or_fetch(vpl, vl, __ATOMIC_SEQ_CST); } 291 { long long int ret; ret = __atomic_or_fetch(vpll, vll, __ATOMIC_SEQ_CST); } 292 #if defined(__SIZEOF_INT128__) 293 { __int128 ret; ret = __atomic_or_fetch(vplll, vlll, __ATOMIC_SEQ_CST); } 294 #endif 295 296 { char ret; ret = __atomic_fetch_add(vpc, vc, __ATOMIC_SEQ_CST); } 297 { short ret; ret = __atomic_fetch_add(vps, vs, __ATOMIC_SEQ_CST); } 298 { int ret; ret = __atomic_fetch_add(vpi, vi, __ATOMIC_SEQ_CST); } 299 { long int ret; ret = __atomic_fetch_add(vpl, vl, __ATOMIC_SEQ_CST); } 300 { long long int ret; ret = __atomic_fetch_add(vpll, vll, __ATOMIC_SEQ_CST); } 301 #if defined(__SIZEOF_INT128__) 302 { __int128 ret; ret = __atomic_fetch_add(vplll, vlll, __ATOMIC_SEQ_CST); } 303 #endif 304 305 { char ret; ret = __atomic_fetch_sub(vpc, vc, __ATOMIC_SEQ_CST); } 306 { short ret; ret = __atomic_fetch_sub(vps, vs, __ATOMIC_SEQ_CST); } 307 { int ret; ret = __atomic_fetch_sub(vpi, vi, __ATOMIC_SEQ_CST); } 308 { long int ret; ret = __atomic_fetch_sub(vpl, vl, __ATOMIC_SEQ_CST); } 309 { long long int ret; ret = __atomic_fetch_sub(vpll, vll, __ATOMIC_SEQ_CST); } 310 #if defined(__SIZEOF_INT128__) 311 { __int128 ret; ret = __atomic_fetch_sub(vplll, vlll, __ATOMIC_SEQ_CST); } 312 #endif 313 314 { char ret; ret = __atomic_fetch_and(vpc, vc, __ATOMIC_SEQ_CST); } 315 { short ret; ret = __atomic_fetch_and(vps, vs, __ATOMIC_SEQ_CST); } 316 { int ret; ret = __atomic_fetch_and(vpi, vi, __ATOMIC_SEQ_CST); } 317 { long int ret; ret = __atomic_fetch_and(vpl, vl, __ATOMIC_SEQ_CST); } 318 { long long int ret; ret = __atomic_fetch_and(vpll, vll, __ATOMIC_SEQ_CST); } 319 #if defined(__SIZEOF_INT128__) 320 { __int128 ret; ret = __atomic_fetch_and(vplll, vlll, __ATOMIC_SEQ_CST); } 321 #endif 322 323 { char ret; ret = __atomic_fetch_nand(vpc, vc, __ATOMIC_SEQ_CST); } 324 { short ret; ret = __atomic_fetch_nand(vps, vs, __ATOMIC_SEQ_CST); } 325 { int ret; ret = __atomic_fetch_nand(vpi, vi, __ATOMIC_SEQ_CST); } 326 { long int ret; ret = __atomic_fetch_nand(vpl, vl, __ATOMIC_SEQ_CST); } 327 { long long int ret; ret = __atomic_fetch_nand(vpll, vll, __ATOMIC_SEQ_CST); } 328 #if defined(__SIZEOF_INT128__) 329 { __int128 ret; ret = __atomic_fetch_nand(vplll, vlll, __ATOMIC_SEQ_CST); } 330 #endif 331 332 { char ret; ret = __atomic_fetch_xor(vpc, vc, __ATOMIC_SEQ_CST); } 333 { short ret; ret = __atomic_fetch_xor(vps, vs, __ATOMIC_SEQ_CST); } 334 { int ret; ret = __atomic_fetch_xor(vpi, vi, __ATOMIC_SEQ_CST); } 335 { long int ret; ret = __atomic_fetch_xor(vpl, vl, __ATOMIC_SEQ_CST); } 336 { long long int ret; ret = __atomic_fetch_xor(vpll, vll, __ATOMIC_SEQ_CST); } 337 #if defined(__SIZEOF_INT128__) 338 { __int128 ret; ret = __atomic_fetch_xor(vplll, vlll, __ATOMIC_SEQ_CST); } 339 #endif 340 341 { char ret; ret = __atomic_fetch_or(vpc, vc, __ATOMIC_SEQ_CST); } 342 { short ret; ret = __atomic_fetch_or(vps, vs, __ATOMIC_SEQ_CST); } 343 { int ret; ret = __atomic_fetch_or(vpi, vi, __ATOMIC_SEQ_CST); } 344 { long int ret; ret = __atomic_fetch_or(vpl, vl, __ATOMIC_SEQ_CST); } 345 { long long int ret; ret = __atomic_fetch_or(vpll, vll, __ATOMIC_SEQ_CST); } 346 #if defined(__SIZEOF_INT128__) 347 { __int128 ret; ret = __atomic_fetch_or(vplll, vlll, __ATOMIC_SEQ_CST); } 348 #endif 349 350 { _Bool ret; ret = __atomic_always_lock_free(sizeof(int), vpi); } 351 { _Bool ret; ret = __atomic_is_lock_free(sizeof(int), vpi); } 316 { char ret; ret = __atomic_add_fetch(vp1, v1, __ATOMIC_SEQ_CST); } 317 { char ret; ret = __atomic_add_fetch_1(vp1, v1, __ATOMIC_SEQ_CST); } 318 { short ret; ret = __atomic_add_fetch(vp2, v2, __ATOMIC_SEQ_CST); } 319 { short ret; ret = __atomic_add_fetch_2(vp2, v2, __ATOMIC_SEQ_CST); } 320 { int ret; ret = __atomic_add_fetch(vp4, v4, __ATOMIC_SEQ_CST); } 321 { int ret; ret = __atomic_add_fetch_4(vp4, v4, __ATOMIC_SEQ_CST); } 322 { long long int ret; ret = __atomic_add_fetch(vp8, v8, __ATOMIC_SEQ_CST); } 323 { long long int ret; ret = __atomic_add_fetch_8(vp8, v8, __ATOMIC_SEQ_CST); } 324 #if defined(__SIZEOF_INT128__) 325 { __int128 ret; ret = __atomic_add_fetch(vp16, v16, __ATOMIC_SEQ_CST); } 326 { __int128 ret; ret = __atomic_add_fetch_16(vp16, v16, __ATOMIC_SEQ_CST); } 327 #endif 328 329 { char ret; ret = __atomic_sub_fetch(vp1, v1, __ATOMIC_SEQ_CST); } 330 { char ret; ret = __atomic_sub_fetch_1(vp1, v1, __ATOMIC_SEQ_CST); } 331 { short ret; ret = __atomic_sub_fetch(vp2, v2, __ATOMIC_SEQ_CST); } 332 { short ret; ret = __atomic_sub_fetch_2(vp2, v2, __ATOMIC_SEQ_CST); } 333 { int ret; ret = __atomic_sub_fetch(vp4, v4, __ATOMIC_SEQ_CST); } 334 { int ret; ret = __atomic_sub_fetch_4(vp4, v4, __ATOMIC_SEQ_CST); } 335 { long long int ret; ret = __atomic_sub_fetch(vp8, v8, __ATOMIC_SEQ_CST); } 336 { long long int ret; ret = __atomic_sub_fetch_8(vp8, v8, __ATOMIC_SEQ_CST); } 337 #if defined(__SIZEOF_INT128__) 338 { __int128 ret; ret = __atomic_sub_fetch(vp16, v16, __ATOMIC_SEQ_CST); } 339 { __int128 ret; ret = __atomic_sub_fetch_16(vp16, v16, __ATOMIC_SEQ_CST); } 340 #endif 341 342 { char ret; ret = __atomic_and_fetch(vp1, v1, __ATOMIC_SEQ_CST); } 343 { char ret; ret = __atomic_and_fetch_1(vp1, v1, __ATOMIC_SEQ_CST); } 344 { short ret; ret = __atomic_and_fetch(vp2, v2, __ATOMIC_SEQ_CST); } 345 { short ret; ret = __atomic_and_fetch_2(vp2, v2, __ATOMIC_SEQ_CST); } 346 { int ret; ret = __atomic_and_fetch(vp4, v4, __ATOMIC_SEQ_CST); } 347 { int ret; ret = __atomic_and_fetch_4(vp4, v4, __ATOMIC_SEQ_CST); } 348 { long long int ret; ret = __atomic_and_fetch(vp8, v8, __ATOMIC_SEQ_CST); } 349 { long long int ret; ret = __atomic_and_fetch_8(vp8, v8, __ATOMIC_SEQ_CST); } 350 #if defined(__SIZEOF_INT128__) 351 { __int128 ret; ret = __atomic_and_fetch(vp16, v16, __ATOMIC_SEQ_CST); } 352 { __int128 ret; ret = __atomic_and_fetch_16(vp16, v16, __ATOMIC_SEQ_CST); } 353 #endif 354 355 { char ret; ret = __atomic_nand_fetch(vp1, v1, __ATOMIC_SEQ_CST); } 356 { char ret; ret = __atomic_nand_fetch_1(vp1, v1, __ATOMIC_SEQ_CST); } 357 { short ret; ret = __atomic_nand_fetch(vp2, v2, __ATOMIC_SEQ_CST); } 358 { short ret; ret = __atomic_nand_fetch_2(vp2, v2, __ATOMIC_SEQ_CST); } 359 { int ret; ret = __atomic_nand_fetch(vp4, v4, __ATOMIC_SEQ_CST); } 360 { int ret; ret = __atomic_nand_fetch_4(vp4, v4, __ATOMIC_SEQ_CST); } 361 { long long int ret; ret = __atomic_nand_fetch(vp8, v8, __ATOMIC_SEQ_CST); } 362 { long long int ret; ret = __atomic_nand_fetch_8(vp8, v8, __ATOMIC_SEQ_CST); } 363 #if defined(__SIZEOF_INT128__) 364 { __int128 ret; ret = __atomic_nand_fetch(vp16, v16, __ATOMIC_SEQ_CST); } 365 { __int128 ret; ret = __atomic_nand_fetch_16(vp16, v16, __ATOMIC_SEQ_CST); } 366 #endif 367 368 { char ret; ret = __atomic_xor_fetch(vp1, v1, __ATOMIC_SEQ_CST); } 369 { char ret; ret = __atomic_xor_fetch_1(vp1, v1, __ATOMIC_SEQ_CST); } 370 { short ret; ret = __atomic_xor_fetch(vp2, v2, __ATOMIC_SEQ_CST); } 371 { short ret; ret = __atomic_xor_fetch_2(vp2, v2, __ATOMIC_SEQ_CST); } 372 { int ret; ret = __atomic_xor_fetch(vp4, v4, __ATOMIC_SEQ_CST); } 373 { int ret; ret = __atomic_xor_fetch_4(vp4, v4, __ATOMIC_SEQ_CST); } 374 { long long int ret; ret = __atomic_xor_fetch(vp8, v8, __ATOMIC_SEQ_CST); } 375 { long long int ret; ret = __atomic_xor_fetch_8(vp8, v8, __ATOMIC_SEQ_CST); } 376 #if defined(__SIZEOF_INT128__) 377 { __int128 ret; ret = __atomic_xor_fetch(vp16, v16, __ATOMIC_SEQ_CST); } 378 { __int128 ret; ret = __atomic_xor_fetch_16(vp16, v16, __ATOMIC_SEQ_CST); } 379 #endif 380 381 { char ret; ret = __atomic_or_fetch(vp1, v1, __ATOMIC_SEQ_CST); } 382 { char ret; ret = __atomic_or_fetch_1(vp1, v1, __ATOMIC_SEQ_CST); } 383 { short ret; ret = __atomic_or_fetch(vp2, v2, __ATOMIC_SEQ_CST); } 384 { short ret; ret = __atomic_or_fetch_2(vp2, v2, __ATOMIC_SEQ_CST); } 385 { int ret; ret = __atomic_or_fetch(vp4, v4, __ATOMIC_SEQ_CST); } 386 { int ret; ret = __atomic_or_fetch_4(vp4, v4, __ATOMIC_SEQ_CST); } 387 { long long int ret; ret = __atomic_or_fetch(vp8, v8, __ATOMIC_SEQ_CST); } 388 { long long int ret; ret = __atomic_or_fetch_8(vp8, v8, __ATOMIC_SEQ_CST); } 389 #if defined(__SIZEOF_INT128__) 390 { __int128 ret; ret = __atomic_or_fetch(vp16, v16, __ATOMIC_SEQ_CST); } 391 { __int128 ret; ret = __atomic_or_fetch_16(vp16, v16, __ATOMIC_SEQ_CST); } 392 #endif 393 394 { char ret; ret = __atomic_fetch_add(vp1, v1, __ATOMIC_SEQ_CST); } 395 { char ret; ret = __atomic_fetch_add_1(vp1, v1, __ATOMIC_SEQ_CST); } 396 { short ret; ret = __atomic_fetch_add(vp2, v2, __ATOMIC_SEQ_CST); } 397 { short ret; ret = __atomic_fetch_add_2(vp2, v2, __ATOMIC_SEQ_CST); } 398 { int ret; ret = __atomic_fetch_add(vp4, v4, __ATOMIC_SEQ_CST); } 399 { int ret; ret = __atomic_fetch_add_4(vp4, v4, __ATOMIC_SEQ_CST); } 400 { long long int ret; ret = __atomic_fetch_add(vp8, v8, __ATOMIC_SEQ_CST); } 401 { long long int ret; ret = __atomic_fetch_add_8(vp8, v8, __ATOMIC_SEQ_CST); } 402 #if defined(__SIZEOF_INT128__) 403 { __int128 ret; ret = __atomic_fetch_add(vp16, v16, __ATOMIC_SEQ_CST); } 404 { __int128 ret; ret = __atomic_fetch_add_16(vp16, v16, __ATOMIC_SEQ_CST); } 405 #endif 406 407 { char ret; ret = __atomic_fetch_sub(vp1, v1, __ATOMIC_SEQ_CST); } 408 { char ret; ret = __atomic_fetch_sub_1(vp1, v1, __ATOMIC_SEQ_CST); } 409 { short ret; ret = __atomic_fetch_sub(vp2, v2, __ATOMIC_SEQ_CST); } 410 { short ret; ret = __atomic_fetch_sub_2(vp2, v2, __ATOMIC_SEQ_CST); } 411 { int ret; ret = __atomic_fetch_sub(vp4, v4, __ATOMIC_SEQ_CST); } 412 { int ret; ret = __atomic_fetch_sub_4(vp4, v4, __ATOMIC_SEQ_CST); } 413 { long long int ret; ret = __atomic_fetch_sub(vp8, v8, __ATOMIC_SEQ_CST); } 414 { long long int ret; ret = __atomic_fetch_sub_8(vp8, v8, __ATOMIC_SEQ_CST); } 415 #if defined(__SIZEOF_INT128__) 416 { __int128 ret; ret = __atomic_fetch_sub(vp16, v16, __ATOMIC_SEQ_CST); } 417 { __int128 ret; ret = __atomic_fetch_sub_16(vp16, v16, __ATOMIC_SEQ_CST); } 418 #endif 419 420 { char ret; ret = __atomic_fetch_and(vp1, v1, __ATOMIC_SEQ_CST); } 421 { char ret; ret = __atomic_fetch_and_1(vp1, v1, __ATOMIC_SEQ_CST); } 422 { short ret; ret = __atomic_fetch_and(vp2, v2, __ATOMIC_SEQ_CST); } 423 { short ret; ret = __atomic_fetch_and_2(vp2, v2, __ATOMIC_SEQ_CST); } 424 { int ret; ret = __atomic_fetch_and(vp4, v4, __ATOMIC_SEQ_CST); } 425 { int ret; ret = __atomic_fetch_and_4(vp4, v4, __ATOMIC_SEQ_CST); } 426 { long long int ret; ret = __atomic_fetch_and(vp8, v8, __ATOMIC_SEQ_CST); } 427 { long long int ret; ret = __atomic_fetch_and_8(vp8, v8, __ATOMIC_SEQ_CST); } 428 #if defined(__SIZEOF_INT128__) 429 { __int128 ret; ret = __atomic_fetch_and(vp16, v16, __ATOMIC_SEQ_CST); } 430 { __int128 ret; ret = __atomic_fetch_and_16(vp16, v16, __ATOMIC_SEQ_CST); } 431 #endif 432 433 { char ret; ret = __atomic_fetch_nand(vp1, v1, __ATOMIC_SEQ_CST); } 434 { char ret; ret = __atomic_fetch_nand_1(vp1, v1, __ATOMIC_SEQ_CST); } 435 { short ret; ret = __atomic_fetch_nand(vp2, v2, __ATOMIC_SEQ_CST); } 436 { short ret; ret = __atomic_fetch_nand_2(vp2, v2, __ATOMIC_SEQ_CST); } 437 { int ret; ret = __atomic_fetch_nand(vp4, v4, __ATOMIC_SEQ_CST); } 438 { int ret; ret = __atomic_fetch_nand_4(vp4, v4, __ATOMIC_SEQ_CST); } 439 { long long int ret; ret = __atomic_fetch_nand(vp8, v8, __ATOMIC_SEQ_CST); } 440 { long long int ret; ret = __atomic_fetch_nand_8(vp8, v8, __ATOMIC_SEQ_CST); } 441 #if defined(__SIZEOF_INT128__) 442 { __int128 ret; ret = __atomic_fetch_nand(vp16, v16, __ATOMIC_SEQ_CST); } 443 { __int128 ret; ret = __atomic_fetch_nand_16(vp16, v16, __ATOMIC_SEQ_CST); } 444 #endif 445 446 { char ret; ret = __atomic_fetch_xor(vp1, v1, __ATOMIC_SEQ_CST); } 447 { char ret; ret = __atomic_fetch_xor_1(vp1, v1, __ATOMIC_SEQ_CST); } 448 { short ret; ret = __atomic_fetch_xor(vp2, v2, __ATOMIC_SEQ_CST); } 449 { short ret; ret = __atomic_fetch_xor_2(vp2, v2, __ATOMIC_SEQ_CST); } 450 { int ret; ret = __atomic_fetch_xor(vp4, v4, __ATOMIC_SEQ_CST); } 451 { int ret; ret = __atomic_fetch_xor_4(vp4, v4, __ATOMIC_SEQ_CST); } 452 { long long int ret; ret = __atomic_fetch_xor(vp8, v8, __ATOMIC_SEQ_CST); } 453 { long long int ret; ret = __atomic_fetch_xor_8(vp8, v8, __ATOMIC_SEQ_CST); } 454 #if defined(__SIZEOF_INT128__) 455 { __int128 ret; ret = __atomic_fetch_xor(vp16, v16, __ATOMIC_SEQ_CST); } 456 { __int128 ret; ret = __atomic_fetch_xor_16(vp16, v16, __ATOMIC_SEQ_CST); } 457 #endif 458 459 { char ret; ret = __atomic_fetch_or(vp1, v1, __ATOMIC_SEQ_CST); } 460 { char ret; ret = __atomic_fetch_or_1(vp1, v1, __ATOMIC_SEQ_CST); } 461 { short ret; ret = __atomic_fetch_or(vp2, v2, __ATOMIC_SEQ_CST); } 462 { short ret; ret = __atomic_fetch_or_2(vp2, v2, __ATOMIC_SEQ_CST); } 463 { int ret; ret = __atomic_fetch_or(vp4, v4, __ATOMIC_SEQ_CST); } 464 { int ret; ret = __atomic_fetch_or_4(vp4, v4, __ATOMIC_SEQ_CST); } 465 { long long int ret; ret = __atomic_fetch_or(vp8, v8, __ATOMIC_SEQ_CST); } 466 { long long int ret; ret = __atomic_fetch_or_8(vp8, v8, __ATOMIC_SEQ_CST); } 467 #if defined(__SIZEOF_INT128__) 468 { __int128 ret; ret = __atomic_fetch_or(vp16, v16, __ATOMIC_SEQ_CST); } 469 { __int128 ret; ret = __atomic_fetch_or_16(vp16, v16, __ATOMIC_SEQ_CST); } 470 #endif 471 472 { _Bool ret; ret = __atomic_always_lock_free(sizeof(int), vp4); } 473 { _Bool ret; ret = __atomic_is_lock_free(sizeof(int), vp4); } 352 474 { __atomic_thread_fence(__ATOMIC_SEQ_CST); } 353 475 { __atomic_signal_fence(__ATOMIC_SEQ_CST); } -
tests/concurrent/examples/.expect/datingService.txt
r3d5701e r9fb8f01 1 Girl:17 is dating Boy at 2 with ccode 17 2 Boy:2 is dating Girl 17 with ccode 17 3 Boy:14 is dating Girl 5 with ccode 5 4 Girl:5 is dating Boy at 14 with ccode 5 5 Boy:9 is dating Girl 10 with ccode 10 6 Girl:10 is dating Boy at 9 with ccode 10 7 Boy:1 is dating Girl 18 with ccode 18 8 Girl:18 is dating Boy at 1 with ccode 18 9 Boy:16 is dating Girl 3 with ccode 3 10 Girl:3 is dating Boy at 16 with ccode 3 11 Boy:5 is dating Girl 14 with ccode 14 12 Girl:14 is dating Boy at 5 with ccode 14 13 Boy:15 is dating Girl 4 with ccode 4 14 Girl:4 is dating Boy at 15 with ccode 4 15 Girl:0 is dating Boy at 19 with ccode 0 16 Boy:19 is dating Girl 0 with ccode 0 17 Girl:9 is dating Boy at 10 with ccode 9 18 Boy:10 is dating Girl 9 with ccode 9 19 Girl:11 is dating Boy at 8 with ccode 11 20 Boy:8 is dating Girl 11 with ccode 11 21 Boy:12 is dating Girl 7 with ccode 7 22 Girl:7 is dating Boy at 12 with ccode 7 23 Boy:11 is dating Girl 8 with ccode 8 24 Girl:8 is dating Boy at 11 with ccode 8 25 Girl:16 is dating Boy at 3 with ccode 16 26 Boy:3 is dating Girl 16 with ccode 16 27 Girl:15 is dating Boy at 4 with ccode 15 28 Boy:4 is dating Girl 15 with ccode 15 29 Girl:19 is dating Boy at 0 with ccode 19 30 Boy:0 is dating Girl 19 with ccode 19 31 Girl:2 is dating Boy at 17 with ccode 2 32 Boy:17 is dating Girl 2 with ccode 2 33 Boy:13 is dating Girl 6 with ccode 6 34 Girl:6 is dating Boy at 13 with ccode 6 35 Boy:7 is dating Girl 12 with ccode 12 36 Girl:12 is dating Boy at 7 with ccode 12 37 Girl:13 is dating Boy at 6 with ccode 13 38 Boy:6 is dating Girl 13 with ccode 13 39 Girl:1 is dating Boy at 18 with ccode 1 40 Boy:18 is dating Girl 1 with ccode 1 -
tests/concurrent/examples/boundedBufferEXT.cfa
r3d5701e r9fb8f01 10 10 // Created On : Wed Apr 18 22:52:12 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jan 16 22:36:34 202013 // Update Count : 1 512 // Last Modified On : Fri Jun 21 08:19:20 2019 13 // Update Count : 14 14 14 // 15 15 … … 37 37 38 38 void insert( Buffer(T) & mutex buffer, T elem ) with( buffer ) { 39 if ( count == BufferSize ) waitfor( remove :buffer );39 if ( count == BufferSize ) waitfor( remove, buffer ); 40 40 elements[back] = elem; 41 41 back = ( back + 1 ) % BufferSize; … … 44 44 45 45 T remove( Buffer(T) & mutex buffer ) with( buffer ) { 46 if ( count == 0 ) waitfor( insert :buffer );46 if ( count == 0 ) waitfor( insert, buffer ); 47 47 T elem = elements[front]; 48 48 front = ( front + 1 ) % BufferSize; -
tests/concurrent/examples/boundedBufferTHREAD.cfa
r3d5701e r9fb8f01 10 10 // Created On : Wed Apr 18 22:52:12 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jan 16 23:09:43 202013 // Update Count : 2 512 // Last Modified On : Fri Jun 21 11:50:12 2019 13 // Update Count : 24 14 14 // 15 15 … … 44 44 void main( Buffer & buffer ) with( buffer ) { 45 45 for () { 46 waitfor( ^?{} :buffer ) {46 waitfor( ^?{}, buffer ) { 47 47 break; 48 } or when ( count != 20 ) waitfor( insert :buffer ) {48 } or when ( count != 20 ) waitfor( insert, buffer ) { 49 49 back = (back + 1) % 20; 50 50 count += 1; 51 } or when ( count != 0 ) waitfor( remove :buffer ) {51 } or when ( count != 0 ) waitfor( remove, buffer ) { 52 52 front = (front + 1) % 20; 53 53 count -= 1; -
tests/concurrent/examples/datingService.cfa
r3d5701e r9fb8f01 1 1 // 2 2 // Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo 3 // 3 // 4 4 // The contents of this file are covered under the licence agreement in the 5 5 // file "LICENCE" distributed with Cforall. … … 35 35 signal_block( Boys[ccode] ); // restart boy to set phone number 36 36 } // if 37 //sout | "Girl:" | PhoneNo | "is dating Boy at" | BoyPhoneNo | "with ccode" | ccode;37 sout | "Girl:" | PhoneNo | "is dating Boy at" | BoyPhoneNo | "with ccode" | ccode; 38 38 return BoyPhoneNo; 39 39 } // DatingService girl … … 47 47 signal_block( Girls[ccode] ); // restart girl to set phone number 48 48 } // if 49 //sout | " Boy:" | PhoneNo | "is dating Girl" | GirlPhoneNo | "with ccode" | ccode;49 sout | " Boy:" | PhoneNo | "is dating Girl" | GirlPhoneNo | "with ccode" | ccode; 50 50 return GirlPhoneNo; 51 51 } // DatingService boy -
tests/concurrent/examples/gortn.cfa
r3d5701e r9fb8f01 10 10 // Created On : Wed Feb 20 08:02:37 2019 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jan 16 22:43:40 202013 // Update Count : 512 // Last Modified On : Fri Jun 21 08:25:03 2019 13 // Update Count : 4 14 14 // 15 15 … … 26 26 void main( GoRtn & gortn ) with( gortn ) { 27 27 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; 32 32 } 33 33 } -
tests/concurrent/examples/quickSort.cfa
r3d5701e r9fb8f01 11 11 // Created On : Wed Dec 6 12:15:52 2017 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Wed Feb 12 18:24:47 202014 // Update Count : 17 713 // Last Modified On : Fri Jun 21 08:27:45 2019 14 // Update Count : 172 15 15 // 16 16 … … 27 27 28 28 void ?{}( Quicksort & qs, int values[], int size, int depth ) { 29 qs. [values, low, high, depth] = [values, 0, size, depth];29 qs.values = values; qs.low = 0; qs.high = size; qs.depth = depth; 30 30 } // Quicksort 31 31 … … 66 66 if ( depth > 0 ) { 67 67 depth -= 1; 68 Quicksort lqs = { values, low, right, depth }; // concurrently sort lower half 69 Quicksort rqs = { values, left, high, depth }; // concurrently sort upper half 70 // Quicksort lqs = { values, low, right, depth }; // concurrently sort lower half 71 // sort( values, left, high, depth ); // concurrently sort upper half 68 Quicksort rqs = { values, low, right, depth }; // concurrently sort upper half 69 //Quicksort lqs( values, left, high, depth ); // concurrently sort lower half 70 sort( values, left, high, depth ); // concurrently sort lower half 72 71 } else { 73 72 sort( values, low, right, 0 ); // sequentially sort lower half … … 163 162 processor processors[ (1 << depth) - 1 ] __attribute__(( unused )); // create 2^depth-1 kernel threads 164 163 165 int * values = alloc( size ); // values to be sorted, too large to put on stack166 for ( counter; size ) { // generate unsorted numbers164 int * values = alloc( size ); // values to be sorted, too large to put on stack 165 for ( counter; size ) { // generate unsorted numbers 167 166 values[counter] = size - counter; // descending values 168 } // for169 for ( i; 200 ) { // random shuffle a few values170 swap( values[rand() % size], values[rand() % size] );171 167 } // for 172 168 { … … 182 178 } // main 183 179 184 // for depth in 0 1 2 3 4 5 ; do echo "sort 500000000 values with ${depth} depth" ; time -f "%Uu %Ss %E %Mkb" a.out -t 500000000 ${depth} ; done185 186 180 // Local Variables: // 187 181 // tab-width: 4 // -
tests/concurrent/multi-monitor.cfa
r3d5701e r9fb8f01 11 11 12 12 void increment( monitor_t & mutex p1, monitor_t & mutex p2, int & value ) { 13 assert(active_thread() == get_monitor(p1)->owner);14 assert(active_thread() == get_monitor(p2)->owner);15 13 value += 1; 16 assert(active_thread() == get_monitor(p1)->owner);17 assert(active_thread() == get_monitor(p2)->owner);18 14 } 19 15 -
tests/concurrent/preempt.cfa
r3d5701e r9fb8f01 36 36 if( (counter % 7) == this.value ) { 37 37 __cfaabi_check_preemption(); 38 int next = __atomic_add_fetch ( &counter, 1, __ATOMIC_SEQ_CST);38 int next = __atomic_add_fetch_4(&counter, 1, __ATOMIC_SEQ_CST); 39 39 __cfaabi_check_preemption(); 40 40 if( (next % 100) == 0 ) printf("%d\n", (int)next); -
tests/concurrent/signal/block.cfa
r3d5701e r9fb8f01 33 33 34 34 monitor global_data_t { 35 $thread* last_thread;36 $thread* last_signaller;35 thread_desc * last_thread; 36 thread_desc * last_signaller; 37 37 }; 38 38 … … 82 82 if( !is_empty( cond ) ) { 83 83 84 $thread* next = front( cond );84 thread_desc * next = front( cond ); 85 85 86 86 if( ! signal_block( cond ) ) { -
tests/concurrent/signal/wait.cfa
r3d5701e r9fb8f01 98 98 } 99 99 100 __ atomic_fetch_sub( &waiter_left, 1, __ATOMIC_SEQ_CST);100 __sync_fetch_and_sub_4( &waiter_left, 1); 101 101 } 102 102 … … 109 109 } 110 110 111 __ atomic_fetch_sub( &waiter_left, 1, __ATOMIC_SEQ_CST);111 __sync_fetch_and_sub_4( &waiter_left, 1); 112 112 } 113 113 … … 120 120 } 121 121 122 __ atomic_fetch_sub( &waiter_left, 1, __ATOMIC_SEQ_CST);122 __sync_fetch_and_sub_4( &waiter_left, 1); 123 123 } 124 124 … … 131 131 } 132 132 133 __ atomic_fetch_sub( &waiter_left, 1, __ATOMIC_SEQ_CST);133 __sync_fetch_and_sub_4( &waiter_left, 1); 134 134 } 135 135 -
tests/concurrent/thread.cfa
r3d5701e r9fb8f01 7 7 thread Second { semaphore* lock; }; 8 8 9 void ?{}( First & this, semaphore & lock ) { ((thread&)this){ "Thread 1"}; this.lock = &lock; }10 void ?{}( Second & this, semaphore & lock ) { ((thread&)this){ "Thread 2"}; this.lock = &lock; }9 void ?{}( First & this, semaphore & lock ) { ((thread&)this){"Thread 1"}; this.lock = &lock; } 10 void ?{}( Second & this, semaphore & lock ) { ((thread&)this){"Thread 2"}; this.lock = &lock; } 11 11 12 12 void main(First& this) { -
tests/concurrent/waitfor/barge.cfa
r3d5701e r9fb8f01 65 65 yield(random( 10 )); 66 66 this.state = WAITFOR; 67 waitfor(do_call :this) {67 waitfor(do_call, this) { 68 68 sout | i; 69 69 } -
tests/concurrent/waitfor/dtor.cfa
r3d5701e r9fb8f01 47 47 yield(random( 10 )); 48 48 set_state( this, MAIN ); 49 waitfor( ^?{} :this ) {49 waitfor( ^?{}, this ) { 50 50 set_state( this, AFTER ); 51 51 } -
tests/concurrent/waitfor/else.cfa
r3d5701e r9fb8f01 14 14 sout | "Starting"; 15 15 16 when( false ) waitfor( notcalled :m );16 when( false ) waitfor( notcalled, m ); 17 17 18 18 sout | "Step" | i++; 19 19 20 waitfor( notcalled :m ); or else {20 waitfor( notcalled, m ); or else { 21 21 sout | "else called"; 22 22 } … … 24 24 sout | "Step" | i++; 25 25 26 when( true ) waitfor( notcalled :m ); or when( true ) else {26 when( true ) waitfor( notcalled, m ); or when( true ) else { 27 27 sout | "else called"; 28 28 } … … 30 30 sout | "Step" | i++; 31 31 32 when( false ) waitfor( notcalled :m ); or when( true ) else {32 when( false ) waitfor( notcalled, m ); or when( true ) else { 33 33 sout | "else called"; 34 34 } … … 36 36 sout | "Step" | i++; 37 37 38 when( false ) waitfor( notcalled :m ); or when( false ) else {38 when( false ) waitfor( notcalled, m ); or when( false ) else { 39 39 sout | "else called"; 40 40 } -
tests/concurrent/waitfor/parse.cfa
r3d5701e r9fb8f01 24 24 25 25 //--------------------------------------- 26 waitfor( f1 :a ) {26 waitfor( f1, a ) { 27 27 1; 28 28 } 29 29 30 30 //--------------------------------------- 31 waitfor( f1 :a ) {31 waitfor( f1, a ) { 32 32 2; 33 33 } 34 waitfor( f2 :a ) {34 waitfor( f2, a ) { 35 35 3; 36 36 } 37 37 38 38 //--------------------------------------- 39 when( 1 < 3 ) waitfor( f2 :a, a ) {39 when( 1 < 3 ) waitfor( f2, a, a ) { 40 40 4; 41 41 } … … 45 45 46 46 //--------------------------------------- 47 when( 2 < 3 ) waitfor( f3 :a ) {47 when( 2 < 3 ) waitfor( f3, a ) { 48 48 5; 49 49 } … … 53 53 54 54 //--------------------------------------- 55 when( 3 < 3 ) waitfor( f3 :a, a ) {55 when( 3 < 3 ) waitfor( f3, a, a ) { 56 56 7; 57 57 } … … 64 64 65 65 //--------------------------------------- 66 when( 6 < 3 ) waitfor( f3 :a, a, a ) {66 when( 6 < 3 ) waitfor( f3, a, a, a ) { 67 67 10; 68 68 } 69 or when( 7 < 3 ) waitfor( f1 :a ) {69 or when( 7 < 3 ) waitfor( f1, a ) { 70 70 11; 71 71 } … … 75 75 76 76 //--------------------------------------- 77 when( 8 < 3 ) waitfor( f3 :a, a ) {77 when( 8 < 3 ) waitfor( f3, a, a ) { 78 78 13; 79 79 } 80 or waitfor( f1 :a ) {80 or waitfor( f1, a ) { 81 81 14; 82 82 } … … 86 86 87 87 //--------------------------------------- 88 when( 10 < 3 ) waitfor( f1 :a ) {88 when( 10 < 3 ) waitfor( f1, a ) { 89 89 16; 90 90 } 91 or waitfor( f2 :a, a ) {91 or waitfor( f2, a, a ) { 92 92 17; 93 93 } … … 100 100 } 101 101 102 int main() {} 102 int main() { 103 104 } -
tests/concurrent/waitfor/parse2.cfa
r3d5701e r9fb8f01 10 10 // Created On : Wed Aug 30 17:53:29 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jan 16 23:13:37 202013 // Update Count : 612 // Last Modified On : Fri Mar 22 13:42:11 2019 13 // Update Count : 3 14 14 // 15 15 … … 26 26 } 27 27 28 waitfor( x :z ) {28 waitfor( x, z ) { 29 29 } 30 30 … … 37 37 or waitfor( y ); 38 38 39 waitfor( x :z );39 waitfor( x, z ); 40 40 or waitfor( y ); 41 41 … … 43 43 or when( true ) waitfor( y ); 44 44 45 when( true ) waitfor( x :z );45 when( true ) waitfor( x, z ); 46 46 or when( true ) waitfor( y ); 47 47 … … 50 50 } 51 51 52 waitfor( x :z ) {52 waitfor( x, z ) { 53 53 } or waitfor( y ) { 54 54 } … … 80 80 or else; 81 81 82 when( true ) waitfor( x :z );82 when( true ) waitfor( x, z ); 83 83 or else; 84 84 … … 99 99 } 100 100 101 when( true ) waitfor( x :z );101 when( true ) waitfor( x, z ); 102 102 or else { 103 103 } … … 115 115 or when( true ) else; 116 116 117 when( true ) waitfor( x :z );117 when( true ) waitfor( x, z ); 118 118 or when( true ) else; 119 119 … … 134 134 } 135 135 136 when( true ) waitfor( x :z );136 when( true ) waitfor( x, z ); 137 137 or when( true ) else { 138 138 } … … 149 149 or timeout( 3 ); 150 150 151 waitfor( x :z );151 waitfor( x, z ); 152 152 or timeout( 3 ); 153 153 … … 163 163 } 164 164 165 when( true ) waitfor( x :z ) {165 when( true ) waitfor( x, z ) { 166 166 } or timeout( 3 ) { 167 167 } … … 171 171 } 172 172 173 when( true ) waitfor( x :z ) {173 when( true ) waitfor( x, z ) { 174 174 } or when ( true ) timeout( 3 ) { 175 175 } … … 229 229 230 230 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; 239 239 240 240 // test else selection -
tests/concurrent/waitfor/recurse.cfa
r3d5701e r9fb8f01 66 66 67 67 rand_yield(); 68 waitfor( call4 :this );68 waitfor( call4, this ); 69 69 rand_yield(); 70 70 … … 78 78 79 79 rand_yield(); 80 waitfor( call3 :this );80 waitfor( call3, this ); 81 81 rand_yield(); 82 82 … … 92 92 93 93 rand_yield(); 94 waitfor( call2 :this );94 waitfor( call2, this ); 95 95 rand_yield(); 96 96 -
tests/concurrent/waitfor/statment.cfa
r3d5701e r9fb8f01 101 101 102 102 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; } } 111 111 112 112 done = true; -
tests/concurrent/waitfor/when.cfa
r3d5701e r9fb8f01 58 58 void arbiter( global_t & mutex this ) { 59 59 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; } } 66 66 67 67 sout | this.last_call; -
tests/config.py.in
r3d5701e r9fb8f01 8 8 BUILDDIR = "@abs_builddir@" 9 9 HOSTARCH = "@host_cpu@" 10 DISTRIBUTE = @HAS_DISTCC@ -
tests/expression.cfa
r3d5701e r9fb8f01 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 9 1 int 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; 15 4 16 5 // operators 17 6 18 ! i;7 ! i; 19 8 ~i; 20 9 +i; 21 10 -i; 22 *p s;23 ++p s;24 --p s;25 p s++;26 p s--;11 *p; 12 ++p; 13 --p; 14 p++; 15 p--; 27 16 28 i + j;29 i - j;30 i * j;17 i+i; 18 i-i; 19 i*i; 31 20 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; 40 29 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; 50 49 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; 85 51 } // main -
tests/heap.cfa
r3d5701e r9fb8f01 10 10 // Created On : Tue Nov 6 17:54:56 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Nov 24 12:34:51201913 // Update Count : 2812 // Last Modified On : Fri Jul 19 08:22:34 2019 13 // Update Count : 19 14 14 // 15 15 … … 38 38 enum { NoOfAllocs = 5000, NoOfMmaps = 10 }; 39 39 char * locns[NoOfAllocs]; 40 size_t amount; 41 enum { limit = 64 * 1024 }; // check alignments up to here 40 int i; 42 41 43 42 // check alloc/free … … 75 74 size_t s = (i + 1) * 20; 76 75 char * area = (char *)malloc( s ); 77 if ( area == 0 p) abort( "malloc/free out of memory" );76 if ( area == 0 ) abort( "malloc/free out of memory" ); 78 77 area[0] = '\345'; area[s - 1] = '\345'; // fill first/last 79 78 area[malloc_usable_size( area ) - 1] = '\345'; // fill ultimate byte … … 84 83 size_t s = i + 1; // +1 to make initialization simpler 85 84 locns[i] = (char *)malloc( s ); 86 if ( locns[i] == 0 p) abort( "malloc/free out of memory" );85 if ( locns[i] == 0 ) abort( "malloc/free out of memory" ); 87 86 locns[i][0] = '\345'; locns[i][s - 1] = '\345'; // fill first/last 88 87 locns[i][malloc_usable_size( locns[i] ) - 1] = '\345'; // fill ultimate byte … … 100 99 size_t s = i + default_mmap_start(); // cross over point 101 100 char * area = (char *)malloc( s ); 102 if ( area == 0 p) abort( "malloc/free out of memory" );101 if ( area == 0 ) abort( "malloc/free out of memory" ); 103 102 area[0] = '\345'; area[s - 1] = '\345'; // fill first/last 104 103 area[malloc_usable_size( area ) - 1] = '\345'; // fill ultimate byte … … 109 108 size_t s = i + default_mmap_start(); // cross over point 110 109 locns[i] = (char *)malloc( s ); 111 if ( locns[i] == 0 p) abort( "malloc/free out of memory" );110 if ( locns[i] == 0 ) abort( "malloc/free out of memory" ); 112 111 locns[i][0] = '\345'; locns[i][s - 1] = '\345'; // fill first/last 113 112 locns[i][malloc_usable_size( locns[i] ) - 1] = '\345'; // fill ultimate byte … … 125 124 size_t s = (i + 1) * 20; 126 125 char * area = (char *)calloc( 5, s ); 127 if ( area == 0 p) abort( "calloc/free out of memory" );126 if ( area == 0 ) abort( "calloc/free out of memory" ); 128 127 if ( area[0] != '\0' || area[s - 1] != '\0' || 129 128 area[malloc_usable_size( area ) - 1] != '\0' || … … 137 136 size_t s = i + 1; 138 137 locns[i] = (char *)calloc( 5, s ); 139 if ( locns[i] == 0 p) abort( "calloc/free out of memory" );138 if ( locns[i] == 0 ) abort( "calloc/free out of memory" ); 140 139 if ( locns[i][0] != '\0' || locns[i][s - 1] != '\0' || 141 140 locns[i][malloc_usable_size( locns[i] ) - 1] != '\0' || … … 156 155 size_t s = i + default_mmap_start(); // cross over point 157 156 char * area = (char *)calloc( 1, s ); 158 if ( area == 0 p) abort( "calloc/free out of memory" );157 if ( area == 0 ) abort( "calloc/free out of memory" ); 159 158 if ( area[0] != '\0' || area[s - 1] != '\0' ) abort( "calloc/free corrupt storage4.1" ); 160 159 if ( area[malloc_usable_size( area ) - 1] != '\0' ) abort( "calloc/free corrupt storage4.2" ); … … 168 167 size_t s = i + default_mmap_start(); // cross over point 169 168 locns[i] = (char *)calloc( 1, s ); 170 if ( locns[i] == 0 p) abort( "calloc/free out of memory" );169 if ( locns[i] == 0 ) abort( "calloc/free out of memory" ); 171 170 if ( locns[i][0] != '\0' || locns[i][s - 1] != '\0' || 172 171 locns[i][malloc_usable_size( locns[i] ) - 1] != '\0' || … … 184 183 // check memalign/free (sbrk) 185 184 185 enum { limit = 64 * 1024 }; // check alignments up to here 186 186 187 for ( a; libAlign() ~= limit ~ a ) { // generate powers of 2 187 188 //sout | alignments[a]; 188 189 for ( s; 1 ~ NoOfAllocs ) { // allocation of size 0 can return null 189 190 char * area = (char *)memalign( a, s ); 190 if ( area == 0 p) abort( "memalign/free out of memory" );191 //sout | i | area;191 if ( area == 0 ) abort( "memalign/free out of memory" ); 192 //sout | i | " " | area; 192 193 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment 193 194 abort( "memalign/free bad alignment : memalign(%d,%d) = %p", (int)a, s, area ); 194 195 } // if 195 area[0] = '\345'; area[s - 1] = '\345'; // fill first/last byte196 area[0] = '\345'; area[s - 1] = '\345'; // fill first/last byte 196 197 area[malloc_usable_size( area ) - 1] = '\345'; // fill ultimate byte 197 198 free( area ); … … 206 207 size_t s = i + default_mmap_start(); // cross over point 207 208 char * area = (char *)memalign( a, s ); 208 if ( area == 0 p) abort( "memalign/free out of memory" );209 //sout | i | area;209 if ( area == 0 ) abort( "memalign/free out of memory" ); 210 //sout | i | " " | area; 210 211 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment 211 212 abort( "memalign/free bad alignment : memalign(%d,%d) = %p", (int)a, (int)s, area ); … … 222 223 // initial N byte allocation 223 224 char * area = (char *)calloc( 5, i ); 224 if ( area == 0 p) abort( "calloc/realloc/free out of memory" );225 if ( area == 0 ) abort( "calloc/realloc/free out of memory" ); 225 226 if ( area[0] != '\0' || area[i - 1] != '\0' || 226 227 area[malloc_usable_size( area ) - 1] != '\0' || … … 230 231 for ( s; i ~ 256 * 1024 ~ 26 ) { // start at initial memory request 231 232 area = (char *)realloc( area, s ); // attempt to reuse storage 232 if ( area == 0 p) abort( "calloc/realloc/free out of memory" );233 if ( area == 0 ) abort( "calloc/realloc/free out of memory" ); 233 234 if ( area[0] != '\0' || area[s - 1] != '\0' || 234 235 area[malloc_usable_size( area ) - 1] != '\0' || … … 244 245 size_t s = i + default_mmap_start(); // cross over point 245 246 char * area = (char *)calloc( 1, s ); 246 if ( area == 0 p) abort( "calloc/realloc/free out of memory" );247 if ( area == 0 ) abort( "calloc/realloc/free out of memory" ); 247 248 if ( area[0] != '\0' || area[s - 1] != '\0' || 248 249 area[malloc_usable_size( area ) - 1] != '\0' || … … 252 253 for ( r; i ~ 256 * 1024 ~ 26 ) { // start at initial memory request 253 254 area = (char *)realloc( area, r ); // attempt to reuse storage 254 if ( area == 0 p) abort( "calloc/realloc/free out of memory" );255 if ( area == 0 ) abort( "calloc/realloc/free out of memory" ); 255 256 if ( area[0] != '\0' || area[r - 1] != '\0' || 256 257 area[malloc_usable_size( area ) - 1] != '\0' || … … 262 263 // check memalign/realloc/free 263 264 264 amount = 2;265 size_t amount = 2; 265 266 for ( a; libAlign() ~= limit ~ a ) { // generate powers of 2 266 267 // initial N byte allocation 267 268 char * area = (char *)memalign( a, amount ); // aligned N-byte allocation 268 if ( area == 0 p) abort( "memalign/realloc/free out of memory" ); // no storage ?269 //sout | alignments[a] | area;269 if ( area == 0 ) abort( "memalign/realloc/free out of memory" ); // no storage ? 270 //sout | alignments[a] | " " | area; 270 271 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment 271 272 abort( "memalign/realloc/free bad alignment : memalign(%d,%d) = %p", (int)a, (int)amount, area ); … … 277 278 if ( area[0] != '\345' || area[s - 2] != '\345' ) abort( "memalign/realloc/free corrupt storage" ); 278 279 area = (char *)realloc( area, s ); // attempt to reuse storage 279 if ( area == 0 p) abort( "memalign/realloc/free out of memory" ); // no storage ?280 //sout | i | area;280 if ( area == 0 ) abort( "memalign/realloc/free out of memory" ); // no storage ? 281 //sout | i | " " | area; 281 282 if ( (size_t)area % a != 0 ) { // check for initial alignment 282 283 abort( "memalign/realloc/free bad alignment %p", area ); … … 293 294 for ( s; 1 ~ limit ) { // allocation of size 0 can return null 294 295 char * area = (char *)cmemalign( a, 1, s ); 295 if ( area == 0 p) abort( "cmemalign/free out of memory" );296 //sout | i | area;296 if ( area == 0 ) abort( "cmemalign/free out of memory" ); 297 //sout | i | " " | area; 297 298 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment 298 299 abort( "cmemalign/free bad alignment : cmemalign(%d,%d) = %p", (int)a, s, area ); … … 312 313 // initial N byte allocation 313 314 char * area = (char *)cmemalign( a, 1, amount ); // aligned N-byte allocation 314 if ( area == 0 p) abort( "cmemalign/realloc/free out of memory" ); // no storage ?315 //sout | alignments[a] | area;315 if ( area == 0 ) abort( "cmemalign/realloc/free out of memory" ); // no storage ? 316 //sout | alignments[a] | " " | area; 316 317 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment 317 318 abort( "cmemalign/realloc/free bad alignment : cmemalign(%d,%d) = %p", (int)a, (int)amount, area ); … … 326 327 if ( area[0] != '\345' || area[s - 2] != '\345' ) abort( "cmemalign/realloc/free corrupt storage2" ); 327 328 area = (char *)realloc( area, s ); // attempt to reuse storage 328 if ( area == 0 p) abort( "cmemalign/realloc/free out of memory" ); // no storage ?329 //sout | i | area;329 if ( area == 0 ) abort( "cmemalign/realloc/free out of memory" ); // no storage ? 330 //sout | i | " " | area; 330 331 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment 331 332 abort( "cmemalign/realloc/free bad alignment %p", area ); … … 338 339 free( area ); 339 340 } // for 340 341 // check memalign/realloc with align/free342 343 amount = 2;344 for ( a; libAlign() ~= limit ~ a ) { // generate powers of 2345 // initial N byte allocation346 char * area = (char *)memalign( a, amount ); // aligned N-byte allocation347 if ( area == 0p ) abort( "memalign/realloc with align/free out of memory" ); // no storage ?348 //sout | alignments[a] | area | endl;349 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment350 abort( "memalign/realloc with align/free bad alignment : memalign(%d,%d) = %p", (int)a, (int)amount, area );351 } // if352 area[0] = '\345'; area[amount - 2] = '\345'; // fill first/penultimate byte353 354 // Do not start this loop index at 0 because realloc of 0 bytes frees the storage.355 for ( s; amount ~ 256 * 1024 ) { // start at initial memory request356 if ( area[0] != '\345' || area[s - 2] != '\345' ) abort( "memalign/realloc/free corrupt storage" );357 area = (char *)realloc( area, a * 2, s ); // attempt to reuse storage358 if ( area == 0p ) abort( "memalign/realloc with align/free out of memory" ); // no storage ?359 //sout | i | area | endl;360 if ( (size_t)area % a * 2 != 0 ) { // check for initial alignment361 abort( "memalign/realloc with align/free bad alignment %p", area );362 } // if363 area[s - 1] = '\345'; // fill last byte364 } // for365 free( area );366 } // for367 368 // check cmemalign/realloc with align/free369 370 amount = 2;371 for ( size_t a = libAlign() + libAlign(); a <= limit; a += a ) { // generate powers of 2372 // initial N byte allocation373 char *area = (char *)cmemalign( a, 1, amount ); // aligned N-byte allocation374 if ( area == 0p ) abort( "cmemalign/realloc with align/free out of memory" ); // no storage ?375 //sout | alignments[a] | area | endl;376 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment377 abort( "cmemalign/realloc with align/free bad alignment : cmemalign(%d,%d) = %p", (int)a, (int)amount, area );378 } // if379 if ( area[0] != '\0' || area[amount - 1] != '\0' ||380 area[malloc_usable_size( area ) - 1] != '\0' ||381 ! malloc_zero_fill( area ) ) abort( "cmemalign/realloc with align/free corrupt storage1" );382 area[0] = '\345'; area[amount - 2] = '\345'; // fill first/penultimate byte383 384 // Do not start this loop index at 0 because realloc of 0 bytes frees the storage.385 for ( int s = amount; s < 256 * 1024; s += 1 ) { // start at initial memory request386 if ( area[0] != '\345' || area[s - 2] != '\345' ) abort( "cmemalign/realloc with align/free corrupt storage2" );387 area = (char *)realloc( area, a * 2, s ); // attempt to reuse storage388 if ( area == 0p ) abort( "cmemalign/realloc with align/free out of memory" ); // no storage ?389 //sout | i | area | endl;390 if ( (size_t)area % a * 2 != 0 || malloc_alignment( area ) != a * 2 ) { // check for initial alignment391 abort( "cmemalign/realloc with align/free bad alignment %p %jd %jd", area, malloc_alignment( area ), a * 2 );392 } // if393 if ( area[s - 1] != '\0' || area[s - 1] != '\0' ||394 area[malloc_usable_size( area ) - 1] != '\0' ||395 ! malloc_zero_fill( area ) ) abort( "cmemalign/realloc/free corrupt storage3" );396 area[s - 1] = '\345'; // fill last byte397 } // for398 free( area );399 } // for400 401 341 //sout | "worker" | thisTask() | "successful completion"; 402 342 } // Worker main -
tests/labelledExit.cfa
r3d5701e r9fb8f01 10 10 // Created On : Wed Aug 10 07:29:39 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 5 16:49:48 202013 // Update Count : 912 // Last Modified On : Tue Nov 6 17:57:42 2018 13 // Update Count : 4 14 14 // 15 15 … … 136 136 } 137 137 138 // all nested control options, labelled exits139 140 Comp: {141 Try: try {142 For: for ( ;; ) {143 While: while ( true ) {144 Do: do {145 If: if ( true ) {146 Switch2: switch ( 3 ) {147 case 3:148 break Try;149 break Comp;150 break For; continue For;151 break While; continue While;152 break Do; continue Do;153 break If;154 break Switch2;155 } // switch156 } // if157 } while ( true );158 } // while159 } // for160 } finally {} // always executed161 } // compound162 163 138 // computed goto 164 {165 void *array[] = { &&foo, &&bar, &&hack };166 foo: bar: hack:167 &&foo;168 &&bar;169 goto *array[i];170 }139 // { 140 // void *array[] = { &&foo, &&bar, &&hack }; 141 // foo: bar: hack: 142 // &&foo; 143 // &&bar; 144 // goto *array[i]; 145 // } 171 146 172 147 Q: if ( i > 5 ) { -
tests/linking/withthreads.cfa
r3d5701e r9fb8f01 34 34 // Local Variables: // 35 35 // tab-width: 4 // 36 // compile-command: "cfa withthreads.cfa" //36 // compile-command: "cfa nothreads.cfa" // 37 37 // End: // -
tests/loopctrl.cfa
r3d5701e r9fb8f01 10 10 // Created On : Wed Aug 8 18:32:59 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Dec 12 17:55:26201913 // Update Count : 10 812 // Last Modified On : Fri Jul 12 12:05:05 2019 13 // Update Count : 106 14 14 // 15 15 … … 43 43 for ( 1 ) { sout | "A"; } sout | nl; 44 44 for ( 10 ) { sout | "A"; } sout | nl; 45 for ( = 10 ) { sout | "A"; } sout | nl;46 45 for ( 1 ~= 10 ~ 2 ) { sout | "B"; } sout | nl; 47 46 for ( 10 -~= 1 ~ 2 ) { sout | "C"; } sout | nl; … … 50 49 51 50 for ( i; 10 ) { sout | i; } sout | nl; 52 for ( i; = 10 ) { sout | i; } sout | nl;53 51 for ( i; 1 ~= 10 ~ 2 ) { sout | i; } sout | nl; 54 52 for ( i; 10 -~= 1 ~ 2 ) { sout | i; } sout | nl; … … 89 87 for ( N ) { sout | "N"; } sout | nl; 90 88 for ( i; N ) { sout | i; } sout | nl; 91 for ( i; = N ) { sout | i; } sout | nl;92 89 for ( i; N -~ 0 ) { sout | i; } sout | nl | nl; 93 90 -
tests/nested-types.cfa
r3d5701e r9fb8f01 10 10 // Created On : Mon Jul 9 10:20:03 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 12 18:21:15 202013 // Update Count : 312 // Last Modified On : Tue Nov 6 17:59:40 2018 13 // Update Count : 2 14 14 // 15 15 … … 50 50 // double d; 51 51 // }; 52 53 // struct S {54 // enum C { R, G, B };55 // int i;56 // struct T {57 // int i;58 // };59 // T t;60 // };61 62 // S s;63 // S.C c;64 // S.T t;65 52 66 53 int main() { -
tests/pybin/settings.py
r3d5701e r9fb8f01 14 14 SRCDIR = os.path.abspath(config.SRCDIR) 15 15 BUILDDIR = os.path.abspath(config.BUILDDIR) 16 distribute = config.DISTRIBUTE17 16 os.chdir(testpath) 18 17 … … 89 88 self.string = "debug" if value else "no debug" 90 89 self.flags = """DEBUG_FLAGS=%s""" % ("-debug -O0" if value else "-nodebug -O2") 91 self.path = "debug" if value else "nodebug"92 90 93 91 class Install: 94 92 def __init__(self, value): 95 if value: 96 distribute = False 97 98 self.string = "installed" if value else "in tree" 99 self.flags = """installed=%s""" % ("yes" if value else "no") 93 self.string = "installed" if value else "in-tree" 94 self.flags = """INSTALL_FLAGS=%s""" % ("" if value else "-in-tree") 100 95 101 96 class Timeouts: … … 114 109 def init( options ): 115 110 global arch 116 global archive117 global debug118 global distcc119 111 global dry_run 120 112 global generating 113 global make 114 global debug 121 115 global install 122 global make116 global timeout 123 117 global output_width 124 global timeout118 global archive 125 119 120 dry_run = options.dry_run 121 generating = options.regenerate_expected 122 make = ['make'] 123 debug = Debug(options.debug) 124 install = Install(options.install) 126 125 arch = Architecture(options.arch) 126 timeout = Timeouts(options.timeout, options.global_timeout) 127 output_width = 24 127 128 archive = os.path.abspath(os.path.join(original_path, options.archive_errors)) if options.archive_errors else None 128 debug = Debug(options.debug)129 dry_run = options.dry_run # must be called before tools.config_hash()130 distcc = "DISTCC_CFA_PATH=~/.cfadistcc/%s/cfa" % tools.config_hash()131 generating = options.regenerate_expected132 install = Install(options.install)133 make = ['make']134 output_width = 24135 timeout = Timeouts(options.timeout, options.global_timeout)136 129 137 # if we distribute, distcc errors will fail tests, use log file for distcc138 # don't use "'DISTCC_LOG' not in os.environ" because it can be set to ''139 if distribute and not os.environ.get('DISTCC_LOG'):140 os.putenv('DISTCC_LOG', os.path.join(BUILDDIR, 'distcc_error.log'))141 130 142 131 def update_make_cmd(force, jobs): … … 147 136 def validate(): 148 137 errf = os.path.join(BUILDDIR, ".validate.err") 149 make_ret, out = tools.make( ".validate", error_file = errf, output _file=subprocess.DEVNULL, error=subprocess.DEVNULL )138 make_ret, out = tools.make( ".validate", error_file = errf, output=subprocess.DEVNULL, error=subprocess.DEVNULL ) 150 139 if make_ret != 0: 151 140 with open (errf, "r") as myfile: -
tests/pybin/tools.py
r3d5701e r9fb8f01 23 23 24 24 # helper functions to run terminal commands 25 def sh(*cmd, timeout = False, output_file = None, input_file = None, input_text = None, error = subprocess.STDOUT, ignore_dry_run = False): 26 try: 27 cmd = list(cmd) 28 29 if input_file and input_text: 30 return 401, "Cannot use both text and file inputs" 31 32 # if this is a dry_run, only print the commands that would be ran 33 if settings.dry_run and not ignore_dry_run: 34 cmd = "{} cmd: {}".format(os.getcwd(), ' '.join(cmd)) 35 if output_file and not isinstance(output_file, int): 36 cmd += " > " 37 cmd += output_file 38 39 if error and not isinstance(error, int): 40 cmd += " 2> " 41 cmd += error 42 43 if input_file and not isinstance(input_file, int) and os.path.isfile(input_file): 44 cmd += " < " 45 cmd += input_file 46 47 print(cmd) 48 return 0, None 49 50 with contextlib.ExitStack() as onexit: 51 # add input redirection if needed 52 input_file = openfd(input_file, 'r', onexit, True) 53 54 # add output redirection if needed 55 output_file = openfd(output_file, 'w', onexit, False) 56 57 # add error redirection if needed 58 error = openfd(error, 'w', onexit, False) 59 60 # run the desired command 61 # use with statement to make sure proc is cleaned 62 # don't use subprocess.run because we want to send SIGABRT on exit 63 with subprocess.Popen( 25 def sh(*cmd, timeout = False, output = None, input = None, error = subprocess.STDOUT): 26 cmd = list(cmd) 27 28 # if this is a dry_run, only print the commands that would be ran 29 if settings.dry_run : 30 cmd = "{} cmd: {}".format(os.getcwd(), ' '.join(cmd)) 31 if output and not isinstance(output, int): 32 cmd += " > " 33 cmd += output 34 35 if error and not isinstance(error, int): 36 cmd += " 2> " 37 cmd += error 38 39 if input and not isinstance(input, int) and os.path.isfile(input): 40 cmd += " < " 41 cmd += input 42 43 print(cmd) 44 return 0, None 45 46 with contextlib.ExitStack() as onexit: 47 # add input redirection if needed 48 input = openfd(input, 'r', onexit, True) 49 50 # add output redirection if needed 51 output = openfd(output, 'w', onexit, False) 52 53 # add error redirection if needed 54 error = openfd(error, 'w', onexit, False) 55 56 # run the desired command 57 try: 58 proc = subprocess.run( 64 59 cmd, 65 **({'input' : bytes(input_text, encoding='utf-8')} if input_text else {'stdin' : input_file}), 66 stdout = output_file, 67 stderr = error 68 ) as proc: 69 70 try: 71 out, _ = proc.communicate( 72 timeout = settings.timeout.single if timeout else None 73 ) 74 75 return proc.returncode, out.decode("utf-8") if out else None 76 except subprocess.TimeoutExpired: 77 proc.send_signal(signal.SIGABRT) 78 proc.communicate() 79 return 124, str(None) 80 81 except Exception as ex: 82 print ("Unexpected error: %s" % ex) 83 raise 60 stdin =input, 61 stdout=output, 62 stderr=error, 63 timeout=settings.timeout.single if timeout else None 64 ) 65 return proc.returncode, proc.stdout.decode("utf-8") if proc.stdout else None 66 except subprocess.TimeoutExpired: 67 return 124, str(None) 84 68 85 69 def is_ascii(fname): … … 91 75 return False 92 76 93 code, out = sh("file %s" % fname, output _file=subprocess.PIPE)77 code, out = sh("file %s" % fname, output=subprocess.PIPE) 94 78 if code != 0: 95 79 return False … … 123 107 if isinstance(files, str ): files = [ files ] 124 108 for file in files: 125 sh( 'rm', '-f', file, output _file=subprocess.DEVNULL, error=subprocess.DEVNULL )109 sh( 'rm', '-f', file, output=subprocess.DEVNULL, error=subprocess.DEVNULL ) 126 110 127 111 # Create 1 or more directory … … 131 115 p = os.path.normpath( file ) 132 116 d = os.path.dirname ( p ) 133 sh( 'mkdir', '-p', d, output _file=subprocess.DEVNULL, error=subprocess.DEVNULL )117 sh( 'mkdir', '-p', d, output=subprocess.DEVNULL, error=subprocess.DEVNULL ) 134 118 135 119 … … 154 138 lhs, 155 139 rhs, 156 output _file=subprocess.PIPE140 output=subprocess.PIPE 157 141 ) 158 142 159 143 # call make 160 def make(target, *, flags = '', output _file= None, error = None, error_file = None, silent = False):144 def make(target, *, flags = '', output = None, error = None, error_file = None, silent = False): 161 145 test_param = """test="%s" """ % (error_file) if error_file else None 162 146 cmd = [ … … 167 151 settings.debug.flags, 168 152 settings.install.flags, 169 settings.distcc if settings.distribute else None,170 153 flags, 171 154 target 172 155 ] 173 156 cmd = [s for s in cmd if s] 174 return sh(*cmd, output _file=output_file, error=error)157 return sh(*cmd, output=output, error=error) 175 158 176 159 def which(program): 177 fpath, fname = os.path.split(program) 178 if fpath: 179 if is_exe(program): 180 return program 181 else: 182 for path in os.environ["PATH"].split(os.pathsep): 183 exe_file = os.path.join(path, program) 184 if is_exe(exe_file): 185 return exe_file 186 return None 160 fpath, fname = os.path.split(program) 161 if fpath: 162 if is_exe(program): 163 return program 164 else: 165 for path in os.environ["PATH"].split(os.pathsep): 166 exe_file = os.path.join(path, program) 167 if is_exe(exe_file): 168 return exe_file 169 170 return None 187 171 188 172 @contextlib.contextmanager … … 217 201 # cat one file into the other 218 202 def cat(source, dest): 219 ret, _ = sh("cat", source, output _file=dest)203 ret, _ = sh("cat", source, output=dest) 220 204 return ret 221 205 … … 272 256 os.write(int(make_jobs_fds.group(3)), tokens) 273 257 else : 274 if settings.distribute: 275 ret, jstr = sh("distcc", "-j", output_file=subprocess.PIPE, ignore_dry_run=True) 276 if ret == 0: 277 options.jobs = int(jstr.strip()) 278 else : 279 options.jobs = multiprocessing.cpu_count() 280 else: 281 options.jobs = multiprocessing.cpu_count() 258 options.jobs = multiprocessing.cpu_count() 282 259 else : 283 260 force = True … … 297 274 ################################################################################ 298 275 299 # get hash for given configuration300 def config_hash():301 path = os.path.normpath(os.path.join(302 settings.SRCDIR,303 ))304 305 distcc_hash = os.path.join(settings.SRCDIR, '../tools/build/distcc_hash')306 config = "%s-%s" % (settings.arch.target, settings.debug.path)307 _, out = sh(distcc_hash, config, output_file=subprocess.PIPE, ignore_dry_run=True)308 return out.strip()309 310 # get pretty string for time of day311 276 def pretty_now(): 312 277 ts = time.time() … … 343 308 return 1, "ERR No core dump" 344 309 345 return sh('gdb', '-n', path, core, '-batch', '-x', cmd, output _file=subprocess.PIPE)310 return sh('gdb', '-n', path, core, '-batch', '-x', cmd, output=subprocess.PIPE) 346 311 347 312 def core_archive(dst, name, exe): 348 # Get the core dump313 # Get the files to copy 349 314 core = os.path.join(os.getcwd(), "core" ) 350 315 351 # update the path for this test352 dst = os.path.join(dst, name)316 # Uncomment if we want timestamps on coredumps 317 # dst = os.path.join(dst, "%s_%s" % (name, pretty_now())) 353 318 354 319 # make a directory for this test 355 # mkdir makes the parent directory only so add a dummy 356 mkdir(os.path.join(dst, name )) 320 mkdir(os.path.join(dst, "dir")) 357 321 358 322 # moves the files … … 364 328 365 329 class Timed: 366 def __enter__(self):367 self.start = time.time()368 return self369 370 def __exit__(self, *args):371 self.end = time.time()372 self.duration = self.end - self.start330 def __enter__(self): 331 self.start = time.time() 332 return self 333 334 def __exit__(self, *args): 335 self.end = time.time() 336 self.duration = self.end - self.start 373 337 374 338 def timed(src, timeout): 375 339 expire = time.time() + timeout 376 340 i = iter(src) 377 with contextlib.suppress(StopIteration): 378 while True: 379 yield i.next(max(expire - time.time(), 0)) 341 while True: 342 yield i.next(max(expire - time.time(), 0)) -
tests/quotedKeyword.cfa
r3d5701e r9fb8f01 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 7 19:07:07 202013 // Update Count : 2 512 // Last Modified On : Tue Dec 4 21:45:53 2018 13 // Update Count : 23 14 14 // 15 15 … … 17 17 18 18 struct { 19 int ` `otype;20 int ` `struct;19 int `otype`; 20 int `struct`; 21 21 } st = { 10, 10 }; 22 22 23 typedef int ` `forall;24 ` `forallxxx = 10;23 typedef int `forall`; 24 `forall` xxx = 10; 25 25 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;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`; 36 36 37 37 int 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`; 44 44 } 45 45 -
tests/raii/dtor-early-exit.cfa
r3d5701e r9fb8f01 217 217 } 218 218 219 void i() {220 // potential loop221 for() {222 if(true) continue;223 int t = 0;224 }225 }226 227 219 // TODO: implement __label__ and uncomment these lines 228 220 void computedGoto() { -
tests/rational.cfa
r3d5701e r9fb8f01 10 10 // Created On : Mon Mar 28 08:43:12 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 8 18:46:23 202013 // Update Count : 8 612 // Last Modified On : Wed Mar 27 07:37:17 2019 13 // Update Count : 80 14 14 // 15 15 … … 19 19 #include <fstream.hfa> 20 20 21 typedef Rational(int) RatInt; 22 double convert( int i ) { return (double)i; } // used by narrow/widen 21 double convert( int i ) { return (double)i; } 23 22 int convert( double d ) { return (int)d; } 24 23 25 24 int main() { 26 25 sout | "constructor"; 27 Rat Int a = { 3 }, b = { 4 }, c, d = 0, e = 1;28 sout | a | b | c | d | e;26 Rational(int) a = { 3 }, b = { 4 }, c; 27 sout | a | b | c; 29 28 30 a = (Rat Int){ 4, 8 };31 b = (Rat Int){ 5, 7 };29 a = (Rational(int)){ 4, 8 }; 30 b = (Rational(int)){ 5, 7 }; 32 31 sout | a | b; 33 a = (Rat Int){ -2, -3 };34 b = (Rat Int){ 3, -2 };32 a = (Rational(int)){ -2, -3 }; 33 b = (Rational(int)){ 3, -2 }; 35 34 sout | a | b; 36 a = (Rat Int){ -2, 3 };37 b = (Rat Int){ 3, 2 };35 a = (Rational(int)){ -2, 3 }; 36 b = (Rational(int)){ 3, 2 }; 38 37 sout | a | b; 39 38 40 39 sout | "logical"; 41 a = (Rat Int){ -2 };42 b = (Rat Int){ -3, 2 };40 a = (Rational(int)){ -2 }; 41 b = (Rational(int)){ -3, 2 }; 43 42 sout | a | b; 44 43 // sout | a == 1; // FIX ME … … 59 58 60 59 sout | "conversion"; 61 a = (Rat Int){ 3, 4 };60 a = (Rational(int)){ 3, 4 }; 62 61 sout | widen( a ); 63 a = (Rat Int){ 1, 7 };62 a = (Rational(int)){ 1, 7 }; 64 63 sout | widen( a ); 65 a = (Rat Int){ 355, 113 };64 a = (Rational(int)){ 355, 113 }; 66 65 sout | widen( a ); 67 66 sout | narrow( 0.75, 4 ); … … 75 74 76 75 sout | "more tests"; 77 Rat Intx = { 1, 2 }, y = { 2 };76 Rational(int) x = { 1, 2 }, y = { 2 }; 78 77 sout | x - y; 79 78 sout | x > y; … … 81 80 sout | y | denominator( y, -2 ) | y; 82 81 83 Rat Intz = { 0, 5 };82 Rational(int) z = { 0, 5 }; 84 83 sout | z; 85 84 86 85 sout | x | numerator( x, 0 ) | x; 87 86 88 x = (Rat Int){ 1, MAX } + (RatInt){ 1, MAX };87 x = (Rational(int)){ 1, MAX } + (Rational(int)){ 1, MAX }; 89 88 sout | x; 90 x = (Rat Int){ 3, MAX } + (RatInt){ 2, MAX };89 x = (Rational(int)){ 3, MAX } + (Rational(int)){ 2, MAX }; 91 90 sout | x; 92 91 -
tests/references.cfa
r3d5701e r9fb8f01 119 119 f( 3, a + b, (S){ 1.0, 7.0 }, (int [3]){ 1, 2, 3 } ); // two rvalue to reference 120 120 } 121 122 {123 int a = 3;124 int *p = &a;125 asm (126 "incl %[p]\n\t"127 : [p] "+m" (*p)128 );129 printf("%d\n", a);130 }131 121 } 132 122 -
tests/test.py
r3d5701e r9fb8f01 10 10 import tempfile 11 11 import time 12 13 import os14 import psutil15 import signal16 12 17 13 ################################################################################ … … 147 143 # build, skipping to next test on error 148 144 with Timed() as comp_dur: 149 make_ret, _ = make( test.target(), output _file=subprocess.DEVNULL, error=out_file, error_file = err_file )145 make_ret, _ = make( test.target(), output=subprocess.DEVNULL, error=out_file, error_file = err_file ) 150 146 151 147 run_dur = None 152 148 # run everything in a temp directory to make sure core file are handled properly 153 149 with tempdir(): 154 # if the make command succe eds continue otherwise skip to diff150 # if the make command succeds continue otherwise skip to diff 155 151 if success(make_ret): 156 152 with Timed() as run_dur: 157 153 if settings.dry_run or is_exe(exe_file): 158 154 # run test 159 retcode, _ = sh(exe_file, output _file=out_file, input_file=in_file, timeout=True)155 retcode, _ = sh(exe_file, output=out_file, input=in_file, timeout=True) 160 156 else : 161 157 # simply cat the result into the output … … 214 210 except KeyboardInterrupt: 215 211 return False, "" 216 except Exception as ex:217 print("Unexpected error in worker thread : %s" % ex, file=sys.stderr)212 except: 213 print("Unexpected error in worker thread", file=sys.stderr) 218 214 sys.stderr.flush() 219 215 return False, "" … … 223 219 def run_tests(tests, jobs) : 224 220 # clean the sandbox from previous commands 225 make('clean', output_file=subprocess.DEVNULL, error=subprocess.DEVNULL) 226 227 # since python prints stacks by default on a interrupt, redo the interrupt handling to be silent 228 def worker_init(): 229 def sig_int(signal_num, frame): 230 pass 231 232 signal.signal(signal.SIGINT, sig_int) 221 make('clean', output=subprocess.DEVNULL, error=subprocess.DEVNULL) 233 222 234 223 # create the executor for our jobs and handle the signal properly 235 pool = multiprocessing.Pool(jobs , worker_init)224 pool = multiprocessing.Pool(jobs) 236 225 237 226 failed = False 238 239 def stop(x, y):240 print("Tests interrupted by user", file=sys.stderr)241 sys.exit(1)242 signal.signal(signal.SIGINT, stop)243 227 244 228 # for each test to run … … 276 260 277 261 # clean the workspace 278 make('clean', output _file=subprocess.DEVNULL, error=subprocess.DEVNULL)262 make('clean', output=subprocess.DEVNULL, error=subprocess.DEVNULL) 279 263 280 264 return 1 if failed else 0 -
tests/time.cfa
r3d5701e r9fb8f01 10 10 // Created On : Tue Mar 27 17:24:56 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Jan 5 18:27:37 202013 // Update Count : 3412 // Last Modified On : Thu Dec 20 23:09:21 2018 13 // Update Count : 23 14 14 // 15 15 … … 20 20 Duration d1 = 3`h, d2 = 2`s, d3 = 3.375`s, d4 = 12`s, d5 = 1`s + 10_000`ns; 21 21 sout | d1 | d2 | d3 | d4 | d5; 22 int i; 22 23 d1 = 0; 23 24 sout | d1 | d2 | d3; … … 34 35 sout | t; 35 36 t = t + d1; 36 sout | t | t `ns;37 sout | t | t.tv; 37 38 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];39 sout | t1 | t1.tv; 40 sout | t - t | t + d5 | t.tv; 41 char buf[16]; 41 42 sout | "yy/mm/dd" | [t, buf]`ymd | nonl; // shared buf => separate calls 42 43 sout | "mm/dd/yy" | mm_dd_yy( t, buf ) | nonl; … … 45 46 sout | "dd/yy/mm" | [t, buf]`dmy; 46 47 Time t2 = { 2001, 7, 4, 0, 0, 1, 0 }, t3 = (timeval){ 994_219_201 }; 47 sout | t2 | t2 `ns | nl | t3 | t3`ns;48 sout | t2 | t2.tv | nl | t3 | t3.tv; 48 49 sout | nl; 49 50 … … 62 63 sout | "Dividing that by 2 gives" | s / 2 | "seconds"; 63 64 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;74 65 } // main 75 66 -
tests/userLiterals.cfa
r3d5701e r9fb8f01 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // user Literals.cfa --7 // user_literals.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Wed Sep 6 21:40:50 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 19 07:48:45 202013 // Update Count : 7412 // Last Modified On : Tue Dec 4 22:03:10 2018 13 // Update Count : 56 14 14 // 15 15 … … 24 24 int ?`__thingy_( int x ) { sout | "_thingy_" | x; return x; } 25 25 26 int ?`s( const char * s ) { sout | "s " | s; return 0; }27 int ?`m( const char16_t * m ) { sout | "m " | m; return 0;}28 int ?`h( const char32_t * h ) { sout | "h " | h; return 0; }26 int ?`s( const char * s ) { sout | "secs" | s; return 0; } 27 int ?`m( const char16_t * m ) { sout | "mins" | m; return 0;} 28 int ?`h( const char32_t * h ) { sout | "hours" | h; return 0; } 29 29 int ?`_A_( const wchar_t * str ) { sout | "_A_" | str; return 0; } 30 30 int ?`__thingy_( const char * str ) { sout | "_thingy_" | str; return 0; } … … 37 37 return (Weight){ l.stones + r.stones }; 38 38 } 39 ofstream & ?|?( ofstream & os, Weight w ) { return os | wd(1,1, w.stones); } 40 void ?|?( ofstream & os, Weight w ) { (ofstream)(os | w); ends( os ); } 39 ofstream & ?|?( ofstream & os, Weight w ) { return os | w.stones; } 41 40 42 41 Weight ?`st( double w ) { return (Weight){ w }; } // backquote for user literals … … 61 60 sout | w; 62 61 63 0`s;62 // 0`secs; 64 63 1`s; 65 64 23`s; … … 83 82 84 83 "abc"`s; 85 // FIX ME: requires char16_t, char32_t, and wchar_t be unique types 86 // u"abc"`m; 87 // U_"abc"`h; 88 // L"abc"`_A_; 84 // u"abc"`m; 85 // U_"abc"`h; 86 // L"abc"`_A_; 89 87 u8_"abc"`__thingy_; 90 88 } // main … … 92 90 // Local Variables: // 93 91 // tab-width: 4 // 94 // compile-command: "cfa user Literals.cfa" //92 // compile-command: "cfa user_literals.cfa" // 95 93 // End: // -
tools/Makefile.in
r3d5701e r9fb8f01 208 208 CCDEPMODE = @CCDEPMODE@ 209 209 CFACC = @CFACC@ 210 CFACC_INSTALL = @CFACC_INSTALL@211 210 CFACPP = @CFACPP@ 212 211 CFA_BACKEND_CC = @CFA_BACKEND_CC@ … … 239 238 FGREP = @FGREP@ 240 239 GREP = @GREP@ 241 HAS_DISTCC = @HAS_DISTCC@242 240 HOST_FLAGS = @HOST_FLAGS@ 243 241 INSTALL = @INSTALL@ -
tools/catchsig.c
r3d5701e r9fb8f01 21 21 printf("Starting...\n"); 22 22 sig(SIGHUP); 23 sig(SIGINT);24 sig(SIGQUIT);25 sig(SIGILL);26 sig(SIGABRT);27 sig(SIGFPE);28 sig(SIGSEGV);29 sig(SIGPIPE);30 sig(SIGALRM);31 sig(SIGTERM);32 sig(SIGUSR1);33 sig(SIGUSR2);34 sig(SIGCHLD);35 sig(SIGCONT);36 sig(SIGTSTP);37 sig(SIGTTIN);38 sig(SIGTTOU);23 sig(SIGINT); 24 sig(SIGQUIT); 25 sig(SIGILL); 26 sig(SIGABRT); 27 sig(SIGFPE); 28 sig(SIGSEGV); 29 sig(SIGPIPE); 30 sig(SIGALRM); 31 sig(SIGTERM); 32 sig(SIGUSR1); 33 sig(SIGUSR2); 34 sig(SIGCHLD); 35 sig(SIGCONT); 36 sig(SIGTSTP); 37 sig(SIGTTIN); 38 sig(SIGTTOU); 39 39 while(1); 40 40 return 0; -
tools/prettyprinter/Makefile.in
r3d5701e r9fb8f01 237 237 CCDEPMODE = @CCDEPMODE@ 238 238 CFACC = @CFACC@ 239 CFACC_INSTALL = @CFACC_INSTALL@240 239 CFACPP = @CFACPP@ 241 240 CFA_BACKEND_CC = @CFA_BACKEND_CC@ … … 268 267 FGREP = @FGREP@ 269 268 GREP = @GREP@ 270 HAS_DISTCC = @HAS_DISTCC@271 269 HOST_FLAGS = @HOST_FLAGS@ 272 270 INSTALL = @INSTALL@ -
tools/stat.py
r3d5701e r9fb8f01 17 17 avg = numpy.mean (content) 18 18 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 ) 20 20 21 21
Note:
See TracChangeset
for help on using the changeset viewer.