Changeset b067d9b for tests


Ignore:
Timestamp:
Oct 29, 2019, 4:01:24 PM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
773db65, 9421f3d8
Parents:
7951100 (diff), 8364209 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
tests
Files:
95 added
207 moved

Legend:

Unmodified
Added
Removed
  • tests/.expect/ato.txt

    r7951100 rb067d9b  
    2222-123.456789012345679 -123.45678901234567890123456789
    2323-123.456-123.456i -123.456-123.456i
    24 0+0i 2  3
     240.+0.i 2  3
    2525-123.456789012346+123.456789012346i -123.4567890123456+123.4567890123456i
    2626123.456789012345679-123.456789012345679i 123.45678901234567890123456789-123.45678901234567890123456789i
  • tests/.expect/complex.txt

    r7951100 rb067d9b  
    11x:3+2i y:4+5i z:7+7i
    2 x:3+2i y:4+5i z:7+7i
     2x:3.+2.i y:4.+5.i z:7.+7.i
    33x:2.1+1.3i y:3.2+4.5i z:5.3+5.8i
    44x:2.1+1.3i y:3.2+4.5i z:5.3+5.8i
  • tests/.expect/identity.txt

    r7951100 rb067d9b  
    99double                  4.1
    1010long double             4.1
    11 float _Complex          -4.1-2i
    12 double _Complex         -4.1-2i
    13 long double _Complex    -4.1-2i
     11float _Complex          -4.1-2.i
     12double _Complex         -4.1-2.i
     13long double _Complex    -4.1-2.i
  • tests/.expect/io1.txt

    r7951100 rb067d9b  
    119 6 28 0 7 1 2
    2 1 2 3
    3 123
    4 123
     20 1 2 3
     30123
     40123
    55
    66opening delimiters
     
    88
    99closing delimiters
    10 1, x 2. x 3; x 4! x 5? x 6% x 7¢ x 8» x 9) x 10] x 11} x
     101, x 2. x 3; x 4! x 5? x 6% x 7 ¢ x 8 » x 9) x 10] x 11} x
    1111
    1212opening/closing delimiters
  • tests/.expect/math2.txt

    r7951100 rb067d9b  
    1 log:0 0 0 0.346574+0.785398i 0.346573590279973+0.785398163397448i 0.346573590279972655+0.78539816339744831i
    2 log2:3 3 3
    3 log10:2 2 2
     1log:0. 0. 0. 0.346574+0.785398i 0.346573590279973+0.785398163397448i 0.346573590279972655+0.78539816339744831i
     2log2:3. 3. 3.
     3log10:2. 2. 2.
    44log1p:0.693147 0.693147180559945 0.693147180559945309
    55ilogb:0 0 0
    6 logb:3 3 3
    7 sqrt:1 1 1 1.09868+0.45509i 1.09868411346781+0.455089860562227i 1.09868411346780997+0.455089860562227341i
    8 cbrt:3 3 3
     6logb:3. 3. 3.
     7sqrt:1. 1. 1. 1.09868+0.45509i 1.09868411346781+0.455089860562227i 1.09868411346780997+0.455089860562227341i
     8cbrt:3. 3. 3.
    99hypot:1.41421 1.4142135623731 1.41421356237309505
    1010sin:0.841471 0.841470984807897 0.841470984807896507 1.29846+0.634964i 1.29845758141598+0.634963914784736i 1.29845758141597729+0.634963914784736108i
     
    1212tan:1.55741 1.5574077246549 1.55740772465490223 0.271753+1.08392i 0.271752585319512+1.08392332733869i 0.271752585319511717+1.08392332733869454i
    1313asin:1.5708 1.5707963267949 1.57079632679489662 0.666239+1.06128i 0.666239432492515+1.06127506190504i 0.666239432492515255+1.06127506190503565i
    14 acos:0 0 0 0.904557-1.06128i 0.904556894302381-1.06127506190504i 0.904556894302381364-1.06127506190503565i
     14acos:0. 0. 0. 0.904557-1.06128i 0.904556894302381-1.06127506190504i 0.904556894302381364-1.06127506190503565i
    1515atan:0.785398 0.785398163397448 0.78539816339744831 1.01722+0.402359i 1.01722196789785+0.402359478108525i 1.01722196789785137+0.402359478108525094i
    1616atan2:0.785398 0.785398163397448 0.78539816339744831 atan:0.785398 0.785398163397448 0.78539816339744831
  • tests/.expect/math3.txt

    r7951100 rb067d9b  
    22cosh:1.54308 1.54308063481524 1.54308063481524378 0.83373+0.988898i 0.833730025131149+0.988897705762865i 0.833730025131149049+0.988897705762865096i
    33tanh:0.761594 0.761594155955765 0.761594155955764888 1.08392+0.271753i 1.08392332733869+0.271752585319512i 1.08392332733869454+0.271752585319511717i
    4 acosh:0 0 0 1.06128+0.904557i 1.06127506190504+0.904556894302381i 1.06127506190503565+0.904556894302381364i
     4acosh:0. 0. 0. 1.06128+0.904557i 1.06127506190504+0.904556894302381i 1.06127506190503565+0.904556894302381364i
    55asinh:0.881374 0.881373587019543 0.881373587019543025 1.06128+0.666239i 1.06127506190504+0.666239432492515i 1.06127506190503565+0.666239432492515255i
    66atanh:inf inf inf 0.402359+1.01722i 0.402359478108525+1.01722196789785i 0.402359478108525094+1.01722196789785137i
     
    99lgamma:1.79176 1.79175946922805 1.791759469228055
    1010lgamma:1.79176 1 1.79175946922805 1 1.791759469228055 1
    11 tgamma:6 6 6
     11tgamma:6. 6. 6.
  • tests/.expect/minmax.txt

    r7951100 rb067d9b  
    66signed long long int    4 3     min 3
    77unsigned long long int  4 3     min 3
    8 float                   4 3.1   min 3.1
    9 double                  4 3.1   min 3.1
    10 long double             4 3.1   min 3.1
     8float                   4. 3.1  min 3.1
     9double                  4. 3.1  min 3.1
     10long double             4. 3.1  min 3.1
    1111
    1212char                    z a     max z
     
    1717signed long long int    4 3     max 4
    1818unsigned long long int  4 3     max 4
    19 float                   4 3.1   max 4
    20 double                  4 3.1   max 4
    21 long double             4 3.1   max 4
     19float                   4. 3.1  max 4.
     20double                  4. 3.1  max 4.
     21long double             4. 3.1  max 4.
  • tests/.expect/references.txt

    r7951100 rb067d9b  
    35353
    36363
    37 3 9 { 1, 7 }, [1, 2, 3]
     373 9 { 1., 7. }, [1, 2, 3]
    3838Destructing a Y
    3939Destructing a Y
  • tests/.expect/sum.txt

    r7951100 rb067d9b  
     1sum from 5 to 15 is 95, check 95
     2sum from 5 to 15 is 95, check 95
    13sum from 5 to 15 is 95, check 95
    24sum from 5 to 15 is 95, check 95
  • tests/.expect/time.txt

    r7951100 rb067d9b  
    1 10800 2 3.07 12 1.00001
    2 0 2 3.07
     110800 2 3.375 12 1.00001
     20 2 3.375
    337 7 7
    4414
  • tests/.gitignore

    r7951100 rb067d9b  
    11.out/
    22.err/
     3.type
  • tests/KRfunctions.cfa

    r7951100 rb067d9b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // KRfunctions.c --
     7// KRfunctions.cfa --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Thu Feb 16 15:23:17 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Aug 20 07:34:17 2017
    13 // Update Count     : 7
     12// Last Modified On : Tue Nov  6 17:50:34 2018
     13// Update Count     : 9
    1414//
    1515
     
    4949// Local Variables: //
    5050// tab-width: 4 //
    51 // compile-command: "cfa KRfunctions.c" //
     51// compile-command: "cfa KRfunctions.cfa" //
    5252// End: //
  • tests/Makefile.in

    r7951100 rb067d9b  
    1717######################## -*- Mode: Makefile-Automake -*- ######################
    1818###############################################################################
    19 
    2019VPATH = @srcdir@
    2120am__is_gnu_make = { \
     
    9291build_triplet = @build@
    9392host_triplet = @host@
    94 noinst_PROGRAMS = fstream_test$(EXEEXT) vector_test$(EXEEXT) \
    95         avl_test$(EXEEXT) Bench$(EXEEXT)
    96 subdir = src/examples
     93EXTRA_PROGRAMS = avl_test$(EXEEXT) .dummy_hack$(EXEEXT)
     94subdir = tests
    9795ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    98 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
     96am__aclocal_m4_deps = $(top_srcdir)/automake/libtool.m4 \
     97        $(top_srcdir)/automake/ltoptions.m4 \
     98        $(top_srcdir)/automake/ltsugar.m4 \
     99        $(top_srcdir)/automake/ltversion.m4 \
     100        $(top_srcdir)/automake/lt~obsolete.m4 \
     101        $(top_srcdir)/automake/cfa.m4 $(top_srcdir)/configure.ac
    99102am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    100103        $(ACLOCAL_M4)
     
    102105mkinstalldirs = $(install_sh) -d
    103106CONFIG_HEADER = $(top_builddir)/config.h
    104 CONFIG_CLEAN_FILES =
    105 CONFIG_CLEAN_VPATH_FILES =
    106 PROGRAMS = $(noinst_PROGRAMS)
    107 Bench_SOURCES = Bench.c
    108 Bench_OBJECTS = Bench.$(OBJEXT)
    109 Bench_LDADD = $(LDADD)
     107CONFIG_CLEAN_FILES = config.py
     108CONFIG_CLEAN_VPATH_FILES = test.py
     109am__dummy_hack_OBJECTS = .dummy_hack.$(OBJEXT) .dummy_hackxx.$(OBJEXT)
     110_dummy_hack_OBJECTS = $(am__dummy_hack_OBJECTS)
     111_dummy_hack_LDADD = $(LDADD)
     112AM_V_lt = $(am__v_lt_@AM_V@)
     113am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
     114am__v_lt_0 = --silent
     115am__v_lt_1 =
    110116am__dirstamp = $(am__leading_dot)dirstamp
    111117am_avl_test_OBJECTS = avltree/avl_test.$(OBJEXT) \
     
    115121avl_test_OBJECTS = $(am_avl_test_OBJECTS)
    116122avl_test_LDADD = $(LDADD)
    117 am_fstream_test_OBJECTS = fstream_test.$(OBJEXT)
    118 fstream_test_OBJECTS = $(am_fstream_test_OBJECTS)
    119 fstream_test_LDADD = $(LDADD)
    120 am_vector_test_OBJECTS = vector_int.$(OBJEXT) array.$(OBJEXT) \
    121         vector_test.$(OBJEXT)
    122 vector_test_OBJECTS = $(am_vector_test_OBJECTS)
    123 vector_test_LDADD = $(LDADD)
    124123AM_V_P = $(am__v_P_@AM_V@)
    125124am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
     
    140139COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
    141140        $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
     141LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
     142        $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
     143        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
     144        $(AM_CFLAGS) $(CFLAGS)
    142145AM_V_CC = $(am__v_CC_@AM_V@)
    143146am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
     
    145148am__v_CC_1 =
    146149CCLD = $(CC)
    147 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
     150LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
     151        $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
     152        $(AM_LDFLAGS) $(LDFLAGS) -o $@
    148153AM_V_CCLD = $(am__v_CCLD_@AM_V@)
    149154am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
    150155am__v_CCLD_0 = @echo "  CCLD    " $@;
    151156am__v_CCLD_1 =
    152 SOURCES = Bench.c $(avl_test_SOURCES) $(fstream_test_SOURCES) \
    153         $(vector_test_SOURCES)
    154 DIST_SOURCES = Bench.c $(avl_test_SOURCES) $(fstream_test_SOURCES) \
    155         $(vector_test_SOURCES)
     157CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
     158        $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
     159LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
     160        $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
     161        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
     162        $(AM_CXXFLAGS) $(CXXFLAGS)
     163AM_V_CXX = $(am__v_CXX_@AM_V@)
     164am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
     165am__v_CXX_0 = @echo "  CXX     " $@;
     166am__v_CXX_1 =
     167CXXLD = $(CXX)
     168CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
     169        $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
     170        $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
     171AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
     172am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
     173am__v_CXXLD_0 = @echo "  CXXLD   " $@;
     174am__v_CXXLD_1 =
     175SOURCES = $(_dummy_hack_SOURCES) $(avl_test_SOURCES)
     176DIST_SOURCES = $(_dummy_hack_SOURCES) $(avl_test_SOURCES)
    156177am__can_run_installinfo = \
    157178  case $$AM_UPDATE_INFO_DIR in \
     
    178199ETAGS = etags
    179200CTAGS = ctags
    180 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/automake/depcomp
     201am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.py.in \
     202        $(srcdir)/test.py $(top_srcdir)/automake/depcomp \
     203        $(top_srcdir)/src/cfa.make
    181204DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
    182205ACLOCAL = @ACLOCAL@
    183 ALLOCA = @ALLOCA@
    184206AMTAR = @AMTAR@
    185207AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
     208AR = @AR@
    186209AUTOCONF = @AUTOCONF@
    187210AUTOHEADER = @AUTOHEADER@
    188211AUTOMAKE = @AUTOMAKE@
    189212AWK = @AWK@
    190 BACKEND_CC = @BACKEND_CC@
    191 CC = @CFA_BINDIR@/@CFA_NAME@
     213BUILD_IN_TREE_FLAGS = @BUILD_IN_TREE_FLAGS@
     214
     215# adjust CC to current flags
     216CC = $(if $(ifeq $(DISTCC_CFA_PATH),yes),distcc $(DISTCC_CFA_PATH),$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
    192217CCAS = @CCAS@
    193218CCASDEPMODE = @CCASDEPMODE@
    194219CCASFLAGS = @CCASFLAGS@
    195220CCDEPMODE = @CCDEPMODE@
     221CFACC = $(CC)
     222CFACC_INSTALL = @CFACC_INSTALL@
     223CFACPP = @CFACPP@
    196224CFA_BACKEND_CC = @CFA_BACKEND_CC@
    197225CFA_BINDIR = @CFA_BINDIR@
     
    201229CFA_NAME = @CFA_NAME@
    202230CFA_PREFIX = @CFA_PREFIX@
    203 
    204 # applies to both programs
    205 CFLAGS =
     231CFLAGS = @CFLAGS@
    206232CPP = @CPP@
    207233CPPFLAGS = @CPPFLAGS@
    208234CXX = @CXX@
     235CXXCPP = @CXXCPP@
    209236CXXDEPMODE = @CXXDEPMODE@
    210237CXXFLAGS = @CXXFLAGS@
    211238CYGPATH_W = @CYGPATH_W@
    212239DEFS = @DEFS@
     240DEMANGLER = @DEMANGLER@
    213241DEPDIR = @DEPDIR@
     242DLLTOOL = @DLLTOOL@
     243DRIVER_DIR = @DRIVER_DIR@
     244DSYMUTIL = @DSYMUTIL@
     245DUMPBIN = @DUMPBIN@
    214246ECHO_C = @ECHO_C@
    215247ECHO_N = @ECHO_N@
     
    217249EGREP = @EGREP@
    218250EXEEXT = @EXEEXT@
     251FGREP = @FGREP@
    219252GREP = @GREP@
     253HAS_DISTCC = @HAS_DISTCC@
     254HOST_FLAGS = @HOST_FLAGS@
    220255INSTALL = @INSTALL@
    221256INSTALL_DATA = @INSTALL_DATA@
     
    223258INSTALL_SCRIPT = @INSTALL_SCRIPT@
    224259INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
     260LD = @LD@
    225261LDFLAGS = @LDFLAGS@
    226262LEX = @LEX@
    227263LEXLIB = @LEXLIB@
    228264LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
     265LIBCFA_TARGET_DIRS = @LIBCFA_TARGET_DIRS@
     266LIBCFA_TARGET_MAKEFILES = @LIBCFA_TARGET_MAKEFILES@
     267LIBDEMANGLE = @LIBDEMANGLE@
    229268LIBOBJS = @LIBOBJS@
    230269LIBS = @LIBS@
     270LIBTOOL = @LIBTOOL@
     271LIPO = @LIPO@
     272LN_S = @LN_S@
    231273LTLIBOBJS = @LTLIBOBJS@
    232 MACHINE_TYPE = @MACHINE_TYPE@
    233 MAINT = @MAINT@
     274LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
    234275MAKEINFO = @MAKEINFO@
     276MANIFEST_TOOL = @MANIFEST_TOOL@
    235277MKDIR_P = @MKDIR_P@
     278NM = @NM@
     279NMEDIT = @NMEDIT@
     280OBJDUMP = @OBJDUMP@
    236281OBJEXT = @OBJEXT@
     282OTOOL = @OTOOL@
     283OTOOL64 = @OTOOL64@
    237284PACKAGE = @PACKAGE@
    238285PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
     
    244291PATH_SEPARATOR = @PATH_SEPARATOR@
    245292RANLIB = @RANLIB@
     293SED = @SED@
    246294SET_MAKE = @SET_MAKE@
    247295SHELL = @SHELL@
    248296STRIP = @STRIP@
     297TARGET_HOSTS = @TARGET_HOSTS@
    249298VERSION = @VERSION@
    250299YACC = @YACC@
     
    254303abs_top_builddir = @abs_top_builddir@
    255304abs_top_srcdir = @abs_top_srcdir@
     305ac_ct_AR = @ac_ct_AR@
    256306ac_ct_CC = @ac_ct_CC@
    257307ac_ct_CXX = @ac_ct_CXX@
     308ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
    258309am__include = @am__include@
    259310am__leading_dot = @am__leading_dot@
     
    302353top_builddir = @top_builddir@
    303354top_srcdir = @top_srcdir@
    304 AM_CFLAGS = -g -Wall -Wno-unused-function -O2
    305 fstream_test_SOURCES = fstream_test.c
    306 vector_test_SOURCES = vector_int.c array.c vector_test.c
    307 avl_test_SOURCES = avltree/avl_test.c avltree/avl0.c avltree/avl1.c avltree/avl2.c avltree/avl3.c avltree/avl4.c avltree/avl-private.c
     355AUTOMAKE_OPTIONS = foreign    # do not require all the GNU file names
     356ACLOCAL_AMFLAGS = -I automake
     357CFACOMPILE = $(CFACC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) $(AM_CFLAGS) $(CFLAGS)
     358LTCFACOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
     359        $(LIBTOOLFLAGS) --mode=compile $(CFACC) $(DEFS) \
     360        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) \
     361        $(AM_CFLAGS) $(CFLAGS)
     362
     363AM_V_CFA = $(am__v_CFA_@AM_V@)
     364am__v_CFA_ = $(am__v_CFA_@AM_DEFAULT_V@)
     365am__v_CFA_0 = @echo "  CFA     " $@;
     366am__v_CFA_1 =
     367AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
     368am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
     369am__v_JAVAC_0 = @echo "  JAVAC   " $@;
     370am__v_JAVAC_1 =
     371AM_V_GOC = $(am__v_GOC_@AM_V@)
     372am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)
     373am__v_GOC_0 = @echo "  GOC     " $@;
     374am__v_GOC_1 =
     375UPPCC = u++
     376UPPCOMPILE = $(UPPCC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_UPPFLAGS) $(UPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_CFLAGS) $(CFLAGS)
     377AM_V_UPP = $(am__v_UPP_@AM_V@)
     378am__v_UPP_ = $(am__v_UPP_@AM_DEFAULT_V@)
     379am__v_UPP_0 = @echo "  UPP     " $@;
     380am__v_UPP_1 =
     381debug = yes
     382installed = no
     383archiveerrors =
     384DEBUG_FLAGS = -debug -O0
     385quick_test = avl_test operators numericConstants expression enum array typeof cast raii/dtor-early-exit raii/init_once attributes
     386concurrent =
     387timeouts =
     388TEST_PY = python3 ${builddir}/test.py
     389
     390# applies to both programs
     391# since automake doesn't have support for CFA we have to
     392AM_CFLAGS = $(if $(test), 2> $(test), ) \
     393        -g \
     394        -Wall \
     395        -Wno-unused-function \
     396        -quiet @CFA_FLAGS@ \
     397        -DIN_DIR="${abs_srcdir}/.in/"
     398
     399
     400# get the desired cfa to test
     401TARGET_CFA = $(if $(filter $(installed),yes), @CFACC_INSTALL@, @CFACC@)
     402
     403# get local binary for depedencies
     404CFACCBIN = @CFACC@
     405
     406# adjusted CC but without the actual distcc call
     407CFACCLOCAL = $(if $(DISTCC_CFA_PATH),$(DISTCC_CFA_PATH),$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
     408PRETTY_PATH = mkdir -p $(dir $(abspath ${@})) && cd ${srcdir} &&
     409avl_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
     410# automake doesn't know we still need C/CPP rules so pretend like we have a C program
     411_dummy_hack_SOURCES = .dummy_hack.c .dummy_hackxx.cpp
     412
     413#----------------------------------------------------------------------------------------------------------------
     414
     415# Use for all tests, make sure the path are correct and all flags are added
     416CFACOMPILETEST = $(PRETTY_PATH) $(CFACOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) $($(shell echo "${@}_FLAGSCFA" | sed 's/-\|\//_/g'))
     417
     418#------------------------------------------------------------------------------
     419# TARGETS WITH CUSTOM FLAGS
     420#------------------------------------------------------------------------------
     421# custom libs
     422gmp_FLAGSLD = -lgmp
     423
     424#------------------------------------------------------------------------------
     425# Generated code
     426GENERATED_CODE = declarationSpecifier gccExtensions extension attributes functions KRfunctions
     427
     428# Use for tests where the make command is expected to succeed but the expected.txt should be compared to stderr
     429EXPECT_STDERR = builtins/sync warnings/self-assignment
    308430all: all-am
    309431
    310432.SUFFIXES:
    311 .SUFFIXES: .c .o .obj
    312 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
     433.SUFFIXES: .c .cfa .cpp .dummy_hack .dummy_hackxx .lo .o .obj .validate
     434$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am $(top_srcdir)/src/cfa.make $(am__configure_deps)
    313435        @for dep in $?; do \
    314436          case '$(am__configure_deps)' in \
     
    319441          esac; \
    320442        done; \
    321         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/examples/Makefile'; \
     443        echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/Makefile'; \
    322444        $(am__cd) $(top_srcdir) && \
    323           $(AUTOMAKE) --foreign src/examples/Makefile
     445          $(AUTOMAKE) --foreign tests/Makefile
    324446Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
    325447        @case '$?' in \
     
    330452            cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
    331453        esac;
     454$(top_srcdir)/src/cfa.make $(am__empty):
    332455
    333456$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
    334457        cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
    335458
    336 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
     459$(top_srcdir)/configure: $(am__configure_deps)
    337460        cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
    338 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
     461$(ACLOCAL_M4): $(am__aclocal_m4_deps)
    339462        cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
    340463$(am__aclocal_m4_deps):
    341 
    342 clean-noinstPROGRAMS:
    343         -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
     464config.py: $(top_builddir)/config.status $(srcdir)/config.py.in
     465        cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
     466
     467.dummy_hack$(EXEEXT): $(_dummy_hack_OBJECTS) $(_dummy_hack_DEPENDENCIES) $(EXTRA__dummy_hack_DEPENDENCIES)
     468        @rm -f .dummy_hack$(EXEEXT)
     469        $(AM_V_CXXLD)$(CXXLINK) $(_dummy_hack_OBJECTS) $(_dummy_hack_LDADD) $(LIBS)
    344470avltree/$(am__dirstamp):
    345471        @$(MKDIR_P) avltree
     
    367493        $(AM_V_CCLD)$(LINK) $(avl_test_OBJECTS) $(avl_test_LDADD) $(LIBS)
    368494
    369 fstream_test$(EXEEXT): $(fstream_test_OBJECTS) $(fstream_test_DEPENDENCIES) $(EXTRA_fstream_test_DEPENDENCIES)
    370         @rm -f fstream_test$(EXEEXT)
    371         $(AM_V_CCLD)$(LINK) $(fstream_test_OBJECTS) $(fstream_test_LDADD) $(LIBS)
    372 
    373 vector_test$(EXEEXT): $(vector_test_OBJECTS) $(vector_test_DEPENDENCIES) $(EXTRA_vector_test_DEPENDENCIES)
    374         @rm -f vector_test$(EXEEXT)
    375         $(AM_V_CCLD)$(LINK) $(vector_test_OBJECTS) $(vector_test_LDADD) $(LIBS)
    376 
    377495mostlyclean-compile:
    378496        -rm -f *.$(OBJEXT)
     
    382500        -rm -f *.tab.c
    383501
    384 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Bench.Po@am__quote@
    385 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/array.Po@am__quote@
    386 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstream_test.Po@am__quote@
    387 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vector_int.Po@am__quote@
    388 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vector_test.Po@am__quote@
    389 @AMDEP_TRUE@@am__include@ @am__quote@avltree/$(DEPDIR)/avl-private.Po@am__quote@
    390 @AMDEP_TRUE@@am__include@ @am__quote@avltree/$(DEPDIR)/avl0.Po@am__quote@
    391 @AMDEP_TRUE@@am__include@ @am__quote@avltree/$(DEPDIR)/avl1.Po@am__quote@
    392 @AMDEP_TRUE@@am__include@ @am__quote@avltree/$(DEPDIR)/avl2.Po@am__quote@
    393 @AMDEP_TRUE@@am__include@ @am__quote@avltree/$(DEPDIR)/avl3.Po@am__quote@
    394 @AMDEP_TRUE@@am__include@ @am__quote@avltree/$(DEPDIR)/avl4.Po@am__quote@
    395 @AMDEP_TRUE@@am__include@ @am__quote@avltree/$(DEPDIR)/avl_test.Po@am__quote@
     502@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/.dummy_hack.Po@am__quote@
     503@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/.dummy_hackxx.Po@am__quote@
    396504
    397505.c.o:
     
    410518@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    411519@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
     520
     521.c.lo:
     522@am__fastdepCC_TRUE@    $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
     523@am__fastdepCC_TRUE@    $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
     524@am__fastdepCC_TRUE@    $(am__mv) $$depbase.Tpo $$depbase.Plo
     525@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
     526@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     527@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
     528
     529.cpp.o:
     530@am__fastdepCXX_TRUE@   $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
     531@am__fastdepCXX_TRUE@   $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
     532@am__fastdepCXX_TRUE@   $(am__mv) $$depbase.Tpo $$depbase.Po
     533@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
     534@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     535@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $<
     536
     537.cpp.obj:
     538@am__fastdepCXX_TRUE@   $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
     539@am__fastdepCXX_TRUE@   $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
     540@am__fastdepCXX_TRUE@   $(am__mv) $$depbase.Tpo $$depbase.Po
     541@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
     542@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     543@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
     544
     545.cpp.lo:
     546@am__fastdepCXX_TRUE@   $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
     547@am__fastdepCXX_TRUE@   $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
     548@am__fastdepCXX_TRUE@   $(am__mv) $$depbase.Tpo $$depbase.Plo
     549@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
     550@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     551@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
     552
     553mostlyclean-libtool:
     554        -rm -f *.lo
     555
     556clean-libtool:
     557        -rm -rf .libs _libs
    412558
    413559ID: $(am__tagged_files)
     
    495641check-am: all-am
    496642check: check-am
    497 all-am: Makefile $(PROGRAMS)
     643all-am: Makefile all-local
    498644installdirs:
    499645install: install-am
     
    531677clean: clean-am
    532678
    533 clean-am: clean-generic clean-noinstPROGRAMS mostlyclean-am
     679clean-am: clean-generic clean-libtool clean-local mostlyclean-am
    534680
    535681distclean: distclean-am
    536         -rm -rf ./$(DEPDIR) avltree/$(DEPDIR)
     682        -rm -rf ./$(DEPDIR)
    537683        -rm -f Makefile
    538684distclean-am: clean-am distclean-compile distclean-generic \
     
    580726
    581727maintainer-clean: maintainer-clean-am
    582         -rm -rf ./$(DEPDIR) avltree/$(DEPDIR)
     728        -rm -rf ./$(DEPDIR)
    583729        -rm -f Makefile
    584730maintainer-clean-am: distclean-am maintainer-clean-generic
     
    586732mostlyclean: mostlyclean-am
    587733
    588 mostlyclean-am: mostlyclean-compile mostlyclean-generic
     734mostlyclean-am: mostlyclean-compile mostlyclean-generic \
     735        mostlyclean-libtool
    589736
    590737pdf: pdf-am
     
    600747.MAKE: install-am install-strip
    601748
    602 .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
    603         clean-noinstPROGRAMS cscopelist-am ctags ctags-am distclean \
    604         distclean-compile distclean-generic distclean-tags distdir dvi \
    605         dvi-am html html-am info info-am install install-am \
    606         install-data install-data-am install-dvi install-dvi-am \
    607         install-exec install-exec-am install-html install-html-am \
    608         install-info install-info-am install-man install-pdf \
    609         install-pdf-am install-ps install-ps-am install-strip \
    610         installcheck installcheck-am installdirs maintainer-clean \
     749.PHONY: CTAGS GTAGS TAGS all all-am all-local check check-am clean \
     750        clean-generic clean-libtool clean-local cscopelist-am ctags \
     751        ctags-am distclean distclean-compile distclean-generic \
     752        distclean-libtool distclean-tags distdir dvi dvi-am html \
     753        html-am info info-am install install-am install-data \
     754        install-data-am install-dvi install-dvi-am install-exec \
     755        install-exec-am install-html install-html-am install-info \
     756        install-info-am install-man install-pdf install-pdf-am \
     757        install-ps install-ps-am install-strip installcheck \
     758        installcheck-am installdirs maintainer-clean \
    611759        maintainer-clean-generic mostlyclean mostlyclean-compile \
    612         mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \
    613         uninstall-am
     760        mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
     761        tags tags-am uninstall uninstall-am
    614762
    615763.PRECIOUS: Makefile
    616764
    617765
    618 Bench : Bench.c
    619         @for ccflags in "-debug" "-nodebug"; do \
    620                 echo ${CC} ${AM_CFLAGS} ${CFLAGS} $${ccflags} -lrt Bench.c;\
    621                 ${CC} ${AM_CFLAGS} ${CFLAGS} $${ccflags} -lrt Bench.c;\
    622                 ./a.out ; \
    623         done ; \
    624         rm -f ./a.out ;
     766.cfa.o:
     767        $(AM_V_CFA)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
     768        $(CFACOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
     769        $(am__mv) $$depbase.Tpo $$depbase.Po
     770
     771.cfa.lo:
     772        $(AM_V_CFA)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
     773        $(LTCFACOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
     774        $(am__mv) $$depbase.Tpo $$depbase.Plo
     775
     776.PHONY: list .validate
     777.INTERMEDIATE: .validate .validate.cfa
     778
     779#----------------------------------------------------------------------------------------------------------------
     780all-local :
     781        @+${TEST_PY} --debug=${debug} --install=${installed} --archive-errors=${archiveerrors} ${concurrent} ${timeouts} ${quick_test}
     782
     783all-tests :
     784        @+${TEST_PY} --debug=${debug} --install=${installed} --archive-errors=${archiveerrors} ${concurrent} ${timeouts} --all # '@' => do not echo command (SILENT), '+' => allows recursive make from within python program
     785
     786clean-local :
     787        rm -f ${EXTRA_PROGRAMS}
     788
     789list :
     790        @+${TEST_PY} --list ${concurrent}
     791
     792.validate: .validate.cfa
     793        $(CFACOMPILE) .validate.cfa -fsyntax-only -Wall -Wextra -Werror
     794
     795.validate.cfa:
     796        @echo "int main() { return 0; }" > ${@}
     797
     798# automake doesn't know we still need C rules so pretend like we have a C program
     799.dummy_hack.c:
     800        @echo "int main() { return 0; }" > ${@}
     801
     802.dummy_hackxx.cpp:
     803        @echo "int bar() { return 0; }" > ${@}
     804
     805concurrency :
     806        @+${TEST_PY} --debug=${debug}  --install=${installed} -Iconcurrent
     807
     808#----------------------------------------------------------------------------------------------------------------
     809
     810# implicit rule so not all test require a rule
     811# split into two steps to support compiling remotely using distcc
     812# don't use distcc to do the linking because distcc doesn't do linking
     813% : %.cfa $(CFACCBIN)
     814        $(CFACOMPILETEST) -c -o $(abspath ${@}).o
     815        $(CFACCLOCAL) $($(shell echo "${@}_FLAGSLD" | sed 's/-\|\//_/g')) $(abspath ${@}).o -o $(abspath ${@})
     816
     817# implicit rule for c++ test
     818# convient for testing the testsuite itself but not actuall used
     819% : %.cpp
     820        $(PRETTY_PATH) $(CXXCOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
     821$(GENERATED_CODE): % : %.cfa $(CFACCBIN)
     822        $(CFACOMPILETEST) -CFA -XCFA -p -c -fsyntax-only -o $(abspath ${@})
     823$(EXPECT_STDERR): % : %.cfa $(CFACCBIN)
     824        $(CFACOMPILETEST) -c -fsyntax-only 2> $(abspath ${@})
     825
     826#------------------------------------------------------------------------------
     827# CUSTOM TARGET
     828#------------------------------------------------------------------------------
     829# expected failures
     830# use custom target since they require a custom define and custom dependencies
     831alloc-ERROR : alloc.cfa $(CFACCBIN)
     832        $(CFACOMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@})
     833
     834typedefRedef-ERR1 : typedefRedef.cfa $(CFACCBIN)
     835        $(CFACOMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@})
     836
     837nested-types-ERR1 : nested-types.cfa $(CFACCBIN)
     838        $(CFACOMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@})
     839
     840nested-types-ERR2 : nested-types.cfa $(CFACCBIN)
     841        $(CFACOMPILETEST) -DERR2 -c -fsyntax-only -o $(abspath ${@})
     842
     843raii/memberCtors-ERR1 : raii/memberCtors.cfa $(CFACCBIN)
     844        $(CFACOMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@})
     845
     846raii/ctor-autogen-ERR1 : raii/ctor-autogen.cfa $(CFACCBIN)
     847        $(CFACOMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@})
     848
     849raii/dtor-early-exit-ERR1 : raii/dtor-early-exit.cfa $(CFACCBIN)
     850        $(CFACOMPILETEST) -DERR1 -c -fsyntax-only -o $(abspath ${@})
     851
     852raii/dtor-early-exit-ERR2 : raii/dtor-early-exit.cfa $(CFACCBIN)
     853        $(CFACOMPILETEST) -DERR2 -c -fsyntax-only -o $(abspath ${@})
     854
     855#------------------------------------------------------------------------------
     856# Other targets
    625857
    626858# Tell versions [3.59,3.63) of GNU make to not export all variables.
  • tests/abs.cfa

    r7951100 rb067d9b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // abs.c --
     7// abs.cfa --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Thu Jan 28 18:26:16 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Feb 22 22:31:03 2017
    13 // Update Count     : 52
     12// Last Modified On : Tue Dec  4 21:33:15 2018
     13// Update Count     : 55
    1414//
    1515
    16 #include <fstream>
    17 #include <stdlib>                                                                               // abs
     16#include <fstream.hfa>
     17#include <stdlib.hfa>                                                                           // abs
    1818
    1919int main( void ) {
    2020        signed char ch = -65;
    21         sout | "char\t\t\t"                                     | ch     | "\tabs " | abs( ch ) | endl;
    22         sout | "signed int\t\t"                         | -65    | "\tabs" | abs( -65 ) | endl;
    23         sout | "signed long int\t\t"            | -65l   | "\tabs" | abs( -65l ) | endl;
    24         sout | "signed long long int\t"         | -65ll  | "\tabs" | abs( -65ll ) | endl;
    25         sout | "float\t\t\t"                            | -65.0f | "\tabs" | abs( -65.0f ) | endl;
    26         sout | "double\t\t\t"                           | -65.0  | "\tabs" | abs( -65.0 ) | endl;
    27         sout | "long double\t\t"                        | -65.0l | "\tabs" | abs( -65.0l ) | endl;
    28         sout | "float _Complex\t\t"                     | -65.0F-2.0iF | "\tabs" | abs( -65.0F-2.0iF ) | endl;
    29         sout | "double _Complex\t\t"            | -65.0D-2.0iD | "\tabs" | abs( -65.0D-2.0iD ) | endl;
    30         sout | "long double _Complex\t"         | -65.0L-2.0iL | "\tabs" | abs( -65.0L-2.0iL ) | endl;
     21        sout | "char\t\t\t"                                     | ch     | "\tabs " | abs( ch );
     22        sout | "signed int\t\t"                         | -65    | "\tabs" | abs( -65 );
     23        sout | "signed long int\t\t"            | -65l   | "\tabs" | abs( -65l );
     24        sout | "signed long long int\t"         | -65ll  | "\tabs" | abs( -65ll );
     25        sout | "float\t\t\t"                            | -65.0f | "\tabs" | abs( -65.0f );
     26        sout | "double\t\t\t"                           | -65.0  | "\tabs" | abs( -65.0 );
     27        sout | "long double\t\t"                        | -65.0l | "\tabs" | abs( -65.0l );
     28        sout | "float _Complex\t\t"                     | -65.0F-2.0iF | "\tabs" | abs( -65.0F-2.0iF );
     29        sout | "double _Complex\t\t"            | -65.0D-2.0iD | "\tabs" | abs( -65.0D-2.0iD );
     30        sout | "long double _Complex\t"         | -65.0L-2.0iL | "\tabs" | abs( -65.0L-2.0iL );
    3131} // main
    3232
    3333// Local Variables: //
    3434// tab-width: 4 //
    35 // compile-command: "cfa abs.c" //
     35// compile-command: "cfa abs.cfa" //
    3636// End: //
  • tests/alloc.cfa

    r7951100 rb067d9b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // alloc.c --
     7// alloc.cfa --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Wed Feb  3 07:56:22 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Feb 16 15:42:31 2018
    13 // Update Count     : 330
     12// Last Modified On : Sun Oct 20 21:45:21 2019
     13// Update Count     : 391
    1414//
    1515
     
    1818#include <stdint.h>                                                                             // uintptr_t
    1919#include <stdlib.h>                                                                             // posix_memalign
    20 #include <fstream>
    21 #include <stdlib>                                                                               // access C malloc, realloc
     20#include <fstream.hfa>
     21#include <stdlib.hfa>                                                                   // access C malloc, realloc
    2222
    2323int * foo( int * p, int c ) { return p; }
     
    2727int main( void ) {
    2828        size_t dim = 10;
    29         char fill = '\xff';
    30         int * p;
     29        char fill = '\xde';
     30        int * p, * p1;
    3131
    3232        // allocation, non-array types
    33 
    34         // int & r = malloc();
    35         // r = 0xdeadbeef;
    36         // printf( "C   malloc %#x\n", r );
    37         // free( &r );
    3833
    3934        p = (int *)malloc( sizeof(*p) );                                        // C malloc, type unsafe
     
    5247        free( p );
    5348
    54         p = alloc( fill );                                  // CFA alloc, fill
     49        p = alloc_set( fill );                                                          // CFA alloc, fill
     50        printf( "CFA array alloc, fill %#hhx\n", fill );
    5551        printf( "CFA alloc, fill %08x\n", *p );
     52        free( p );
     53
     54        p = alloc_set( 3 );                                                                     // CFA alloc, fill
     55        printf( "CFA alloc, fill %d\n", *p );
     56        free( p );
    5657
    5758
     
    6162        p = (int *)calloc( dim, sizeof( *p ) );                         // C array calloc, type unsafe
    6263        printf( "C   array calloc, fill 0\n" );
    63         for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); }
     64        for ( i; dim ) { printf( "%#x ", p[i] ); }
    6465        printf( "\n" );
    6566        free( p );
     
    6768        p = calloc( dim );                                  // CFA array calloc, type safe
    6869        printf( "CFA array calloc, fill 0\n" );
    69         for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); }
     70        for ( i; dim ) { printf( "%#x ", p[i] ); }
    7071        printf( "\n" );
    7172        free( p );
    7273
    7374        p = alloc( dim );                                   // CFA array alloc, type safe
    74         for ( int i = 0; i < dim; i += 1 ) { p[i] = 0xdeadbeef; }
     75        for ( i; dim ) { p[i] = 0xdeadbeef; }
    7576        printf( "CFA array alloc, no fill\n" );
    76         for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); }
    77         printf( "\n" );
    78         free( p );
    79 
    80         p = alloc( 2 * dim, fill );                         // CFA array alloc, fill
     77        for ( i; dim ) { printf( "%#x ", p[i] ); }
     78        printf( "\n" );
     79        free( p );
     80
     81        p = alloc_set( 2 * dim, fill );                                         // CFA array alloc, fill
    8182        printf( "CFA array alloc, fill %#hhx\n", fill );
    82         for ( int i = 0; i < 2 * dim; i += 1 ) { printf( "%#x ", p[i] ); }
    83         printf( "\n" );
    84         // do not free
     83        for ( i; 2 * dim ) { printf( "%#x ", p[i] ); }
     84        printf( "\n" );
     85        free( p );
     86
     87        p = alloc_set( 2 * dim, 0xdeadbeef );                           // CFA array alloc, fill
     88        printf( "CFA array alloc, fill %#hhx\n", 0xdeadbeef );
     89        for ( i; 2 * dim ) { printf( "%#x ", p[i] ); }
     90        printf( "\n" );
     91        // do not free
     92
     93        p1 = alloc_set( 2 * dim, p );                                           // CFA array alloc, fill
     94        printf( "CFA array alloc, fill from array\n" );
     95        for ( i; 2 * dim ) { printf( "%#x %#x, ", p[i], p1[i] ); }
     96        free( p1 );
     97        printf( "\n" );
    8598
    8699
     
    89102
    90103        p = (int *)realloc( p, dim * sizeof(*p) );                      // C realloc
    91         for ( int i = 0; i < dim; i += 1 ) { p[i] = 0xdeadbeef; }
    92         printf( "C   realloc\n" );
    93         for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); }
    94         printf( "\n" );
     104        printf( "C realloc\n" );
     105        for ( i; dim ) { printf( "%#x ", p[i] ); }
     106        printf( "\n" );
     107        // do not free
    95108
    96109        p = realloc( p, 2 * dim * sizeof(*p) );             // CFA realloc
    97         for ( int i = dim; i < 2 * dim; i += 1 ) { p[i] = 0x1010101; }
     110        for ( i; dim ~ 2 * dim ) { p[i] = 0x1010101; }
    98111        printf( "CFA realloc\n" );
    99         for ( int i = 0; i < 2 * dim; i += 1 ) { printf( "%#x ", p[i] ); }
     112        for ( i; 2 * dim ) { printf( "%#x ", p[i] ); }
    100113        printf( "\n" );
    101114        // do not free
     
    106119
    107120        p = alloc( p, dim );                                // CFA resize array alloc
    108         for ( int i = 0; i < dim; i += 1 ) { p[i] = 0xdeadbeef; }
    109         printf( "CFA resize alloc\n" );
    110         for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); }
    111         printf( "\n" );
     121        for ( i; dim ) { p[i] = 0xdeadbeef; }
     122        printf( "CFA resize array alloc\n" );
     123        for ( i; dim ) { printf( "%#x ", p[i] ); }
     124        printf( "\n" );
     125        // do not free
    112126
    113127        p = alloc( p, 2 * dim );                            // CFA resize array alloc
    114         for ( int i = dim; i < 2 * dim; i += 1 ) { p[i] = 0x1010101; }
     128        for ( i; dim ~ 2 * dim ) { p[i] = 0x1010101; }
    115129        printf( "CFA resize array alloc\n" );
    116         for ( int i = 0; i < 2 * dim; i += 1 ) { printf( "%#x ", p[i] ); }
    117         printf( "\n" );
    118 
    119         p = alloc( p, dim );                                // CFA array alloc
     130        for ( i; 2 * dim ) { printf( "%#x ", p[i] ); }
     131        printf( "\n" );
     132        // do not free
     133
     134        p = alloc( p, dim );                                // CFA resize array alloc
    120135        printf( "CFA resize array alloc\n" );
    121         for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); }
    122         printf( "\n" );
    123 
    124         free( p );
    125         p = 0;
    126 
    127         p = alloc( p, dim, fill );                          // CFA array alloc, fill
     136        for ( i; dim ) { printf( "%#x ", p[i] ); }
     137        printf( "\n" );
     138        // do not free
     139
     140        p = alloc_set( p, 3 * dim, fill );                                      // CFA resize array alloc, fill
    128141        printf( "CFA resize array alloc, fill\n" );
    129         for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); }
    130         printf( "\n" );
    131 
    132         p = alloc( p, 2 * dim, fill );                      // CFA array alloc, fill
     142        for ( i; 3 * dim ) { printf( "%#x ", p[i] ); }
     143        printf( "\n" );
     144        // do not free
     145
     146        p = alloc_set( p, dim, fill );                                          // CFA resize array alloc, fill
    133147        printf( "CFA resize array alloc, fill\n" );
    134         for ( int i = 0; i < 2 * dim; i += 1 ) { printf( "%#x ", p[i] ); }
    135         printf( "\n" );
    136 
    137         p = alloc( p, dim, fill );                          // CFA array alloc, fill
     148        for ( i; dim ) { printf( "%#x ", p[i] ); }
     149        printf( "\n" );
     150        // do not free
     151
     152        p = alloc_set( p, 3 * dim, fill );                                      // CFA resize array alloc, fill
    138153        printf( "CFA resize array alloc, fill\n" );
    139         for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] );; }
     154        for ( i; 3 * dim ) { printf( "%#x ", p[i] );; }
    140155        printf( "\n" );
    141156        free( p );
     
    171186        free( stp );
    172187
    173         stp = &(*aligned_alloc( Alignment )){ 42, 42.5 };     // CFA aligned_alloc
    174         assert( (uintptr_t)stp % Alignment == 0 );
    175         printf( "CFA aligned_alloc %d %g\n", stp->x, stp->y );
    176         free( stp );
    177 
    178         stp = &(*align_alloc( Alignment )){ 42, 42.5 };       // CFA align_alloc
    179         assert( (uintptr_t)stp % Alignment == 0 );
    180         printf( "CFA align_alloc %d %g\n", stp->x, stp->y );
    181         free( stp );
    182 
    183         stp = align_alloc( Alignment, fill );               // CFA memalign, fill
    184         assert( (uintptr_t)stp % Alignment == 0 );
    185         printf( "CFA align_alloc fill %#x %a\n", stp->x, stp->y );
     188        stp = &(*alloc_align( Alignment)){ 42, 42.5 };          // CFA alloc_align
     189        assert( (uintptr_t)stp % Alignment == 0 );
     190        printf( "CFA alloc_align %d %g\n", stp->x, stp->y );
     191        free( stp );
     192
     193        stp = &(*alloc_align( Alignment )){ 42, 42.5 };         // CFA alloc_align
     194        assert( (uintptr_t)stp % Alignment == 0 );
     195        printf( "CFA alloc_align %d %g\n", stp->x, stp->y );
     196        free( stp );
     197
     198        stp = alloc_align_set( Alignment, fill );                       // CFA memalign, fill
     199        assert( (uintptr_t)stp % Alignment == 0 );
     200        printf( "CFA alloc_align fill %#x %a\n", stp->x, stp->y );
     201        free( stp );
     202
     203        stp = alloc_align_set( Alignment, (Struct){ 42, 42.5 } ); // CFA memalign, fill
     204        assert( (uintptr_t)stp % Alignment == 0 );
     205        printf( "CFA alloc_align fill %d %g\n", stp->x, stp->y );
     206        // do not free
     207
     208        stp = &(*alloc_align( stp, 4096 )){ 42, 42.5 };         // CFA realign
     209        assert( (uintptr_t)stp % 4096 == 0 );
     210        printf( "CFA alloc_align %d %g\n", stp->x, stp->y );
    186211        free( stp );
    187212
     
    190215        printf( "\n" );
    191216
    192         stp = align_alloc( Alignment, dim );                // CFA array memalign
    193         assert( (uintptr_t)stp % Alignment == 0 );
    194         for ( int i = 0; i < dim; i += 1 ) { stp[i] = (Struct){ 42, 42.5 }; }
    195         printf( "CFA array align_alloc\n" );
    196         for ( int i = 0; i < dim; i += 1 ) { printf( "%d %g, ", stp[i].x, stp[i].y ); }
    197         printf( "\n" );
    198         free( stp );
    199 
    200         stp = align_alloc( Alignment, dim, fill );          // CFA array memalign, fill
    201         assert( (uintptr_t)stp % Alignment == 0 );
    202         printf( "CFA array align_alloc, fill\n" );
    203         for ( int i = 0; i < dim; i += 1 ) { printf( "%#x %a, ", stp[i].x, stp[i].y ); }
     217        stp = alloc_align( Alignment, dim );                // CFA array memalign
     218        assert( (uintptr_t)stp % Alignment == 0 );
     219        for ( i; dim ) { stp[i] = (Struct){ 42, 42.5 }; }
     220        printf( "CFA array alloc_align\n" );
     221        for ( i; dim ) { printf( "%d %g, ", stp[i].x, stp[i].y ); }
     222        printf( "\n" );
     223        free( stp );
     224
     225        stp = alloc_align_set( Alignment, dim, fill );          // CFA array memalign, fill
     226        assert( (uintptr_t)stp % Alignment == 0 );
     227        printf( "CFA array alloc_align, fill\n" );
     228        for ( i; dim ) { printf( "%#x %a, ", stp[i].x, stp[i].y ); }
     229        printf( "\n" );
     230        free( stp );
     231
     232        stp = alloc_align_set( Alignment, dim, (Struct){ 42, 42.5 } ); // CFA array memalign, fill
     233        assert( (uintptr_t)stp % Alignment == 0 );
     234        printf( "CFA array alloc_align, fill\n" );
     235        for ( i; dim ) { printf( "%d %g, ", stp[i].x, stp[i].y ); }
     236        printf( "\n" );
     237        // do not free
     238
     239        stp1 = alloc_align_set( Alignment, dim, stp );          // CFA array memalign, fill
     240        assert( (uintptr_t)stp % Alignment == 0 );
     241        printf( "CFA array alloc_align, fill array\n" );
     242        for ( i; dim ) { printf( "%d %g, ", stp1[i].x, stp1[i].y ); }
     243        printf( "\n" );
     244        free( stp1 );
     245
     246        stp = alloc_align( stp, 4096, dim );                            // CFA aligned realloc array
     247        assert( (uintptr_t)stp % 4096 == 0 );
     248        for ( i; dim ) { stp[i] = (Struct){ 42, 42.5 }; }
     249        printf( "CFA realloc array alloc_align\n" );
     250        for ( i; dim ) { printf( "%d %g, ", stp[i].x, stp[i].y ); }
    204251        printf( "\n" );
    205252        free( stp );
     
    218265        printf( "\n" );
    219266
    220         memset( sta, dim, fill );                           // CFA array memset, type safe
     267        amemset( sta, fill, dim );                                                      // CFA array memset, type safe
    221268        printf( "CFA array memset\n" );
    222         for ( int i = 0; i < dim; i += 1 ) { printf( "%#x %a, ", sta[i].x, sta[i].y ); }
    223         printf( "\n" );
    224 
    225         memcpy( sta1, sta, dim );                           // CFA array memcpy, type safe
    226         printf( "CFA memcpy\n" );
    227         for ( int i = 0; i < dim; i += 1 ) { printf( "%#x %a, ", sta1[i].x, sta1[i].y ); }
     269        for ( i; dim ) { printf( "%#x %a, ", sta[i].x, sta[i].y ); }
     270        printf( "\n" );
     271
     272        amemcpy( sta1, sta, dim );                                                      // CFA array memcpy, type safe
     273        printf( "CFA array memcpy\n" );
     274        for ( i; dim ) { printf( "%#x %a, ", sta1[i].x, sta1[i].y ); }
    228275        printf( "\n" );
    229276
     
    240287        stp = anew( dim, 42, 42.5 );
    241288        printf( "CFA array new initialize\n" );
    242         for ( int i = 0; i < dim; i += 1 ) { printf( "%d %g, ", stp[i].x, stp[i].y ); }
     289        for ( i; dim ) { printf( "%d %g, ", stp[i].x, stp[i].y ); }
    243290        printf( "\n" );
    244291        stp1 = anew( dim, 42, 42.5 );
    245         for ( int i = 0; i < dim; i += 1 ) { printf( "%d %g, ", stp1[i].x, stp1[i].y ); }
     292        for ( i; dim ) { printf( "%d %g, ", stp1[i].x, stp1[i].y ); }
    246293        printf( "\n" );
    247294        adelete( dim, stp, dim, stp1 );
     
    271318// Local Variables: //
    272319// tab-width: 4 //
    273 // compile-command: "cfa alloc.c" //
     320// compile-command: "cfa alloc.cfa" //
    274321// End: //
  • tests/ato.cfa

    r7951100 rb067d9b  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // ato.c --
    8 // 
     6//
     7// ato.cfa --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Thu Feb  4 08:10:57 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Nov 16 18:31:56 2017
    13 // Update Count     : 89
    14 // 
     12// Last Modified On : Tue Dec  4 21:33:53 2018
     13// Update Count     : 92
     14//
    1515
    16 #include <fstream>
    17 #include <stdlib>                                                                               // ato, strto
     16#include <fstream.hfa>
     17#include <stdlib.hfa>                                                                           // ato, strto
    1818
    1919int main( void ) {
    2020        const char * sptr = "-123";
    2121        int i = ato( sptr );
    22         sout | i | sptr | endl;
     22        sout | i | sptr;
    2323        sptr = "123";
    2424        unsigned int ui = ato( sptr );
    25         sout | ui | sptr | endl;
     25        sout | ui | sptr;
    2626
    2727        sptr = "-123";
    2828        long int li = ato( sptr );
    29         sout | li | sptr | endl;
     29        sout | li | sptr;
    3030        sptr = "123";
    3131        unsigned long int uli = ato( sptr );
    32         sout | uli | sptr | endl;
     32        sout | uli | sptr;
    3333
    3434        sptr = "-123";
    3535        long long int lli = ato( sptr );
    36         sout | lli | sptr | endl;
     36        sout | lli | sptr;
    3737        sptr = "123";
    3838        unsigned long long int ulli = ato( sptr );
    39         sout | ulli | sptr | endl;
     39        sout | ulli | sptr;
    4040
    4141        sptr = "-123.456";
    4242        float f = ato( sptr );
    43         sout | f | sptr | endl;
     43        sout | f | sptr;
    4444        sptr = "-123.4567890123456";
    4545        double d = ato( sptr );
    46         sout | d | sptr | endl;
     46        sout | d | sptr;
    4747        sptr = "-123.45678901234567890123456789";
    4848        long double ld = ato( sptr );
    49         sout | ld | sptr | endl;
     49        sout | ld | sptr;
    5050
    5151        sptr = "-123.456-123.456i";
    5252        float _Complex fc = ato( sptr );
    53         sout | fc | sptr | endl;
     53        sout | fc | sptr;
    5454        sptr = "-123.4567890123456+123.4567890123456i";
    5555        double _Complex dc = ato( sptr );
    56         sout | dc | sptr | endl;
     56        sout | dc | sptr;
    5757        sptr = "123.45678901234567890123456789-123.45678901234567890123456789i";
    5858        long double _Complex ldc = ato( sptr );
    59         sout | ldc | sptr | endl;
     59        sout | ldc | sptr;
    6060        sptr = "123.45678901234-123.4567890i";
    6161        long double _Complex ldc2 = ato( sptr );
    62         sout | ldc2 | sptr | endl;
     62        sout | ldc2 | sptr;
    6363
    6464
    6565        sptr = "-123";
    6666        i = strto( sptr, 0, 10 );
    67         sout | i | sptr | endl;
     67        sout | i | sptr;
    6868        sptr = "123";
    6969        ui = strto( sptr, 0, 10 );
    70         sout | ui | sptr | endl;
     70        sout | ui | sptr;
    7171
    7272        sptr = "-123";
    7373        li = strto( sptr, 0, 10 );
    74         sout | li | sptr | endl;
     74        sout | li | sptr;
    7575        sptr = "123";
    7676        uli = strto( sptr, 0, 10 );
    77         sout | uli | sptr | endl;
     77        sout | uli | sptr;
    7878
    7979        sptr = "-123";
    8080        lli = strto( sptr, 0, 10 );
    81         sout | lli | sptr | endl;
     81        sout | lli | sptr;
    8282        sptr = "123";
    8383        ulli = strto( sptr, 0, 10 );
    84         sout | ulli | sptr | endl;
     84        sout | ulli | sptr;
    8585
    8686        sptr = "-123.456";
    8787        f = strto( sptr, 0 );
    88         sout | f | sptr | endl;
     88        sout | f | sptr;
    8989        sptr = "-123.4567890123456";
    9090        d = strto( sptr, 0 );
    91         sout | d | sptr | endl;
     91        sout | d | sptr;
    9292        sptr = "-123.45678901234567890123456789";
    9393        ld = strto( sptr, 0 );
    94         sout | ld | sptr | endl;
     94        sout | ld | sptr;
    9595
    9696        sptr = "-123.456-123.456i";
    9797        fc = strto( sptr, 0 );
    98         sout | fc | sptr | endl;
     98        sout | fc | sptr;
    9999
    100100        char * eptr = 0;
    101101        // sptr = "2fred";
    102102        // fc = strto( sptr, &eptr );
    103         // sout | fc | sptr | eptr | endl;
     103        // sout | fc | sptr | eptr;
    104104
    105105        sptr = "2  3";
    106106        fc = strto( sptr, &eptr );
    107         sout | fc | sptr | eptr | endl;
     107        sout | fc | sptr | eptr;
    108108
    109109        sptr = "-123.4567890123456+123.4567890123456i";
    110110        dc = strto( sptr, 0 );
    111         sout | dc | sptr | endl;
     111        sout | dc | sptr;
    112112        sptr = "123.45678901234567890123456789-123.45678901234567890123456789i";
    113113        ldc = strto( sptr, 0 );
    114         sout | ldc | sptr | endl;
     114        sout | ldc | sptr;
    115115        sptr = "123.45678901234-123.4567890i";
    116116        ldc2 = strto( sptr, 0 );
    117         sout | ldc2 | sptr | endl;
     117        sout | ldc2 | sptr;
    118118} // main
    119119
    120120// Local Variables: //
    121121// tab-width: 4 //
    122 // compile-command: "cfa ato.c" //
     122// compile-command: "cfa ato.cfa" //
    123123// End: //
  • tests/attributes.cfa

    r7951100 rb067d9b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // attributes.c --
     7// attributes.cfa --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Mon Feb  6 16:07:02 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 23:05:52 2017
    13 // Update Count     : 3
     12// Last Modified On : Tue Nov  6 17:51:12 2018
     13// Update Count     : 17
    1414//
    1515
     
    2929enum __attribute__(( packed )) Agn3 { E2 };
    3030#ifdef __CFA__
    31 struct __attribute__(( unused )) ( int ) {};
    32 struct __attribute__(( unused )) ( int ) {};
     31struct __attribute__(( unused )) {} ( int );
     32struct __attribute__(( unused )) Agn4 {} ( int );
    3333#endif // __CFA__
    3434
     
    4242    __attribute__(( unused )) int f5 __attribute__(( unused ));
    4343    __attribute__(( used )) int f6 __attribute__(( packed )), f7 __attribute__(( unused )) __attribute__(( unused )), __attribute__(( used )) f8 __attribute__(( unused ));
    44     int __attribute__(( unused ));
    4544    int ( ( * (f9) __attribute__(( unused )) ) __attribute__(( unused )) );
    4645};
     
    149148struct Vad {
    150149    int __attribute__(( unused ));
    151     int __attribute__(( unused )) * __attribute__(( unused ));
    152     int __attribute__(( unused )) [10] __attribute__(( unused ));
    153     int __attribute__(( unused )) (*)() __attribute__(( unused ));
     150    int __attribute__(( unused )) :4;
     151    int __attribute__(( unused )) :4, __attribute__(( unused )) :6;
    154152};
    155153
    156154// Local Variables: //
    157155// tab-width: 4 //
    158 // compile-command: "cfa attributes.c" //
     156// compile-command: "cfa attributes.cfa" //
    159157// End: //
  • tests/avltree/avl1.cfa

    r7951100 rb067d9b  
    11#include "avl.h"
    22// #include "cwrap.h"
    3 #include <stdlib>
     3#include <stdlib.hfa>
    44
    55forall(otype K | Comparable(K), otype V)
  • tests/avltree/avl3.cfa

    r7951100 rb067d9b  
    11#include "avl.h"
    22#include "avl-private.h"
    3 #include <stdlib>
     3#include <stdlib.hfa>
    44
    55// swaps the data within two tree nodes
  • tests/avltree/avl_test.cfa

    r7951100 rb067d9b  
    11#include "avl.h"
    22#include "avl-private.h"
    3 #include <stdlib>
     3#include <stdlib.hfa>
    44
    55extern "C" {
  • tests/builtins/sync.cfa

    r7951100 rb067d9b  
    1111        volatile __int128 * vp16 = 0; __int128 * rp16 = 0; __int128 v16 = 0;
    1212        #endif
     13        struct type * volatile * vpp = 0; struct type ** rpp = 0; struct type * vp = 0;
    1314
    1415        { char ret; ret = __sync_fetch_and_add(vp1, v1); }
     
    180181        { _Bool ret; ret = __sync_bool_compare_and_swap_16(vp16, v16,v16); }
    181182        #endif
     183        { _Bool ret; ret = __sync_bool_compare_and_swap(vpp, vp, vp); }
    182184
    183185        { char ret; ret = __sync_val_compare_and_swap(vp1, v1, v1); }
     
    193195        { __int128 ret; ret = __sync_val_compare_and_swap_16(vp16, v16,v16); }
    194196        #endif
     197        { struct type * ret; ret = __sync_val_compare_and_swap(vpp, vp, vp); }
     198
    195199
    196200        { char ret; ret = __sync_lock_test_and_set(vp1, v1); }
     
    230234        { __atomic_clear(vp1, v1); }
    231235
    232         { char ret; ret = __atomic_exchange_n(vp1, &v1, __ATOMIC_SEQ_CST); }
     236        { char ret; ret = __atomic_exchange_n(vp1, v1, __ATOMIC_SEQ_CST); }
    233237        { char ret; ret = __atomic_exchange_1(vp1, v1, __ATOMIC_SEQ_CST); }
    234238        { char ret; __atomic_exchange(vp1, &v1, &ret, __ATOMIC_SEQ_CST); }
    235         { short ret; ret = __atomic_exchange_n(vp2, &v2, __ATOMIC_SEQ_CST); }
     239        { short ret; ret = __atomic_exchange_n(vp2, v2, __ATOMIC_SEQ_CST); }
    236240        { short ret; ret = __atomic_exchange_2(vp2, v2, __ATOMIC_SEQ_CST); }
    237241        { short ret; __atomic_exchange(vp2, &v2, &ret, __ATOMIC_SEQ_CST); }
    238         { int ret; ret = __atomic_exchange_n(vp4, &v4, __ATOMIC_SEQ_CST); }
     242        { int ret; ret = __atomic_exchange_n(vp4, v4, __ATOMIC_SEQ_CST); }
    239243        { int ret; ret = __atomic_exchange_4(vp4, v4, __ATOMIC_SEQ_CST); }
    240244        { int ret; __atomic_exchange(vp4, &v4, &ret, __ATOMIC_SEQ_CST); }
    241         { long long int ret; ret = __atomic_exchange_n(vp8, &v8, __ATOMIC_SEQ_CST); }
     245        { long long int ret; ret = __atomic_exchange_n(vp8, v8, __ATOMIC_SEQ_CST); }
    242246        { long long int ret; ret = __atomic_exchange_8(vp8, v8, __ATOMIC_SEQ_CST); }
    243247        { long long int ret; __atomic_exchange(vp8, &v8, &ret, __ATOMIC_SEQ_CST); }
    244248        #if defined(__SIZEOF_INT128__)
    245         { __int128 ret; ret = __atomic_exchange_n(vp16, &v16, __ATOMIC_SEQ_CST); }
     249        { __int128 ret; ret = __atomic_exchange_n(vp16, v16, __ATOMIC_SEQ_CST); }
    246250        { __int128 ret; ret = __atomic_exchange_16(vp16, v16, __ATOMIC_SEQ_CST); }
    247251        { __int128 ret; __atomic_exchange(vp16, &v16, &ret, __ATOMIC_SEQ_CST); }
    248252        #endif
     253        { struct type * ret; ret = __atomic_exchange_n(vpp, vp, __ATOMIC_SEQ_CST); }
     254        { struct type * ret; __atomic_exchange(vpp, &vp, &ret, __ATOMIC_SEQ_CST); }
    249255
    250256        { char ret; ret = __atomic_load_n(vp1, __ATOMIC_SEQ_CST); }
     
    265271        { __int128 ret; __atomic_load(vp16, &ret, __ATOMIC_SEQ_CST); }
    266272        #endif
     273        { struct type * ret; ret = __atomic_load_n(vpp, __ATOMIC_SEQ_CST); }
     274        { struct type * ret; __atomic_load(vpp, &ret, __ATOMIC_SEQ_CST); }
    267275
    268276        { _Bool ret; ret = __atomic_compare_exchange_n(vp1, rp1, v1, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     
    283291        { _Bool ret; ret = __atomic_compare_exchange(vp16, rp16, &v16, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    284292        #endif
     293        { _Bool ret; ret = __atomic_compare_exchange_n(vpp, rpp, vp, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     294        { _Bool ret; ret = __atomic_compare_exchange(vpp, rpp, &vp, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    285295
    286296        { __atomic_store_n(vp1, v1, __ATOMIC_SEQ_CST); }
     
    301311        { __atomic_store(vp16, &v16, __ATOMIC_SEQ_CST); }
    302312        #endif
     313        { __atomic_store_n(vpp, vp, __ATOMIC_SEQ_CST); }
     314        { __atomic_store(vpp, &vp, __ATOMIC_SEQ_CST); }
    303315
    304316        { char ret; ret = __atomic_add_fetch(vp1, v1, __ATOMIC_SEQ_CST); }
  • tests/completeTypeError.cfa

    r7951100 rb067d9b  
    55forall(dtype T | sized(T)) void quux(T *);
    66
    7 struct A; // incomplete
    8 struct B {}; // complete
     7struct A;       // incomplete
     8struct B {};    // complete
    99
    1010int main() {
    11         int *i;
    12         void *v;
     11        int * i;
     12        void * v;
    1313
    1414        A * x;
     
    1919        // okay
    2020        *i;
    21         *x; // picks B
     21        *y;
    2222        *z;
    2323        foo(i);
     
    3232        // bad
    3333        *v;
    34         *y;
     34        *x;     // ambiguous
    3535        foo(v);
    3636        baz(v);
     
    5252void qux(T * y) {
    5353        // okay
     54        *y;
    5455        bar(y);
    5556        qux(y);
     
    5859        baz(y);
    5960        quux(y);
    60         *y;
    6161}
    6262
  • tests/complex.cfa

    r7951100 rb067d9b  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // complex.c --
    8 // 
     6//
     7// complex.cfa --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Wed May 24 22:07:31 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 24 22:08:01 2017
    13 // Update Count     : 1
    14 // 
     12// Last Modified On : Tue Dec  4 21:34:21 2018
     13// Update Count     : 4
     14//
    1515
    1616#include <stdio.h>
    1717#include <complex.h>
    1818#ifdef __CFA__
    19 #include <fstream>
     19#include <fstream.hfa>
    2020#endif // __CFA
    2121
     
    2525    printf( "x:%g+%gi y:%g+%gi z:%g+%gi\n", creal(x), cimag(x), creal(y), cimag(y), creal(z), cimag(z) );
    2626#ifdef __CFA__
    27     sout | "x:" | x | "y:" | y | "z:" | z | endl;
     27    sout | "x:" | x | "y:" | y | "z:" | z;
    2828#endif // __CFA
    2929    x = 2.1 + 1.3i;
     
    3232    printf( "x:%g+%gi y:%g+%gi z:%g+%gi\n", creal(x), cimag(x), creal(y), cimag(y), creal(z), cimag(z) );
    3333#ifdef __CFA__
    34     sout | "x:" | x | "y:" | y | "z:" | z | endl;
     34    sout | "x:" | x | "y:" | y | "z:" | z;
    3535#endif // __CFA
    3636}
     
    3838// Local Variables: //
    3939// tab-width: 4 //
    40 // compile-command: "cfa complex.c" //
     40// compile-command: "cfa complex.cfa" //
    4141// End: //
  • tests/concurrent/examples/boundedBufferEXT.cfa

    r7951100 rb067d9b  
    11//
     2// Cforall Version 1.0.0 Copyright (C) 2018 University of Waterloo
     3//
    24// The contents of this file are covered under the licence agreement in the
    35// file "LICENCE" distributed with Cforall.
     
    810// Created On       : Wed Apr 18 22:52:12 2018
    911// Last Modified By : Peter A. Buhr
    10 // Last Modified On : Wed May  2 16:12:58 2018
    11 // Update Count     : 7
     12// Last Modified On : Fri Jun 21 08:19:20 2019
     13// Update Count     : 14
    1214//
    1315
    14 #include <stdlib>                                                                               // random
    15 #include <fstream>
    16 #include <kernel>
    17 #include <thread>
     16#include <stdlib.hfa>                                                                   // random
     17#include <fstream.hfa>
     18#include <kernel.hfa>
     19#include <thread.hfa>
    1820#include <unistd.h>                                                                             // getpid
    1921
     
    5052}
    5153
    52 const int Sentinel = -1;
     54enum { Sentinel = -1 };
    5355
    5456thread Producer {
     
    5759};
    5860void main( Producer & prod ) with( prod ) {
    59         for ( int i = 1; i <= N; i += 1 ) {
     61        for ( i; 1 ~= N ) {
    6062                yield( random( 5 ) );
    6163                insert( buffer, 1 );
     
    7375void main( Consumer & cons ) with( cons ) {
    7476        sum = 0;
    75         for ( ;; ) {
     77        for () {
    7678                yield( random( 5 ) );
    7779                int item = remove( buffer );
     
    9799        srandom( 1003 );
    98100
    99         for ( i = 0; i < Cons; i += 1 ) {                                       // create consumers
     101        for ( i; Cons ) {                                                                       // create consumers
    100102                cons[i] = new( &buffer, sums[i] );
    101103        } // for
    102         for ( i = 0; i < Prods; i += 1 ) {                                      // create producers
     104        for ( i; Prods ) {                                                                      // create producers
    103105                prods[i] = new( &buffer, 100000 );
    104106        } // for
    105107
    106         for ( i = 0; i < Prods; i += 1 ) {                                      // wait for producers to finish
     108        for ( i; Prods ) {                                                                      // wait for producers to finish
    107109                delete( prods[i] );
    108110        } // for
    109         for ( i = 0; i < Cons; i += 1 ) {                                       // generate sentinal values to stop consumers
     111        for ( i; Cons ) {                                                                       // generate sentinal values to stop consumers
    110112                insert( buffer, Sentinel );
    111113        } // for
    112114        int sum = 0;
    113         for ( i = 0; i < Cons; i += 1 ) {                                       // wait for consumers to finish
     115        for ( i; Cons ) {                                                                       // wait for consumers to finish
    114116                delete( cons[i] );
    115117                sum += sums[i];
    116118        } // for
    117         sout | "total:" | sum | endl;
     119        sout | "total:" | sum;
    118120}
    119121
    120122// Local Variables: //
    121123// tab-width: 4 //
    122 // compile-command: "cfa boundedBufferEXT.c" //
     124// compile-command: "cfa boundedBufferEXT.cfa" //
    123125// End: //
  • tests/concurrent/examples/boundedBufferINT.cfa

    r7951100 rb067d9b  
    11//
     2// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
     3//
    24// The contents of this file are covered under the licence agreement in the
    35// file "LICENCE" distributed with Cforall.
     
    810// Created On       : Mon Oct 30 12:45:13 2017
    911// Last Modified By : Peter A. Buhr
    10 // Last Modified On : Thu Apr 26 23:08:17 2018
    11 // Update Count     : 82
     12// Last Modified On : Fri Jun 21 08:20:46 2019
     13// Update Count     : 90
    1214//
    1315
    14 #include <stdlib>                                                                               // random
    15 #include <fstream>
    16 #include <kernel>
    17 #include <thread>
     16#include <stdlib.hfa>                                                                   // random
     17#include <fstream.hfa>
     18#include <kernel.hfa>
     19#include <thread.hfa>
    1820#include <unistd.h>                                                                             // getpid
    1921
     
    5153}
    5254
    53 const int Sentinel = -1;
     55enum { Sentinel = -1 };
    5456
    5557thread Producer {
     
    5860};
    5961void main( Producer & prod ) with( prod ) {
    60         for ( int i = 1; i <= N; i += 1 ) {
     62        for ( i; 1 ~= N ) {
    6163                yield( random( 5 ) );
    6264                insert( buffer, 1 );
     
    7476void main( Consumer & cons ) with( cons ) {
    7577        sum = 0;
    76         for ( ;; ) {
     78        for () {
    7779                yield( random( 5 ) );
    7880                int item = remove( buffer );
     
    98100        srandom( 1003 );
    99101
    100         for ( i = 0; i < Cons; i += 1 ) {                                       // create consumers
     102        for ( i; Cons ) {                                                                       // create consumers
    101103                cons[i] = new( &buffer, sums[i] );
    102104        } // for
    103         for ( i = 0; i < Prods; i += 1 ) {                                      // create producers
     105        for ( i; Prods ) {                                                                      // create producers
    104106                prods[i] = new( &buffer, 100000 );
    105107        } // for
    106108
    107         for ( i = 0; i < Prods; i += 1 ) {                                      // wait for producers to finish
     109        for ( i; Prods ) {                                                                      // wait for producers to finish
    108110                delete( prods[i] );
    109111        } // for
    110         for ( i = 0; i < Cons; i += 1 ) {                                       // generate sentinal values to stop consumers
     112        for ( i; Cons ) {                                                                       // generate sentinal values to stop consumers
    111113                insert( buffer, Sentinel );
    112114        } // for
    113115        int sum = 0;
    114         for ( i = 0; i < Cons; i += 1 ) {                                       // wait for consumers to finish
     116        for ( i; Cons ) {                                                                       // wait for consumers to finish
    115117                delete( cons[i] );
    116118                sum += sums[i];
    117119        } // for
    118         sout | "total:" | sum | endl;
     120        sout | "total:" | sum;
    119121}
    120122
    121123// Local Variables: //
    122124// tab-width: 4 //
    123 // compile-command: "cfa boundedBufferINT.c" //
     125// compile-command: "cfa boundedBufferINT.cfa" //
    124126// End: //
  • tests/concurrent/examples/datingService.cfa

    r7951100 rb067d9b  
    11//
     2// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
     3//
    24// The contents of this file are covered under the licence agreement in the
    35// file "LICENCE" distributed with Cforall.
     
    810// Created On       : Mon Oct 30 12:56:20 2017
    911// Last Modified By : Peter A. Buhr
    10 // Last Modified On : Sun May 27 09:05:18 2018
    11 // Update Count     : 26
     12// Last Modified On : Fri Jun 21 11:32:34 2019
     13// Update Count     : 38
    1214//
    1315
    14 #include <stdlib>                                                                               // random
    15 #include <fstream>
    16 #include <kernel>
    17 #include <thread>
     16#include <stdlib.hfa>                                                                   // random
     17#include <fstream.hfa>
     18#include <kernel.hfa>
     19#include <thread.hfa>
    1820#include <unistd.h>                                                                             // getpid
    1921
     
    3335                signal_block( Boys[ccode] );                                    // restart boy to set phone number
    3436        } // if
     37        sout | "Girl:" | PhoneNo | "is dating Boy at" | BoyPhoneNo | "with ccode" | ccode;
    3538        return BoyPhoneNo;
    3639} // DatingService girl
     
    4447                signal_block( Girls[ccode] );                                   // restart girl to set phone number
    4548        } // if
     49        sout | " Boy:" | PhoneNo | "is dating Girl" | GirlPhoneNo | "with ccode" | ccode;
    4650        return GirlPhoneNo;
    4751} // DatingService boy
     
    5862        yield( random( 100 ) );                                                         // don't all start at the same time
    5963        unsigned int partner = girl( TheExchange, id, ccode );
    60         sout | "Girl:" | id | "is dating Boy at" | partner | "with ccode" | ccode | endl;
    6164        girlck[id] = partner;
    6265} // Girl main
     
    6972
    7073thread Boy {
    71         DatingService &TheExchange;
     74        DatingService & TheExchange;
    7275        unsigned int id, ccode;
    7376}; // Boy
     
    7679        yield( random( 100 ) );                                                         // don't all start at the same time
    7780        unsigned int partner = boy( TheExchange, id, ccode );
    78         sout | " Boy:" | id | "is dating Girl" | partner | "with ccode" | ccode | endl;
    7981        boyck[id] = partner;
    8082} // Boy main
     
    9395        srandom( /*getpid()*/ 103 );
    9496
    95         for ( unsigned int i = 0; i < CompCodes; i += 1 ) {
    96                 girls[i] = new( &TheExchange, i, i );
     97        for ( i; (unsigned int)CompCodes ) {
     98                girls[i] = new( &TheExchange, i, i );                   // TheExchange constructor needs unsigned int
    9799                boys[i]  = new( &TheExchange, i, CompCodes - ( i + 1 ) );
    98100        } // for
    99101
    100         for ( unsigned int i = 0; i < CompCodes; i += 1 ) {
     102        for ( i; CompCodes ) {
    101103                delete( boys[i] );
    102104                delete( girls[i] );
    103105        } // for
    104106
    105         for ( unsigned int i = 0; i < CompCodes; i += 1 ) {
     107        for ( i; CompCodes ) {
    106108                if ( girlck[ boyck[i] ] != boyck[ girlck[i] ] ) abort();
    107109        } // for
     
    110112// Local Variables: //
    111113// tab-width: 4 //
    112 // compile-command: "cfa datingService.c" //
     114// compile-command: "cfa datingService.cfa" //
    113115// End: //
  • tests/concurrent/examples/matrixSum.cfa

    r7951100 rb067d9b  
    1 //                               -*- Mode: C -*-
    2 //
     1//
    32// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
    43//
    54// The contents of this file are covered under the licence agreement in the
    65// file "LICENCE" distributed with Cforall.
    7 // 
    8 // matrixSum.c --
    9 // 
     6//
     7// matrixSum.cfa --
     8//
    109// Author           : Peter A. Buhr
    1110// Created On       : Mon Oct  9 08:29:28 2017
    1211// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Fri May 25 09:34:27 2018
    14 // Update Count     : 10
    15 // 
     12// Last Modified On : Wed Feb 20 08:37:53 2019
     13// Update Count     : 16
     14//
    1615
    17 #include <fstream>
    18 #include <kernel>
    19 #include <thread>
     16#include <fstream.hfa>
     17#include <kernel.hfa>
     18#include <thread.hfa>
    2019
    2120thread Adder {
     
    3029void main( Adder & adder ) with( adder ) {                              // thread starts here
    3130        subtotal = 0;
    32         for ( int c = 0; c < cols; c += 1 ) {
     31        for ( c; cols ) {
    3332                subtotal += row[c];
    3433        } // for
     
    3635
    3736int main() {
    38         const int rows = 10, cols = 1000;
     37        /* const */ int rows = 10, cols = 1000;
    3938        int matrix[rows][cols], subtotals[rows], total = 0;
    4039        processor p;                                                                            // add kernel thread
    4140
    42         for ( int r = 0; r < rows; r += 1 ) {
    43                 for ( int c = 0; c < cols; c += 1 ) {
     41        for ( r; rows ) {
     42                for ( c; cols ) {
    4443                        matrix[r][c] = 1;
    4544                } // for
    4645        } // for
    4746        Adder * adders[rows];
    48         for ( int r = 0; r < rows; r += 1 ) {                           // start threads to sum rows
     47        for ( r; rows ) {                                                                       // start threads to sum rows
    4948                adders[r] = &(*malloc()){ matrix[r], cols, subtotals[r] };
    5049//              adders[r] = new( matrix[r], cols, &subtotals[r] );
    5150        } // for
    52         for ( int r = 0; r < rows; r += 1 ) {                           // wait for threads to finish
     51        for ( r; rows ) {                                                                       // wait for threads to finish
    5352                delete( adders[r] );
    5453                total += subtotals[r];                                                  // total subtotals
    5554        } // for
    56         sout | total | endl;
     55        sout | total;
    5756}
    5857
    5958// Local Variables: //
    6059// tab-width: 4 //
    61 // compile-command: "cfa matrixSum.c" //
     60// compile-command: "cfa matrixSum.cfa" //
    6261// End: //
  • tests/concurrent/examples/quickSort.cfa

    r7951100 rb067d9b  
     1//
     2// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
    13//
    24// The contents of this file are covered under the licence agreement in the
     
    911// Created On       : Wed Dec  6 12:15:52 2017
    1012// Last Modified By : Peter A. Buhr
    11 // Last Modified On : Tue Jan 30 15:58:58 2018
    12 // Update Count     : 162
     13// Last Modified On : Thu Oct 10 13:58:18 2019
     14// Update Count     : 176
    1315//
    1416
    15 #include <fstream>
    16 #include <stdlib>
    17 #include <kernel>
    18 #include <thread>
     17#include <fstream.hfa>
     18#include <stdlib.hfa>
     19#include <kernel.hfa>
     20#include <thread.hfa>
    1921#include <string.h>                                                                             // strcmp
    2022
     
    6466                        if ( depth > 0 ) {
    6567                                depth -= 1;
    66                                 Quicksort rqs = { values, low, right, depth }; // concurrently sort upper half
    67                                 //Quicksort lqs( values, left, high, depth ); // concurrently sort lower half
    68                                 sort( values, left, high, depth );              // concurrently sort lower half
     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
    6972                        } else {
    7073                                sort( values, low, right, 0 );                  // sequentially sort lower half
     
    8891
    8992void usage( char * argv[] ) {
    90         sout | "Usage:" | argv[0] | "( -s unsorted-file [ sorted-file ] | -t size (>= 0) [ depth (>= 0) ] )" | endl;
     93        sout | "Usage:" | argv[0] | "( -s unsorted-file [ sorted-file ] | -t size (>= 0) [ depth (>= 0) ] )";
    9194        exit( EXIT_FAILURE );                                                           // TERMINATE!
    9295} // usage
     
    114117                                &sortedfile = new( (const char *)argv[2] ); // open the output file
    115118                                if ( fail( sortedfile ) ) {
    116                                         serr | "Error! Could not open sorted output file \"" | argv[2] | "\"" | endl;
     119                                        serr | "Error! Could not open sorted output file \"" | argv[2] | "\"";
    117120                                        usage( argv );
    118121                                } // if
     
    121124                                &unsortedfile = new( (const char *)argv[1] ); // open the input file
    122125                                if ( fail( unsortedfile ) ) {
    123                                         serr | "Error! Could not open unsorted input file \"" | argv[1] | "\"" | endl;
     126                                        serr | "Error! Could not open unsorted input file \"" | argv[1] | "\"";
    124127                                        usage( argv );
    125128                                } // if
     
    127130                } // if
    128131        } // if
     132        sortedfile | nlOff;                                                                     // turn off auto newline
    129133
    130134        enum { ValuesPerLine = 22 };                                            // number of values printed per line
    131135
    132136        if ( &unsortedfile ) {                                                          // generate output ?
    133                 for ( ;; ) {
     137                for () {
    134138                        unsortedfile | size;                                            // read number of elements in the list
    135139                  if ( eof( unsortedfile ) ) break;
    136140                        int * values = alloc( size );                           // values to be sorted, too large to put on stack
    137                         for ( int counter = 0; counter < size; counter += 1 ) { // read unsorted numbers
     141                        for ( counter; size ) {                                         // read unsorted numbers
    138142                                unsortedfile | values[counter];
    139                                 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | endl | "  ";
     143                                if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | nl | "  ";
    140144                                sortedfile | values[counter];
    141145                                if ( counter < size - 1 && (counter + 1) % ValuesPerLine != 0 ) sortedfile | ' ';
    142146                        } // for
    143                         sortedfile | endl;
     147                        sortedfile | nl;
    144148                        if ( size > 0 ) {                                                       // values to sort ?
    145149                                Quicksort QS = { values, size - 1, 0 }; // sort values
    146150                        } // wait until sort tasks terminate
    147                         for ( int counter = 0; counter < size; counter += 1 ) { // print sorted list
    148                                 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | endl | "  ";
     151                        for ( counter; size ) {                                         // print sorted list
     152                                if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | nl | "  ";
    149153                                sortedfile | values[counter];
    150154                                if ( counter < size - 1 && (counter + 1) % ValuesPerLine != 0 ) sortedfile | ' ';
    151155                        } // for
    152                         sortedfile | endl | endl;
     156                        sortedfile | nl | nl;
    153157
    154158                        delete( values );
     
    159163                processor processors[ (1 << depth) - 1 ] __attribute__(( unused )); // create 2^depth-1 kernel threads
    160164
    161                 int * values = alloc( size );                           // values to be sorted, too large to put on stack
    162                 for ( int counter = 0; counter < size; counter += 1 ) { // generate unsorted numbers
     165                int * values = alloc( size );                                   // values to be sorted, too large to put on stack
     166                for ( counter; size ) {                                                 // generate unsorted numbers
    163167                        values[counter] = size - counter;                       // descending values
     168                } // for
     169                for ( int i = 0; i < 200; i +=1 ) {                             // random shuffle a few values
     170                        swap( values[rand() % size], values[rand() % size] );
    164171                } // for
    165172                {
     
    167174                } // wait until sort tasks terminate
    168175
    169                 // for ( int counter = 0; counter < size - 1; counter += 1 ) { // check sorting
     176                // for ( counter; size - 1 ) {                          // check sorting
    170177                //      if ( values[counter] > values[counter + 1] ) abort();
    171178                // } // for
     
    175182} // main
    176183
     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} ; done
     185
    177186// Local Variables: //
    178187// tab-width: 4 //
    179 // compile-command: "cfa quickSort.c" //
     188// compile-command: "cfa quickSort.cfa" //
    180189// End: //
  • tests/concurrent/monitor.cfa

    r7951100 rb067d9b  
    1 #include <fstream>
    2 #include <kernel>
    3 #include <monitor>
    4 #include <thread>
     1#include <fstream.hfa>
     2#include <kernel.hfa>
     3#include <monitor.hfa>
     4#include <thread.hfa>
    55
    66monitor global_t {
     
    4040                MyThread f[4];
    4141        }
    42         sout | global.value | endl;
     42        sout | global.value;
    4343}
  • tests/concurrent/multi-monitor.cfa

    r7951100 rb067d9b  
    1 #include <fstream>
    2 #include <kernel>
    3 #include <monitor>
    4 #include <thread>
     1#include <fstream.hfa>
     2#include <kernel.hfa>
     3#include <monitor.hfa>
     4#include <thread.hfa>
    55
    66static int global12, global23, global13;
     
    5252                }
    5353        }
    54         sout | global12 | global23 | global13 | endl;
     54        sout | global12 | global23 | global13;
    5555}
  • tests/concurrent/preempt.cfa

    r7951100 rb067d9b  
    1 #include <kernel>
    2 #include <thread>
    3 #include <time>
     1#include <kernel.hfa>
     2#include <thread.hfa>
     3#include <time.hfa>
     4
     5#include "long_tests.hfa"
    46
    57#ifndef PREEMPTION_RATE
     
    1113}
    1214
    13 #ifdef LONG_TEST
     15#ifdef TEST_LONG
    1416static const unsigned long N = 30_000ul;
    1517#else
     
    3032
    3133void main(worker_t & this) {
    32         while(counter < N) {
     34        while(TEST(counter < N)) {
    3335                __cfaabi_check_preemption();
    3436                if( (counter % 7) == this.value ) {
     
    4042                }
    4143                __cfaabi_check_preemption();
     44                KICK_WATCHDOG;
    4245        }
    4346}
  • tests/concurrent/signal/block.cfa

    r7951100 rb067d9b  
    77
    88
    9 #include <fstream>
    10 #include <kernel>
    11 #include <monitor>
    12 #include <stdlib>
    13 #include <thread>
    14 #include <time>
     9#include <fstream.hfa>
     10#include <kernel.hfa>
     11#include <monitor.hfa>
     12#include <stdlib.hfa>
     13#include <thread.hfa>
     14#include <time.hfa>
     15
     16#include "long_tests.hfa"
    1517
    1618#ifndef PREEMPTION_RATE
     
    2224}
    2325
    24 #ifdef LONG_TEST
     26#ifdef TEST_LONG
    2527static const unsigned long N = 150_000ul;
    2628#else
     
    5557
    5658        if(a.last_thread != a.last_signaller || b.last_thread != b.last_signaller ) {
    57                 sout | "ERROR Barging detected, expected" | a.last_signaller | b.last_signaller | "got" | a.last_thread | b.last_thread | endl;
     59                sout | "ERROR Barging detected, expected" | a.last_signaller | b.last_signaller | "got" | a.last_thread | b.last_thread;
    5860                abort();
    5961        }
     
    6668thread Waiter {};
    6769void main( Waiter & this ) {
    68         for( int i = 0; i < N; i++ ) {
     70        for( int i = 0; TEST(i < N); i++ ) {
    6971                wait_op( globalA, globalB, i );
     72                KICK_WATCHDOG;
    7073        }
    7174}
     
    8285
    8386                if( ! signal_block( cond ) ) {
    84                         sout | "ERROR expected to be able to signal" | endl;
     87                        sout | "ERROR expected to be able to signal";
    8588                        abort();
    8689                }
     
    8992
    9093                if(a.last_thread != next || b.last_thread != next) {
    91                         sout | "ERROR Barging detected, expected" | next | "got" | a.last_thread | b.last_thread | endl;
     94                        sout | "ERROR Barging detected, expected" | next | "got" | a.last_thread | b.last_thread;
    9295                        abort();
    9396                }
     
    127130                Signaller s[4];
    128131                Barger b[13];
    129                 sout | "Starting waiters" | endl;
     132                sout | "Starting waiters";
    130133                {
    131134                        Waiter w[3];
    132135                }
    133                 sout | "Waiters done" | endl;
     136                sout | "Waiters done";
    134137                done = true;
    135138        }
  • tests/concurrent/signal/disjoint.cfa

    r7951100 rb067d9b  
    1 #include <fstream>
    2 #include <kernel>
    3 #include <monitor>
    4 #include <thread>
    5 #include <time>
     1#include <fstream.hfa>
     2#include <kernel.hfa>
     3#include <monitor.hfa>
     4#include <thread.hfa>
     5#include <time.hfa>
     6
     7#include "long_tests.hfa"
    68
    79#ifndef PREEMPTION_RATE
     
    1315}
    1416
    15 #ifdef LONG_TEST
     17#ifdef TEST_LONG
    1618static const unsigned long N = 300_000ul;
    1719#else
     
    6466        wait( cond );
    6567        if( d.state != SIGNAL ) {
    66                 sout | "ERROR barging!" | endl;
     68                sout | "ERROR barging!";
    6769        }
    6870
    69         d.counter++;
     71        #if !defined(TEST_FOREVER)
     72                d.counter++;
     73                if( (d.counter % 1000) == 0 ) sout | d.counter;
     74        #endif
    7075
    71         if( (d.counter % 1000) == 0 ) sout | d.counter | endl;
    72 
    73         return d.counter < N;
     76        return TEST(d.counter < N);
    7477}
    7578
     
    7780
    7881void main( Waiter & this ) {
    79         while( wait( mut, data ) ) { yield(); }
     82        while( wait( mut, data ) ) { KICK_WATCHDOG; yield(); }
    8083}
    8184
     
    9497
    9598        //This is technically a mutual exclusion violation but the mutex monitor protects us
    96         bool running = data.counter < N && data.counter > 0;
     99        bool running = TEST(data.counter < N) && data.counter > 0;
    97100        if( data.state != SIGNAL && running ) {
    98                 sout | "ERROR Eager signal" | data.state | endl;
     101                sout | "ERROR Eager signal" | data.state;
    99102        }
    100103}
     
    121124                        Waiter w[4];
    122125                }
    123                 sout | "All waiter done" | endl;
     126                sout | "All waiter done";
    124127                all_done = true;
    125128        }
  • tests/concurrent/signal/wait.cfa

    r7951100 rb067d9b  
    55
    66
    7 #include <fstream>
    8 #include <kernel>
    9 #include <monitor>
    10 #include <stdlib>
    11 #include <thread>
    12 #include <time>
     7#include <fstream.hfa>
     8#include <kernel.hfa>
     9#include <monitor.hfa>
     10#include <stdlib.hfa>
     11#include <thread.hfa>
     12#include <time.hfa>
     13
     14#define __kick_rate 12000ul
     15#include "long_tests.hfa"
    1316
    1417#ifndef PREEMPTION_RATE
     
    2023}
    2124
    22 #ifdef LONG_TEST
     25#ifdef TEST_LONG
    2326static const unsigned long N = 375_000ul;
    2427#else
     
    8083                                break;
    8184                        default:
    82                                 sout | "Something went wrong" | endl;
     85                                sout | "Something went wrong";
    8386                                abort();
    8487                }
     
    9093// Waiter ABC
    9194void main( WaiterABC & this ) {
    92         for( int i = 0; i < N; i++ ) {
     95        for( int i = 0; TEST(i < N); i++ ) {
    9396                wait( condABC, globalA, globalB, globalC );
     97                KICK_WATCHDOG;
    9498        }
    9599
     
    100104// Waiter AB
    101105void main( WaiterAB & this ) {
    102         for( int i = 0; i < N; i++ ) {
     106        for( int i = 0; TEST(i < N); i++ ) {
    103107                wait( condAB , globalA, globalB );
     108                KICK_WATCHDOG;
    104109        }
    105110
     
    110115// Waiter AC
    111116void main( WaiterAC & this ) {
    112         for( int i = 0; i < N; i++ ) {
     117        for( int i = 0; TEST(i < N); i++ ) {
    113118                wait( condAC , globalA, globalC );
     119                KICK_WATCHDOG;
    114120        }
    115121
     
    120126// Waiter BC
    121127void main( WaiterBC & this ) {
    122         for( int i = 0; i < N; i++ ) {
     128        for( int i = 0; TEST(i < N); i++ ) {
    123129                wait( condBC , globalB, globalC );
     130                KICK_WATCHDOG;
    124131        }
    125132
     
    133140        waiter_left = 4;
    134141        processor p[2];
    135         sout | "Starting" | endl;
     142        sout | "Starting";
    136143        {
    137144                Signaler  e;
     
    143150                }
    144151        }
    145         sout | "Done" | endl;
     152        sout | "Done";
    146153}
  • tests/concurrent/thread.cfa

    r7951100 rb067d9b  
    1 #include <fstream>
    2 #include <kernel>
    3 #include <stdlib>
    4 #include <thread>
     1#include <fstream.hfa>
     2#include <kernel.hfa>
     3#include <stdlib.hfa>
     4#include <thread.hfa>
    55
    66thread First  { semaphore* lock; };
     
    1212void main(First& this) {
    1313        for(int i = 0; i < 10; i++) {
    14                 sout | "First : Suspend No." | i + 1 | endl;
     14                sout | "First : Suspend No." | i + 1;
    1515                yield();
    1616        }
     
    2121        P(*this.lock);
    2222        for(int i = 0; i < 10; i++) {
    23                 sout | "Second : Suspend No." | i + 1 | endl;
     23                sout | "Second : Suspend No." | i + 1;
    2424                yield();
    2525        }
     
    2929int main(int argc, char* argv[]) {
    3030        semaphore lock = { 0 };
    31         sout | "User main begin" | endl;
     31        sout | "User main begin";
    3232        {
    3333                processor p;
     
    3737                }
    3838        }
    39         sout | "User main end" | endl;
     39        sout | "User main end";
    4040}
  • tests/concurrent/waitfor/barge.cfa

    r7951100 rb067d9b  
    66//---------------------------------------------------------
    77
    8 #include <fstream>
    9 #include <kernel>
    10 #include <monitor>
    11 #include <stdlib>
    12 #include <thread>
     8#include <fstream.hfa>
     9#include <kernel.hfa>
     10#include <monitor.hfa>
     11#include <stdlib.hfa>
     12#include <thread.hfa>
    1313
    1414#include <stdbool.h>
     
    4848        yield(random( 10 ));
    4949        if( this.state != WAITFOR && !this.done && this.started ) {
    50                 serr | "Barging before caller detected" | endl;
     50                serr | "Barging before caller detected";
    5151        }
    5252
     
    6666                this.state = WAITFOR;
    6767                waitfor(do_call, this) {
    68                         sout | i | endl;
     68                        sout | i;
    6969                }
    7070
    7171                if( this.state != CALL ) {
    72                         serr | "Barging after caller detected" | endl;
     72                        serr | "Barging after caller detected";
    7373                }
    7474        }
     
    8383
    8484int main() {
    85         sout | "Starting" | endl;
     85        sout | "Starting";
    8686        {
    8787                barger_t bargers[17];
     
    8989                waiter_t waiters;
    9090        }
    91         sout | "Stopping" | endl;
     91        sout | "Stopping";
    9292}
  • tests/concurrent/waitfor/dtor.cfa

    r7951100 rb067d9b  
    44//---------------------------------------------------------
    55
    6 #include <fstream>
    7 #include <kernel>
    8 #include <monitor>
    9 #include <stdlib>
    10 #include <thread>
     6#include <fstream.hfa>
     7#include <kernel.hfa>
     8#include <monitor.hfa>
     9#include <stdlib.hfa>
     10#include <thread.hfa>
    1111
    1212#include <stdbool.h>
     
    2929        switch(state) {
    3030                case CTOR  : break;
    31                 case MAIN  : if( this.state != CTOR  ) { serr | "ERROR Expected state to be CTOR"  | endl; abort(); } this.state = state; break;
    32                 case AFTER : if( this.state != MAIN  ) { serr | "ERROR Expected state to be MAIN"  | endl; abort(); } this.state = state; break;
    33                 case END   : if( this.state != AFTER ) { serr | "ERROR Expected state to be AFTER" | endl; abort(); } this.state = state; break;
    34                 case DTOR  : if( this.state != END   ) { serr | "ERROR Expected state to be END"   | endl; abort(); } this.state = state; break;
     31                case MAIN  : if( this.state != CTOR  ) { serr | "ERROR Expected state to be CTOR" ; abort(); } this.state = state; break;
     32                case AFTER : if( this.state != MAIN  ) { serr | "ERROR Expected state to be MAIN" ; abort(); } this.state = state; break;
     33                case END   : if( this.state != AFTER ) { serr | "ERROR Expected state to be AFTER"; abort(); } this.state = state; break;
     34                case DTOR  : if( this.state != END   ) { serr | "ERROR Expected state to be END"  ; abort(); } this.state = state; break;
    3535        }
    3636}
     
    5454
    5555int main() {
    56         sout | "Starting" | endl;
     56        sout | "Starting";
    5757        processor p;
    5858        for( int i = 0; i < N; i++ ){
     
    6060                yield( random( 100 ) );
    6161        }
    62         sout | "Stopping" | endl;
     62        sout | "Stopping";
    6363}
  • tests/concurrent/waitfor/else.cfa

    r7951100 rb067d9b  
    1 #include <fstream>
    2 #include <monitor>
     1#include <fstream.hfa>
     2#include <monitor.hfa>
    33
    44#include <stdbool.h>
     
    1212void test( M & mutex m ) {
    1313        int i = 0;
    14         sout | "Starting" | endl;
     14        sout | "Starting";
    1515
    1616        when( false ) waitfor( notcalled, m );
    1717
    18         sout | "Step" | i++ | endl;
     18        sout | "Step" | i++;
    1919
    2020        waitfor( notcalled, m ); or else {
    21                 sout | "else called" | endl;
     21                sout | "else called";
    2222        }
    2323
    24         sout | "Step" | i++ | endl;
     24        sout | "Step" | i++;
    2525
    2626        when( true ) waitfor( notcalled, m ); or when( true ) else {
    27                 sout | "else called" | endl;
     27                sout | "else called";
    2828        }
    2929
    30         sout | "Step" | i++ | endl;
     30        sout | "Step" | i++;
    3131
    3232        when( false ) waitfor( notcalled, m ); or when( true ) else {
    33                 sout | "else called" | endl;
     33                sout | "else called";
    3434        }
    3535
    36         sout | "Step" | i++ | endl;
     36        sout | "Step" | i++;
    3737
    3838        when( false ) waitfor( notcalled, m ); or when( false ) else {
    39                 sout | "else called" | endl;
     39                sout | "else called";
    4040        }
    4141
    42         sout | "Done" | endl;
     42        sout | "Done";
    4343}
    4444
  • tests/concurrent/waitfor/parse.cfa

    r7951100 rb067d9b  
    88//----------------------------------------------------------------------------------------
    99
    10 #include <monitor>
     10#include <monitor.hfa>
    1111
    1212monitor M {};
  • tests/concurrent/waitfor/parse2.cfa

    r7951100 rb067d9b  
    1010// Created On       : Wed Aug 30 17:53:29 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 30 17:55:17 2017
    13 // Update Count     : 2
     12// Last Modified On : Fri Mar 22 13:42:11 2019
     13// Update Count     : 3
    1414//
    1515
     
    246246// Local Variables: //
    247247// tab-width: 4 //
    248 // compile-command: "cfa waitfor.c" //
     248// compile-command: "cfa waitfor.cfa" //
    249249// End: //
  • tests/concurrent/waitfor/recurse.cfa

    r7951100 rb067d9b  
    44//-----------------------------------------------------------------
    55
    6 #include <fstream>
    7 #include <kernel>
    8 #include <monitor>
    9 #include <stdlib>
    10 #include <thread>
     6#include <fstream.hfa>
     7#include <kernel.hfa>
     8#include <monitor.hfa>
     9#include <stdlib.hfa>
     10#include <thread.hfa>
    1111
    1212#include <stdbool.h>
     
    9595        rand_yield();
    9696
    97         sout | "1st" | endl;
     97        sout | "1st" | nl;
    9898
    9999        return this.counter < N ? (state_t)this.actions[idx] : (state_t)STOP;
     
    123123                        case THIRD  : while( !global.ready ) { yield(); } this.state = call3( global, this.idx ); break;
    124124                        case LAST   : while( !global.ready ) { yield(); } this.state = call4( global, this.idx ); break;
    125                         case STOP   : serr | "This should not happen" | endl;
     125                        case STOP   : serr | "This should not happen" | nl;
    126126                }
    127127        }
     
    132132int main() {
    133133        srandom( time(NULL) );
    134         sout | "Starting" | endl;
     134        sout | nlOff;                                   // turn off auto newline
     135        sout | "Starting" | nl;
    135136        {
    136137                waiter_t waiters[4] = {
     
    142143                the_threads = waiters;
    143144        }
    144         sout | "Stopping" | endl;
     145        sout | "Stopping" | nl;
    145146}
  • tests/concurrent/waitfor/simple.cfa

    r7951100 rb067d9b  
    1 #include <fstream>
    2 #include <kernel>
    3 #include <monitor>
    4 #include <stdlib>
    5 #include <thread>
     1#include <fstream.hfa>
     2#include <kernel.hfa>
     3#include <monitor.hfa>
     4#include <stdlib.hfa>
     5#include <thread.hfa>
    66
    77#include <time.h>
     
    3131
    3232void do_wait( global_t * mutex a ) {
    33         sout | "Waiting to accept" | endl;
     33        sout | "Waiting to accept";
    3434        yield( random( 10 ) );
    3535
    36         sout | "Accepting" | endl;
     36        sout | "Accepting";
    3737
    3838        __acceptable_t acceptable;
     
    4343        __waitfor_internal( 1, &acceptable );
    4444
    45         sout | "Accepted" | endl;
     45        sout | "Accepted";
    4646        yield( random( 10 ) );
    4747}
     
    5050        for( int i = 0; i < N; i++ ) {
    5151                do_wait( &globalA );
    52                 sout | i | endl;
     52                sout | i;
    5353        }
    5454
     
    7676        srandom( time( NULL ) );
    7777        printf("%p\n", &globalA);
    78         sout | "Starting" | endl;
     78        sout | "Starting";
    7979        {
    8080                Acceptor r;
     
    8282
    8383        }
    84         sout | "Done" | endl;
     84        sout | "Done";
    8585}
  • tests/concurrent/waitfor/statment.cfa

    r7951100 rb067d9b  
    1 #include <fstream>
    2 #include <kernel>
    3 #include <monitor>
    4 #include <thread>
     1#include <fstream.hfa>
     2#include <kernel.hfa>
     3#include <monitor.hfa>
     4#include <thread.hfa>
    55
    66#include <stdbool.h>
     
    8484                case 7: return call7( m );
    8585                default :
    86                         serr | "Incorrect index" | index | endl;
     86                        serr | "Incorrect index" | index;
    8787                        abort();
    8888        }
     
    102102        while( !done ) {
    103103                   waitfor( get_index, this );
    104                 or waitfor( call1, this ) { sout | "Statement" | endl; if( this.last_val != 1 ) { serr | "Incorrect index: expected" | 1 | "got" | this.last_val | endl; } }
    105                 or waitfor( call2, this ) { sout | "Statement" | endl; if( this.last_val != 2 ) { serr | "Incorrect index: expected" | 2 | "got" | this.last_val | endl; } }
    106                 or waitfor( call3, this ) { sout | "Statement" | endl; if( this.last_val != 3 ) { serr | "Incorrect index: expected" | 3 | "got" | this.last_val | endl; } }
    107                 or waitfor( call4, this ) { sout | "Statement" | endl; if( this.last_val != 4 ) { serr | "Incorrect index: expected" | 4 | "got" | this.last_val | endl; } }
    108                 or waitfor( call5, this ) { sout | "Statement" | endl; if( this.last_val != 5 ) { serr | "Incorrect index: expected" | 5 | "got" | this.last_val | endl; } }
    109                 or waitfor( call6, this ) { sout | "Statement" | endl; if( this.last_val != 6 ) { serr | "Incorrect index: expected" | 6 | "got" | this.last_val | endl; } }
    110                 or waitfor( call7, this ) { sout | "Statement" | endl; if( this.last_val != 7 ) { serr | "Incorrect index: expected" | 7 | "got" | this.last_val | endl; } }
     104                or waitfor( call1, this ) { sout | "Statement"; if( this.last_val != 1 ) { serr | "Incorrect index: expected" | 1 | "got" | this.last_val; } }
     105                or waitfor( call2, this ) { sout | "Statement"; if( this.last_val != 2 ) { serr | "Incorrect index: expected" | 2 | "got" | this.last_val; } }
     106                or waitfor( call3, this ) { sout | "Statement"; if( this.last_val != 3 ) { serr | "Incorrect index: expected" | 3 | "got" | this.last_val; } }
     107                or waitfor( call4, this ) { sout | "Statement"; if( this.last_val != 4 ) { serr | "Incorrect index: expected" | 4 | "got" | this.last_val; } }
     108                or waitfor( call5, this ) { sout | "Statement"; if( this.last_val != 5 ) { serr | "Incorrect index: expected" | 5 | "got" | this.last_val; } }
     109                or waitfor( call6, this ) { sout | "Statement"; if( this.last_val != 6 ) { serr | "Incorrect index: expected" | 6 | "got" | this.last_val; } }
     110                or waitfor( call7, this ) { sout | "Statement"; if( this.last_val != 7 ) { serr | "Incorrect index: expected" | 7 | "got" | this.last_val; } }
    111111
    112112                done = true;
     
    128128int main() {
    129129        processor p[2];
    130         sout | "Starting" | endl;
     130        sout | "Starting";
    131131        {
    132132                caller c[7];
    133133                waiter w;
    134134        }
    135         sout | "Stopping" | endl;
     135        sout | "Stopping";
    136136}
  • tests/concurrent/waitfor/when.cfa

    r7951100 rb067d9b  
    44//-----------------------------------------------------------------
    55
    6 #include <fstream>
    7 #include <kernel>
    8 #include <monitor>
    9 #include <stdlib>
    10 #include <thread>
     6#include <fstream.hfa>
     7#include <kernel.hfa>
     8#include <monitor.hfa>
     9#include <stdlib.hfa>
     10#include <thread.hfa>
    1111
    1212#include <stdbool.h>
     
    5858void arbiter( global_t & mutex this ) {
    5959        for( int i = 0; i < N; i++ ) {
    60                    when( this.last_call == 6 ) waitfor( call1, this ) { if( this.last_call != 1) { serr | "Expected last_call to be 1 got" | this.last_call | endl; } }
    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 | endl; } }
    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 | endl; } }
    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 | endl; } }
    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 | endl; } }
    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 | endl; } }
     60                   when( this.last_call == 6 ) waitfor( call1, this ) { if( this.last_call != 1) { serr | "Expected last_call to be 1 got" | this.last_call; } }
     61                or when( this.last_call == 1 ) waitfor( call2, this ) { if( this.last_call != 2) { serr | "Expected last_call to be 2 got" | this.last_call; } }
     62                or when( this.last_call == 2 ) waitfor( call3, this ) { if( this.last_call != 3) { serr | "Expected last_call to be 3 got" | this.last_call; } }
     63                or when( this.last_call == 3 ) waitfor( call4, this ) { if( this.last_call != 4) { serr | "Expected last_call to be 4 got" | this.last_call; } }
     64                or when( this.last_call == 4 ) waitfor( call5, this ) { if( this.last_call != 5) { serr | "Expected last_call to be 5 got" | this.last_call; } }
     65                or when( this.last_call == 5 ) waitfor( call6, this ) { if( this.last_call != 6) { serr | "Expected last_call to be 6 got" | this.last_call; } }
    6666
    67                 sout | this.last_call | endl;
     67                sout | this.last_call;
    6868        }
    6969
     
    7878int main() {
    7979        srandom( time(NULL) );
    80         sout | "Starting" | endl;
     80        sout | "Starting";
    8181        {
    8282                arbiter_t arbiter;
     
    8484
    8585        }
    86         sout | "Stopping" | endl;
     86        sout | "Stopping";
    8787}
  • tests/coroutine/.in/fmtLines.txt

    r7951100 rb067d9b  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // fmtLines.cc -- 
    8 // 
     6//
     7// fmtLines.cc --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Sun Sep 17 21:56:15 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Sep 18 11:35:57 2017
    13 // Update Count     : 31
    14 // 
     12// Last Modified On : Fri Mar 22 13:41:03 2019
     13// Update Count     : 33
     14//
    1515
    16 #include <fstream>
    17 #include <coroutine>
     16#include <fstream.hfa>
     17#include <coroutine.hfa>
    1818
    1919coroutine Format {
     
    2727
    2828void ^?{}( Format & fmt ) {
    29     if ( fmt.g != 0 || fmt.b != 0 ) sout | endl;
     29    if ( fmt.g != 0 || fmt.b != 0 ) sout | nl;
    3030}
    3131
     
    4242                        sout | "  ";                                                            // print block separator
    4343                } // for
    44                 sout | endl;                                                                    // print group separator
     44                sout | nl;                                                                      // print group separator
    4545        } // for
    4646} // main
     
    6464// Local Variables: //
    6565// tab-width: 4 //
    66 // compile-command: "cfa fmtLines.c" //
     66// compile-command: "cfa fmtLines.cfa" //
    6767// End: //
  • tests/coroutine/fibonacci.cfa

    r7951100 rb067d9b  
    66//
    77// fibonacci.c -- 3-state finite-state machine
    8 
    98//
    109// Author           : Thierry Delisle
    1110// Created On       : Thu Jun  8 07:29:37 2017
    1211// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Fri Apr 27 08:55:31 2018
    14 // Update Count     : 19
     12// Last Modified On : Fri Mar 22 13:40:35 2019
     13// Update Count     : 26
    1514//
    1615
    17 #include <fstream>
    18 #include <coroutine>
     16#include <fstream.hfa>
     17#include <coroutine.hfa>
    1918
    2019coroutine Fibonacci { int fn; };                                                // used for communication
     
    2625        fn = 1;  fn2 = fn1;  fn1 = fn;                                          // 2nd case
    2726        suspend();                                                                                      // restart last resume
    28         for ( ;; ) {
     27        for () {
    2928                fn = fn1 + fn2;  fn2 = fn1;  fn1 = fn;                  // general case
    3029                suspend();                                                                              // restart last resume
     
    3938int main() {
    4039        Fibonacci f1, f2;
    41         for ( int i = 1; i <= 10; i += 1 ) {
    42                 sout | next( f1 ) | next( f2 ) | endl;
     40        for ( 10 ) {                                                                            // print N Fibonacci values
     41                sout | next( f1 ) | next( f2 );
    4342        } // for
    4443}
     
    4645// Local Variables: //
    4746// tab-width: 4 //
    48 // compile-command: "cfa fibonacci.c" //
     47// compile-command: "cfa fibonacci.cfa" //
    4948// End: //
  • tests/coroutine/fmtLines.cfa

    r7951100 rb067d9b  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
     6//
    77// fmtLines.cc -- format characters into blocks of 4 and groups of 5 blocks per line
    8 // 
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Sun Sep 17 21:56:15 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue May 15 12:25:33 2018
    13 // Update Count     : 42
    14 // 
     12// Last Modified On : Fri Mar 22 13:41:16 2019
     13// Update Count     : 58
     14//
    1515
    16 #include <fstream>
    17 #include <coroutine>
     16#include <fstream.hfa>
     17#include <coroutine.hfa>
    1818
    1919coroutine Format {
     
    2323
    2424void main( Format & fmt ) with( fmt ) {
    25         for ( ;; ) {                                                                            // for as many characters
     25        for () {                                                                                        // for as many characters
    2626                for ( g = 0; g < 5; g += 1 ) {                                  // groups of 5 blocks
    2727                        for ( b = 0; b < 4; b += 1 ) {                          // blocks of 4 characters
    28                                 for ( ;; ) {                                                    // for newline characters
     28                                for () {                                                                // for newline characters
    2929                                        suspend();
    30                                         if ( ch != '\n' ) break;                        // ignore newline
     30                                  if ( ch != '\n' ) break;                              // ignore newline
    3131                                } // for
    3232                                sout | ch;                                                              // print character
     
    3434                        sout | "  ";                                                            // print block separator
    3535                } // for
    36                 sout | endl;                                                                    // print group separator
     36                sout | nl;                                                                              // print group separator
    3737        } // for
    3838} // main
     
    4343
    4444void ^?{}( Format & fmt ) with( fmt ) {
    45         if ( g != 0 || b != 0 ) sout | endl;
     45        if ( g != 0 || b != 0 ) sout | nl;
    4646}
    4747
    4848void format( Format & fmt ) {
    4949        resume( fmt );
    50 } // prt
     50} // format
    5151
    5252int main() {
    5353        Format fmt;
     54        sout | nlOff;                                                                           // turn off auto newline
    5455
    55         eof: for ( ;; ) {                                                                       // read until end of file
     56  eof: for () {                                                                                 // read until end of file
    5657                sin | fmt.ch;                                                                   // read one character
    5758          if ( eof( sin ) ) break eof;                                          // eof ?
     
    6263// Local Variables: //
    6364// tab-width: 4 //
    64 // compile-command: "cfa fmtLines.c" //
     65// compile-command: "cfa fmtLines.cfa" //
    6566// End: //
  • tests/coroutine/pingpong.cfa

    r7951100 rb067d9b  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // pingpong.c -- 
    8 // 
     6//
     7// pingpong.c --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Wed Sep 20 11:55:23 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Sep 20 13:41:39 2017
    13 // Update Count     : 26
    14 // 
     12// Last Modified On : Tue Mar 26 17:54:14 2019
     13// Update Count     : 35
     14//
    1515
    16 #include <coroutine>
    17 #include <fstream>
     16#include <coroutine.hfa>
     17#include <fstream.hfa>
    1818
    1919coroutine PingPong {
    2020        const char * name;
    2121        /* const */ unsigned int N;
    22         PingPong * part;
     22        PingPong & part;
    2323};
    2424
    2525void ?{}( PingPong & this, const char * name, unsigned int N, PingPong & part ) {
    26         this.name = name;
    27         this.N = N;
    28         this.part = &part;
     26        this.[name, N] = [name, N];  &this.part = &part;
    2927}
    3028void ?{}( PingPong & this, const char * name, unsigned int N ) {
    31         this{ name, N, *(PingPong *)0 };
     29        this{ name, N, *0p };                                                           // call first constructor
    3230}
    3331void cycle( PingPong & pingpong ) {
     
    3533}
    3634void partner( PingPong & this, PingPong & part ) {
    37         this.part = &part;
     35        &this.part = &part;
    3836        resume( this );
    3937}
    40 void main( PingPong & pingpong ) {                                              // ping's starter ::main, pong's starter ping
    41         for ( unsigned int i = 0; i < pingpong.N; i += 1 ) {
    42                 sout | pingpong.name | endl;
    43                 cycle( *pingpong.part );
     38void main( PingPong & pingpong ) with(pingpong) {               // ping's starter ::main, pong's starter ping
     39        for ( N ) {                                                                                     // N ping-pongs
     40                sout | name;
     41                cycle( part );
    4442        } // for
    4543}
     
    5250// Local Variables: //
    5351// tab-width: 4 //
    54 // compile-command: "cfa pingpong.c" //
     52// compile-command: "cfa pingpong.cfa" //
    5553// End: //
  • tests/coroutine/prodcons.cfa

    r7951100 rb067d9b  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // prodcons.c -- 
    8 // 
     6//
     7// prodcons.c --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Mon Sep 18 12:23:39 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jan  2 12:17:01 2018
    13 // Update Count     : 47
    14 // 
     12// Last Modified On : Fri Mar 22 13:41:10 2019
     13// Update Count     : 54
     14//
    1515
    16 #include <fstream>
    17 #include <coroutine>
    18 #include <stdlib>                                                                               // random
     16#include <fstream.hfa>
     17#include <coroutine.hfa>
     18#include <stdlib.hfa>                                                                   // random
    1919#include <unistd.h>                                                                             // getpid
    2020
     
    2424
    2525coroutine Prod {
    26         Cons * c;
     26        Cons & c;
    2727        int N, money, receipt;
    2828};
    2929void main( Prod & prod ) with( prod ) {                                 // starter ::main
    3030        // 1st resume starts here
    31         for ( int i = 0; i < N; i += 1 ) {
    32                 int p1 = random( 100 );
    33                 int p2 = random( 100 );
    34                 sout | p1 | " " | p2 | endl;
    35                 int status = delivery( *c, p1, p2 );
    36                 sout | " $" | money | endl;
    37                 sout | status | endl;
     31        for ( i; N ) {                                                                          // N pairs of values
     32                int p1 = random( 100 ), p2 = random( 100 );
     33                sout | p1 | " " | p2;
     34                int status = delivery( c, p1, p2 );
     35                sout | " $" | money | nl | status;
    3836                receipt += 1;
    3937        }
    40         stop( *c );
    41         sout | "prod stops" | endl;
     38        stop( c );
     39        sout | "prod stops";
    4240}
    4341int payment( Prod & prod, int money ) {
     
    4745}
    4846void start( Prod & prod, int N, Cons &c ) {
    49         prod.N = N;
    50         prod.c = &c;
    51         prod.receipt = 0;
     47        &prod.c = &c;
     48        prod.[N, receipt] = [N, 0];
    5249        resume( prod );                                                                         // activate main
    5350}
    5451
    5552coroutine Cons {
    56         Prod * p;
     53        Prod & p;
    5754        int p1, p2, status;
    5855        bool done;
    5956};
    6057void ?{}( Cons & cons, Prod & p ) {
    61         cons.p = &p;
    62         cons.status = 0;
    63         cons.done = false;
     58        &cons.p = &p;
     59        cons.[status, done ] = [0, false];
    6460}
    6561void ^?{}( Cons & cons ) {}
     
    6864        int money = 1, receipt;
    6965        for ( ; ! done; ) {
    70                 sout | p1 | " " | p2 | endl;
    71                 sout | " $" | money | endl;
     66                sout | p1 | " " | p2 | nl | " $" | money;
    7267                status += 1;
    73                 receipt = payment( *p, money );
    74                 sout | " #" | receipt | endl;
     68                receipt = payment( p, money );
     69                sout | " #" | receipt;
    7570                money += 1;
    7671        }
    77         sout | "cons stops" | endl;
     72        sout | "cons stops";
    7873}
    7974int delivery( Cons & cons, int p1, int p2 ) {
    80         cons.p1 = p1;
    81         cons.p2 = p2;
     75        cons.[p1, p2] = [p1, p2];
    8276        resume( cons );                                                                         // main 1st time, then
    8377        return cons.status;                                                                     // cons in payment
     
    9286        srandom( /* getpid() */ 103 );                                          // fixed seed for testing
    9387        start( prod, 5, cons );
    94         sout | "main stops" | endl;
     88        sout | "main stops";
    9589}
    9690
    9791// Local Variables: //
    9892// tab-width: 4 //
    99 // compile-command: "cfa prodcons.c" //
     93// compile-command: "cfa prodcons.cfa" //
    10094// End: //
  • tests/coroutine/runningTotal.cfa

    r7951100 rb067d9b  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // runningTotal.c -- 
    8 // 
     6//
     7// runningTotal.c --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Wed Dec  6 08:05:27 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec  6 08:09:24 2017
    13 // Update Count     : 2
    14 // 
     12// Last Modified On : Fri Mar 22 13:40:49 2019
     13// Update Count     : 5
     14//
    1515
    16 #include <fstream>
    17 #include <coroutine>
     16#include <fstream.hfa>
     17#include <coroutine.hfa>
    1818
    1919coroutine RunTotal {                                                                    // input numbers and return running total
     
    2929
    3030void main( RunTotal & rntl ) with( rntl ) {
    31         for ( ;; ) {
     31        for () {
    3232                update( rntl, input );
    3333        } // for
     
    4141int main() {
    4242        RunTotal rntl;
    43         for ( int i = 0; i < 10; i += 1 ) {
    44                 sout | i | add( rntl, i ) | endl;
     43        for ( i; 10 ) {
     44                sout | i | add( rntl, i );
    4545        } // for
    4646}
     
    4848// Local Variables: //
    4949// tab-width: 4 //
    50 // compile-command: "cfa runningTotal.c" //
     50// compile-command: "cfa runningTotal.cfa" //
    5151// End: //
  • tests/counter.cfa

    r7951100 rb067d9b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // counter.c --
     7// counter.cfa --
    88//
    99// Author           : Aaron B. Moss
    1010// Created On       : Thu Feb 22 15:27:00 2018
    11 // Last Modified By : Aaron B. Moss
    12 // Last Modified On : Thu Feb 22 15:27:00 2018
    13 // Update Count     : 1
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue Nov  6 17:50:23 2018
     13// Update Count     : 2
    1414//
    1515
     
    3737// Local Variables: //
    3838// tab-width: 4 //
    39 // compile-command: "cfa counter.c" //
     39// compile-command: "cfa counter.cfa" //
    4040// End: //
  • tests/declarationErrors.cfa

    r7951100 rb067d9b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // declarationErrors.c --
     7// declarationErrors.cfa --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Wed Aug 17 08:23:43 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Sep  9 22:57:52 2016
    13 // Update Count     : 31
     12// Last Modified On : Tue Nov  6 17:52:47 2018
     13// Update Count     : 32
    1414//
    1515
     
    4242// Local Variables: //
    4343// tab-width: 4 //
    44 // compile-command: "cfa declarationErrors.c" //
     44// compile-command: "cfa declarationErrors.cfa" //
    4545// End: //
  • tests/declarationSpecifier.cfa

    r7951100 rb067d9b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // declarationSpecifier.c --
     7// declarationSpecifier.cfa --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Wed Aug 17 08:21:04 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 17 08:24:33 2016
    13 // Update Count     : 2
     12// Last Modified On : Tue Apr 30 18:20:36 2019
     13// Update Count     : 4
    1414//
    1515
     
    8989
    9090//Dummy main
    91 int main(int argc, char const *argv[])
    92 {
    93         return 0;
    94 }
     91int main( int argc, char const * argv[] ) {}
    9592
    9693// Local Variables: //
    9794// tab-width: 4 //
    98 // compile-command: "cfa declarationSpecifier.c" //
     95// compile-command: "cfa declarationSpecifier.cfa" //
    9996// End: //
  • tests/div.cfa

    r7951100 rb067d9b  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // div.c --
    8 // 
     6//
     7// div.cfa --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Tue Aug  8 16:28:43 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Dec  7 09:06:52 2017
    13 // Update Count     : 18
    14 // 
     12// Last Modified On : Tue Dec  4 21:35:01 2018
     13// Update Count     : 20
     14//
    1515
    16 #include <fstream>
    17 #include <stdlib>                                                                               // div
     16#include <fstream.hfa>
     17#include <stdlib.hfa>                                                                   // div
    1818
    1919struct T { int i; };
     
    2323
    2424int main( void ) {
    25         sout | "div" | div( 13, 5 ) | div( 13L, 5L ) | div( 13LL, 5LL ) | endl;
     25        sout | "div" | div( 13, 5 ) | div( 13L, 5L ) | div( 13LL, 5LL );
    2626        short s1 = 13, s2 = 5;
    27         sout | "div" | div( s1, s2 ) | endl;
     27        sout | "div" | div( s1, s2 );
    2828        T t1 = { 13 }, t2 = { 5 };
    29         sout | "div" | div( t1, t2 ) | endl;                            // polymorphic div
     29        sout | "div" | div( t1, t2 );                                           // polymorphic div
    3030} // main
    3131
    3232// Local Variables: //
    3333// tab-width: 4 //
    34 // compile-command: "cfa div.c" //
     34// compile-command: "cfa div.cfa" //
    3535// End: //
  • tests/except-0.cfa

    r7951100 rb067d9b  
    88#include <stdbool.h>
    99
    10 #include "except-mac.h"
     10#include "except-mac.hfa"
    1111TRIVIAL_EXCEPTION(yin)
    1212TRIVIAL_EXCEPTION(yang)
     
    2525void ^?{}(signal_exit * this) {
    2626        printf("Exiting: %s\n", this->area);
    27 //      sout | "Exiting:" | this->area | endl;
     27//      sout | "Exiting:" | this->area;
    2828}
    2929
  • tests/except-1.cfa

    r7951100 rb067d9b  
    55#include <stdio.h>
    66
    7 #include "except-mac.h"
     7#include "except-mac.hfa"
    88TRIVIAL_EXCEPTION(yin)
    99TRIVIAL_EXCEPTION(yang)
  • tests/except-2.cfa

    r7951100 rb067d9b  
    22
    33
    4 #include <stdlib>
    5 #include "except-mac.h"
     4#include <stdlib.hfa>
     5#include "except-mac.hfa"
    66
    77TRIVIAL_EXCEPTION(yin)
  • tests/except-3.cfa

    r7951100 rb067d9b  
    22
    33#include <stdio.h>
    4 #include "except-mac.h"
     4#include "except-mac.hfa"
    55TRIVIAL_EXCEPTION(myth)
    66
  • tests/extension.cfa

    r7951100 rb067d9b  
    22// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
    33//
    4 // extension.c --
     4// extension.cfa --
    55//
    66// Author           : Peter A. Buhr
    77// Created On       : Mon Jul  4 20:42:43 2016
    88// Last Modified By : Peter A. Buhr
    9 // Last Modified On : Mon Feb  6 15:44:39 2017
    10 // Update Count     : 46
     9// Last Modified On : Tue Nov  6 17:53:21 2018
     10// Update Count     : 47
    1111//
    1212
     
    5656// Local Variables: //
    5757// tab-width: 4 //
    58 // compile-command: "cfa extension.c" //
     58// compile-command: "cfa extension.cfa" //
    5959// End: //
  • tests/fstream_test.cfa

    r7951100 rb067d9b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // fstream_test.c --
     7// fstream_test.cfa --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug 24 11:30:26 2017
    13 // Update Count     : 65
     12// Last Modified On : Sat Dec 22 09:47:44 2018
     13// Update Count     : 68
    1414//
    1515
    16 #include <fstream>
     16#include <fstream.hfa>
    1717
    1818int main( void ) {
    1919        int nombre;
    20         sout | "Entrez un nombre, s'il vous plaît:" | endl;
     20        sout | "Entrez un nombre, s'il vous plaît:";
    2121        sin  | nombre;
    22         sout | "Vous avez entré" | nombre | endl;
     22        sout | "Vous avez entré" | nombre;
    2323        sout | "le nombre" | nombre | "est"
    24                  | (nombre > 0 ? "positif" : nombre == 0 ? "zéro" : "négatif") | endl;
     24                 | (nombre > 0 ? "positif" : nombre == 0 ? "zéro" : "négatif");
    2525
    26         sout | "Entrez trois nombres, s'il vous plaît: " | endl;
     26        sout | "Entrez trois nombres, s'il vous plaît:";
    2727        int i, j, k;
    2828        sin  | i | j | k;
    29         sout | "Vous avez entré" | "i:" | "" | i | "j:" | "" | j | "k:" | "" | k | endl;
     29        sout | "Vous avez entré" | "i:" | "" | i | "j:" | "" | j | "k:" | "" | k;
    3030}
    3131
    3232// Local Variables: //
    3333// tab-width: 4 //
    34 // compile-command: "cfa fstream_test.c" //
     34// compile-command: "cfa fstream_test.cfa" //
    3535// End: //
  • tests/function-operator.cfa

    r7951100 rb067d9b  
    1010// Created On       : Fri Aug 25 15:21:11 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Dec  7 12:42:26 2017
    13 // Update Count     : 6
     12// Last Modified On : Thu Apr 11 18:27:45 2019
     13// Update Count     : 10
    1414//
    1515
    16 #include <fstream>
    17 #include <stdlib>
     16#include <fstream.hfa>
     17#include <stdlib.hfa>
    1818
    1919#define length(array) (sizeof((array))/sizeof((array)[0]))
     
    6262
    6363// test ?()(T, ...) -- ?() with function call-by-reference
    64 forall(otype Generator, otype GenRet | { GenRet ?()(Generator &); }, dtype Iter, otype T| Iterator(Iter, T) | Assignable(T, GenRet))
     64forall(otype Generator, otype GenRet | { GenRet ?()(Generator &); }, dtype Iter, otype T | Iterator(Iter, T) | Assignable(T, GenRet))
    6565void generate(Iter first, Iter last, Generator & gen) {
    6666        int i = 0;
     
    8383// TODO: abstract over (os, T)
    8484os_wrapper ?=?(os_wrapper & wrapper, int x) {
    85         *wrapper.out | x | endl;
     85        *wrapper.out | x;
    8686        return wrapper;
    8787}
     
    9292void ?{}(ostream_iterator & iter, ofstream * out) {
    9393        iter.out = new(out);
    94                 }
     94}
    9595// no destructor, memory leak. This is necessary for this to work at the moment, since
    9696// *? requires its parameter by value and returns a reference.
     
    168168        transform(begin(x), end(x), begin(x), &times2);
    169169        copy(begin(x), end(x), out_iter);
     170
     171        // REMOVE WHEN ?* PROBLEM FIXED.
     172        delete(out_iter.out);
    170173}
    171174
  • tests/functions.cfa

    r7951100 rb067d9b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // functions.c --
     7// functions.cfa --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Wed Aug 17 08:39:58 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jan 17 22:44:12 2018
    13 // Update Count     : 12
     12// Last Modified On : Tue Nov  6 17:54:09 2018
     13// Update Count     : 13
    1414//
    1515
     
    188188// Local Variables: //
    189189// tab-width: 4 //
    190 // compile-command: "cfa functions.c" //
     190// compile-command: "cfa functions.cfa" //
    191191// End: //
  • tests/gccExtensions.cfa

    r7951100 rb067d9b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // gccExtensions.c --
     7// gccExtensions.cfa --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Sun Aug 14 17:28:17 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 17 09:26:50 2016
    13 // Update Count     : 10
     12// Last Modified On : Mon Aug  5 18:04:37 2019
     13// Update Count     : 28
    1414//
    1515
     
    5050
    5151  L1: L2:
    52         asm goto ( "frob %%r5, %1; jc %l[L1]; mov (%2), %%r5"
    53                            : /* No outputs. */
    54                            : "r"(src), "r"(&dst)
    55                            : "r5", "memory"
    56                            : L1, L2 );
     52        asm goto ( "frob %%r5, %1; jc %l[L1]; mov (%2), %%r5"
     53                           : /* No outputs. */
     54                           : "r"(src), "r"(&dst)
     55                           : "r5", "memory"
     56                           : L1, L2 );
    5757
    5858        // alternative type/qualifer names
     
    110110        struct __attribute(()) s4 { int i; } x2, y2 __attribute(());
    111111
    112         int m1 [10] __attribute(());
    113         int m2 [10][10] __attribute(());
     112        int m1[10] __attribute(());
     113        int m2[10][10] __attribute(());
    114114        int __attribute(()) m3 [10][10];
    115115//      int ( __attribute(()) m4 [10] )[10];
    116116
    117         return 0;
     117        // int128
     118
     119#if defined( __SIZEOF_INT128__ )
     120        void f128( __int128 i );
     121        void f128( __uint128_t );
     122
     123        __int128 i128_0;
     124        f128( i128_0 );
     125        unsigned __int128 i128_1;
     126        f128( i128_1 );
     127        __int128_t i128_2;
     128        f128( i128_2 );
     129        __uint128_t i128_3;
     130        f128( i128_3 );
     131#endif
    118132}
    119133
    120134// Local Variables: //
    121135// tab-width: 4 //
    122 // compile-command: "cfa gccExtensions.c" //
     136// compile-command: "cfa gccExtensions.cfa" //
    123137// End: //
  • tests/identFuncDeclarator.cfa

    r7951100 rb067d9b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // identFuncDeclarator.c --
     7// identFuncDeclarator.cfa --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Wed Aug 17 08:36:34 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jan 17 22:39:13 2018
    13 // Update Count     : 2
     12// Last Modified On : Tue Nov  6 17:56:33 2018
     13// Update Count     : 3
    1414//
    1515
     
    115115// Local Variables: //
    116116// tab-width: 4 //
    117 // compile-command: "cfa identFuncDeclarator.c" //
     117// compile-command: "cfa identFuncDeclarator.cfa" //
    118118// End: //
  • tests/identParamDeclarator.cfa

    r7951100 rb067d9b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // identParamDeclarator.c --
     7// identParamDeclarator.cfa --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Wed Aug 17 08:37:56 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jan 17 22:36:11 2018
    13 // Update Count     : 2
     12// Last Modified On : Tue Nov  6 17:56:44 2018
     13// Update Count     : 3
    1414//
    1515
     
    163163// Local Variables: //
    164164// tab-width: 4 //
    165 // compile-command: "cfa identParamDeclarator.c" //
     165// compile-command: "cfa identParamDeclarator.cfa" //
    166166// End: //
  • tests/ifwhileCtl.cfa

    r7951100 rb067d9b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // ifwhileCtl.c --
     7// ifwhileCtl.cfa --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Sat Aug 26 10:13:11 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jun  6 17:15:09 2018
    13 // Update Count     : 21
     12// Last Modified On : Tue Dec  4 21:39:18 2018
     13// Update Count     : 23
    1414//
    1515
    16 #include <fstream>
     16#include <fstream.hfa>
    1717
    1818int f( int r ) { return r; }
     
    2222
    2323        if ( int x = 1 ) {
    24                 sout | "x != 0 correct" | endl;
     24                sout | "x != 0 correct";
    2525        } else {
    26                 sout | "x == 0 incorrect" | endl;
     26                sout | "x == 0 incorrect";
    2727        } // if
    2828
    2929        if ( int x = 4, y = 0 ) {
    30                 sout | "x != 0 && y != 0 incorrect" | endl;
     30                sout | "x != 0 && y != 0 incorrect";
    3131        } else if ( int x = 4, y = 1 ) {
    32                 sout | "x != 0 && y != 0 correct" | endl;
     32                sout | "x != 0 && y != 0 correct";
    3333        } else {
    34                 sout | "x == 0 || y == 0 incorrect" | endl;
     34                sout | "x == 0 || y == 0 incorrect";
    3535        } // if
    3636
    3737        if ( int x = 5, y = f( x ); x == y ) {
    38                 sout | "x == y correct" | endl;
     38                sout | "x == y correct";
    3939        } else {
    40                 sout | "x != y incorrect" | endl;
     40                sout | "x != y incorrect";
    4141        } // if
    4242
    4343        if ( struct S { int i; } s = { 3 }; s.i < 4 ) {
    4444                S s1;
    45                 sout | "s.i < 4 correct" | endl;
     45                sout | "s.i < 4 correct";
    4646        } else {
    4747                S s1;
    48                 sout | "s.i >= 4 incorrect" | endl;
     48                sout | "s.i >= 4 incorrect";
    4949        } // if
    5050
    5151        while ( int x = 1 ) {
    52                 sout | "x != 0 correct" | endl;
     52                sout | "x != 0 correct";
    5353                break;
    5454        } // while
    5555
    5656        while ( int x = 4, y = 0 ) {
    57                 sout | "x != 0 && y != 0 incorrect" | endl;
     57                sout | "x != 0 && y != 0 incorrect";
    5858        } // while
    5959
    6060        while ( int x = 5, y = f( x ); x == y ) {
    61                 sout | "x == y correct" | endl;
     61                sout | "x == y correct";
    6262                break;
    6363        } // while
     
    6565        while ( struct S { int i; } s = { 3 }; s.i < 4 ) {
    6666                S s1;
    67                 sout | "s.i < 4 correct" | endl;
     67                sout | "s.i < 4 correct";
    6868                break;
    6969        } // while
     
    7272// Local Variables: //
    7373// tab-width: 4 //
    74 // compile-command: "cfa ifwhileCtl.c" //
     74// compile-command: "cfa ifwhileCtl.cfa" //
    7575// End: //
  • tests/labelledExit.cfa

    r7951100 rb067d9b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // labelledExit.c --
     7// labelledExit.cfa --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Wed Aug 10 07:29:39 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 10 07:30:15 2016
    13 // Update Count     : 1
     12// Last Modified On : Fri Oct 25 17:41:51 2019
     13// Update Count     : 7
    1414//
    1515
     
    6060        }
    6161
    62   D: for ( ;; ) {
     62  D: for () {
    6363                break D;
    6464                continue D;
     
    6767  Z : i += 1;
    6868        goto Z;
    69   X: Y: for ( ;; ) {
     69  X: Y: for () {
    7070                i += 1;
    7171                if ( i > 5 ) continue X;
     
    7474                break;
    7575        }
    76   XX: for ( ;; ) {
    77           YY: for ( ;; ) {
    78                   ZZ: for ( ;; ) {
     76  XX: for () {
     77          YY: for () {
     78                  ZZ: for () {
    7979                                i += 1;
    8080                                if ( i > 5 ) continue XX;
     
    8989        }
    9090
    91         for ( ;; ) ;
     91        for () ;
    9292        for ( int i = 0 ;; ) ;
    9393        for (  ; i < 0; ) ;
     
    9797  L20: L21: L22: L23: L24: L25: L26: L27: L28: L29:
    9898  L31: L32: L33: L34:
    99         for ( ;; ) {
     99        for () {
    100100                break L0;
    101101        }
     
    136136        }
    137137
     138        // all nested control options, labelled exits
     139
     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                                                        } // switch
     156                                                } // if
     157                                        } while ( true );
     158                                } // while
     159                        } // for
     160                } finally {} // always executed
     161        } // compound
     162
    138163        // computed goto
    139164        // {
     
    159184// Local Variables: //
    160185// tab-width: 4 //
    161 // compile-command: "cfa labelledExit.c" //
     186// compile-command: "cfa labelledExit.cfa" //
    162187// End: //
  • tests/limits.cfa

    r7951100 rb067d9b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // limits.c --
     7// limits.cfa --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Tue May 10 20:44:20 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar  1 16:21:55 2018
    13 // Update Count     : 7
     12// Last Modified On : Tue Nov  6 17:57:55 2018
     13// Update Count     : 8
    1414//
    1515
    16 #include <limits>
     16#include <limits.hfa>
    1717
    1818// Integral Constants
     
    153153// Local Variables: //
    154154// tab-width: 4 //
    155 // compile-command: "cfa limits.c" //
     155// compile-command: "cfa limits.cfa" //
    156156// End: //
  • tests/literals.cfa

    r7951100 rb067d9b  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // literals.c --
    8 // 
     6//
     7// literals.cfa --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Sat Sep  9 16:34:38 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Mar  4 10:41:31 2018
    13 // Update Count     : 134
    14 //
    15 
     12// Last Modified On : Tue Feb 12 08:07:39 2019
     13// Update Count     : 224
     14//
     15
     16#include <features.h>                                                                   // __GNUC_PREREQ
    1617#ifdef __CFA__
    17 #include <stdint.h>
    18 #include <fstream>
    19 
    20 void f( char v ) { sout | "char " | v | endl; }
    21 void f( signed char v ) { sout | "signed char " | v | endl; }
    22 void f( unsigned char v ) { sout | "unsigned char " | v | endl; }
    23 void f( signed short v ) { sout | "signed short int" | v | endl; }
    24 void f( unsigned short v ) { sout | "unsigned short int" | v | endl; }
    25 void f( size_t v ) { sout | "size_t" | v | endl; }
     18#include <fstream.hfa>
     19
     20void f( char v ) { sout | "char " | v; }
     21void f( signed char v ) { sout | "signed char " | v; }
     22void f( unsigned char v ) { sout | "unsigned char " | v; }
     23void f( signed short v ) { sout | "signed short int" | v; }
     24void f( unsigned short v ) { sout | "unsigned short int" | v; }
     25void f( size_t v ) { sout | "size_t" | v; }
    2626#endif // __CFA__
    2727
     
    151151        -0X0123456789.0123456789P-09;  -0X0123456789.0123456789P-09f;  -0X0123456789.0123456789P-09l;  -0X0123456789.0123456789P-09F;  -0X0123456789.0123456789P-09L;
    152152
     153#if defined(__GNUC__) && __GNUC_PREREQ(7,0)                             // gcc version >= 7
     154// floating with length, gcc f16/f128x unsupported and no prelude code for any _FloatXXx, so they work by conversion to long double
     155
     156        /*  0123456789.f16; */   0123456789.f32;   0123456789.f32x;   0123456789.f64;   0123456789.f64x;   0123456789.W;   0123456789.f128;   0123456789.q;  /*  0123456789.f128x; */
     157        /* +0123456789.f16; */  +0123456789.f32;  +0123456789.f32x;  +0123456789.f64;  +0123456789.f64x;  +0123456789.w;  +0123456789.f128;  +0123456789.Q;  /* +0123456789.f128x; */
     158        /* -0123456789.f16; */  -0123456789.f32;  -0123456789.f32x;  -0123456789.f64;  -0123456789.f64x;  -0123456789.W;  -0123456789.f128;  -0123456789.q;  /* -0123456789.f128x; */
     159
     160        /*  0123456789.e09F16; */    0123456789.e09F32;    0123456789.e09F32x;    0123456789.e09F64;    0123456789.e09F64x;    0123456789.e09W;    0123456789.e09F128;    0123456789.e09q;   /*  .0123456789e09q; */
     161        /* +0123456789.e+09F16; */  +0123456789.e+09F32;  +0123456789.e+09F32x;  +0123456789.e+09F64;  +0123456789.e+09F64x;  +0123456789.e+09w;  +0123456789.e+09F128;  +0123456789.e+09Q;  /* +.0123456789E+09Q; */
     162        /* -0123456789.e-09F16; */  -0123456789.e-09F32;  -0123456789.e-09F32x;  -0123456789.e-09F64;  -0123456789.e-09F64x;  -0123456789.e-09W;  -0123456789.e-09F128;  -0123456789.e-09q;  /* -.0123456789E-09q; */
     163
     164        /*  .0123456789e09F16; */    .0123456789e09F32;    .0123456789e09F32x;    .0123456789e09F64;    .0123456789e09F64x;    .0123456789e09W;    .0123456789e09F128;    .0123456789e09q;   /*  .0123456789e09q; */
     165        /* +.0123456789e+09F16; */  +.0123456789e+09F32;  +.0123456789e+09F32x;  +.0123456789e+09F64;  +.0123456789e+09F64x;  +.0123456789e+09w;  +.0123456789e+09F128;  +.0123456789e+09Q;  /* +.0123456789E+09Q; */
     166        /* -.0123456789e-09F16; */  -.0123456789e-09F32;  -.0123456789e-09F32x;  -.0123456789e-09F64;  -.0123456789e-09F64x;  -.0123456789e-09W;  -.0123456789e-09F128;  -.0123456789e-09q;  /* -.0123456789E-09q; */
     167
     168        /*  0123456789.0123456789F16; */   0123456789.0123456789F32;   0123456789.0123456789F32x;   0123456789.0123456789F64;   0123456789.0123456789F64x;   0123456789.0123456789W;   0123456789.0123456789F128;   0123456789.0123456789q;  /*  0123456789.0123456789q; */
     169        /* +0123456789.0123456789F16; */  +0123456789.0123456789F32;  +0123456789.0123456789F32x;  +0123456789.0123456789F64;  +0123456789.0123456789F64x;  +0123456789.0123456789w;  +0123456789.0123456789F128;  +0123456789.0123456789Q;  /* +0123456789.0123456789Q; */
     170        /* -0123456789.0123456789F16; */  -0123456789.0123456789F32;  -0123456789.0123456789F32x;  -0123456789.0123456789F64;  -0123456789.0123456789F64x;  -0123456789.0123456789W;  -0123456789.0123456789F128;  -0123456789.0123456789q;  /* -0123456789.0123456789q; */
     171
     172        /*  0123456789.0123456789E09F16; */    0123456789.0123456789E09F32;    0123456789.0123456789E09F32x;    0123456789.0123456789E09F64;    0123456789.0123456789E09F64x;    0123456789.0123456789E09W;    0123456789.0123456789E09F128;    0123456789.0123456789E09q;   /*  0123456789.0123456789E09q; */
     173        /* +0123456789.0123456789E+09F16; */  +0123456789.0123456789E+09F32;  +0123456789.0123456789E+09F32x;  +0123456789.0123456789E+09F64;  +0123456789.0123456789E+09F64x;  +0123456789.0123456789E+09w;  +0123456789.0123456789E+09F128;  +0123456789.0123456789E+09Q;  /* +0123456789.0123456789E+09Q; */
     174        /* -0123456789.0123456789E-09F16; */  -0123456789.0123456789E-09F32;  -0123456789.0123456789E-09F32x;  -0123456789.0123456789E-09F64;  -0123456789.0123456789E-09F64x;  -0123456789.0123456789E-09W;  -0123456789.0123456789E-09F128;  -0123456789.0123456789E-09q;  /* -0123456789.0123456789E-09q; */
     175
     176        /*  0x123456789.p09f16; */    0x123456789.p09f32;    0x123456789.p09f32x;    0x123456789.p09f64;    0x123456789.p09f64x;    0x123456789.p09W;    0x123456789.p09f128;    0x123456789.p09q;   /*  0x123456789.p09f128x; */
     177        /* +0x123456789.P+09f16; */  +0x123456789.P+09f32;  +0x123456789.P+09f32x;  +0x123456789.P+09f64;  +0x123456789.P+09f64x;  +0x123456789.P+09w;  +0x123456789.P+09f128;  +0x123456789.P+09Q;  /* +0x123456789.P+09f128x; */
     178        /* -0x123456789.P-09f16; */  -0x123456789.P-09f32;  -0x123456789.P-09f32x;  -0x123456789.P-09f64;  -0x123456789.P-09f64x;  -0x123456789.P-09W;  -0x123456789.P-09f128;  -0x123456789.P-09q;  /* -0x123456789.P-09f128x; */
     179
     180        /*  0x123456789.p09F16; */    0x123456789.p09F32;    0x123456789.p09F32x;    0x123456789.p09F64;    0x123456789.p09F64x;    0x123456789.p09W;    0x123456789.p09F128;    0x123456789.p09q;   /*  .0123456789p09q; */
     181        /* +0x123456789.p+09F16; */  +0x123456789.p+09F32;  +0x123456789.p+09F32x;  +0x123456789.p+09F64;  +0x123456789.p+09F64x;  +0x123456789.p+09w;  +0x123456789.p+09F128;  +0x123456789.p+09Q;  /* +.0123456789p+09Q; */
     182        /* -0x123456789.p-09F16; */  -0x123456789.p-09F32;  -0x123456789.p-09F32x;  -0x123456789.p-09F64;  -0x123456789.p-09F64x;  -0x123456789.p-09W;  -0x123456789.p-09F128;  -0x123456789.p-09q;  /* -.0123456789P-09q; */
     183
     184        /*  0X.0123456789p09F16; */    0X.0123456789p09F32;    0X.0123456789p09F32x;    0X.0123456789p09F64;    0X.0123456789p09F64x;    0X.0123456789p09W;    0X.0123456789p09F128;    0X.0123456789p09q;   /*  0X.0123456789p09q; */
     185        /* +0X.0123456789p+09F16; */  +0X.0123456789p+09F32;  +0X.0123456789p+09F32x;  +0X.0123456789p+09F64;  +0X.0123456789p+09F64x;  +0X.0123456789p+09w;  +0X.0123456789p+09F128;  +0X.0123456789p+09Q;  /* +0X.0123456789p+09Q; */
     186        /* -0X.0123456789p-09F16; */  -0X.0123456789p-09F32;  -0X.0123456789p-09F32x;  -0X.0123456789p-09F64;  -0X.0123456789p-09F64x;  -0X.0123456789p-09W;  -0X.0123456789p-09F128;  -0X.0123456789p-09q;  /* -0X.0123456789P-09q; */
     187
     188        /*  0x123456789.0123456789P09F16; */    0x123456789.0123456789P09F32;    0x123456789.0123456789P09F32x;    0x123456789.0123456789P09F64;    0x123456789.0123456789P09F64x;    0x123456789.0123456789P09W;    0x123456789.0123456789P09F128;    0x123456789.0123456789P09q;   /*  0x123456789.0123456789P09q; */
     189        /* +0x123456789.0123456789P+09F16; */  +0x123456789.0123456789P+09F32;  +0x123456789.0123456789P+09F32x;  +0x123456789.0123456789P+09F64;  +0x123456789.0123456789P+09F64x;  +0x123456789.0123456789P+09w;  +0x123456789.0123456789P+09F128;  +0x123456789.0123456789P+09Q;  /* +0x123456789.0123456789P+09Q; */
     190        /* -0x123456789.0123456789p-09F16; */  -0x123456789.0123456789p-09F32;  -0x123456789.0123456789p-09F32x;  -0x123456789.0123456789p-09F64;  -0x123456789.0123456789p-09F64x;  -0x123456789.0123456789p-09W;  -0x123456789.0123456789p-09F128;  -0x123456789.0123456789p-09q;  /* -0x123456789.0123456789p-09q; */
     191
     192        /*  0x123456789.0123456789P09F16; */    0x123456789.0123456789P09F32;    0x123456789.0123456789P09F32x;    0x123456789.0123456789P09F64;    0x123456789.0123456789P09F64x;    0x123456789.0123456789P09W;    0x123456789.0123456789P09F128;    0x123456789.0123456789P09q;   /*  0x123456789.0123456789P09q; */
     193        /* +0x123456789.0123456789p+09F16; */  +0x123456789.0123456789p+09F32;  +0x123456789.0123456789p+09F32x;  +0x123456789.0123456789p+09F64;  +0x123456789.0123456789p+09F64x;  +0x123456789.0123456789p+09w;  +0x123456789.0123456789p+09F128;  +0x123456789.0123456789p+09Q;  /* +0x123456789.0123456789p+09Q; */
     194        /* -0x123456789.0123456789P-09F16; */  -0x123456789.0123456789P-09F32;  -0x123456789.0123456789P-09F32x;  -0x123456789.0123456789P-09F64;  -0x123456789.0123456789P-09F64x;  -0x123456789.0123456789P-09W;  -0x123456789.0123456789P-09F128;  -0x123456789.0123456789P-09q;  /* -0x123456789.0123456789P-09q; */
     195#endif // __GNUC_PREREQ(7,0)
     196
    153197#ifdef __CFA__
    154198// fixed-size length
    155199
    156200        // binary
    157          0b01101011_l8;   0b01101011_l16;   0b01101011_l32;   0b01101011_l64;   0b01101011_l128;   0b01101011_l8u;   0b01101011_ul16;   0b01101011_l32u;   0b01101011_ul64;   0b01101011_ul128;
    158         +0b01101011_l8;  +0b01101011_l16;  +0b01101011_l32;  +0b01101011_l64;  +0b01101011_l128;  +0b01101011_l8u;  +0b01101011_ul16;  +0b01101011_l32u;  +0b01101011_ul64;  +0b01101011_ul128;
    159         -0b01101011_l8;  -0b01101011_l16;  -0b01101011_l32;  -0b01101011_l64;  -0b01101011_l128;  -0b01101011_l8u;  -0b01101011_ul16;  -0b01101011_l32u;  -0b01101011_ul64;  -0b01101011_ul128;
     201         0b01101011_l8;   0b01101011_l16;   0b01101011_l32;   0b01101011_l64;   0b01101011_l8u;   0b01101011_ul16;   0b01101011_l32u;   0b01101011_ul64;
     202        +0b01101011_l8;  +0b01101011_l16;  +0b01101011_l32;  +0b01101011_l64;  +0b01101011_l8u;  +0b01101011_ul16;  +0b01101011_l32u;  +0b01101011_ul64;
     203        -0b01101011_l8;  -0b01101011_l16;  -0b01101011_l32;  -0b01101011_l64;  -0b01101011_l8u;  -0b01101011_ul16;  -0b01101011_l32u;  -0b01101011_ul64;
     204
     205#ifdef __LP64__ // 64-bit processor
     206        0b01101011_l128;   0b01101011_ul128;
     207        +0b01101011_l128;  +0b01101011_ul128;
     208        -0b01101011_l128;  -0b01101011_ul128;
     209#endif // __LP64__
    160210
    161211        // octal
    162          01234567_l8;   01234567_l16;   01234567_l32;   01234567_l64;   01234567_l128;   01234567_l8u;   01234567_ul16;   01234567_l32u;   01234567_ul64;   01234567_ul128;
    163         +01234567_l8;  +01234567_l16;  +01234567_l32;  +01234567_l64;  +01234567_l128;  +01234567_l8u;  +01234567_ul16;  +01234567_l32u;  +01234567_ul64;  +01234567_ul128;
    164         -01234567_l8;  -01234567_l16;  -01234567_l32;  -01234567_l64;  -01234567_l128;  -01234567_l8u;  -01234567_ul16;  -01234567_l32u;  -01234567_ul64;  -01234567_ul128;
     212         01234567_l8;   01234567_l16;   01234567_l32;   01234567_l64;   01234567_l8u;   01234567_ul16;   01234567_l32u;   01234567_ul64;
     213        +01234567_l8;  +01234567_l16;  +01234567_l32;  +01234567_l64;  +01234567_ul8;  +01234567_ul16;  +01234567_l32u;  +01234567_ul64;
     214        -01234567_l8;  -01234567_l16;  -01234567_l32;  -01234567_l64;  -01234567_l8u;  -01234567_ul16;  -01234567_l32u;  -01234567_ul64;
     215
     216#ifdef __LP64__ // 64-bit processor
     217        01234567_l128;   01234567_ul128;
     218        +01234567_l128;  +01234567_ul128;
     219        -01234567_l128;  -01234567_ul128;
     220#endif // __LP64__
    165221
    166222        // decimal
    167          1234567890L8;   1234567890L16;   1234567890l32;   1234567890l64;   1234567890l128;   1234567890UL8;   1234567890L16U;   1234567890Ul32;   1234567890l64u;   1234567890l128u;
    168         +1234567890L8;  +1234567890L16;  +1234567890l32;  +1234567890l64;  +1234567890l128;  +1234567890UL8;  +1234567890L16U;  +1234567890Ul32;  +1234567890l64u;  +1234567890l128u;
    169         -1234567890L8;  -1234567890L16;  -1234567890l32;  -1234567890l64;  -1234567890l128;  -1234567890UL8;  -1234567890L16U;  -1234567890Ul32;  -1234567890l64u;  -1234567890l128u;
     223         1234567890L8;   1234567890L16;   1234567890l32;   1234567890l64;   1234567890UL8;   1234567890L16U;   1234567890Ul32;   1234567890l64u;
     224        +1234567890L8;  +1234567890L16;  +1234567890l32;  +1234567890l64;  +1234567890UL8;  +1234567890L16U;  +1234567890Ul32;  +1234567890l64u;
     225        -1234567890L8;  -1234567890L16;  -1234567890l32;  -1234567890l64;  -1234567890UL8;  -1234567890L16U;  -1234567890Ul32;  -1234567890l64u;
     226
     227#ifdef __LP64__ // 64-bit processor
     228        1234567890l128;   1234567890l128u;
     229        +1234567890l128;  +1234567890l128u;
     230        -1234567890l128;  -1234567890l128u;
     231#endif // __LP64__
    170232
    171233        // hexadecimal
     
    185247        +0X0123456789ABCDEF_l8;  +0X0123456789ABCDEF_l16;  +0X0123456789ABCDEFl32;  +0X0123456789ABCDEFl64;  +0X0123456789ABCDEF_ul8;  +0X0123456789ABCDEF_l16u;  +0X0123456789ABCDEFul32;  +0X0123456789ABCDEFl64u;
    186248        -0X0123456789ABCDEF_l8;  -0X0123456789ABCDEF_l16;  -0X0123456789ABCDEFl32;  -0X0123456789ABCDEFl64;  -0X0123456789ABCDEF_ul8;  -0X0123456789ABCDEF_l16u;  -0X0123456789ABCDEFul32;  -0X0123456789ABCDEFl64u;
    187 
    188         // floating
    189          0123456789.l32;   0123456789.l64;   0123456789.l80;   0123456789.l128;
    190         +0123456789.l32;  +0123456789.l64;  +0123456789.l80;  +0123456789.l128;
    191         -0123456789.l32;  -0123456789.l64;  -0123456789.l80;  -0123456789.l128;
    192 
    193          0123456789.e09L32;    0123456789.e09L64;    0123456789.e09L80;    0123456789.e09L128;
    194         +0123456789.e+09L32;  +0123456789.e+09L64;  +0123456789.e+09L80;  +0123456789.e+09L128;
    195         -0123456789.e-09L32;  -0123456789.e-09L64;  -0123456789.e-09L80;  -0123456789.e-09L128;
    196 
    197          .0123456789e09L32;    .0123456789e09L64;    .0123456789e09L80;    .0123456789e09L128;
    198         +.0123456789E+09L32;  +.0123456789E+09L64;  +.0123456789E+09L80;  +.0123456789E+09L128;
    199         -.0123456789E-09L32;  -.0123456789E-09L64;  -.0123456789E-09L80;  -.0123456789E-09L128;
    200 
    201          0123456789.0123456789L32;       0123456789.0123456789L64;       0123456789.0123456789L80;       0123456789.0123456789L128;
    202         +0123456789.0123456789E09L32;   +0123456789.0123456789E09L64;   +0123456789.0123456789E09L80;   +0123456789.0123456789E09L128;
    203         -0123456789.0123456789E+09L32;  -0123456789.0123456789E+09L64;  -0123456789.0123456789E+09L80;  -0123456789.0123456789E+09L128;
    204          0123456789.0123456789E-09L32;   0123456789.0123456789E-09L64;   0123456789.0123456789E-09L80;   0123456789.0123456789E-09L128;
    205        
    206          0x0123456789.p09l32;   0x0123456789.p09l64;   0x0123456789.p09l80;   0x0123456789.p09l128;
    207         +0x0123456789.p09l32;  +0x0123456789.p09l64;  +0x0123456789.p09l80;  +0x0123456789.p09l128;
    208         -0x0123456789.p09l32;  -0x0123456789.p09l64;  -0x0123456789.p09l80;  -0x0123456789.p09l128;
    209 
    210          0x0123456789.p+09l32;   0x0123456789.p+09L64;   0x0123456789.p+09L80;   0x0123456789.p+09L128;
    211         +0x0123456789.p-09l32;  +0x0123456789.p-09L64;  +0x0123456789.p-09L80;  +0x0123456789.p-09L128;
    212         -0x.0123456789p09l32;   -0x.0123456789p09L64;   -0x.0123456789p09L80;   -0x.0123456789p09L128;
    213249
    214250// char, short, int suffix overloading
     
    306342// Local Variables: //
    307343// tab-width: 4 //
    308 // compile-command: "cfa literals.c" //
     344// compile-command: "cfa literals.cfa" //
    309345// End: //
  • tests/math4.cfa

    r7951100 rb067d9b  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // math4.c --
    8 // 
     6//
     7// math4.cfa --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Thu May 24 20:56:54 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu May 24 20:58:06 2018
    13 // Update Count     : 2
    14 // 
     12// Last Modified On : Tue Dec  4 18:15:01 2018
     13// Update Count     : 4
     14//
    1515
    16 #include <fstream>
    17 #include <math>
     16#include <fstream.hfa>
     17#include <math.hfa>
    1818
    1919int main( void ) {
     
    2424        //---------------------- Nearest Integer ----------------------
    2525
    26         sout | "floor:" | floor( 1.2F ) | floor( 1.2D ) | floor( 1.2L ) | endl;
    27         sout | "ceil:" | ceil( 1.6F ) | ceil( 1.6D ) | ceil( 1.6L ) | endl;
    28         sout | "trunc:" | trunc( 3.5F ) | trunc( 3.5D ) | trunc( 3.5L ) | endl;
    29         sout | "rint:" | (float)rint( 1.5F ) | (double)rint( 1.5D ) | (long double)rint( 1.5L ) | endl;
    30         sout | "rint:" | (long int)rint( 1.5F ) | (long int)rint( 1.5D ) | (long int)rint( 1.5L ) | endl;
    31         sout | "rint:" | (long long int)rint( 1.5F ) | (long long int)rint( 1.5D ) | (long long int)rint( 1.5L ) | endl;
    32         sout | "lrint:" | lrint( 1.5F ) | lrint( 1.5D ) | lrint( 1.5L ) | endl;
    33         sout | "llrint:" | llrint( 1.5F ) | llrint( 1.5D ) | llrint( 1.5L ) | endl;
    34         sout | "nearbyint:" | nearbyint( 3.5F ) | nearbyint( 3.5D ) | nearbyint( 3.5L ) | endl;
    35         sout | "round:" | (float)round( 1.5F ) | (double)round( 1.5D ) | (long double)round( 1.5L ) | endl;
    36         sout | "round:" | (long int)round( 1.5F ) | (long int)round( 1.5D ) | (long int)round( 1.5L ) | endl;
    37         sout | "round:" | (long long int)round( 1.5F ) | (long long int)round( 1.5D ) | (long long int)round( 1.5L ) | endl;
    38         sout | "lround:" | lround( 1.5F ) | lround( 1.5D ) | lround( 1.5L ) | endl;
    39         sout | "llround:" | llround( 1.5F ) | llround( 1.5D ) | llround( 1.5L ) | endl;
     26        sout | "floor:" | floor( 1.2F ) | floor( 1.2D ) | floor( 1.2L );
     27        sout | "ceil:" | ceil( 1.6F ) | ceil( 1.6D ) | ceil( 1.6L );
     28        sout | "trunc:" | trunc( 3.5F ) | trunc( 3.5D ) | trunc( 3.5L );
     29        sout | "rint:" | (float)rint( 1.5F ) | (double)rint( 1.5D ) | (long double)rint( 1.5L );
     30        sout | "rint:" | (long int)rint( 1.5F ) | (long int)rint( 1.5D ) | (long int)rint( 1.5L );
     31        sout | "rint:" | (long long int)rint( 1.5F ) | (long long int)rint( 1.5D ) | (long long int)rint( 1.5L );
     32        sout | "lrint:" | lrint( 1.5F ) | lrint( 1.5D ) | lrint( 1.5L );
     33        sout | "llrint:" | llrint( 1.5F ) | llrint( 1.5D ) | llrint( 1.5L );
     34        sout | "nearbyint:" | nearbyint( 3.5F ) | nearbyint( 3.5D ) | nearbyint( 3.5L );
     35        sout | "round:" | (float)round( 1.5F ) | (double)round( 1.5D ) | (long double)round( 1.5L );
     36        sout | "round:" | (long int)round( 1.5F ) | (long int)round( 1.5D ) | (long int)round( 1.5L );
     37        sout | "round:" | (long long int)round( 1.5F ) | (long long int)round( 1.5D ) | (long long int)round( 1.5L );
     38        sout | "lround:" | lround( 1.5F ) | lround( 1.5D ) | lround( 1.5L );
     39        sout | "llround:" | llround( 1.5F ) | llround( 1.5D ) | llround( 1.5L );
    4040
    4141        //---------------------- Manipulation ----------------------
    4242
    43         sout | "copysign:" | copysign( 1.0F, -1.0F ) | copysign( 1.0D, -1.0D ) | copysign( 1.0L, -1.0L ) | endl;
     43        sout | "copysign:" | copysign( 1.0F, -1.0F ) | copysign( 1.0D, -1.0D ) | copysign( 1.0L, -1.0L );
    4444        int exp;
    4545        f = frexp( 4.0F, &exp );
    46         sout | "frexp:" | f | exp;
     46        sout | "frexp:" | f | exp | nonl;
    4747        d = frexp( 4.0D, &exp );
    48         sout | d | exp;
     48        sout | d | exp | nonl;
    4949        l = frexp( 4.0L, &exp );
    50         sout | l | exp | endl;
    51         sout | "ldexp:" | ldexp( 2.0F, 2 ) | ldexp( 2.0D, 2 ) | ldexp( 2.0L, 2 ) | endl;
     50        sout | l | exp;
     51        sout | "ldexp:" | ldexp( 2.0F, 2 ) | ldexp( 2.0D, 2 ) | ldexp( 2.0L, 2 );
    5252        float fi;
    5353        double di;
    5454        long double ldi;
    5555        f = modf( 2.3F, &fi );
    56         sout | "modf:" | fi | f;
     56        sout | "modf:" | fi | f | nonl;
    5757        d = modf( 2.3D, &di );
    58         sout | di | d;
     58        sout | di | d | nonl;
    5959        l = modf( 2.3L, &ldi );
    60         sout | ldi | l | endl;
    61         sout | "modf:" | modf( 2.3F ) | modf( 2.3D ) | modf( 2.3L ) | endl;
    62         sout | "nextafter:" | nextafter( 2.0F, 3.0F ) | nextafter( 2.0D, 3.0D ) | nextafter( 2.0L, 3.0L ) | endl;
    63         sout | "nexttoward:" | nexttoward( 2.0F, 3.0F ) | nexttoward( 2.0D, 3.0D ) | nexttoward( 2.0L, 3.0L ) | endl;
     60        sout | ldi | l;
     61        sout | "modf:" | modf( 2.3F ) | modf( 2.3D ) | modf( 2.3L );
     62        sout | "nextafter:" | nextafter( 2.0F, 3.0F ) | nextafter( 2.0D, 3.0D ) | nextafter( 2.0L, 3.0L );
     63        sout | "nexttoward:" | nexttoward( 2.0F, 3.0F ) | nexttoward( 2.0D, 3.0D ) | nexttoward( 2.0L, 3.0L );
    6464
    65         sout | "scalbn:" | scalbn( 2.0F, 3 ) | scalbn( 2.0D, 3 ) | scalbn( 2.0L, 3 ) | endl;
    66         sout | "scalbln:" | scalbln( 2.0F, 3L ) | scalbln( 2.0D, 3L ) | scalbln( 2.0L, 3L ) | endl;
     65        sout | "scalbn:" | scalbn( 2.0F, 3 ) | scalbn( 2.0D, 3 ) | scalbn( 2.0L, 3 );
     66        sout | "scalbln:" | scalbln( 2.0F, 3L ) | scalbln( 2.0D, 3L ) | scalbln( 2.0L, 3L );
    6767} // main
    6868
    6969// Local Variables: //
    7070// tab-width: 4 //
    71 // compile-command: "cfa math3.c" //
     71// compile-command: "cfa math3.cfa" //
    7272// End: //
  • tests/maybe.cfa

    r7951100 rb067d9b  
    1515
    1616#include <assert.h>
    17 #include <containers/maybe>
     17#include <containers/maybe.hfa>
    1818
    1919void checkPredicates() {
  • tests/minmax.cfa

    r7951100 rb067d9b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // minmax.c --
     7// minmax.cfa --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Apr 10 17:29:09 2018
    13 // Update Count     : 50
     12// Last Modified On : Tue Dec  4 21:45:31 2018
     13// Update Count     : 52
    1414//
    1515
    16 #include <fstream>
    17 #include <stdlib>                                                                               // min, max
     16#include <fstream.hfa>
     17#include <stdlib.hfa>                                                                           // min, max
    1818
    1919int main( void ) {
     
    2222        int ?>?( char op1, char op2 ) { return (int)op1 > (int)op2; }
    2323
    24         sout | "char\t\t\t"                                     | 'z' | ' ' | 'a' | "\tmin " | min( 'z', 'a' ) | endl;
    25         sout | "signed int\t\t"                         | 4 | 3 | "\tmin" | min( 4, 3 ) | endl;
    26         sout | "unsigned int\t\t"                       | 4u | 3u | "\tmin" | min( 4u, 3u ) | endl;
    27         sout | "signed long int\t\t"            | 4l | 3l | "\tmin" | min( 4l, 3l ) | endl;
    28         sout | "unsigned long int\t"            | 4ul | 3ul | "\tmin" | min( 4ul, 3ul ) | endl;
    29         sout | "signed long long int\t"         | 4ll | 3ll | "\tmin" | min( 4ll, 3ll ) | endl;
    30         sout | "unsigned long long int\t"       | 4ull | 3ull | "\tmin" | min( 4ull, 3ull ) | endl;
    31         sout | "float\t\t\t"                            | 4.0f | 3.1f | "\tmin" | min( 4.0f, 3.1f ) | endl;
    32         sout | "double\t\t\t"                           | 4.0 | 3.1 | "\tmin" | min( 4.0, 3.1 ) | endl;
    33         sout | "long double\t\t"                        | 4.0l | 3.1l | "\tmin" | min( 4.0l, 3.1l ) | endl;
     24        sout | "char\t\t\t"                                     | 'z' | ' ' | 'a' | "\tmin " | min( 'z', 'a' );
     25        sout | "signed int\t\t"                         | 4 | 3 | "\tmin" | min( 4, 3 );
     26        sout | "unsigned int\t\t"                       | 4u | 3u | "\tmin" | min( 4u, 3u );
     27        sout | "signed long int\t\t"            | 4l | 3l | "\tmin" | min( 4l, 3l );
     28        sout | "unsigned long int\t"            | 4ul | 3ul | "\tmin" | min( 4ul, 3ul );
     29        sout | "signed long long int\t"         | 4ll | 3ll | "\tmin" | min( 4ll, 3ll );
     30        sout | "unsigned long long int\t"       | 4ull | 3ull | "\tmin" | min( 4ull, 3ull );
     31        sout | "float\t\t\t"                            | 4.0f | 3.1f | "\tmin" | min( 4.0f, 3.1f );
     32        sout | "double\t\t\t"                           | 4.0 | 3.1 | "\tmin" | min( 4.0, 3.1 );
     33        sout | "long double\t\t"                        | 4.0l | 3.1l | "\tmin" | min( 4.0l, 3.1l );
    3434
    35         sout | endl;
     35        sout | nl;
    3636
    37         sout | "char\t\t\t"                                     | 'z' | ' ' | 'a' | "\tmax " | max( 'z', 'a' ) | endl;
    38         sout | "signed int\t\t"                         | 4 | 3 | "\tmax" | max( 4, 3 ) | endl;
    39         sout | "unsigned int\t\t"                       | 4u | 3u | "\tmax" | max( 4u, 3u ) | endl;
    40         sout | "signed long int\t\t"            | 4l | 3l | "\tmax" | max( 4l, 3l ) | endl;
    41         sout | "unsigned long int\t"            | 4ul | 3ul | "\tmax" | max( 4ul, 3ul ) | endl;
    42         sout | "signed long long int\t"         | 4ll | 3ll | "\tmax" | max( 4ll, 3ll ) | endl;
    43         sout | "unsigned long long int\t"       | 4ull | 3ull | "\tmax" | max( 4ull, 3ull ) | endl;
    44         sout | "float\t\t\t"                            | 4.0f | 3.1f | "\tmax" | max( 4.0f, 3.1f ) | endl;
    45         sout | "double\t\t\t"                           | 4.0 | 3.1 | "\tmax" | max( 4.0, 3.1 ) | endl;
    46         sout | "long double\t\t"                        | 4.0l | 3.1l | "\tmax" | max( 4.0l, 3.1l ) | endl;
     37        sout | "char\t\t\t"                                     | 'z' | ' ' | 'a' | "\tmax " | max( 'z', 'a' );
     38        sout | "signed int\t\t"                         | 4 | 3 | "\tmax" | max( 4, 3 );
     39        sout | "unsigned int\t\t"                       | 4u | 3u | "\tmax" | max( 4u, 3u );
     40        sout | "signed long int\t\t"            | 4l | 3l | "\tmax" | max( 4l, 3l );
     41        sout | "unsigned long int\t"            | 4ul | 3ul | "\tmax" | max( 4ul, 3ul );
     42        sout | "signed long long int\t"         | 4ll | 3ll | "\tmax" | max( 4ll, 3ll );
     43        sout | "unsigned long long int\t"       | 4ull | 3ull | "\tmax" | max( 4ull, 3ull );
     44        sout | "float\t\t\t"                            | 4.0f | 3.1f | "\tmax" | max( 4.0f, 3.1f );
     45        sout | "double\t\t\t"                           | 4.0 | 3.1 | "\tmax" | max( 4.0, 3.1 );
     46        sout | "long double\t\t"                        | 4.0l | 3.1l | "\tmax" | max( 4.0l, 3.1l );
    4747} // main
    4848
    4949// Local Variables: //
    5050// tab-width: 4 //
    51 // compile-command: "cfa minmax.c" //
     51// compile-command: "cfa minmax.cfa" //
    5252// End: //
  • tests/numericConstants.cfa

    r7951100 rb067d9b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // numericConstants.c --
     7// numericConstants.cfa --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Wed May 24 22:10:36 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 24 22:11:36 2017
    13 // Update Count     : 2
     12// Last Modified On : Tue Feb  5 08:58:16 2019
     13// Update Count     : 5
    1414//
    1515
     
    6767// Local Variables: //
    6868// tab-width: 4 //
    69 // compile-command: "cfa minmax.c" //
     69// compile-command: "cfa numericConstants.cfa" //
    7070// End: //
  • tests/polymorphism.cfa

    r7951100 rb067d9b  
    99// Author           : Rob Schluntz
    1010// Created On       : Tue Oct 17 12:19:48 2017
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Tue Oct 17 12:21:07 2017
    13 // Update Count     : 1
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue Dec 25 14:40:24 2018
     13// Update Count     : 3
    1414//
    1515
    1616#include <assert.h>
    1717#include <inttypes.h>
     18#include <fstream.hfa>
    1819
    1920forall(otype T)
     
    6162                int y = 456;
    6263                int z = f(x, y);
    63                 printf("%d %d %d\n", x, y, z);
     64                sout | x | y | z;
    6465        }
    65 
    6666        {
    6767                // explicitly specialize function
    6868                int (*f)(int) = ident;
    6969                ((int(*)(int))ident);
    70                 printf("%d %d\n", f(5), ((int(*)(int))ident)(5));
     70                sout | f(5) | ((int(*)(int))ident)(5);
    7171        }
    72 
    7372        {
    7473                // test aggregates with polymorphic members
     
    10099
    101100                void print(x_type x) {
    102                         printf("%"PRIu32"\n", x);
     101                        sout | x;
    103102                }
    104103
    105104                void print(y_type y) {
    106                         printf("%"PRIu64"\n", y);
     105                        sout | y;
    107106                }
    108107
  • tests/pybin/test_run.py

    r7951100 rb067d9b  
    44
    55import pybin.settings
    6 import datetime
    7 
    8 from string import Template
    9 
    10 class DeltaTemplate(Template):
    11     delimiter = "%"
    12 
    13 def strfdelta(tdelta, fmt):
    14     d["H"], rem = divmod(tdelta.seconds, 3600)
    15     d["M"], d["S"] = divmod(rem, 60)
    16     t = DeltaTemplate(fmt)
    17     return t.substitute(**d)
    186
    197# Test class that defines what a test is
     
    2816
    2917        def prepare(self):
    30                 sh("mkdir -p %s" % os.path.join(self.path, '.err'))
    31                 sh("mkdir -p %s" % os.path.join(self.path, '.out'))
    32                 sh("mkdir -p %s" % os.path.join(self.path, '.in' ))
     18                mkdir( (self.output_log(), self.error_log(), self.input()            ) )
     19                rm   ( (self.output_log(), self.error_log(), self.target_executable()) )
    3320
    3421        def expect(self):
    35                 return ("%s/.expect/%s%s.txt" % (self.path, self.name, '' if not self.arch else ".%s" % self.arch))
     22                return os.path.normpath( os.path.join(settings.SRCDIR  , self.path, ".expect", "%s%s.txt" % (self.name,'' if not self.arch else ".%s" % self.arch)) )
    3623
    3724        def error_log(self):
    38                 return ("%s/.err/%s.log"    % (self.path, self.name))
     25                return os.path.normpath( os.path.join(settings.BUILDDIR, self.path, ".err"   , "%s.log" % self.name) )
    3926
    4027        def output_log(self):
    41                 return ("%s/.out/%s.log"    % (self.path, self.name))
     28                return os.path.normpath( os.path.join(settings.BUILDDIR, self.path, ".out"   , "%s.log" % self.name) )
    4229
    4330        def input(self):
    44                 return ("%s/.in/%s.txt"     % (self.path, self.name))
     31                return os.path.normpath( os.path.join(settings.SRCDIR  , self.path, ".in"    , "%s.txt" % self.name) )
    4532
    4633        def target_output(self):
     
    4835
    4936        def target(self):
    50                 return os.path.join(self.path, self.name)
     37                return os.path.normpath( os.path.join(self.path, self.name) )
     38
     39        def target_executable(self):
     40                return os.path.normpath( os.path.join(settings.BUILDDIR, self.path, self.name) )
    5141
    5242        @classmethod
     
    5848                test = Test()
    5949                test.name = os.path.basename(target)
    60                 test.path = os.path.dirname (target)
    61                 test.arch = settings.arch.toString() if settings.arch.cross_compile else ''
     50                test.path = os.path.relpath (os.path.dirname(target), settings.SRCDIR)
     51                test.arch = settings.arch.target if settings.arch.cross_compile else ''
    6252                return test
    6353
  • tests/quotedKeyword.cfa

    r7951100 rb067d9b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // quoted_keyword.c -- test quoted keyword usage
     7// quotedKeyword.cfa -- test quoted keyword usage
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun 30 14:03:59 2016
    13 // Update Count     : 19
     12// Last Modified On : Tue Dec  4 21:45:53 2018
     13// Update Count     : 23
    1414//
    1515
    16 #include <fstream>
     16#include <fstream.hfa>
    1717
    1818struct {
     
    4141        st.`struct` = 3;
    4242        `throw` = 4;
    43         sout | `catch` + st.`otype` + st.`struct` + `throw` | endl;
     43        sout | `catch` + st.`otype` + st.`struct` + `throw`;
    4444}
    4545
    4646// Local Variables: //
    4747// tab-width: 4 //
    48 // compile-command: "cfa quoted_keyword.c" //
     48// compile-command: "cfa quotedKeyword.cfa" //
    4949// End: //
  • tests/raii/.expect/ctor-autogen-ERR1.txt

    r7951100 rb067d9b  
    1 raii/ctor-autogen.c:102:1 error: Unique best alternative includes deleted identifier in Cast of:
     1raii/ctor-autogen.cfa:102:1 error: Unique best alternative includes deleted identifier in Generated Cast of:
    22  Application of
    33    Deleted Expression
    44      Variable Expression: ?{}: static inline function
    55      ... with parameters
    6         _dst: reference to instance of struct Managed with body 1 
     6        _dst: reference to instance of struct Managed with body 1
    77        x: signed int
    8       ... returning nothing 
     8      ... returning nothing
    99
    1010      ... deleted by: ?{}: function
    1111      ... with parameters
    12         m: reference to instance of struct Managed with body 1 
    13       ... returning nothing 
    14       ... with body 
     12        m: reference to instance of struct Managed with body 1
     13      ... returning nothing
     14      ... with body
    1515        CompoundStmt
    1616          Expression Statement:
     
    2020                intrinsic reference to signed int
    2121                intrinsic signed int
    22               ... returning 
     22              ... returning
    2323                _retval__operator_assign: signed int
    24                 ... with attributes: 
     24                ... with attributes:
    2525                  Attribute with name: unused
    2626
    2727
    2828            ... to arguments
    29               Cast of:
    30                 Member Expression, with field: 
     29              Generated Cast of:
     30                Member Expression, with field:
    3131                  x: signed int
    32                 ... from aggregate: 
    33                   Cast of:
    34                     Variable Expression: m: reference to instance of struct Managed with body 1 
     32                ... from aggregate:
     33                  Generated Cast of:
     34                    Variable Expression: m: reference to instance of struct Managed with body 1
    3535                  ... to:
    36                     instance of struct Managed with body 1 
     36                    instance of struct Managed with body 1
    3737              ... to:
    3838                reference to signed int
    39               Cast of:
     39              Generated Cast of:
    4040                constant expression (0 0: zero_t)
    4141              ... to:
     
    4848
    4949  ... to arguments
    50     Cast of:
    51       Variable Expression: x: instance of struct Managed with body 1 
     50    Generated Cast of:
     51      Variable Expression: x: instance of struct Managed with body 1
    5252    ... to:
    53       reference to instance of struct Managed with body 1 
     53      reference to instance of struct Managed with body 1
    5454    constant expression (123 123: signed int)
    5555
  • tests/raii/dtor-early-exit.cfa

    r7951100 rb067d9b  
    1010// Created On       : Wed Aug 17 08:26:25 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 17 08:29:37 2016
    13 // Update Count     : 2
    14 //
    15 
    16 #include <fstream>
    17 #include <stdlib>
    18 extern "C" {
    19 #define false ((int)0)  // until stdbool.h works
    20 #define assert(cond) if (! (cond)) { sout | "Assertion failed: (" | #cond | ") at " __FILE__ | ":" | __LINE__ | endl; abort(); }
    21 }
     12// Last Modified On : Fri Dec 21 08:45:19 2018
     13// Update Count     : 10
     14//
     15
     16#include <fstream.hfa>
     17#include <stdlib.hfa>
     18#include <assert.h>
    2219
    2320struct A {
     
    2825// don't want these called
    2926void ?{}(A & a) { assert( false ); }
    30 void ?{}(A & a, const char * name) { a.name = name; sout | "construct " | name | endl; a.x = (int*)malloc(); }
     27void ?{}(A & a, const char * name) { a.name = name; sout | "construct " | name; a.x = (int*)malloc(); }
    3128void ?{}(A & a, const char * name, int * ptr) { assert( false ); }
    3229
    3330A ?=?(A & a, A b) {  sout | "assign " | a.name | " " | b.name; return a; }
    34 void ?{}(A & a, A b) { sout | "copy construct " | b.name | endl; a.x = (int*)malloc(); }
    35 void ^?{}(A & a) { sout | "destruct " | a.name | endl; free(a.x); }
     31void ?{}(A & a, A b) { sout | "copy construct " | b.name; a.x = (int*)malloc(); }
     32void ^?{}(A & a) { sout | "destruct " | a.name; free(a.x); }
    3633
    3734// test returns
    3835void f(int i) {
    39         sout | "f i=" | i | endl;
     36        sout | "f i=" | i;
    4037        A x = { "x" };  // construct x
    4138        {
     
    5855void g() {
    5956        for (int i = 0; i < 10; i++) {
    60                 sout | "g for i=" | i | endl;
     57                sout | "g for i=" | i;
    6158                A x = { "x" };
    6259                // construct x
    6360                // destruct x
    6461        }
    65         sout | endl;
     62        sout | nl;
    6663        {
    6764                int i = 0;
    6865                while (i < 10) {
    69                         sout | "g while i=" | i | endl;
     66                        sout | "g while i=" | i;
    7067                        A x = { "x" };
    7168                        // construct x
     
    7471                }
    7572        }
    76         sout | endl;
     73        sout | nl;
    7774        for (int i = 0; i < 10; i++) {
    7875                switch(10) {
     
    8178                        case 10: {
    8279                                A y = { "y" };
    83                                 sout | "g switch i=" | i | endl;
     80                                sout | "g switch i=" | i;
    8481                                // construct y
    8582                                break; // destruct y
    8683                        }
    8784                        default: {
    88                                 sout | "g switch i=" | i | endl;
     85                                sout | "g switch i=" | i;
    8986                                A x = { "x" };
    9087                                // construct x
     
    9390                }
    9491        }
    95         sout | endl;
     92        sout | nl;
    9693        for (int k = 0; k < 2; k++) {
    97                 sout | "g for k=" | k | endl;
     94                sout | "g for k=" | k;
    9895                L1: for (int i = 0; i < 10; i++) {
    99                         sout | "g for i=" | i | endl;
     96                        sout | "g for i=" | i;
    10097
    10198                        A x = { "x" };
    10299                        if (i == 2) {
    103                                 sout | "continue L1" | endl;
     100                                sout | "continue L1";
    104101                                continue;  // destruct x
    105102                        } else if (i == 3) {
    106                                 sout | "break L1" | endl;
     103                                sout | "break L1";
    107104                                break;  // destruct x
    108105                        }
    109106
    110107                        L2: for (int j = 0; j < 10; j++) {
    111                                 sout | "g for j=" | j | endl;
     108                                sout | "g for j=" | j;
    112109                                A y = { "y" };
    113110                                if (j == 0) {
    114                                         sout | "continue L2" | endl;
     111                                        sout | "continue L2";
    115112                                        continue; // destruct y - missing because object that needs to be destructed is not a part of this block, it's a part of the for's block
    116113                                } else if (j == 1) {
    117                                         sout | "break L2" | endl;
     114                                        sout | "break L2";
    118115                                        break;  // destruct y
    119116                                } else if (i == 1) {
    120                                         sout | "continue L1" | endl;
     117                                        sout | "continue L1";
    121118                                        continue L1; // destruct x,y - note: continue takes you to destructors for block, so only generate destructor for y
    122119                                } else if (k == 1) {
    123                                         sout | "break L1" | endl;
     120                                        sout | "break L1";
    124121                                        break L1;  // destruct x,y
    125122                                }
     
    128125        }
    129126
    130         sout | endl;
     127        sout | nl;
    131128        L3: if( 3 ) {
    132129                A w = { "w" };
    133130                if( 4 ) {
    134131                        A v = { "v" };
    135                         sout | "break L3" | endl;
     132                        sout | "break L3";
    136133                        break L3;
    137134                }
     
    147144        // * if S_L-S_G is non-empty, error
    148145        // * emit destructors for all variables in S_G-S_L
    149         sout | "h" | endl;
     146        sout | "h";
    150147        {
    151148                L0: ;
     
    155152                        A y = { "y" };
    156153                        // S_L1 = { y }
    157                 L1: sout | "L1" | endl;
     154                L1: sout | "L1";
    158155                        A x = { "x" };
    159156                        // S_L2 = { y, x }
    160                 L2: sout | "L2" | endl;
     157                L2: sout | "L2";
    161158                        if (i == 0) {
    162159                                ++i;
    163                                 sout | "goto L1" | endl;
     160                                sout | "goto L1";
    164161                                // S_G = { y, x }
    165162                                goto L1;  // jump back, destruct b/c before x definition
     
    168165                        } else if (i == 1) {
    169166                                ++i;
    170                                 sout | "goto L2" | endl;
     167                                sout | "goto L2";
    171168                                // S_G = { y, x }
    172169                                goto L2;  // jump back, do not destruct
     
    175172                        } else if (i == 2) {
    176173                                ++i;
    177                                 sout | "goto L3" | endl;
     174                                sout | "goto L3";
    178175                                // S_G = { y, x }
    179176                                goto L3;  // jump ahead, do not destruct
     
    183180                                ++i;
    184181                                A z = { "z" };
    185                                 sout | "goto L3-2" | endl;
     182                                sout | "goto L3-2";
    186183                                // S_G = { z, y, x }
    187184                                goto L3;
     
    190187                        } else {
    191188                                ++i;
    192                                 sout | "goto L4" | endl;
     189                                sout | "goto L4";
    193190                                // S_G = { y, x }
    194191                                goto L4;  // jump ahead, destruct b/c left block x was defined in
     
    197194                        }
    198195                        // S_L3 = { y, x }
    199                 L3: sout | "L3" | endl;
    200                         sout | "goto L2-2" | endl;
     196                L3: sout | "L3";
     197                        sout | "goto L2-2";
    201198                        // S_G = { y, x }
    202199                        goto L2; // jump back, do not destruct
     
    205202        }
    206203        // S_L4 = {}
    207         L4: sout | "L4" | endl;
     204        L4: sout | "L4";
    208205        if (i == 4) {
    209                 sout | "goto L0" | endl;
     206                sout | "goto L0";
    210207                // S_G = {}
    211208                goto L0;
     
    243240                f(i);
    244241        }
    245         sout | endl;
     242        sout | nl;
    246243        g();
    247         sout | endl;
     244        sout | nl;
    248245        h();
    249246
  • tests/raii/globals.cfa

    r7951100 rb067d9b  
    1 #include <fstream>
     1#include <fstream.hfa>
    22
    33struct value_t {
     
    7070
    7171int main() {
    72         sout | "static\t\tinline\t\tautogen\t\tvalue" | endl;
     72        sout | "static\t\tinline\t\tautogen\t\tvalue";
    7373
    74         sout | "no \t\tno \t\tno \t\t" | g.val.value    | endl;
    75         sout | "no \t\tno \t\tyes\t\t" | ga.val.value   | endl;
    76         sout | "no \t\tyes\t\tno \t\t" | gi.val.value   | endl;
    77         sout | "no \t\tyes\t\tyes\t\t" | gia.val.value  | endl;
    78         sout | "yes\t\tno \t\tno \t\t" | gs.val.value   | endl;
    79         sout | "yes\t\tno \t\tyes\t\t" | gsa.val.value  | endl;
    80         sout | "yes\t\tyes\t\tno \t\t" | gsi.val.value  | endl;
    81         sout | "yes\t\tyes\t\tyes\t\t" | gsia.val.value | endl;
     74        sout | "no \t\tno \t\tno \t\t" | g.val.value;
     75        sout | "no \t\tno \t\tyes\t\t" | ga.val.value;
     76        sout | "no \t\tyes\t\tno \t\t" | gi.val.value;
     77        sout | "no \t\tyes\t\tyes\t\t" | gia.val.value;
     78        sout | "yes\t\tno \t\tno \t\t" | gs.val.value;
     79        sout | "yes\t\tno \t\tyes\t\t" | gsa.val.value;
     80        sout | "yes\t\tyes\t\tno \t\t" | gsi.val.value;
     81        sout | "yes\t\tyes\t\tyes\t\t" | gsia.val.value;
    8282
    8383}
  • tests/raii/init_once.cfa

    r7951100 rb067d9b  
    1010// Created On       : Tue Jun 14 15:43:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul  9 11:30:29 2016
    13 // Update Count     : 3
     12// Last Modified On : Fri Mar 22 13:41:26 2019
     13// Update Count     : 4
    1414//
    1515
     
    192192// Local Variables: //
    193193// tab-width: 4 //
    194 // compile-command: "cfa init_once.c" //
     194// compile-command: "cfa init_once.cfa" //
    195195// End: //
  • tests/raii/memberCtors.cfa

    r7951100 rb067d9b  
    11struct WrappedInt {
    22  int x;
     3  int id;
    34};
     5int intID = 0;
    46
    57void ?{}(WrappedInt & this) {
    6   printf("constructing int\n");
     8  this.id = intID++;
     9  printf("constructing int id: %d\n", this.id);
    710  this.x = 0;
    811}
    912
    1013void ?{}(WrappedInt & this, WrappedInt other) {
    11   printf("copy constructing int: %d\n", other.x);
     14  this.id = intID++;
     15  printf("copy constructing int: %d id: %d\n", other.x, this.id);
    1216  this.x = other.x;
    1317}
    1418
    1519void ?{}(WrappedInt & this, int x) {
    16   printf("constructing int: %d\n", x);
     20  this.id = intID++;
     21  printf("constructing int: %d id: %d\n", x, this.id);
    1722  this.x = x;
    1823}
    1924
    2025void ^?{}(WrappedInt & this) {
    21   printf("destructing int: %d\n", this.x);
     26  printf("destructing int: %d id: %d\n", this.x, this.id);
    2227}
    2328
    24 void ?=?(WrappedInt & this, int x) {
    25   printf("assigning int: %d %d\n", this.x, x);
     29/* WrappedInt */ void ?=?(WrappedInt & this, int x) {
     30  printf("assigning int: %d %d id: %d\n", this.x, x, this.id);
    2631  this.x = x;
     32  // return this;
    2733}
     34
     35// WrappedInt ?=?(WrappedInt & this, WrappedInt other) {
     36//   printf("assigning int: %d %d\n", this.x, other.x);
     37//   this.x = other.x;
     38//   return this;
     39// }
    2840
    2941struct A {
    3042  WrappedInt x, y, z;
     43  int id;
    3144};
     45int AID = 0;
    3246
    3347void ?{}(A & a) {
    3448  // currently must define default ctor, since there's no "= default" syntax
     49  a.id = AID++;
     50  printf("default construct A %d\n", a.id);
    3551}
    3652
    3753void ?{}(A & a, int x) {
    38   printf("begin construct A\n");
     54  a.id = AID++;
     55  printf("begin construct A id: %d\n", a.id);
    3956  printf("construct a.x\n");
    4057  (a.x){ x+999 };
     
    4562
    4663void ?{}(A & this, A other) {
    47   printf("begin copy construct A\n");
     64  this.id = AID++;
     65  printf("begin copy construct A id: %d\n", this.id);
    4866  printf("copy construct this.x\n");
    4967  (this.x){ other.x };
     
    5472
    5573A ?=?(A & this, A other) {
    56   printf("begin ?=? A\n");
     74  printf("begin ?=? A id: %d\n", this.id);
    5775  this.x = other.x;
    5876  this.y = other.y;
     
    6482struct B {
    6583  A a1, a2, a3;
     84  int id;
    6685};
     86int BID = 0;
    6787
    6888void ?{}(B & b) {
    69   printf("begin construct B\n");
     89  b.id = BID++;
     90  printf("begin construct B id: %d\n", b.id);
    7091  printf("assign b.a2\n");
    7192  b.a2 = (A) { 2 };
     
    79100
    80101void ^?{}(B & b) {
     102  b.id = BID++;
     103  printf("begin destruct B id: %d\n", b.id);
    81104  b.a2 = (A) { 0 };
    82105  ^(b.a1){};
     106  printf("end destruct B\n");
    83107} // a2, a3 never destructed - will be automatically destructed
    84108
    85109int main() {
    86110  printf("Before declaration of b1\n");
    87   B b1;
     111  B b1;  // b1 = { { 1000, 0, 0 }, { 1001, 0, 0 }, { 0, 0, 0 } }
    88112  printf("Before declaration of b2\n");
    89113  B b2 = b1;
  • tests/random.cfa

    r7951100 rb067d9b  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // random.c --
    8 // 
     6//
     7// random.cfa --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Tue Jul  5 21:29:30 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jan  2 12:19:34 2018
    13 // Update Count     : 19
    14 // 
     12// Last Modified On : Tue Dec  4 21:46:25 2018
     13// Update Count     : 22
     14//
    1515
    16 #include <fstream>
    17 #include <stdlib>                                                                               // random
     16#include <fstream.hfa>
     17#include <stdlib.hfa>                                                                   // random
    1818#include <unistd.h>                                                                             // getpid
    1919
     
    2424        // test polymorphic calls to random and stream
    2525        char c = random();
    26         sout | c | endl;
     26        sout | c;
    2727        c = random( 'A' );
    28         sout | c | endl;
     28        sout | c;
    2929        c = random( 'A', 'Z' );
    30         sout | c | endl;
     30        sout | c;
    3131
    3232        int i = random();
    33     sout | i | endl;
     33    sout | i;
    3434        i = random( 10 );
    35     sout | i | endl;
     35    sout | i;
    3636        i = random( -10, 20 );
    37     sout | i | endl;
     37    sout | i;
    3838
    3939        unsigned int ui = random();
    40     sout | ui | endl;
     40    sout | ui;
    4141        ui = random( 10u );
    42     sout | ui | endl;
     42    sout | ui;
    4343        ui = random( 10u, 20u );
    44     sout | ui | endl;
     44    sout | ui;
    4545
    4646        long int li = random();
    47     sout | li | endl;
     47    sout | li;
    4848        li = random( 10l );
    49     sout | li | endl;
     49    sout | li;
    5050        li = random( -10l, 20l );
    51     sout | li | endl;
     51    sout | li;
    5252
    5353        unsigned long int uli = random();
    54     sout | uli | endl;
     54    sout | uli;
    5555        uli = random( 10ul );
    56     sout | uli | endl;
     56    sout | uli;
    5757        uli = random( 10ul, 20ul );
    58     sout | uli | endl;
     58    sout | uli;
    5959
    6060    float f = random();
    61     sout | f | endl;
     61    sout | f;
    6262
    6363    double d = random();
    64     sout | d | endl;
     64    sout | d;
    6565
    6666    float _Complex fc = random();
    67     sout | fc | endl;
     67    sout | fc;
    6868
    6969    double _Complex dc = random();
    70     sout | dc | endl;
     70    sout | dc;
    7171
    7272    long double _Complex ldc = random();
    73     sout | ldc | endl;
     73    sout | ldc;
    7474} // main
    7575
    7676// Local Variables: //
    7777// tab-width: 4 //
    78 // compile-command: "cfa random.c" //
     78// compile-command: "cfa random.cfa" //
    7979// End: //
  • tests/result.cfa

    r7951100 rb067d9b  
    1515
    1616#include <assert.h>
    17 #include <containers/result>
     17#include <containers/result.hfa>
    1818
    1919void checkPredicates() {
  • tests/searchsort.cfa

    r7951100 rb067d9b  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // searchsort.c --
    8 // 
     6//
     7// searchsort.cfa --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Thu Feb  4 18:17:50 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jan  2 08:01:17 2018
    13 // Update Count     : 100
    14 // 
     12// Last Modified On : Thu Dec 20 22:49:46 2018
     13// Update Count     : 108
     14//
    1515
    16 #include <fstream>
    17 #include <stdlib>                                                                               // bsearch, qsort
     16#include <fstream.hfa>
     17#include <stdlib.hfa>                                                                   // bsearch, qsort
    1818#include <stdlib.h>                                                                             // C version of bsearch
    1919
     
    2121
    2222int main( void ) {
    23         const unsigned int size = 10;
     23        const int size = 10;
    2424        int iarr[size];
    2525
    26         for ( unsigned int i = 0; i < size; i += 1 ) {
     26        sout | nlOff;                                                                           // turn off auto newline
     27
     28        for ( i; 0 ~ size ) {
    2729                iarr[i] = size - i;
    2830                sout | iarr[i] | ", ";
    2931        } // for
    30         sout | endl | endl;
     32        sout | nl | nl;
    3133
    3234        // ascending sort/search by changing < to >
    3335        qsort( iarr, size );
    34         for ( unsigned int i = 0; i < size; i += 1 ) {
     36        for ( i; 0 ~ size ) {
    3537                sout | iarr[i] | ", ";
    3638        } // for
    37         sout | endl;
    38         for ( unsigned int i = 0; i < size; i += 1 ) {          // C version
     39        sout | nl;
     40        for ( i; 0 ~ size ) {           // C version
    3941                int key = size - i;
    4042                int * v = bsearch( &key, iarr, size, sizeof( iarr[0] ), comp );
    4143                sout | key | ':' | *v | ", ";
    4244        } // for
    43         sout | endl;
     45        sout | nl;
    4446
    45         for ( unsigned int i = 0; i < size; i += 1 ) {
     47        for ( i; 0 ~ size ) {
    4648                int * v = bsearch( size - i, iarr, size );
    4749                sout | size - i | ':' | *v | ", ";
    4850        } // for
    49         sout | endl;
    50         for ( unsigned int i = 0; i < size; i += 1 ) {
     51        sout | nl;
     52        for ( i; 0 ~ size ) {
    5153                unsigned int posn = bsearch( size - i, iarr, size );
    5254                sout | size - i | ':' | iarr[posn] | ", ";
    5355        } // for
    54         sout | endl | endl;
     56        sout | nl | nl;
    5557
    5658        // descending sort/search by changing < to >
    57         for ( unsigned int i = 0; i < size; i += 1 ) {
     59        for ( i; 0 ~ size ) {
    5860                iarr[i] = i + 1;
    5961                sout | iarr[i] | ", ";
    6062        } // for
    61         sout | endl;
     63        sout | nl;
    6264        {
    63                 int ?<?( int x, int y ) { return x > y; }
    64                 qsort( iarr, size );
    65                 for ( unsigned int i = 0; i < size; i += 1 ) {
     65                // redefinition of ?<? can't overlap the loop controls:
     66                {
     67                        int (*?<?)(int, int) = ?>?;
     68                        qsort( iarr, size );
     69                }
     70                for ( i; 0 ~ size ) {
    6671                        sout | iarr[i] | ", ";
    6772                } // for
    68                 sout | endl;
    69                 for ( unsigned int i = 0; i < size; i += 1 ) {
     73                sout | nl;
     74                for ( i; 0 ~ size ) {
     75                        int (*?<?)(int, int) = ?>?;
    7076                        int * v = bsearch( size - i, iarr, size );
    7177                        sout | size - i | ':' | *v | ", ";
    7278                } // for
    73                 sout | endl;
    74                 for ( unsigned int i = 0; i < size; i += 1 ) {
     79                sout | nl;
     80                for ( i; 0 ~ size ) {
     81                        int (*?<?)(int, int) = ?>?;
    7582                        unsigned int posn = bsearch( size - i, iarr, size );
    7683                        sout | size - i | ':' | iarr[posn] | ", ";
    7784                } // for
    7885        }
    79         sout | endl | endl;
     86        sout | nl | nl;
    8087
    8188        double darr[size];
    82         for ( unsigned int i = 0; i < size; i += 1 ) {
     89        for ( i; 0 ~ size ) {
    8390                darr[i] = size - i + 0.5;
    8491                sout | darr[i] | ", ";
    8592        } // for
    86         sout | endl;
     93        sout | nl;
    8794        qsort( darr, size );
    88         for ( unsigned int i = 0; i < size; i += 1 ) {
     95        for ( i; 0 ~ size ) {
    8996                sout | darr[i] | ", ";
    9097        } // for
    91         sout | endl;
    92         for ( unsigned int i = 0; i < size; i += 1 ) {
     98        sout | nl;
     99        for ( i; 0 ~ size ) {
    93100                double * v = bsearch( size - i + 0.5, darr, size );
    94101                sout | size - i + 0.5 | ':' | *v | ", ";
    95102        } // for
    96         sout | endl;
    97         for ( unsigned int i = 0; i < size; i += 1 ) {
     103        sout | nl;
     104        for ( i; 0 ~ size ) {
    98105                unsigned int posn = bsearch( size - i + 0.5, darr, size );
    99106                sout | size - i + 0.5 | ':' | darr[posn] | ", ";
    100107        } // for
    101         sout | endl | endl;
     108        sout | nl | nl;
    102109
    103110        struct S { int i, j; } sarr[size];
    104111        int ?<?( S t1, S t2 ) { return t1.i < t2.i && t1.j < t2.j; }
    105112        ofstream & ?|?( ofstream & os, S v ) { return os | v.i | ' ' | v.j; }
    106         for ( unsigned int i = 0; i < size; i += 1 ) {
     113        for ( i; 0 ~ size ) {
    107114                sarr[i].i = size - i;
    108115                sarr[i].j = size - i + 1;
    109116                sout | sarr[i] | ", ";
    110117        } // for
    111         sout | endl;
     118        sout | nl;
    112119        qsort( sarr, size );
    113         for ( unsigned int i = 0; i < size; i += 1 ) {
     120        for ( i; 0 ~ size ) {
    114121                sout | sarr[i] | ", ";
    115122        } // for
    116         sout | endl;
    117         for ( unsigned int i = 0; i < size; i += 1 ) {
     123        sout | nl;
     124        for ( i; 0 ~ size ) {
    118125                S temp = { size - i, size - i + 1 };
    119126                S * v = bsearch( temp, sarr, size );
    120127                sout | temp | ':' | *v | ", ";
    121128        } // for
    122         sout | endl;
    123         for ( unsigned int i = 0; i < size; i += 1 ) {
     129        sout | nl;
     130        for ( i; 0 ~ size ) {
    124131                S temp = { size - i, size - i + 1 };
    125132                unsigned int posn = bsearch( temp, sarr, size );
    126133                sout | temp | ':' | sarr[posn] | ", ";
    127134        } // for
    128         sout | endl | endl;
     135        sout | nl | nl;
    129136        {
    130                 unsigned int getKey( const S & s ) { return s.j; }
    131                 for ( unsigned int i = 0; i < size; i += 1 ) {
     137                int getKey( const S & s ) { return s.j; }
     138                for ( i; 0 ~ size ) {
    132139                        sout | sarr[i] | ", ";
    133140                } // for
    134                 sout | endl;
    135                 for ( unsigned int i = 0; i < size; i += 1 ) {
     141                sout | nl;
     142                for ( i; 0 ~ size ) {
    136143                        S * v = bsearch( size - i + 1, sarr, size );
    137144                        sout | size - i + 1 | ':' | *v | ", ";
    138145                } // for
    139                 sout | endl;
    140                 for ( unsigned int i = 0; i < size; i += 1 ) {
     146                sout | nl;
     147                for ( i; 0 ~ size ) {
    141148                        unsigned int posn = bsearch( size - i + 1, sarr, size );
    142149                        sout | size - i + 1 | ':' | sarr[posn] | ", ";
    143150                } // for
    144                 sout | endl | endl;
     151                sout | nl | nl;
    145152        }
    146153} // main
     
    148155// Local Variables: //
    149156// tab-width: 4 //
    150 // compile-command: "cfa searchsort.c" //
     157// compile-command: "cfa searchsort.cfa" //
    151158// End: //
  • tests/stdincludes.cfa

    r7951100 rb067d9b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // stdincludes.c --
     7// stdincludes.cfa --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Tue Aug 29 08:26:14 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 30 07:56:39 2017
    13 // Update Count     : 5
     12// Last Modified On : Tue Nov  6 18:00:53 2018
     13// Update Count     : 6
    1414//
    1515
     
    5151// Local Variables: //
    5252// tab-width: 4 //
    53 // compile-command: "cfa stdincludes.c" //
     53// compile-command: "cfa stdincludes.cfa" //
    5454// End: //
  • tests/switch.cfa

    r7951100 rb067d9b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // switch.c --
     7// switch.cfa --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Tue Jul 12 06:50:22 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar  8 07:33:05 2018
    13 // Update Count     : 36
     12// Last Modified On : Tue Nov  6 18:01:34 2018
     13// Update Count     : 37
    1414//
    1515
     
    104104// Local Variables: //
    105105// tab-width: 4 //
    106 // compile-command: "cfa switch.c" //
     106// compile-command: "cfa switch.cfa" //
    107107// End: //
  • tests/test.py

    r7951100 rb067d9b  
    1 #!/usr/bin/python
    2 from __future__ import print_function
     1#!/usr/bin/python3
    32
    43from pybin.tools import *
     
    98import re
    109import sys
     10import tempfile
    1111import time
    1212
     
    1515################################################################################
    1616
    17 def findTests():
     17def find_tests():
    1818        expected = []
    1919
    20         def matchTest(path):
    21                 match = re.search("(\.[\w\/\-_]*)\/.expect\/([\w\-_]+)(\.[\w\-_]+)?\.txt", path)
     20        def match_test(path):
     21                match = re.search("^%s\/([\w\/\-_]*).expect\/([\w\-_]+)(\.[\w\-_]+)?\.txt$" % settings.SRCDIR, path)
    2222                if match :
    2323                        test = Test()
     
    2828                                expected.append(test)
    2929
    30         pathWalk( matchTest )
     30        path_walk( match_test )
    3131
    3232        return expected
    3333
    3434# reads the directory ./.expect and indentifies the tests
    35 def listTests( includes, excludes ):
    36         includes = [canonicalPath( i ) for i in includes] if includes else None
    37         excludes = [canonicalPath( i ) for i in excludes] if excludes else None
    38 
     35def list_tests( includes, excludes ):
    3936        # tests directly in the .expect folder will always be processed
    40         test_list = findTests()
     37        test_list = find_tests()
    4138
    4239        # if we have a limited number of includes, filter by them
     
    5552
    5653# from the found tests, filter all the valid tests/desired tests
    57 def validTests( options ):
     54def valid_tests( options ):
    5855        tests = []
    5956
     
    6259        if options.regenerate_expected :
    6360                for testname in options.tests :
    64                         testname = canonicalPath( testname )
     61                        testname = canonical_path( testname )
    6562                        if Test.valid_name(testname):
    66                                 found = [test for test in allTests if test.target() == testname]
     63                                found = [test for test in all_tests if canonical_path( test.target() ) == testname]
    6764                                tests.append( found[0] if len(found) == 1 else Test.from_target(testname) )
    6865                        else :
     
    7269                # otherwise we only need to validate that all tests are present in the complete list
    7370                for testname in options.tests:
    74                         test = [t for t in allTests if pathCmp( t.target(), testname )]
     71                        test = [t for t in all_tests if path_cmp( t.target(), testname )]
    7572
    7673                        if test :
     
    8279
    8380# parses the option
    84 def getOptions():
     81def parse_args():
    8582        # create a parser with the arguments for the tests script
    8683        parser = argparse.ArgumentParser(description='Script which runs cforall tests')
    87         parser.add_argument('--debug', help='Run all tests in debug or release', type=yes_no, default='no')
     84        parser.add_argument('--debug', help='Run all tests in debug or release', type=yes_no, default='yes')
     85        parser.add_argument('--install', help='Run all tests based on installed binaries or tree binaries', type=yes_no, default='no')
    8886        parser.add_argument('--arch', help='Test for specific architecture', type=str, default='')
     87        parser.add_argument('--timeout', help='Maximum duration in seconds after a single test is considered to have timed out', type=int, default=60)
     88        parser.add_argument('--global-timeout', help='Maximum cumulative duration in seconds after the ALL tests are considered to have timed out', type=int, default=7200)
    8989        parser.add_argument('--dry-run', help='Don\'t run the tests, only output the commands', action='store_true')
    9090        parser.add_argument('--list', help='List all test available', action='store_true')
    9191        parser.add_argument('--all', help='Run all test available', action='store_true')
    9292        parser.add_argument('--regenerate-expected', help='Regenerate the .expect by running the specified tets, can be used with --all option', action='store_true')
     93        parser.add_argument('--archive-errors', help='If called with a valid path, on test crashes the test script will copy the core dump and the executable to the specified path.', type=str, default='')
    9394        parser.add_argument('-j', '--jobs', help='Number of tests to run simultaneously', type=int)
    9495        parser.add_argument('--list-comp', help='List all valide arguments', action='store_true')
     
    9798        parser.add_argument('tests', metavar='test', type=str, nargs='*', help='a list of tests to run')
    9899
    99         options =  parser.parse_args()
     100        try:
     101                options =  parser.parse_args()
     102        except:
     103                print('ERROR: invalid arguments', file=sys.stderr)
     104                parser.print_help(sys.stderr)
     105                sys.exit(1)
    100106
    101107        # script must have at least some tests to run or be listing
     
    107113        # check that exactly one of the booleans is set to true
    108114        if not sum( (listing, all_tests, some_tests, some_dirs) ) > 0 :
    109                 print('ERROR: must have option \'--all\', \'--list\', \'--include\', \'-I\' or non-empty test list', file=sys.stderr)
     115                print('''ERROR: must have option '--all', '--list', '--include', '-I' or non-empty test list''', file=sys.stderr)
    110116                parser.print_help()
    111117                sys.exit(1)
     
    116122#               running test functions
    117123################################################################################
     124def success(val):
     125        return val == 0 or settings.dry_run
     126
     127def no_rule(file, target):
     128        return not settings.dry_run and file_contains_only(file, "make: *** No rule to make target `%s'.  Stop." % target)
     129
    118130# logic to run a single test and return the result (No handling of printing or other test framework logic)
    119131def run_single_test(test):
    120132
    121133        # find the output file based on the test name and options flag
     134        exe_file = test.target_executable();
    122135        out_file = test.target_output()
    123136        err_file = test.error_log()
     
    128141        test.prepare()
    129142
    130         # remove any outputs from the previous tests to prevent side effects
    131         rm( (out_file, err_file, test.target()) )
    132 
    133143        # build, skipping to next test on error
    134         before = time.time()
    135         make_ret, _ = make( test.target(),
    136                 redirects  = "2> %s 1> /dev/null" % out_file,
    137                 error_file = err_file
    138         )
    139         after = time.time()
    140 
    141         comp_dur = after - before
     144        with Timed() as comp_dur:
     145                make_ret, _ = make( test.target(), output_file=subprocess.DEVNULL, error=out_file, error_file = err_file )
    142146
    143147        run_dur = None
    144 
    145         # if the make command succeds continue otherwise skip to diff
    146         if make_ret == 0 or settings.dry_run:
    147                 before = time.time()
    148                 if settings.dry_run or fileIsExecutable(test.target()) :
    149                         # run test
    150                         retcode, _ = sh("timeout 60 %s > %s 2>&1" % (test.target(), out_file), input = in_file)
    151                 else :
    152                         # simply cat the result into the output
    153                         retcode, _ = sh("cat %s > %s" % (test.target(), out_file))
    154 
    155                 after = time.time()
    156                 run_dur = after - before
    157         else:
    158                 retcode, _ = sh("mv %s %s" % (err_file, out_file))
    159 
    160 
    161         if retcode == 0:
    162                 if settings.generating :
    163                         # if we are ounly generating the output we still need to check that the test actually exists
    164                         if not settings.dry_run and fileContainsOnly(out_file, "make: *** No rule to make target `%s'.  Stop." % test.target()) :
    165                                 retcode = 1;
    166                                 error = "\t\tNo make target for test %s!" % test.target()
    167                                 sh("rm %s" % out_file, False)
    168                         else:
    169                                 error = None
    170                 else :
    171                         # fetch return code and error from the diff command
    172                         retcode, error = diff(cmp_file, out_file)
    173 
    174         else:
    175                 with open (out_file, "r") as myfile:
    176                         error = myfile.read()
     148        # run everything in a temp directory to make sure core file are handled properly
     149        with tempdir():
     150                # if the make command succeds continue otherwise skip to diff
     151                if success(make_ret):
     152                        with Timed() as run_dur:
     153                                if settings.dry_run or is_exe(exe_file):
     154                                        # run test
     155                                        retcode, _ = sh(exe_file, output_file=out_file, input_file=in_file, timeout=True)
     156                                else :
     157                                        # simply cat the result into the output
     158                                        retcode = cat(exe_file, out_file)
     159                else:
     160                        retcode = mv(err_file, out_file)
     161
     162                if success(retcode):
     163                        if settings.generating :
     164                                # if we are ounly generating the output we still need to check that the test actually exists
     165                                if no_rule(out_file, test.target()) :
     166                                        retcode = 1
     167                                        error = "\t\tNo make target for test %s!" % test.target()
     168                                        rm(out_file)
     169                                else:
     170                                        error = None
     171                        else :
     172                                # fetch return code and error from the diff command
     173                                retcode, error = diff(cmp_file, out_file)
     174
     175                else:
     176                        with open (out_file, "r") as myfile:
     177                                error = myfile.read()
     178
     179                        ret, info = core_info(exe_file)
     180                        error = error + info if error else info
     181
     182                        if settings.archive:
     183                                error = error + '\n' + core_archive(settings.archive, test.target(), exe_file)
     184
    177185
    178186
    179187        # clean the executable
    180         sh("rm -f %s > /dev/null 2>&1" % test.target())
    181 
    182         return retcode, error, [comp_dur, run_dur]
     188        rm(exe_file)
     189
     190        return retcode, error, [comp_dur.duration, run_dur.duration if run_dur else None]
    183191
    184192# run a single test and handle the errors, outputs, printing, exception handling, etc.
    185193def run_test_worker(t) :
    186 
    187         with SignalHandling():
     194        try :
    188195                # print formated name
    189                 name_txt = "%20s  " % t.name
     196                name_txt = '{0:{width}}  '.format(t.target(), width=settings.output_width)
    190197
    191198                retcode, error, duration = run_single_test(t)
     
    195202
    196203                #print result with error if needed
    197                 text = name_txt + result_txt
     204                text = '\t' + name_txt + result_txt
    198205                out = sys.stdout
    199206                if error :
    200                         text = text + "\n" + error
    201                         out = sys.stderr
    202 
    203                 print(text, file = out)
    204                 sys.stdout.flush()
     207                        text = text + '\n' + error
     208
     209                return retcode == TestResult.SUCCESS, text
     210        except KeyboardInterrupt:
     211                return False, ""
     212        except Exception as ex:
     213                print("Unexpected error in worker thread: %s" % ex, file=sys.stderr)
    205214                sys.stderr.flush()
    206 
    207         return retcode != TestResult.SUCCESS
     215                return False, ""
     216
    208217
    209218# run the given list of tests with the given parameters
    210219def run_tests(tests, jobs) :
    211220        # clean the sandbox from previous commands
    212         make('clean', redirects = '> /dev/null 2>&1')
     221        make('clean', output_file=subprocess.DEVNULL, error=subprocess.DEVNULL)
    213222
    214223        # create the executor for our jobs and handle the signal properly
    215         pool = setupPool(jobs)
     224        pool = multiprocessing.Pool(jobs)
     225
     226        failed = False
    216227
    217228        # for each test to run
    218229        try :
    219                 results = pool.map_async(
     230                num = len(tests)
     231                fancy = sys.stdout.isatty()
     232                results = pool.imap_unordered(
    220233                        run_test_worker,
    221234                        tests,
    222235                        chunksize = 1
    223                 ).get(7200)
     236                )
     237
     238                for i, (succ, txt) in enumerate(timed(results, timeout = settings.timeout.total), 1) :
     239                        if not succ :
     240                                failed = True
     241
     242                        print("       " + txt)
     243
     244                        if(fancy and i != num):
     245                                print("%d/%d" % (i, num), end='\r')
     246                                sys.stdout.flush()
     247
    224248        except KeyboardInterrupt:
     249                print("Tests interrupted by user", file=sys.stderr)
    225250                pool.terminate()
    226                 print("Tests interrupted by user")
    227                 sys.exit(1)
     251                pool.join()
     252                failed = True
     253        except multiprocessing.TimeoutError:
     254                print("ERROR: Test suite timed out", file=sys.stderr)
     255                pool.terminate()
     256                pool.join()
     257                failed = True
     258                killgroup() # needed to cleanly kill all children
     259
    228260
    229261        # clean the workspace
    230         make('clean', redirects = '> /dev/null 2>&1')
    231 
    232         for failed in results:
    233                 if failed :
    234                         return 1
    235 
    236         return 0
     262        make('clean', output_file=subprocess.DEVNULL, error=subprocess.DEVNULL)
     263
     264        return 1 if failed else 0
    237265
    238266
     
    241269################################################################################
    242270if __name__ == "__main__":
    243         #always run from same folder
    244         chdir()
    245271
    246272        # parse the command line arguments
    247         options = getOptions()
     273        options = parse_args()
    248274
    249275        # init global settings
     
    251277
    252278        # fetch the liest of all valid tests
    253         allTests = listTests( options.include, options.exclude )
     279        all_tests = list_tests( options.include, options.exclude )
     280
    254281
    255282        # if user wants all tests than no other treatement of the test list is required
    256283        if options.all or options.list or options.list_comp or options.include :
    257                 tests = allTests
     284                tests = all_tests
    258285
    259286        #otherwise we need to validate that the test list that was entered is valid
    260287        else :
    261                 tests = validTests( options )
     288                tests = valid_tests( options )
    262289
    263290        # make sure we have at least some test to run
     
    272299        # users may want to simply list the tests
    273300        if options.list_comp :
    274                 print("-h --help --debug --dry-run --list --arch --all --regenerate-expected -j --jobs ", end='')
     301                print("-h --help --debug --dry-run --list --arch --all --regenerate-expected --archive-errors --install --timeout --global-timeout -j --jobs ", end='')
    275302                print(" ".join(map(lambda t: "%s" % (t.target()), tests)))
    276303
    277304        elif options.list :
    278305                print("Listing for %s:%s"% (settings.arch.string, settings.debug.string))
    279                 fancy_print("\n".join(map(lambda t: "%s" % (t.toString()), tests)))
     306                fancy_print("\n".join(map(lambda t: t.toString(), tests)))
    280307
    281308        else :
    282                 options.jobs, forceJobs = jobCount( options, tests )
    283                 settings.updateMakeCmd(forceJobs, options.jobs)
    284 
    285                 print('%s (%s:%s) on %i cores' % (
    286                         'Regenerate tests' if settings.generating else 'Running',
     309                # check the build configuration works
     310                settings.prep_output(tests)
     311                settings.validate()
     312
     313                options.jobs, forceJobs = job_count( options, tests )
     314                settings.update_make_cmd(forceJobs, options.jobs)
     315
     316                print('%s %i tests on %i cores (%s:%s)' % (
     317                        'Regenerating' if settings.generating else 'Running',
     318                        len(tests),
     319                        options.jobs,
    287320                        settings.arch.string,
    288                         settings.debug.string,
    289                         options.jobs
     321                        settings.debug.string
    290322                ))
    291323
  • tests/tuple/tupleAssign.cfa

    r7951100 rb067d9b  
    1010// Created On       : Tue Nov 15 17:24:32 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Mar  6 21:23:58 2017
    13 // Update Count     : 34
     12// Last Modified On : Tue Dec  4 22:03:48 2018
     13// Update Count     : 35
    1414//
    1515
    16 #include <fstream>
     16#include <fstream.hfa>
    1717
    1818int main() {
     
    2424                // swap x, y and store the new [x, y] in [u, v] and in z;
    2525                printf( "u=%d v=%d x=%d y=%d z=[%d, %d]\n", u, v, x, y, z );
    26                 sout | "u=" | u | "v=" | v | "x=" | x | "y=" | y | "z=[" | z | "]" | endl;
     26                sout | "u=" | u | "v=" | v | "x=" | x | "y=" | y | "z=[" | z | "]";
    2727                z = [u, v] = [x, y] = [y, x];
    2828                printf( "u=%d v=%d x=%d y=%d z=[%d, %d]\n", u, v, x, y, z );
    29                 sout | "u=" | u | "v=" | v | "x=" | x | "y=" | y | "z=[" | z | "]" | endl;
     29                sout | "u=" | u | "v=" | v | "x=" | x | "y=" | y | "z=[" | z | "]";
    3030
    3131                // shuffle elements -- v = z.0, z.0 = z.1, z.1 = u, u = v
    3232                [v, z, u] = [z, u, v];
    3333                printf( "u=%d v=%d z=[%d, %d]\n", u, v, z );
    34                 sout | "u=" | u | "v=" | v | "z=[" | z | "]" | endl;
     34                sout | "u=" | u | "v=" | v | "z=[" | z | "]";
    3535
    3636                // multiple assignment with tuple expression on right
     
    3838                [u, v] = [123, 456];
    3939                printf( "u=%d v=%d z=[%d, %d]\n", u, v, z );
    40                 sout | "u=" | u | "v=" | v | "z=[" | z | "]" | endl;
     40                sout | "u=" | u | "v=" | v | "z=[" | z | "]";
    4141        }
    4242        {
     
    5555                [t, x, d, i, c, x] = (double)94.12;
    5656                printf( "d=%lg i=%d c=%c t=[%d, %lg, %d]\n", d, i, (int)c, t );
    57                 sout | "d=" | d | "i=" | i | "c=" | c | ' ' | "t=[" | t | "]" | endl;
     57                sout | "d=" | d | "i=" | i | "c=" | c | ' ' | "t=[" | t | "]";
    5858                [x, c, i, d, x, t] = (double)-94.12;
    5959                printf( "d=%lg i=%d c=%c t=[%d, %lg, %d]\n", d, i, c, t );
    60                 sout | "d=" | d | "i=" | i | "c=" | c | ' ' | "t=[" | t | "]" | endl;
     60                sout | "d=" | d | "i=" | i | "c=" | c | ' ' | "t=[" | t | "]";
    6161        }
    6262}
  • tests/tuple/tupleVariadic.cfa

    r7951100 rb067d9b  
    99// Author           : Rob Schluntz
    1010// Created On       : Fri Dec 16 10:25:35 2016
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri Dec 21 14:42:48 2016
    13 // Update Count     : 2
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Aug  2 09:24:04 2018
     13// Update Count     : 6
    1414//
     15
     16#include <stdlib.hfa>
    1517
    1618void func(void) {
     
    2830        printf("called process(double) %g\n", x);
    2931}
    30 
    31 forall( dtype T, ttype Params | sized(T) | { void ?{}(T &, Params); } )
    32 T * new(Params p);
    3332
    3433struct array {
     
    6665        a.data[2] = a2;
    6766        printf("called ?{} with a: %d %d %d\n", a0, a1, a2);
     67}
     68
     69void ^?{}(array & a) {
     70        free(a.data);
    6871}
    6972
     
    126129                bar(x);
    127130        }
     131
     132        delete(ptr);
     133        delete(x4);
     134        delete(x3);
     135        delete(x2);
     136        delete(x1);
     137        delete(x0);
    128138}
    129139
     
    131141// tab-width: 4 //
    132142// End: //
    133 
  • tests/userLiterals.cfa

    r7951100 rb067d9b  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // user_literals.c --
    8 // 
     6//
     7// user_literals.cfa --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Wed Sep  6 21:40:50 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Apr 29 16:51:42 2018
    13 // Update Count     : 54
    14 // 
     12// Last Modified On : Tue Dec  4 22:03:10 2018
     13// Update Count     : 56
     14//
    1515
    16 #include <fstream>
     16#include <fstream.hfa>
    1717#include <wchar.h>
    1818#include <uchar.h>
    1919
    20 int ?`s( int s ) { sout | "secs" | s | endl; return s; }
    21 int ?`m( int m ) { sout | "mins" | m | endl; return m * 60; }
    22 int ?`h( int h ) { sout | "hours" | h | endl; return h * 3600; }
    23 int ?`_A_( int x ) { sout | "_A_" | x | endl; return x; }
    24 int ?`__thingy_( int x ) { sout | "_thingy_" | x | endl; return x; }
     20int ?`s( int s ) { sout | "secs" | s; return s; }
     21int ?`m( int m ) { sout | "mins" | m; return m * 60; }
     22int ?`h( int h ) { sout | "hours" | h; return h * 3600; }
     23int ?`_A_( int x ) { sout | "_A_" | x; return x; }
     24int ?`__thingy_( int x ) { sout | "_thingy_" | x; return x; }
    2525
    26 int ?`s( const char * s ) { sout | "secs" | s | endl; return 0; }
    27 int ?`m( const char16_t * m ) { sout | "mins" | m | endl; return 0;}
    28 int ?`h( const char32_t * h ) { sout | "hours" | h | endl; return 0; }
    29 int ?`_A_( const wchar_t * str ) { sout | "_A_" | str | endl; return 0; }
    30 int ?`__thingy_( const char * str ) { sout | "_thingy_" | str | endl; return 0; }
     26int ?`s( const char * s ) { sout | "secs" | s; return 0; }
     27int ?`m( const char16_t * m ) { sout | "mins" | m; return 0;}
     28int ?`h( const char32_t * h ) { sout | "hours" | h; return 0; }
     29int ?`_A_( const wchar_t * str ) { sout | "_A_" | str; return 0; }
     30int ?`__thingy_( const char * str ) { sout | "_thingy_" | str; return 0; }
    3131
    3232
     
    4646        Weight w, heavy = { 20 };                                                       // 20 stone
    4747        w = 155`lb;
    48         sout | w | endl;
     48        sout | w;
    4949        w = 0b_1111`st;
    50         sout | w | endl;
     50        sout | w;
    5151        w = 0_233`lb;                                                                           // octal weight (155)
    52         sout | w | endl;
     52        sout | w;
    5353        w = 0x_9b_u`kg;
    54         sout | w | endl;
     54        sout | w;
    5555        w = 70.3`kg;
    56         sout | w | endl;
     56        sout | w;
    5757        w = 11`st + 1`lb;
    58         sout | w | endl;
     58        sout | w;
    5959        w = 5`st + 8`kg + 25`lb + heavy;
    60         sout | w | endl;
     60        sout | w;
    6161
    6262//      0`secs;
     
    9090// Local Variables: //
    9191// tab-width: 4 //
    92 // compile-command: "cfa user_literals.c" //
     92// compile-command: "cfa user_literals.cfa" //
    9393// End: //
  • tests/variableDeclarator.cfa

    r7951100 rb067d9b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // variableDeclarator.c --
     7// variableDeclarator.cfa --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Wed Aug 17 08:41:42 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 17 08:42:21 2016
    13 // Update Count     : 1
     12// Last Modified On : Tue Nov  6 18:02:16 2018
     13// Update Count     : 2
    1414//
    1515
     
    182182// Local Variables: //
    183183// tab-width: 4 //
    184 // compile-command: "cfa variableDeclarator.c" //
     184// compile-command: "cfa variableDeclarator.cfa" //
    185185// End: //
  • tests/vector.cfa

    r7951100 rb067d9b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // vector.c --
     7// vector.cfa --
    88//
    99// Author           : Thierry Delisle
    1010// Created On       : Mon Jul  4 23:36:19 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jan 18 17:08:08 2018
    13 // Update Count     : 27
     12// Last Modified On : Tue Dec  4 22:02:39 2018
     13// Update Count     : 29
    1414//
    1515
    16 #include <fstream>
    17 #include <vector>
     16#include <fstream.hfa>
     17#include <vector.hfa>
    1818
    1919#undef assert
     
    2121        do {                                                                            \
    2222                if ( !(x) ) {                                                   \
    23                         sout | "CHECK failed :" | #x | "at" | __FILE__ | " :" | __LINE__ | endl;        \
     23                        sout | "CHECK failed :" | #x | "at" | __FILE__ | " :" | __LINE__;       \
    2424                        abort();                                                        \
    2525                }                                                                               \
     
    3131        assert( empty( &iv ) );
    3232        assert( size( &iv ) == 0 );
    33         sout | size( &iv ) | endl;
     33        sout | size( &iv );
    3434
    3535        push_back( &iv, 1 );
    3636        assert( size( &iv ) == 1 );
    37         sout | size( &iv ) | endl;
     37        sout | size( &iv );
    3838
    3939        push_back( &iv, 2 );
    4040        assert( size( &iv ) == 2 );
    41         sout | size( &iv ) | endl;
     41        sout | size( &iv );
    4242
    4343        push_back( &iv, 3 );
    4444        assert( size( &iv ) == 3 );
    45         sout | size( &iv ) | endl;
     45        sout | size( &iv );
    4646
    4747        assert( !empty( &iv ) );
     
    5858        assert( empty( &iv ) );
    5959        assert( size( &iv ) == 0 );
    60         sout | size( &iv ) | endl;
     60        sout | size( &iv );
    6161}
    6262
    6363// Local Variables: //
    6464// tab-width: 4 //
    65 // compile-command: "cfa vector.c" //
     65// compile-command: "cfa vector.cfa" //
    6666// End: //
  • tests/virtualCast.cfa

    r7951100 rb067d9b  
    99 */
    1010
    11 #include <stdlib>
     11#include <stdlib.hfa>
    1212#include <assert.h>
    1313
  • tests/warnings/self-assignment.cfa

    r7951100 rb067d9b  
    99// Author           : Rob Schluntz
    1010// Created On       : Thu Mar 1 13:53:57 2018
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Thu Mar 1 13:53:57 2018
    13 // Update Count     : 2
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Feb 20 07:56:17 2019
     13// Update Count     : 3
    1414//
    1515
    1616struct S {
    17   int i;
     17        int i;
    1818};
    1919
    2020struct T {
    21   S s;
     21        S s;
    2222};
    2323
    2424int main() {
    25   int j = 0;
    26   S s = { 0 };
    27   T t = { { 0 } };
     25        int j = 0;
     26        S s = { 0 };
     27        T t = { { 0 } };
    2828
    29   j = j;
    30   s = s;
    31   s.i = s.i;
    32   t.s.i = t.s.i;
     29        j = j;
     30        s = s;
     31        s.i = s.i;
     32        t.s.i = t.s.i;
    3333}
    3434
Note: See TracChangeset for help on using the changeset viewer.