Changes in / [0720e049:3d4b23fa]


Ignore:
Files:
7 added
19 deleted
234 edited

Legend:

Unmodified
Added
Removed
  • .gitignore

    r0720e049 r3d4b23fa  
    2424lib
    2525include
    26 share
    2726
    2827# src executables, for lib and bin
  • Makefile.am

    r0720e049 r3d4b23fa  
    2121
    2222MAINTAINERCLEANFILES = lib/* bin/* src/examples/.deps/* src/tests/.deps/* src/tests/.out/*
    23 
    24 man1_MANS = doc/man/cfa.1
  • Makefile.in

    r0720e049 r3d4b23fa  
    131131    *) (install-info --version) >/dev/null 2>&1;; \
    132132  esac
    133 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
    134 am__vpath_adj = case $$p in \
    135     $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
    136     *) f=$$p;; \
    137   esac;
    138 am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
    139 am__install_max = 40
    140 am__nobase_strip_setup = \
    141   srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
    142 am__nobase_strip = \
    143   for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
    144 am__nobase_list = $(am__nobase_strip_setup); \
    145   for p in $$list; do echo "$$p $$p"; done | \
    146   sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
    147   $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
    148     if (++n[$$2] == $(am__install_max)) \
    149       { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
    150     END { for (dir in files) print dir, files[dir] }'
    151 am__base_list = \
    152   sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
    153   sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
    154 am__uninstall_files_from_dir = { \
    155   test -z "$$files" \
    156     || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
    157     || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
    158          $(am__cd) "$$dir" && rm -f $$files; }; \
    159   }
    160 man1dir = $(mandir)/man1
    161 am__installdirs = "$(DESTDIR)$(man1dir)"
    162 NROFF = nroff
    163 MANS = $(man1_MANS)
    164133RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
    165134  distclean-recursive maintainer-clean-recursive
     
    198167        $(top_srcdir)/automake/install-sh \
    199168        $(top_srcdir)/automake/missing INSTALL README automake/compile \
    200         automake/config.guess automake/config.sub automake/install-sh \
    201         automake/missing
     169        automake/config.guess automake/config.sub automake/depcomp \
     170        automake/install-sh automake/missing automake/ylwrap
    202171DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
    203172distdir = $(PACKAGE)-$(VERSION)
     
    366335EXTRA_DIST = Docs                       # non-source files
    367336MAINTAINERCLEANFILES = lib/* bin/* src/examples/.deps/* src/tests/.deps/* src/tests/.out/*
    368 man1_MANS = doc/man/cfa.1
    369337all: config.h
    370338        $(MAKE) $(AM_MAKEFLAGS) all-recursive
     
    419387distclean-hdr:
    420388        -rm -f config.h stamp-h1
    421 install-man1: $(man1_MANS)
    422         @$(NORMAL_INSTALL)
    423         @list1='$(man1_MANS)'; \
    424         list2=''; \
    425         test -n "$(man1dir)" \
    426           && test -n "`echo $$list1$$list2`" \
    427           || exit 0; \
    428         echo " $(MKDIR_P) '$(DESTDIR)$(man1dir)'"; \
    429         $(MKDIR_P) "$(DESTDIR)$(man1dir)" || exit 1; \
    430         { for i in $$list1; do echo "$$i"; done;  \
    431         if test -n "$$list2"; then \
    432           for i in $$list2; do echo "$$i"; done \
    433             | sed -n '/\.1[a-z]*$$/p'; \
    434         fi; \
    435         } | while read p; do \
    436           if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
    437           echo "$$d$$p"; echo "$$p"; \
    438         done | \
    439         sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
    440               -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
    441         sed 'N;N;s,\n, ,g' | { \
    442         list=; while read file base inst; do \
    443           if test "$$base" = "$$inst"; then list="$$list $$file"; else \
    444             echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
    445             $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \
    446           fi; \
    447         done; \
    448         for i in $$list; do echo "$$i"; done | $(am__base_list) | \
    449         while read files; do \
    450           test -z "$$files" || { \
    451             echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \
    452             $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \
    453         done; }
    454 
    455 uninstall-man1:
    456         @$(NORMAL_UNINSTALL)
    457         @list='$(man1_MANS)'; test -n "$(man1dir)" || exit 0; \
    458         files=`{ for i in $$list; do echo "$$i"; done; \
    459         } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
    460               -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
    461         dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir)
    462389
    463390# This directory's subdirectories are mostly independent; you can cd
     
    757684check-am: all-am
    758685check: check-recursive
    759 all-am: Makefile $(MANS) config.h
     686all-am: Makefile config.h
    760687installdirs: installdirs-recursive
    761688installdirs-am:
    762         for dir in "$(DESTDIR)$(man1dir)"; do \
    763           test -z "$$dir" || $(MKDIR_P) "$$dir"; \
    764         done
    765689install: install-recursive
    766690install-exec: install-exec-recursive
     
    815739info-am:
    816740
    817 install-data-am: install-man
     741install-data-am:
    818742
    819743install-dvi: install-dvi-recursive
     
    831755install-info-am:
    832756
    833 install-man: install-man1
     757install-man:
    834758
    835759install-pdf: install-pdf-recursive
     
    861785ps-am:
    862786
    863 uninstall-am: uninstall-man
    864 
    865 uninstall-man: uninstall-man1
     787uninstall-am:
    866788
    867789.MAKE: $(am__recursive_targets) all install-am install-strip
     
    876798        install-data install-data-am install-dvi install-dvi-am \
    877799        install-exec install-exec-am install-html install-html-am \
    878         install-info install-info-am install-man install-man1 \
    879         install-pdf install-pdf-am install-ps install-ps-am \
    880         install-strip installcheck installcheck-am installdirs \
    881         installdirs-am maintainer-clean maintainer-clean-generic \
    882         mostlyclean mostlyclean-generic pdf pdf-am ps ps-am tags \
    883         tags-am uninstall uninstall-am uninstall-man uninstall-man1
     800        install-info install-info-am install-man install-pdf \
     801        install-pdf-am install-ps install-ps-am install-strip \
     802        installcheck installcheck-am installdirs installdirs-am \
     803        maintainer-clean maintainer-clean-generic mostlyclean \
     804        mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \
     805        uninstall-am
    884806
    885807.PRECIOUS: Makefile
  • automake/compile

    r0720e049 r3d4b23fa  
    22# Wrapper for compilers which do not understand '-c -o'.
    33
    4 scriptversion=2012-10-14.11; # UTC
    5 
    6 # Copyright (C) 1999-2014 Free Software Foundation, Inc.
     4scriptversion=2012-01-04.17; # UTC
     5
     6# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009, 2010, 2012 Free
     7# Software Foundation, Inc.
    78# Written by Tom Tromey <tromey@cygnus.com>.
    89#
     
    7778      ;;
    7879  esac
    79 }
    80 
    81 # func_cl_dashL linkdir
    82 # Make cl look for libraries in LINKDIR
    83 func_cl_dashL ()
    84 {
    85   func_file_conv "$1"
    86   if test -z "$lib_path"; then
    87     lib_path=$file
    88   else
    89     lib_path="$lib_path;$file"
    90   fi
    91   linker_opts="$linker_opts -LIBPATH:$file"
    92 }
    93 
    94 # func_cl_dashl library
    95 # Do a library search-path lookup for cl
    96 func_cl_dashl ()
    97 {
    98   lib=$1
    99   found=no
    100   save_IFS=$IFS
    101   IFS=';'
    102   for dir in $lib_path $LIB
    103   do
    104     IFS=$save_IFS
    105     if $shared && test -f "$dir/$lib.dll.lib"; then
    106       found=yes
    107       lib=$dir/$lib.dll.lib
    108       break
    109     fi
    110     if test -f "$dir/$lib.lib"; then
    111       found=yes
    112       lib=$dir/$lib.lib
    113       break
    114     fi
    115     if test -f "$dir/lib$lib.a"; then
    116       found=yes
    117       lib=$dir/lib$lib.a
    118       break
    119     fi
    120   done
    121   IFS=$save_IFS
    122 
    123   if test "$found" != yes; then
    124     lib=$lib.lib
    125   fi
    12680}
    12781
     
    156110          esac
    157111          ;;
    158         -I)
    159           eat=1
    160           func_file_conv "$2" mingw
    161           set x "$@" -I"$file"
    162           shift
    163           ;;
    164112        -I*)
    165113          func_file_conv "${1#-I}" mingw
     
    167115          shift
    168116          ;;
    169         -l)
    170           eat=1
    171           func_cl_dashl "$2"
    172           set x "$@" "$lib"
    173           shift
    174           ;;
    175117        -l*)
    176           func_cl_dashl "${1#-l}"
    177           set x "$@" "$lib"
    178           shift
    179           ;;
    180         -L)
    181           eat=1
    182           func_cl_dashL "$2"
     118          lib=${1#-l}
     119          found=no
     120          save_IFS=$IFS
     121          IFS=';'
     122          for dir in $lib_path $LIB
     123          do
     124            IFS=$save_IFS
     125            if $shared && test -f "$dir/$lib.dll.lib"; then
     126              found=yes
     127              set x "$@" "$dir/$lib.dll.lib"
     128              break
     129            fi
     130            if test -f "$dir/$lib.lib"; then
     131              found=yes
     132              set x "$@" "$dir/$lib.lib"
     133              break
     134            fi
     135          done
     136          IFS=$save_IFS
     137
     138          test "$found" != yes && set x "$@" "$lib.lib"
     139          shift
    183140          ;;
    184141        -L*)
    185           func_cl_dashL "${1#-L}"
     142          func_file_conv "${1#-L}"
     143          if test -z "$lib_path"; then
     144            lib_path=$file
     145          else
     146            lib_path="$lib_path;$file"
     147          fi
     148          linker_opts="$linker_opts -LIBPATH:$file"
    186149          ;;
    187150        -static)
  • automake/config.guess

    • Property mode changed from 100755 to 120000
    r0720e049 r3d4b23fa  
    1 #! /bin/sh
    2 # Attempt to guess a canonical system name.
    3 #   Copyright 1992-2015 Free Software Foundation, Inc.
    4 
    5 timestamp='2015-08-20'
    6 
    7 # This file is free software; you can redistribute it and/or modify it
    8 # under the terms of the GNU General Public License as published by
    9 # the Free Software Foundation; either version 3 of the License, or
    10 # (at your option) any later version.
    11 #
    12 # This program is distributed in the hope that it will be useful, but
    13 # WITHOUT ANY WARRANTY; without even the implied warranty of
    14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    15 # General Public License for more details.
    16 #
    17 # You should have received a copy of the GNU General Public License
    18 # along with this program; if not, see <http://www.gnu.org/licenses/>.
    19 #
    20 # As a special exception to the GNU General Public License, if you
    21 # distribute this file as part of a program that contains a
    22 # configuration script generated by Autoconf, you may include it under
    23 # the same distribution terms that you use for the rest of that
    24 # program.  This Exception is an additional permission under section 7
    25 # of the GNU General Public License, version 3 ("GPLv3").
    26 #
    27 # Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
    28 #
    29 # You can get the latest version of this script from:
    30 # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
    31 #
    32 # Please send patches to <config-patches@gnu.org>.
    33 
    34 
    35 me=`echo "$0" | sed -e 's,.*/,,'`
    36 
    37 usage="\
    38 Usage: $0 [OPTION]
    39 
    40 Output the configuration name of the system \`$me' is run on.
    41 
    42 Operation modes:
    43   -h, --help         print this help, then exit
    44   -t, --time-stamp   print date of last modification, then exit
    45   -v, --version      print version number, then exit
    46 
    47 Report bugs and patches to <config-patches@gnu.org>."
    48 
    49 version="\
    50 GNU config.guess ($timestamp)
    51 
    52 Originally written by Per Bothner.
    53 Copyright 1992-2015 Free Software Foundation, Inc.
    54 
    55 This is free software; see the source for copying conditions.  There is NO
    56 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
    57 
    58 help="
    59 Try \`$me --help' for more information."
    60 
    61 # Parse command line
    62 while test $# -gt 0 ; do
    63   case $1 in
    64     --time-stamp | --time* | -t )
    65        echo "$timestamp" ; exit ;;
    66     --version | -v )
    67        echo "$version" ; exit ;;
    68     --help | --h* | -h )
    69        echo "$usage"; exit ;;
    70     -- )     # Stop option processing
    71        shift; break ;;
    72     - ) # Use stdin as input.
    73        break ;;
    74     -* )
    75        echo "$me: invalid option $1$help" >&2
    76        exit 1 ;;
    77     * )
    78        break ;;
    79   esac
    80 done
    81 
    82 if test $# != 0; then
    83   echo "$me: too many arguments$help" >&2
    84   exit 1
    85 fi
    86 
    87 trap 'exit 1' 1 2 15
    88 
    89 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a
    90 # compiler to aid in system detection is discouraged as it requires
    91 # temporary files to be created and, as you can see below, it is a
    92 # headache to deal with in a portable fashion.
    93 
    94 # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
    95 # use `HOST_CC' if defined, but it is deprecated.
    96 
    97 # Portable tmp directory creation inspired by the Autoconf team.
    98 
    99 set_cc_for_build='
    100 trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
    101 trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
    102 : ${TMPDIR=/tmp} ;
    103  { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
    104  { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
    105  { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
    106  { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
    107 dummy=$tmp/dummy ;
    108 tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
    109 case $CC_FOR_BUILD,$HOST_CC,$CC in
    110  ,,)    echo "int x;" > $dummy.c ;
    111         for c in cc gcc c89 c99 ; do
    112           if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
    113              CC_FOR_BUILD="$c"; break ;
    114           fi ;
    115         done ;
    116         if test x"$CC_FOR_BUILD" = x ; then
    117           CC_FOR_BUILD=no_compiler_found ;
    118         fi
    119         ;;
    120  ,,*)   CC_FOR_BUILD=$CC ;;
    121  ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
    122 esac ; set_cc_for_build= ;'
    123 
    124 # This is needed to find uname on a Pyramid OSx when run in the BSD universe.
    125 # (ghazi@noc.rutgers.edu 1994-08-24)
    126 if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
    127         PATH=$PATH:/.attbin ; export PATH
    128 fi
    129 
    130 UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
    131 UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
    132 UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
    133 UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
    134 
    135 case "${UNAME_SYSTEM}" in
    136 Linux|GNU|GNU/*)
    137         # If the system lacks a compiler, then just pick glibc.
    138         # We could probably try harder.
    139         LIBC=gnu
    140 
    141         eval $set_cc_for_build
    142         cat <<-EOF > $dummy.c
    143         #include <features.h>
    144         #if defined(__UCLIBC__)
    145         LIBC=uclibc
    146         #elif defined(__dietlibc__)
    147         LIBC=dietlibc
    148         #else
    149         LIBC=gnu
    150         #endif
    151         EOF
    152         eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
    153         ;;
    154 esac
    155 
    156 # Note: order is significant - the case branches are not exclusive.
    157 
    158 case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
    159     *:NetBSD:*:*)
    160         # NetBSD (nbsd) targets should (where applicable) match one or
    161         # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
    162         # *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
    163         # switched to ELF, *-*-netbsd* would select the old
    164         # object file format.  This provides both forward
    165         # compatibility and a consistent mechanism for selecting the
    166         # object file format.
    167         #
    168         # Note: NetBSD doesn't particularly care about the vendor
    169         # portion of the name.  We always set it to "unknown".
    170         sysctl="sysctl -n hw.machine_arch"
    171         UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
    172             /sbin/$sysctl 2>/dev/null || \
    173             /usr/sbin/$sysctl 2>/dev/null || \
    174             echo unknown)`
    175         case "${UNAME_MACHINE_ARCH}" in
    176             armeb) machine=armeb-unknown ;;
    177             arm*) machine=arm-unknown ;;
    178             sh3el) machine=shl-unknown ;;
    179             sh3eb) machine=sh-unknown ;;
    180             sh5el) machine=sh5le-unknown ;;
    181             earmv*)
    182                 arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
    183                 endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'`
    184                 machine=${arch}${endian}-unknown
    185                 ;;
    186             *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
    187         esac
    188         # The Operating System including object format, if it has switched
    189         # to ELF recently, or will in the future.
    190         case "${UNAME_MACHINE_ARCH}" in
    191             arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax)
    192                 eval $set_cc_for_build
    193                 if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
    194                         | grep -q __ELF__
    195                 then
    196                     # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
    197                     # Return netbsd for either.  FIX?
    198                     os=netbsd
    199                 else
    200                     os=netbsdelf
    201                 fi
    202                 ;;
    203             *)
    204                 os=netbsd
    205                 ;;
    206         esac
    207         # Determine ABI tags.
    208         case "${UNAME_MACHINE_ARCH}" in
    209             earm*)
    210                 expr='s/^earmv[0-9]/-eabi/;s/eb$//'
    211                 abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"`
    212                 ;;
    213         esac
    214         # The OS release
    215         # Debian GNU/NetBSD machines have a different userland, and
    216         # thus, need a distinct triplet. However, they do not need
    217         # kernel version information, so it can be replaced with a
    218         # suitable tag, in the style of linux-gnu.
    219         case "${UNAME_VERSION}" in
    220             Debian*)
    221                 release='-gnu'
    222                 ;;
    223             *)
    224                 release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2`
    225                 ;;
    226         esac
    227         # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
    228         # contains redundant information, the shorter form:
    229         # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
    230         echo "${machine}-${os}${release}${abi}"
    231         exit ;;
    232     *:Bitrig:*:*)
    233         UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
    234         echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE}
    235         exit ;;
    236     *:OpenBSD:*:*)
    237         UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
    238         echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
    239         exit ;;
    240     *:ekkoBSD:*:*)
    241         echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
    242         exit ;;
    243     *:SolidBSD:*:*)
    244         echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
    245         exit ;;
    246     macppc:MirBSD:*:*)
    247         echo powerpc-unknown-mirbsd${UNAME_RELEASE}
    248         exit ;;
    249     *:MirBSD:*:*)
    250         echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
    251         exit ;;
    252     *:Sortix:*:*)
    253         echo ${UNAME_MACHINE}-unknown-sortix
    254         exit ;;
    255     alpha:OSF1:*:*)
    256         case $UNAME_RELEASE in
    257         *4.0)
    258                 UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
    259                 ;;
    260         *5.*)
    261                 UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
    262                 ;;
    263         esac
    264         # According to Compaq, /usr/sbin/psrinfo has been available on
    265         # OSF/1 and Tru64 systems produced since 1995.  I hope that
    266         # covers most systems running today.  This code pipes the CPU
    267         # types through head -n 1, so we only detect the type of CPU 0.
    268         ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
    269         case "$ALPHA_CPU_TYPE" in
    270             "EV4 (21064)")
    271                 UNAME_MACHINE="alpha" ;;
    272             "EV4.5 (21064)")
    273                 UNAME_MACHINE="alpha" ;;
    274             "LCA4 (21066/21068)")
    275                 UNAME_MACHINE="alpha" ;;
    276             "EV5 (21164)")
    277                 UNAME_MACHINE="alphaev5" ;;
    278             "EV5.6 (21164A)")
    279                 UNAME_MACHINE="alphaev56" ;;
    280             "EV5.6 (21164PC)")
    281                 UNAME_MACHINE="alphapca56" ;;
    282             "EV5.7 (21164PC)")
    283                 UNAME_MACHINE="alphapca57" ;;
    284             "EV6 (21264)")
    285                 UNAME_MACHINE="alphaev6" ;;
    286             "EV6.7 (21264A)")
    287                 UNAME_MACHINE="alphaev67" ;;
    288             "EV6.8CB (21264C)")
    289                 UNAME_MACHINE="alphaev68" ;;
    290             "EV6.8AL (21264B)")
    291                 UNAME_MACHINE="alphaev68" ;;
    292             "EV6.8CX (21264D)")
    293                 UNAME_MACHINE="alphaev68" ;;
    294             "EV6.9A (21264/EV69A)")
    295                 UNAME_MACHINE="alphaev69" ;;
    296             "EV7 (21364)")
    297                 UNAME_MACHINE="alphaev7" ;;
    298             "EV7.9 (21364A)")
    299                 UNAME_MACHINE="alphaev79" ;;
    300         esac
    301         # A Pn.n version is a patched version.
    302         # A Vn.n version is a released version.
    303         # A Tn.n version is a released field test version.
    304         # A Xn.n version is an unreleased experimental baselevel.
    305         # 1.2 uses "1.2" for uname -r.
    306         echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
    307         # Reset EXIT trap before exiting to avoid spurious non-zero exit code.
    308         exitcode=$?
    309         trap '' 0
    310         exit $exitcode ;;
    311     Alpha\ *:Windows_NT*:*)
    312         # How do we know it's Interix rather than the generic POSIX subsystem?
    313         # Should we change UNAME_MACHINE based on the output of uname instead
    314         # of the specific Alpha model?
    315         echo alpha-pc-interix
    316         exit ;;
    317     21064:Windows_NT:50:3)
    318         echo alpha-dec-winnt3.5
    319         exit ;;
    320     Amiga*:UNIX_System_V:4.0:*)
    321         echo m68k-unknown-sysv4
    322         exit ;;
    323     *:[Aa]miga[Oo][Ss]:*:*)
    324         echo ${UNAME_MACHINE}-unknown-amigaos
    325         exit ;;
    326     *:[Mm]orph[Oo][Ss]:*:*)
    327         echo ${UNAME_MACHINE}-unknown-morphos
    328         exit ;;
    329     *:OS/390:*:*)
    330         echo i370-ibm-openedition
    331         exit ;;
    332     *:z/VM:*:*)
    333         echo s390-ibm-zvmoe
    334         exit ;;
    335     *:OS400:*:*)
    336         echo powerpc-ibm-os400
    337         exit ;;
    338     arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
    339         echo arm-acorn-riscix${UNAME_RELEASE}
    340         exit ;;
    341     arm*:riscos:*:*|arm*:RISCOS:*:*)
    342         echo arm-unknown-riscos
    343         exit ;;
    344     SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
    345         echo hppa1.1-hitachi-hiuxmpp
    346         exit ;;
    347     Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
    348         # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
    349         if test "`(/bin/universe) 2>/dev/null`" = att ; then
    350                 echo pyramid-pyramid-sysv3
    351         else
    352                 echo pyramid-pyramid-bsd
    353         fi
    354         exit ;;
    355     NILE*:*:*:dcosx)
    356         echo pyramid-pyramid-svr4
    357         exit ;;
    358     DRS?6000:unix:4.0:6*)
    359         echo sparc-icl-nx6
    360         exit ;;
    361     DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
    362         case `/usr/bin/uname -p` in
    363             sparc) echo sparc-icl-nx7; exit ;;
    364         esac ;;
    365     s390x:SunOS:*:*)
    366         echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
    367         exit ;;
    368     sun4H:SunOS:5.*:*)
    369         echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
    370         exit ;;
    371     sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
    372         echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
    373         exit ;;
    374     i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
    375         echo i386-pc-auroraux${UNAME_RELEASE}
    376         exit ;;
    377     i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
    378         eval $set_cc_for_build
    379         SUN_ARCH="i386"
    380         # If there is a compiler, see if it is configured for 64-bit objects.
    381         # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
    382         # This test works for both compilers.
    383         if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
    384             if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
    385                 (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
    386                 grep IS_64BIT_ARCH >/dev/null
    387             then
    388                 SUN_ARCH="x86_64"
    389             fi
    390         fi
    391         echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
    392         exit ;;
    393     sun4*:SunOS:6*:*)
    394         # According to config.sub, this is the proper way to canonicalize
    395         # SunOS6.  Hard to guess exactly what SunOS6 will be like, but
    396         # it's likely to be more like Solaris than SunOS4.
    397         echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
    398         exit ;;
    399     sun4*:SunOS:*:*)
    400         case "`/usr/bin/arch -k`" in
    401             Series*|S4*)
    402                 UNAME_RELEASE=`uname -v`
    403                 ;;
    404         esac
    405         # Japanese Language versions have a version number like `4.1.3-JL'.
    406         echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
    407         exit ;;
    408     sun3*:SunOS:*:*)
    409         echo m68k-sun-sunos${UNAME_RELEASE}
    410         exit ;;
    411     sun*:*:4.2BSD:*)
    412         UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
    413         test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
    414         case "`/bin/arch`" in
    415             sun3)
    416                 echo m68k-sun-sunos${UNAME_RELEASE}
    417                 ;;
    418             sun4)
    419                 echo sparc-sun-sunos${UNAME_RELEASE}
    420                 ;;
    421         esac
    422         exit ;;
    423     aushp:SunOS:*:*)
    424         echo sparc-auspex-sunos${UNAME_RELEASE}
    425         exit ;;
    426     # The situation for MiNT is a little confusing.  The machine name
    427     # can be virtually everything (everything which is not
    428     # "atarist" or "atariste" at least should have a processor
    429     # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
    430     # to the lowercase version "mint" (or "freemint").  Finally
    431     # the system name "TOS" denotes a system which is actually not
    432     # MiNT.  But MiNT is downward compatible to TOS, so this should
    433     # be no problem.
    434     atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
    435         echo m68k-atari-mint${UNAME_RELEASE}
    436         exit ;;
    437     atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
    438         echo m68k-atari-mint${UNAME_RELEASE}
    439         exit ;;
    440     *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
    441         echo m68k-atari-mint${UNAME_RELEASE}
    442         exit ;;
    443     milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
    444         echo m68k-milan-mint${UNAME_RELEASE}
    445         exit ;;
    446     hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
    447         echo m68k-hades-mint${UNAME_RELEASE}
    448         exit ;;
    449     *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
    450         echo m68k-unknown-mint${UNAME_RELEASE}
    451         exit ;;
    452     m68k:machten:*:*)
    453         echo m68k-apple-machten${UNAME_RELEASE}
    454         exit ;;
    455     powerpc:machten:*:*)
    456         echo powerpc-apple-machten${UNAME_RELEASE}
    457         exit ;;
    458     RISC*:Mach:*:*)
    459         echo mips-dec-mach_bsd4.3
    460         exit ;;
    461     RISC*:ULTRIX:*:*)
    462         echo mips-dec-ultrix${UNAME_RELEASE}
    463         exit ;;
    464     VAX*:ULTRIX*:*:*)
    465         echo vax-dec-ultrix${UNAME_RELEASE}
    466         exit ;;
    467     2020:CLIX:*:* | 2430:CLIX:*:*)
    468         echo clipper-intergraph-clix${UNAME_RELEASE}
    469         exit ;;
    470     mips:*:*:UMIPS | mips:*:*:RISCos)
    471         eval $set_cc_for_build
    472         sed 's/^        //' << EOF >$dummy.c
    473 #ifdef __cplusplus
    474 #include <stdio.h>  /* for printf() prototype */
    475         int main (int argc, char *argv[]) {
    476 #else
    477         int main (argc, argv) int argc; char *argv[]; {
    478 #endif
    479         #if defined (host_mips) && defined (MIPSEB)
    480         #if defined (SYSTYPE_SYSV)
    481           printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
    482         #endif
    483         #if defined (SYSTYPE_SVR4)
    484           printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
    485         #endif
    486         #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
    487           printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
    488         #endif
    489         #endif
    490           exit (-1);
    491         }
    492 EOF
    493         $CC_FOR_BUILD -o $dummy $dummy.c &&
    494           dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
    495           SYSTEM_NAME=`$dummy $dummyarg` &&
    496             { echo "$SYSTEM_NAME"; exit; }
    497         echo mips-mips-riscos${UNAME_RELEASE}
    498         exit ;;
    499     Motorola:PowerMAX_OS:*:*)
    500         echo powerpc-motorola-powermax
    501         exit ;;
    502     Motorola:*:4.3:PL8-*)
    503         echo powerpc-harris-powermax
    504         exit ;;
    505     Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
    506         echo powerpc-harris-powermax
    507         exit ;;
    508     Night_Hawk:Power_UNIX:*:*)
    509         echo powerpc-harris-powerunix
    510         exit ;;
    511     m88k:CX/UX:7*:*)
    512         echo m88k-harris-cxux7
    513         exit ;;
    514     m88k:*:4*:R4*)
    515         echo m88k-motorola-sysv4
    516         exit ;;
    517     m88k:*:3*:R3*)
    518         echo m88k-motorola-sysv3
    519         exit ;;
    520     AViiON:dgux:*:*)
    521         # DG/UX returns AViiON for all architectures
    522         UNAME_PROCESSOR=`/usr/bin/uname -p`
    523         if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
    524         then
    525             if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
    526                [ ${TARGET_BINARY_INTERFACE}x = x ]
    527             then
    528                 echo m88k-dg-dgux${UNAME_RELEASE}
    529             else
    530                 echo m88k-dg-dguxbcs${UNAME_RELEASE}
    531             fi
    532         else
    533             echo i586-dg-dgux${UNAME_RELEASE}
    534         fi
    535         exit ;;
    536     M88*:DolphinOS:*:*) # DolphinOS (SVR3)
    537         echo m88k-dolphin-sysv3
    538         exit ;;
    539     M88*:*:R3*:*)
    540         # Delta 88k system running SVR3
    541         echo m88k-motorola-sysv3
    542         exit ;;
    543     XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
    544         echo m88k-tektronix-sysv3
    545         exit ;;
    546     Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
    547         echo m68k-tektronix-bsd
    548         exit ;;
    549     *:IRIX*:*:*)
    550         echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
    551         exit ;;
    552     ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
    553         echo romp-ibm-aix     # uname -m gives an 8 hex-code CPU id
    554         exit ;;               # Note that: echo "'`uname -s`'" gives 'AIX '
    555     i*86:AIX:*:*)
    556         echo i386-ibm-aix
    557         exit ;;
    558     ia64:AIX:*:*)
    559         if [ -x /usr/bin/oslevel ] ; then
    560                 IBM_REV=`/usr/bin/oslevel`
    561         else
    562                 IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
    563         fi
    564         echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
    565         exit ;;
    566     *:AIX:2:3)
    567         if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
    568                 eval $set_cc_for_build
    569                 sed 's/^                //' << EOF >$dummy.c
    570                 #include <sys/systemcfg.h>
    571 
    572                 main()
    573                         {
    574                         if (!__power_pc())
    575                                 exit(1);
    576                         puts("powerpc-ibm-aix3.2.5");
    577                         exit(0);
    578                         }
    579 EOF
    580                 if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
    581                 then
    582                         echo "$SYSTEM_NAME"
    583                 else
    584                         echo rs6000-ibm-aix3.2.5
    585                 fi
    586         elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
    587                 echo rs6000-ibm-aix3.2.4
    588         else
    589                 echo rs6000-ibm-aix3.2
    590         fi
    591         exit ;;
    592     *:AIX:*:[4567])
    593         IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
    594         if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
    595                 IBM_ARCH=rs6000
    596         else
    597                 IBM_ARCH=powerpc
    598         fi
    599         if [ -x /usr/bin/lslpp ] ; then
    600                 IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc |
    601                            awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
    602         else
    603                 IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
    604         fi
    605         echo ${IBM_ARCH}-ibm-aix${IBM_REV}
    606         exit ;;
    607     *:AIX:*:*)
    608         echo rs6000-ibm-aix
    609         exit ;;
    610     ibmrt:4.4BSD:*|romp-ibm:BSD:*)
    611         echo romp-ibm-bsd4.4
    612         exit ;;
    613     ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
    614         echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
    615         exit ;;                             # report: romp-ibm BSD 4.3
    616     *:BOSX:*:*)
    617         echo rs6000-bull-bosx
    618         exit ;;
    619     DPX/2?00:B.O.S.:*:*)
    620         echo m68k-bull-sysv3
    621         exit ;;
    622     9000/[34]??:4.3bsd:1.*:*)
    623         echo m68k-hp-bsd
    624         exit ;;
    625     hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
    626         echo m68k-hp-bsd4.4
    627         exit ;;
    628     9000/[34678]??:HP-UX:*:*)
    629         HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
    630         case "${UNAME_MACHINE}" in
    631             9000/31? )            HP_ARCH=m68000 ;;
    632             9000/[34]?? )         HP_ARCH=m68k ;;
    633             9000/[678][0-9][0-9])
    634                 if [ -x /usr/bin/getconf ]; then
    635                     sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
    636                     sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
    637                     case "${sc_cpu_version}" in
    638                       523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
    639                       528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
    640                       532)                      # CPU_PA_RISC2_0
    641                         case "${sc_kernel_bits}" in
    642                           32) HP_ARCH="hppa2.0n" ;;
    643                           64) HP_ARCH="hppa2.0w" ;;
    644                           '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
    645                         esac ;;
    646                     esac
    647                 fi
    648                 if [ "${HP_ARCH}" = "" ]; then
    649                     eval $set_cc_for_build
    650                     sed 's/^            //' << EOF >$dummy.c
    651 
    652                 #define _HPUX_SOURCE
    653                 #include <stdlib.h>
    654                 #include <unistd.h>
    655 
    656                 int main ()
    657                 {
    658                 #if defined(_SC_KERNEL_BITS)
    659                     long bits = sysconf(_SC_KERNEL_BITS);
    660                 #endif
    661                     long cpu  = sysconf (_SC_CPU_VERSION);
    662 
    663                     switch (cpu)
    664                         {
    665                         case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
    666                         case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
    667                         case CPU_PA_RISC2_0:
    668                 #if defined(_SC_KERNEL_BITS)
    669                             switch (bits)
    670                                 {
    671                                 case 64: puts ("hppa2.0w"); break;
    672                                 case 32: puts ("hppa2.0n"); break;
    673                                 default: puts ("hppa2.0"); break;
    674                                 } break;
    675                 #else  /* !defined(_SC_KERNEL_BITS) */
    676                             puts ("hppa2.0"); break;
    677                 #endif
    678                         default: puts ("hppa1.0"); break;
    679                         }
    680                     exit (0);
    681                 }
    682 EOF
    683                     (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
    684                     test -z "$HP_ARCH" && HP_ARCH=hppa
    685                 fi ;;
    686         esac
    687         if [ ${HP_ARCH} = "hppa2.0w" ]
    688         then
    689             eval $set_cc_for_build
    690 
    691             # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
    692             # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
    693             # generating 64-bit code.  GNU and HP use different nomenclature:
    694             #
    695             # $ CC_FOR_BUILD=cc ./config.guess
    696             # => hppa2.0w-hp-hpux11.23
    697             # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
    698             # => hppa64-hp-hpux11.23
    699 
    700             if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
    701                 grep -q __LP64__
    702             then
    703                 HP_ARCH="hppa2.0w"
    704             else
    705                 HP_ARCH="hppa64"
    706             fi
    707         fi
    708         echo ${HP_ARCH}-hp-hpux${HPUX_REV}
    709         exit ;;
    710     ia64:HP-UX:*:*)
    711         HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
    712         echo ia64-hp-hpux${HPUX_REV}
    713         exit ;;
    714     3050*:HI-UX:*:*)
    715         eval $set_cc_for_build
    716         sed 's/^        //' << EOF >$dummy.c
    717         #include <unistd.h>
    718         int
    719         main ()
    720         {
    721           long cpu = sysconf (_SC_CPU_VERSION);
    722           /* The order matters, because CPU_IS_HP_MC68K erroneously returns
    723              true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
    724              results, however.  */
    725           if (CPU_IS_PA_RISC (cpu))
    726             {
    727               switch (cpu)
    728                 {
    729                   case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
    730                   case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
    731                   case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
    732                   default: puts ("hppa-hitachi-hiuxwe2"); break;
    733                 }
    734             }
    735           else if (CPU_IS_HP_MC68K (cpu))
    736             puts ("m68k-hitachi-hiuxwe2");
    737           else puts ("unknown-hitachi-hiuxwe2");
    738           exit (0);
    739         }
    740 EOF
    741         $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
    742                 { echo "$SYSTEM_NAME"; exit; }
    743         echo unknown-hitachi-hiuxwe2
    744         exit ;;
    745     9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
    746         echo hppa1.1-hp-bsd
    747         exit ;;
    748     9000/8??:4.3bsd:*:*)
    749         echo hppa1.0-hp-bsd
    750         exit ;;
    751     *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
    752         echo hppa1.0-hp-mpeix
    753         exit ;;
    754     hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
    755         echo hppa1.1-hp-osf
    756         exit ;;
    757     hp8??:OSF1:*:*)
    758         echo hppa1.0-hp-osf
    759         exit ;;
    760     i*86:OSF1:*:*)
    761         if [ -x /usr/sbin/sysversion ] ; then
    762             echo ${UNAME_MACHINE}-unknown-osf1mk
    763         else
    764             echo ${UNAME_MACHINE}-unknown-osf1
    765         fi
    766         exit ;;
    767     parisc*:Lites*:*:*)
    768         echo hppa1.1-hp-lites
    769         exit ;;
    770     C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
    771         echo c1-convex-bsd
    772         exit ;;
    773     C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
    774         if getsysinfo -f scalar_acc
    775         then echo c32-convex-bsd
    776         else echo c2-convex-bsd
    777         fi
    778         exit ;;
    779     C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
    780         echo c34-convex-bsd
    781         exit ;;
    782     C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
    783         echo c38-convex-bsd
    784         exit ;;
    785     C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
    786         echo c4-convex-bsd
    787         exit ;;
    788     CRAY*Y-MP:*:*:*)
    789         echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
    790         exit ;;
    791     CRAY*[A-Z]90:*:*:*)
    792         echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
    793         | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
    794               -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
    795               -e 's/\.[^.]*$/.X/'
    796         exit ;;
    797     CRAY*TS:*:*:*)
    798         echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
    799         exit ;;
    800     CRAY*T3E:*:*:*)
    801         echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
    802         exit ;;
    803     CRAY*SV1:*:*:*)
    804         echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
    805         exit ;;
    806     *:UNICOS/mp:*:*)
    807         echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
    808         exit ;;
    809     F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
    810         FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
    811         FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
    812         FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
    813         echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
    814         exit ;;
    815     5000:UNIX_System_V:4.*:*)
    816         FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
    817         FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
    818         echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
    819         exit ;;
    820     i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
    821         echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
    822         exit ;;
    823     sparc*:BSD/OS:*:*)
    824         echo sparc-unknown-bsdi${UNAME_RELEASE}
    825         exit ;;
    826     *:BSD/OS:*:*)
    827         echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
    828         exit ;;
    829     *:FreeBSD:*:*)
    830         UNAME_PROCESSOR=`/usr/bin/uname -p`
    831         case ${UNAME_PROCESSOR} in
    832             amd64)
    833                 echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
    834             *)
    835                 echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
    836         esac
    837         exit ;;
    838     i*:CYGWIN*:*)
    839         echo ${UNAME_MACHINE}-pc-cygwin
    840         exit ;;
    841     *:MINGW64*:*)
    842         echo ${UNAME_MACHINE}-pc-mingw64
    843         exit ;;
    844     *:MINGW*:*)
    845         echo ${UNAME_MACHINE}-pc-mingw32
    846         exit ;;
    847     *:MSYS*:*)
    848         echo ${UNAME_MACHINE}-pc-msys
    849         exit ;;
    850     i*:windows32*:*)
    851         # uname -m includes "-pc" on this system.
    852         echo ${UNAME_MACHINE}-mingw32
    853         exit ;;
    854     i*:PW*:*)
    855         echo ${UNAME_MACHINE}-pc-pw32
    856         exit ;;
    857     *:Interix*:*)
    858         case ${UNAME_MACHINE} in
    859             x86)
    860                 echo i586-pc-interix${UNAME_RELEASE}
    861                 exit ;;
    862             authenticamd | genuineintel | EM64T)
    863                 echo x86_64-unknown-interix${UNAME_RELEASE}
    864                 exit ;;
    865             IA64)
    866                 echo ia64-unknown-interix${UNAME_RELEASE}
    867                 exit ;;
    868         esac ;;
    869     [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
    870         echo i${UNAME_MACHINE}-pc-mks
    871         exit ;;
    872     8664:Windows_NT:*)
    873         echo x86_64-pc-mks
    874         exit ;;
    875     i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
    876         # How do we know it's Interix rather than the generic POSIX subsystem?
    877         # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
    878         # UNAME_MACHINE based on the output of uname instead of i386?
    879         echo i586-pc-interix
    880         exit ;;
    881     i*:UWIN*:*)
    882         echo ${UNAME_MACHINE}-pc-uwin
    883         exit ;;
    884     amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
    885         echo x86_64-unknown-cygwin
    886         exit ;;
    887     p*:CYGWIN*:*)
    888         echo powerpcle-unknown-cygwin
    889         exit ;;
    890     prep*:SunOS:5.*:*)
    891         echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
    892         exit ;;
    893     *:GNU:*:*)
    894         # the GNU system
    895         echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
    896         exit ;;
    897     *:GNU/*:*:*)
    898         # other systems with GNU libc and userland
    899         echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC}
    900         exit ;;
    901     i*86:Minix:*:*)
    902         echo ${UNAME_MACHINE}-pc-minix
    903         exit ;;
    904     aarch64:Linux:*:*)
    905         echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
    906         exit ;;
    907     aarch64_be:Linux:*:*)
    908         UNAME_MACHINE=aarch64_be
    909         echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
    910         exit ;;
    911     alpha:Linux:*:*)
    912         case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
    913           EV5)   UNAME_MACHINE=alphaev5 ;;
    914           EV56)  UNAME_MACHINE=alphaev56 ;;
    915           PCA56) UNAME_MACHINE=alphapca56 ;;
    916           PCA57) UNAME_MACHINE=alphapca56 ;;
    917           EV6)   UNAME_MACHINE=alphaev6 ;;
    918           EV67)  UNAME_MACHINE=alphaev67 ;;
    919           EV68*) UNAME_MACHINE=alphaev68 ;;
    920         esac
    921         objdump --private-headers /bin/sh | grep -q ld.so.1
    922         if test "$?" = 0 ; then LIBC="gnulibc1" ; fi
    923         echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
    924         exit ;;
    925     arc:Linux:*:* | arceb:Linux:*:*)
    926         echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
    927         exit ;;
    928     arm*:Linux:*:*)
    929         eval $set_cc_for_build
    930         if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
    931             | grep -q __ARM_EABI__
    932         then
    933             echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
    934         else
    935             if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
    936                 | grep -q __ARM_PCS_VFP
    937             then
    938                 echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi
    939             else
    940                 echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf
    941             fi
    942         fi
    943         exit ;;
    944     avr32*:Linux:*:*)
    945         echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
    946         exit ;;
    947     cris:Linux:*:*)
    948         echo ${UNAME_MACHINE}-axis-linux-${LIBC}
    949         exit ;;
    950     crisv32:Linux:*:*)
    951         echo ${UNAME_MACHINE}-axis-linux-${LIBC}
    952         exit ;;
    953     e2k:Linux:*:*)
    954         echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
    955         exit ;;
    956     frv:Linux:*:*)
    957         echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
    958         exit ;;
    959     hexagon:Linux:*:*)
    960         echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
    961         exit ;;
    962     i*86:Linux:*:*)
    963         echo ${UNAME_MACHINE}-pc-linux-${LIBC}
    964         exit ;;
    965     ia64:Linux:*:*)
    966         echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
    967         exit ;;
    968     m32r*:Linux:*:*)
    969         echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
    970         exit ;;
    971     m68*:Linux:*:*)
    972         echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
    973         exit ;;
    974     mips:Linux:*:* | mips64:Linux:*:*)
    975         eval $set_cc_for_build
    976         sed 's/^        //' << EOF >$dummy.c
    977         #undef CPU
    978         #undef ${UNAME_MACHINE}
    979         #undef ${UNAME_MACHINE}el
    980         #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
    981         CPU=${UNAME_MACHINE}el
    982         #else
    983         #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
    984         CPU=${UNAME_MACHINE}
    985         #else
    986         CPU=
    987         #endif
    988         #endif
    989 EOF
    990         eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
    991         test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
    992         ;;
    993     openrisc*:Linux:*:*)
    994         echo or1k-unknown-linux-${LIBC}
    995         exit ;;
    996     or32:Linux:*:* | or1k*:Linux:*:*)
    997         echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
    998         exit ;;
    999     padre:Linux:*:*)
    1000         echo sparc-unknown-linux-${LIBC}
    1001         exit ;;
    1002     parisc64:Linux:*:* | hppa64:Linux:*:*)
    1003         echo hppa64-unknown-linux-${LIBC}
    1004         exit ;;
    1005     parisc:Linux:*:* | hppa:Linux:*:*)
    1006         # Look for CPU level
    1007         case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
    1008           PA7*) echo hppa1.1-unknown-linux-${LIBC} ;;
    1009           PA8*) echo hppa2.0-unknown-linux-${LIBC} ;;
    1010           *)    echo hppa-unknown-linux-${LIBC} ;;
    1011         esac
    1012         exit ;;
    1013     ppc64:Linux:*:*)
    1014         echo powerpc64-unknown-linux-${LIBC}
    1015         exit ;;
    1016     ppc:Linux:*:*)
    1017         echo powerpc-unknown-linux-${LIBC}
    1018         exit ;;
    1019     ppc64le:Linux:*:*)
    1020         echo powerpc64le-unknown-linux-${LIBC}
    1021         exit ;;
    1022     ppcle:Linux:*:*)
    1023         echo powerpcle-unknown-linux-${LIBC}
    1024         exit ;;
    1025     s390:Linux:*:* | s390x:Linux:*:*)
    1026         echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
    1027         exit ;;
    1028     sh64*:Linux:*:*)
    1029         echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
    1030         exit ;;
    1031     sh*:Linux:*:*)
    1032         echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
    1033         exit ;;
    1034     sparc:Linux:*:* | sparc64:Linux:*:*)
    1035         echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
    1036         exit ;;
    1037     tile*:Linux:*:*)
    1038         echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
    1039         exit ;;
    1040     vax:Linux:*:*)
    1041         echo ${UNAME_MACHINE}-dec-linux-${LIBC}
    1042         exit ;;
    1043     x86_64:Linux:*:*)
    1044         echo ${UNAME_MACHINE}-pc-linux-${LIBC}
    1045         exit ;;
    1046     xtensa*:Linux:*:*)
    1047         echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
    1048         exit ;;
    1049     i*86:DYNIX/ptx:4*:*)
    1050         # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
    1051         # earlier versions are messed up and put the nodename in both
    1052         # sysname and nodename.
    1053         echo i386-sequent-sysv4
    1054         exit ;;
    1055     i*86:UNIX_SV:4.2MP:2.*)
    1056         # Unixware is an offshoot of SVR4, but it has its own version
    1057         # number series starting with 2...
    1058         # I am not positive that other SVR4 systems won't match this,
    1059         # I just have to hope.  -- rms.
    1060         # Use sysv4.2uw... so that sysv4* matches it.
    1061         echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
    1062         exit ;;
    1063     i*86:OS/2:*:*)
    1064         # If we were able to find `uname', then EMX Unix compatibility
    1065         # is probably installed.
    1066         echo ${UNAME_MACHINE}-pc-os2-emx
    1067         exit ;;
    1068     i*86:XTS-300:*:STOP)
    1069         echo ${UNAME_MACHINE}-unknown-stop
    1070         exit ;;
    1071     i*86:atheos:*:*)
    1072         echo ${UNAME_MACHINE}-unknown-atheos
    1073         exit ;;
    1074     i*86:syllable:*:*)
    1075         echo ${UNAME_MACHINE}-pc-syllable
    1076         exit ;;
    1077     i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
    1078         echo i386-unknown-lynxos${UNAME_RELEASE}
    1079         exit ;;
    1080     i*86:*DOS:*:*)
    1081         echo ${UNAME_MACHINE}-pc-msdosdjgpp
    1082         exit ;;
    1083     i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
    1084         UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
    1085         if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
    1086                 echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
    1087         else
    1088                 echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
    1089         fi
    1090         exit ;;
    1091     i*86:*:5:[678]*)
    1092         # UnixWare 7.x, OpenUNIX and OpenServer 6.
    1093         case `/bin/uname -X | grep "^Machine"` in
    1094             *486*)           UNAME_MACHINE=i486 ;;
    1095             *Pentium)        UNAME_MACHINE=i586 ;;
    1096             *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
    1097         esac
    1098         echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
    1099         exit ;;
    1100     i*86:*:3.2:*)
    1101         if test -f /usr/options/cb.name; then
    1102                 UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
    1103                 echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
    1104         elif /bin/uname -X 2>/dev/null >/dev/null ; then
    1105                 UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
    1106                 (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
    1107                 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
    1108                         && UNAME_MACHINE=i586
    1109                 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
    1110                         && UNAME_MACHINE=i686
    1111                 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
    1112                         && UNAME_MACHINE=i686
    1113                 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
    1114         else
    1115                 echo ${UNAME_MACHINE}-pc-sysv32
    1116         fi
    1117         exit ;;
    1118     pc:*:*:*)
    1119         # Left here for compatibility:
    1120         # uname -m prints for DJGPP always 'pc', but it prints nothing about
    1121         # the processor, so we play safe by assuming i586.
    1122         # Note: whatever this is, it MUST be the same as what config.sub
    1123         # prints for the "djgpp" host, or else GDB configury will decide that
    1124         # this is a cross-build.
    1125         echo i586-pc-msdosdjgpp
    1126         exit ;;
    1127     Intel:Mach:3*:*)
    1128         echo i386-pc-mach3
    1129         exit ;;
    1130     paragon:*:*:*)
    1131         echo i860-intel-osf1
    1132         exit ;;
    1133     i860:*:4.*:*) # i860-SVR4
    1134         if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
    1135           echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
    1136         else # Add other i860-SVR4 vendors below as they are discovered.
    1137           echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
    1138         fi
    1139         exit ;;
    1140     mini*:CTIX:SYS*5:*)
    1141         # "miniframe"
    1142         echo m68010-convergent-sysv
    1143         exit ;;
    1144     mc68k:UNIX:SYSTEM5:3.51m)
    1145         echo m68k-convergent-sysv
    1146         exit ;;
    1147     M680?0:D-NIX:5.3:*)
    1148         echo m68k-diab-dnix
    1149         exit ;;
    1150     M68*:*:R3V[5678]*:*)
    1151         test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
    1152     3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
    1153         OS_REL=''
    1154         test -r /etc/.relid \
    1155         && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
    1156         /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
    1157           && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
    1158         /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
    1159           && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
    1160     3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
    1161         /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
    1162           && { echo i486-ncr-sysv4; exit; } ;;
    1163     NCR*:*:4.2:* | MPRAS*:*:4.2:*)
    1164         OS_REL='.3'
    1165         test -r /etc/.relid \
    1166             && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
    1167         /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
    1168             && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
    1169         /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
    1170             && { echo i586-ncr-sysv4.3${OS_REL}; exit; }
    1171         /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
    1172             && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
    1173     m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
    1174         echo m68k-unknown-lynxos${UNAME_RELEASE}
    1175         exit ;;
    1176     mc68030:UNIX_System_V:4.*:*)
    1177         echo m68k-atari-sysv4
    1178         exit ;;
    1179     TSUNAMI:LynxOS:2.*:*)
    1180         echo sparc-unknown-lynxos${UNAME_RELEASE}
    1181         exit ;;
    1182     rs6000:LynxOS:2.*:*)
    1183         echo rs6000-unknown-lynxos${UNAME_RELEASE}
    1184         exit ;;
    1185     PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
    1186         echo powerpc-unknown-lynxos${UNAME_RELEASE}
    1187         exit ;;
    1188     SM[BE]S:UNIX_SV:*:*)
    1189         echo mips-dde-sysv${UNAME_RELEASE}
    1190         exit ;;
    1191     RM*:ReliantUNIX-*:*:*)
    1192         echo mips-sni-sysv4
    1193         exit ;;
    1194     RM*:SINIX-*:*:*)
    1195         echo mips-sni-sysv4
    1196         exit ;;
    1197     *:SINIX-*:*:*)
    1198         if uname -p 2>/dev/null >/dev/null ; then
    1199                 UNAME_MACHINE=`(uname -p) 2>/dev/null`
    1200                 echo ${UNAME_MACHINE}-sni-sysv4
    1201         else
    1202                 echo ns32k-sni-sysv
    1203         fi
    1204         exit ;;
    1205     PENTIUM:*:4.0*:*)   # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
    1206                         # says <Richard.M.Bartel@ccMail.Census.GOV>
    1207         echo i586-unisys-sysv4
    1208         exit ;;
    1209     *:UNIX_System_V:4*:FTX*)
    1210         # From Gerald Hewes <hewes@openmarket.com>.
    1211         # How about differentiating between stratus architectures? -djm
    1212         echo hppa1.1-stratus-sysv4
    1213         exit ;;
    1214     *:*:*:FTX*)
    1215         # From seanf@swdc.stratus.com.
    1216         echo i860-stratus-sysv4
    1217         exit ;;
    1218     i*86:VOS:*:*)
    1219         # From Paul.Green@stratus.com.
    1220         echo ${UNAME_MACHINE}-stratus-vos
    1221         exit ;;
    1222     *:VOS:*:*)
    1223         # From Paul.Green@stratus.com.
    1224         echo hppa1.1-stratus-vos
    1225         exit ;;
    1226     mc68*:A/UX:*:*)
    1227         echo m68k-apple-aux${UNAME_RELEASE}
    1228         exit ;;
    1229     news*:NEWS-OS:6*:*)
    1230         echo mips-sony-newsos6
    1231         exit ;;
    1232     R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
    1233         if [ -d /usr/nec ]; then
    1234                 echo mips-nec-sysv${UNAME_RELEASE}
    1235         else
    1236                 echo mips-unknown-sysv${UNAME_RELEASE}
    1237         fi
    1238         exit ;;
    1239     BeBox:BeOS:*:*)     # BeOS running on hardware made by Be, PPC only.
    1240         echo powerpc-be-beos
    1241         exit ;;
    1242     BeMac:BeOS:*:*)     # BeOS running on Mac or Mac clone, PPC only.
    1243         echo powerpc-apple-beos
    1244         exit ;;
    1245     BePC:BeOS:*:*)      # BeOS running on Intel PC compatible.
    1246         echo i586-pc-beos
    1247         exit ;;
    1248     BePC:Haiku:*:*)     # Haiku running on Intel PC compatible.
    1249         echo i586-pc-haiku
    1250         exit ;;
    1251     x86_64:Haiku:*:*)
    1252         echo x86_64-unknown-haiku
    1253         exit ;;
    1254     SX-4:SUPER-UX:*:*)
    1255         echo sx4-nec-superux${UNAME_RELEASE}
    1256         exit ;;
    1257     SX-5:SUPER-UX:*:*)
    1258         echo sx5-nec-superux${UNAME_RELEASE}
    1259         exit ;;
    1260     SX-6:SUPER-UX:*:*)
    1261         echo sx6-nec-superux${UNAME_RELEASE}
    1262         exit ;;
    1263     SX-7:SUPER-UX:*:*)
    1264         echo sx7-nec-superux${UNAME_RELEASE}
    1265         exit ;;
    1266     SX-8:SUPER-UX:*:*)
    1267         echo sx8-nec-superux${UNAME_RELEASE}
    1268         exit ;;
    1269     SX-8R:SUPER-UX:*:*)
    1270         echo sx8r-nec-superux${UNAME_RELEASE}
    1271         exit ;;
    1272     Power*:Rhapsody:*:*)
    1273         echo powerpc-apple-rhapsody${UNAME_RELEASE}
    1274         exit ;;
    1275     *:Rhapsody:*:*)
    1276         echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
    1277         exit ;;
    1278     *:Darwin:*:*)
    1279         UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
    1280         eval $set_cc_for_build
    1281         if test "$UNAME_PROCESSOR" = unknown ; then
    1282             UNAME_PROCESSOR=powerpc
    1283         fi
    1284         if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then
    1285             if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
    1286                 if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
    1287                     (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
    1288                     grep IS_64BIT_ARCH >/dev/null
    1289                 then
    1290                     case $UNAME_PROCESSOR in
    1291                         i386) UNAME_PROCESSOR=x86_64 ;;
    1292                         powerpc) UNAME_PROCESSOR=powerpc64 ;;
    1293                     esac
    1294                 fi
    1295             fi
    1296         elif test "$UNAME_PROCESSOR" = i386 ; then
    1297             # Avoid executing cc on OS X 10.9, as it ships with a stub
    1298             # that puts up a graphical alert prompting to install
    1299             # developer tools.  Any system running Mac OS X 10.7 or
    1300             # later (Darwin 11 and later) is required to have a 64-bit
    1301             # processor. This is not true of the ARM version of Darwin
    1302             # that Apple uses in portable devices.
    1303             UNAME_PROCESSOR=x86_64
    1304         fi
    1305         echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
    1306         exit ;;
    1307     *:procnto*:*:* | *:QNX:[0123456789]*:*)
    1308         UNAME_PROCESSOR=`uname -p`
    1309         if test "$UNAME_PROCESSOR" = "x86"; then
    1310                 UNAME_PROCESSOR=i386
    1311                 UNAME_MACHINE=pc
    1312         fi
    1313         echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
    1314         exit ;;
    1315     *:QNX:*:4*)
    1316         echo i386-pc-qnx
    1317         exit ;;
    1318     NEO-?:NONSTOP_KERNEL:*:*)
    1319         echo neo-tandem-nsk${UNAME_RELEASE}
    1320         exit ;;
    1321     NSE-*:NONSTOP_KERNEL:*:*)
    1322         echo nse-tandem-nsk${UNAME_RELEASE}
    1323         exit ;;
    1324     NSR-?:NONSTOP_KERNEL:*:*)
    1325         echo nsr-tandem-nsk${UNAME_RELEASE}
    1326         exit ;;
    1327     *:NonStop-UX:*:*)
    1328         echo mips-compaq-nonstopux
    1329         exit ;;
    1330     BS2000:POSIX*:*:*)
    1331         echo bs2000-siemens-sysv
    1332         exit ;;
    1333     DS/*:UNIX_System_V:*:*)
    1334         echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
    1335         exit ;;
    1336     *:Plan9:*:*)
    1337         # "uname -m" is not consistent, so use $cputype instead. 386
    1338         # is converted to i386 for consistency with other x86
    1339         # operating systems.
    1340         if test "$cputype" = "386"; then
    1341             UNAME_MACHINE=i386
    1342         else
    1343             UNAME_MACHINE="$cputype"
    1344         fi
    1345         echo ${UNAME_MACHINE}-unknown-plan9
    1346         exit ;;
    1347     *:TOPS-10:*:*)
    1348         echo pdp10-unknown-tops10
    1349         exit ;;
    1350     *:TENEX:*:*)
    1351         echo pdp10-unknown-tenex
    1352         exit ;;
    1353     KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
    1354         echo pdp10-dec-tops20
    1355         exit ;;
    1356     XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
    1357         echo pdp10-xkl-tops20
    1358         exit ;;
    1359     *:TOPS-20:*:*)
    1360         echo pdp10-unknown-tops20
    1361         exit ;;
    1362     *:ITS:*:*)
    1363         echo pdp10-unknown-its
    1364         exit ;;
    1365     SEI:*:*:SEIUX)
    1366         echo mips-sei-seiux${UNAME_RELEASE}
    1367         exit ;;
    1368     *:DragonFly:*:*)
    1369         echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
    1370         exit ;;
    1371     *:*VMS:*:*)
    1372         UNAME_MACHINE=`(uname -p) 2>/dev/null`
    1373         case "${UNAME_MACHINE}" in
    1374             A*) echo alpha-dec-vms ; exit ;;
    1375             I*) echo ia64-dec-vms ; exit ;;
    1376             V*) echo vax-dec-vms ; exit ;;
    1377         esac ;;
    1378     *:XENIX:*:SysV)
    1379         echo i386-pc-xenix
    1380         exit ;;
    1381     i*86:skyos:*:*)
    1382         echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
    1383         exit ;;
    1384     i*86:rdos:*:*)
    1385         echo ${UNAME_MACHINE}-pc-rdos
    1386         exit ;;
    1387     i*86:AROS:*:*)
    1388         echo ${UNAME_MACHINE}-pc-aros
    1389         exit ;;
    1390     x86_64:VMkernel:*:*)
    1391         echo ${UNAME_MACHINE}-unknown-esx
    1392         exit ;;
    1393 esac
    1394 
    1395 cat >&2 <<EOF
    1396 $0: unable to guess system type
    1397 
    1398 This script, last modified $timestamp, has failed to recognize
    1399 the operating system you are using. It is advised that you
    1400 download the most up to date version of the config scripts from
    1401 
    1402   http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
    1403 and
    1404   http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
    1405 
    1406 If the version you run ($0) is already up to date, please
    1407 send the following data and any information you think might be
    1408 pertinent to <config-patches@gnu.org> in order to provide the needed
    1409 information to handle your system.
    1410 
    1411 config.guess timestamp = $timestamp
    1412 
    1413 uname -m = `(uname -m) 2>/dev/null || echo unknown`
    1414 uname -r = `(uname -r) 2>/dev/null || echo unknown`
    1415 uname -s = `(uname -s) 2>/dev/null || echo unknown`
    1416 uname -v = `(uname -v) 2>/dev/null || echo unknown`
    1417 
    1418 /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
    1419 /bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
    1420 
    1421 hostinfo               = `(hostinfo) 2>/dev/null`
    1422 /bin/universe          = `(/bin/universe) 2>/dev/null`
    1423 /usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
    1424 /bin/arch              = `(/bin/arch) 2>/dev/null`
    1425 /usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
    1426 /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
    1427 
    1428 UNAME_MACHINE = ${UNAME_MACHINE}
    1429 UNAME_RELEASE = ${UNAME_RELEASE}
    1430 UNAME_SYSTEM  = ${UNAME_SYSTEM}
    1431 UNAME_VERSION = ${UNAME_VERSION}
    1432 EOF
    1433 
    1434 exit 1
    1435 
    1436 # Local variables:
    1437 # eval: (add-hook 'write-file-hooks 'time-stamp)
    1438 # time-stamp-start: "timestamp='"
    1439 # time-stamp-format: "%:y-%02m-%02d"
    1440 # time-stamp-end: "'"
    1441 # End:
     1/usr/share/automake-1.15/config.guess
  • automake/config.sub

    • Property mode changed from 100755 to 120000
    r0720e049 r3d4b23fa  
    1 #! /bin/sh
    2 # Configuration validation subroutine script.
    3 #   Copyright 1992-2015 Free Software Foundation, Inc.
    4 
    5 timestamp='2015-08-20'
    6 
    7 # This file is free software; you can redistribute it and/or modify it
    8 # under the terms of the GNU General Public License as published by
    9 # the Free Software Foundation; either version 3 of the License, or
    10 # (at your option) any later version.
    11 #
    12 # This program is distributed in the hope that it will be useful, but
    13 # WITHOUT ANY WARRANTY; without even the implied warranty of
    14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    15 # General Public License for more details.
    16 #
    17 # You should have received a copy of the GNU General Public License
    18 # along with this program; if not, see <http://www.gnu.org/licenses/>.
    19 #
    20 # As a special exception to the GNU General Public License, if you
    21 # distribute this file as part of a program that contains a
    22 # configuration script generated by Autoconf, you may include it under
    23 # the same distribution terms that you use for the rest of that
    24 # program.  This Exception is an additional permission under section 7
    25 # of the GNU General Public License, version 3 ("GPLv3").
    26 
    27 
    28 # Please send patches to <config-patches@gnu.org>.
    29 #
    30 # Configuration subroutine to validate and canonicalize a configuration type.
    31 # Supply the specified configuration type as an argument.
    32 # If it is invalid, we print an error message on stderr and exit with code 1.
    33 # Otherwise, we print the canonical config type on stdout and succeed.
    34 
    35 # You can get the latest version of this script from:
    36 # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
    37 
    38 # This file is supposed to be the same for all GNU packages
    39 # and recognize all the CPU types, system types and aliases
    40 # that are meaningful with *any* GNU software.
    41 # Each package is responsible for reporting which valid configurations
    42 # it does not support.  The user should be able to distinguish
    43 # a failure to support a valid configuration from a meaningless
    44 # configuration.
    45 
    46 # The goal of this file is to map all the various variations of a given
    47 # machine specification into a single specification in the form:
    48 #       CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
    49 # or in some cases, the newer four-part form:
    50 #       CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
    51 # It is wrong to echo any other type of specification.
    52 
    53 me=`echo "$0" | sed -e 's,.*/,,'`
    54 
    55 usage="\
    56 Usage: $0 [OPTION] CPU-MFR-OPSYS
    57        $0 [OPTION] ALIAS
    58 
    59 Canonicalize a configuration name.
    60 
    61 Operation modes:
    62   -h, --help         print this help, then exit
    63   -t, --time-stamp   print date of last modification, then exit
    64   -v, --version      print version number, then exit
    65 
    66 Report bugs and patches to <config-patches@gnu.org>."
    67 
    68 version="\
    69 GNU config.sub ($timestamp)
    70 
    71 Copyright 1992-2015 Free Software Foundation, Inc.
    72 
    73 This is free software; see the source for copying conditions.  There is NO
    74 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
    75 
    76 help="
    77 Try \`$me --help' for more information."
    78 
    79 # Parse command line
    80 while test $# -gt 0 ; do
    81   case $1 in
    82     --time-stamp | --time* | -t )
    83        echo "$timestamp" ; exit ;;
    84     --version | -v )
    85        echo "$version" ; exit ;;
    86     --help | --h* | -h )
    87        echo "$usage"; exit ;;
    88     -- )     # Stop option processing
    89        shift; break ;;
    90     - ) # Use stdin as input.
    91        break ;;
    92     -* )
    93        echo "$me: invalid option $1$help"
    94        exit 1 ;;
    95 
    96     *local*)
    97        # First pass through any local machine types.
    98        echo $1
    99        exit ;;
    100 
    101     * )
    102        break ;;
    103   esac
    104 done
    105 
    106 case $# in
    107  0) echo "$me: missing argument$help" >&2
    108     exit 1;;
    109  1) ;;
    110  *) echo "$me: too many arguments$help" >&2
    111     exit 1;;
    112 esac
    113 
    114 # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
    115 # Here we must recognize all the valid KERNEL-OS combinations.
    116 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
    117 case $maybe_os in
    118   nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
    119   linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
    120   knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
    121   kopensolaris*-gnu* | \
    122   storm-chaos* | os2-emx* | rtmk-nova*)
    123     os=-$maybe_os
    124     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
    125     ;;
    126   android-linux)
    127     os=-linux-android
    128     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
    129     ;;
    130   *)
    131     basic_machine=`echo $1 | sed 's/-[^-]*$//'`
    132     if [ $basic_machine != $1 ]
    133     then os=`echo $1 | sed 's/.*-/-/'`
    134     else os=; fi
    135     ;;
    136 esac
    137 
    138 ### Let's recognize common machines as not being operating systems so
    139 ### that things like config.sub decstation-3100 work.  We also
    140 ### recognize some manufacturers as not being operating systems, so we
    141 ### can provide default operating systems below.
    142 case $os in
    143         -sun*os*)
    144                 # Prevent following clause from handling this invalid input.
    145                 ;;
    146         -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
    147         -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
    148         -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
    149         -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
    150         -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
    151         -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
    152         -apple | -axis | -knuth | -cray | -microblaze*)
    153                 os=
    154                 basic_machine=$1
    155                 ;;
    156         -bluegene*)
    157                 os=-cnk
    158                 ;;
    159         -sim | -cisco | -oki | -wec | -winbond)
    160                 os=
    161                 basic_machine=$1
    162                 ;;
    163         -scout)
    164                 ;;
    165         -wrs)
    166                 os=-vxworks
    167                 basic_machine=$1
    168                 ;;
    169         -chorusos*)
    170                 os=-chorusos
    171                 basic_machine=$1
    172                 ;;
    173         -chorusrdb)
    174                 os=-chorusrdb
    175                 basic_machine=$1
    176                 ;;
    177         -hiux*)
    178                 os=-hiuxwe2
    179                 ;;
    180         -sco6)
    181                 os=-sco5v6
    182                 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
    183                 ;;
    184         -sco5)
    185                 os=-sco3.2v5
    186                 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
    187                 ;;
    188         -sco4)
    189                 os=-sco3.2v4
    190                 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
    191                 ;;
    192         -sco3.2.[4-9]*)
    193                 os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
    194                 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
    195                 ;;
    196         -sco3.2v[4-9]*)
    197                 # Don't forget version if it is 3.2v4 or newer.
    198                 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
    199                 ;;
    200         -sco5v6*)
    201                 # Don't forget version if it is 3.2v4 or newer.
    202                 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
    203                 ;;
    204         -sco*)
    205                 os=-sco3.2v2
    206                 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
    207                 ;;
    208         -udk*)
    209                 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
    210                 ;;
    211         -isc)
    212                 os=-isc2.2
    213                 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
    214                 ;;
    215         -clix*)
    216                 basic_machine=clipper-intergraph
    217                 ;;
    218         -isc*)
    219                 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
    220                 ;;
    221         -lynx*178)
    222                 os=-lynxos178
    223                 ;;
    224         -lynx*5)
    225                 os=-lynxos5
    226                 ;;
    227         -lynx*)
    228                 os=-lynxos
    229                 ;;
    230         -ptx*)
    231                 basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
    232                 ;;
    233         -windowsnt*)
    234                 os=`echo $os | sed -e 's/windowsnt/winnt/'`
    235                 ;;
    236         -psos*)
    237                 os=-psos
    238                 ;;
    239         -mint | -mint[0-9]*)
    240                 basic_machine=m68k-atari
    241                 os=-mint
    242                 ;;
    243 esac
    244 
    245 # Decode aliases for certain CPU-COMPANY combinations.
    246 case $basic_machine in
    247         # Recognize the basic CPU types without company name.
    248         # Some are omitted here because they have special meanings below.
    249         1750a | 580 \
    250         | a29k \
    251         | aarch64 | aarch64_be \
    252         | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
    253         | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
    254         | am33_2.0 \
    255         | arc | arceb \
    256         | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
    257         | avr | avr32 \
    258         | ba \
    259         | be32 | be64 \
    260         | bfin \
    261         | c4x | c8051 | clipper \
    262         | d10v | d30v | dlx | dsp16xx \
    263         | e2k | epiphany \
    264         | fido | fr30 | frv | ft32 \
    265         | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
    266         | hexagon \
    267         | i370 | i860 | i960 | ia64 \
    268         | ip2k | iq2000 \
    269         | k1om \
    270         | le32 | le64 \
    271         | lm32 \
    272         | m32c | m32r | m32rle | m68000 | m68k | m88k \
    273         | maxq | mb | microblaze | microblazeel | mcore | mep | metag \
    274         | mips | mipsbe | mipseb | mipsel | mipsle \
    275         | mips16 \
    276         | mips64 | mips64el \
    277         | mips64octeon | mips64octeonel \
    278         | mips64orion | mips64orionel \
    279         | mips64r5900 | mips64r5900el \
    280         | mips64vr | mips64vrel \
    281         | mips64vr4100 | mips64vr4100el \
    282         | mips64vr4300 | mips64vr4300el \
    283         | mips64vr5000 | mips64vr5000el \
    284         | mips64vr5900 | mips64vr5900el \
    285         | mipsisa32 | mipsisa32el \
    286         | mipsisa32r2 | mipsisa32r2el \
    287         | mipsisa32r6 | mipsisa32r6el \
    288         | mipsisa64 | mipsisa64el \
    289         | mipsisa64r2 | mipsisa64r2el \
    290         | mipsisa64r6 | mipsisa64r6el \
    291         | mipsisa64sb1 | mipsisa64sb1el \
    292         | mipsisa64sr71k | mipsisa64sr71kel \
    293         | mipsr5900 | mipsr5900el \
    294         | mipstx39 | mipstx39el \
    295         | mn10200 | mn10300 \
    296         | moxie \
    297         | mt \
    298         | msp430 \
    299         | nds32 | nds32le | nds32be \
    300         | nios | nios2 | nios2eb | nios2el \
    301         | ns16k | ns32k \
    302         | open8 | or1k | or1knd | or32 \
    303         | pdp10 | pdp11 | pj | pjl \
    304         | powerpc | powerpc64 | powerpc64le | powerpcle \
    305         | pyramid \
    306         | riscv32 | riscv64 \
    307         | rl78 | rx \
    308         | score \
    309         | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
    310         | sh64 | sh64le \
    311         | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
    312         | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
    313         | spu \
    314         | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
    315         | ubicom32 \
    316         | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
    317         | visium \
    318         | we32k \
    319         | x86 | xc16x | xstormy16 | xtensa \
    320         | z8k | z80)
    321                 basic_machine=$basic_machine-unknown
    322                 ;;
    323         c54x)
    324                 basic_machine=tic54x-unknown
    325                 ;;
    326         c55x)
    327                 basic_machine=tic55x-unknown
    328                 ;;
    329         c6x)
    330                 basic_machine=tic6x-unknown
    331                 ;;
    332         leon|leon[3-9])
    333                 basic_machine=sparc-$basic_machine
    334                 ;;
    335         m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip)
    336                 basic_machine=$basic_machine-unknown
    337                 os=-none
    338                 ;;
    339         m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
    340                 ;;
    341         ms1)
    342                 basic_machine=mt-unknown
    343                 ;;
    344 
    345         strongarm | thumb | xscale)
    346                 basic_machine=arm-unknown
    347                 ;;
    348         xgate)
    349                 basic_machine=$basic_machine-unknown
    350                 os=-none
    351                 ;;
    352         xscaleeb)
    353                 basic_machine=armeb-unknown
    354                 ;;
    355 
    356         xscaleel)
    357                 basic_machine=armel-unknown
    358                 ;;
    359 
    360         # We use `pc' rather than `unknown'
    361         # because (1) that's what they normally are, and
    362         # (2) the word "unknown" tends to confuse beginning users.
    363         i*86 | x86_64)
    364           basic_machine=$basic_machine-pc
    365           ;;
    366         # Object if more than one company name word.
    367         *-*-*)
    368                 echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
    369                 exit 1
    370                 ;;
    371         # Recognize the basic CPU types with company name.
    372         580-* \
    373         | a29k-* \
    374         | aarch64-* | aarch64_be-* \
    375         | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
    376         | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
    377         | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
    378         | arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
    379         | avr-* | avr32-* \
    380         | ba-* \
    381         | be32-* | be64-* \
    382         | bfin-* | bs2000-* \
    383         | c[123]* | c30-* | [cjt]90-* | c4x-* \
    384         | c8051-* | clipper-* | craynv-* | cydra-* \
    385         | d10v-* | d30v-* | dlx-* \
    386         | e2k-* | elxsi-* \
    387         | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
    388         | h8300-* | h8500-* \
    389         | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
    390         | hexagon-* \
    391         | i*86-* | i860-* | i960-* | ia64-* \
    392         | ip2k-* | iq2000-* \
    393         | k1om-* \
    394         | le32-* | le64-* \
    395         | lm32-* \
    396         | m32c-* | m32r-* | m32rle-* \
    397         | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
    398         | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
    399         | microblaze-* | microblazeel-* \
    400         | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
    401         | mips16-* \
    402         | mips64-* | mips64el-* \
    403         | mips64octeon-* | mips64octeonel-* \
    404         | mips64orion-* | mips64orionel-* \
    405         | mips64r5900-* | mips64r5900el-* \
    406         | mips64vr-* | mips64vrel-* \
    407         | mips64vr4100-* | mips64vr4100el-* \
    408         | mips64vr4300-* | mips64vr4300el-* \
    409         | mips64vr5000-* | mips64vr5000el-* \
    410         | mips64vr5900-* | mips64vr5900el-* \
    411         | mipsisa32-* | mipsisa32el-* \
    412         | mipsisa32r2-* | mipsisa32r2el-* \
    413         | mipsisa32r6-* | mipsisa32r6el-* \
    414         | mipsisa64-* | mipsisa64el-* \
    415         | mipsisa64r2-* | mipsisa64r2el-* \
    416         | mipsisa64r6-* | mipsisa64r6el-* \
    417         | mipsisa64sb1-* | mipsisa64sb1el-* \
    418         | mipsisa64sr71k-* | mipsisa64sr71kel-* \
    419         | mipsr5900-* | mipsr5900el-* \
    420         | mipstx39-* | mipstx39el-* \
    421         | mmix-* \
    422         | mt-* \
    423         | msp430-* \
    424         | nds32-* | nds32le-* | nds32be-* \
    425         | nios-* | nios2-* | nios2eb-* | nios2el-* \
    426         | none-* | np1-* | ns16k-* | ns32k-* \
    427         | open8-* \
    428         | or1k*-* \
    429         | orion-* \
    430         | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
    431         | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
    432         | pyramid-* \
    433         | riscv32-* | riscv64-* \
    434         | rl78-* | romp-* | rs6000-* | rx-* \
    435         | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
    436         | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
    437         | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
    438         | sparclite-* \
    439         | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \
    440         | tahoe-* \
    441         | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
    442         | tile*-* \
    443         | tron-* \
    444         | ubicom32-* \
    445         | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
    446         | vax-* \
    447         | visium-* \
    448         | we32k-* \
    449         | x86-* | x86_64-* | xc16x-* | xps100-* \
    450         | xstormy16-* | xtensa*-* \
    451         | ymp-* \
    452         | z8k-* | z80-*)
    453                 ;;
    454         # Recognize the basic CPU types without company name, with glob match.
    455         xtensa*)
    456                 basic_machine=$basic_machine-unknown
    457                 ;;
    458         # Recognize the various machine names and aliases which stand
    459         # for a CPU type and a company and sometimes even an OS.
    460         386bsd)
    461                 basic_machine=i386-unknown
    462                 os=-bsd
    463                 ;;
    464         3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
    465                 basic_machine=m68000-att
    466                 ;;
    467         3b*)
    468                 basic_machine=we32k-att
    469                 ;;
    470         a29khif)
    471                 basic_machine=a29k-amd
    472                 os=-udi
    473                 ;;
    474         abacus)
    475                 basic_machine=abacus-unknown
    476                 ;;
    477         adobe68k)
    478                 basic_machine=m68010-adobe
    479                 os=-scout
    480                 ;;
    481         alliant | fx80)
    482                 basic_machine=fx80-alliant
    483                 ;;
    484         altos | altos3068)
    485                 basic_machine=m68k-altos
    486                 ;;
    487         am29k)
    488                 basic_machine=a29k-none
    489                 os=-bsd
    490                 ;;
    491         amd64)
    492                 basic_machine=x86_64-pc
    493                 ;;
    494         amd64-*)
    495                 basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
    496                 ;;
    497         amdahl)
    498                 basic_machine=580-amdahl
    499                 os=-sysv
    500                 ;;
    501         amiga | amiga-*)
    502                 basic_machine=m68k-unknown
    503                 ;;
    504         amigaos | amigados)
    505                 basic_machine=m68k-unknown
    506                 os=-amigaos
    507                 ;;
    508         amigaunix | amix)
    509                 basic_machine=m68k-unknown
    510                 os=-sysv4
    511                 ;;
    512         apollo68)
    513                 basic_machine=m68k-apollo
    514                 os=-sysv
    515                 ;;
    516         apollo68bsd)
    517                 basic_machine=m68k-apollo
    518                 os=-bsd
    519                 ;;
    520         aros)
    521                 basic_machine=i386-pc
    522                 os=-aros
    523                 ;;
    524         asmjs)
    525                 basic_machine=asmjs-unknown
    526                 ;;
    527         aux)
    528                 basic_machine=m68k-apple
    529                 os=-aux
    530                 ;;
    531         balance)
    532                 basic_machine=ns32k-sequent
    533                 os=-dynix
    534                 ;;
    535         blackfin)
    536                 basic_machine=bfin-unknown
    537                 os=-linux
    538                 ;;
    539         blackfin-*)
    540                 basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
    541                 os=-linux
    542                 ;;
    543         bluegene*)
    544                 basic_machine=powerpc-ibm
    545                 os=-cnk
    546                 ;;
    547         c54x-*)
    548                 basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
    549                 ;;
    550         c55x-*)
    551                 basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
    552                 ;;
    553         c6x-*)
    554                 basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
    555                 ;;
    556         c90)
    557                 basic_machine=c90-cray
    558                 os=-unicos
    559                 ;;
    560         cegcc)
    561                 basic_machine=arm-unknown
    562                 os=-cegcc
    563                 ;;
    564         convex-c1)
    565                 basic_machine=c1-convex
    566                 os=-bsd
    567                 ;;
    568         convex-c2)
    569                 basic_machine=c2-convex
    570                 os=-bsd
    571                 ;;
    572         convex-c32)
    573                 basic_machine=c32-convex
    574                 os=-bsd
    575                 ;;
    576         convex-c34)
    577                 basic_machine=c34-convex
    578                 os=-bsd
    579                 ;;
    580         convex-c38)
    581                 basic_machine=c38-convex
    582                 os=-bsd
    583                 ;;
    584         cray | j90)
    585                 basic_machine=j90-cray
    586                 os=-unicos
    587                 ;;
    588         craynv)
    589                 basic_machine=craynv-cray
    590                 os=-unicosmp
    591                 ;;
    592         cr16 | cr16-*)
    593                 basic_machine=cr16-unknown
    594                 os=-elf
    595                 ;;
    596         crds | unos)
    597                 basic_machine=m68k-crds
    598                 ;;
    599         crisv32 | crisv32-* | etraxfs*)
    600                 basic_machine=crisv32-axis
    601                 ;;
    602         cris | cris-* | etrax*)
    603                 basic_machine=cris-axis
    604                 ;;
    605         crx)
    606                 basic_machine=crx-unknown
    607                 os=-elf
    608                 ;;
    609         da30 | da30-*)
    610                 basic_machine=m68k-da30
    611                 ;;
    612         decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
    613                 basic_machine=mips-dec
    614                 ;;
    615         decsystem10* | dec10*)
    616                 basic_machine=pdp10-dec
    617                 os=-tops10
    618                 ;;
    619         decsystem20* | dec20*)
    620                 basic_machine=pdp10-dec
    621                 os=-tops20
    622                 ;;
    623         delta | 3300 | motorola-3300 | motorola-delta \
    624               | 3300-motorola | delta-motorola)
    625                 basic_machine=m68k-motorola
    626                 ;;
    627         delta88)
    628                 basic_machine=m88k-motorola
    629                 os=-sysv3
    630                 ;;
    631         dicos)
    632                 basic_machine=i686-pc
    633                 os=-dicos
    634                 ;;
    635         djgpp)
    636                 basic_machine=i586-pc
    637                 os=-msdosdjgpp
    638                 ;;
    639         dpx20 | dpx20-*)
    640                 basic_machine=rs6000-bull
    641                 os=-bosx
    642                 ;;
    643         dpx2* | dpx2*-bull)
    644                 basic_machine=m68k-bull
    645                 os=-sysv3
    646                 ;;
    647         ebmon29k)
    648                 basic_machine=a29k-amd
    649                 os=-ebmon
    650                 ;;
    651         elxsi)
    652                 basic_machine=elxsi-elxsi
    653                 os=-bsd
    654                 ;;
    655         encore | umax | mmax)
    656                 basic_machine=ns32k-encore
    657                 ;;
    658         es1800 | OSE68k | ose68k | ose | OSE)
    659                 basic_machine=m68k-ericsson
    660                 os=-ose
    661                 ;;
    662         fx2800)
    663                 basic_machine=i860-alliant
    664                 ;;
    665         genix)
    666                 basic_machine=ns32k-ns
    667                 ;;
    668         gmicro)
    669                 basic_machine=tron-gmicro
    670                 os=-sysv
    671                 ;;
    672         go32)
    673                 basic_machine=i386-pc
    674                 os=-go32
    675                 ;;
    676         h3050r* | hiux*)
    677                 basic_machine=hppa1.1-hitachi
    678                 os=-hiuxwe2
    679                 ;;
    680         h8300hms)
    681                 basic_machine=h8300-hitachi
    682                 os=-hms
    683                 ;;
    684         h8300xray)
    685                 basic_machine=h8300-hitachi
    686                 os=-xray
    687                 ;;
    688         h8500hms)
    689                 basic_machine=h8500-hitachi
    690                 os=-hms
    691                 ;;
    692         harris)
    693                 basic_machine=m88k-harris
    694                 os=-sysv3
    695                 ;;
    696         hp300-*)
    697                 basic_machine=m68k-hp
    698                 ;;
    699         hp300bsd)
    700                 basic_machine=m68k-hp
    701                 os=-bsd
    702                 ;;
    703         hp300hpux)
    704                 basic_machine=m68k-hp
    705                 os=-hpux
    706                 ;;
    707         hp3k9[0-9][0-9] | hp9[0-9][0-9])
    708                 basic_machine=hppa1.0-hp
    709                 ;;
    710         hp9k2[0-9][0-9] | hp9k31[0-9])
    711                 basic_machine=m68000-hp
    712                 ;;
    713         hp9k3[2-9][0-9])
    714                 basic_machine=m68k-hp
    715                 ;;
    716         hp9k6[0-9][0-9] | hp6[0-9][0-9])
    717                 basic_machine=hppa1.0-hp
    718                 ;;
    719         hp9k7[0-79][0-9] | hp7[0-79][0-9])
    720                 basic_machine=hppa1.1-hp
    721                 ;;
    722         hp9k78[0-9] | hp78[0-9])
    723                 # FIXME: really hppa2.0-hp
    724                 basic_machine=hppa1.1-hp
    725                 ;;
    726         hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
    727                 # FIXME: really hppa2.0-hp
    728                 basic_machine=hppa1.1-hp
    729                 ;;
    730         hp9k8[0-9][13679] | hp8[0-9][13679])
    731                 basic_machine=hppa1.1-hp
    732                 ;;
    733         hp9k8[0-9][0-9] | hp8[0-9][0-9])
    734                 basic_machine=hppa1.0-hp
    735                 ;;
    736         hppa-next)
    737                 os=-nextstep3
    738                 ;;
    739         hppaosf)
    740                 basic_machine=hppa1.1-hp
    741                 os=-osf
    742                 ;;
    743         hppro)
    744                 basic_machine=hppa1.1-hp
    745                 os=-proelf
    746                 ;;
    747         i370-ibm* | ibm*)
    748                 basic_machine=i370-ibm
    749                 ;;
    750         i*86v32)
    751                 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
    752                 os=-sysv32
    753                 ;;
    754         i*86v4*)
    755                 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
    756                 os=-sysv4
    757                 ;;
    758         i*86v)
    759                 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
    760                 os=-sysv
    761                 ;;
    762         i*86sol2)
    763                 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
    764                 os=-solaris2
    765                 ;;
    766         i386mach)
    767                 basic_machine=i386-mach
    768                 os=-mach
    769                 ;;
    770         i386-vsta | vsta)
    771                 basic_machine=i386-unknown
    772                 os=-vsta
    773                 ;;
    774         iris | iris4d)
    775                 basic_machine=mips-sgi
    776                 case $os in
    777                     -irix*)
    778                         ;;
    779                     *)
    780                         os=-irix4
    781                         ;;
    782                 esac
    783                 ;;
    784         isi68 | isi)
    785                 basic_machine=m68k-isi
    786                 os=-sysv
    787                 ;;
    788         leon-*|leon[3-9]-*)
    789                 basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'`
    790                 ;;
    791         m68knommu)
    792                 basic_machine=m68k-unknown
    793                 os=-linux
    794                 ;;
    795         m68knommu-*)
    796                 basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
    797                 os=-linux
    798                 ;;
    799         m88k-omron*)
    800                 basic_machine=m88k-omron
    801                 ;;
    802         magnum | m3230)
    803                 basic_machine=mips-mips
    804                 os=-sysv
    805                 ;;
    806         merlin)
    807                 basic_machine=ns32k-utek
    808                 os=-sysv
    809                 ;;
    810         microblaze*)
    811                 basic_machine=microblaze-xilinx
    812                 ;;
    813         mingw64)
    814                 basic_machine=x86_64-pc
    815                 os=-mingw64
    816                 ;;
    817         mingw32)
    818                 basic_machine=i686-pc
    819                 os=-mingw32
    820                 ;;
    821         mingw32ce)
    822                 basic_machine=arm-unknown
    823                 os=-mingw32ce
    824                 ;;
    825         miniframe)
    826                 basic_machine=m68000-convergent
    827                 ;;
    828         *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
    829                 basic_machine=m68k-atari
    830                 os=-mint
    831                 ;;
    832         mips3*-*)
    833                 basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
    834                 ;;
    835         mips3*)
    836                 basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
    837                 ;;
    838         monitor)
    839                 basic_machine=m68k-rom68k
    840                 os=-coff
    841                 ;;
    842         morphos)
    843                 basic_machine=powerpc-unknown
    844                 os=-morphos
    845                 ;;
    846         moxiebox)
    847                 basic_machine=moxie-unknown
    848                 os=-moxiebox
    849                 ;;
    850         msdos)
    851                 basic_machine=i386-pc
    852                 os=-msdos
    853                 ;;
    854         ms1-*)
    855                 basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
    856                 ;;
    857         msys)
    858                 basic_machine=i686-pc
    859                 os=-msys
    860                 ;;
    861         mvs)
    862                 basic_machine=i370-ibm
    863                 os=-mvs
    864                 ;;
    865         nacl)
    866                 basic_machine=le32-unknown
    867                 os=-nacl
    868                 ;;
    869         ncr3000)
    870                 basic_machine=i486-ncr
    871                 os=-sysv4
    872                 ;;
    873         netbsd386)
    874                 basic_machine=i386-unknown
    875                 os=-netbsd
    876                 ;;
    877         netwinder)
    878                 basic_machine=armv4l-rebel
    879                 os=-linux
    880                 ;;
    881         news | news700 | news800 | news900)
    882                 basic_machine=m68k-sony
    883                 os=-newsos
    884                 ;;
    885         news1000)
    886                 basic_machine=m68030-sony
    887                 os=-newsos
    888                 ;;
    889         news-3600 | risc-news)
    890                 basic_machine=mips-sony
    891                 os=-newsos
    892                 ;;
    893         necv70)
    894                 basic_machine=v70-nec
    895                 os=-sysv
    896                 ;;
    897         next | m*-next )
    898                 basic_machine=m68k-next
    899                 case $os in
    900                     -nextstep* )
    901                         ;;
    902                     -ns2*)
    903                       os=-nextstep2
    904                         ;;
    905                     *)
    906                       os=-nextstep3
    907                         ;;
    908                 esac
    909                 ;;
    910         nh3000)
    911                 basic_machine=m68k-harris
    912                 os=-cxux
    913                 ;;
    914         nh[45]000)
    915                 basic_machine=m88k-harris
    916                 os=-cxux
    917                 ;;
    918         nindy960)
    919                 basic_machine=i960-intel
    920                 os=-nindy
    921                 ;;
    922         mon960)
    923                 basic_machine=i960-intel
    924                 os=-mon960
    925                 ;;
    926         nonstopux)
    927                 basic_machine=mips-compaq
    928                 os=-nonstopux
    929                 ;;
    930         np1)
    931                 basic_machine=np1-gould
    932                 ;;
    933         neo-tandem)
    934                 basic_machine=neo-tandem
    935                 ;;
    936         nse-tandem)
    937                 basic_machine=nse-tandem
    938                 ;;
    939         nsr-tandem)
    940                 basic_machine=nsr-tandem
    941                 ;;
    942         op50n-* | op60c-*)
    943                 basic_machine=hppa1.1-oki
    944                 os=-proelf
    945                 ;;
    946         openrisc | openrisc-*)
    947                 basic_machine=or32-unknown
    948                 ;;
    949         os400)
    950                 basic_machine=powerpc-ibm
    951                 os=-os400
    952                 ;;
    953         OSE68000 | ose68000)
    954                 basic_machine=m68000-ericsson
    955                 os=-ose
    956                 ;;
    957         os68k)
    958                 basic_machine=m68k-none
    959                 os=-os68k
    960                 ;;
    961         pa-hitachi)
    962                 basic_machine=hppa1.1-hitachi
    963                 os=-hiuxwe2
    964                 ;;
    965         paragon)
    966                 basic_machine=i860-intel
    967                 os=-osf
    968                 ;;
    969         parisc)
    970                 basic_machine=hppa-unknown
    971                 os=-linux
    972                 ;;
    973         parisc-*)
    974                 basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
    975                 os=-linux
    976                 ;;
    977         pbd)
    978                 basic_machine=sparc-tti
    979                 ;;
    980         pbb)
    981                 basic_machine=m68k-tti
    982                 ;;
    983         pc532 | pc532-*)
    984                 basic_machine=ns32k-pc532
    985                 ;;
    986         pc98)
    987                 basic_machine=i386-pc
    988                 ;;
    989         pc98-*)
    990                 basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
    991                 ;;
    992         pentium | p5 | k5 | k6 | nexgen | viac3)
    993                 basic_machine=i586-pc
    994                 ;;
    995         pentiumpro | p6 | 6x86 | athlon | athlon_*)
    996                 basic_machine=i686-pc
    997                 ;;
    998         pentiumii | pentium2 | pentiumiii | pentium3)
    999                 basic_machine=i686-pc
    1000                 ;;
    1001         pentium4)
    1002                 basic_machine=i786-pc
    1003                 ;;
    1004         pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
    1005                 basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
    1006                 ;;
    1007         pentiumpro-* | p6-* | 6x86-* | athlon-*)
    1008                 basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
    1009                 ;;
    1010         pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
    1011                 basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
    1012                 ;;
    1013         pentium4-*)
    1014                 basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
    1015                 ;;
    1016         pn)
    1017                 basic_machine=pn-gould
    1018                 ;;
    1019         power)  basic_machine=power-ibm
    1020                 ;;
    1021         ppc | ppcbe)    basic_machine=powerpc-unknown
    1022                 ;;
    1023         ppc-* | ppcbe-*)
    1024                 basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
    1025                 ;;
    1026         ppcle | powerpclittle | ppc-le | powerpc-little)
    1027                 basic_machine=powerpcle-unknown
    1028                 ;;
    1029         ppcle-* | powerpclittle-*)
    1030                 basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
    1031                 ;;
    1032         ppc64)  basic_machine=powerpc64-unknown
    1033                 ;;
    1034         ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
    1035                 ;;
    1036         ppc64le | powerpc64little | ppc64-le | powerpc64-little)
    1037                 basic_machine=powerpc64le-unknown
    1038                 ;;
    1039         ppc64le-* | powerpc64little-*)
    1040                 basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
    1041                 ;;
    1042         ps2)
    1043                 basic_machine=i386-ibm
    1044                 ;;
    1045         pw32)
    1046                 basic_machine=i586-unknown
    1047                 os=-pw32
    1048                 ;;
    1049         rdos | rdos64)
    1050                 basic_machine=x86_64-pc
    1051                 os=-rdos
    1052                 ;;
    1053         rdos32)
    1054                 basic_machine=i386-pc
    1055                 os=-rdos
    1056                 ;;
    1057         rom68k)
    1058                 basic_machine=m68k-rom68k
    1059                 os=-coff
    1060                 ;;
    1061         rm[46]00)
    1062                 basic_machine=mips-siemens
    1063                 ;;
    1064         rtpc | rtpc-*)
    1065                 basic_machine=romp-ibm
    1066                 ;;
    1067         s390 | s390-*)
    1068                 basic_machine=s390-ibm
    1069                 ;;
    1070         s390x | s390x-*)
    1071                 basic_machine=s390x-ibm
    1072                 ;;
    1073         sa29200)
    1074                 basic_machine=a29k-amd
    1075                 os=-udi
    1076                 ;;
    1077         sb1)
    1078                 basic_machine=mipsisa64sb1-unknown
    1079                 ;;
    1080         sb1el)
    1081                 basic_machine=mipsisa64sb1el-unknown
    1082                 ;;
    1083         sde)
    1084                 basic_machine=mipsisa32-sde
    1085                 os=-elf
    1086                 ;;
    1087         sei)
    1088                 basic_machine=mips-sei
    1089                 os=-seiux
    1090                 ;;
    1091         sequent)
    1092                 basic_machine=i386-sequent
    1093                 ;;
    1094         sh)
    1095                 basic_machine=sh-hitachi
    1096                 os=-hms
    1097                 ;;
    1098         sh5el)
    1099                 basic_machine=sh5le-unknown
    1100                 ;;
    1101         sh64)
    1102                 basic_machine=sh64-unknown
    1103                 ;;
    1104         sparclite-wrs | simso-wrs)
    1105                 basic_machine=sparclite-wrs
    1106                 os=-vxworks
    1107                 ;;
    1108         sps7)
    1109                 basic_machine=m68k-bull
    1110                 os=-sysv2
    1111                 ;;
    1112         spur)
    1113                 basic_machine=spur-unknown
    1114                 ;;
    1115         st2000)
    1116                 basic_machine=m68k-tandem
    1117                 ;;
    1118         stratus)
    1119                 basic_machine=i860-stratus
    1120                 os=-sysv4
    1121                 ;;
    1122         strongarm-* | thumb-*)
    1123                 basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
    1124                 ;;
    1125         sun2)
    1126                 basic_machine=m68000-sun
    1127                 ;;
    1128         sun2os3)
    1129                 basic_machine=m68000-sun
    1130                 os=-sunos3
    1131                 ;;
    1132         sun2os4)
    1133                 basic_machine=m68000-sun
    1134                 os=-sunos4
    1135                 ;;
    1136         sun3os3)
    1137                 basic_machine=m68k-sun
    1138                 os=-sunos3
    1139                 ;;
    1140         sun3os4)
    1141                 basic_machine=m68k-sun
    1142                 os=-sunos4
    1143                 ;;
    1144         sun4os3)
    1145                 basic_machine=sparc-sun
    1146                 os=-sunos3
    1147                 ;;
    1148         sun4os4)
    1149                 basic_machine=sparc-sun
    1150                 os=-sunos4
    1151                 ;;
    1152         sun4sol2)
    1153                 basic_machine=sparc-sun
    1154                 os=-solaris2
    1155                 ;;
    1156         sun3 | sun3-*)
    1157                 basic_machine=m68k-sun
    1158                 ;;
    1159         sun4)
    1160                 basic_machine=sparc-sun
    1161                 ;;
    1162         sun386 | sun386i | roadrunner)
    1163                 basic_machine=i386-sun
    1164                 ;;
    1165         sv1)
    1166                 basic_machine=sv1-cray
    1167                 os=-unicos
    1168                 ;;
    1169         symmetry)
    1170                 basic_machine=i386-sequent
    1171                 os=-dynix
    1172                 ;;
    1173         t3e)
    1174                 basic_machine=alphaev5-cray
    1175                 os=-unicos
    1176                 ;;
    1177         t90)
    1178                 basic_machine=t90-cray
    1179                 os=-unicos
    1180                 ;;
    1181         tile*)
    1182                 basic_machine=$basic_machine-unknown
    1183                 os=-linux-gnu
    1184                 ;;
    1185         tx39)
    1186                 basic_machine=mipstx39-unknown
    1187                 ;;
    1188         tx39el)
    1189                 basic_machine=mipstx39el-unknown
    1190                 ;;
    1191         toad1)
    1192                 basic_machine=pdp10-xkl
    1193                 os=-tops20
    1194                 ;;
    1195         tower | tower-32)
    1196                 basic_machine=m68k-ncr
    1197                 ;;
    1198         tpf)
    1199                 basic_machine=s390x-ibm
    1200                 os=-tpf
    1201                 ;;
    1202         udi29k)
    1203                 basic_machine=a29k-amd
    1204                 os=-udi
    1205                 ;;
    1206         ultra3)
    1207                 basic_machine=a29k-nyu
    1208                 os=-sym1
    1209                 ;;
    1210         v810 | necv810)
    1211                 basic_machine=v810-nec
    1212                 os=-none
    1213                 ;;
    1214         vaxv)
    1215                 basic_machine=vax-dec
    1216                 os=-sysv
    1217                 ;;
    1218         vms)
    1219                 basic_machine=vax-dec
    1220                 os=-vms
    1221                 ;;
    1222         vpp*|vx|vx-*)
    1223                 basic_machine=f301-fujitsu
    1224                 ;;
    1225         vxworks960)
    1226                 basic_machine=i960-wrs
    1227                 os=-vxworks
    1228                 ;;
    1229         vxworks68)
    1230                 basic_machine=m68k-wrs
    1231                 os=-vxworks
    1232                 ;;
    1233         vxworks29k)
    1234                 basic_machine=a29k-wrs
    1235                 os=-vxworks
    1236                 ;;
    1237         w65*)
    1238                 basic_machine=w65-wdc
    1239                 os=-none
    1240                 ;;
    1241         w89k-*)
    1242                 basic_machine=hppa1.1-winbond
    1243                 os=-proelf
    1244                 ;;
    1245         xbox)
    1246                 basic_machine=i686-pc
    1247                 os=-mingw32
    1248                 ;;
    1249         xps | xps100)
    1250                 basic_machine=xps100-honeywell
    1251                 ;;
    1252         xscale-* | xscalee[bl]-*)
    1253                 basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
    1254                 ;;
    1255         ymp)
    1256                 basic_machine=ymp-cray
    1257                 os=-unicos
    1258                 ;;
    1259         z8k-*-coff)
    1260                 basic_machine=z8k-unknown
    1261                 os=-sim
    1262                 ;;
    1263         z80-*-coff)
    1264                 basic_machine=z80-unknown
    1265                 os=-sim
    1266                 ;;
    1267         none)
    1268                 basic_machine=none-none
    1269                 os=-none
    1270                 ;;
    1271 
    1272 # Here we handle the default manufacturer of certain CPU types.  It is in
    1273 # some cases the only manufacturer, in others, it is the most popular.
    1274         w89k)
    1275                 basic_machine=hppa1.1-winbond
    1276                 ;;
    1277         op50n)
    1278                 basic_machine=hppa1.1-oki
    1279                 ;;
    1280         op60c)
    1281                 basic_machine=hppa1.1-oki
    1282                 ;;
    1283         romp)
    1284                 basic_machine=romp-ibm
    1285                 ;;
    1286         mmix)
    1287                 basic_machine=mmix-knuth
    1288                 ;;
    1289         rs6000)
    1290                 basic_machine=rs6000-ibm
    1291                 ;;
    1292         vax)
    1293                 basic_machine=vax-dec
    1294                 ;;
    1295         pdp10)
    1296                 # there are many clones, so DEC is not a safe bet
    1297                 basic_machine=pdp10-unknown
    1298                 ;;
    1299         pdp11)
    1300                 basic_machine=pdp11-dec
    1301                 ;;
    1302         we32k)
    1303                 basic_machine=we32k-att
    1304                 ;;
    1305         sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
    1306                 basic_machine=sh-unknown
    1307                 ;;
    1308         sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
    1309                 basic_machine=sparc-sun
    1310                 ;;
    1311         cydra)
    1312                 basic_machine=cydra-cydrome
    1313                 ;;
    1314         orion)
    1315                 basic_machine=orion-highlevel
    1316                 ;;
    1317         orion105)
    1318                 basic_machine=clipper-highlevel
    1319                 ;;
    1320         mac | mpw | mac-mpw)
    1321                 basic_machine=m68k-apple
    1322                 ;;
    1323         pmac | pmac-mpw)
    1324                 basic_machine=powerpc-apple
    1325                 ;;
    1326         *-unknown)
    1327                 # Make sure to match an already-canonicalized machine name.
    1328                 ;;
    1329         *)
    1330                 echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
    1331                 exit 1
    1332                 ;;
    1333 esac
    1334 
    1335 # Here we canonicalize certain aliases for manufacturers.
    1336 case $basic_machine in
    1337         *-digital*)
    1338                 basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
    1339                 ;;
    1340         *-commodore*)
    1341                 basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
    1342                 ;;
    1343         *)
    1344                 ;;
    1345 esac
    1346 
    1347 # Decode manufacturer-specific aliases for certain operating systems.
    1348 
    1349 if [ x"$os" != x"" ]
    1350 then
    1351 case $os in
    1352         # First match some system type aliases
    1353         # that might get confused with valid system types.
    1354         # -solaris* is a basic system type, with this one exception.
    1355         -auroraux)
    1356                 os=-auroraux
    1357                 ;;
    1358         -solaris1 | -solaris1.*)
    1359                 os=`echo $os | sed -e 's|solaris1|sunos4|'`
    1360                 ;;
    1361         -solaris)
    1362                 os=-solaris2
    1363                 ;;
    1364         -svr4*)
    1365                 os=-sysv4
    1366                 ;;
    1367         -unixware*)
    1368                 os=-sysv4.2uw
    1369                 ;;
    1370         -gnu/linux*)
    1371                 os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
    1372                 ;;
    1373         # First accept the basic system types.
    1374         # The portable systems comes first.
    1375         # Each alternative MUST END IN A *, to match a version number.
    1376         # -sysv* is not here because it comes later, after sysvr4.
    1377         -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
    1378               | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
    1379               | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
    1380               | -sym* | -kopensolaris* | -plan9* \
    1381               | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
    1382               | -aos* | -aros* | -cloudabi* | -sortix* \
    1383               | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
    1384               | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
    1385               | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
    1386               | -bitrig* | -openbsd* | -solidbsd* \
    1387               | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
    1388               | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
    1389               | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
    1390               | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
    1391               | -chorusos* | -chorusrdb* | -cegcc* \
    1392               | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
    1393               | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
    1394               | -linux-newlib* | -linux-musl* | -linux-uclibc* \
    1395               | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
    1396               | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
    1397               | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
    1398               | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
    1399               | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
    1400               | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
    1401               | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
    1402               | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*)
    1403         # Remember, each alternative MUST END IN *, to match a version number.
    1404                 ;;
    1405         -qnx*)
    1406                 case $basic_machine in
    1407                     x86-* | i*86-*)
    1408                         ;;
    1409                     *)
    1410                         os=-nto$os
    1411                         ;;
    1412                 esac
    1413                 ;;
    1414         -nto-qnx*)
    1415                 ;;
    1416         -nto*)
    1417                 os=`echo $os | sed -e 's|nto|nto-qnx|'`
    1418                 ;;
    1419         -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
    1420               | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
    1421               | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
    1422                 ;;
    1423         -mac*)
    1424                 os=`echo $os | sed -e 's|mac|macos|'`
    1425                 ;;
    1426         -linux-dietlibc)
    1427                 os=-linux-dietlibc
    1428                 ;;
    1429         -linux*)
    1430                 os=`echo $os | sed -e 's|linux|linux-gnu|'`
    1431                 ;;
    1432         -sunos5*)
    1433                 os=`echo $os | sed -e 's|sunos5|solaris2|'`
    1434                 ;;
    1435         -sunos6*)
    1436                 os=`echo $os | sed -e 's|sunos6|solaris3|'`
    1437                 ;;
    1438         -opened*)
    1439                 os=-openedition
    1440                 ;;
    1441         -os400*)
    1442                 os=-os400
    1443                 ;;
    1444         -wince*)
    1445                 os=-wince
    1446                 ;;
    1447         -osfrose*)
    1448                 os=-osfrose
    1449                 ;;
    1450         -osf*)
    1451                 os=-osf
    1452                 ;;
    1453         -utek*)
    1454                 os=-bsd
    1455                 ;;
    1456         -dynix*)
    1457                 os=-bsd
    1458                 ;;
    1459         -acis*)
    1460                 os=-aos
    1461                 ;;
    1462         -atheos*)
    1463                 os=-atheos
    1464                 ;;
    1465         -syllable*)
    1466                 os=-syllable
    1467                 ;;
    1468         -386bsd)
    1469                 os=-bsd
    1470                 ;;
    1471         -ctix* | -uts*)
    1472                 os=-sysv
    1473                 ;;
    1474         -nova*)
    1475                 os=-rtmk-nova
    1476                 ;;
    1477         -ns2 )
    1478                 os=-nextstep2
    1479                 ;;
    1480         -nsk*)
    1481                 os=-nsk
    1482                 ;;
    1483         # Preserve the version number of sinix5.
    1484         -sinix5.*)
    1485                 os=`echo $os | sed -e 's|sinix|sysv|'`
    1486                 ;;
    1487         -sinix*)
    1488                 os=-sysv4
    1489                 ;;
    1490         -tpf*)
    1491                 os=-tpf
    1492                 ;;
    1493         -triton*)
    1494                 os=-sysv3
    1495                 ;;
    1496         -oss*)
    1497                 os=-sysv3
    1498                 ;;
    1499         -svr4)
    1500                 os=-sysv4
    1501                 ;;
    1502         -svr3)
    1503                 os=-sysv3
    1504                 ;;
    1505         -sysvr4)
    1506                 os=-sysv4
    1507                 ;;
    1508         # This must come after -sysvr4.
    1509         -sysv*)
    1510                 ;;
    1511         -ose*)
    1512                 os=-ose
    1513                 ;;
    1514         -es1800*)
    1515                 os=-ose
    1516                 ;;
    1517         -xenix)
    1518                 os=-xenix
    1519                 ;;
    1520         -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
    1521                 os=-mint
    1522                 ;;
    1523         -aros*)
    1524                 os=-aros
    1525                 ;;
    1526         -zvmoe)
    1527                 os=-zvmoe
    1528                 ;;
    1529         -dicos*)
    1530                 os=-dicos
    1531                 ;;
    1532         -nacl*)
    1533                 ;;
    1534         -none)
    1535                 ;;
    1536         *)
    1537                 # Get rid of the `-' at the beginning of $os.
    1538                 os=`echo $os | sed 's/[^-]*-//'`
    1539                 echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
    1540                 exit 1
    1541                 ;;
    1542 esac
    1543 else
    1544 
    1545 # Here we handle the default operating systems that come with various machines.
    1546 # The value should be what the vendor currently ships out the door with their
    1547 # machine or put another way, the most popular os provided with the machine.
    1548 
    1549 # Note that if you're going to try to match "-MANUFACTURER" here (say,
    1550 # "-sun"), then you have to tell the case statement up towards the top
    1551 # that MANUFACTURER isn't an operating system.  Otherwise, code above
    1552 # will signal an error saying that MANUFACTURER isn't an operating
    1553 # system, and we'll never get to this point.
    1554 
    1555 case $basic_machine in
    1556         score-*)
    1557                 os=-elf
    1558                 ;;
    1559         spu-*)
    1560                 os=-elf
    1561                 ;;
    1562         *-acorn)
    1563                 os=-riscix1.2
    1564                 ;;
    1565         arm*-rebel)
    1566                 os=-linux
    1567                 ;;
    1568         arm*-semi)
    1569                 os=-aout
    1570                 ;;
    1571         c4x-* | tic4x-*)
    1572                 os=-coff
    1573                 ;;
    1574         c8051-*)
    1575                 os=-elf
    1576                 ;;
    1577         hexagon-*)
    1578                 os=-elf
    1579                 ;;
    1580         tic54x-*)
    1581                 os=-coff
    1582                 ;;
    1583         tic55x-*)
    1584                 os=-coff
    1585                 ;;
    1586         tic6x-*)
    1587                 os=-coff
    1588                 ;;
    1589         # This must come before the *-dec entry.
    1590         pdp10-*)
    1591                 os=-tops20
    1592                 ;;
    1593         pdp11-*)
    1594                 os=-none
    1595                 ;;
    1596         *-dec | vax-*)
    1597                 os=-ultrix4.2
    1598                 ;;
    1599         m68*-apollo)
    1600                 os=-domain
    1601                 ;;
    1602         i386-sun)
    1603                 os=-sunos4.0.2
    1604                 ;;
    1605         m68000-sun)
    1606                 os=-sunos3
    1607                 ;;
    1608         m68*-cisco)
    1609                 os=-aout
    1610                 ;;
    1611         mep-*)
    1612                 os=-elf
    1613                 ;;
    1614         mips*-cisco)
    1615                 os=-elf
    1616                 ;;
    1617         mips*-*)
    1618                 os=-elf
    1619                 ;;
    1620         or32-*)
    1621                 os=-coff
    1622                 ;;
    1623         *-tti)  # must be before sparc entry or we get the wrong os.
    1624                 os=-sysv3
    1625                 ;;
    1626         sparc-* | *-sun)
    1627                 os=-sunos4.1.1
    1628                 ;;
    1629         *-be)
    1630                 os=-beos
    1631                 ;;
    1632         *-haiku)
    1633                 os=-haiku
    1634                 ;;
    1635         *-ibm)
    1636                 os=-aix
    1637                 ;;
    1638         *-knuth)
    1639                 os=-mmixware
    1640                 ;;
    1641         *-wec)
    1642                 os=-proelf
    1643                 ;;
    1644         *-winbond)
    1645                 os=-proelf
    1646                 ;;
    1647         *-oki)
    1648                 os=-proelf
    1649                 ;;
    1650         *-hp)
    1651                 os=-hpux
    1652                 ;;
    1653         *-hitachi)
    1654                 os=-hiux
    1655                 ;;
    1656         i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
    1657                 os=-sysv
    1658                 ;;
    1659         *-cbm)
    1660                 os=-amigaos
    1661                 ;;
    1662         *-dg)
    1663                 os=-dgux
    1664                 ;;
    1665         *-dolphin)
    1666                 os=-sysv3
    1667                 ;;
    1668         m68k-ccur)
    1669                 os=-rtu
    1670                 ;;
    1671         m88k-omron*)
    1672                 os=-luna
    1673                 ;;
    1674         *-next )
    1675                 os=-nextstep
    1676                 ;;
    1677         *-sequent)
    1678                 os=-ptx
    1679                 ;;
    1680         *-crds)
    1681                 os=-unos
    1682                 ;;
    1683         *-ns)
    1684                 os=-genix
    1685                 ;;
    1686         i370-*)
    1687                 os=-mvs
    1688                 ;;
    1689         *-next)
    1690                 os=-nextstep3
    1691                 ;;
    1692         *-gould)
    1693                 os=-sysv
    1694                 ;;
    1695         *-highlevel)
    1696                 os=-bsd
    1697                 ;;
    1698         *-encore)
    1699                 os=-bsd
    1700                 ;;
    1701         *-sgi)
    1702                 os=-irix
    1703                 ;;
    1704         *-siemens)
    1705                 os=-sysv4
    1706                 ;;
    1707         *-masscomp)
    1708                 os=-rtu
    1709                 ;;
    1710         f30[01]-fujitsu | f700-fujitsu)
    1711                 os=-uxpv
    1712                 ;;
    1713         *-rom68k)
    1714                 os=-coff
    1715                 ;;
    1716         *-*bug)
    1717                 os=-coff
    1718                 ;;
    1719         *-apple)
    1720                 os=-macos
    1721                 ;;
    1722         *-atari*)
    1723                 os=-mint
    1724                 ;;
    1725         *)
    1726                 os=-none
    1727                 ;;
    1728 esac
    1729 fi
    1730 
    1731 # Here we handle the case where we know the os, and the CPU type, but not the
    1732 # manufacturer.  We pick the logical manufacturer.
    1733 vendor=unknown
    1734 case $basic_machine in
    1735         *-unknown)
    1736                 case $os in
    1737                         -riscix*)
    1738                                 vendor=acorn
    1739                                 ;;
    1740                         -sunos*)
    1741                                 vendor=sun
    1742                                 ;;
    1743                         -cnk*|-aix*)
    1744                                 vendor=ibm
    1745                                 ;;
    1746                         -beos*)
    1747                                 vendor=be
    1748                                 ;;
    1749                         -hpux*)
    1750                                 vendor=hp
    1751                                 ;;
    1752                         -mpeix*)
    1753                                 vendor=hp
    1754                                 ;;
    1755                         -hiux*)
    1756                                 vendor=hitachi
    1757                                 ;;
    1758                         -unos*)
    1759                                 vendor=crds
    1760                                 ;;
    1761                         -dgux*)
    1762                                 vendor=dg
    1763                                 ;;
    1764                         -luna*)
    1765                                 vendor=omron
    1766                                 ;;
    1767                         -genix*)
    1768                                 vendor=ns
    1769                                 ;;
    1770                         -mvs* | -opened*)
    1771                                 vendor=ibm
    1772                                 ;;
    1773                         -os400*)
    1774                                 vendor=ibm
    1775                                 ;;
    1776                         -ptx*)
    1777                                 vendor=sequent
    1778                                 ;;
    1779                         -tpf*)
    1780                                 vendor=ibm
    1781                                 ;;
    1782                         -vxsim* | -vxworks* | -windiss*)
    1783                                 vendor=wrs
    1784                                 ;;
    1785                         -aux*)
    1786                                 vendor=apple
    1787                                 ;;
    1788                         -hms*)
    1789                                 vendor=hitachi
    1790                                 ;;
    1791                         -mpw* | -macos*)
    1792                                 vendor=apple
    1793                                 ;;
    1794                         -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
    1795                                 vendor=atari
    1796                                 ;;
    1797                         -vos*)
    1798                                 vendor=stratus
    1799                                 ;;
    1800                 esac
    1801                 basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
    1802                 ;;
    1803 esac
    1804 
    1805 echo $basic_machine$os
    1806 exit
    1807 
    1808 # Local variables:
    1809 # eval: (add-hook 'write-file-hooks 'time-stamp)
    1810 # time-stamp-start: "timestamp='"
    1811 # time-stamp-format: "%:y-%02m-%02d"
    1812 # time-stamp-end: "'"
    1813 # End:
     1/usr/share/automake-1.15/config.sub
  • automake/depcomp

    r0720e049 r3d4b23fa  
    22# depcomp - compile a program generating dependencies as side-effects
    33
    4 scriptversion=2013-05-30.07; # UTC
    5 
    6 # Copyright (C) 1999-2014 Free Software Foundation, Inc.
     4scriptversion=2011-12-04.11; # UTC
     5
     6# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010,
     7# 2011 Free Software Foundation, Inc.
    78
    89# This program is free software; you can redistribute it and/or modify
     
    2829case $1 in
    2930  '')
    30     echo "$0: No command.  Try '$0 --help' for more information." 1>&2
    31     exit 1;
    32     ;;
     31     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
     32     exit 1;
     33     ;;
    3334  -h | --h*)
    3435    cat <<\EOF
     
    4041Environment variables:
    4142  depmode     Dependency tracking mode.
    42   source      Source file read by 'PROGRAMS ARGS'.
    43   object      Object file output by 'PROGRAMS ARGS'.
     43  source      Source file read by `PROGRAMS ARGS'.
     44  object      Object file output by `PROGRAMS ARGS'.
    4445  DEPDIR      directory where to store dependencies.
    4546  depfile     Dependency file to output.
     
    5758esac
    5859
    59 # Get the directory component of the given path, and save it in the
    60 # global variables '$dir'.  Note that this directory component will
    61 # be either empty or ending with a '/' character.  This is deliberate.
    62 set_dir_from ()
    63 {
    64   case $1 in
    65     */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
    66       *) dir=;;
    67   esac
    68 }
    69 
    70 # Get the suffix-stripped basename of the given path, and save it the
    71 # global variable '$base'.
    72 set_base_from ()
    73 {
    74   base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
    75 }
    76 
    77 # If no dependency file was actually created by the compiler invocation,
    78 # we still have to create a dummy depfile, to avoid errors with the
    79 # Makefile "include basename.Plo" scheme.
    80 make_dummy_depfile ()
    81 {
    82   echo "#dummy" > "$depfile"
    83 }
    84 
    85 # Factor out some common post-processing of the generated depfile.
    86 # Requires the auxiliary global variable '$tmpdepfile' to be set.
    87 aix_post_process_depfile ()
    88 {
    89   # If the compiler actually managed to produce a dependency file,
    90   # post-process it.
    91   if test -f "$tmpdepfile"; then
    92     # Each line is of the form 'foo.o: dependency.h'.
    93     # Do two passes, one to just change these to
    94     #   $object: dependency.h
    95     # and one to simply output
    96     #   dependency.h:
    97     # which is needed to avoid the deleted-header problem.
    98     { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
    99       sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
    100     } > "$depfile"
    101     rm -f "$tmpdepfile"
    102   else
    103     make_dummy_depfile
    104   fi
    105 }
    106 
    107 # A tabulation character.
    108 tab='   '
    109 # A newline character.
    110 nl='
    111 '
    112 # Character ranges might be problematic outside the C locale.
    113 # These definitions help.
    114 upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
    115 lower=abcdefghijklmnopqrstuvwxyz
    116 digits=0123456789
    117 alpha=${upper}${lower}
    118 
    11960if test -z "$depmode" || test -z "$source" || test -z "$object"; then
    12061  echo "depcomp: Variables source, object and depmode must be set" 1>&2
     
    12869
    12970rm -f "$tmpdepfile"
    130 
    131 # Avoid interferences from the environment.
    132 gccflag= dashmflag=
    13371
    13472# Some modes work just like other modes, but use different flags.  We
     
    14381
    14482if test "$depmode" = dashXmstdout; then
    145   # This is just like dashmstdout with a different argument.
    146   dashmflag=-xM
    147   depmode=dashmstdout
     83   # This is just like dashmstdout with a different argument.
     84   dashmflag=-xM
     85   depmode=dashmstdout
    14886fi
    14987
    15088cygpath_u="cygpath -u -f -"
    15189if test "$depmode" = msvcmsys; then
    152   # This is just like msvisualcpp but w/o cygpath translation.
    153   # Just convert the backslash-escaped backslashes to single forward
    154   # slashes to satisfy depend.m4
    155   cygpath_u='sed s,\\\\,/,g'
    156   depmode=msvisualcpp
     90   # This is just like msvisualcpp but w/o cygpath translation.
     91   # Just convert the backslash-escaped backslashes to single forward
     92   # slashes to satisfy depend.m4
     93   cygpath_u='sed s,\\\\,/,g'
     94   depmode=msvisualcpp
    15795fi
    15896
    15997if test "$depmode" = msvc7msys; then
    160   # This is just like msvc7 but w/o cygpath translation.
    161   # Just convert the backslash-escaped backslashes to single forward
    162   # slashes to satisfy depend.m4
    163   cygpath_u='sed s,\\\\,/,g'
    164   depmode=msvc7
    165 fi
    166 
    167 if test "$depmode" = xlc; then
    168   # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
    169   gccflag=-qmakedep=gcc,-MF
    170   depmode=gcc
     98   # This is just like msvc7 but w/o cygpath translation.
     99   # Just convert the backslash-escaped backslashes to single forward
     100   # slashes to satisfy depend.m4
     101   cygpath_u='sed s,\\\\,/,g'
     102   depmode=msvc7
    171103fi
    172104
     
    191123  "$@"
    192124  stat=$?
    193   if test $stat -ne 0; then
     125  if test $stat -eq 0; then :
     126  else
    194127    rm -f "$tmpdepfile"
    195128    exit $stat
     
    199132
    200133gcc)
    201 ## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
    202 ## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
    203 ## (see the conditional assignment to $gccflag above).
    204134## There are various ways to get dependency output from gcc.  Here's
    205135## why we pick this rather obscure method:
     
    208138##   (We might end up doing this anyway to support other compilers.)
    209139## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
    210 ##   -MM, not -M (despite what the docs say).  Also, it might not be
    211 ##   supported by the other compilers which use the 'gcc' depmode.
     140##   -MM, not -M (despite what the docs say).
    212141## - Using -M directly means running the compiler twice (even worse
    213142##   than renaming).
     
    217146  "$@" -Wp,"$gccflag$tmpdepfile"
    218147  stat=$?
    219   if test $stat -ne 0; then
     148  if test $stat -eq 0; then :
     149  else
    220150    rm -f "$tmpdepfile"
    221151    exit $stat
     
    223153  rm -f "$depfile"
    224154  echo "$object : \\" > "$depfile"
    225   # The second -e expression handles DOS-style file names with drive
    226   # letters.
     155  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
     156## The second -e expression handles DOS-style file names with drive letters.
    227157  sed -e 's/^[^:]*: / /' \
    228158      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
    229 ## This next piece of magic avoids the "deleted header file" problem.
     159## This next piece of magic avoids the `deleted header file' problem.
    230160## The problem is that when a header file which appears in a .P file
    231161## is deleted, the dependency causes make to die (because there is
     
    233163## dummy dependencies for each header file.  Too bad gcc doesn't do
    234164## this for us directly.
    235 ## Some versions of gcc put a space before the ':'.  On the theory
     165  tr ' ' '
     166' < "$tmpdepfile" |
     167## Some versions of gcc put a space before the `:'.  On the theory
    236168## that the space means something, we add a space to the output as
    237169## well.  hp depmode also adds that space, but also prefixes the VPATH
     
    239171## Some versions of the HPUX 10.20 sed can't process this invocation
    240172## correctly.  Breaking it into two sed invocations is a workaround.
    241   tr ' ' "$nl" < "$tmpdepfile" \
    242     | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
    243     | sed -e 's/$/ :/' >> "$depfile"
     173    sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
     174      | sed -e 's/$/ :/' >> "$depfile"
    244175  rm -f "$tmpdepfile"
    245176  ;;
     
    259190  fi
    260191  stat=$?
    261   if test $stat -ne 0; then
     192  if test $stat -eq 0; then :
     193  else
    262194    rm -f "$tmpdepfile"
    263195    exit $stat
     
    267199  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
    268200    echo "$object : \\" > "$depfile"
     201
    269202    # Clip off the initial element (the dependent).  Don't try to be
    270203    # clever and replace this with sed code, as IRIX sed won't handle
    271204    # lines with more than a fixed number of characters (4096 in
    272205    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
    273     # the IRIX cc adds comments like '#:fec' to the end of the
     206    # the IRIX cc adds comments like `#:fec' to the end of the
    274207    # dependency line.
    275     tr ' ' "$nl" < "$tmpdepfile" \
    276       | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
    277       | tr "$nl" ' ' >> "$depfile"
     208    tr ' ' '
     209' < "$tmpdepfile" \
     210    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
     211    tr '
     212' ' ' >> "$depfile"
    278213    echo >> "$depfile"
     214
    279215    # The second pass generates a dummy entry for each header file.
    280     tr ' ' "$nl" < "$tmpdepfile" \
    281       | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
    282       >> "$depfile"
    283   else
    284     make_dummy_depfile
    285   fi
    286   rm -f "$tmpdepfile"
    287   ;;
    288 
    289 xlc)
    290   # This case exists only to let depend.m4 do its work.  It works by
    291   # looking at the text of this script.  This case will never be run,
    292   # since it is checked for above.
    293   exit 1
     216    tr ' ' '
     217' < "$tmpdepfile" \
     218   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
     219   >> "$depfile"
     220  else
     221    # The sourcefile does not contain any dependencies, so just
     222    # store a dummy comment line, to avoid errors with the Makefile
     223    # "include basename.Plo" scheme.
     224    echo "#dummy" > "$depfile"
     225  fi
     226  rm -f "$tmpdepfile"
    294227  ;;
    295228
     
    297230  # The C for AIX Compiler uses -M and outputs the dependencies
    298231  # in a .u file.  In older versions, this file always lives in the
    299   # current directory.  Also, the AIX compiler puts '$object:' at the
     232  # current directory.  Also, the AIX compiler puts `$object:' at the
    300233  # start of each line; $object doesn't have directory information.
    301234  # Version 6 uses the directory in both cases.
    302   set_dir_from "$object"
    303   set_base_from "$object"
     235  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
     236  test "x$dir" = "x$object" && dir=
     237  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
    304238  if test "$libtool" = yes; then
    305239    tmpdepfile1=$dir$base.u
     
    314248  fi
    315249  stat=$?
    316   if test $stat -ne 0; then
     250
     251  if test $stat -eq 0; then :
     252  else
    317253    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
    318254    exit $stat
     
    323259    test -f "$tmpdepfile" && break
    324260  done
    325   aix_post_process_depfile
    326   ;;
    327 
    328 tcc)
    329   # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
    330   # FIXME: That version still under development at the moment of writing.
    331   #        Make that this statement remains true also for stable, released
    332   #        versions.
    333   # It will wrap lines (doesn't matter whether long or short) with a
    334   # trailing '\', as in:
    335   #
    336   #   foo.o : \
    337   #    foo.c \
    338   #    foo.h \
    339   #
    340   # It will put a trailing '\' even on the last line, and will use leading
    341   # spaces rather than leading tabs (at least since its commit 0394caf7
    342   # "Emit spaces for -MD").
    343   "$@" -MD -MF "$tmpdepfile"
    344   stat=$?
    345   if test $stat -ne 0; then
    346     rm -f "$tmpdepfile"
    347     exit $stat
    348   fi
    349   rm -f "$depfile"
    350   # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
    351   # We have to change lines of the first kind to '$object: \'.
    352   sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
    353   # And for each line of the second kind, we have to emit a 'dep.h:'
    354   # dummy dependency, to avoid the deleted-header problem.
    355   sed -n -e 's|^  *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
    356   rm -f "$tmpdepfile"
    357   ;;
    358 
    359 ## The order of this option in the case statement is important, since the
    360 ## shell code in configure will try each of these formats in the order
    361 ## listed in this file.  A plain '-MD' option would be understood by many
    362 ## compilers, so we must ensure this comes after the gcc and icc options.
    363 pgcc)
    364   # Portland's C compiler understands '-MD'.
    365   # Will always output deps to 'file.d' where file is the root name of the
    366   # source file under compilation, even if file resides in a subdirectory.
    367   # The object file name does not affect the name of the '.d' file.
    368   # pgcc 10.2 will output
     261  if test -f "$tmpdepfile"; then
     262    # Each line is of the form `foo.o: dependent.h'.
     263    # Do two passes, one to just change these to
     264    # `$object: dependent.h' and one to simply `dependent.h:'.
     265    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
     266    # That's a tab and a space in the [].
     267    sed -e 's,^.*\.[a-z]*:[      ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
     268  else
     269    # The sourcefile does not contain any dependencies, so just
     270    # store a dummy comment line, to avoid errors with the Makefile
     271    # "include basename.Plo" scheme.
     272    echo "#dummy" > "$depfile"
     273  fi
     274  rm -f "$tmpdepfile"
     275  ;;
     276
     277icc)
     278  # Intel's C compiler understands `-MD -MF file'.  However on
     279  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
     280  # ICC 7.0 will fill foo.d with something like
     281  #    foo.o: sub/foo.c
     282  #    foo.o: sub/foo.h
     283  # which is wrong.  We want:
     284  #    sub/foo.o: sub/foo.c
     285  #    sub/foo.o: sub/foo.h
     286  #    sub/foo.c:
     287  #    sub/foo.h:
     288  # ICC 7.1 will output
    369289  #    foo.o: sub/foo.c sub/foo.h
    370   # and will wrap long lines using '\' :
     290  # and will wrap long lines using \ :
    371291  #    foo.o: sub/foo.c ... \
    372292  #     sub/foo.h ... \
    373293  #     ...
    374   set_dir_from "$object"
    375   # Use the source, not the object, to determine the base name, since
    376   # that's sadly what pgcc will do too.
    377   set_base_from "$source"
    378   tmpdepfile=$base.d
    379 
    380   # For projects that build the same source file twice into different object
    381   # files, the pgcc approach of using the *source* file root name can cause
    382   # problems in parallel builds.  Use a locking strategy to avoid stomping on
    383   # the same $tmpdepfile.
    384   lockdir=$base.d-lock
    385   trap "
    386     echo '$0: caught signal, cleaning up...' >&2
    387     rmdir '$lockdir'
    388     exit 1
    389   " 1 2 13 15
    390   numtries=100
    391   i=$numtries
    392   while test $i -gt 0; do
    393     # mkdir is a portable test-and-set.
    394     if mkdir "$lockdir" 2>/dev/null; then
    395       # This process acquired the lock.
    396       "$@" -MD
    397       stat=$?
    398       # Release the lock.
    399       rmdir "$lockdir"
    400       break
    401     else
    402       # If the lock is being held by a different process, wait
    403       # until the winning process is done or we timeout.
    404       while test -d "$lockdir" && test $i -gt 0; do
    405         sleep 1
    406         i=`expr $i - 1`
    407       done
    408     fi
    409     i=`expr $i - 1`
    410   done
    411   trap - 1 2 13 15
    412   if test $i -le 0; then
    413     echo "$0: failed to acquire lock after $numtries attempts" >&2
    414     echo "$0: check lockdir '$lockdir'" >&2
    415     exit 1
    416   fi
    417 
    418   if test $stat -ne 0; then
     294
     295  "$@" -MD -MF "$tmpdepfile"
     296  stat=$?
     297  if test $stat -eq 0; then :
     298  else
    419299    rm -f "$tmpdepfile"
    420300    exit $stat
     
    428308  # Some versions of the HPUX 10.20 sed can't process this invocation
    429309  # correctly.  Breaking it into two sed invocations is a workaround.
    430   sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
    431     | sed -e 's/$/ :/' >> "$depfile"
     310  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
     311    sed -e 's/$/ :/' >> "$depfile"
    432312  rm -f "$tmpdepfile"
    433313  ;;
     
    440320  # happens to be.
    441321  # Much of this is similar to the tru64 case; see comments there.
    442   set_dir_from  "$object"
    443   set_base_from "$object"
     322  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
     323  test "x$dir" = "x$object" && dir=
     324  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
    444325  if test "$libtool" = yes; then
    445326    tmpdepfile1=$dir$base.d
     
    452333  fi
    453334  stat=$?
    454   if test $stat -ne 0; then
     335  if test $stat -eq 0; then :
     336  else
    455337     rm -f "$tmpdepfile1" "$tmpdepfile2"
    456338     exit $stat
     
    462344  done
    463345  if test -f "$tmpdepfile"; then
    464     sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
    465     # Add 'dependent.h:' lines.
     346    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
     347    # Add `dependent.h:' lines.
    466348    sed -ne '2,${
    467                s/^ *//
    468                s/ \\*$//
    469                s/$/:/
    470                p
    471              }' "$tmpdepfile" >> "$depfile"
    472   else
    473     make_dummy_depfile
     349               s/^ *//
     350               s/ \\*$//
     351               s/$/:/
     352               p
     353             }' "$tmpdepfile" >> "$depfile"
     354  else
     355    echo "#dummy" > "$depfile"
    474356  fi
    475357  rm -f "$tmpdepfile" "$tmpdepfile2"
     
    477359
    478360tru64)
    479   # The Tru64 compiler uses -MD to generate dependencies as a side
    480   # effect.  'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
    481   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
    482   # dependencies in 'foo.d' instead, so we check for that too.
    483   # Subdirectories are respected.
    484   set_dir_from  "$object"
    485   set_base_from "$object"
    486 
    487   if test "$libtool" = yes; then
    488     # Libtool generates 2 separate objects for the 2 libraries.  These
    489     # two compilations output dependencies in $dir.libs/$base.o.d and
    490     # in $dir$base.o.d.  We have to check for both files, because
    491     # one of the two compilations can be disabled.  We should prefer
    492     # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
    493     # automatically cleaned when .libs/ is deleted, while ignoring
    494     # the former would cause a distcleancheck panic.
    495     tmpdepfile1=$dir$base.o.d          # libtool 1.5
    496     tmpdepfile2=$dir.libs/$base.o.d    # Likewise.
    497     tmpdepfile3=$dir.libs/$base.d      # Compaq CCC V6.2-504
    498     "$@" -Wc,-MD
    499   else
    500     tmpdepfile1=$dir$base.d
    501     tmpdepfile2=$dir$base.d
    502     tmpdepfile3=$dir$base.d
    503     "$@" -MD
    504   fi
    505 
    506   stat=$?
    507   if test $stat -ne 0; then
    508     rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
    509     exit $stat
    510   fi
    511 
    512   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
    513   do
    514     test -f "$tmpdepfile" && break
    515   done
    516   # Same post-processing that is required for AIX mode.
    517   aix_post_process_depfile
    518   ;;
     361   # The Tru64 compiler uses -MD to generate dependencies as a side
     362   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
     363   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
     364   # dependencies in `foo.d' instead, so we check for that too.
     365   # Subdirectories are respected.
     366   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
     367   test "x$dir" = "x$object" && dir=
     368   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
     369
     370   if test "$libtool" = yes; then
     371      # With Tru64 cc, shared objects can also be used to make a
     372      # static library.  This mechanism is used in libtool 1.4 series to
     373      # handle both shared and static libraries in a single compilation.
     374      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
     375      #
     376      # With libtool 1.5 this exception was removed, and libtool now
     377      # generates 2 separate objects for the 2 libraries.  These two
     378      # compilations output dependencies in $dir.libs/$base.o.d and
     379      # in $dir$base.o.d.  We have to check for both files, because
     380      # one of the two compilations can be disabled.  We should prefer
     381      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
     382      # automatically cleaned when .libs/ is deleted, while ignoring
     383      # the former would cause a distcleancheck panic.
     384      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
     385      tmpdepfile2=$dir$base.o.d          # libtool 1.5
     386      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
     387      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
     388      "$@" -Wc,-MD
     389   else
     390      tmpdepfile1=$dir$base.o.d
     391      tmpdepfile2=$dir$base.d
     392      tmpdepfile3=$dir$base.d
     393      tmpdepfile4=$dir$base.d
     394      "$@" -MD
     395   fi
     396
     397   stat=$?
     398   if test $stat -eq 0; then :
     399   else
     400      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
     401      exit $stat
     402   fi
     403
     404   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
     405   do
     406     test -f "$tmpdepfile" && break
     407   done
     408   if test -f "$tmpdepfile"; then
     409      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
     410      # That's a tab and a space in the [].
     411      sed -e 's,^.*\.[a-z]*:[    ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
     412   else
     413      echo "#dummy" > "$depfile"
     414   fi
     415   rm -f "$tmpdepfile"
     416   ;;
    519417
    520418msvc7)
     
    527425  stat=$?
    528426  grep -v '^Note: including file: ' "$tmpdepfile"
    529   if test $stat -ne 0; then
     427  if test "$stat" = 0; then :
     428  else
    530429    rm -f "$tmpdepfile"
    531430    exit $stat
     
    545444}' | $cygpath_u | sort -u | sed -n '
    546445s/ /\\ /g
    547 s/\(.*\)/'"$tab"'\1 \\/p
     446s/\(.*\)/       \1 \\/p
    548447s/.\(.*\) \\/\1:/
    549448H
    550449$ {
    551   s/.*/'"$tab"'/
     450  s/.*/ /
    552451  G
    553452  p
    554453}' >> "$depfile"
    555   echo >> "$depfile" # make sure the fragment doesn't end with a backslash
    556454  rm -f "$tmpdepfile"
    557455  ;;
     
    581479  fi
    582480
    583   # Remove '-o $object'.
     481  # Remove `-o $object'.
    584482  IFS=" "
    585483  for arg
     
    601499
    602500  test -z "$dashmflag" && dashmflag=-M
    603   # Require at least two characters before searching for ':'
     501  # Require at least two characters before searching for `:'
    604502  # in the target name.  This is to cope with DOS-style filenames:
    605   # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
     503  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
    606504  "$@" $dashmflag |
    607     sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
     505    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
    608506  rm -f "$depfile"
    609507  cat < "$tmpdepfile" > "$depfile"
    610   # Some versions of the HPUX 10.20 sed can't process this sed invocation
    611   # correctly.  Breaking it into two sed invocations is a workaround.
    612   tr ' ' "$nl" < "$tmpdepfile" \
    613     | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
    614     | sed -e 's/$/ :/' >> "$depfile"
     508  tr ' ' '
     509' < "$tmpdepfile" | \
     510## Some versions of the HPUX 10.20 sed can't process this invocation
     511## correctly.  Breaking it into two sed invocations is a workaround.
     512    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
    615513  rm -f "$tmpdepfile"
    616514  ;;
     
    665563  # No need to regex-escape $object, excess matching of '.' is harmless.
    666564  sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
    667   # Some versions of the HPUX 10.20 sed can't process the last invocation
    668   # correctly.  Breaking it into two sed invocations is a workaround.
    669   sed '1,2d' "$tmpdepfile" \
    670     | tr ' ' "$nl" \
    671     | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
    672     | sed -e 's/$/ :/' >> "$depfile"
     565  sed '1,2d' "$tmpdepfile" | tr ' ' '
     566' | \
     567## Some versions of the HPUX 10.20 sed can't process this invocation
     568## correctly.  Breaking it into two sed invocations is a workaround.
     569    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
    673570  rm -f "$tmpdepfile" "$tmpdepfile".bak
    674571  ;;
     
    687584  fi
    688585
    689   # Remove '-o $object'.
     586  # Remove `-o $object'.
    690587  IFS=" "
    691588  for arg
     
    706603  done
    707604
    708   "$@" -E \
    709     | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
    710              -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
    711     | sed '$ s: \\$::' > "$tmpdepfile"
     605  "$@" -E |
     606    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
     607       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
     608    sed '$ s: \\$::' > "$tmpdepfile"
    712609  rm -f "$depfile"
    713610  echo "$object : \\" > "$depfile"
     
    741638      ;;
    742639    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
    743         set fnord "$@"
    744         shift
    745         shift
    746         ;;
     640        set fnord "$@"
     641        shift
     642        shift
     643        ;;
    747644    *)
    748         set fnord "$@" "$arg"
    749         shift
    750         shift
    751         ;;
     645        set fnord "$@" "$arg"
     646        shift
     647        shift
     648        ;;
    752649    esac
    753650  done
     
    756653  rm -f "$depfile"
    757654  echo "$object : \\" > "$depfile"
    758   sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
    759   echo "$tab" >> "$depfile"
     655  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::      \1 \\:p' >> "$depfile"
     656  echo "        " >> "$depfile"
    760657  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
    761658  rm -f "$tmpdepfile"
  • automake/install-sh

    r0720e049 r3d4b23fa  
    22# install - install a program, script, or datafile
    33
    4 scriptversion=2014-09-12.12; # UTC
     4scriptversion=2011-01-19.21; # UTC
    55
    66# This originates from X11R5 (mit/util/scripts/install.sh), which was
     
    3636#
    3737# Calling this script install-sh is preferred over install.sh, to prevent
    38 # 'make' implicit rules from creating a file called install from it
     38# `make' implicit rules from creating a file called install from it
    3939# when there is no Makefile.
    4040#
     
    4242# from scratch.
    4343
    44 tab='   '
    4544nl='
    4645'
    47 IFS=" $tab$nl"
    48 
    49 # Set DOITPROG to "echo" to test this script.
    50 
     46IFS=" ""        $nl"
     47
     48# set DOITPROG to echo to test this script
     49
     50# Don't use :- since 4.3BSD and earlier shells don't like it.
    5151doit=${DOITPROG-}
    52 doit_exec=${doit:-exec}
     52if test -z "$doit"; then
     53  doit_exec=exec
     54else
     55  doit_exec=$doit
     56fi
    5357
    5458# Put in absolute file names if you don't have them in your path;
     
    6569stripprog=${STRIPPROG-strip}
    6670
     71posix_glob='?'
     72initialize_posix_glob='
     73  test "$posix_glob" != "?" || {
     74    if (set -f) 2>/dev/null; then
     75      posix_glob=
     76    else
     77      posix_glob=:
     78    fi
     79  }
     80'
     81
    6782posix_mkdir=
    6883
     
    8398
    8499copy_on_change=false
    85 is_target_a_directory=possibly
     100no_target_directory=
    86101
    87102usage="\
     
    123138
    124139    -g) chgrpcmd="$chgrpprog $2"
    125         shift;;
     140        shift;;
    126141
    127142    --help) echo "$usage"; exit $?;;
    128143
    129144    -m) mode=$2
    130         case $mode in
    131           *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
    132             echo "$0: invalid mode: $mode" >&2
    133             exit 1;;
    134         esac
    135         shift;;
     145        case $mode in
     146          *' '* | *'    '* | *'
     147'*        | *'*'* | *'?'* | *'['*)
     148            echo "$0: invalid mode: $mode" >&2
     149            exit 1;;
     150        esac
     151        shift;;
    136152
    137153    -o) chowncmd="$chownprog $2"
    138         shift;;
     154        shift;;
    139155
    140156    -s) stripcmd=$stripprog;;
    141157
    142     -t)
    143         is_target_a_directory=always
    144         dst_arg=$2
    145         # Protect names problematic for 'test' and other utilities.
    146         case $dst_arg in
    147           -* | [=\(\)!]) dst_arg=./$dst_arg;;
    148         esac
    149         shift;;
    150 
    151     -T) is_target_a_directory=never;;
     158    -t) dst_arg=$2
     159        # Protect names problematic for `test' and other utilities.
     160        case $dst_arg in
     161          -* | [=\(\)!]) dst_arg=./$dst_arg;;
     162        esac
     163        shift;;
     164
     165    -T) no_target_directory=true;;
    152166
    153167    --version) echo "$0 $scriptversion"; exit $?;;
    154168
    155     --) shift
    156         break;;
    157 
    158     -*) echo "$0: invalid option: $1" >&2
    159         exit 1;;
     169    --) shift
     170        break;;
     171
     172    -*) echo "$0: invalid option: $1" >&2
     173        exit 1;;
    160174
    161175    *)  break;;
     
    163177  shift
    164178done
    165 
    166 # We allow the use of options -d and -T together, by making -d
    167 # take the precedence; this is for compatibility with GNU install.
    168 
    169 if test -n "$dir_arg"; then
    170   if test -n "$dst_arg"; then
    171     echo "$0: target directory not allowed when installing a directory." >&2
    172     exit 1
    173   fi
    174 fi
    175179
    176180if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
     
    187191    shift # arg
    188192    dst_arg=$arg
    189     # Protect names problematic for 'test' and other utilities.
     193    # Protect names problematic for `test' and other utilities.
    190194    case $dst_arg in
    191195      -* | [=\(\)!]) dst_arg=./$dst_arg;;
     
    199203    exit 1
    200204  fi
    201   # It's OK to call 'install-sh -d' without argument.
     205  # It's OK to call `install-sh -d' without argument.
    202206  # This can happen when creating conditional directories.
    203207  exit 0
    204 fi
    205 
    206 if test -z "$dir_arg"; then
    207   if test $# -gt 1 || test "$is_target_a_directory" = always; then
    208     if test ! -d "$dst_arg"; then
    209       echo "$0: $dst_arg: Is not a directory." >&2
    210       exit 1
    211     fi
    212   fi
    213208fi
    214209
     
    229224    *[0-7])
    230225      if test -z "$stripcmd"; then
    231         u_plus_rw=
     226        u_plus_rw=
    232227      else
    233         u_plus_rw='% 200'
     228        u_plus_rw='% 200'
    234229      fi
    235230      cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
    236231    *)
    237232      if test -z "$stripcmd"; then
    238         u_plus_rw=
     233        u_plus_rw=
    239234      else
    240         u_plus_rw=,u+rw
     235        u_plus_rw=,u+rw
    241236      fi
    242237      cp_umask=$mode$u_plus_rw;;
     
    246241for src
    247242do
    248   # Protect names problematic for 'test' and other utilities.
     243  # Protect names problematic for `test' and other utilities.
    249244  case $src in
    250245    -* | [=\(\)!]) src=./$src;;
     
    275270    # if double slashes aren't ignored.
    276271    if test -d "$dst"; then
    277       if test "$is_target_a_directory" = never; then
    278         echo "$0: $dst_arg: Is a directory" >&2
    279         exit 1
     272      if test -n "$no_target_directory"; then
     273        echo "$0: $dst_arg: Is a directory" >&2
     274        exit 1
    280275      fi
    281276      dstdir=$dst
     
    283278      dstdir_status=0
    284279    else
    285       dstdir=`dirname "$dst"`
     280      # Prefer dirname, but fall back on a substitute if dirname fails.
     281      dstdir=`
     282        (dirname "$dst") 2>/dev/null ||
     283        expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
     284             X"$dst" : 'X\(//\)[^/]' \| \
     285             X"$dst" : 'X\(//\)$' \| \
     286             X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
     287        echo X"$dst" |
     288            sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
     289                   s//\1/
     290                   q
     291                 }
     292                 /^X\(\/\/\)[^/].*/{
     293                   s//\1/
     294                   q
     295                 }
     296                 /^X\(\/\/\)$/{
     297                   s//\1/
     298                   q
     299                 }
     300                 /^X\(\/\).*/{
     301                   s//\1/
     302                   q
     303                 }
     304                 s/.*/./; q'
     305      `
     306
    286307      test -d "$dstdir"
    287308      dstdir_status=$?
     
    294315    case $posix_mkdir in
    295316      '')
    296         # Create intermediate dirs using mode 755 as modified by the umask.
    297         # This is like FreeBSD 'install' as of 1997-10-28.
    298         umask=`umask`
    299         case $stripcmd.$umask in
    300           # Optimize common cases.
    301           *[2367][2367]) mkdir_umask=$umask;;
    302           .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
    303 
    304           *[0-7])
    305             mkdir_umask=`expr $umask + 22 \
    306               - $umask % 100 % 40 + $umask % 20 \
    307               - $umask % 10 % 4 + $umask % 2
    308             `;;
    309           *) mkdir_umask=$umask,go-w;;
    310         esac
    311 
    312         # With -d, create the new directory with the user-specified mode.
    313         # Otherwise, rely on $mkdir_umask.
    314         if test -n "$dir_arg"; then
    315           mkdir_mode=-m$mode
    316         else
    317           mkdir_mode=
    318         fi
    319 
    320         posix_mkdir=false
    321         case $umask in
    322           *[123567][0-7][0-7])
    323             # POSIX mkdir -p sets u+wx bits regardless of umask, which
    324             # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
    325             ;;
    326           *)
    327             # $RANDOM is not portable (e.g. dash);  use it when possible to
    328             # lower collision chance
    329             tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
    330             trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0
    331 
    332             # As "mkdir -p" follows symlinks and we work in /tmp possibly;  so
    333             # create the $tmpdir first (and fail if unsuccessful) to make sure
    334             # that nobody tries to guess the $tmpdir name.
    335             if (umask $mkdir_umask &&
    336                 $mkdirprog $mkdir_mode "$tmpdir" &&
    337                 exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
    338             then
    339               if test -z "$dir_arg" || {
    340                    # Check for POSIX incompatibilities with -m.
    341                    # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
    342                    # other-writable bit of parent directory when it shouldn't.
    343                    # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
    344                    test_tmpdir="$tmpdir/a"
    345                    ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
    346                    case $ls_ld_tmpdir in
    347                      d????-?r-*) different_mode=700;;
    348                      d????-?--*) different_mode=755;;
    349                      *) false;;
    350                    esac &&
    351                    $mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
    352                      ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
    353                      test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
    354                    }
    355                  }
    356               then posix_mkdir=:
    357               fi
    358               rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
    359             else
    360               # Remove any dirs left behind by ancient mkdir implementations.
    361               rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
    362             fi
    363             trap '' 0;;
    364         esac;;
     317        # Create intermediate dirs using mode 755 as modified by the umask.
     318        # This is like FreeBSD 'install' as of 1997-10-28.
     319        umask=`umask`
     320        case $stripcmd.$umask in
     321          # Optimize common cases.
     322          *[2367][2367]) mkdir_umask=$umask;;
     323          .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
     324
     325          *[0-7])
     326            mkdir_umask=`expr $umask + 22 \
     327              - $umask % 100 % 40 + $umask % 20 \
     328              - $umask % 10 % 4 + $umask % 2
     329            `;;
     330          *) mkdir_umask=$umask,go-w;;
     331        esac
     332
     333        # With -d, create the new directory with the user-specified mode.
     334        # Otherwise, rely on $mkdir_umask.
     335        if test -n "$dir_arg"; then
     336          mkdir_mode=-m$mode
     337        else
     338          mkdir_mode=
     339        fi
     340
     341        posix_mkdir=false
     342        case $umask in
     343          *[123567][0-7][0-7])
     344            # POSIX mkdir -p sets u+wx bits regardless of umask, which
     345            # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
     346            ;;
     347          *)
     348            tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
     349            trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
     350
     351            if (umask $mkdir_umask &&
     352                exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
     353            then
     354              if test -z "$dir_arg" || {
     355                   # Check for POSIX incompatibilities with -m.
     356                   # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
     357                   # other-writeable bit of parent directory when it shouldn't.
     358                   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
     359                   ls_ld_tmpdir=`ls -ld "$tmpdir"`
     360                   case $ls_ld_tmpdir in
     361                     d????-?r-*) different_mode=700;;
     362                     d????-?--*) different_mode=755;;
     363                     *) false;;
     364                   esac &&
     365                   $mkdirprog -m$different_mode -p -- "$tmpdir" && {
     366                     ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
     367                     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
     368                   }
     369                 }
     370              then posix_mkdir=:
     371              fi
     372              rmdir "$tmpdir/d" "$tmpdir"
     373            else
     374              # Remove any dirs left behind by ancient mkdir implementations.
     375              rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
     376            fi
     377            trap '' 0;;
     378        esac;;
    365379    esac
    366380
    367381    if
    368382      $posix_mkdir && (
    369         umask $mkdir_umask &&
    370         $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
     383        umask $mkdir_umask &&
     384        $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
    371385      )
    372386    then :
     
    378392
    379393      case $dstdir in
    380         /*) prefix='/';;
    381         [-=\(\)!]*) prefix='./';;
    382         *)  prefix='';;
     394        /*) prefix='/';;
     395        [-=\(\)!]*) prefix='./';;
     396        *)  prefix='';;
    383397      esac
     398
     399      eval "$initialize_posix_glob"
    384400
    385401      oIFS=$IFS
    386402      IFS=/
    387       set -f
     403      $posix_glob set -f
    388404      set fnord $dstdir
    389405      shift
    390       set +f
     406      $posix_glob set +f
    391407      IFS=$oIFS
    392408
     
    395411      for d
    396412      do
    397         test X"$d" = X && continue
    398 
    399         prefix=$prefix$d
    400         if test -d "$prefix"; then
    401           prefixes=
    402         else
    403           if $posix_mkdir; then
    404             (umask=$mkdir_umask &&
    405              $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
    406             # Don't fail if two instances are running concurrently.
    407             test -d "$prefix" || exit 1
    408           else
    409             case $prefix in
    410               *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
    411               *) qprefix=$prefix;;
    412             esac
    413             prefixes="$prefixes '$qprefix'"
    414           fi
    415         fi
    416         prefix=$prefix/
     413        test X"$d" = X && continue
     414
     415        prefix=$prefix$d
     416        if test -d "$prefix"; then
     417          prefixes=
     418        else
     419          if $posix_mkdir; then
     420            (umask=$mkdir_umask &&
     421             $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
     422            # Don't fail if two instances are running concurrently.
     423            test -d "$prefix" || exit 1
     424          else
     425            case $prefix in
     426              *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
     427              *) qprefix=$prefix;;
     428            esac
     429            prefixes="$prefixes '$qprefix'"
     430          fi
     431        fi
     432        prefix=$prefix/
    417433      done
    418434
    419435      if test -n "$prefixes"; then
    420         # Don't fail if two instances are running concurrently.
    421         (umask $mkdir_umask &&
    422         eval "\$doit_exec \$mkdirprog $prefixes") ||
    423           test -d "$dstdir" || exit 1
    424         obsolete_mkdir_used=true
     436        # Don't fail if two instances are running concurrently.
     437        (umask $mkdir_umask &&
     438        eval "\$doit_exec \$mkdirprog $prefixes") ||
     439          test -d "$dstdir" || exit 1
     440        obsolete_mkdir_used=true
    425441      fi
    426442    fi
     
    457473    # If -C, don't bother to copy if it wouldn't change the file.
    458474    if $copy_on_change &&
    459        old=`LC_ALL=C ls -dlL "$dst"     2>/dev/null` &&
    460        new=`LC_ALL=C ls -dlL "$dsttmp"  2>/dev/null` &&
    461        set -f &&
     475       old=`LC_ALL=C ls -dlL "$dst"     2>/dev/null` &&
     476       new=`LC_ALL=C ls -dlL "$dsttmp"  2>/dev/null` &&
     477
     478       eval "$initialize_posix_glob" &&
     479       $posix_glob set -f &&
    462480       set X $old && old=:$2:$4:$5:$6 &&
    463481       set X $new && new=:$2:$4:$5:$6 &&
    464        set +f &&
     482       $posix_glob set +f &&
     483
    465484       test "$old" = "$new" &&
    466485       $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
     
    475494      # support -f.
    476495      {
    477         # Now remove or move aside any old file at destination location.
    478         # We try this two ways since rm can't unlink itself on some
    479         # systems and the destination file might be busy for other
    480         # reasons.  In this case, the final cleanup might fail but the new
    481         # file should still install successfully.
    482         {
    483           test ! -f "$dst" ||
    484           $doit $rmcmd -f "$dst" 2>/dev/null ||
    485           { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
    486             { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
    487           } ||
    488           { echo "$0: cannot unlink or rename $dst" >&2
    489             (exit 1); exit 1
    490           }
    491         } &&
    492 
    493         # Now rename the file to the real destination.
    494         $doit $mvcmd "$dsttmp" "$dst"
     496        # Now remove or move aside any old file at destination location.
     497        # We try this two ways since rm can't unlink itself on some
     498        # systems and the destination file might be busy for other
     499        # reasons.  In this case, the final cleanup might fail but the new
     500        # file should still install successfully.
     501        {
     502          test ! -f "$dst" ||
     503          $doit $rmcmd -f "$dst" 2>/dev/null ||
     504          { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
     505            { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
     506          } ||
     507          { echo "$0: cannot unlink or rename $dst" >&2
     508            (exit 1); exit 1
     509          }
     510        } &&
     511
     512        # Now rename the file to the real destination.
     513        $doit $mvcmd "$dsttmp" "$dst"
    495514      }
    496515    fi || exit 1
  • automake/test-driver

    • Property mode changed from 100755 to 120000
    r0720e049 r3d4b23fa  
    1 #! /bin/sh
    2 # test-driver - basic testsuite driver script.
    3 
    4 scriptversion=2013-07-13.22; # UTC
    5 
    6 # Copyright (C) 2011-2014 Free Software Foundation, Inc.
    7 #
    8 # This program is free software; you can redistribute it and/or modify
    9 # it under the terms of the GNU General Public License as published by
    10 # the Free Software Foundation; either version 2, or (at your option)
    11 # any later version.
    12 #
    13 # This program is distributed in the hope that it will be useful,
    14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16 # GNU General Public License for more details.
    17 #
    18 # You should have received a copy of the GNU General Public License
    19 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
    20 
    21 # As a special exception to the GNU General Public License, if you
    22 # distribute this file as part of a program that contains a
    23 # configuration script generated by Autoconf, you may include it under
    24 # the same distribution terms that you use for the rest of that program.
    25 
    26 # This file is maintained in Automake, please report
    27 # bugs to <bug-automake@gnu.org> or send patches to
    28 # <automake-patches@gnu.org>.
    29 
    30 # Make unconditional expansion of undefined variables an error.  This
    31 # helps a lot in preventing typo-related bugs.
    32 set -u
    33 
    34 usage_error ()
    35 {
    36   echo "$0: $*" >&2
    37   print_usage >&2
    38   exit 2
    39 }
    40 
    41 print_usage ()
    42 {
    43   cat <<END
    44 Usage:
    45   test-driver --test-name=NAME --log-file=PATH --trs-file=PATH
    46               [--expect-failure={yes|no}] [--color-tests={yes|no}]
    47               [--enable-hard-errors={yes|no}] [--]
    48               TEST-SCRIPT [TEST-SCRIPT-ARGUMENTS]
    49 The '--test-name', '--log-file' and '--trs-file' options are mandatory.
    50 END
    51 }
    52 
    53 test_name= # Used for reporting.
    54 log_file=  # Where to save the output of the test script.
    55 trs_file=  # Where to save the metadata of the test run.
    56 expect_failure=no
    57 color_tests=no
    58 enable_hard_errors=yes
    59 while test $# -gt 0; do
    60   case $1 in
    61   --help) print_usage; exit $?;;
    62   --version) echo "test-driver $scriptversion"; exit $?;;
    63   --test-name) test_name=$2; shift;;
    64   --log-file) log_file=$2; shift;;
    65   --trs-file) trs_file=$2; shift;;
    66   --color-tests) color_tests=$2; shift;;
    67   --expect-failure) expect_failure=$2; shift;;
    68   --enable-hard-errors) enable_hard_errors=$2; shift;;
    69   --) shift; break;;
    70   -*) usage_error "invalid option: '$1'";;
    71    *) break;;
    72   esac
    73   shift
    74 done
    75 
    76 missing_opts=
    77 test x"$test_name" = x && missing_opts="$missing_opts --test-name"
    78 test x"$log_file"  = x && missing_opts="$missing_opts --log-file"
    79 test x"$trs_file"  = x && missing_opts="$missing_opts --trs-file"
    80 if test x"$missing_opts" != x; then
    81   usage_error "the following mandatory options are missing:$missing_opts"
    82 fi
    83 
    84 if test $# -eq 0; then
    85   usage_error "missing argument"
    86 fi
    87 
    88 if test $color_tests = yes; then
    89   # Keep this in sync with 'lib/am/check.am:$(am__tty_colors)'.
    90   red='[0;31m' # Red.
    91   grn='[0;32m' # Green.
    92   lgn='[1;32m' # Light green.
    93   blu='[1;34m' # Blue.
    94   mgn='[0;35m' # Magenta.
    95   std='[m'     # No color.
    96 else
    97   red= grn= lgn= blu= mgn= std=
    98 fi
    99 
    100 do_exit='rm -f $log_file $trs_file; (exit $st); exit $st'
    101 trap "st=129; $do_exit" 1
    102 trap "st=130; $do_exit" 2
    103 trap "st=141; $do_exit" 13
    104 trap "st=143; $do_exit" 15
    105 
    106 # Test script is run here.
    107 "$@" >$log_file 2>&1
    108 estatus=$?
    109 
    110 if test $enable_hard_errors = no && test $estatus -eq 99; then
    111   tweaked_estatus=1
    112 else
    113   tweaked_estatus=$estatus
    114 fi
    115 
    116 case $tweaked_estatus:$expect_failure in
    117   0:yes) col=$red res=XPASS recheck=yes gcopy=yes;;
    118   0:*)   col=$grn res=PASS  recheck=no  gcopy=no;;
    119   77:*)  col=$blu res=SKIP  recheck=no  gcopy=yes;;
    120   99:*)  col=$mgn res=ERROR recheck=yes gcopy=yes;;
    121   *:yes) col=$lgn res=XFAIL recheck=no  gcopy=yes;;
    122   *:*)   col=$red res=FAIL  recheck=yes gcopy=yes;;
    123 esac
    124 
    125 # Report the test outcome and exit status in the logs, so that one can
    126 # know whether the test passed or failed simply by looking at the '.log'
    127 # file, without the need of also peaking into the corresponding '.trs'
    128 # file (automake bug#11814).
    129 echo "$res $test_name (exit status: $estatus)" >>$log_file
    130 
    131 # Report outcome to console.
    132 echo "${col}${res}${std}: $test_name"
    133 
    134 # Register the test result, and other relevant metadata.
    135 echo ":test-result: $res" > $trs_file
    136 echo ":global-test-result: $res" >> $trs_file
    137 echo ":recheck: $recheck" >> $trs_file
    138 echo ":copy-in-global-log: $gcopy" >> $trs_file
    139 
    140 # Local Variables:
    141 # mode: shell-script
    142 # sh-indentation: 2
    143 # eval: (add-hook 'write-file-hooks 'time-stamp)
    144 # time-stamp-start: "scriptversion="
    145 # time-stamp-format: "%:y-%02m-%02d.%02H"
    146 # time-stamp-time-zone: "UTC"
    147 # time-stamp-end: "; # UTC"
    148 # End:
     1/usr/share/automake-1.15/test-driver
  • automake/ylwrap

    r0720e049 r3d4b23fa  
    22# ylwrap - wrapper for lex/yacc invocations.
    33
    4 scriptversion=2013-01-12.17; # UTC
    5 
    6 # Copyright (C) 1996-2014 Free Software Foundation, Inc.
     4scriptversion=2011-08-25.18; # UTC
     5
     6# Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005,
     7# 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
    78#
    89# Written by Tom Tromey <tromey@cygnus.com>.
     
    3031# <automake-patches@gnu.org>.
    3132
    32 get_dirname ()
    33 {
    34   case $1 in
    35     */*|*\\*) printf '%s\n' "$1" | sed -e 's|\([\\/]\)[^\\/]*$|\1|';;
    36     # Otherwise,  we want the empty string (not ".").
    37   esac
    38 }
    39 
    40 # guard FILE
    41 # ----------
    42 # The CPP macro used to guard inclusion of FILE.
    43 guard ()
    44 {
    45   printf '%s\n' "$1"                                                    \
    46     | sed                                                               \
    47         -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'   \
    48         -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'                        \
    49         -e 's/__*/_/g'
    50 }
    51 
    52 # quote_for_sed [STRING]
    53 # ----------------------
    54 # Return STRING (or stdin) quoted to be used as a sed pattern.
    55 quote_for_sed ()
    56 {
    57   case $# in
    58     0) cat;;
    59     1) printf '%s\n' "$1";;
    60   esac \
    61     | sed -e 's|[][\\.*]|\\&|g'
    62 }
    63 
    6433case "$1" in
    6534  '')
    66     echo "$0: No files given.  Try '$0 --help' for more information." 1>&2
     35    echo "$0: No files given.  Try \`$0 --help' for more information." 1>&2
    6736    exit 1
    6837    ;;
     
    9766
    9867# The input.
    99 input=$1
     68input="$1"
    10069shift
    101 # We'll later need for a correct munging of "#line" directives.
    102 input_sub_rx=`get_dirname "$input" | quote_for_sed`
    103 case $input in
     70case "$input" in
    10471  [\\/]* | ?:[\\/]*)
    10572    # Absolute path; do nothing.
     
    10774  *)
    10875    # Relative path.  Make it absolute.
    109     input=`pwd`/$input
    110     ;;
    111 esac
    112 input_rx=`get_dirname "$input" | quote_for_sed`
    113 
    114 # Since DOS filename conventions don't allow two dots,
    115 # the DOS version of Bison writes out y_tab.c instead of y.tab.c
    116 # and y_tab.h instead of y.tab.h. Test to see if this is the case.
    117 y_tab_nodot=false
    118 if test -f y_tab.c || test -f y_tab.h; then
    119   y_tab_nodot=true
    120 fi
    121 
    122 # The parser itself, the first file, is the destination of the .y.c
    123 # rule in the Makefile.
    124 parser=$1
    125 
    126 # A sed program to s/FROM/TO/g for all the FROM/TO so that, for
    127 # instance, we rename #include "y.tab.h" into #include "parse.h"
    128 # during the conversion from y.tab.c to parse.c.
    129 sed_fix_filenames=
    130 
    131 # Also rename header guards, as Bison 2.7 for instance uses its header
    132 # guard in its implementation file.
    133 sed_fix_header_guards=
    134 
    135 while test $# -ne 0; do
    136   if test x"$1" = x"--"; then
     76    input="`pwd`/$input"
     77    ;;
     78esac
     79
     80pairlist=
     81while test "$#" -ne 0; do
     82  if test "$1" = "--"; then
    13783    shift
    13884    break
    13985  fi
    140   from=$1
    141   # Handle y_tab.c and y_tab.h output by DOS
    142   if $y_tab_nodot; then
    143     case $from in
    144       "y.tab.c") from=y_tab.c;;
    145       "y.tab.h") from=y_tab.h;;
    146     esac
    147   fi
     86  pairlist="$pairlist $1"
    14887  shift
    149   to=$1
    150   shift
    151   sed_fix_filenames="${sed_fix_filenames}s|"`quote_for_sed "$from"`"|$to|g;"
    152   sed_fix_header_guards="${sed_fix_header_guards}s|"`guard "$from"`"|"`guard "$to"`"|g;"
    15388done
    15489
    15590# The program to run.
    156 prog=$1
     91prog="$1"
    15792shift
    15893# Make any relative path in $prog absolute.
    159 case $prog in
     94case "$prog" in
    16095  [\\/]* | ?:[\\/]*) ;;
    161   *[\\/]*) prog=`pwd`/$prog ;;
    162 esac
    163 
     96  *[\\/]*) prog="`pwd`/$prog" ;;
     97esac
     98
     99# FIXME: add hostname here for parallel makes that run commands on
     100# other machines.  But that might take us over the 14-char limit.
    164101dirname=ylwrap$$
    165102do_exit="cd '`pwd`' && rm -rf $dirname > /dev/null 2>&1;"' (exit $ret); exit $ret'
     
    179116
    180117if test $ret -eq 0; then
    181   for from in *
    182   do
    183     to=`printf '%s\n' "$from" | sed "$sed_fix_filenames"`
     118  set X $pairlist
     119  shift
     120  first=yes
     121  # Since DOS filename conventions don't allow two dots,
     122  # the DOS version of Bison writes out y_tab.c instead of y.tab.c
     123  # and y_tab.h instead of y.tab.h. Test to see if this is the case.
     124  y_tab_nodot="no"
     125  if test -f y_tab.c || test -f y_tab.h; then
     126    y_tab_nodot="yes"
     127  fi
     128
     129  # The directory holding the input.
     130  input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'`
     131  # Quote $INPUT_DIR so we can use it in a regexp.
     132  # FIXME: really we should care about more than `.' and `\'.
     133  input_rx=`echo "$input_dir" | sed 's,\\\\,\\\\\\\\,g;s,\\.,\\\\.,g'`
     134
     135  while test "$#" -ne 0; do
     136    from="$1"
     137    # Handle y_tab.c and y_tab.h output by DOS
     138    if test $y_tab_nodot = "yes"; then
     139      if test $from = "y.tab.c"; then
     140        from="y_tab.c"
     141      else
     142        if test $from = "y.tab.h"; then
     143          from="y_tab.h"
     144        fi
     145      fi
     146    fi
    184147    if test -f "$from"; then
    185148      # If $2 is an absolute path name, then just use that,
    186       # otherwise prepend '../'.
    187       case $to in
    188         [\\/]* | ?:[\\/]*) target=$to;;
    189         *) target=../$to;;
     149      # otherwise prepend `../'.
     150      case "$2" in
     151        [\\/]* | ?:[\\/]*) target="$2";;
     152        *) target="../$2";;
    190153      esac
    191154
    192       # Do not overwrite unchanged header files to avoid useless
    193       # recompilations.  Always update the parser itself: it is the
    194       # destination of the .y.c rule in the Makefile.  Divert the
    195       # output of all other files to a temporary file so we can
    196       # compare them to existing versions.
    197       if test $from != $parser; then
    198         realtarget=$target
    199         target=tmp-`printf '%s\n' "$target" | sed 's|.*[\\/]||g'`
    200       fi
    201 
    202       # Munge "#line" or "#" directives.  Don't let the resulting
    203       # debug information point at an absolute srcdir.  Use the real
    204       # output file name, not yy.lex.c for instance.  Adjust the
    205       # include guards too.
    206       sed -e "/^#/!b"                           \
    207           -e "s|$input_rx|$input_sub_rx|"       \
    208           -e "$sed_fix_filenames"               \
    209           -e "$sed_fix_header_guards"           \
    210         "$from" >"$target" || ret=$?
    211 
    212       # Check whether files must be updated.
    213       if test "$from" != "$parser"; then
     155      # We do not want to overwrite a header file if it hasn't
     156      # changed.  This avoid useless recompilations.  However the
     157      # parser itself (the first file) should always be updated,
     158      # because it is the destination of the .y.c rule in the
     159      # Makefile.  Divert the output of all other files to a temporary
     160      # file so we can compare them to existing versions.
     161      if test $first = no; then
     162        realtarget="$target"
     163        target="tmp-`echo $target | sed s/.*[\\/]//g`"
     164      fi
     165      # Edit out `#line' or `#' directives.
     166      #
     167      # We don't want the resulting debug information to point at
     168      # an absolute srcdir; it is better for it to just mention the
     169      # .y file with no path.
     170      #
     171      # We want to use the real output file name, not yy.lex.c for
     172      # instance.
     173      #
     174      # We want the include guards to be adjusted too.
     175      FROM=`echo "$from" | sed \
     176            -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
     177            -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
     178      TARGET=`echo "$2" | sed \
     179            -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
     180            -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
     181
     182      sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \
     183          -e "s,$FROM,$TARGET," "$from" >"$target" || ret=$?
     184
     185      # Check whether header files must be updated.
     186      if test $first = no; then
    214187        if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then
    215           echo "$to is unchanged"
     188          echo "$2" is unchanged
    216189          rm -f "$target"
    217190        else
    218           echo "updating $to"
     191          echo updating "$2"
    219192          mv -f "$target" "$realtarget"
    220193        fi
    221194      fi
    222195    else
    223       # A missing file is only an error for the parser.  This is a
    224       # blatant hack to let us support using "yacc -d".  If -d is not
    225       # specified, don't fail when the header file is "missing".
    226       if test "$from" = "$parser"; then
     196      # A missing file is only an error for the first file.  This
     197      # is a blatant hack to let us support using "yacc -d".  If -d
     198      # is not specified, we don't want an error when the header
     199      # file is "missing".
     200      if test $first = yes; then
    227201        ret=1
    228202      fi
    229203    fi
     204    shift
     205    shift
     206    first=no
    230207  done
     208else
     209  ret=$?
    231210fi
    232211
  • configure

    r0720e049 r3d4b23fa  
    34713471        case $host_cpu in
    34723472                i386)
    3473                         CFLAGS+=" -m32 "
    3474                         CXXFLAGS+=" -m32 "
    3475                         CFAFLAGS+=" -m32 "
    3476                         LDFLAGS+=" -m32 "
     3473                        CFLAGS+="-m32"
     3474                        CXXFLAGS+="-m32"
     3475                        CFAFLAGS+="-m32"
     3476                        LDFLAGS+="-m32"
    34773477                        ;;
    34783478                i686)
    3479                         CFLAGS+=" -m32 "
    3480                   CXXFLAGS+=" -m32 "
    3481                   CFAFLAGS+=" -m32 "
    3482                   LDFLAGS+=" -m32 "
     3479                        CFLAGS+="-m32"
     3480                        CXXFLAGS+="-m32"
     3481                        CFAFLAGS+="-m32"
     3482                        LDFLAGS+="-m32"
    34833483                        ;;
    34843484                x86_64)
    3485                         CFLAGS+=" -m64 "
    3486                         CXXFLAGS+=" -m64 "
    3487                         CFAFLAGS+=" -m64 "
    3488                         LDFLAGS+=" -m64 "
     3485                        CFLAGS+="-m64"
     3486                        CXXFLAGS+="-m64"
     3487                        CFAFLAGS+="-m64"
     3488                        LDFLAGS+="-m64"
    34893489                        ;;
    34903490        esac
  • configure.ac

    r0720e049 r3d4b23fa  
    167167AC_SUBST([MACHINE_TYPE],[$host_cpu])
    168168
    169 if ! test "$host_cpu" = "$build_cpu"; then
     169if ! test "$host_cpu" = "$build_cpu"; then 
    170170        case $host_cpu in
    171171                i386)
    172                         CFLAGS+=" -m32 "
    173                         CXXFLAGS+=" -m32 "
    174                         CFAFLAGS+=" -m32 "
    175                         LDFLAGS+=" -m32 "
     172                        CFLAGS+="-m32"
     173                        CXXFLAGS+="-m32"
     174                        CFAFLAGS+="-m32"
     175                        LDFLAGS+="-m32"
    176176                        ;;
    177177                i686)
    178                         CFLAGS+=" -m32 "
    179                   CXXFLAGS+=" -m32 "
    180                   CFAFLAGS+=" -m32 "
    181                   LDFLAGS+=" -m32 "
     178                        CFLAGS+="-m32"
     179                        CXXFLAGS+="-m32"
     180                        CFAFLAGS+="-m32"
     181                        LDFLAGS+="-m32"
    182182                        ;;
    183183                x86_64)
    184                         CFLAGS+=" -m64 "
    185                         CXXFLAGS+=" -m64 "
    186                         CFAFLAGS+=" -m64 "
    187                         LDFLAGS+=" -m64 "
     184                        CFLAGS+="-m64"
     185                        CXXFLAGS+="-m64"
     186                        CFAFLAGS+="-m64"
     187                        LDFLAGS+="-m64"
    188188                        ;;
    189189        esac
  • doc/LaTeXmacros/common.tex

    r0720e049 r3d4b23fa  
    1111%% Created On       : Sat Apr  9 10:06:17 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Mon Jul 24 21:02:14 2017
    14 %% Update Count     : 352
     13%% Last Modified On : Thu Jul 13 11:44:59 2017
     14%% Update Count     : 335
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    134134
    135135% inline text and code index (cannot use ©)
    136 \newcommand{\Indexc}[2][\@empty]{\lstinline[#1]$#2$\index{#2@\lstinline[#1]$#2$}}
     136\newcommand{\Indexc}[1]{\lstinline$#1$\index{#1@\lstinline$#1$}}
    137137% code index (cannot use ©)
    138 \newcommand{\indexc}[2][\@empty]{\index{#2@\lstinline[#1]$#2$}}
     138\newcommand{\indexc}[1]{\index{#1@\lstinline$#1$}}
    139139
    140140% Denote newterms in particular font and index them without particular font and in lowercase, e.g., \newterm{abc}.
     
    234234basicstyle=\linespread{0.9}\sf,                                                 % reduce line spacing and use sanserif font
    235235stringstyle=\tt,                                                                                % use typewriter font
    236 tabsize=5,                                                                                              % N space tabbing
     236tabsize=6,                                                                                              % N space tabbing
    237237xleftmargin=\parindentlnth,                                                             % indent code to paragraph indentation
    238238extendedchars=true,                                                                             % allow ASCII characters in the range 128-255
  • doc/LaTeXmacros/lstlang.sty

    r0720e049 r3d4b23fa  
    88%% Created On       : Sat May 13 16:34:42 2017
    99%% Last Modified By : Peter A. Buhr
    10 %% Last Modified On : Mon Jul 24 20:40:37 2017
    11 %% Update Count     : 13
     10%% Last Modified On : Wed Jul 12 22:42:09 2017
     11%% Update Count     : 12
    1212%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1313
     
    112112                finally, forall, ftype, _Generic, _Imaginary, inline, __label__, lvalue, _Noreturn, one_t,
    113113                otype, restrict, _Static_assert, throw, throwResume, trait, try, ttype, typeof, __typeof,
    114                 __typeof__, virtual, with, zero_t},
     114                __typeof__, with, zero_t},
    115115        morekeywords=[2]{
    116116                _Atomic, coroutine, is_coroutine, is_monitor, is_thread, monitor, mutex, nomutex,
  • doc/generic_types/generic_types.tex

    r0720e049 r3d4b23fa  
    4949
    5050% Useful macros
    51 \newcommand{\CFAIcon}{\textsf{C}\raisebox{\depth}{\rotatebox{180}{\textsf{A}}}\xspace} % Cforall symbolic name
    52 \newcommand{\CFA}{\protect\CFAIcon} % safe for section/caption
    53 \newcommand{\CC}{\textrm{C}\kern-.1em\hbox{+\kern-.25em+}\xspace} % C++ symbolic name
    54 \newcommand{\CCeleven}{\textrm{C}\kern-.1em\hbox{+\kern-.25em+}11\xspace} % C++11 symbolic name
    55 \newcommand{\CCfourteen}{\textrm{C}\kern-.1em\hbox{+\kern-.25em+}14\xspace} % C++14 symbolic name
    56 \newcommand{\CCseventeen}{\textrm{C}\kern-.1em\hbox{+\kern-.25em+}17\xspace} % C++17 symbolic name
    57 \newcommand{\CCtwenty}{\textrm{C}\kern-.1em\hbox{+\kern-.25em+}20\xspace} % C++20 symbolic name
     51\newcommand{\CFA}{C\raisebox{\depth}{\rotatebox{180}{\textsf{A}}}\hspace{-1pt}\xspace} % Cforall symbolic name
     52%\newcommand{\CFA}{C$\mathbf\forall$\xspace} % Cforall symbolic name
     53\newcommand{\CC}{\rm C\kern-.1em\hbox{+\kern-.25em+}\xspace} % C++ symbolic name
     54\newcommand{\CCeleven}{\rm C\kern-.1em\hbox{+\kern-.25em+}11\xspace} % C++11 symbolic name
     55\newcommand{\CCfourteen}{\rm C\kern-.1em\hbox{+\kern-.25em+}14\xspace} % C++14 symbolic name
     56\newcommand{\CCseventeen}{\rm C\kern-.1em\hbox{+\kern-.25em+}17\xspace} % C++17 symbolic name
     57\newcommand{\CCtwenty}{\rm C\kern-.1em\hbox{+\kern-.25em+}20\xspace} % C++20 symbolic name
    5858\newcommand{\CCV}{\rm C\kern-.1em\hbox{+\kern-.25em+}obj\xspace} % C++ virtual symbolic name
    5959\newcommand{\Csharp}{C\raisebox{-0.7ex}{\Large$^\sharp$}\xspace} % C# symbolic name
     
    443443This function could acquire the layout for @set(T)@ by calling its layout function with the layout of @T@ implicitly passed into the function.
    444444
    445 Whether a type is concrete, dtype-static, or dynamic is decided solely on the @forall@'s type parameters.
    446 This design allows opaque forward declarations of generic types, \eg @forall(otype T)@ @struct Box@ -- like in C, all uses of @Box(T)@ can be separately compiled, and callers from other translation units know the proper calling conventions to use.
    447 If the definition of a structure type is included in deciding whether a generic type is dynamic or concrete, some further types may be recognized as dtype-static (\eg @forall(otype T)@ @struct unique_ptr { T * p }@ does not depend on @T@ for its layout, but the existence of an @otype@ parameter means that it \emph{could}.), but preserving separate compilation (and the associated C compatibility) in the existing design is judged to be an appropriate trade-off.
     445Whether a type is concrete, dtype-static, or dynamic is decided solely on the type parameters and @forall@ clause on a declaration.
     446This design allows opaque forward declarations of generic types, \eg @forall(otype T) struct Box@ -- like in C, all uses of @Box(T)@ can be separately compiled, and callers from other translation units know the proper calling conventions to use.
     447If the definition of a structure type is included in deciding whether a generic type is dynamic or concrete, some further types may be recognized as dtype-static (\eg @forall(otype T) struct unique_ptr { T * p }@ does not depend on @T@ for its layout, but the existence of an @otype@ parameter means that it \emph{could}.), but preserving separate compilation (and the associated C compatibility) in the existing design is judged to be an appropriate trade-off.
    448448
    449449
     
    855855}
    856856\end{lstlisting}
    857 \begin{sloppypar}
    858857Tuple expressions are then simply converted directly into compound literals, \eg @[5, 'x', 1.24]@ becomes @(_tuple3(int, char, double)){ 5, 'x', 1.24 }@.
    859 \end{sloppypar}
    860858
    861859\begin{comment}
  • doc/proposals/concurrency/text/concurrency.tex

    r0720e049 r3d4b23fa  
    44% ======================================================================
    55% ======================================================================
    6 Several tool can be used to solve concurrency challenges. Since many of these challenges appear with the use of mutable shared-state, some languages and libraries simply disallow mutable shared-state (Erlang~\cite{Erlang}, Haskell~\cite{Haskell}, Akka (Scala)~\cite{Akka}). In these paradigms, interaction among concurrent objects relies on message passing~\cite{Thoth,Harmony,V-Kernel} or other paradigms that closely relate to networking concepts (channels\cit for example). However, in languages that use routine calls as their core abstraction-mechanism, these approaches force a clear distinction between concurrent and non-concurrent paradigms (i.e., message passing versus routine call). This distinction in turn means that, in order to be effective, programmers need to learn two sets of designs patterns. While this distinction can be hidden away in library code, effective use of the librairy still has to take both paradigms into account.
    7 
    8 Approaches based on shared memory are more closely related to non-concurrent paradigms since they often rely on basic constructs like routine calls and shared objects. At the lowest level, concurrent paradigms are implemented as atomic operations and locks. Many such mechanisms have been proposed, including semaphores~\cite{Dijkstra68b} and path expressions~\cite{Campbell74}. However, for productivity reasons it is desireable to have a higher-level construct be the core concurrency paradigm~\cite{HPP:Study}.
    9 
    10 An approach that is worth mentionning because it is gaining in popularity is transactionnal memory~\cite{Dice10}[Check citation]. While this approach is even pursued by system languages like \CC\cit, the performance and feature set is currently too restrictive to be the main concurrency paradigm for general purpose language, which is why it was rejected as the core paradigm for concurrency in \CFA.
     6Several tool can be used to solve concurrency challenges. Since many of these challenges appear with the use of mutable shared-state, some languages and libraries simply disallow mutable shared-state (Erlang~\cite{Erlang}, Haskell~\cite{Haskell}, Akka (Scala)~\cite{Akka}). In these paradigms, interaction among concurrent objects relies on message passing~\cite{Thoth,Harmony,V-Kernel} or other paradigms that closely relate to networking concepts (channels\cit for example). However, in languages that use routine calls as their core abstraction-mechanism, these approaches force a clear distinction between concurrent and non-concurrent paradigms (i.e., message passing versus routine call). This distinction in turn means that, in order to be effective, programmers need to learn two sets of designs patterns. While this distinction can be hidden away in library code, effective use of the librairy still has to take both paradigms into account. 
     7
     8Approaches based on shared memory are more closely related to non-concurrent paradigms since they often rely on basic constructs like routine calls and shared objects. At the lowest level, concurrent paradigms are implemented as atomic operations and locks. Many such mechanisms have been proposed, including semaphores~\cite{Dijkstra68b} and path expressions~\cite{Campbell74}. However, for productivity reasons it is desireable to have a higher-level construct be the core concurrency paradigm~\cite{HPP:Study}. 
     9
     10An approach that is worth mentionning because it is gaining in popularity is transactionnal memory~\cite{Dice10}[Check citation]. While this approach is even pursued by system languages like \CC\cit, the performance and feature set is currently too restrictive to be the main concurrency paradigm for general purpose language, which is why it was rejected as the core paradigm for concurrency in \CFA. 
    1111
    1212One of the most natural, elegant, and efficient mechanisms for synchronization and communication, especially for shared memory systems, is the \emph{monitor}. Monitors were first proposed by Brinch Hansen~\cite{Hansen73} and later described and extended by C.A.R.~Hoare~\cite{Hoare74}. Many programming languages---e.g., Concurrent Pascal~\cite{ConcurrentPascal}, Mesa~\cite{Mesa}, Modula~\cite{Modula-2}, Turing~\cite{Turing:old}, Modula-3~\cite{Modula-3}, NeWS~\cite{NeWS}, Emerald~\cite{Emerald}, \uC~\cite{Buhr92a} and Java~\cite{Java}---provide monitors as explicit language constructs. In addition, operating-system kernels and device drivers have a monitor-like structure, although they often use lower-level primitives such as semaphores or locks to simulate monitors. For these reasons, this project proposes monitors as the core concurrency-construct.
     
    101101        }
    102102\end{cfacode}
    103 The multi-acquisition monitor lock allows a monitor lock to be acquired by both \code{bar} or \code{baz} and acquired again in \code{foo}. In the calls to \code{bar} and \code{baz} the monitors are acquired in opposite order.
     103The multi-acquisition monitor lock allows a monitor lock to be acquired by both \code{bar} or \code{baz} and acquired again in \code{foo}. In the calls to \code{bar} and \code{baz} the monitors are acquired in opposite order. 
    104104
    105105However, such use leads the lock acquiring order problem. In the example above, the user uses implicit ordering in the case of function \code{foo} but explicit ordering in the case of \code{bar} and \code{baz}. This subtle mistake means that calling these routines concurrently may lead to deadlock and is therefore undefined behavior. As shown on several occasion\cit, solving this problem requires:
     
    169169\end{tabular}
    170170\end{center}
    171 Notice how the counter is used without any explicit synchronisation and yet supports thread-safe semantics for both reading and writting.
     171Notice how the counter is used without any explicit synchronisation and yet supports thread-safe semantics for both reading and writting. 
    172172
    173173% ======================================================================
     
    178178Depending on the choice of semantics for when monitor locks are acquired, interaction between monitors and \CFA's concept of polymorphism can be complex to support. However, it is shown that entry-point locking solves most of the issues.
    179179
    180 First of all, interaction between \code{otype} polymorphism and monitors is impossible since monitors do not support copying. Therefore, the main question is how to support \code{dtype} polymorphism. Since a monitor's main purpose is to ensure mutual exclusion when accessing shared data, this implies that mutual exclusion is only required for routines that do in fact access shared data. However, since \code{dtype} polymorphism always handles incomplete types (by definition), no \code{dtype} polymorphic routine can access shared data since the data requires knowledge about the type. Therefore, the only concern when combining \code{dtype} polymorphism and monitors is to protect access to routines.
    181 
    182 Before looking into complex control-flow, it is important to present the difference between the two acquiring options : callsite and entry-point locking, i.e. acquiring the monitors before making a mutex routine call or as the first operation of the mutex routine-call. For example:
     180First of all, interaction between \code{otype} polymorphism and monitors is impossible since monitors do not support copying. Therefore, the main question is how to support \code{dtype} polymorphism. Since a monitor's main purpose is to ensure mutual exclusion when accessing shared data, this implies that mutual exclusion is only required for routines that do in fact access shared data. However, since \code{dtype} polymorphism always handles incomplete types (by definition), no \code{dtype} polymorphic routine can access shared data since the data requires knowledge about the type. Therefore, the only concern when combining \code{dtype} polymorphism and monitors is to protect access to routines. 
     181
     182Before looking into complex control flow, it is important to present the difference between the two acquiring options : \gls{callsite-locking} and \gls{entry-point-locking}, i.e. acquiring the monitors before making a mutex routine call or as the first instruction of the mutex routine call. For example:
    183183\begin{center}
    184184\setlength\tabcolsep{1.5pt}
     
    245245\end{center}
    246246
    247 \Gls{callsite-locking} is inefficient, since any \code{dtype} routine may have to obtain some lock before calling a routine, depending on whether or not the type passed is a monitor. However, with \gls{entry-point-locking} calling a monitor routine becomes exactly the same as calling it from anywhere else.
    248 
    249 Note the \code{mutex} keyword relies on the resolver, which means that in cases where a generic monitor routine is actually desired, writing a mutex routine is possible with the proper trait. This is possible because monitors are designed in terms a trait. For example:
     247\Gls{callsite-locking} is inefficient, since any \code{dtype} routine may have to obtain some lock before calling a routine, depending on whether or not the type passed is a monitor. However, with \gls{entry-point-locking} calling a monitor routine becomes exactly the same as calling it from anywhere else. Note that the \code{mutex} keyword relies on the resolver rather than another form of language, which mean that in cases where a generic monitor routine is actually desired, writing a mutex routine is possible with the proper trait. This is possible because monitors are designed in terms a trait. For example:
    250248\begin{cfacode}
    251249//Incorrect
    252250//T is not a monitor
    253251forall(dtype T)
    254 void foo(T * mutex t);
     252void foo(T * mutex t); 
    255253
    256254//Correct
    257 //this function only works on monitors
     255//this function only works on monitors 
    258256//(any monitor)
    259257forall(dtype T | is_monitor(T))
    260 void bar(T * mutex t));
     258void bar(T * mutex t)); 
    261259\end{cfacode}
    262260
     
    269267In addition to mutual exclusion, the monitors at the core of \CFA's concurrency can also be used to achieve synchronisation. With monitors, this is generally achieved with internal or external scheduling as in\cit. Since internal scheduling of single monitors is mostly a solved problem, this proposal concentraits on extending internal scheduling to multiple monitors at once. Indeed, like the \gls{group-acquire} semantics, internal scheduling extends to multiple monitors at once in a way that is natural to the user but requires additional complexity on the implementation side.
    270268
    271 First, here is a simple example of such a technique:
     269First, Here is a simple example of such a technique:
    272270
    273271\begin{cfacode}
     
    291289\end{cfacode}
    292290
    293 There are two details to note here. First, there \code{signal} is a delayed operation, it only unblocks the waiting thread when it reaches the end of the critical section. This is needed to respect mutual-exclusion. Second, in \CFA, \code{condition} have no particular need to be stored inside a monitor, beyond any software engineering reasons. Here routine \code{foo} waits for the \code{signal} from \code{bar} before making further progress, effectively ensuring a basic ordering.
     291There are two details to note here. First, there \code{signal} is a delayed operation, it only unblocks the waiting thread when it reaches the end of the critical section. This is needed to respect mutual-exclusion. Second, in \CFA, \code{condition} have no particular need to be stored inside a monitor, beyond any software engineering reasons. Here routine \code{foo} waits for the \code{signal} from \code{bar} before making further progress, effectively ensuring a basic ordering. 
    294292
    295293An important aspect to take into account here is that \CFA does not allow barging, which means that once function \code{bar} releases the monitor, foo is guaranteed to resume immediately after (unless some other thread waited on the same condition). This guarantees offers the benefit of not having to loop arount waits in order to guarantee that a condition is still met. The main reason \CFA offers this guarantee is that users can easily introduce barging if it becomes a necessity but adding barging prevention or barging avoidance is more involved without language support. Supporting barging prevention as well as extending internal scheduling to multiple monitors is the main source of complexity in the design of \CFA concurrency.
     
    319317\end{pseudo}
    320318\end{multicols}
    321 The example shows the simple case of having two threads (one for each column) and a single monitor A. One thread acquires before waiting (atomically blocking and releasing A) and the other acquires before signalling. There is an important thing to note here, both \code{wait} and \code{signal} must be called with the proper monitor(s) already acquired. This restriction is hidden on the user side in \uC, as it is a logical requirement for barging prevention.
     319
     320The previous example shows the simple case of having two threads (one for each column) and a single monitor A. One thread acquires before waiting (atomically blocking and releasing A) and the other acquires before signalling. There is an important thing to note here, both \code{wait} and \code{signal} must be called with the proper monitor(s) already acquired. This restriction is hidden on the user side in \uC, as it is a logical requirement for barging prevention.
    322321
    323322A direct extension of the previous example is the \gls{group-acquire} version:
     
    338337\end{pseudo}
    339338\end{multicols}
     339
    340340This version uses \gls{group-acquire} (denoted using the \& symbol), but the presence of multiple monitors does not add a particularly new meaning. Synchronization happens between the two threads in exactly the same way and order. The only difference is that mutual exclusion covers more monitors. On the implementation side, handling multiple monitors does add a degree of complexity as the next few examples demonstrate.
    341341
     
    397397\end{center}
    398398
    399 It is particularly important to pay attention to code sections 8 and 3, which are where the existing semantics of internal scheduling need to be extended for multiple monitors. The root of the problem is that \gls{group-acquire} is used in a context where one of the monitors is already acquired and is why it is important to define the behaviour of the previous pseudo-code. When the signaller thread reaches the location where it should "release A \& B" (line 16), it must actually transfer ownership of monitor B to the waiting thread. This ownership trasnfer is required in order to prevent barging. Since the signalling thread still needs the monitor A, simply waking up the waiting thread is not an option because it would violate mutual exclusion. There are three options:
     399It is particularly important to pay attention to code sections 8 and 3, which are where the existing semantics of internal scheduling need to be extended for multiple monitors. The root of the problem is that \gls{group-acquire} is used in a context where one of the monitors is already acquired and is why it is important to define the behaviour of the previous pseudo-code. When the signaller thread reaches the location where it should "release A \& B" (line 17), it must actually transfer ownership of monitor B to the waiting thread. This ownership trasnfer is required in order to prevent barging. Since the signalling thread still needs the monitor A, simply waking up the waiting thread is not an option because it would violate mutual exclusion. We are therefore left with three options:
    400400
    401401\subsubsection{Delaying signals}
    402 The first more obvious solution to solve the problem of multi-monitor scheduling is to keep ownership of all locks until the last lock is ready to be transferred. It can be argued that that moment is the correct time to transfer ownership when the last lock is no longer needed because this semantics fits most closely to the behaviour of single monitor scheduling. This solution has the main benefit of transferring ownership of groups of monitors, which simplifies the semantics from mutiple objects to a single group of object, effectively making the existing single monitor semantic viable by simply changing monitors to monitor collections.
     402The first more obvious solution to solve the problem of multi-monitor scheduling is to keep ownership of all locks until the last lock is ready to be transferred. It can be argued that that moment is the correct time to transfer ownership when the last lock is no longer needed is what fits most closely to the behaviour of single monitor scheduling. This solution has the main benefit of transferring ownership of groups of monitors, which simplifies the semantics from mutiple objects to a single groupd of object. Effectively making the existing single monitor semantic viable by simply changing monitors to monitor collections.
    403403\begin{multicols}{2}
    404404Waiter
     
    424424\end{pseudo}
    425425\end{multicols}
    426 However, this solution can become much more complicated depending on what is executed while secretly holding B (at line 10). Indeed, nothing prevents a user from signalling monitor A on a different condition variable:
     426However, this solution can become much more complicated depending on what is executed while secretly holding B. Indeed, nothing prevents a user from signalling monitor A on a different condition variable:
    427427\newpage
    428428\begin{multicols}{2}
     
    459459\end{multicols}
    460460
    461 The goal in this solution is to avoid the need to transfer ownership of a subset of the condition monitors. However, this goal is unreacheable in the previous example. Depending on the order of signals (line 12 and 15) two cases can happen.
    462 
    463 \paragraph{Case 1: thread 1 goes first.} In this case, the problem is that monitor A needs to be passed to thread 2 when thread 1 is done with it.
    464 \paragraph{Case 2: thread 2 goes first.} In this case, the problem is that monitor B needs to be passed to thread 1, which can be done directly or using thread 2 as an intermediate.
     461The goal in this solution is to avoid the need to transfer ownership of a subset of the condition monitors. However, this goal is unreacheable in the previous example. Depending on the order of signals (line 12 and 15) two cases can happen. Note that ordering is not determined by a race condition but by whether signalled threads are enqueued in FIFO or FILO order. However, regardless of the answer, users can move line 15 before line 11 and get the reverse effect.
     462
     463\paragraph{Case 1: thread 1 will go first.} In this case, the problem is that monitor A needs to be passed to thread 2 when thread 1 is done with it.
     464\paragraph{Case 2: thread 2 will go first.} In this case, the problem is that monitor B needs to be passed to thread 1. This can be done directly or using thread 2 as an intermediate.
    465465\\
    466466
    467 Note that ordering is not determined by a race condition but by whether signalled threads are enqueued in FIFO or FILO order. However, regardless of the answer, users can move line 15 before line 11 and get the reverse effect.
    468 
    469467In both cases however, the threads need to be able to distinguish on a per monitor basis which ones need to be released and which ones need to be transferred. Which means monitors cannot be handled as a single homogenous group.
    470468
    471469\subsubsection{Dependency graphs}
    472 In the Listing 1 pseudo-code, there is a solution which statisfies both barging prevention and mutual exclusion. If ownership of both monitors is transferred to the waiter when the signaller releases A and then the waiter transfers back ownership of A when it releases it then the problem is solved. Dynamically finding the correct order is therefore the second possible solution. The problem it encounters is that it effectively boils down to resolving a dependency graph of ownership requirements. Here even the simplest of code snippets requires two transfers and it seems to increase in a manner closer to polynomial. For example, the following code, which is just a direct extension to three monitors, requires at least three ownership transfer and has multiple solutions:
     470In the Listing 1 pseudo-code, there is a solution which would statisfy both barging prevention and mutual exclusion. If ownership of both monitors is transferred to the waiter when the signaller releases A and then the waiter transfers back ownership of A when it releases it then the problem is solved. Dynamically finding the correct order is therefore the second possible solution. The problem it encounters is that it effectively boils down to resolving a dependency graph of ownership requirements. Here even the simplest of code snippets requires two transfers and it seems to increase in a manner closer to polynomial. For example the following code which is just a direct extension to three monitors requires at least three ownership transfer and has multiple solutions:
    473471
    474472\begin{multicols}{2}
     
    498496
    499497\subsubsection{Partial signalling}
    500 Finally, the solution that is chosen for \CFA is to use partial signalling. Consider the following case:
     498Finally, the solution that was chosen for \CFA is to use partial signalling. Consider the following case:
    501499
    502500\begin{multicols}{2}
     
    520518\end{pseudo}
    521519\end{multicols}
    522 The partial signalling solution transfers ownership of monitor B at lines 10 but does not wake the waiting thread since it is still using monitor A. Only when it reaches line 11 does it actually wakeup the waiting thread. This solution has the benefit that complexity is encapsulated into only two actions, passing monitors to the next owner when they should be release and conditionnaly waking threads if all conditions are met. Contrary to the other solutions, this solution quickly hits an upper bound on complexity of implementation.
     520
     521The partial signalling solution transfers ownership of monitor B at lines 10 but does not wake the waiting thread since it is still using monitor A. Only when it reaches line 11 does it actually wakeup the waiting thread. This solution has the benefit that complexity is encapsulated in to only two actions, passing monitors to the next owner when they should be release and conditionnaly waking threads if all conditions are met. Contrary to the other solutions, this solution quickly hits an upper bound on complexity of implementation.
    523522
    524523% ======================================================================
     
    527526% ======================================================================
    528527% ======================================================================
    529 An important note is that, until now, signalling a monitor was a delayed operation. The ownership of the monitor is transferred only when the monitor would have otherwise been released, not at the point of the \code{signal} statement. However, in some cases, it may be more convenient for users to immediately transfer ownership to the thread that is waiting for cooperation, which is achieved using the \code{signal_block} routine\footnote{name to be discussed}.
     528An important note is that, until now, signalling a monitor was a delayed operation. The ownership of the monitor is transferred only when the monitor would have otherwise been released, not at the point of the \code{signal} statement. However, in some cases, it may be more convenient for users to immediately transfer ownership to the thread that is waiting for cooperation. This is achieved using the \code{signal_block} routine\footnote{name to be discussed}.
    530529
    531530For example here is an example highlighting the difference in behaviour:
     
    626625        bool inUse;
    627626public:
    628         void P() {
    629                 if(inUse) wait(c);
     627        void P() { 
     628                if(inUse) wait(c); 
    630629                inUse = true;
    631630        }
    632         void V() {
    633                 inUse = false;
    634                 signal(c);
     631        void V() { 
     632                inUse = false;         
     633                signal(c); 
    635634        }
    636635}
     
    640639        bool inUse;
    641640public:
    642         void P() {
    643                 if(inUse) _Accept(V);
     641        void P() { 
     642                if(inUse) _Accept(V); 
    644643                inUse = true;
    645644        }
    646         void g() {
     645        void g() { 
    647646                inUse = false;
    648647
  • doc/proposals/concurrency/version

    r0720e049 r3d4b23fa  
    1 0.9.122
     10.9.119
  • doc/proposals/virtual.txt

    r0720e049 r3d4b23fa  
    11Proposal for virtual functionality
    2 
    3 There are two types of virtual inheritance in this proposal, relaxed
    4 (implicit) and strict (explicit). Relaxed is the simpler case that uses the
    5 existing trait system with the addition of trait references and vtables.
    6 Strict adds some constraints and requires some additional notation but allows
    7 for down-casting.
    8 
    9 Relaxed Virtual Inheritance:
    102
    113Imagine the following code :
     
    2820void draw(line*);
    2921
    30 While all the members of this simple UI support drawing, creating a UI that
    31 easily supports both these UI requires some tedious boiler-plate code:
     22While all the members of this simple UI support drawing creating a UI that easily
     23supports both these UI requires some tedious boiler-plate code :
    3224
    3325enum type_t { text, line };
     
    4941}
    5042
    51 While this code will work as implemented, adding any new widgets or any new
    52 widget behaviors requires changing existing code to add the desired
    53 functionality. To ease this maintenance effort required CFA introduces the
    54 concept of trait references.
     43While this code will work as indented, adding any new widgets or any new widget behaviors
     44requires changing existing code to add the desired functionality. To ease this maintenance
     45effort required CFA introduces the concept of dynamic types, in a manner similar to C++.
    5546
    56 Using trait references to implement the above gives the following :
     47A simple usage of dynamic type with the previous example would look like :
    5748
    58 trait drawable objects[10];
     49drawable* objects[10];
    5950fill_objects(objects);
    6051
    6152while(running) {
    62       for(drawable object : objects) {
     53      for(drawable* object : objects) {
    6354            draw(object);
    6455      }
    6556}
    6657
    67 The keyword trait is optional (by the same rules as the struct keyword). This
    68 is not currently supported in CFA and the lookup is not possible to implement
    69 statically. Therefore we need to add a new feature to handle having dynamic
    70 lookups like this.
     58However, this is not currently do-able in the current CFA and furthermore is not
     59possible to implement statically. Therefore we need to add a new feature to handle
     60having dynamic types like this (That is types that are found dynamically not types
     61that change dynamically).
    7162
    72 What we really want to do is express the fact that calling draw() on a trait
    73 reference should find the underlying type of the given parameter and find how
    74 it implements the routine, as in the example with the enumeration and union.
     63C++ uses inheritance and virtual functions to find the
     64desired type dynamically. CFA takes inspiration from this solution.
    7565
    76 For instance specifying that the drawable trait reference looks up the type
    77 of the first argument to find the implementation would be :
     66What we really want to do is express the fact that calling draw() on a object
     67should find the dynamic type of the parameter before calling the routine, much like the
     68hand written example given above. We can express this by adding the virtual keyword on
     69the parameter of the constraints on our trait:
    7870
    7971trait drawable(otype T) {
     
    8173};
    8274
    83 This could be implied in simple cases like this one (single parameter on the
    84 trait and single generic parameter on the function). In more complex cases it
    85 would have to be explicitly given, or a strong convention would have to be
    86 enforced (e.g. implementation of trait functions is always drawn from the
    87 first polymorphic parameter).
     75This expresses the idea that drawable is similar to an abstract base class in C++ and
     76also gives meaning to trying to take a pointer of drawable. That is anything that can
     77be cast to a drawable pointer has the necessary information to call the draw routine on
     78that type. Before that drawable was only a abstract type while now it also points to a
     79piece of storage which specify which behavior the object will have at run time.
    8880
    89 Once a function in a trait has been marked as virtual it defines a new
    90 function that takes in that trait's reference and then dynamically calls the
    91 underlying type implementation. Hence a trait reference becomes a kind of
    92 abstract type, cannot be directly instantiated but can still be used.
     81This storage needs to be allocate somewhere. C++ just adds an invisible pointer at
     82the beginning of the struct but we can do something more explicit for users, actually
     83have a visible special field :
    9384
    94 One of the limitations of this design is that it does not support double
    95 dispatching, which concretely means traits cannot have routines with more than
    96 one virtual parameter. The program must have a single table to look up the
    97 function on. Using trait references with traits with more than one parameter
    98 is also restricted, initially forbidden, see extension.
     85struct text {
     86      char* text;
     87      vtable drawable;
     88};
    9989
    100 Extension: Multi-parameter Virtual Traits:
     90struct line{
     91      vtable drawable;
     92      vec2 start;
     93      vec2 end;
     94};
    10195
    102 This implementation can be extended to traits with multiple parameters if
    103 one is called out as being the virtual trait. For example :
     96With these semantics, adding a "vtable drawable" means that text pointers and line pointers are now
     97convertible to drawable pointers. This conversion will not necessarily be a type only change however, indeed,
     98the drawable pointer will point to the field "vtable drawable" not the head of the struct. However, since all
     99the types are known at compile time, converting pointers becomes a simple offset operations.
    104100
    105 trait iterator(otype T, dtype Item) {
    106         Maybe(Item) next(virtual T *);
     101The vtable field contains a pointer to a vtable which contains all the information needed for the caller
     102to find the function pointer of the desired behavior.
     103
     104One of the limitations of this design is that it does not support double dispatching, which
     105concretely means traits cannot have routines with more than one virtual parameter. This design
     106would have many ambiguities if it did support multiple virtual parameter. A futher limitation is
     107that traits over more than one type cannot have vtables meaningfully defined for them, as the
     108particular vtable to use would be a function of the other type(s) the trait is defined over.
     109
     110It is worth noting that the function pointers in these vtables are bound at object construction, rather than
     111function call-site, as in Cforall's existing polymorphic functions. As such, it is possible that two objects
     112with the same static type would have a different vtable (consider what happens if draw(line*) is overridden
     113between the definitions of two line objects). Given that the virtual drawable* erases static types though,
     114this should not be confusing in practice. A more distressing possibility is that of creating an object that
     115outlives the scope of one of the functions in its vtable. This is certainly a possible bug, but it is of a
     116type that C programmers are familiar with, and should be able to avoid by the usual methods.
     117
     118Extensibility.
     119
     120One of the obvious critics of this implementation is that it lacks extensibility for classes
     121that cannot be modified (ex: Linux C headers). However this solution can be extended to
     122allow more extensibility by adding "Fat pointers".
     123
     124Indeed, users could already "solve" this issue by writing their own fat pointers as such:
     125
     126trait MyContext(otype T) {
     127      void* get_stack(virtual T*)
     128};
     129
     130void* get_stack(ucontext_t *context);
     131
     132struct fat_ucontext_t {
     133      vtable MyContext;
     134      ucontext_t *context;
    107135}
    108136
    109 iterator(int) generators[10];
    110 
    111 Which creates a collection of iterators that produce integers, regardless of
    112 how those iterators are implemented. This may require a note that this trait
    113 is virtual on T and not Item, but noting it on the functions may be enough.
    114 
    115 
    116 Strict Virtual Inheritance:
    117 
    118 One powerful feature relaxed virtual does not support is the idea of down
    119 casting. Once something has been converted into a trait reference there is
    120 very little we can do to recover and of the type information, only the trait's
    121 required function implementations are kept.
    122 
    123 To allow down casting strict virtual requires that all traits and structures
    124 involved be organized into a tree. Each trait or struct must have a unique
    125 position on this tree (no multiple inheritance).
    126 
    127 This is declared as follows :
    128 
    129 trait error(otype T) virtual {
    130         const char * msg(T *);
     137//Tedious forwarding routine
     138void* get_stack(fat_ucontext_t *ptr) {
     139      return get_stack(ptr->context);
    131140}
    132141
    133 trait io_error(otype T) virtual error {
    134         FILE * src(T *);
    135 }
     142However, users would have to write all the virtual methods they want to override and make
     143them all simply forward to the existing method that takes the corresponding POCO(Plain Old C Object).
    136144
    137 struct eof_error virtual io_error {
    138         FILE * fd;
     145The alternative we propose is to use language level fat pointers :
     146
     147trait MyContext(otype T) {
     148      void* get_stack(virtual T*)
    139149};
    140150
    141 So the trait error is the head of a new tree and io_error is a child of it.
     151void* get_stack(ucontext_t *context);
    142152
    143 Also the parent trait is implicitly part of the assertions of the children,
    144 so all children implement the same operations as the parent. By the unique
    145 path down the tree, we can also uniquely order them so that a prefix of a
    146 child's vtable has the same format as its parent's.
     153//The type vptr(ucontext_t) all
     154vptr(ucontext_t) context;
    147155
    148 This gives us an important extra feature, runtime checking of the parent-child
    149 relationship with a C++ dynamic_cast like operation. Allowing checked
    150 conversions from trait references to more particular references, which works
    151 if the underlying type is, or is a child of, the new trait type.
     156These behave exactly as the previous example but all the forwarding routines are automatically generated.
    152157
    153 Extension: Multiple Parents
     158Bikeshedding.
    154159
    155 Although each trait/struct must have a unique position on each tree, it could
    156 have positions on multiple trees. All this requires is the ability to give
    157 multiple parents, as here :
     160It may be desirable to add fewer new keywords than discussed in this proposal; it is possible that "virtual"
     161could replace both "vtable" and "vptr" above with unambiguous contextual meaning. However, for purposes of
     162clarity in the design discussion it is beneficial to keep the keywords for separate concepts distinct.
    158163
    159 trait region(otype T) virtual drawable, collider;
    160 
    161 The restriction being, the parents must come from different trees. This
    162 object (and all of its children) can be cast to either tree. This is handled
    163 by generating a separate vtable for each tree the structure is in.
    164 
    165 Extension: Multi-parameter Strict Virtual
    166 
    167 If a trait has multiple parameters then one must be called out to be the one
    168 we generate separate vtables for, as in :
    169 
    170 trait example(otype T, otype U) virtual(T) ...
    171 
    172 This can generate a separate vtable for each U for which all the T+U
    173 implementations are provided. These are then separate nodes in the tree (or
    174 the root of different trees) as if each was created individually. Providing a
    175 single unique instance of these nodes would be the most difficult aspect of
    176 this extension, possibly intractable, though with sufficient hoisting and
    177 link-once duplication it may be possible.
    178 
    179 Example:
    180 
    181 trait argument(otype T) virtual {
    182         char short_name(virtual T *);
    183         bool is_set(virtual T *);
    184 };
    185 
    186 trait value_argument(otype T, otype U) virtual(T) argument {
    187         U get_value(virtual T *);
    188 };
    189 
    190 Extension: Structural Inheritance
    191 
    192 Currently traits must be the internal nodes and structs the leaf nodes.
    193 Structs could be made internal nodes as well, in which case the child structs
    194 would likely structurally inherit the fields of their parents.
    195 
    196 
    197 Storing the Virtual Lookup Table (vtable):
    198 
    199 We have so far been silent on how the vtable is created, stored and accessed.
    200 
    201 Creation happens at compile time. Function pointers are found by using the
    202 same best match rules as elsewhere (additional rules for defaults from the
    203 parent may or may not be required). For strict virtual this must happen at the
    204 global scope and forbidding static functions, to ensure that a single unique
    205 vtable is created. Similarly, there may have to be stricter matching rules
    206 for the functions that go into the vtable, possibly requiring an exact match.
    207 Relaxed virtual could relax both restrictions, if we allow different vtable
    208 at different conversion (struct to trait reference) sites. If it is allowed
    209 local functions being bound to a vtable could cause issues when they go out
    210 of scope, however this should follow the lifetime rules most C programs
    211 already follow implicitly.
    212 
    213 Most vtables should be stored statically, the only exception being some of
    214 the relaxed vtables that could have local function pointers. These may be able
    215 to be stack allocated. All vtables should be immutable and require no manual
    216 cleanup.
    217 
    218 Access has two main options:
    219 
    220 The first is through the use of fat pointers, or a tuple of pointers. When the
    221 object is converted to a trait reference, the pointers to its vtables are
    222 stored along side it.
    223 
    224 This allows for compatibility with existing structures (such as those imported
    225 from C) and is the default storage method unless a different one is given.
    226 
    227 The other is by inlining the vtable pointer as "intrusive vtables". This adds
    228 a field to the structure to the vtable. The trait reference then has a single
    229 pointer to this field, the vtable includes an offset to find the beginning of
    230 the structure again.
    231 
    232 This is used if you specify a vtable field in the structure. If given in the
    233 trait the vtable pointer in the trait reference can then become a single
    234 pointer to the vtable field and use that to recover the original object
    235 pointer as well as retrieve all operations.
    236 
    237 trait drawable(otype T) {
    238         vtable drawable;
    239 };
    240 
    241 struct line {
    242         vtable drawable;
    243         vec2 start;
    244         vec2 end;
    245 };
    246 
    247 This inline code allows trait references to be converted to plain pointers
    248 (although they still must be called specially). The vtable field may just be
    249 an opaque block of memory or it may allow user access to the vtable. If so
    250 then there should be some way to retrieve the type of the vtable, which will be
    251 autogenerated and often unique.
    252 
    253 
    254 Keyword Usage:
    255 
    256 It may be desirable to add fewer new keywords than discussed in this proposal.
    257 It is possible that "virtual" could replace both "vtable" above with
    258 unambiguous contextual meaning. However, for purposes of clarity in the design
    259 discussion it is beneficial to keep the keywords for separate concepts distinct.
    260 
    261 
    262 Trait References and Operations:
    263 
    264 sizeof(drawable) will return the size of the trait object itself. However :
    265 
    266 line a_line;
    267 drawable widget = a_line;
    268 sizeof(widget);
    269 
    270 Will instead return the sizeof the underlying object, although the trait must
    271 require that its implementation is sized for there to be a meaningful value
    272 to return. You may also get the size of the trait reference with
    273 
    274 sizeof(&widget);
    275 
    276 Calling free on a trait reference will free the memory for the object. It will
    277 leave the vtables alone, as those are (always?) statically allocated.
  • doc/refrat/Makefile

    r0720e049 r3d4b23fa  
    99SOURCES = ${addsuffix .tex, \
    1010refrat \
    11 keywords \
    12 operidents \
    1311}
    1412
  • doc/refrat/refrat.tex

    r0720e049 r3d4b23fa  
    1111%% Created On       : Wed Apr  6 14:52:25 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Sun Aug  6 10:25:31 2017
    14 %% Update Count     : 105
     13%% Last Modified On : Fri Jun  2 10:43:14 2017
     14%% Update Count     : 83
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
    1717% requires tex packages: texlive-base texlive-latex-base tex-common texlive-humanities texlive-latex-extra texlive-fonts-recommended
    1818
    19 \documentclass[openright,twoside,11pt]{report}
     19\documentclass[openright,twoside]{report}
    2020
    2121%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     
    3737\usepackage{mathptmx}                                   % better math font with "times"
    3838\usepackage[usenames]{color}
    39 \input{common}                                          % common CFA document macros
     39\usepackage[pagewise]{lineno}
     40\renewcommand{\linenumberfont}{\scriptsize\sffamily}
     41\input{common}                                          % bespoke macros used in the document
    4042\usepackage[dvips,plainpages=false,pdfpagelabels,pdfpagemode=UseNone,colorlinks=true,pagebackref=true,linkcolor=blue,citecolor=blue,urlcolor=blue,pagebackref=true,breaklinks=true]{hyperref}
    4143\usepackage{breakurl}
    4244\renewcommand{\UrlFont}{\small\sf}
    4345
    44 \usepackage[pagewise]{lineno}
    45 \renewcommand{\linenumberfont}{\scriptsize\sffamily}
    46 \usepackage[firstpage]{draftwatermark}
    47 \SetWatermarkLightness{0.9}
    48 
    49 % Default underscore is too low and wide. Cannot use lstlisting "literate" as replacing underscore
    50 % removes it as a variable-name character so keywords in variables are highlighted. MUST APPEAR
    51 % AFTER HYPERREF.
    52 \renewcommand{\textunderscore}{\leavevmode\makebox[1.2ex][c]{\rule{1ex}{0.075ex}}}
    53 
    5446\setlength{\topmargin}{-0.45in}                                                 % move running title into header
    5547\setlength{\headsep}{0.25in}
     
    5850
    5951\CFAStyle                                                                                               % use default CFA format-style
    60 \lstnewenvironment{C++}[1][]                            % use C++ style
    61 {\lstset{language=C++,moredelim=**[is][\protect\color{red}]{®}{®}#1}}
    62 {}
    6352
    6453% inline code ©...© (copyright symbol) emacs: C-q M-)
     
    9887
    9988\date{
    100 \today
     89DRAFT \\ \today
    10190}% date
    10291
     
    123112
    124113\clearpage
    125 \thispagestyle{plain}
    126114\pdfbookmark[1]{Contents}{section}
    127115\tableofcontents
    128116
    129117\clearpage
    130 \thispagestyle{plain}
    131118\pagenumbering{arabic}
    132119
     
    430417
    431418\begin{syntax}
    432 \lhs{keyword} one of
    433 \rhs \dots
    434 \rhs \input{keywords}
     419\oldlhs{keyword}
     420\rhs ©forall©
     421\rhs ©lvalue©
     422\rhs ©trait©
     423\rhs ©dtype©
     424\rhs ©ftype©
     425\rhs ©otype©
    435426\end{syntax}
    436427
     
    478469
    479470\begin{table}[hbt]
    480 \centering
    481 \input{operidents}
     471\hfil
     472\begin{tabular}[t]{ll}
     473%identifier & operation \\ \hline
     474©?[?]© & subscripting \impl{?[?]}\\
     475©?()© & function call \impl{?()}\\
     476©?++© & postfix increment \impl{?++}\\
     477©?--© & postfix decrement \impl{?--}\\
     478©++?© & prefix increment \impl{++?}\\
     479©--?© & prefix decrement \impl{--?}\\
     480©*?© & dereference \impl{*?}\\
     481©+?© & unary plus \impl{+?}\\
     482©-?© & arithmetic negation \impl{-?}\\
     483©~?© & bitwise negation \impl{~?}\\
     484©!?© & logical complement \impl{"!?}\\
     485©?*?© & multiplication \impl{?*?}\\
     486©?/?© & division \impl{?/?}\\
     487\end{tabular}\hfil
     488\begin{tabular}[t]{ll}
     489%identifier & operation \\ \hline
     490©?%?© & remainder \impl{?%?}\\
     491©?+?© & addition \impl{?+?}\\
     492©?-?© & subtraction \impl{?-?}\\
     493©?<<?© & left shift \impl{?<<?}\\
     494©?>>?© & right shift \impl{?>>?}\\
     495©?<?© & less than \impl{?<?}\\
     496©?<=?© & less than or equal \impl{?<=?}\\
     497©?>=?© & greater than or equal \impl{?>=?}\\
     498©?>?© & greater than \impl{?>?}\\
     499©?==?© & equality \impl{?==?}\\
     500©?!=?© & inequality \impl{?"!=?}\\
     501©?&?© & bitwise AND \impl{?&?}\\
     502\end{tabular}\hfil
     503\begin{tabular}[t]{ll}
     504%identifier & operation \\ \hline
     505©?^?© & exclusive OR \impl{?^?}\\
     506©?|?© & inclusive OR \impl{?"|?}\\
     507©?=?© & simple assignment \impl{?=?}\\
     508©?*=?© & multiplication assignment \impl{?*=?}\\
     509©?/=?© & division assignment \impl{?/=?}\\
     510©?%=?© & remainder assignment \impl{?%=?}\\
     511©?+=?© & addition assignment \impl{?+=?}\\
     512©?-=?© & subtraction assignment \impl{?-=?}\\
     513©?<<=?© & left-shift assignment \impl{?<<=?}\\
     514©?>>=?© & right-shift assignment \impl{?>>=?}\\
     515©?&=?© & bitwise AND assignment \impl{?&=?}\\
     516©?^=?© & exclusive OR assignment \impl{?^=?}\\
     517©?|=?© & inclusive OR assignment \impl{?"|=?}\\
     518\end{tabular}
     519\hfil
    482520\caption{Operator Identifiers}
    483521\label{opids}
  • doc/rob_thesis/Makefile

    r0720e049 r3d4b23fa  
    1 TeXLIB = .:../LaTeXmacros:../bibliography/:
     1## Define the appropriate configuration variables.
     2
     3TeXLIB = .:../LaTeXmacros:../LaTeXmacros/listings:../LaTeXmacros/enumitem:../bibliography/:
    24LaTeX  = TEXINPUTS=${TeXLIB} && export TEXINPUTS && pdflatex -halt-on-error
    35BibTeX = BIBINPUTS=${TeXLIB} && export BIBINPUTS && bibtex
    46
    5 all : thesis.pdf
     7## Define the text source files.
    68
    7 thesis.pdf : Makefile ../LaTeXmacros/common.tex cfa-format.tex thesis.tex intro.tex ctordtor.tex tuples.tex variadic.tex conclusions.tex
    8         ${LaTeX} thesis
    9         ${BibTeX} thesis
    10         ${LaTeX} thesis
    11         ${LaTeX} thesis
    12         pdf2ps thesis.pdf thesis.ps
     9# SOURCES = ${addsuffix .tex, \
     10# thesis \
     11# }
    1312
    14 clean :
     13# FIGURES = ${addsuffix .tex, \
     14# }
     15
     16# PICTURES = ${addsuffix .pstex, \
     17# }
     18
     19# PROGRAMS = ${addsuffix .tex, \
     20# }
     21
     22# GRAPHS = ${addsuffix .tex, \
     23# }
     24
     25# ## Define the documents that need to be made.
     26
     27# DOCUMENT = thesis.pdf
     28
     29# Directives #
     30
     31# all : ${DOCUMENT}
     32
     33# clean :
     34#       rm -f *.bbl *.aux *.dvi *.idx *.ilg *.ind *.brf *.out *.log *.toc *.blg *.pstex_t *.cf \
     35#               ${FIGURES} ${PICTURES} ${PROGRAMS} ${GRAPHS} ${basename ${DOCUMENT}}.ps ${DOCUMENT}
     36
     37# File Dependencies #
     38
     39# ${DOCUMENT} : ${basename ${DOCUMENT}}.ps
     40#       ps2pdf $<
     41
     42# ${basename ${DOCUMENT}}.ps : ${basename ${DOCUMENT}}.dvi
     43#       dvips $< -o $@
     44
     45# ${basename ${DOCUMENT}}.dvi : Makefile ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} ${basename ${DOCUMENT}}.tex \
     46#               ../LaTeXmacros/common.tex ../LaTeXmacros/indexstyle ../bibliography/cfa.bib
     47#       # Conditionally create an empty *.ind (index) file for inclusion until makeindex is run.
     48#       if [ ! -r ${basename $@}.ind ] ; then touch ${basename $@}.ind ; fi
     49#       # Must have *.aux file containing citations for bibtex
     50#       if [ ! -r ${basename $@}.aux ] ; then ${LaTeX} ${basename $@}.tex ; fi
     51#       -${BibTeX} ${basename $@}
     52#       # Some citations reference others so run steps again to resolve these citations
     53#       ${LaTeX} ${basename $@}.tex
     54#       -${BibTeX} ${basename $@}
     55#       # Make index from *.aux entries and input index at end of document
     56#       makeindex -s ../LaTeXmacros/indexstyle ${basename $@}.idx
     57#       ${LaTeX} ${basename $@}.tex
     58#       # Run again to get index title into table of contents
     59#       ${LaTeX} ${basename $@}.tex
     60
     61# predefined :
     62#       sed -f predefined.sed ${basename ${DOCUMENT}}.tex > ${basename $@}.cf
     63
     64# ## Define the default recipes.
     65
     66# %.tex : %.fig
     67#       fig2dev -L eepic $< > $@
     68
     69# %.ps : %.fig
     70#       fig2dev -L ps $< > $@
     71
     72# %.pstex : %.fig
     73#       fig2dev -L pstex $< > $@
     74#       fig2dev -L pstex_t -p $@ $< > $@_t
     75
     76
     77all:
     78        $(LaTeX) thesis
     79        $(BibTeX) thesis
     80        $(LaTeX) thesis
     81        $(LaTeX) thesis
     82
     83clean:
    1584        rm -f *.aux *.bbl *.blg *.lof *.log *.lot *.out *.toc
    1685
    17 spotless : clean
    18         rm -f thesis.pdf thesis.ps
     86splotless: clean
     87        rm -f thesis.pdf
  • doc/rob_thesis/thesis.tex

    r0720e049 r3d4b23fa  
    135135    pdfpagelabels=true,     % adds page number as label in Acrobat's page count
    136136    bookmarks=true,         % show bookmarks bar?
    137     unicode=false,          % non-Latin characters in Acrobat's bookmarks
    138     pdftoolbar=true,        % show Acrobat's toolbar?
    139     pdfmenubar=true,        % show Acrobat's menu?
     137    unicode=false,          % non-Latin characters in Acrobats bookmarks
     138    pdftoolbar=true,        % show Acrobats toolbar?
     139    pdfmenubar=true,        % show Acrobats menu?
    140140    pdffitwindow=false,     % window fit to page when opened
    141141    pdfstartview={FitH},    % fits the width of the page to the window
  • doc/user/EHMHierarchy.fig

    r0720e049 r3d4b23fa  
    1 #FIG 3.2  Produced by xfig version 3.2.5c
     1#FIG 3.2  Produced by xfig version 3.2.5b
    22Landscape
    33Center
     
    19192 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
    2020        1 1 1.00 60.00 90.00
    21          1950 1425 2925 1200
     21         1950 1425 3000 1200
    22222 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
    2323        1 1 1.00 60.00 90.00
     
    2929        1 1 1.00 60.00 90.00
    3030         4950 1950 4950 1725
    31 4 1 0 50 -1 0 13 0.0000 2 135 225 1950 1650 IO\001
    32 4 1 0 50 -1 0 13 0.0000 2 135 915 4950 1650 Arithmetic\001
    33 4 1 0 50 -1 0 13 0.0000 2 150 330 1350 2100 File\001
    34 4 1 0 50 -1 0 13 0.0000 2 135 735 2550 2100 Network\001
    35 4 1 0 50 -1 0 13 0.0000 2 180 1215 3750 2100 DivideByZero\001
    36 4 1 0 50 -1 0 13 0.0000 2 150 810 4950 2100 Overflow\001
    37 4 1 0 50 -1 0 13 0.0000 2 150 915 6000 2100 Underflow\001
    38 4 1 0 50 -1 0 13 0.0000 2 180 855 3450 1200 Exception\001
     314 1 0 100 0 0 12 0.0000 0 135 195 1950 1650 IO\001
     324 1 0 100 0 0 12 0.0000 0 135 870 4950 1650 Arithmetic\001
     334 1 0 100 0 0 12 0.0000 0 135 315 1350 2100 File\001
     344 1 0 100 0 0 12 0.0000 0 135 690 2550 2100 Network\001
     354 1 0 100 0 0 12 0.0000 0 180 1170 3750 2100 DivideByZero\001
     364 1 0 100 0 0 12 0.0000 0 135 750 4950 2100 Overflow\001
     374 1 0 100 0 0 12 0.0000 0 135 855 6000 2100 Underflow\001
     384 1 0 100 0 0 12 0.0000 0 180 840 3450 1200 Exception\001
  • doc/user/Makefile

    r0720e049 r3d4b23fa  
    99SOURCES = ${addsuffix .tex, \
    1010user \
    11 ../refrat/keywords \
    12 ../refrat/operidents \
    1311}
    1412
  • doc/user/user.tex

    r0720e049 r3d4b23fa  
    1111%% Created On       : Wed Apr  6 14:53:29 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Sun Aug  6 10:24:21 2017
    14 %% Update Count     : 3036
     13%% Last Modified On : Thu Jul 13 11:44:57 2017
     14%% Update Count     : 2690
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    3737\usepackage{mathptmx}                                   % better math font with "times"
    3838\usepackage[usenames]{color}
     39\usepackage[pagewise]{lineno}
     40\renewcommand{\linenumberfont}{\scriptsize\sffamily}
    3941\input{common}                                          % common CFA document macros
    4042\usepackage[dvips,plainpages=false,pdfpagelabels,pdfpagemode=UseNone,colorlinks=true,pagebackref=true,linkcolor=blue,citecolor=blue,urlcolor=blue,pagebackref=true,breaklinks=true]{hyperref}
     
    4244\renewcommand{\UrlFont}{\small\sf}
    4345
    44 \usepackage[pagewise]{lineno}
    45 \renewcommand{\linenumberfont}{\scriptsize\sffamily}
    46 \usepackage[firstpage]{draftwatermark}
    47 \SetWatermarkLightness{0.9}
    48 
    4946% Default underscore is too low and wide. Cannot use lstlisting "literate" as replacing underscore
    5047% removes it as a variable-name character so keywords in variables are highlighted. MUST APPEAR
    5148% AFTER HYPERREF.
     49\renewcommand{\_}{\leavevmode\makebox[1.2ex][c]{\rule{1ex}{0.075ex}}}
    5250\renewcommand{\textunderscore}{\leavevmode\makebox[1.2ex][c]{\rule{1ex}{0.075ex}}}
    5351
     
    5856
    5957\CFAStyle                                                                                               % use default CFA format-style
    60 \lstnewenvironment{C++}[1][]                            % use C++ style
     58
     59\lstnewenvironment{C++}[1][]
    6160{\lstset{language=C++,moredelim=**[is][\protect\color{red}]{®}{®}#1}}
    6261{}
     
    7978\newcommand{\B}[1]{{\Textbf[blue]{#1}}}
    8079\newcommand{\G}[1]{{\Textbf[OliveGreen]{#1}}}
    81 \newcommand{\KWC}{K-W C\xspace}
    8280
    8381\newsavebox{\LstBox}
     
    107105
    108106\date{
    109 \today
     107DRAFT \\ \today
    110108}% date
    111109
     
    199197This document is a programmer reference-manual for the \CFA programming language.
    200198The manual covers the core features of the language and runtime-system, with simple examples illustrating syntax and semantics of each feature.
    201 The manual does not teach programming, \ie how to combine the new constructs to build complex programs.
     199The manual does not teach programming, i.e., how to combine the new constructs to build complex programs.
    202200A reader should already have an intermediate knowledge of control flow, data structures, and concurrency issues to understand the ideas presented, as well as some experience programming in C/\CC.
    203201Implementers should refer to the \CFA Programming Language Specification for details about the language syntax and semantics.
     
    249247\section{History}
    250248
    251 The \CFA project started with \Index*{Dave Till}\index{Till, Dave}'s \Index*{K-W C}~\cite{Buhr94a,Till89}, which extended C with new declaration syntax, multiple return values from routines, and advanced assignment capabilities using the notion of tuples.
     249The \CFA project started with \Index*{K-W C}~\cite{Buhr94a,Till89}, which extended C with new declaration syntax, multiple return values from routines, and advanced assignment capabilities using the notion of tuples.
    252250(See~\cite{Werther96} for similar work in \Index*[C++]{\CC{}}.)
    253 The first \CFA implementation of these extensions was by \Index*{Rodolfo Esteves}\index{Esteves, Rodolfo}~\cite{Esteves04}.
    254 
    255 The signature feature of \CFA is \emph{\Index{overload}able} \Index{parametric-polymorphic} functions~\cite{forceone:impl,Cormack90,Duggan96} with functions generalized using a ©forall© clause (giving the language its name):
     251The first \CFA implementation of these extensions was by Esteves~\cite{Esteves04}.
     252
     253The signature feature of \CFA is \Index{overload}able \Index{parametric-polymorphic} functions~\cite{forceone:impl,Cormack90,Duggan96} with functions generalized using a ©forall© clause (giving the language its name):
    256254\begin{lstlisting}
    257255®forall( otype T )® T identity( T val ) { return val; }
     
    259257\end{lstlisting}
    260258% extending the C type system with parametric polymorphism and overloading, as opposed to the \Index*[C++]{\CC{}} approach of object-oriented extensions.
    261 \CFA{}\hspace{1pt}'s polymorphism was originally formalized by \Index*{Glen Ditchfield}\index{Ditchfield, Glen}~\cite{Ditchfield92}, and first implemented by \Index*{Richard Bilson}\index{Bilson, Richard}~\cite{Bilson03}.
     259\CFA{}\hspace{1pt}'s polymorphism was originally formalized by Ditchfiled~\cite{Ditchfield92}, and first implemented by Bilson~\cite{Bilson03}.
    262260However, at that time, there was little interesting in extending C, so work did not continue.
    263261As the saying goes, ``\Index*{What goes around, comes around.}'', and there is now renewed interest in the C programming language because of legacy code-bases, so the \CFA project has been restarted.
     
    272270Language developers often state that adequate \Index{library support} takes more work than designing and implementing the language itself.
    273271Fortunately, \CFA, like \Index*[C++]{\CC{}}, starts with immediate access to all exiting C libraries, and in many cases, can easily wrap library routines with simpler and safer interfaces, at very low cost.
    274 Hence, \CFA begins by leveraging the large repository of C libraries, and than allows programmers to incrementally augment their C programs with modern \Index{backward-compatible} features.
     272Hence, \CFA begins by leveraging the large repository of C libraries at little cost.
    275273
    276274\begin{comment}
     
    320318\begin{cfa}
    321319char abs( char );
    322 ®extern "C" {® int abs( int ); ®}®              §\C{// use default C routine for int}§
     320®extern "C" {®
     321int abs( int );                                                 §\C{// use default C routine for int}§
     322®}® // extern "C"
    323323long int abs( long int );
    324324long long int abs( long long int );
     
    335335Hence, there is the same need as in \CC, to know if a name is a C or \CFA name, so it can be correctly formed.
    336336There is no way around this problem, other than C's approach of creating unique names for each pairing of operation and type.
    337 
    338337This example strongly illustrates a core idea in \CFA: \emph{the \Index{power of a name}}.
    339338The name ``©abs©'' evokes the notion of absolute value, and many mathematical types provide the notion of absolute value.
     
    344343\section[Compiling a CFA Program]{Compiling a \CFA Program}
    345344
    346 The command ©cfa© is used to compile a \CFA program and is based on the \Index{GNU} \Indexc{gcc} command, \eg:
    347 \begin{cfa}
    348 cfa§\indexc{cfa}\index{compilation!cfa@©cfa©}§ [ gcc-options ] [ C/§\CFA{}§ source-files ] [ assembler/loader files ]
     345The command ©cfa© is used to compile \CFA program(s), and is based on the GNU \Indexc{gcc} command, \eg:
     346\begin{cfa}
     347cfa§\indexc{cfa}\index{compilation!cfa@©cfa©}§ [ gcc-options ] C/§\CFA{}§-files [ assembler/loader-files ]
    349348\end{cfa}
    350349\CFA programs having the following ©gcc© flags turned on:
     
    354353The 1999 C standard plus GNU extensions.
    355354\item
    356 \Indexc[deletekeywords=inline]{-fgnu89-inline}\index{compilation option!-fgnu89-inline@{\lstinline[deletekeywords=inline]$-fgnu89-inline$}}
     355{\lstset{deletekeywords={inline}}
     356\Indexc{-fgnu89-inline}\index{compilation option!-fgnu89-inline@{©-fgnu89-inline©}}
    357357Use the traditional GNU semantics for inline routines in C99 mode, which allows inline routines in header files.
     358}%
    358359\end{description}
    359360The following new \CFA options are available:
     
    362363\Indexc{-CFA}\index{compilation option!-CFA@©-CFA©}
    363364Only the C preprocessor and the \CFA translator steps are performed and the transformed program is written to standard output, which makes it possible to examine the code generated by the \CFA translator.
    364 The generated code starts with the standard \CFA \Index{prelude}.
     365The generated code started with the standard \CFA prelude.
    365366
    366367\item
     
    374375\Indexc{-nodebug}\index{compilation option!-nodebug@©-nodebug©}
    375376The program is linked with the non-debugging version of the runtime system, so the execution of the program is faster.
    376 \Emph{However, no runtime checks or ©assert©s are performed so errors usually result in abnormal program behaviour or termination.}
     377\Emph{However, no runtime checks or ©assert©s are performed so errors usually result in abnormal program termination.}
    377378
    378379\item
     
    394395\textbf{This option is the default.}
    395396
    396 \begin{comment}
    397397\item
    398398\Indexc{-no-include-stdhdr}\index{compilation option!-no-include-stdhdr@©-no-include-stdhdr©}
    399399Do not supply ©extern "C"© wrappers for \Celeven standard include files (see~\VRef{s:StandardHeaders}).
    400400\textbf{This option is \emph{not} the default.}
    401 \end{comment}
    402401\end{description}
    403402
     
    420419\item
    421420\Indexc{__CFA__}\index{preprocessor variables!__CFA__@©__CFA__©},
    422 \Indexc{__CFORALL__}\index{preprocessor variables!__CFORALL__@©__CFORALL__©}, and
     421\Indexc{__CFORALL__}\index{preprocessor variables!__CFORALL__@©__CFORALL__©} and
    423422\Indexc{__cforall}\index{preprocessor variables!__cforall@©__cforall©}
    424423are always available during preprocessing and have no value.
     
    473472\label{s:BackquoteIdentifiers}
    474473
    475 \CFA introduces several new keywords (see \VRef{s:CFAKeywords}) that can clash with existing C variable-names in legacy code.
     474\CFA introduces in new keywords (see \VRef{s:CFAKeywords}) that can clash with existing C variable-names in legacy code.
    476475Keyword clashes are accommodated by syntactic transformations using the \CFA backquote escape-mechanism:
    477476\begin{cfa}
     
    479478double ®`®forall®`® = 3.5;
    480479\end{cfa}
    481 
    482480Existing C programs with keyword clashes can be converted by enclosing keyword identifiers in backquotes, and eventually the identifier name can be changed to a non-keyword name.
    483 \VRef[Figure]{f:HeaderFileInterposition} shows how clashes in existing C header-files (see~\VRef{s:StandardHeaders}) can be handled using preprocessor \newterm{interposition}: ©#include_next© and ©-I filename©.
    484 Several common C header-files with keyword clashes are fixed in the standard \CFA header-library, so there is a seamless programming-experience.
     481\VRef[Figure]{f:InterpositionHeaderFile} shows how clashes in C header files (see~\VRef{s:StandardHeaders}) can be handled using preprocessor \newterm{interposition}: ©#include_next© and ©-I filename©:
    485482
    486483\begin{figure}
    487484\begin{cfa}
    488 // include file uses the CFA keyword "with".
    489 #if ! defined( with )                   §\C{// nesting ?}§
    490 #define with ®`®with®`®                 §\C{// make keyword an identifier}§
     485// include file uses the CFA keyword "otype".
     486#if ! defined( otype )                  §\C{// nesting ?}§
     487#define otype ®`®otype®`®               §\C{// make keyword an identifier}§
    491488#define __CFA_BFD_H__
    492 #endif
    493 
    494 ®#include_next <bfdlink.h>              §\C{// must have internal check for multiple expansion}§
    495 ®
    496 #if defined( with ) && defined( __CFA_BFD_H__ ) §\C{// reset only if set}§
    497 #undef with
     489#endif // ! otype
     490
     491#®include_next® <bfd.h>                 §\C{// must have internal check for multiple expansion}§
     492
     493#if defined( otype ) && defined( __CFA_BFD_H__ )        §\C{// reset only if set}§
     494#undef otype
    498495#undef __CFA_BFD_H__
    499 #endif
    500 \end{cfa}
    501 \caption{Header-File Interposition}
    502 \label{f:HeaderFileInterposition}
     496#endif // otype && __CFA_BFD_H__
     497\end{cfa}
     498\caption{Interposition of Header File}
     499\label{f:InterpositionHeaderFile}
    503500\end{figure}
    504501
     
    508505While C provides ©continue© and ©break© statements for altering control flow, both are restricted to one level of nesting for a particular control structure.
    509506Unfortunately, this restriction forces programmers to use \Indexc{goto} to achieve the equivalent control-flow for more than one level of nesting.
    510 To prevent having to switch to the ©goto©, \CFA extends the \Indexc{continue}\index{continue@\lstinline $continue$!labelled}\index{labelled!continue@©continue©} and \Indexc{break}\index{break@\lstinline $break$!labelled}\index{labelled!break@©break©} with a target label to support static multi-level exit\index{multi-level exit}\index{static multi-level exit}~\cite{Buhr85}, as in Java.
     507To prevent having to switch to the ©goto©, \CFA extends the \Indexc{continue}\index{continue@\lstinline $continue$!labelled}\index{labelled!continue@©continue©} and \Indexc{break}\index{break@\lstinline $break$!labelled}\index{labelled!break@©break©} with a target label to support static multi-level exit\index{multi-level exit}\index{static multi-level exit}~\cite{Buhr85}.
    511508For both ©continue© and ©break©, the target label must be directly associated with a ©for©, ©while© or ©do© statement;
    512509for ©break©, the target label can also be associated with a ©switch©, ©if© or compound (©{}©) statement.
    513 \VRef[Figure]{f:MultiLevelExit} shows ©continue© and ©break© indicating the specific control structure, and the corresponding C program using only ©goto© and labels.
    514 The innermost loop has 7 exit points, which cause continuation or termination of one or more of the 7 \Index{nested control-structure}s.
     510\VRef[Figure]{f:MultiLevelResumeTermination} shows the labelled ©continue© and ©break©, specifying which control structure is the target for exit, and the corresponding C program using only ©goto©.
     511The innermost loop has 7 exit points, which cause resumption or termination of one or more of the 7 \Index{nested control-structure}s.
     512Java supports both labelled ©continue© and ©break© statements.
    515513
    516514\begin{figure}
    517 \begin{tabular}{@{\hspace{\parindentlnth}}l@{\hspace{\parindentlnth}}l@{\hspace{\parindentlnth}}l@{}}
    518 \multicolumn{1}{@{\hspace{\parindentlnth}}c@{\hspace{\parindentlnth}}}{\textbf{\CFA}}   & \multicolumn{1}{@{\hspace{\parindentlnth}}c}{\textbf{C}}      \\
     515\begin{tabular}{@{\hspace{\parindentlnth}}l@{\hspace{1.5em}}l@{}}
     516\multicolumn{1}{c@{\hspace{1.5em}}}{\textbf{\CFA}}      & \multicolumn{1}{c}{\textbf{C}}        \\
    519517\begin{cfa}
    520518®LC:® {
     
    525523                        ®LF:® for ( ... ) {
    526524                                ®LW:® while ( ... ) {
    527                                         ... break ®LC®; ...
    528                                         ... break ®LS®; ...
    529                                         ... break ®LIF®; ...
    530                                         ... continue ®LF;® ...
    531                                         ... break ®LF®; ...
    532                                         ... continue ®LW®; ...
    533                                         ... break ®LW®; ...
     525                                        ... break ®LC®; ...                     // terminate compound
     526                                        ... break ®LS®; ...                     // terminate switch
     527                                        ... break ®LIF®; ...                    // terminate if
     528                                        ... continue ®LF;® ...   // resume loop
     529                                        ... break ®LF®; ...                     // terminate loop
     530                                        ... continue ®LW®; ...   // resume loop
     531                                        ... break ®LW®; ...               // terminate loop
    534532                                } // while
    535533                        } // for
    536534                } else {
    537                         ... break ®LIF®; ...
     535                        ... break ®LIF®; ...                                     // terminate if
    538536                } // if
    539537        } // switch
     
    564562} ®LC:® ;
    565563\end{cfa}
    566 &
    567 \begin{cfa}
    568 
    569 
    570 
    571 
    572 
    573 
    574 
    575 // terminate compound
    576 // terminate switch
    577 // terminate if
    578 // continue loop
    579 // terminate loop
    580 // continue loop
    581 // terminate loop
    582 
    583 
    584 
    585 // terminate if
    586 
    587 
    588 
    589 \end{cfa}
    590564\end{tabular}
    591 \caption{Multi-level Exit}
    592 \label{f:MultiLevelExit}
     565\caption{Multi-level Resume/Termination}
     566\label{f:MultiLevelResumeTermination}
    593567\end{figure}
     568
     569\begin{comment}
     570int main() {
     571  LC: {
     572          LS: switch ( 1 ) {
     573                  case 3:
     574                  LIF: if ( 1 ) {
     575                          LF: for ( ;; ) {
     576                                  LW: while ( 1 ) {
     577                                                break LC;                       // terminate compound
     578                                                break LS;                       // terminate switch
     579                                                break LIF;                      // terminate if
     580                                                continue LF;     // resume loop
     581                                                break LF;                       // terminate loop
     582                                                continue LW;     // resume loop
     583                                                break LW;                 // terminate loop
     584                                        } // while
     585                                } // for
     586                        } else {
     587                                break LIF;                                       // terminate if
     588                        } // if
     589                } // switch
     590        } // compound
     591        {
     592                switch ( 1 ) {
     593                  case 3:
     594                        if ( 1 ) {
     595                                for ( ;; ) {
     596                                        while ( 1 ) {
     597                                                goto LCx;
     598                                                goto LSx;
     599                                                goto LIF;
     600                                                goto LFC;
     601                                                goto LFB;
     602                                                goto LWC;
     603                                                goto LWB;
     604                                          LWC: ; } LWB: ;
     605                                  LFC: ; } LFB: ;
     606                        } else {
     607                                goto LIF;
     608                        } L3: ;
     609                } LSx: ;
     610        } LCx: ;
     611}
     612
     613// Local Variables: //
     614// tab-width: 4 //
     615// End: //
     616\end{comment}
     617
    594618
    595619Both labelled ©continue© and ©break© are a ©goto©\index{goto@\lstinline $goto$!restricted} restricted in the following ways:
     
    600624\item
    601625They cannot branch into a control structure.
    602 This restriction prevents missing declarations and/or initializations at the start of a control structure resulting in undefined behaviour.
     626This restriction prevents missing initialization at the start of a control structure resulting in undefined behaviour.
    603627\end{itemize}
    604628The advantage of the labelled ©continue©/©break© is allowing static multi-level exits without having to use the ©goto© statement, and tying control flow to the target control structure rather than an arbitrary point in a program.
    605 Furthermore, the location of the label at the \emph{beginning} of the target control structure informs the reader (\Index{eye candy}) that complex control-flow is occurring in the body of the control structure.
     629Furthermore, the location of the label at the \emph{beginning} of the target control structure informs the reader that complex control-flow is occurring in the body of the control structure.
    606630With ©goto©, the label is at the end of the control structure, which fails to convey this important clue early enough to the reader.
    607631Finally, using an explicit target for the transfer instead of an implicit target allows new constructs to be added or removed without affecting existing constructs.
     
    695719The problem with this usage is branching into control structures, which is known to cause both comprehension and technical difficulties.
    696720The comprehension problem occurs from the inability to determine how control reaches a particular point due to the number of branches leading to it.
    697 The technical problem results from the inability to ensure declaration and initialization of variables when blocks are not entered at the beginning.
    698 There are no positive arguments for this kind of control flow, and therefore, there is a strong impetus to eliminate it.
     721The technical problem results from the inability to ensure allocation and initialization of variables when blocks are not entered at the beginning.
     722Often transferring into a block can bypass variable declaration and/or its initialization, which results in subsequent errors.
     723There are virtually no positive arguments for this kind of control flow, and therefore, there is a strong impetus to eliminate it.
    699724Nevertheless, C does have an idiom where this capability is used, known as ``\Index*{Duff's device}''~\cite{Duff83}:
    700725\begin{cfa}
     
    896921class C {
    897922        int i, j;
    898         int mem() {                                     §\C{\color{red}// implicit "this" parameter}§
    899                 i = 1;                                  §\C{\color{red}// this->i}§
    900                 j = 2;                                  §\C{\color{red}// this->j}§
    901         }
     923        int mem() {              ®// implicit "this" parameter
     924                i = 1;          ®// this->i
     925®               j = 3;          ®// this->j
     926®       }
    902927}
    903928\end{C++}
    904929Since CFA is non-object-oriented, the equivalent object-oriented program looks like:
    905930\begin{cfa}
    906 struct S { int i, j; };
    907 int mem( S &®this® ) {                  §\C{// explicit "this" parameter}§
    908         ®this.®i = 1;                           §\C{// "this" is not elided}§
     931struct C {
     932        int i, j;
     933};
     934int mem( C &this ) {    // explicit "this" parameter
     935        ®this.®i = 1;                     // "this" is not elided
    909936        ®this.®j = 2;
    910937}
    911938\end{cfa}
    912939but it is cumbersome having to write "©this.©" many times in a member.
    913 
    914 \CFA provides a ©with© clause/statement (see Pascal~\cite[\S~4.F]{Pascal}) to elided the "©this.©" by opening a scope containing field identifiers, changing the qualified fields into variables and giving an opportunity for optimizing qualified references.
    915 \begin{cfa}
    916 int mem( S &this ) ®with this® { §\C{// with clause}§
    917         i = 1;                                          §\C{\color{red}// this->i}§
    918         j = 2;                                          §\C{\color{red}// this->j}§
    919 }
     940\CFA provides a ©with© clause/statement to elided the "©this.©".
     941\begin{cfa}
     942int mem( C &this ) ®with this® {
     943        i = 1;                  ®// this.i
     944®       j = 2;                  ®// this.j
     945®}
    920946\end{cfa}
    921947which extends to multiple routine parameters:
    922948\begin{cfa}
    923 struct T { double m, n; };
    924 int mem2( S &this1, T &this2 ) ®with this1, this2® {
     949struct D {
     950        double m, n;
     951};
     952int mem2( C &this1, D &this2 ) ®with this1, this2® {
    925953        i = 1; j = 2;
    926954        m = 1.0; n = 2.0;
    927955}
    928956\end{cfa}
     957The ©with© clause/statement comes from Pascal~\cite[\S~4.F]{Pascal}.
    929958
    930959The statement form is used within a block:
     
    933962        struct S1 { ... } s1;
    934963        struct S2 { ... } s2;
    935         ®with s1® {                     // with statement
     964        ®with s1® {
    936965                // access fields of s1 without qualification
    937966                ®with s2® {  // nesting
    938                         // access fields of s1 and s2 without qualification
     967                        // access fields of s2 without qualification
    939968                }
    940969        }
     
    945974\end{cfa}
    946975
    947 When opening multiple structures, fields with the same name and type are ambiguous and must be fully qualified.
    948 For fields with the same name but different type, context/cast can be used to disambiguate.
    949 \begin{cfa}
    950 struct S { int i; int j; double m; } a, c;
    951 struct T { int i; int k; int m } b, c;
     976Names clashes when opening multiple structures are ambiguous.
     977\begin{cfa}
     978struct A { int i; int j; } a, c;
     979struct B { int i; int k; } b, c;
    952980®with a, b® {
    953         j + k;                                          §\C{// unambiguous, unique names define unique types}§
    954         i;                                                      §\C{// ambiguous, same name and type}§
    955         a.i + b.i;                                      §\C{// unambiguous, qualification defines unique names}§
    956         m;                                                      §\C{// ambiguous, same name and no context to define unique type}§
    957         m = 5.0;                                        §\C{// unambiguous, same name and context defines unique type}§
    958         m = 1;                                          §\C{// unambiguous, same name and context defines unique type}§
    959 }
    960 ®with c® { ... }                                §\C{// ambiguous, same name and no context}§
    961 ®with (S)c® { ... }                             §\C{// unambiguous, same name and cast defines unique type}§
     981        j + k;                                          §\C{// unambiguous}§
     982        i;                                                      §\C{// ambiguous}§
     983        a.i + b.i;                                      §\C{// unambiguous}§
     984}
     985®with c® {                                              §\C{// ambiguous}§
     986        // ...
     987}
    962988\end{cfa}
    963989
    964990
    965991\section{Exception Handling}
    966 \label{s:ExceptionHandling}
    967992
    968993Exception handling provides two mechanism: change of control flow from a raise to a handler, and communication from the raise to the handler.
    969 Transfer of control can be local, within a routine, or non-local, among routines.
    970 Non-local transfer can cause stack unwinding, \ie non-local routine termination, depending on the kind of raise.
    971 \begin{cfa}
    972 exception_t E {};                               §\C{// exception type}§
     994\begin{cfa}
     995exception void h( int i );
     996exception int h( int i, double d );
     997
    973998void f(...) {
    974         ... throw E{}; ...                      §\C{// termination}§
    975         ... throwResume E{}; ...        §\C{// resumption}§
    976 }
     999        ... throw h( 3 );
     1000        ... i = resume h( 3, 5.1 );
     1001}
     1002
    9771003try {
    9781004        f(...);
    979 } catch( E e : §boolean-predicate§ ) {                  §\C[8cm]{// termination handler}§
    980         // recover and continue
    981 } catchResume( E e : §boolean-predicate§ ) {    §\C{// resumption handler}\CRT§
    982         // repair and return
     1005} catch h( int w ) {
     1006        // reset
     1007} resume h( int p, double x ) {
     1008        return 17;  // recover
    9831009} finally {
    984         // always executed
    985 }
    986 \end{cfa}
    987 The kind of raise and handler match: ©throw© with ©catch© and ©throwResume© with ©catchResume©.
    988 Then the exception type must match along with any additonal predicate must be true.
    989 The ©catch© and ©catchResume© handlers may appear in any oder.
    990 However, the ©finally© clause must appear at the end of the ©try© statement.
     1010}
     1011\end{cfa}
     1012So the type raised would be the mangled name of the exception prototype and that name would be matched at the handler clauses by comparing the strings.
     1013The arguments for the call would have to be packed in a message and unpacked at handler clause and then a call made to the handler.
    9911014
    9921015
     
    11991222
    12001223
    1201 \section{Exponentiation Operator}
    1202 
    1203 C, \CC, and Java (and many other programming languages) have no exponentiation operator\index{exponentiation!operator}\index{operator!exponentiation}, \ie $x^y$, and instead use a routine, like \Indexc{pow}, to perform the exponentiation operation.
    1204 \CFA extends the basic operators with the exponentiation operator ©?\?©\index{?\\?@\lstinline$?\?$} and ©?\=?©\index{?\\=?@\lstinline$?\=?$}, as in, ©x \ y© and ©x \= y©, which means $x^y$ and $x \leftarrow x^y$.
    1205 The priority of the exponentiation operator is between the cast and multiplicative operators, so that ©w * (int)x \ (int)y * z© is parenthesized as ©((w * (((int)x) \ ((int)y))) * z)©.
    1206 
    1207 As for \Index{division}, there are exponentiation operators for integral and floating-point types, including the builtin \Index{complex} types.
    1208 Unsigned integral exponentiation\index{exponentiation!unsigned integral} is performed with repeated multiplication\footnote{The multiplication computation is optimized to $O(\log y)$.} (or shifting if the base is 2).
    1209 Signed integral exponentiation\index{exponentiation!signed integral} is performed with repeated multiplication (or shifting if the base is 2), but yields a floating-point result because $x^{-y}=1/x^y$.
    1210 Hence, it is important to designate exponent integral-constants as unsigned or signed: ©3 \ 3u© return an integral result, while ©3 \ 3© returns a floating-point result.
    1211 Floating-point exponentiation\index{exponentiation!floating point} is performed using \Index{logarithm}s\index{exponentiation!logarithm}, so the base cannot be negative.
    1212 \begin{cfa}
    1213 sout | 2 ®\® 8u | 4 ®\® 3u | -4 ®\® 3u | 4 ®\® -3 | -4 ®\® -3 | 4.0 ®\® 2.1 | (1.0f+2.0fi) ®\® (3.0f+2.0fi) | endl;
    1214 256 64 -64 0.015625 -0.015625 18.3791736799526 0.264715-1.1922i
    1215 \end{cfa}
    1216 Parenthesis are necessary for the complex constants or the expresion is parsed as ©1.0f+(2.0fi \ 3.0f)+2.0fi©.
    1217 The exponentiation operator is available for all the basic types, but for user-defined types, only the integral-computation versions are available.
    1218 For returning an integral value, the user type ©T© must define multiplication, ©*©, and one, ©1©;
    1219 for returning a floating-point value, an additional divide of type ©T© into a ©double© returning a ©double© (©double ?/?( double, T )©) is necessary for negative exponents.
    1220 
    1221 
    12221224\section{Pointer / Reference}
    12231225
     
    12281230An integer constant expression with the value 0, or such an expression cast to type ©void *©, is called a \newterm{null-pointer constant}.\footnote{
    12291231One way to conceptualize the null pointer is that no variable is placed at this address, so the null-pointer address can be used to denote an uninitialized pointer/reference object;
    1230 \ie the null pointer is guaranteed to compare unequal to a pointer to any object or routine.
    1231 In general, a value with special meaning among a set of values is called a \emph{\Index{sentinel value}}, \eg ©-1© as a return code value.}
     1232\ie the null pointer is guaranteed to compare unequal to a pointer to any object or routine.}
    12321233An address is \newterm{sound}, if it points to a valid memory location in scope, \ie within the program's execution-environment and has not been freed.
    12331234Dereferencing an \newterm{unsound} address, including the null pointer, is \Index{undefined}, often resulting in a \Index{memory fault}.
     
    12641265\hline
    12651266\begin{cfa}
    1266 lda             r1,100  // load address of x
    1267 ld               r2,(r1)          // load value of x
    1268 lda             r3,104  // load address of y
    1269 st               r2,(r3)          // store x into y
     1267lda             r1,100                  // load address of x
     1268ld               r2,(r1)                  // load value of x
     1269lda             r3,104                  // load address of y
     1270st               r2,(r3)                  // store x into y
    12701271\end{cfa}
    12711272&
    12721273\begin{cfa}
    12731274
    1274 ld              r2,(100)        // load value of x
    1275 
    1276 st              r2,(104)        // store x into y
     1275ld              r2,(100)                // load value of x
     1276
     1277st              r2,(104)                // store x into y
    12771278\end{cfa}
    12781279\end{tabular}
     
    14221423int w, x, y, z, & ar[3] = { x, y, z }; §\C{// initialize array of references}§
    14231424&ar[1] = &w;                                            §\C{// change reference array element}§
    1424 typeof( ar[1] ) p;                                      §\C{// (gcc) is int, \ie the type of referenced object}§
    1425 typeof( &ar[1] ) q;                                     §\C{// (gcc) is int \&, \ie the type of reference}§
    1426 sizeof( ar[1] ) == sizeof( int );       §\C{// is true, \ie the size of referenced object}§
    1427 sizeof( &ar[1] ) == sizeof( int *)      §\C{// is true, \ie the size of a reference}§
     1425typeof( ar[1] ) p;                                      §\C{// (gcc) is int, i.e., the type of referenced object}§
     1426typeof( &ar[1] ) q;                                     §\C{// (gcc) is int \&, i.e., the type of reference}§
     1427sizeof( ar[1] ) == sizeof( int );       §\C{// is true, i.e., the size of referenced object}§
     1428sizeof( &ar[1] ) == sizeof( int *)      §\C{// is true, i.e., the size of a reference}§
    14281429\end{cfa}
    14291430
     
    15701571
    15711572\item
    1572 lvalue to reference conversion: \lstinline[deletekeywords=lvalue]$lvalue-type cv1 T$ converts to ©cv2 T &©, which allows implicitly converting variables to references.
     1573lvalue to reference conversion: \lstinline[deletekeywords={lvalue}]@lvalue-type cv1 T@ converts to ©cv2 T &©, which allows implicitly converting variables to references.
    15731574\begin{cfa}
    15741575int x, &r = ®x®, f( int & p ); // lvalue variable (int) convert to reference (int &)
     
    17641765
    17651766In detail, the brackets, ©[]©, enclose the result type, where each return value is named and that name is a local variable of the particular return type.\footnote{
    1766 \Index*{Michael Tiemann}\index{Tiemann, Michael}, with help from \Index*{Doug Lea}\index{Lea, Doug}, provided named return values in g++, circa 1989.}
     1767\Index*{Michael Tiemann}, with help from \Index*{Doug Lea}, provided named return values in g++, circa 1989.}
    17671768The value of each local return variable is automatically returned at routine termination.
    17681769Declaration qualifiers can only appear at the start of a routine definition, \eg:
     
    22232224
    22242225
    2225 \section{Tuple}
    2226 
    2227 In C and \CFA, lists of elements appear in several contexts, such as the parameter list of a routine call.
    2228 \begin{cfa}
    2229 f( ®2, x, 3 + i® );                             §\C{// element list}§
    2230 \end{cfa}
    2231 A list of elements is called a \newterm{tuple}, and is different from a \Index{comma expression}.
    2232 
    2233 
    2234 \subsection{Multiple-Return-Value Functions}
    2235 \label{s:MRV_Functions}
    2236 
    2237 In standard C, functions can return at most one value.
    2238 To emulate functions with multiple return values, \emph{\Index{aggregation}} and/or \emph{\Index{aliasing}} is used.
    2239 In the former situation, the function designer creates a record type that combines all of the return values into a single type.
    2240 For example, consider a function returning the most frequently occurring letter in a string, and its frequency.
    2241 This example is complex enough to illustrate that an array is insufficient, since arrays are homogeneous, and demonstrates a potential pitfall that exists with aliasing.
    2242 \begin{cfa}
    2243 struct mf_ret {
    2244         int freq;
    2245         char ch;
    2246 };
    2247 
    2248 struct mf_ret most_frequent(const char * str) {
    2249         char freqs [26] = { 0 };
    2250         struct mf_ret ret = { 0, 'a' };
    2251         for (int i = 0; str[i] != '\0'; ++i) {
    2252                 if (isalpha(str[i])) {        // only count letters
    2253                         int ch = tolower(str[i]);   // convert to lower case
    2254                         int idx = ch-'a';
    2255                         if (++freqs[idx] > ret.freq) {  // update on new max
    2256                           ret.freq = freqs[idx];
    2257                           ret.ch = ch;
    2258                         }
    2259                 }
    2260         }
    2261         return ret;
    2262 }
    2263 
    2264 const char * str = "hello world";
    2265 struct mf_ret ret = most_frequent(str);
    2266 printf("%s -- %d %c\n", str, ret.freq, ret.ch);
    2267 \end{cfa}
    2268 Of note, the designer must come up with a name for the return type and for each of its fields.
    2269 Unnecessary naming is a common programming language issue, introducing verbosity and a complication of the user's mental model.
    2270 That is, adding another named type creates another association in the programmer's mind that needs to be kept track of when reading and writing code.
    2271 As such, this technique is effective when used sparingly, but can quickly get out of hand if many functions need to return different combinations of types.
    2272 
    2273 In the latter approach, the designer simulates multiple return values by passing the additional return values as pointer parameters.
    2274 The pointer parameters are assigned inside of the routine body to emulate a return.
    2275 Using the same example,
    2276 \begin{cfa}
    2277 int most_frequent(const char * str, char * ret_ch) {
    2278         char freqs [26] = { 0 };
    2279         int ret_freq = 0;
    2280         for (int i = 0; str[i] != '\0'; ++i) {
    2281                 if (isalpha(str[i])) {        // only count letters
    2282                         int ch = tolower(str[i]);   // convert to lower case
    2283                         int idx = ch-'a';
    2284                         if (++freqs[idx] > ret_freq) {  // update on new max
    2285                           ret_freq = freqs[idx];
    2286                           *ret_ch = ch;   // assign to out parameter
    2287                         }
    2288                 }
    2289         }
    2290         return ret_freq;  // only one value returned directly
    2291 }
    2292 
    2293 const char * str = "hello world";
    2294 char ch;                            // pre-allocate return value
    2295 int freq = most_frequent(str, &ch); // pass return value as out parameter
    2296 printf("%s -- %d %c\n", str, freq, ch);
    2297 \end{cfa}
    2298 Notably, using this approach, the caller is directly responsible for allocating storage for the additional temporary return values, which complicates the call site with a sequence of variable declarations leading up to the call.
    2299 Also, while a disciplined use of ©const© can give clues about whether a pointer parameter is going to be used as an out parameter, it is not immediately obvious from only the routine signature whether the callee expects such a parameter to be initialized before the call.
    2300 Furthermore, while many C routines that accept pointers are designed so that it is safe to pass ©NULL© as a parameter, there are many C routines that are not null-safe.
    2301 On a related note, C does not provide a standard mechanism to state that a parameter is going to be used as an additional return value, which makes the job of ensuring that a value is returned more difficult for the compiler.
    2302 Interestingly, there is a subtle bug in the previous example, in that ©ret_ch© is never assigned for a string that does not contain any letters, which can lead to undefined behaviour.
    2303 In this particular case, it turns out that the frequency return value also doubles as an error code, where a frequency of 0 means the character return value should be ignored.
    2304 Still, not every routine with multiple return values should be required to return an error code, and error codes are easily ignored, so this is not a satisfying solution.
    2305 As with the previous approach, this technique can simulate multiple return values, but in practice it is verbose and error prone.
    2306 
    2307 In \CFA, functions can be declared to return multiple values with an extension to the function declaration syntax.
    2308 Multiple return values are declared as a comma-separated list of types in square brackets in the same location that the return type appears in standard C function declarations.
    2309 The ability to return multiple values from a function requires a new syntax for the return statement.
    2310 For consistency, the return statement in \CFA accepts a comma-separated list of expressions in square brackets.
    2311 The expression resolution phase of the \CFA translator ensures that the correct form is used depending on the values being returned and the return type of the current function.
    2312 A multiple-returning function with return type ©T© can return any expression that is implicitly convertible to ©T©.
    2313 Using the running example, the ©most_frequent© function can be written using multiple return values as such,
    2314 \begin{cfa}
    2315 [int, char] most_frequent(const char * str) {
    2316         char freqs [26] = { 0 };
    2317         int ret_freq = 0;
    2318         char ret_ch = 'a';  // arbitrary default value for consistent results
    2319         for (int i = 0; str[i] != '\0'; ++i) {
    2320                 if (isalpha(str[i])) {        // only count letters
    2321                         int ch = tolower(str[i]);   // convert to lower case
    2322                         int idx = ch-'a';
    2323                         if (++freqs[idx] > ret_freq) {  // update on new max
    2324                           ret_freq = freqs[idx];
    2325                           ret_ch = ch;
    2326                         }
    2327                 }
    2328         }
    2329         return [ret_freq, ret_ch];
    2330 }
    2331 \end{cfa}
    2332 This approach provides the benefits of compile-time checking for appropriate return statements as in aggregation, but without the required verbosity of declaring a new named type, which precludes the bug seen with out-parameters.
    2333 
    2334 The addition of multiple-return-value functions necessitates a syntax for accepting multiple values at the call-site.
    2335 The simplest mechanism for retaining a return value in C is variable assignment.
    2336 By assigning the return value into a variable, its value can be retrieved later at any point in the program.
    2337 As such, \CFA allows assigning multiple values from a function into multiple variables, using a square-bracketed list of lvalue expressions on the left side.
    2338 \begin{cfa}
    2339 const char * str = "hello world";
    2340 int freq;
    2341 char ch;
    2342 [freq, ch] = most_frequent(str);  // assign into multiple variables
    2343 printf("%s -- %d %c\n", str, freq, ch);
    2344 \end{cfa}
    2345 It is also common to use a function's output as the input to another function.
    2346 \CFA also allows this case, without any new syntax.
    2347 When a function call is passed as an argument to another call, the expression resolver attempts to find the best match of actual arguments to formal parameters given all of the possible expression interpretations in the current scope \cite{Bilson03}.
    2348 For example,
    2349 \begin{cfa}
    2350 void process(int);       // (1)
    2351 void process(char);      // (2)
    2352 void process(int, char); // (3)
    2353 void process(char, int); // (4)
    2354 
    2355 process(most_frequent("hello world"));  // selects (3)
    2356 \end{cfa}
    2357 In this case, there is only one option for a function named ©most_frequent© that takes a string as input.
    2358 This function returns two values, one ©int© and one ©char©.
    2359 There are four options for a function named ©process©, but only two that accept two arguments, and of those the best match is (3), which is also an exact match.
    2360 This expression first calls ©most_frequent("hello world")©, which produces the values ©3© and ©'l'©, which are fed directly to the first and second parameters of (3), respectively.
    2361 
    2362 \section{Tuple Expressions}
    2363 Multiple-return-value functions provide \CFA with a new syntax for expressing a combination of expressions in the return statement and a combination of types in a function signature.
    2364 These notions can be generalized to provide \CFA with \emph{tuple expressions} and \emph{tuple types}.
    2365 A tuple expression is an expression producing a fixed-size, ordered list of values of heterogeneous types.
    2366 The type of a tuple expression is the tuple of the subexpression types, or a \emph{tuple type}.
    2367 In \CFA, a tuple expression is denoted by a comma-separated list of expressions enclosed in square brackets.
    2368 For example, the expression ©[5, 'x', 10.5]© has type ©[int, char, double]©.
    2369 The previous expression has 3 \emph{components}.
    2370 Each component in a tuple expression can be any \CFA expression, including another tuple expression.
    2371 The order of evaluation of the components in a tuple expression is unspecified, to allow a compiler the greatest flexibility for program optimization.
    2372 It is, however, guaranteed that each component of a tuple expression is evaluated for side-effects, even if the result is not used.
    2373 Multiple-return-value functions can equivalently be called \emph{tuple-returning functions}.
    2374 
    2375 \subsection{Tuple Variables}
    2376 The call-site of the ©most_frequent© routine has a notable blemish, in that it required the preallocation of return variables in a manner similar to the aliasing example, since it is impossible to declare multiple variables of different types in the same declaration in standard C.
    2377 In \CFA, it is possible to overcome this restriction by declaring a \emph{tuple variable}.
    2378 \begin{cfa}[emph=ret, emphstyle=\color{red}]
    2379 const char * str = "hello world";
    2380 [int, char] ret = most_frequent(str);  // initialize tuple variable
    2381 printf("%s -- %d %c\n", str, ret);
    2382 \end{cfa}
    2383 It is now possible to accept multiple values into a single piece of storage, in much the same way that it was previously possible to pass multiple values from one function call to another.
    2384 These variables can be used in any of the contexts where a tuple expression is allowed, such as in the ©printf© function call.
    2385 As in the ©process© example, the components of the tuple value are passed as separate parameters to ©printf©, allowing very simple printing of tuple expressions.
    2386 One way to access the individual components is with a simple assignment, as in previous examples.
    2387 \begin{cfa}
    2388 int freq;
    2389 char ch;
    2390 [freq, ch] = ret;
    2391 \end{cfa}
    2392 
    2393 \begin{sloppypar}
    2394 In addition to variables of tuple type, it is also possible to have pointers to tuples, and arrays of tuples.
    2395 Tuple types can be composed of any types, except for array types, since array assignment is disallowed, which makes tuple assignment difficult when a tuple contains an array.
    2396 \begin{cfa}
    2397 [double, int] di;
    2398 [double, int] * pdi
    2399 [double, int] adi[10];
    2400 \end{cfa}
    2401 This examples declares a variable of type ©[double, int]©, a variable of type pointer to ©[double, int]©, and an array of ten ©[double, int]©.
    2402 \end{sloppypar}
    2403 
    2404 \subsection{Tuple Indexing}
    2405 
    2406 At times, it is desirable to access a single component of a tuple-valued expression without creating unnecessary temporary variables to assign to.
    2407 Given a tuple-valued expression ©e© and a compile-time constant integer $i$ where $0 \leq i < n$, where $n$ is the number of components in ©e©, ©e.i© accesses the $i$\textsuperscript{th} component of ©e©.
    2408 For example,
    2409 \begin{cfa}
    2410 [int, double] x;
    2411 [char *, int] f();
    2412 void g(double, int);
    2413 [int, double] * p;
    2414 
    2415 int y = x.0;                                                    §\C{// access int component of x}§
    2416 y = f().1;                                                              §\C{// access int component of f}§
    2417 p->0 = 5;                                                               §\C{// access int component of tuple pointed-to by p}§
    2418 g( x.1, x.0 );                                                  §\C{// rearrange x to pass to g}§
    2419 double z = [x, f()].0.1;                                §\C{// access second component of first component of tuple expression}§
    2420 \end{cfa}
    2421 As seen above, tuple-index expressions can occur on any tuple-typed expression, including tuple-returning functions, square-bracketed tuple expressions, and other tuple-index expressions, provided the retrieved component is also a tuple.
    2422 This feature was proposed for \KWC but never implemented \cite[p.~45]{Till89}.
    2423 
    2424 \subsection{Flattening and Structuring}
    2425 As evident in previous examples, tuples in \CFA do not have a rigid structure.
    2426 In function call contexts, tuples support implicit flattening and restructuring conversions.
    2427 Tuple flattening recursively expands a tuple into the list of its basic components.
    2428 Tuple structuring packages a list of expressions into a value of tuple type.
    2429 \begin{cfa}
    2430 int f(int, int);
    2431 int g([int, int]);
    2432 int h(int, [int, int]);
    2433 [int, int] x;
    2434 int y;
    2435 
    2436 f(x);      // flatten
    2437 g(y, 10);  // structure
    2438 h(x, y);   // flatten & structure
    2439 \end{cfa}
    2440 In \CFA, each of these calls is valid.
    2441 In the call to ©f©, ©x© is implicitly flattened so that the components of ©x© are passed as the two arguments to ©f©.
    2442 For the call to ©g©, the values ©y© and ©10© are structured into a single argument of type ©[int, int]© to match the type of the parameter of ©g©.
    2443 Finally, in the call to ©h©, ©x© is flattened to yield an argument list of length 3, of which the first component of ©x© is passed as the first parameter of ©h©, and the second component of ©x© and ©y© are structured into the second argument of type ©[int, int]©.
    2444 The flexible structure of tuples permits a simple and expressive function-call syntax to work seamlessly with both single- and multiple-return-value functions, and with any number of arguments of arbitrarily complex structure.
    2445 
    2446 In \KWC \cite{Buhr94a,Till89}, there were 4 tuple coercions: opening, closing, flattening, and structuring.
    2447 Opening coerces a tuple value into a tuple of values, while closing converts a tuple of values into a single tuple value.
    2448 Flattening coerces a nested tuple into a flat tuple, \ie it takes a tuple with tuple components and expands it into a tuple with only non-tuple components.
    2449 Structuring moves in the opposite direction, \ie it takes a flat tuple value and provides structure by introducing nested tuple components.
    2450 
    2451 In \CFA, the design has been simplified to require only the two conversions previously described, which trigger only in function call and return situations.
    2452 This simplification is a primary contribution of this thesis to the design of tuples in \CFA.
    2453 Specifically, the expression resolution algorithm examines all of the possible alternatives for an expression to determine the best match.
    2454 In resolving a function call expression, each combination of function value and list of argument alternatives is examined.
    2455 Given a particular argument list and function value, the list of argument alternatives is flattened to produce a list of non-tuple valued expressions.
    2456 Then the flattened list of expressions is compared with each value in the function's parameter list.
    2457 If the parameter's type is not a tuple type, then the current argument value is unified with the parameter type, and on success the next argument and parameter are examined.
    2458 If the parameter's type is a tuple type, then the structuring conversion takes effect, recursively applying the parameter matching algorithm using the tuple's component types as the parameter list types.
    2459 Assuming a successful unification, eventually the algorithm gets to the end of the tuple type, which causes all of the matching expressions to be consumed and structured into a tuple expression.
    2460 For example, in
    2461 \begin{cfa}
    2462 int f(int, [double, int]);
    2463 f([5, 10.2], 4);
    2464 \end{cfa}
    2465 There is only a single definition of ©f©, and 3 arguments with only single interpretations.
    2466 First, the argument alternative list ©[5, 10.2], 4© is flattened to produce the argument list ©5, 10.2, 4©.
    2467 Next, the parameter matching algorithm begins, with $P = $©int© and $A = $©int©, which unifies exactly.
    2468 Moving to the next parameter and argument, $P = $©[double, int]© and $A = $©double©.
    2469 This time, the parameter is a tuple type, so the algorithm applies recursively with $P' = $©double© and $A = $©double©, which unifies exactly.
    2470 Then $P' = $©int© and $A = $©double©, which again unifies exactly.
    2471 At this point, the end of $P'$ has been reached, so the arguments ©10.2, 4© are structured into the tuple expression ©[10.2, 4]©.
    2472 Finally, the end of the parameter list $P$ has also been reached, so the final expression is ©f(5, [10.2, 4])©.
    2473 
    2474 \section{Tuple Assignment}
    2475 \label{s:TupleAssignment}
    2476 An assignment where the left side of the assignment operator has a tuple type is called tuple assignment.
    2477 There are two kinds of tuple assignment depending on whether the right side of the assignment operator has a tuple type or a non-tuple type, called \emph{Multiple} and \emph{Mass} Assignment, respectively.
    2478 \begin{cfa}
    2479 int x;
    2480 double y;
    2481 [int, double] z;
    2482 [y, x] = 3.14;  // mass assignment
    2483 [x, y] = z;     // multiple assignment
    2484 z = 10;         // mass assignment
    2485 z = [x, y];     // multiple assignment
    2486 \end{cfa}
    2487 Let $L_i$ for $i$ in $[0, n)$ represent each component of the flattened left side, $R_i$ represent each component of the flattened right side of a multiple assignment, and $R$ represent the right side of a mass assignment.
    2488 
    2489 For a multiple assignment to be valid, both tuples must have the same number of elements when flattened.
    2490 For example, the following is invalid because the number of components on the left does not match the number of components on the right.
    2491 \begin{cfa}
    2492 [int, int] x, y, z;
    2493 [x, y] = z;   // multiple assignment, invalid 4 != 2
    2494 \end{cfa}
    2495 Multiple assignment assigns $R_i$ to $L_i$ for each $i$.
    2496 That is, ©?=?(&$L_i$, $R_i$)© must be a well-typed expression.
    2497 In the previous example, ©[x, y] = z©, ©z© is flattened into ©z.0, z.1©, and the assignments ©x = z.0© and ©y = z.1© happen.
    2498 
    2499 A mass assignment assigns the value $R$ to each $L_i$.
    2500 For a mass assignment to be valid, ©?=?(&$L_i$, $R$)© must be a well-typed expression.
    2501 These semantics differ from C cascading assignment (\eg ©a=b=c©) in that conversions are applied to $R$ in each individual assignment, which prevents data loss from the chain of conversions that can happen during a cascading assignment.
    2502 For example, ©[y, x] = 3.14© performs the assignments ©y = 3.14© and ©x = 3.14©, which results in the value ©3.14© in ©y© and the value ©3© in ©x©.
    2503 On the other hand, the C cascading assignment ©y = x = 3.14© performs the assignments ©x = 3.14© and ©y = x©, which results in the value ©3© in ©x©, and as a result the value ©3© in ©y© as well.
    2504 
    2505 Both kinds of tuple assignment have parallel semantics, such that each value on the left side and right side is evaluated \emph{before} any assignments occur.
    2506 As a result, it is possible to swap the values in two variables without explicitly creating any temporary variables or calling a function.
    2507 \begin{cfa}
    2508 int x = 10, y = 20;
    2509 [x, y] = [y, x];
    2510 \end{cfa}
    2511 After executing this code, ©x© has the value ©20© and ©y© has the value ©10©.
    2512 
    2513 In \CFA, tuple assignment is an expression where the result type is the type of the left side of the assignment, as in normal assignment.
    2514 That is, a tuple assignment produces the value of the left-hand side after assignment.
    2515 These semantics allow cascading tuple assignment to work out naturally in any context where a tuple is permitted.
    2516 These semantics are a change from the original tuple design in \KWC \cite{Till89}, wherein tuple assignment was a statement that allows cascading assignments as a special case.
    2517 Restricting tuple assignment to statements was an attempt to to fix what was seen as a problem with side-effects, wherein assignment can be used in many different locations, such as in function-call argument position.
    2518 While permitting assignment as an expression does introduce the potential for subtle complexities, it is impossible to remove assignment expressions from \CFA without affecting backwards compatibility.
    2519 Furthermore, there are situations where permitting assignment as an expression improves readability by keeping code succinct and reducing repetition, and complicating the definition of tuple assignment puts a greater cognitive burden on the user.
    2520 In another language, tuple assignment as a statement could be reasonable, but it would be inconsistent for tuple assignment to be the only kind of assignment that is not an expression.
    2521 In addition, \KWC permits the compiler to optimize tuple assignment as a block copy, since it does not support user-defined assignment operators.
    2522 This optimization could be implemented in \CFA, but it requires the compiler to verify that the selected assignment operator is trivial.
    2523 
    2524 The following example shows multiple, mass, and cascading assignment used in one expression
    2525 \begin{cfa}
    2526         int a, b;
    2527         double c, d;
    2528         [void] f([int, int]);
    2529         f([c, a] = [b, d] = 1.5);  // assignments in parameter list
    2530 \end{cfa}
    2531 The tuple expression begins with a mass assignment of ©1.5© into ©[b, d]©, which assigns ©1.5© into ©b©, which is truncated to ©1©, and ©1.5© into ©d©, producing the tuple ©[1, 1.5]© as a result.
    2532 That tuple is used as the right side of the multiple assignment (\ie, ©[c, a] = [1, 1.5]©) that assigns ©1© into ©c© and ©1.5© into ©a©, which is truncated to ©1©, producing the result ©[1, 1]©.
    2533 Finally, the tuple ©[1, 1]© is used as an expression in the call to ©f©.
    2534 
    2535 \subsection{Tuple Construction}
    2536 Tuple construction and destruction follow the same rules and semantics as tuple assignment, except that in the case where there is no right side, the default constructor or destructor is called on each component of the tuple.
    2537 As constructors and destructors did not exist in previous versions of \CFA or in \KWC, this is a primary contribution of this thesis to the design of tuples.
    2538 \begin{cfa}
    2539 struct S;
    2540 void ?{}(S *);         // (1)
    2541 void ?{}(S *, int);    // (2)
    2542 void ?{}(S * double);  // (3)
    2543 void ?{}(S *, S);      // (4)
    2544 
    2545 [S, S] x = [3, 6.28];  // uses (2), (3), specialized constructors
    2546 [S, S] y;              // uses (1), (1), default constructor
    2547 [S, S] z = x.0;        // uses (4), (4), copy constructor
    2548 \end{cfa}
    2549 In this example, ©x© is initialized by the multiple constructor calls ©?{}(&x.0, 3)© and ©?{}(&x.1, 6.28)©, while ©y© is initialized by two default constructor calls ©?{}(&y.0)© and ©?{}(&y.1)©.
    2550 ©z© is initialized by mass copy constructor calls ©?{}(&z.0, x.0)© and ©?{}(&z.1, x.0)©.
    2551 Finally, ©x©, ©y©, and ©z© are destructed, \ie the calls ©^?{}(&x.0)©, ©^?{}(&x.1)©, ©^?{}(&y.0)©, ©^?{}(&y.1)©, ©^?{}(&z.0)©, and ©^?{}(&z.1)©.
    2552 
    2553 It is possible to define constructors and assignment functions for tuple types that provide new semantics, if the existing semantics do not fit the needs of an application.
    2554 For example, the function ©void ?{}([T, U] *, S);© can be defined to allow a tuple variable to be constructed from a value of type ©S©.
    2555 \begin{cfa}
    2556 struct S { int x; double y; };
    2557 void ?{}([int, double] * this, S s) {
    2558         this->0 = s.x;
    2559         this->1 = s.y;
    2560 }
    2561 \end{cfa}
    2562 Due to the structure of generated constructors, it is possible to pass a tuple to a generated constructor for a type with a member prefix that matches the type of the tuple.
    2563 For example,
    2564 \begin{cfa}
    2565 struct S { int x; double y; int z };
    2566 [int, double] t;
    2567 S s = t;
    2568 \end{cfa}
    2569 The initialization of ©s© with ©t© works by default because ©t© is flattened into its components, which satisfies the generated field constructor ©?{}(S *, int, double)© to initialize the first two values.
    2570 
    2571 \section{Member-Access Tuple Expression}
    2572 \label{s:MemberAccessTuple}
    2573 It is possible to access multiple fields from a single expression using a \emph{Member-Access Tuple Expression}.
    2574 The result is a single tuple-valued expression whose type is the tuple of the types of the members.
    2575 For example,
    2576 \begin{cfa}
    2577 struct S { int x; double y; char * z; } s;
    2578 s.[x, y, z];
    2579 \end{cfa}
    2580 Here, the type of ©s.[x, y, z]© is ©[int, double, char *]©.
    2581 A member tuple expression has the form ©a.[x, y, z];© where ©a© is an expression with type ©T©, where ©T© supports member access expressions, and ©x, y, z© are all members of ©T© with types ©T$_x$©, ©T$_y$©, and ©T$_z$© respectively.
    2582 Then the type of ©a.[x, y, z]© is ©[T_x, T_y, T_z]©.
    2583 
    2584 Since tuple index expressions are a form of member-access expression, it is possible to use tuple-index expressions in conjunction with member tuple expressions to manually restructure a tuple (\eg, rearrange components, drop components, duplicate components, etc.).
    2585 \begin{cfa}
    2586 [int, int, long, double] x;
    2587 void f(double, long);
    2588 
    2589 f(x.[0, 3]);          // f(x.0, x.3)
    2590 x.[0, 1] = x.[1, 0];  // [x.0, x.1] = [x.1, x.0]
    2591 [long, int, long] y = x.[2, 0, 2];
    2592 \end{cfa}
    2593 
    2594 It is possible for a member tuple expression to contain other member access expressions.
    2595 For example,
    2596 \begin{cfa}
    2597 struct A { double i; int j; };
    2598 struct B { int * k; short l; };
    2599 struct C { int x; A y; B z; } v;
    2600 v.[x, y.[i, j], z.k];
    2601 \end{cfa}
    2602 This expression is equivalent to ©[v.x, [v.y.i, v.y.j], v.z.k]©.
    2603 That is, the aggregate expression is effectively distributed across the tuple, which allows simple and easy access to multiple components in an aggregate, without repetition.
    2604 It is guaranteed that the aggregate expression to the left of the ©.© in a member tuple expression is evaluated exactly once.
    2605 As such, it is safe to use member tuple expressions on the result of a side-effecting function.
    2606 \begin{cfa}
    2607 [int, float, double] f();
    2608 [double, float] x = f().[2, 1];
    2609 \end{cfa}
    2610 
    2611 In \KWC, member tuple expressions are known as \emph{record field tuples} \cite{Till89}.
    2612 Since \CFA permits these tuple-access expressions using structures, unions, and tuples, \emph{member tuple expression} or \emph{field tuple expression} is more appropriate.
    2613 
    2614 It is possible to extend member-access expressions further.
    2615 Currently, a member-access expression whose member is a name requires that the aggregate is a structure or union, while a constant integer member requires the aggregate to be a tuple.
    2616 In the interest of orthogonal design, \CFA could apply some meaning to the remaining combinations as well.
    2617 For example,
    2618 \begin{cfa}
    2619 struct S { int x, y; } s;
    2620 [S, S] z;
    2621 
    2622 s.x;  // access member
    2623 z.0;  // access component
    2624 
    2625 s.1;  // ???
    2626 z.y;  // ???
    2627 \end{cfa}
    2628 One possibility is for ©s.1© to select the second member of ©s©.
    2629 Under this interpretation, it becomes possible to not only access members of a struct by name, but also by position.
    2630 Likewise, it seems natural to open this mechanism to enumerations as well, wherein the left side would be a type, rather than an expression.
    2631 One benefit of this interpretation is familiarity, since it is extremely reminiscent of tuple-index expressions.
    2632 On the other hand, it could be argued that this interpretation is brittle in that changing the order of members or adding new members to a structure becomes a brittle operation.
    2633 This problem is less of a concern with tuples, since modifying a tuple affects only the code that directly uses the tuple, whereas modifying a structure has far reaching consequences for every instance of the structure.
    2634 
    2635 As for ©z.y©, one interpretation is to extend the meaning of member tuple expressions.
    2636 That is, currently the tuple must occur as the member, \ie to the right of the dot.
    2637 Allowing tuples to the left of the dot could distribute the member across the elements of the tuple, in much the same way that member tuple expressions distribute the aggregate across the member tuple.
    2638 In this example, ©z.y© expands to ©[z.0.y, z.1.y]©, allowing what is effectively a very limited compile-time field-sections map operation, where the argument must be a tuple containing only aggregates having a member named ©y©.
    2639 It is questionable how useful this would actually be in practice, since structures often do not have names in common with other structures, and further this could cause maintainability issues in that it encourages programmers to adopt very simple naming conventions to maximize the amount of overlap between different types.
    2640 Perhaps more useful would be to allow arrays on the left side of the dot, which would likewise allow mapping a field access across the entire array, producing an array of the contained fields.
    2641 The immediate problem with this idea is that C arrays do not carry around their size, which would make it impossible to use this extension for anything other than a simple stack allocated array.
    2642 
    2643 Supposing this feature works as described, it would be necessary to specify an ordering for the expansion of member-access expressions versus member-tuple expressions.
    2644 \begin{cfa}
    2645 struct { int x, y; };
    2646 [S, S] z;
    2647 z.[x, y];  // ???
    2648 // => [z.0, z.1].[x, y]
    2649 // => [z.0.x, z.0.y, z.1.x, z.1.y]
    2650 // or
    2651 // => [z.x, z.y]
    2652 // => [[z.0, z.1].x, [z.0, z.1].y]
    2653 // => [z.0.x, z.1.x, z.0.y, z.1.y]
    2654 \end{cfa}
    2655 Depending on exactly how the two tuples are combined, different results can be achieved.
    2656 As such, a specific ordering would need to be imposed to make this feature useful.
    2657 Furthermore, this addition moves a member-tuple expression's meaning from being clear statically to needing resolver support, since the member name needs to be distributed appropriately over each member of the tuple, which could itself be a tuple.
    2658 
    2659 A second possibility is for \CFA to have named tuples, as they exist in Swift and D.
    2660 \begin{cfa}
    2661 typedef [int x, int y] Point2D;
    2662 Point2D p1, p2;
    2663 p1.x + p1.y + p2.x + p2.y;
    2664 p1.0 + p1.1 + p2.0 + p2.1;  // equivalent
    2665 \end{cfa}
    2666 In this simpler interpretation, a tuple type carries with it a list of possibly empty identifiers.
    2667 This approach fits naturally with the named return-value feature, and would likely go a long way towards implementing it.
    2668 
    2669 Ultimately, the first two extensions introduce complexity into the model, with relatively little perceived benefit, and so were dropped from consideration.
    2670 Named tuples are a potentially useful addition to the language, provided they can be parsed with a reasonable syntax.
    2671 
    2672 
    2673 \section{Casting}
    2674 In C, the cast operator is used to explicitly convert between types.
    2675 In \CFA, the cast operator has a secondary use, which is type ascription, since it forces the expression resolution algorithm to choose the lowest cost conversion to the target type.
    2676 That is, a cast can be used to select the type of an expression when it is ambiguous, as in the call to an overloaded function.
    2677 \begin{cfa}
    2678 int f();     // (1)
    2679 double f();  // (2)
    2680 
    2681 f();       // ambiguous - (1),(2) both equally viable
    2682 (int)f();  // choose (2)
    2683 \end{cfa}
    2684 Since casting is a fundamental operation in \CFA, casts need to be given a meaningful interpretation in the context of tuples.
    2685 Taking a look at standard C provides some guidance with respect to the way casts should work with tuples.
    2686 \begin{cfa}[numbers=left]
    2687 int f();
    2688 void g();
    2689 
    2690 (void)f();  // valid, ignore results
    2691 (int)g();   // invalid, void cannot be converted to int
    2692 
    2693 struct A { int x; };
    2694 (struct A)f();  // invalid, int cannot be converted to A
    2695 \end{cfa}
    2696 In C, line 4 is a valid cast, which calls ©f© and discards its result.
    2697 On the other hand, line 5 is invalid, because ©g© does not produce a result, so requesting an ©int© to materialize from nothing is nonsensical.
    2698 Finally, line 8 is also invalid, because in C casts only provide conversion between scalar types \cite[p.~91]{C11}.
    2699 For consistency, this implies that any case wherein the number of components increases as a result of the cast is invalid, while casts that have the same or fewer number of components may be valid.
    2700 
    2701 Formally, a cast to tuple type is valid when $T_n \leq S_m$, where $T_n$ is the number of components in the target type and $S_m$ is the number of components in the source type, and for each $i$ in $[0, n)$, $S_i$ can be cast to $T_i$.
    2702 Excess elements ($S_j$ for all $j$ in $[n, m)$) are evaluated, but their values are discarded so that they are not included in the result expression.
    2703 This discarding naturally follows the way that a cast to void works in C.
    2704 
    2705 For example,
    2706 \begin{cfa}
    2707         [int, int, int] f();
    2708         [int, [int, int], int] g();
    2709 
    2710         ([int, double])f();           // (1) valid
    2711         ([int, int, int])g();         // (2) valid
    2712         ([void, [int, int]])g();      // (3) valid
    2713         ([int, int, int, int])g();    // (4) invalid
    2714         ([int, [int, int, int]])g();  // (5) invalid
    2715 \end{cfa}
    2716 
    2717 (1) discards the last element of the return value and converts the second element to type double.
    2718 Since ©int© is effectively a 1-element tuple, (2) discards the second component of the second element of the return value of ©g©.
    2719 If ©g© is free of side effects, this is equivalent to ©[(int)(g().0), (int)(g().1.0), (int)(g().2)]©.
    2720 Since ©void© is effectively a 0-element tuple, (3) discards the first and third return values, which is effectively equivalent to ©[(int)(g().1.0), (int)(g().1.1)]©).
    2721 % will this always hold true? probably, as constructors should give all of the conversion power we need. if casts become function calls, what would they look like? would need a way to specify the target type, which seems awkward. Also, C++ basically only has this because classes are closed to extension, while we don't have that problem (can have floating constructors for any type).
    2722 Note that a cast is not a function call in \CFA, so flattening and structuring conversions do not occur for cast expressions.
    2723 As such, (4) is invalid because the cast target type contains 4 components, while the source type contains only 3.
    2724 Similarly, (5) is invalid because the cast ©([int, int, int])(g().1)© is invalid.
    2725 That is, it is invalid to cast ©[int, int]© to ©[int, int, int]©.
    2726 
    2727 \section{Polymorphism}
    2728 Due to the implicit flattening and structuring conversions involved in argument passing, ©otype© and ©dtype© parameters are restricted to matching only with non-tuple types.
    2729 The integration of polymorphism, type assertions, and monomorphic specialization of tuple-assertions are a primary contribution of this thesis to the design of tuples.
    2730 \begin{cfa}
    2731 forall(otype T, dtype U)
    2732 void f(T x, U * y);
    2733 
    2734 f([5, "hello"]);
    2735 \end{cfa}
    2736 In this example, ©[5, "hello"]© is flattened, so that the argument list appears as ©5, "hello"©.
    2737 The argument matching algorithm binds ©T© to ©int© and ©U© to ©const char©, and calls the function as normal.
    2738 
    2739 Tuples can contain otype and dtype components.
    2740 For example, a plus operator can be written to add two triples of a type together.
    2741 \begin{cfa}
    2742 forall(otype T | { T ?+?(T, T); })
    2743 [T, T, T] ?+?([T, T, T] x, [T, T, T] y) {
    2744         return [x.0+y.0, x.1+y.1, x.2+y.2];
    2745 }
    2746 [int, int, int] x;
    2747 int i1, i2, i3;
    2748 [i1, i2, i3] = x + ([10, 20, 30]);
    2749 \end{cfa}
    2750 Note that due to the implicit tuple conversions, this function is not restricted to the addition of two triples.
    2751 A call to this plus operator type checks as long as a total of 6 non-tuple arguments are passed after flattening, and all of the arguments have a common type that can bind to ©T©, with a pairwise ©?+?© over ©T©.
    2752 For example, these expressions also succeed and produce the same value.
    2753 \begin{cfa}
    2754 ([x.0, x.1]) + ([x.2, 10, 20, 30]);  // x + ([10, 20, 30])
    2755 x.0 + ([x.1, x.2, 10, 20, 30]);      // x + ([10, 20, 30])
    2756 \end{cfa}
    2757 This presents a potential problem if structure is important, as these three expressions look like they should have different meanings.
    2758 Furthermore, these calls can be made ambiguous by introducing seemingly different functions.
    2759 \begin{cfa}
    2760 forall(otype T | { T ?+?(T, T); })
    2761 [T, T, T] ?+?([T, T] x, [T, T, T, T]);
    2762 forall(otype T | { T ?+?(T, T); })
    2763 [T, T, T] ?+?(T x, [T, T, T, T, T]);
    2764 \end{cfa}
    2765 It is also important to note that these calls could be disambiguated if the function return types were different, as they likely would be for a reasonable implementation of ©?+?©, since the return type is used in overload resolution.
    2766 Still, these semantics are a deficiency of the current argument matching algorithm, and depending on the function, differing return values may not always be appropriate.
    2767 These issues could be rectified by applying an appropriate conversion cost to the structuring and flattening conversions, which are currently 0-cost conversions in the expression resolver.
    2768 Care would be needed in this case to ensure that exact matches do not incur such a cost.
    2769 \begin{cfa}
    2770 void f([int, int], int, int);
    2771 
    2772 f([0, 0], 0, 0);    // no cost
    2773 f(0, 0, 0, 0);      // cost for structuring
    2774 f([0, 0,], [0, 0]); // cost for flattening
    2775 f([0, 0, 0], 0);    // cost for flattening and structuring
    2776 \end{cfa}
    2777 
    2778 Until this point, it has been assumed that assertion arguments must match the parameter type exactly, modulo polymorphic specialization (\ie, no implicit conversions are applied to assertion arguments).
    2779 This decision presents a conflict with the flexibility of tuples.
    2780 \subsection{Assertion Inference}
    2781 \begin{cfa}
    2782 int f([int, double], double);
    2783 forall(otype T, otype U | { T f(T, U, U); })
    2784 void g(T, U);
    2785 g(5, 10.21);
    2786 \end{cfa}
    2787 If assertion arguments must match exactly, then the call to ©g© cannot be resolved, since the expected type of ©f© is flat, while the only ©f© in scope requires a tuple type.
    2788 Since tuples are fluid, this requirement reduces the usability of tuples in polymorphic code.
    2789 To ease this pain point, function parameter and return lists are flattened for the purposes of type unification, which allows the previous example to pass expression resolution.
    2790 
    2791 This relaxation is made possible by extending the existing thunk generation scheme, as described by Bilson \cite{Bilson03}.
    2792 Now, whenever a candidate's parameter structure does not exactly match the formal parameter's structure, a thunk is generated to specialize calls to the actual function.
    2793 \begin{cfa}
    2794 int _thunk(int _p0, double _p1, double _p2) {
    2795         return f([_p0, _p1], _p2);
    2796 }
    2797 \end{cfa}
    2798 Essentially, this provides flattening and structuring conversions to inferred functions, improving the compatibility of tuples and polymorphism.
    2799 
    2800 
    28012226\section{Tuples}
    28022227
     
    32552680\begin{cfa}[belowskip=0pt]
    32562681char store[®sepSize®];                                          §\C{// sepSize is the maximum separator size}§
    3257 strcpy( store, sepGet( sout ) );                          §\C{// copy current separator}§
    3258 sepSet( sout, "_" );                                            §\C{// change separator to underscore}§
     2682strcpy( store, sepGet( sout ) );
     2683sepSet( sout, "_" );
    32592684sout | 1 | 2 | 3 | endl;
    32602685\end{cfa}
     
    32632688\end{cfa}
    32642689\begin{cfa}[belowskip=0pt]
    3265 sepSet( sout, store );                                          §\C{// change separator back to original}§
     2690sepSet( sout, store );
    32662691sout | 1 | 2 | 3 | endl;
    32672692\end{cfa}
     
    36883113
    36893114\begin{table}[hbt]
    3690 \centering
    3691 \input{../refrat/operidents}
     3115\hfil
     3116\begin{tabular}[t]{ll}
     3117%identifier & operation \\ \hline
     3118©?[?]© & subscripting \impl{?[?]}\\
     3119©?()© & function call \impl{?()}\\
     3120©?++© & postfix increment \impl{?++}\\
     3121©?--© & postfix decrement \impl{?--}\\
     3122©++?© & prefix increment \impl{++?}\\
     3123©--?© & prefix decrement \impl{--?}\\
     3124©*?© & dereference \impl{*?}\\
     3125©+?© & unary plus \impl{+?}\\
     3126©-?© & arithmetic negation \impl{-?}\\
     3127©~?© & bitwise negation \impl{~?}\\
     3128©!?© & logical complement \impl{"!?}\\
     3129©?*?© & multiplication \impl{?*?}\\
     3130©?/?© & division \impl{?/?}\\
     3131\end{tabular}\hfil
     3132\begin{tabular}[t]{ll}
     3133%identifier & operation \\ \hline
     3134©?%?© & remainder \impl{?%?}\\
     3135©?+?© & addition \impl{?+?}\\
     3136©?-?© & subtraction \impl{?-?}\\
     3137©?<<?© & left shift \impl{?<<?}\\
     3138©?>>?© & right shift \impl{?>>?}\\
     3139©?<?© & less than \impl{?<?}\\
     3140©?<=?© & less than or equal \impl{?<=?}\\
     3141©?>=?© & greater than or equal \impl{?>=?}\\
     3142©?>?© & greater than \impl{?>?}\\
     3143©?==?© & equality \impl{?==?}\\
     3144©?!=?© & inequality \impl{?"!=?}\\
     3145©?&?© & bitwise AND \impl{?&?}\\
     3146\end{tabular}\hfil
     3147\begin{tabular}[t]{ll}
     3148%identifier & operation \\ \hline
     3149©?^?© & exclusive OR \impl{?^?}\\
     3150©?|?© & inclusive OR \impl{?"|?}\\
     3151©?=?© & simple assignment \impl{?=?}\\
     3152©?*=?© & multiplication assignment \impl{?*=?}\\
     3153©?/=?© & division assignment \impl{?/=?}\\
     3154©?%=?© & remainder assignment \impl{?%=?}\\
     3155©?+=?© & addition assignment \impl{?+=?}\\
     3156©?-=?© & subtraction assignment \impl{?-=?}\\
     3157©?<<=?© & left-shift assignment \impl{?<<=?}\\
     3158©?>>=?© & right-shift assignment \impl{?>>=?}\\
     3159©?&=?© & bitwise AND assignment \impl{?&=?}\\
     3160©?^=?© & exclusive OR assignment \impl{?^=?}\\
     3161©?|=?© & inclusive OR assignment \impl{?"|=?}\\
     3162\end{tabular}
     3163\hfil
    36923164\caption{Operator Identifiers}
    36933165\label{opids}
     
    37363208\section{Auto Type-Inferencing}
    37373209
    3738 Auto type-inferencing occurs in a declaration where a variable's type is inferred from its initialization ex\-pression type.
     3210Auto type-inferencing occurs in a declaration where a variable's type is inferred from its initialization expression type.
    37393211\begin{quote2}
    37403212\begin{tabular}{@{}l@{\hspace{3em}}ll@{}}
     
    37653237\begin{itemize}
    37663238\item
    3767 preventing having to determine or write long generic types,
     3239preventing having to determine or write out long generic types,
    37683240\item
    37693241ensure secondary variables, related to a primary variable, always have the same type.
     
    37733245\Indexc{gcc} provides ©typeof© to declare a secondary variable from a primary variable.
    37743246\CFA also relies heavily on the specification of the left-hand side of assignment for type inferencing, so in many cases it is crucial to specify the type of the left-hand side to select the correct type of the right-hand expression.
    3775 Only for overloaded routines \emph{with the same return type} is variable type-inferencing possible.
     3247Only for overloaded routines with the same return type is variable type-inferencing possible.
    37763248Finally, ©auto© presents the programming problem of tracking down a type when the type is actually needed.
    37773249For example, given
     
    37893261There is also the conundrum in type inferencing of when to \emph{\Index{brand}} a type.
    37903262That is, when is the type of the variable more important than the type of its initialization expression.
    3791 For example, if a change is made in an initialization expression, it can cause significant cascading type changes and/or errors.
    3792 At some point, a variable type needs to remain constant and the expression to be in error when it changes.
     3263For example, if a change is made in an initialization expression, it can cause hundreds or thousands of cascading type changes and/or errors.
     3264At some point, a programmer wants the type of the variable to remain constant and the expression to be in error when it changes.
    37933265
    37943266Given ©typedef© and ©typeof© in \CFA, and the strong need to use the type of left-hand side in inferencing, auto type-inferencing is not supported at this time.
     
    40033475        }
    40043476\end{cfa}
     3477\end{comment}
     3478
     3479
     3480\subsection{Memory Management}
     3481
     3482
     3483\subsubsection{Manual Memory Management}
     3484
     3485Using malloc and free to dynamically allocate memory exposes several potential, and common, errors.
     3486First, malloc breaks type safety because it returns a pointer to void.
     3487There is no relationship between the type that the returned pointer is cast to, and the amount of memory allocated.
     3488This problem is solved with a type-safe malloc.
     3489Do.s type-safe malloc does not take any arguments for size.
     3490Instead, it infers the type based on the return value, and then allocates space for the inferred type.
     3491
     3492\begin{cfa}
     3493float *f = malloc(); // allocates the size of a float
     3494
     3495struct S {
     3496        int i, j, k;
     3497};
     3498
     3499struct S *s = malloc(); // allocates the size of a struct S
     3500\end{cfa}
     3501
     3502In addition to the improved malloc, \CFA also provides a technique for combining allocation and initialization into one step, using the new function.
     3503For all constructors defined for a given type (see Operator Overloading), a corresponding call to new can be used to allocate and construct that type.
     3504
     3505\begin{cfa}
     3506type Complex = struct {
     3507        float real;
     3508        float imag;
     3509};
     3510
     3511// default constructor
     3512
     3513void ?{}(Complex &c) {
     3514        c.real = 0.0;
     3515        c.imag = 0.0;
     3516}
     3517
     3518
     3519
     3520// 2 parameter constructor
     3521
     3522void ?{}(Complex &c, float real, float imag) {
     3523        c.real = real;
     3524        c.imag = imag;
     3525}
     3526
     3527
     3528int main() {
     3529        Complex c1; // No constructor is called
     3530        Complex c2{}; // Default constructor called
     3531        Complex c3{1.0, -1.0}; // 2 parameter constructor is called
     3532
     3533        Complex *p1 = malloc(); // allocate
     3534        Complex *p2 = new(); // allocate + default constructor
     3535        Complex *p3 = new(0.5, 1.0); // allocate + 2 param constructor
     3536}
     3537\end{cfa}
     3538
     3539
     3540\subsubsection{Automatic Memory Management}
     3541
     3542\CFA may also support automatic memory management to further improve safety.
     3543If the compiler can insert all of the code needed to manage dynamically allocated memory (automatic reference counting), then developers can avoid problems with dangling pointers, double frees, memory leaks, etc.
     3544This feature requires further investigation.
     3545\CFA will not have a garbage collector, but might use some kind of region-based memory management.
     3546
     3547
     3548\begin{comment}
     3549\subsection{Unsafe C Constructs}
     3550
     3551C programmers are able to access all of the low-level tricks that are sometimes needed for close-to-the-hardware programming.
     3552Some of these practices however are often error-prone and difficult to read and maintain.
     3553Since \CFA is designed to be safer than C, such constructs are disallowed in \CFA code.
     3554If a programmer wants to use one of these unsafe C constructs, the unsafe code must be contained in a C linkage block (see Interoperability), which will be compiled like C code.
     3555This block means that the user is telling the tools, .I know this is unsafe, but I.m going to do it anyway..
     3556
     3557The exact set of unsafe C constructs that will be disallowed in \CFA has not yet been decided, but is sure to include pointer arithmetic, pointer casting, etc.
     3558Once the full set is decided, the rules will be listed here.
    40053559\end{comment}
    40063560
     
    42263780\label{f:SimpleTasks}
    42273781\end{figure}
     3782
     3783
     3784\begin{comment}
     3785\begin{cfa}
     3786type Adder = task {
     3787        int *row;
     3788        int size;
     3789        int &subtotal;
     3790}
     3791\end{cfa}
     3792
     3793A task may define a constructor, which will be called upon allocation and run on the caller.s thread.
     3794A destructor may also be defined, which is called at deallocation (when a dynamic object is deleted or when a local object goes out of scope).
     3795After a task is allocated and initialized, its thread is spawned implicitly and begins executing in its function call method.
     3796All tasks must define this function call method, with a void return value and no additional parameters, or the compiler will report an error.
     3797Below are example functions for the above Adder task, and its usage to sum up a matrix on multiple threads.
     3798(Note that this example is designed to display the syntax and functionality, not the best method to solve this problem)
     3799\begin{cfa}
     3800void ?{}(Adder &a, int r[], int s, int &st) { // constructor
     3801        a.row = r;
     3802        a.size = s;
     3803        a.subtotal = st;
     3804}
     3805
     3806// implicitly spawn thread and begin execution here
     3807
     3808void ?()(Adder &a) {
     3809        int c;
     3810        subtotal = 0;
     3811        for (c=0; c<a.size; ++c) {
     3812        subtotal += row[c];
     3813        }
     3814}
     3815
     3816int main() {
     3817        const int rows = 100, cols = 1000000;
     3818        int matrix[rows][cols];
     3819        int subtotals[rows];
     3820        int total = 0;
     3821        int r;
     3822
     3823        { // create a new scope here for our adders
     3824        Adder adders[rows];
     3825        // read in the matrix
     3826        ...
     3827        for (r=0; r<rows; ++r) {
     3828        // tasks are initialized on this thread
     3829        Adders[r] = {matrix[r], cols, subtotals[r]};
     3830        Adders[r](); // spawn thread and begin execution
     3831        }
     3832        } // adders go out of scope; block here until they all finish
     3833        total += subtotals[r];
     3834        printf(.total is %d\n., total);
     3835}
     3836\end{cfa}
     3837
     3838\subsection{Cooperative Scheduling}
     3839
     3840Tasks in \CFA are cooperatively scheduled, meaning that a task will not be interrupted by another task, except at specific yield points.
     3841In Listing 31, there are no yield points, so each task runs to completion with no interruptions.
     3842Places where a task could yield include waiting for a lock (explicitly or implicitly), waiting for I/O, or waiting for a specific function (or one of a set of functions) to be called.
     3843This last option is introduced with the yield function. yield is used to indicate that this task should yield its thread until the specified function is called.
     3844For example, the code below defines a monitor that maintains a generic list.
     3845When a task tries to pop from the list, but it is empty, the task should yield until another task puts something into the list, with the push function.
     3846Similarly, when a task tries to push something onto the list, but it is full, it will yield until another task frees some space with the pop function.
     3847
     3848\begin{cfa}
     3849// type T is used as a generic type for all definitions inside
     3850// the curly brackets
     3851
     3852generic(type T) {
     3853        type Channel = monitor {
     3854        List(T) list; // list is a simple generic list type
     3855        };
     3856
     3857        T pop(mutex &Channel(T) ch) {
     3858        if (ch.list.empty()) {
     3859        // yield until push is called for this channel
     3860        yield(push);
     3861        }
     3862        return ch.list.pop();
     3863        }
     3864
     3865        void push(mutex &Channel(T)ch, T val) {
     3866        if (ch.list.full()) {
     3867        // yield until pop is called for this channel
     3868        yield(pop);
     3869        }
     3870        ch.list.push(val);
     3871        }
     3872}
     3873\end{cfa}
     3874
     3875A task can also yield indefinitely by calling yield with no arguments.
     3876This will tell the scheduler to yield this task until it is resumed by some other task.
     3877A task can resume another task by using its functional call operator.
     3878The code below shows a simple ping-pong example, where two tasks yield back and forth to each other using these methods.
     3879
     3880\begin{cfa}
     3881type Ping = task {
     3882        Pong *partner;
     3883};
     3884
     3885void ?{}(Ping &p, Pong *partner = 0) {
     3886        p.partner = partner;
     3887}
     3888
     3889void ?()(Ping &p) {
     3890        for(;;) { // loop forever
     3891        printf(.ping\n.);
     3892        partner(); // resumes the partner task
     3893        yield(); // yields this task
     3894        }
     3895}
     3896
     3897type Pong = task {
     3898        Ping *partner;
     3899};
     3900
     3901void ?{}(Pong &p, Ping *partner = 0) {
     3902        p.partner = partner;
     3903}
     3904
     3905void ?()(Pong &p) {
     3906        for(;;) { // loop forever
     3907        yield(); // yields this task
     3908        printf(.pong/n.);
     3909        partner(); // resumes the partner task
     3910        }
     3911}
     3912
     3913void main() {
     3914        Ping ping; // allocate ping
     3915        Pong pong{ping}; // allocate, initialize, and start pong
     3916        Ping{pong}; // initialize and start ping
     3917}
     3918\end{cfa}
     3919
     3920The same functionality can be accomplished by providing functions to be called by the partner task.
     3921\begin{cfa}
     3922type Pingpong = task {
     3923        String msg;
     3924        Pingpong *partner;
     3925};
     3926
     3927void ?{}(Pingpong &p, String msg, Pingpong *partner = 0) {
     3928        p.msg = msg;
     3929        p.partner = partner;
     3930}
     3931
     3932void ?()(Pingpong &p) {
     3933        for(;;) {
     3934        yield(go);
     3935        }
     3936}
     3937
     3938void go(Pingpong &p) {
     3939        print(.%(p.msg)\n.);
     3940        go(p.partner);
     3941}
     3942
     3943void main() {
     3944        Pingpong ping = {.ping.};
     3945        Pingpong pong = {.pong., ping};
     3946        ping.partner = pong;
     3947        go(ping);
     3948}
     3949\end{cfa}
     3950\end{comment}
    42283951
    42293952
     
    48864609
    48874610
    4888 \section{Language Comparisons}
     4611\section{Comparison with Other Languages}
    48894612
    48904613\CFA is one of many languages that attempts to improve upon C.
     
    56215344
    56225345
    5623 \section{C Incompatibles}
     5346\section{\texorpdfstring{\CFA Keywords}{Cforall Keywords}}
     5347\label{s:CFAKeywords}
     5348
     5349\CFA introduces the following new keywords.
     5350
     5351\begin{quote2}
     5352\begin{tabular}{lllll}
     5353\begin{tabular}{@{}l@{}}
     5354©_At©                   \\
     5355©catch©                 \\
     5356©catchResume©   \\
     5357©choose©                \\
     5358©coroutine©             \\
     5359\end{tabular}
     5360&
     5361\begin{tabular}{@{}l@{}}
     5362©disable©               \\
     5363©dtype©                 \\
     5364©enable©                \\
     5365©fallthrough©   \\
     5366©fallthru©              \\
     5367\end{tabular}
     5368&
     5369\begin{tabular}{@{}l@{}}
     5370©finally©               \\
     5371©forall©                \\
     5372©ftype©                 \\
     5373©lvalue©                \\
     5374©monitor©               \\
     5375\end{tabular}
     5376&
     5377\begin{tabular}{@{}l@{}}
     5378©mutex©                 \\
     5379©one_t©                 \\
     5380©otype©                 \\
     5381©throw©                 \\
     5382©throwResume©   \\
     5383\end{tabular}
     5384&
     5385\begin{tabular}{@{}l@{}}
     5386©trait©                 \\
     5387©try©                   \\
     5388©ttype©                 \\
     5389©zero_t©                \\
     5390                                \\
     5391\end{tabular}
     5392\end{tabular}
     5393\end{quote2}
     5394
     5395
     5396\section{Incompatible}
    56245397
    56255398The following incompatibles exist between \CFA and C, and are similar to Annex C for \CC~\cite{C++14}.
     
    56495422g( p1, p2 ) int p1, p2;                 §\C{// int g( int p1, int p2 );}§
    56505423\end{cfa}
    5651 \CFA continues to support K\&R routine definitions:
     5424\CFA supports K\&R routine definitions:
    56525425\begin{cfa}
    56535426f( a, b, c )                                    §\C{// default int return}§
     
    57225495struct X { int i; struct X *next; };
    57235496static struct X a;                              §\C{// forward definition}§
    5724 static struct X b = { 0, ®&a® };§\C{// forward reference, valid in C, invalid in \CFA}§
     5497static struct X b = { 0, ®&a® };        §\C{// forward reference, valid in C, invalid in \CFA}§
    57255498static struct X a = { 1, &b };  §\C{// definition}§
    57265499\end{cfa}
     
    57375510enum ®Colour® { R, G, B, Y, C, M };
    57385511struct Person {
    5739         enum ®Colour® { R, G, B };      §\C[7cm]{// nested type}§
     5512        enum ®Colour® { R, G, B };      §\C{// nested type}§
    57405513        struct Face {                           §\C{// nested type}§
    57415514                ®Colour® Eyes, Hair;    §\C{// type defined outside (1 level)}§
     
    57465519};
    57475520®Colour® c = R;                                 §\C{// type/enum defined same level}§
    5748 Person®.Colour® pc = Person®.®R;§\C{// type/enum defined inside}§
    5749 Person®.®Face pretty;                   §\C{// type defined inside}\CRT§
     5521Person®.Colour® pc = Person®.®R;        §\C{// type/enum defined inside}§
     5522Person®.®Face pretty;                   §\C{// type defined inside}§
    57505523\end{cfa}
    57515524In C, the name of the nested types belongs to the same scope as the name of the outermost enclosing structure, \ie the nested types are hoisted to the scope of the outer-most type, which is not useful and confusing.
     
    57765549\item
    57775550\begin{description}
    5778 \item[Change:] remove implicit conversion of ©void *© to or from any ©T *© pointer:
    5779 \begin{cfa}
    5780 void foo() {
    5781         int * b = malloc( sizeof(int) );        §\C{// implicitly convert void * to int *}§
    5782         char * c = b;                           §\C{// implicitly convert int * to void *, and then void * to char *}§
    5783 }
    5784 \end{cfa}
    5785 \item[Rationale:] increase type safety
    5786 \item[Effect on original feature:] deletion of semantically well-defined feature.
    5787 \item[Difficulty of converting:] requires adding a cast (see \VRef{s:StorageManagement} for better alternatives):
    5788 \begin{cfa}
    5789         int * b = (int *)malloc( sizeof(int) );
    5790         char * c = (char *)b;
    5791 \end{cfa}
    5792 \item[How widely used:] Significant.
    5793 Some C translators already give a warning if the cast is not used.
    5794 \end{description}
    5795 
    5796 \item
    5797 \begin{description}
    5798 \item[Change:] Types must be declared in declarations, not in expressions
    5799 In C, a sizeof expression or cast expression may create a new type. For example,
    5800 \begin{cfa}
    5801 p = (void*)(struct x {int i;} *)0;
    5802 \end{cfa}
    5803 declares a new type, struct x .
    5804 \item[Rationale:] This prohibition helps to clarify the location of declarations in the source code.
    5805 \item[Effect on original feature:] Deletion of a semantically welldefined feature.
    5806 \item[Difficulty of converting:] Syntactic transformation.
    5807 \item[How widely used:] Seldom.
    5808 \end{description}
    5809 
    5810 \item
    5811 \begin{description}
    58125551\item[Change:] comma expression is disallowed as subscript
    58135552\item[Rationale:] safety issue to prevent subscripting error for multidimensional arrays: ©x[i,j]© instead of ©x[i][j]©, and this syntactic form then taken by \CFA for new style arrays.
    58145553\item[Effect on original feature:] change to semantics of well-defined feature.
    58155554\item[Difficulty of converting:] semantic transformation of ©x[i,j]© to ©x[(i,j)]©
    5816 \item[How widely used:] Seldom.
     5555\item[How widely used:] seldom.
    58175556\end{description}
    58185557\end{enumerate}
    58195558
    58205559
    5821 \section{\texorpdfstring{\CFA Keywords}{Cforall Keywords}}
    5822 \label{s:CFAKeywords}
    5823 
    5824 \CFA introduces the following new keywords.
    5825 
    5826 \begin{quote2}
    5827 \input{../refrat/keywords}
    5828 \end{quote2}
    5829 
    5830 
    58315560\section{Standard Headers}
    58325561\label{s:StandardHeaders}
     
    58345563\Celeven prescribes the following standard header-files~\cite[\S~7.1.2]{C11} and \CFA adds to this list:
    58355564\begin{quote2}
    5836 \begin{tabular}{@{}llllll|l@{}}
    5837 \multicolumn{6}{c|}{C11} & \multicolumn{1}{c}{\CFA}             \\
     5565\lstset{deletekeywords={float}}
     5566\begin{tabular}{@{}llll|l@{}}
     5567\multicolumn{4}{c|}{C11} & \multicolumn{1}{c}{\CFA}             \\
    58385568\hline
    58395569\begin{tabular}{@{}l@{}}
     
    58435573\Indexc{errno.h}                \\
    58445574\Indexc{fenv.h}                 \\
     5575\Indexc{float.h}                \\
     5576\Indexc{inttypes.h}             \\
     5577\Indexc{iso646.h}               \\
    58455578\end{tabular}
    58465579&
    58475580\begin{tabular}{@{}l@{}}
    5848 \Indexc[deletekeywords=float]{float.h} \\
    5849 \Indexc{inttypes.h}             \\
    5850 \Indexc{iso646.h}               \\
    58515581\Indexc{limits.h}               \\
    58525582\Indexc{locale.h}               \\
    5853 \end{tabular}
    5854 &
    5855 \begin{tabular}{@{}l@{}}
    58565583\Indexc{math.h}                 \\
    58575584\Indexc{setjmp.h}               \\
     
    58595586\Indexc{stdalign.h}             \\
    58605587\Indexc{stdarg.h}               \\
     5588\Indexc{stdatomic.h}    \\
    58615589\end{tabular}
    58625590&
    58635591\begin{tabular}{@{}l@{}}
    5864 \Indexc{stdatomic.h}    \\
    58655592\Indexc{stdbool.h}              \\
    58665593\Indexc{stddef.h}               \\
    58675594\Indexc{stdint.h}               \\
    58685595\Indexc{stdio.h}                \\
    5869 \end{tabular}
    5870 &
    5871 \begin{tabular}{@{}l@{}}
    58725596\Indexc{stdlib.h}               \\
    58735597\Indexc{stdnoreturn.h}  \\
    58745598\Indexc{string.h}               \\
    58755599\Indexc{tgmath.h}               \\
    5876 \Indexc{threads.h}              \\
    58775600\end{tabular}
    58785601&
    58795602\begin{tabular}{@{}l@{}}
     5603\Indexc{threads.h}              \\
    58805604\Indexc{time.h}                 \\
    58815605\Indexc{uchar.h}                \\
     
    58835607\Indexc{wctype.h}               \\
    58845608                                                \\
     5609                                                \\
     5610                                                \\
    58855611\end{tabular}
    58865612&
    58875613\begin{tabular}{@{}l@{}}
     5614\Indexc{unistd.h}               \\
    58885615\Indexc{gmp.h}                  \\
    5889 \Indexc{malloc.h}               \\
    5890 \Indexc{unistd.h}               \\
     5616                                                \\
     5617                                                \\
     5618                                                \\
     5619                                                \\
    58915620                                                \\
    58925621                                                \\
     
    58975626hence, names in these include files are not mangled\index{mangling!name} (see~\VRef{s:Interoperability}).
    58985627All other C header files must be explicitly wrapped in ©extern "C"© to prevent name mangling.
    5899 For \Index*[C++]{\CC{}}, the name-mangling issue is often handled internally in many C header-files through checks for preprocessor variable ©__cplusplus©, which adds appropriate ©extern "C"© qualifiers.
     5628For \Index*[C++]{\CC{}}, the name-mangling issue is handled implicitly because most C header-files are augmented with checks for preprocessor variable ©__cplusplus©, which adds appropriate ©extern "C"© qualifiers.
    59005629
    59015630
     
    59075636
    59085637\subsection{Storage Management}
    5909 \label{s:StorageManagement}
    59105638
    59115639The storage-management routines extend their C equivalents by overloading, alternate names, providing shallow type-safety, and removing the need to specify the allocation size for non-array types.
     
    59275655The table shows allocation routines supporting different combinations of storage-management capabilities:
    59285656\begin{center}
    5929 \begin{tabular}{@{}r|r|l|l|l|l@{}}
    5930 \multicolumn{1}{c}{}&           & \multicolumn{1}{c|}{fill}     & resize        & alignment     & array \\
     5657\begin{tabular}{@{}lr|l|l|l|l@{}}
     5658                &                                       & \multicolumn{1}{c|}{fill}     & resize        & alignment     & array \\
    59315659\hline
    59325660C               & ©malloc©                      & no                    & no            & no            & no    \\
     
    59355663                & ©memalign©            & no                    & no            & yes           & no    \\
    59365664                & ©posix_memalign©      & no                    & no            & yes           & no    \\
    5937 \hline
    59385665C11             & ©aligned_alloc©       & no                    & no            & yes           & no    \\
    5939 \hline
    59405666\CFA    & ©alloc©                       & no/copy/yes   & no/yes        & no            & yes   \\
    59415667                & ©align_alloc©         & no/yes                & no            & yes           & yes   \\
     
    61215847long double remainder( long double, long double );
    61225848
    6123 float remquo( float, float, int * );§\indexc{remquo}§
     5849[ int, float ] remquo( float, float );§\indexc{remquo}§
     5850float remquo( float, float, int * );
     5851[ int, double ] remquo( double, double );
    61245852double remquo( double, double, int * );
     5853[ int, long double ] remquo( long double, long double );
    61255854long double remquo( long double, long double, int * );
    6126 [ int, float ] remquo( float, float );
    6127 [ int, double ] remquo( double, double );
    6128 [ int, long double ] remquo( long double, long double );
    6129 
    6130 float div( float, float, int * );§\indexc{div}§ §\C{// alternative name for remquo}§
     5855
     5856[ int, float ] div( float, float );                                             // alternative name for remquo
     5857float div( float, float, int * );§\indexc{div}§
     5858[ int, double ] div( double, double );
    61315859double div( double, double, int * );
     5860[ int, long double ] div( long double, long double );
    61325861long double div( long double, long double, int * );
    6133 [ int, float ] div( float, float );
    6134 [ int, double ] div( double, double );
    6135 [ int, long double ] div( long double, long double );
    61365862
    61375863float fma( float, float, float );§\indexc{fma}§
     
    61635889double exp2( double );
    61645890long double exp2( long double );
    6165 // float _Complex exp2( float _Complex );
    6166 // double _Complex exp2( double _Complex );
    6167 // long double _Complex exp2( long double _Complex );
     5891float _Complex exp2( float _Complex );
     5892double _Complex exp2( double _Complex );
     5893long double _Complex exp2( long double _Complex );
    61685894
    61695895float expm1( float );§\indexc{expm1}§
    61705896double expm1( double );
    61715897long double expm1( long double );
     5898
     5899float log( float );§\indexc{log}§
     5900double log( double );
     5901long double log( long double );
     5902float _Complex log( float _Complex );
     5903double _Complex log( double _Complex );
     5904long double _Complex log( long double _Complex );
     5905
     5906float log2( float );§\indexc{log2}§
     5907double log2( double );
     5908long double log2( long double );
     5909float _Complex log2( float _Complex );
     5910double _Complex log2( double _Complex );
     5911long double _Complex log2( long double _Complex );
     5912
     5913float log10( float );§\indexc{log10}§
     5914double log10( double );
     5915long double log10( long double );
     5916float _Complex log10( float _Complex );
     5917double _Complex log10( double _Complex );
     5918long double _Complex log10( long double _Complex );
     5919
     5920float log1p( float );§\indexc{log1p}§
     5921double log1p( double );
     5922long double log1p( long double );
     5923
     5924int ilogb( float );§\indexc{ilogb}§
     5925int ilogb( double );
     5926int ilogb( long double );
     5927
     5928float logb( float );§\indexc{logb}§
     5929double logb( double );
     5930long double logb( long double );
     5931\end{cfa}
     5932
     5933
     5934\subsection{Power}
     5935
     5936\leavevmode
     5937\begin{cfa}[aboveskip=0pt,belowskip=0pt]
     5938float sqrt( float );§\indexc{sqrt}§
     5939double sqrt( double );
     5940long double sqrt( long double );
     5941float _Complex sqrt( float _Complex );
     5942double _Complex sqrt( double _Complex );
     5943long double _Complex sqrt( long double _Complex );
     5944
     5945float cbrt( float );§\indexc{cbrt}§
     5946double cbrt( double );
     5947long double cbrt( long double );
     5948
     5949float hypot( float, float );§\indexc{hypot}§
     5950double hypot( double, double );
     5951long double hypot( long double, long double );
    61725952
    61735953float pow( float, float );§\indexc{pow}§
     
    61775957double _Complex pow( double _Complex, double _Complex );
    61785958long double _Complex pow( long double _Complex, long double _Complex );
    6179 \end{cfa}
    6180 
    6181 
    6182 \subsection{Logarithm}
    6183 
    6184 \leavevmode
    6185 \begin{cfa}[aboveskip=0pt,belowskip=0pt]
    6186 float log( float );§\indexc{log}§
    6187 double log( double );
    6188 long double log( long double );
    6189 float _Complex log( float _Complex );
    6190 double _Complex log( double _Complex );
    6191 long double _Complex log( long double _Complex );
    6192 
    6193 float log2( float );§\indexc{log2}§
    6194 double log2( double );
    6195 long double log2( long double );
    6196 // float _Complex log2( float _Complex );
    6197 // double _Complex log2( double _Complex );
    6198 // long double _Complex log2( long double _Complex );
    6199 
    6200 float log10( float );§\indexc{log10}§
    6201 double log10( double );
    6202 long double log10( long double );
    6203 // float _Complex log10( float _Complex );
    6204 // double _Complex log10( double _Complex );
    6205 // long double _Complex log10( long double _Complex );
    6206 
    6207 float log1p( float );§\indexc{log1p}§
    6208 double log1p( double );
    6209 long double log1p( long double );
    6210 
    6211 int ilogb( float );§\indexc{ilogb}§
    6212 int ilogb( double );
    6213 int ilogb( long double );
    6214 
    6215 float logb( float );§\indexc{logb}§
    6216 double logb( double );
    6217 long double logb( long double );
    6218 
    6219 float sqrt( float );§\indexc{sqrt}§
    6220 double sqrt( double );
    6221 long double sqrt( long double );
    6222 float _Complex sqrt( float _Complex );
    6223 double _Complex sqrt( double _Complex );
    6224 long double _Complex sqrt( long double _Complex );
    6225 
    6226 float cbrt( float );§\indexc{cbrt}§
    6227 double cbrt( double );
    6228 long double cbrt( long double );
    6229 
    6230 float hypot( float, float );§\indexc{hypot}§
    6231 double hypot( double, double );
    6232 long double hypot( long double, long double );
    62335959\end{cfa}
    62345960
     
    62846010long double atan2( long double, long double );
    62856011
    6286 float atan( float, float );                                     §\C{// alternative name for atan2}§
     6012float atan( float, float );                                                             // alternative name for atan2
    62876013double atan( double, double );§\indexc{atan}§
    62886014long double atan( long double, long double );
     
    64726198
    64736199\begin{cfa}
    6474 void ?{}( Int * this );                                 §\C{// constructor/destructor
     6200void ?{}( Int * this );                                 §\C{// constructor
    64756201void ?{}( Int * this, Int init );
    64766202void ?{}( Int * this, zero_t );
     
    67276453// implementation
    67286454struct Rational {§\indexc{Rational}§
    6729         long int numerator, denominator;        §\C{// invariant: denominator > 0}§
     6455        long int numerator, denominator;                                        // invariant: denominator > 0
    67306456}; // Rational
    67316457
  • doc/working/resolver_design.md

    r0720e049 r3d4b23fa  
    9191## Conversion Costs ##
    9292Each possible resolution of an expression has a _cost_ tuple consisting of
    93 the following components:
    94 1. _unsafe_ conversion cost: summed degree of unsafe conversions; unlike CFA03, this is not a simple count of conversions (for symmetry with the safe conversions)
    95 2. _polymorphic unifications_: count of parameters and return values bound to some polymorphic type for boxing
    96 3. _type variables_: number of polymorphic type variables bound
    97 4. negated _type specializations_: Each type assertion specializes the polymorphism, thus decreasing the cost; nested polymorphic types (e.g. `T*`) are also counted as specializations
    98 5. _safe_ conversions: summed degree of safe conversions
    99 6. _qualifier_ conversions: summed degree of qualifier and reference conversions
     93the following components: _unsafe_ conversion cost, _polymorphic_
     94specialization cost, _safe_ conversion cost, a count of _explicit_
     95conversions, and _qualifier_ conversion cost.
    10096These components are lexically-ordered and can be summed element-wise;
    10197summation starts at `(0, 0, 0, 0, 0)`.
    102 
    103 **TODO** update below for consistency with this
    10498
    10599### Lvalue and Qualifier Conversions ###
  • src/CodeGen/CodeGenerator.cc

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Tus Jul 25 15:29:00 2017
    13 // Update Count     : 486
     12// Last Modified On : Thu Jun  8 16:00:00 2017
     13// Update Count     : 485
    1414//
    15 #include "CodeGenerator.h"
    1615
    1716#include <cassert>                   // for assert, assertf
    1817#include <list>                      // for _List_iterator, list, list<>::it...
    1918
     19#include "CodeGenerator.h"
    2020#include "Common/SemanticError.h"    // for SemanticError
    2121#include "Common/UniqueName.h"       // for UniqueName
     
    586586        }
    587587
    588         void CodeGenerator::visit( VirtualCastExpr * castExpr ) {
    589                 assertf( ! genC, "VirtualCastExpr should not reach code generation." );
    590                 extension( castExpr );
    591                 output << "(virtual ";
    592                 castExpr->get_arg()->accept( *this );
    593                 output << ")";
    594         }
    595 
    596588        void CodeGenerator::visit( UntypedMemberExpr * memberExpr ) {
    597589                assertf( ! genC, "UntypedMemberExpr should not reach code generation." );
  • src/CodeGen/CodeGenerator.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Tus Jul 25 25:30:00 2017
    13 // Update Count     : 54
     12// Last Modified On : Thu Jun  8 15:48:00 2017
     13// Update Count     : 52
    1414//
    1515
    16 #pragma once
     16#ifndef CODEGENV_H
     17#define CODEGENV_H
    1718
    1819#include <list>                   // for list
     
    5960                virtual void visit( AddressExpr *addressExpr );
    6061                virtual void visit( CastExpr *castExpr );
    61                 virtual void visit( VirtualCastExpr *castExpr );
    6262                virtual void visit( UntypedMemberExpr *memberExpr );
    6363                virtual void visit( MemberExpr *memberExpr );
     
    159159} // namespace CodeGen
    160160
     161#endif // CODEGENV_H
     162
    161163// Local Variables: //
    162164// tab-width: 4 //
  • src/CodeGen/FixMain.h

    r0720e049 r3d4b23fa  
    99// Author           : Thierry Delisle
    1010// Created On       : Thr Jan 12 14:11:09 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:16:59 2017
    13 // Update Count     : 1
     11// Last Modified By :
     12// Last Modified On :
     13// Update Count     : 0
    1414//
    1515
    16 #pragma once
     16#ifndef FIXMAIN_H
     17#define FIXMAIN_H
    1718
    1819#include <iosfwd>
     
    4344        };
    4445};
     46
     47#endif //FIXMAIN_H
  • src/CodeGen/FixNames.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:17:33 2017
    13 // Update Count     : 3
     12// Last Modified On : Mon May 18 23:37:32 2015
     13// Update Count     : 2
    1414//
    1515
    16 #pragma once
     16#ifndef FIXNAMES_H
     17#define FIXNAMES_H
    1718
    1819#include <list>  // for list
     
    2526} // namespace CodeGen
    2627
     28#endif // FIXNAMES_H
     29
    2730// Local Variables: //
    2831// tab-width: 4 //
  • src/CodeGen/GenType.cc

    r0720e049 r3d4b23fa  
    1313// Update Count     : 22
    1414//
    15 #include "GenType.h"
    1615
    1716#include <cassert>                // for assert, assertf
     
    2019
    2120#include "CodeGenerator.h"        // for CodeGenerator
     21#include "GenType.h"
    2222#include "SynTree/Declaration.h"  // for DeclarationWithType
    2323#include "SynTree/Expression.h"   // for Expression
  • src/CodeGen/GenType.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:17:23 2017
    13 // Update Count     : 2
     12// Last Modified On : Mon May 18 23:38:53 2015
     13// Update Count     : 1
    1414//
    1515
    16 #pragma once
     16#ifndef _GENTYPE_H
     17#define _GENTYPE_H
    1718
    1819#include <string>  // for string
     
    2526} // namespace CodeGen
    2627
     28#endif // _GENTYPE_H
     29
    2730// Local Variables: //
    2831// tab-width: 4 //
  • src/CodeGen/Generate.cc

    r0720e049 r3d4b23fa  
    1313// Update Count     : 6
    1414//
    15 #include "Generate.h"
    1615
    1716#include <iostream>                  // for ostream, endl, operator<<
     
    2120#include "CodeGenerator.h"           // for CodeGenerator, doSemicolon, oper...
    2221#include "GenType.h"                 // for genPrettyType
     22#include "Generate.h"
    2323#include "Parser/LinkageSpec.h"      // for isBuiltin, isGeneratable
    2424#include "SynTree/BaseSyntaxNode.h"  // for BaseSyntaxNode
  • src/CodeGen/Generate.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:16:35 2017
    13 // Update Count     : 2
     12// Last Modified On : Mon May 18 23:39:51 2015
     13// Update Count     : 1
    1414//
    1515
    16 #pragma once
     16#ifndef GENERATE_H
     17#define GENERATE_H
    1718
    1819#include <iostream>  // for ostream
     
    3031} // namespace CodeGen
    3132
     33#endif // GENERATE_H
     34
    3235// Local Variables: //
    3336// tab-width: 4 //
  • src/CodeGen/OperatorTable.cc

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 15 17:12:22 2017
    13 // Update Count     : 15
     12// Last Modified On : Tue Dec 13 14:33:05 2016
     13// Update Count     : 10
    1414//
    1515
     
    3535                        {       "++?",          "++",   "_operator_preincr",                    OT_PREFIXASSIGN         },
    3636                        {       "--?",          "--",   "_operator_predecr",                    OT_PREFIXASSIGN         },
    37                         {       "?\\?",         "\\",   "_operator_exponential",                OT_INFIX                        },
    3837                        {       "?*?",          "*",    "_operator_multiply",                   OT_INFIX                        },
    3938                        {       "?/?",          "/",    "_operator_divide",                             OT_INFIX                        },
     
    5352                        {       "?|?",          "|",    "_operator_bitor",                              OT_INFIX                        },
    5453                        {       "?=?",          "=",    "_operator_assign",                             OT_INFIXASSIGN          },
    55                         {       "?\\=?",        "\\=",  "_operator_expassign",                  OT_INFIXASSIGN          },
    5654                        {       "?*=?",         "*=",   "_operator_multassign",                 OT_INFIXASSIGN          },
    5755                        {       "?/=?",         "/=",   "_operator_divassign",                  OT_INFIXASSIGN          },
  • src/CodeGen/OperatorTable.h

    r0720e049 r3d4b23fa  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:17:11 2017
    13 // Update Count     : 6
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Jun 24 16:17:57 2015
     13// Update Count     : 5
    1414//
    1515
    16 #pragma once
     16#ifndef _OPERATORTABLE_H
     17#define _OPERATORTABLE_H
    1718
    1819#include <string>
     
    4445} // namespace CodeGen
    4546
     47#endif // _OPERATORTABLE_H
     48
    4649// Local Variables: //
    4750// tab-width: 4 //
  • src/CodeTools/DeclStats.h

    r0720e049 r3d4b23fa  
    99// Author           : Aaron Moss
    1010// Created On       : Wed Jan 31 16:40:00 2016
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:17:56 2017
    13 // Update Count     : 2
     11// Last Modified By : Aaron Moss
     12// Last Modified On : Wed Jan 31 16:40:00 2016
     13// Update Count     : 1
    1414//
    1515
    16 #pragma once
     16#ifndef DECLSTATS_H
     17#define DECLSTATS_H
    1718
    1819#include <list>  // for list
     
    2728}  // namespace CodeTools
    2829
     30#endif // DECLSTATS_H
     31
    2932// Local Variables: //
    3033// tab-width: 4 //
  • src/CodeTools/TrackLoc.cc

    r0720e049 r3d4b23fa  
    1616#include "TrackLoc.h"
    1717
    18 #include <cstdlib>                   // for exit, EXIT_FAILURE
    19 #include <iostream>                  // for operator<<, ostream, basic_ostream
    20 #include <stack>                     // for stack
    21 #include <string>                    // for operator<<, string
    22 #include <typeindex>                 // for type_index
     18#include <cstdlib>                    // for size_t, exit, EXIT_FAILURE
     19#include <iostream>                   // for operator<<, ostream, basic_ostream
     20#include <iterator>                   // for back_inserter, inserter
     21#include <stack>                      // for stack
     22#include <string>                     // for operator<<, string
     23#include <typeindex>                  // for type_index
    2324
    24 #include "Common/PassVisitor.h"      // for PassVisitor
    25 #include "Common/utility.h"          // for CodeLocation
    26 #include "SynTree/BaseSyntaxNode.h"  // for BaseSyntaxNode
     25#include "Common/PassVisitor.h"       // for PassVisitor
     26#include "Common/PassVisitor.impl.h"  // for acceptAll
     27#include "Common/SemanticError.h"     // for SemanticError
     28#include "Common/utility.h"           // for CodeLocation
     29#include "SynTree/BaseSyntaxNode.h"   // for BaseSyntaxNode
     30#include "SynTree/Mutator.h"          // for mutateAll
     31#include "SynTree/Visitor.h"          // for acceptAll
    2732
    2833class Declaration;
     
    4146                std::stack< CodeLocation * > parents;
    4247        public:
    43                 LocationPrinter(size_t printLevel) :
     48                LocationPrinter(size_t printLevel) : 
    4449                        printLevel(printLevel), lastNode(nullptr)
    4550                {}
     
    6065                                if ( !parents.empty() ) {
    6166                                        node->location = *parents.top();
    62                                 }
     67                                } 
    6368                                else if (nullptr != lastNode) {
    6469                                        node->location = *lastNode;
    65                                 }
     70                                } 
    6671                                else {
    6772                                        std::cerr << "Top level node has no CodeLocation " << name << std::endl;
  • src/CodeTools/TrackLoc.h

    r0720e049 r3d4b23fa  
    99// Author           : Andrew Beach
    1010// Created On       : Tues May 2 15:40:00 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:17:44 2017
    13 // Update Count     : 1
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed May 3 14:42:00 2017
     13// Update Count     : 0
    1414//
    1515
    16 #pragma once
     16#ifndef TRACKLOC_H
     17#define TRACKLOC_H
    1718
    1819#include <cstddef>   // for size_t
     
    3031}  // namespace CodeTools
    3132
     33#endif // TRACKLOC_H
     34
    3235// Local Variables: //
    3336// tab-width: 4 //
  • src/Common/CompilerError.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:18:07 2017
    13 // Update Count     : 4
     12// Last Modified On : Thu Aug 18 23:41:30 2016
     13// Update Count     : 3
    1414//
    1515
    16 #pragma once
     16#ifndef COMPILER_ERROR_H
     17#define COMPILER_ERROR_H
    1718
    1819#include <string>
     
    3031};
    3132
     33#endif // COMPILER_ERROR_H
     34
    3235// Local Variables: //
    3336// tab-width: 4 //
  • src/Common/PassVisitor.h

    r0720e049 r3d4b23fa  
    8181        virtual void visit( NameExpr *nameExpr ) override final;
    8282        virtual void visit( CastExpr *castExpr ) override final;
    83         virtual void visit( VirtualCastExpr *castExpr ) override final;
    8483        virtual void visit( AddressExpr *addressExpr ) override final;
    8584        virtual void visit( LabelAddressExpr *labAddressExpr ) override final;
     
    169168        virtual Expression* mutate( LabelAddressExpr *labAddressExpr ) override final;
    170169        virtual Expression* mutate( CastExpr *castExpr ) override final;
    171         virtual Expression* mutate( VirtualCastExpr *castExpr ) override final;
    172170        virtual Expression* mutate( UntypedMemberExpr *memberExpr ) override final;
    173171        virtual Expression* mutate( MemberExpr *memberExpr ) override final;
  • src/Common/PassVisitor.impl.h

    r0720e049 r3d4b23fa  
    11#pragma once
    2 // IWYU pragma: private, include "PassVisitor.h"
    32
    43#define VISIT_START( node )                     \
     
    607606
    608607template< typename pass_type >
    609 void PassVisitor< pass_type >::visit( VirtualCastExpr * node ) {
    610         VISIT_BODY( node );
    611 }
    612 
    613 template< typename pass_type >
    614608void PassVisitor< pass_type >::visit( AddressExpr * node ) {
    615609        VISIT_BODY( node );
     
    984978
    985979template< typename pass_type >
    986 Expression * PassVisitor< pass_type >::mutate( VirtualCastExpr * node ) {
    987         MUTATE_BODY( Expression, node );
    988 }
    989 
    990 template< typename pass_type >
    991980Expression * PassVisitor< pass_type >::mutate( UntypedMemberExpr * node ) {
    992981        MUTATE_BODY( Expression, node );
  • src/Common/PassVisitor.proto.h

    r0720e049 r3d4b23fa  
    11#pragma once
    2 // IWYU pragma: private, include "PassVisitor.h"
    32
    43template<typename pass_type>
  • src/Common/ScopedMap.h

    r0720e049 r3d4b23fa  
    99// Author           : Aaron B. Moss
    1010// Created On       : Wed Dec 2 11:37:00 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:18:24 2017
    13 // Update Count     : 2
    14 //
    15 
    16 #pragma once
     11// Last Modified By : Aaron B. Moss
     12// Last Modified On : Wed Dec 2 11:37:00 2015
     13// Update Count     : 1
     14//
     15
     16#ifndef _SCOPEDMAP_H
     17#define _SCOPEDMAP_H
    1718
    1819#include <cassert>
     
    304305};
    305306
     307#endif // _SCOPEDMAP_H
     308
    306309// Local Variables: //
    307310// tab-width: 4 //
  • src/Common/SemanticError.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:18:59 2017
    13 // Update Count     : 6
     12// Last Modified On : Sat Sep 24 15:13:42 2016
     13// Update Count     : 5
    1414//
    1515
    16 #pragma once
     16#ifndef SEMANTICERROR_H
     17#define SEMANTICERROR_H
    1718
    1819#include <exception>  // for exception
     
    6162}
    6263
     64#endif // SEMANTICERROR_H
     65
    6366// Local Variables: //
    6467// tab-width: 4 //
  • src/Common/UnimplementedError.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:18:35 2017
    13 // Update Count     : 2
     12// Last Modified On : Tue May 19 07:23:08 2015
     13// Update Count     : 1
    1414//
    1515
    16 #pragma once
     16#ifndef _UNIMPLEMENTEDERROR_H
     17#define _UNIMPLEMENTEDERROR_H
    1718
    1819#include <string>
     
    3031};
    3132
     33#endif // _UNIMPLEMENTEDERROR_H
     34
    3235// Local Variables: //
    3336// tab-width: 4 //
  • src/Common/UniqueName.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:18:45 2017
    13 // Update Count     : 2
     12// Last Modified On : Tue May 19 07:24:20 2015
     13// Update Count     : 1
    1414//
    1515
    16 #pragma once
     16#ifndef UNIQUENAME_H
     17#define UNIQUENAME_H
    1718
    1819#include <string>
     
    2728};
    2829
     30#endif // UNIQUENAME_H
     31
    2932// Local Variables: //
    3033// tab-width: 4 //
  • src/Common/VectorMap.h

    r0720e049 r3d4b23fa  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // VectorMap.h --
     7// ScopedMap.h --
    88//
    99// Author           : Aaron B. Moss
    1010// Created On       : Wed Feb  1 16:55:00 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:19:29 2017
    13 // Update Count     : 2
    14 //
    15 
    16 #pragma once
     11// Last Modified By : Aaron B. Moss
     12// Last Modified On : Wed Feb  1 16:55:00 2017
     13// Update Count     : 1
     14//
     15
     16#ifndef _VECTORMAP_H
     17#define _VECTORMAP_H
    1718
    1819#include <iterator>
     
    244245}
    245246
     247#endif // _VECTORMAP_H
     248
    246249// Local Variables: //
    247250// tab-width: 4 //
  • src/Common/utility.h

    r0720e049 r3d4b23fa  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:19:13 2017
    13 // Update Count     : 33
    14 //
    15 
    16 #pragma once
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Fri May 5 11:03:00 2017
     13// Update Count     : 32
     14//
     15
     16#ifndef _UTILITY_H
     17#define _UTILITY_H
    1718
    1819#include <cctype>
     
    378379}
    379380
     381#endif // _UTILITY_H
     382
    380383// Local Variables: //
    381384// tab-width: 4 //
  • src/Concurrency/Keywords.cc

    r0720e049 r3d4b23fa  
     1//                              -*- Mode: CPP -*-
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    1112// Last Modified By :
    1213// Last Modified On :
    13 // Update Count     : 5
     14// Update Count     : 3
    1415//
    1516
     
    548549        }
    549550};
    550 
    551 // Local Variables: //
    552 // mode: c //
    553 // tab-width: 4 //
    554 // End: //
  • src/Concurrency/Keywords.h

    r0720e049 r3d4b23fa  
     1//                              -*- Mode: CPP -*-
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    1112// Last Modified By :
    1213// Last Modified On :
    13 // Update Count     : 1
     14// Update Count     : 0
    1415//
    1516
    16 #pragma once
     17#ifndef KEYWORDS_H
     18#define KEYWORDS_H
    1719
    1820#include <list>  // for list
     
    2628};
    2729
    28 // Local Variables: //
    29 // tab-width: 4 //
    30 // mode: c++ //
    31 // compile-command: "make install" //
    32 // End: //
     30#endif //KEYWORDS_H
  • src/ControlStruct/ExceptTranslate.cc

    r0720e049 r3d4b23fa  
    1010// Created On       : Wed Jun 14 16:49:00 2017
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Tus Aug  8 16:54:00 2017
    13 // Update Count     : 7
     12// Last Modified On : Wed Jul 12 15:07:00 2017
     13// Update Count     : 3
    1414//
    1515
     
    2121#include "SynTree/Type.h"
    2222#include "SynTree/Attribute.h"
    23 #include "SynTree/VarExprReplacer.h"
    2423
    2524namespace ControlStruct {
     25
     26        // This (large) section could probably be moved out of the class
     27        // and be static helpers instead.
     28
     29        // Type(Qualifiers &, false, std::list<Attribute *> &)
     30
     31        // void (*function)();
     32        static FunctionType try_func_t(Type::Qualifiers(), false);
     33        // void (*function)(int, exception);
     34        static FunctionType catch_func_t(Type::Qualifiers(), false);
     35        // int (*function)(exception);
     36        static FunctionType match_func_t(Type::Qualifiers(), false);
     37        // bool (*function)(exception);
     38        static FunctionType handle_func_t(Type::Qualifiers(), false);
     39        // void (*function)(__attribute__((unused)) void *);
     40        static FunctionType finally_func_t(Type::Qualifiers(), false);
     41
     42        static void init_func_types() {
     43                static bool init_complete = false;
     44                if (init_complete) {
     45                        return;
     46                }
     47                ObjectDecl index_obj(
     48                        "__handler_index",
     49                        Type::StorageClasses(),
     50                        LinkageSpec::Cforall,
     51                        /*bitfieldWidth*/ NULL,
     52                        new BasicType( emptyQualifiers, BasicType::SignedInt ),
     53                        /*init*/ NULL
     54                        );
     55                ObjectDecl exception_obj(
     56                        "__exception_inst",
     57                        Type::StorageClasses(),
     58                        LinkageSpec::Cforall,
     59                        /*bitfieldWidth*/ NULL,
     60                        new PointerType(
     61                                emptyQualifiers,
     62                                new BasicType( emptyQualifiers, BasicType::SignedInt )
     63                                ),
     64                        /*init*/ NULL
     65                        );
     66                ObjectDecl bool_obj(
     67                        "__ret_bool",
     68                        Type::StorageClasses(),
     69                        LinkageSpec::Cforall,
     70                        /*bitfieldWidth*/ NULL,
     71                        new BasicType(emptyQualifiers, BasicType::Bool),
     72                        /*init*/ NULL
     73                        );
     74                ObjectDecl voidptr_obj(
     75                        "__hook",
     76                        Type::StorageClasses(),
     77                        LinkageSpec::Cforall,
     78                        NULL,
     79                        new PointerType(
     80                                emptyQualifiers,
     81                                new VoidType(
     82                                        emptyQualifiers
     83                                        ),
     84                                std::list<Attribute *>{new Attribute("unused")}
     85                                ),
     86                        NULL
     87                        );
     88
     89                catch_func_t.get_parameters().push_back( index_obj.clone() );
     90                catch_func_t.get_parameters().push_back( exception_obj.clone() );
     91                match_func_t.get_returnVals().push_back( index_obj.clone() );
     92                match_func_t.get_parameters().push_back( exception_obj.clone() );
     93                handle_func_t.get_returnVals().push_back( bool_obj.clone() );
     94                handle_func_t.get_parameters().push_back( exception_obj.clone() );
     95                finally_func_t.get_parameters().push_back( voidptr_obj.clone() );
     96
     97                init_complete = true;
     98        }
    2699
    27100        // Buricratic Helpers (Not having to do with the paritular operation.)
     
    42115        }
    43116
     117        template<typename T>
     118        void free_all( std::list<T *> &list ) {
     119                typename std::list<T *>::iterator it;
     120                for ( it = list.begin() ; it != list.end() ; ++it ) {
     121                        delete *it;
     122                }
     123                list.clear();
     124        }
     125
    44126        void appendDeclStmt( CompoundStmt * block, Declaration * item ) {
    45127                block->push_back(new DeclStmt(noLabels, item));
     
    50132        }
    51133
    52         class ExceptionMutatorCore : public WithGuards {
    53                 enum Context { NoHandler, TerHandler, ResHandler };
    54 
    55                 // Also need to handle goto, break & continue.
    56                 // They need to be cut off in a ResHandler, until we enter another
    57                 // loop, switch or the goto stays within the function.
    58 
    59                 Context cur_context;
    60 
    61                 // The current (innermost) termination handler exception declaration.
    62                 ObjectDecl * handler_except_decl;
    63 
    64                 // The built in types used in translation.
    65                 StructDecl * except_decl;
    66                 StructDecl * node_decl;
    67                 StructDecl * hook_decl;
    68 
    69                 // The many helper functions for code/syntree generation.
    70                 Statement * create_given_throw(
    71                         const char * throwFunc, ThrowStmt * throwStmt );
    72                 Statement * create_terminate_throw( ThrowStmt * throwStmt );
    73                 Statement * create_terminate_rethrow( ThrowStmt * throwStmt );
    74                 Statement * create_resume_throw( ThrowStmt * throwStmt );
    75                 Statement * create_resume_rethrow( ThrowStmt * throwStmt );
    76                 CompoundStmt * take_try_block( TryStmt * tryStmt );
    77                 FunctionDecl * create_try_wrapper( CompoundStmt * body );
    78                 FunctionDecl * create_terminate_catch( CatchList &handlers );
    79                 CompoundStmt * create_single_matcher(
    80                         DeclarationWithType * except_obj, CatchStmt * modded_handler );
    81                 FunctionDecl * create_terminate_match( CatchList &handlers );
    82                 CompoundStmt * create_terminate_caller( FunctionDecl * try_wrapper,
    83                         FunctionDecl * terminate_catch, FunctionDecl * terminate_match );
    84                 FunctionDecl * create_resume_handler( CatchList &handlers );
    85                 CompoundStmt * create_resume_wrapper(
    86                         Statement * wraps, FunctionDecl * resume_handler );
    87                 FunctionDecl * create_finally_wrapper( TryStmt * tryStmt );
    88                 ObjectDecl * create_finally_hook( FunctionDecl * finally_wrapper );
    89 
    90                 // Types used in translation, make sure to use clone.
    91                 // void (*function)();
    92                 FunctionType try_func_t;
    93                 // void (*function)(int, exception);
    94                 FunctionType catch_func_t;
    95                 // int (*function)(exception);
    96                 FunctionType match_func_t;
    97                 // bool (*function)(exception);
    98                 FunctionType handle_func_t;
    99                 // void (*function)(__attribute__((unused)) void *);
    100                 FunctionType finally_func_t;
    101 
    102                 StructInstType * create_except_type() {
    103                         assert( except_decl );
    104                         return new StructInstType( noQualifiers, except_decl );
    105                 }
    106                 void init_func_types();
    107 
    108         public:
    109                 ExceptionMutatorCore() :
    110                         cur_context( NoHandler ),
    111                         handler_except_decl( nullptr ),
    112                         except_decl( nullptr ), node_decl( nullptr ), hook_decl( nullptr ),
    113                         try_func_t( noQualifiers, false ),
    114                         catch_func_t( noQualifiers, false ),
    115                         match_func_t( noQualifiers, false ),
    116                         handle_func_t( noQualifiers, false ),
    117                         finally_func_t( noQualifiers, false )
    118                 {}
    119 
    120                 void premutate( CatchStmt *catchStmt );
    121                 void premutate( StructDecl *structDecl );
    122                 Statement * postmutate( ThrowStmt *throwStmt );
    123                 Statement * postmutate( TryStmt *tryStmt );
    124         };
    125 
    126         void ExceptionMutatorCore::init_func_types() {
    127                 assert( except_decl );
    128 
    129                 ObjectDecl index_obj(
    130                         "__handler_index",
    131                         Type::StorageClasses(),
    132                         LinkageSpec::Cforall,
    133                         /*bitfieldWidth*/ NULL,
    134                         new BasicType( noQualifiers, BasicType::SignedInt ),
    135                         /*init*/ NULL
    136                         );
    137                 ObjectDecl exception_obj(
    138                         "__exception_inst",
    139                         Type::StorageClasses(),
    140                         LinkageSpec::Cforall,
    141                         /*bitfieldWidth*/ NULL,
    142                         new PointerType(
    143                                 noQualifiers,
    144                                 new StructInstType( noQualifiers, except_decl )
    145                                 ),
    146                         /*init*/ NULL
    147                         );
    148                 ObjectDecl bool_obj(
    149                         "__ret_bool",
    150                         Type::StorageClasses(),
    151                         LinkageSpec::Cforall,
    152                         /*bitfieldWidth*/ NULL,
    153                         new BasicType( noQualifiers, BasicType::Bool ),
    154                         /*init*/ NULL
    155                         );
    156                 ObjectDecl voidptr_obj(
    157                         "__hook",
     134        // ThrowStmt Mutation Helpers
     135
     136        Statement * create_given_throw(
     137                        const char * throwFunc, ThrowStmt * throwStmt ) {
     138                // { int NAME = EXPR; throwFunc( &NAME ); }
     139                CompoundStmt * result = new CompoundStmt( noLabels );
     140                ObjectDecl * local = new ObjectDecl(
     141                        "__local_exception_copy",
    158142                        Type::StorageClasses(),
    159143                        LinkageSpec::Cforall,
    160144                        NULL,
    161                         new PointerType(
    162                                 noQualifiers,
    163                                 new VoidType(
    164                                         noQualifiers
    165                                         ),
    166                                 std::list<Attribute *>{ new Attribute( "unused" ) }
    167                                 ),
    168                         NULL
    169                         );
    170 
    171                 catch_func_t.get_parameters().push_back( index_obj.clone() );
    172                 catch_func_t.get_parameters().push_back( exception_obj.clone() );
    173                 match_func_t.get_returnVals().push_back( index_obj.clone() );
    174                 match_func_t.get_parameters().push_back( exception_obj.clone() );
    175                 handle_func_t.get_returnVals().push_back( bool_obj.clone() );
    176                 handle_func_t.get_parameters().push_back( exception_obj.clone() );
    177                 finally_func_t.get_parameters().push_back( voidptr_obj.clone() );
    178         }
    179 
    180         // ThrowStmt Mutation Helpers
    181 
    182         Statement * ExceptionMutatorCore::create_given_throw(
    183                         const char * throwFunc, ThrowStmt * throwStmt ) {
    184                 // `throwFunc`( `throwStmt->get_name` );
     145                        new BasicType( emptyQualifiers, BasicType::SignedInt ),
     146                        new SingleInit( throwStmt->get_expr() )
     147                        );
     148                appendDeclStmt( result, local );
    185149                UntypedExpr * call = new UntypedExpr( new NameExpr( throwFunc ) );
    186                 call->get_args().push_back( throwStmt->get_expr() );
     150                call->get_args().push_back( new AddressExpr( nameOf( local ) ) );
     151                result->push_back( new ExprStmt( throwStmt->get_labels(), call ) );
    187152                throwStmt->set_expr( nullptr );
    188153                delete throwStmt;
    189                 return new ExprStmt( noLabels, call );
    190         }
    191 
    192         Statement * ExceptionMutatorCore::create_terminate_throw(
    193                         ThrowStmt *throwStmt ) {
    194                 // __throw_terminate( `throwStmt->get_name()` ); }
     154                return result;
     155        }
     156
     157        Statement * create_terminate_throw( ThrowStmt *throwStmt ) {
     158                // { int NAME = EXPR; __throw_terminate( &NAME ); }
    195159                return create_given_throw( "__cfaehm__throw_terminate", throwStmt );
    196160        }
    197 
    198         Statement * ExceptionMutatorCore::create_terminate_rethrow(
    199                         ThrowStmt *throwStmt ) {
    200                 // { `handler_except_decl` = NULL; __rethrow_terminate(); }
     161        Statement * create_terminate_rethrow( ThrowStmt *throwStmt ) {
     162                // __rethrow_terminate();
    201163                assert( nullptr == throwStmt->get_expr() );
    202                 assert( handler_except_decl );
    203 
    204                 CompoundStmt * result = new CompoundStmt( throwStmt->get_labels() );
    205                 result->push_back( new ExprStmt( noLabels, UntypedExpr::createAssign(
    206                         nameOf( handler_except_decl ),
    207                         new ConstantExpr( Constant::null(
    208                                 new PointerType(
    209                                         noQualifiers,
    210                                         handler_except_decl->get_type()->clone()
    211                                         )
    212                                 ) )
    213                         ) ) );
    214                 result->push_back( new ExprStmt(
    215                         noLabels,
     164                Statement * result = new ExprStmt(
     165                        throwStmt->get_labels(),
    216166                        new UntypedExpr( new NameExpr( "__cfaehm__rethrow_terminate" ) )
    217                         ) );
     167                        );
    218168                delete throwStmt;
    219169                return result;
    220170        }
    221 
    222         Statement * ExceptionMutatorCore::create_resume_throw(
    223                         ThrowStmt *throwStmt ) {
    224                 // __throw_resume( `throwStmt->get_name` );
     171        Statement * create_resume_throw( ThrowStmt *throwStmt ) {
     172                // __throw_resume( EXPR );
    225173                return create_given_throw( "__cfaehm__throw_resume", throwStmt );
    226174        }
    227 
    228         Statement * ExceptionMutatorCore::create_resume_rethrow(
    229                         ThrowStmt *throwStmt ) {
     175        Statement * create_resume_rethrow( ThrowStmt *throwStmt ) {
    230176                // return false;
    231177                Statement * result = new ReturnStmt(
     
    239185        // TryStmt Mutation Helpers
    240186
    241         CompoundStmt * ExceptionMutatorCore::take_try_block( TryStmt *tryStmt ) {
     187        CompoundStmt * take_try_block( TryStmt *tryStmt ) {
    242188                CompoundStmt * block = tryStmt->get_block();
    243189                tryStmt->set_block( nullptr );
    244190                return block;
    245191        }
    246 
    247         FunctionDecl * ExceptionMutatorCore::create_try_wrapper(
    248                         CompoundStmt *body ) {
     192        FunctionDecl * create_try_wrapper( CompoundStmt *body ) {
    249193
    250194                return new FunctionDecl( "try", Type::StorageClasses(),
     
    252196        }
    253197
    254         FunctionDecl * ExceptionMutatorCore::create_terminate_catch(
    255                         CatchList &handlers ) {
     198        FunctionDecl * create_terminate_catch( CatchList &handlers ) {
    256199                std::list<CaseStmt *> handler_wrappers;
    257200
    258201                FunctionType *func_type = catch_func_t.clone();
    259202                DeclarationWithType * index_obj = func_type->get_parameters().front();
    260                 DeclarationWithType * except_obj = func_type->get_parameters().back();
     203        //      DeclarationWithType * except_obj = func_type->get_parameters().back();
    261204
    262205                // Index 1..{number of handlers}
     
    267210                        CatchStmt * handler = *it;
    268211
     212                        // INTEGERconstant Version
    269213                        // case `index`:
    270214                        // {
    271                         //     `handler.decl` = { (virtual `decl.type`)`except` };
    272                         //     `handler.body`;
     215                        //     `handler.body`
    273216                        // }
    274217                        // return;
    275                         CompoundStmt * block = new CompoundStmt( noLabels );
    276 
    277                         // Just copy the exception value. (Post Validation)
    278                         ObjectDecl * handler_decl =
    279                                 static_cast<ObjectDecl *>( handler->get_decl() );
    280                         ObjectDecl * local_except = handler_decl->clone();
    281                         local_except->set_init(
    282                                 new ListInit({ new SingleInit(
    283                                         new VirtualCastExpr( nameOf( except_obj ),
    284                                                 local_except->get_type()
    285                                                 )
    286                                         ) })
    287                                 );
    288                         block->push_back( new DeclStmt( noLabels, local_except ) );
    289 
    290                         // Add the cleanup attribute.
    291                         local_except->get_attributes().push_back( new Attribute(
    292                                 "cleanup",
    293                                 { new NameExpr( "__cfaehm__cleanup_terminate" ) }
    294                                 ) );
    295 
    296                         // Update variables in the body to point to this local copy.
    297                         {
    298                                 VarExprReplacer::DeclMap mapping;
    299                                 mapping[ handler_decl ] = local_except;
    300                                 VarExprReplacer mapper( mapping );
    301                                 handler->get_body()->accept( mapper );
    302                         }
    303 
    304                         block->push_back( handler->get_body() );
     218                        std::list<Statement *> caseBody;
     219                        caseBody.push_back( handler->get_body() );
    305220                        handler->set_body( nullptr );
    306 
    307                         std::list<Statement *> caseBody
    308                                         { block, new ReturnStmt( noLabels, nullptr ) };
     221                        caseBody.push_back( new ReturnStmt( noLabels, nullptr ) );
     222
    309223                        handler_wrappers.push_back( new CaseStmt(
    310224                                noLabels,
     
    335249        // Create a single check from a moddified handler.
    336250        // except_obj is referenced, modded_handler will be freed.
    337         CompoundStmt * ExceptionMutatorCore::create_single_matcher(
     251        CompoundStmt *create_single_matcher(
    338252                        DeclarationWithType * except_obj, CatchStmt * modded_handler ) {
    339                 // {
    340                 //     `modded_handler.decl`
    341                 //     if ( `decl.name = (virtual `decl.type`)`except`
    342                 //             [&& `modded_handler.cond`] ) {
    343                 //         `modded_handler.body`
    344                 //     }
    345                 // }
    346 
    347253                CompoundStmt * block = new CompoundStmt( noLabels );
    348254
    349                 // Local Declaration
    350                 ObjectDecl * local_except =
    351                         dynamic_cast<ObjectDecl *>( modded_handler->get_decl() );
    352                 assert( local_except );
    353                 block->push_back( new DeclStmt( noLabels, local_except ) );
    354 
    355                 // Check for type match.
    356                 Expression * cond = UntypedExpr::createAssign( nameOf( local_except ),
    357                         new VirtualCastExpr( nameOf( except_obj ),
    358                                 local_except->get_type()->clone() ) );
    359 
    360                 // Add the check on the conditional if it is provided.
     255                // INTEGERconstant Version
     256                assert( nullptr == modded_handler->get_decl() );
     257                ConstantExpr * number =
     258                        dynamic_cast<ConstantExpr*>( modded_handler->get_cond() );
     259                assert( number );
     260                modded_handler->set_cond( nullptr );
     261
     262                Expression * cond;
     263                {
     264                        std::list<Expression *> args;
     265                        args.push_back( number );
     266
     267                        std::list<Expression *> rhs_args;
     268                        rhs_args.push_back( nameOf( except_obj ) );
     269                        Expression * rhs = new UntypedExpr(
     270                                new NameExpr( "*?" ), rhs_args );
     271                        args.push_back( rhs );
     272
     273                        cond = new UntypedExpr( new NameExpr( "?==?" /*???*/), args );
     274                }
     275
    361276                if ( modded_handler->get_cond() ) {
    362277                        cond = new LogicalExpr( cond, modded_handler->get_cond() );
    363278                }
    364                 // Construct the match condition.
    365279                block->push_back( new IfStmt( noLabels,
    366280                        cond, modded_handler->get_body(), nullptr ) );
     
    373287        }
    374288
    375         FunctionDecl * ExceptionMutatorCore::create_terminate_match(
    376                         CatchList &handlers ) {
    377                 // int match(exception * except) {
    378                 //     HANDLER WRAPPERS { return `index`; }
    379                 // }
    380 
     289        FunctionDecl * create_terminate_match( CatchList &handlers ) {
    381290                CompoundStmt * body = new CompoundStmt( noLabels );
    382291
     
    410319        }
    411320
    412         CompoundStmt * ExceptionMutatorCore::create_terminate_caller(
     321        CompoundStmt * create_terminate_caller(
    413322                        FunctionDecl * try_wrapper,
    414323                        FunctionDecl * terminate_catch,
    415                         FunctionDecl * terminate_match ) {
    416                 // { __cfaehm__try_terminate(`try`, `catch`, `match`); }
     324                        FunctionDecl * terminate_match) {
    417325
    418326                UntypedExpr * caller = new UntypedExpr( new NameExpr(
     
    428336        }
    429337
    430         FunctionDecl * ExceptionMutatorCore::create_resume_handler(
    431                         CatchList &handlers ) {
    432                 // bool handle(exception * except) {
    433                 //     HANDLER WRAPPERS { `hander->body`; return true; }
    434                 // }
     338        FunctionDecl * create_resume_handler( CatchList &handlers ) {
    435339                CompoundStmt * body = new CompoundStmt( noLabels );
    436340
     
    465369        }
    466370
    467         CompoundStmt * ExceptionMutatorCore::create_resume_wrapper(
     371        CompoundStmt * create_resume_wrapper(
     372                        StructDecl * node_decl,
    468373                        Statement * wraps,
    469374                        FunctionDecl * resume_handler ) {
     
    509414        }
    510415
    511         FunctionDecl * ExceptionMutatorCore::create_finally_wrapper(
    512                         TryStmt * tryStmt ) {
    513                 // void finally() { <finally code> }
     416        FunctionDecl * create_finally_wrapper( TryStmt * tryStmt ) {
    514417                FinallyStmt * finally = tryStmt->get_finally();
    515418                CompoundStmt * body = finally->get_block();
     
    522425        }
    523426
    524         ObjectDecl * ExceptionMutatorCore::create_finally_hook(
    525                         FunctionDecl * finally_wrapper ) {
     427        ObjectDecl * create_finally_hook(
     428                        StructDecl * hook_decl, FunctionDecl * finally_wrapper ) {
    526429                // struct __cfaehm__cleanup_hook __finally_hook
    527430                //      __attribute__((cleanup( finally_wrapper )));
     
    541444                        nullptr,
    542445                        new StructInstType(
    543                                 noQualifiers,
     446                                emptyQualifiers,
    544447                                hook_decl
    545448                                ),
     
    549452        }
    550453
    551         // Visiting/Mutating Functions
    552         void ExceptionMutatorCore::premutate( CatchStmt *catchStmt ) {
    553                 // Validate the Statement's form.
    554                 ObjectDecl * decl =
    555                         dynamic_cast<ObjectDecl *>( catchStmt->get_decl() );
    556                 if ( decl && true /* check decl->get_type() */ ) {
    557                         // Pass.
    558                 } else if ( CatchStmt::Terminate == catchStmt->get_kind() ) {
    559                         throw SemanticError("catch must have exception type");
    560                 } else {
    561                         throw SemanticError("catchResume must have exception type");
    562                 }
    563 
    564                 // Track the handler context.
    565                 GuardValue( cur_context );
    566                 if ( CatchStmt::Terminate == catchStmt->get_kind() ) {
    567                         cur_context = TerHandler;
    568 
    569                         GuardValue( handler_except_decl );
    570                         handler_except_decl = decl;
    571                 } else {
    572                         cur_context = ResHandler;
    573                 }
    574         }
    575 
    576         void ExceptionMutatorCore::premutate( StructDecl *structDecl ) {
    577                 if ( !structDecl->has_body() ) {
    578                         // Skip children?
    579                         return;
    580                 } else if ( structDecl->get_name() == "__cfaehm__base_exception_t" ) {
    581                         assert( nullptr == except_decl );
    582                         except_decl = structDecl;
    583                         init_func_types();
    584                 } else if ( structDecl->get_name() == "__cfaehm__try_resume_node" ) {
    585                         assert( nullptr == node_decl );
    586                         node_decl = structDecl;
    587                 } else if ( structDecl->get_name() == "__cfaehm__cleanup_hook" ) {
    588                         assert( nullptr == hook_decl );
    589                         hook_decl = structDecl;
    590                 }
    591                 // Later we might get the exception type as well.
    592         }
     454
     455        class ExceptionMutatorCore : public WithGuards {
     456                enum Context { NoHandler, TerHandler, ResHandler };
     457
     458                // Also need to handle goto, break & continue.
     459                // They need to be cut off in a ResHandler, until we enter another
     460                // loop, switch or the goto stays within the function.
     461
     462                Context cur_context;
     463
     464                // We might not need this, but a unique base for each try block's
     465                // generated functions might be nice.
     466                //std::string curFunctionName;
     467                //unsigned int try_count = 0;
     468
     469                StructDecl *node_decl;
     470                StructDecl *hook_decl;
     471
     472        public:
     473                ExceptionMutatorCore() :
     474                        cur_context(NoHandler),
     475                        node_decl(nullptr), hook_decl(nullptr)
     476                {}
     477
     478                void premutate( CatchStmt *catchStmt );
     479                void premutate( StructDecl *structDecl );
     480                Statement * postmutate( ThrowStmt *throwStmt );
     481                Statement * postmutate( TryStmt *tryStmt );
     482        };
    593483
    594484        Statement * ExceptionMutatorCore::postmutate( ThrowStmt *throwStmt ) {
    595                 assert( except_decl );
    596 
    597485                // Ignoring throwStmt->get_target() for now.
    598486                if ( ThrowStmt::Terminate == throwStmt->get_kind() ) {
     
    622510
    623511        Statement * ExceptionMutatorCore::postmutate( TryStmt *tryStmt ) {
    624                 assert( except_decl );
    625512                assert( node_decl );
    626513                assert( hook_decl );
     
    637524                        appendDeclStmt( block, finally_block );
    638525                        // Create and add the finally cleanup hook.
    639                         appendDeclStmt( block, create_finally_hook( finally_block ) );
     526                        appendDeclStmt( block,
     527                                create_finally_hook( hook_decl, finally_block ) );
    640528                }
    641529
     
    651539                        appendDeclStmt( block, resume_handler );
    652540                        // Prepare hooks
    653                         inner = create_resume_wrapper( inner, resume_handler );
     541                        inner = create_resume_wrapper( node_decl, inner, resume_handler );
    654542                }
    655543
     
    672560                block->push_back( inner );
    673561
     562                //free_all( termination_handlers );
     563                //free_all( resumption_handlers );
     564
    674565                return block;
    675566        }
    676567
     568        void ExceptionMutatorCore::premutate( CatchStmt *catchStmt ) {
     569                GuardValue( cur_context );
     570                if ( CatchStmt::Terminate == catchStmt->get_kind() ) {
     571                        cur_context = TerHandler;
     572                } else {
     573                        cur_context = ResHandler;
     574                }
     575        }
     576
     577        void ExceptionMutatorCore::premutate( StructDecl *structDecl ) {
     578                if ( !structDecl->has_body() ) {
     579                        // Skip children?
     580                        return;
     581                } else if ( structDecl->get_name() == "__cfaehm__try_resume_node" ) {
     582                        assert( nullptr == node_decl );
     583                        node_decl = structDecl;
     584                } else if ( structDecl->get_name() == "__cfaehm__cleanup_hook" ) {
     585                        assert( nullptr == hook_decl );
     586                        hook_decl = structDecl;
     587                }
     588                // Later we might get the exception type as well.
     589        }
     590
    677591        void translateEHM( std::list< Declaration *> & translationUnit ) {
     592                init_func_types();
     593
    678594                PassVisitor<ExceptionMutatorCore> translator;
    679595                mutateAll( translationUnit, translator );
  • src/ControlStruct/ExceptTranslate.h

    r0720e049 r3d4b23fa  
    99// Author           : Andrew Beach
    1010// Created On       : Tus Jun 06 10:13:00 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:19:23 2017
    13 // Update Count     : 4
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Fri Jun 30 10:20:00 2017
     13// Update Count     : 2
    1414//
    1515
    16 #pragma once
     16#ifndef EXCEPT_TRANSLATE_H
     17#define EXCEPT_TRANSLATE_H
    1718
    1819#include <list>
     
    2122namespace ControlStruct {
    2223        void translateEHM( std::list< Declaration *> & translationUnit );
    23         // Converts exception handling structures into their underlying C code.  Translation does use the exception
    24         // handling header, make sure it is visible wherever translation occurs.
     24        /* Converts exception handling structures into their underlying C code.
     25         * Translation does use the exception handling header, make sure it is
     26         * visible wherever translation occurs.
     27         */
    2528}
    2629
    27 // Local Variables: //
    28 // tab-width: 4 //
    29 // mode: c++ //
    30 // compile-command: "make install" //
    31 // End: //
     30#endif // EXCEPT_TRANSLATE_H
  • src/ControlStruct/ForExprMutator.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:17:08 2017
    13 // Update Count     : 4
     12// Last Modified On : Mon Jan 25 21:22:13 2016
     13// Update Count     : 3
    1414//
    1515
    16 #pragma once
     16#ifndef FOR_MUTATOR_H
     17#define FOR_MUTATOR_H
    1718
    1819#include "SynTree/Mutator.h"
     
    2627} // namespace ControlStruct
    2728
     29#endif // CHOOSE_MUTATOR_H
     30
    2831// Local Variables: //
    2932// tab-width: 4 //
  • src/ControlStruct/LabelFixer.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:17:24 2017
    13 // Update Count     : 34
     12// Last Modified On : Tue Jul 12 17:36:16 2016
     13// Update Count     : 33
    1414//
    1515
    16 #pragma once
     16#ifndef LABEL_FIXER_H
     17#define LABEL_FIXER_H
    1718
    1819#include "Common/utility.h"
     
    8283} // namespace ControlStruct
    8384
     85#endif // LABEL_FIXER_H
     86
    8487// Local Variables: //
    8588// tab-width: 4 //
  • src/ControlStruct/LabelGenerator.h

    r0720e049 r3d4b23fa  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:20:14 2017
    13 // Update Count     : 6
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Jun 03 14:16:26 2015
     13// Update Count     : 5
    1414//
    1515
    16 #pragma once
     16#ifndef LABEL_GENERATOR_H
     17#define LABEL_GENERATOR_H
    1718
    1819#include "SynTree/SynTree.h"
     
    3435} // namespace ControlStruct
    3536
     37#endif // LABEL_GENERATOR_H
     38
    3639// Local Variables: //
    3740// tab-width: 4 //
  • src/ControlStruct/MLEMutator.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:19:59 2017
    13 // Update Count     : 35
     12// Last Modified On : Tue Jul 12 17:37:01 2016
     13// Update Count     : 34
    1414//
    1515
    16 #pragma once
     16#ifndef MLE_MUTATOR_H
     17#define MLE_MUTATOR_H
    1718
    1819#include <map>
     
    8889} // namespace ControlStruct
    8990
     91#endif // MLE_MUTATOR_H
     92
    9093// Local Variables: //
    9194// tab-width: 4 //
  • src/ControlStruct/Mutate.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:17:59 2017
    13 // Update Count     : 3
     12// Last Modified On : Tue May 19 15:31:20 2015
     13// Update Count     : 2
    1414//
    1515
    16 #pragma once
     16#ifndef CTRLS_MUTATE_H
     17#define CTRLS_MUTATE_H
    1718
    1819#include <list>
     
    2627} // namespace ControlStruct
    2728
     29#endif // CTRLS_MUTATE_H
     30
    2831// Local Variables: //
    2932// tab-width: 4 //
  • src/GenPoly/Box.cc

    r0720e049 r3d4b23fa  
    2727#include "Box.h"
    2828#include "DeclMutator.h"
    29 #include "Lvalue.h"
     29#include "PolyMutator.h"
    3030#include "FindFunction.h"
    31 #include "PolyMutator.h"
    3231#include "ScopedSet.h"
    3332#include "ScrubTyVars.h"
     
    203202                };
    204203
    205                 /// Replaces initialization of polymorphic values with alloca, declaration of dtype/ftype with appropriate void expression, sizeof expressions of polymorphic types with the proper variable, and strips fields from generic struct declarations.
     204                /// Replaces initialization of polymorphic values with alloca, declaration of dtype/ftype with appropriate void expression, and sizeof expressions of polymorphic types with the proper variable
    206205                class Pass3 final : public PolyMutator {
    207206                  public:
     
    211210                        using PolyMutator::mutate;
    212211                        virtual DeclarationWithType *mutate( FunctionDecl *functionDecl ) override;
    213                         virtual Declaration *mutate( StructDecl *structDecl ) override;
    214                         virtual Declaration *mutate( UnionDecl *unionDecl ) override;
    215212                        virtual ObjectDecl *mutate( ObjectDecl *objectDecl ) override;
    216213                        virtual TypedefDecl *mutate( TypedefDecl *objectDecl ) override;
     
    756753
    757754                void Pass1::boxParam( Type *param, Expression *&arg, const TyVarMap &exprTyVars ) {
    758                         assertf( arg->has_result(), "arg does not have result: %s", toString( arg ).c_str() );
     755                        assert( arg->has_result() );
    759756                        if ( isPolyType( param, exprTyVars ) ) {
    760                                 Type * newType = arg->get_result()->clone();
    761                                 if ( env ) env->apply( newType );
    762                                 std::auto_ptr<Type> manager( newType );
    763                                 if ( isPolyType( newType ) ) {
     757                                if ( isPolyType( arg->get_result() ) ) {
    764758                                        // if the argument's type is polymorphic, we don't need to box again!
    765759                                        return;
    766760                                } else if ( arg->get_result()->get_lvalue() ) {
    767                                         // argument expression may be CFA lvalue, but not C lvalue -- apply generalizedLvalue transformations.
    768                                         arg =  generalizedLvalue( new AddressExpr( arg ) );
     761                                        // VariableExpr and MemberExpr are lvalues; need to check this isn't coming from the second arg of a comma expression though (not an lvalue)
     762                                        // xxx - need to test that this code is still reachable
     763                                        if ( CommaExpr *commaArg = dynamic_cast< CommaExpr* >( arg ) ) {
     764                                                commaArg->set_arg2( new AddressExpr( commaArg->get_arg2() ) );
     765                                        } else {
     766                                                arg = new AddressExpr( arg );
     767                                        }
    769768                                        if ( ! ResolvExpr::typesCompatible( param, arg->get_result(), SymTab::Indexer() ) ) {
    770769                                                // silence warnings by casting boxed parameters when the actual type does not match up with the formal type.
     
    17491748
    17501749                Expression *PolyGenericCalculator::mutate( SizeofExpr *sizeofExpr ) {
    1751                         Type *ty = sizeofExpr->get_isType() ? sizeofExpr->get_type() : sizeofExpr->get_expr()->get_result();
     1750                        Type *ty = sizeofExpr->get_type();
    17521751                        if ( findGeneric( ty ) ) {
    17531752                                Expression *ret = new NameExpr( sizeofName( mangleType( ty ) ) );
     
    17591758
    17601759                Expression *PolyGenericCalculator::mutate( AlignofExpr *alignofExpr ) {
    1761                         Type *ty = alignofExpr->get_isType() ? alignofExpr->get_type() : alignofExpr->get_expr()->get_result();
     1760                        Type *ty = alignofExpr->get_type();
    17621761                        if ( findGeneric( ty ) ) {
    17631762                                Expression *ret = new NameExpr( alignofName( mangleType( ty ) ) );
     
    18691868                }
    18701869
    1871                 /// Strips the members from a generic aggregate
    1872                 void stripGenericMembers(AggregateDecl* decl) {
    1873                         if ( ! decl->get_parameters().empty() ) decl->get_members().clear();
    1874                 }
    1875 
    1876                 Declaration *Pass3::mutate( StructDecl *structDecl ) {
    1877                         stripGenericMembers( structDecl );
    1878                         return structDecl;
    1879                 }
    1880 
    1881                 Declaration *Pass3::mutate( UnionDecl *unionDecl ) {
    1882                         stripGenericMembers( unionDecl );
    1883                         return unionDecl;
    1884                 }
    1885 
    18861870                TypeDecl * Pass3::mutate( TypeDecl *typeDecl ) {
    18871871//   Initializer *init = 0;
  • src/GenPoly/Box.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:23:52 2017
    13 // Update Count     : 6
     12// Last Modified On : Thu Nov 19 17:24:01 2015
     13// Update Count     : 5
    1414//
    1515
    16 #pragma once
     16#ifndef _BOX_H
     17#define _BOX_H
    1718
    1819#include <list>
     
    2425} // namespace GenPoly
    2526
     27#endif // _BOX_H
     28
    2629// Local Variables: //
    2730// tab-width: 4 //
  • src/GenPoly/CopyParams.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:23:09 2017
    13 // Update Count     : 2
     12// Last Modified On : Tue May 19 07:34:25 2015
     13// Update Count     : 1
    1414//
    1515
    16 #pragma once
     16#ifndef _COPYPARAMS_H
     17#define _COPYPARAMS_H
    1718
    1819#include "SynTree/SynTree.h"
     
    2324} // namespace GenPoly
    2425
     26#endif // _COPYPARAMS_H
     27
    2528// Local Variables: //
    2629// tab-width: 4 //
  • src/GenPoly/DeclMutator.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Fri Nov 27 14:44:00 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:21:12 2017
    13 // Update Count     : 4
     12// Last Modified On : Tue Jul 12 17:39:01 2016
     13// Update Count     : 2
    1414//
    1515
    16 #pragma once
     16#ifndef _DECLMUTATOR_H
     17#define _DECLMUTATOR_H
    1718
    1819#include <list>
     
    2627        /// Mutates a list of declarations, providing a means of adding new declarations into the list
    2728        class DeclMutator : public Mutator {
    28           public:
     29        public:
    2930                typedef Mutator Parent;
    3031
     
    4950                /// Called on exit from a scope; overriders should call this as a super-class call
    5051                virtual void doEndScope();
    51           protected:
     52        protected:
    5253                /// Mutate a statement that forms its own scope
    5354                Statement* mutateStatement( Statement *stmt );
     
    5859                /// Add a declaration to the list to be added after the current position
    5960                void addDeclarationAfter( Declaration* decl );
    60           private:
     61        private:
    6162                /// A stack of declarations to add before the current declaration or statement
    6263                std::vector< std::list< Declaration* > > declsToAdd;
     
    6667} // namespace
    6768
     69#endif // _DECLMUTATOR_H
     70
    6871// Local Variables: //
    6972// tab-width: 4 //
  • src/GenPoly/ErasableScopedMap.h

    r0720e049 r3d4b23fa  
    99// Author           : Aaron B. Moss
    1010// Created On       : Wed Dec 2 11:37:00 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:23:24 2017
    13 // Update Count     : 2
    14 //
    15 
    16 #pragma once
     11// Last Modified By : Aaron B. Moss
     12// Last Modified On : Wed Dec 2 11:37:00 2015
     13// Update Count     : 1
     14//
     15
     16#ifndef _ERASABLESCOPEDMAP_H
     17#define _ERASABLESCOPEDMAP_H
    1718
    1819#include <cassert>
     
    277278} // namespace GenPoly
    278279
     280#endif // _ERASABLESCOPEDMAP_H
     281
    279282// Local Variables: //
    280283// tab-width: 4 //
  • src/GenPoly/FindFunction.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:23:36 2017
    13 // Update Count     : 2
     12// Last Modified On : Tue May 19 07:36:35 2015
     13// Update Count     : 1
    1414//
    1515
    16 #pragma once
     16#ifndef FINDFUNCTION_H
     17#define FINDFUNCTION_H
    1718
    1819#include "SynTree/SynTree.h"
     
    2829} // namespace GenPoly
    2930
     31#endif // FINDFUNCTION_H
     32
    3033// Local Variables: //
    3134// tab-width: 4 //
  • src/GenPoly/GenPoly.h

    r0720e049 r3d4b23fa  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:22:57 2017
    13 // Update Count     : 7
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Tue Nov 24 15:24:38 2015
     13// Update Count     : 6
    1414//
    1515
    16 #pragma once
     16#ifndef GENPOLY_H
     17#define GENPOLY_H
    1718
    1819#include <string>
     
    110111} // namespace GenPoly
    111112
     113#endif // GENPOLY_H
     114
    112115// Local Variables: //
    113116// tab-width: 4 //
  • src/GenPoly/InstantiateGeneric.h

    r0720e049 r3d4b23fa  
    99// Author           : Aaron B. Moss
    1010// Created On       : Thu Aug 04 18:33:00 2016
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:22:42 2017
    13 // Update Count     : 2
     11// Last Modified By : Aaron B. Moss
     12// Last Modified On : Thu Aug 04 18:33:00 2016
     13// Update Count     : 1
    1414//
    1515
    16 #pragma once
     16#ifndef _INSTANTIATEGENERIC_H
     17#define _INSTANTIATEGENERIC_H
    1718
    1819#include "SynTree/SynTree.h"
     
    2526} // namespace GenPoly
    2627
     28#endif // _INSTANTIATEGENERIC_H
     29
    2730// Local Variables: //
    2831// tab-width: 4 //
  • src/GenPoly/Lvalue.cc

    r0720e049 r3d4b23fa  
    2727#include "SynTree/Mutator.h"
    2828#include "SymTab/Indexer.h"
    29 
    3029#include "ResolvExpr/Resolver.h"
    31 #include "ResolvExpr/TypeEnvironment.h"
    3230#include "ResolvExpr/typeops.h"
    33 #include "ResolvExpr/Unify.h"
    3431
    3532#include "Common/UniqueName.h"
     
    6360                        typedef Mutator Parent;
    6461
    65                         virtual Expression * mutate( MemberExpr * memExpr );
    6662                        virtual Expression * mutate( AddressExpr * addressExpr );
    67 
    68                         template<typename Func>
    69                         Expression * applyTransformation( Expression * expr, Expression * arg, Func mkExpr );
    7063                };
    7164        } // namespace
     
    7871                acceptAll( translationUnit, p2 );
    7972                mutateAll( translationUnit, genLval );
    80         }
    81 
    82         Expression * generalizedLvalue( Expression * expr ) {
    83                 GeneralizedLvalue genLval;
    84                 return expr->acceptMutator( genLval );
    8573        }
    8674
     
    175163                }
    176164
    177                 template<typename Func>
    178                 Expression * GeneralizedLvalue::applyTransformation( Expression * expr, Expression * arg, Func mkExpr ) {
    179                         if ( CommaExpr * commaExpr = dynamic_cast< CommaExpr * >( arg ) ) {
     165                Expression * GeneralizedLvalue::mutate( AddressExpr * addrExpr ) {
     166                        addrExpr = safe_dynamic_cast< AddressExpr * >( Parent::mutate( addrExpr ) );
     167                        if ( CommaExpr * commaExpr = dynamic_cast< CommaExpr * >( addrExpr->get_arg() ) ) {
    180168                                Expression * arg1 = commaExpr->get_arg1()->clone();
    181169                                Expression * arg2 = commaExpr->get_arg2()->clone();
    182                                 Expression * ret = new CommaExpr( arg1, mkExpr( arg2 ) );
    183                                 ret->set_env( expr->get_env() );
    184                                 expr->set_env( nullptr );
    185                                 delete expr;
    186                                 return ret->acceptMutator( *this );
    187                         } else if ( ConditionalExpr * condExpr = dynamic_cast< ConditionalExpr * >( arg ) ) {
     170                                delete addrExpr;
     171                                return new CommaExpr( arg1, new AddressExpr( arg2 ) );
     172                        } else if ( ConditionalExpr * condExpr = dynamic_cast< ConditionalExpr * >( addrExpr->get_arg() ) ) {
    188173                                Expression * arg1 = condExpr->get_arg1()->clone();
    189174                                Expression * arg2 = condExpr->get_arg2()->clone();
    190175                                Expression * arg3 = condExpr->get_arg3()->clone();
    191                                 ConditionalExpr * ret = new ConditionalExpr( arg1, mkExpr( arg2 ), mkExpr( arg3 ) );
    192                                 ret->set_env( expr->get_env() );
    193                                 expr->set_env( nullptr );
    194                                 delete expr;
    195 
    196                                 // conditional expr type may not be either of the argument types, need to unify
    197                                 using namespace ResolvExpr;
    198                                 Type* commonType = nullptr;
    199                                 TypeEnvironment newEnv;
    200                                 AssertionSet needAssertions, haveAssertions;
    201                                 OpenVarSet openVars;
    202                                 unify( ret->get_arg2()->get_result(), ret->get_arg3()->get_result(), newEnv, needAssertions, haveAssertions, openVars, SymTab::Indexer(), commonType );
    203                                 ret->set_result( commonType ? commonType : ret->get_arg2()->get_result()->clone() );
    204                                 return ret->acceptMutator( *this );
     176                                delete addrExpr;
     177                                return new ConditionalExpr( arg1, new AddressExpr( arg2 ), new AddressExpr( arg3 ) );
    205178                        }
    206                         return expr;
    207                 }
    208 
    209                 Expression * GeneralizedLvalue::mutate( MemberExpr * memExpr ) {
    210                         Parent::mutate( memExpr );
    211                         return applyTransformation( memExpr, memExpr->get_aggregate(), [=]( Expression * aggr ) { return new MemberExpr( memExpr->get_member(), aggr ); } );
    212                 }
    213 
    214                 Expression * GeneralizedLvalue::mutate( AddressExpr * addrExpr ) {
    215                         addrExpr = safe_dynamic_cast< AddressExpr * >( Parent::mutate( addrExpr ) );
    216                         return applyTransformation( addrExpr, addrExpr->get_arg(), []( Expression * arg ) { return new AddressExpr( arg ); } );
     179                        return addrExpr;
    217180                }
    218181        } // namespace
  • src/GenPoly/Lvalue.h

    r0720e049 r3d4b23fa  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Lvalue.h --
     7// Lvalue.h -- 
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:21:59 2017
    13 // Update Count     : 2
     12// Last Modified On : Tue May 19 07:42:09 2015
     13// Update Count     : 1
    1414//
    1515
    16 #pragma once
     16#ifndef _LVALUE_H
     17#define _LVALUE_H
    1718
    1819#include <list>
     
    2324        /// replaces return type of `lvalue T` with `T*`, along with appropriate address-of and dereference operators
    2425        void convertLvalue( std::list< Declaration* >& translationUnit );
     26} // namespace GenPoly
    2527
    26         /// applies transformations that allow GCC to accept more complicated lvalue expressions, e.g. &(a, b)
    27         Expression * generalizedLvalue( Expression * expr );
    28 } // namespace GenPoly
     28#endif // _LVALUE_H
    2929
    3030// Local Variables: //
  • src/GenPoly/PolyMutator.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:20:31 2017
    13 // Update Count     : 7
     12// Last Modified On : Tue Jul 12 17:39:41 2016
     13// Update Count     : 6
    1414//
    1515
    16 #pragma once
     16#ifndef _POLYMUTATOR_H
     17#define _POLYMUTATOR_H
    1718
    1819#include <map>
     
    6566} // namespace
    6667
     68#endif // _POLYMUTATOR_H
     69
    6770// Local Variables: //
    6871// tab-width: 4 //
  • src/GenPoly/ScopedSet.h

    r0720e049 r3d4b23fa  
    99// Author           : Aaron B. Moss
    1010// Created On       : Thu Dec 3 11:51:00 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:22:17 2017
    13 // Update Count     : 2
    14 //
    15 
    16 #pragma once
     11// Last Modified By : Aaron B. Moss
     12// Last Modified On : Thu Dec 3 11:51:00 2015
     13// Update Count     : 1
     14//
     15
     16#ifndef _SCOPEDSET_H
     17#define _SCOPEDSET_H
    1718
    1819#include <iterator>
     
    246247} // namespace GenPoly
    247248
     249#endif // _SCOPEDSET_H
     250
    248251// Local Variables: //
    249252// tab-width: 4 //
  • src/GenPoly/ScrubTyVars.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:21:47 2017
    13 // Update Count     : 2
     12// Last Modified On : Tue May 19 07:48:14 2015
     13// Update Count     : 1
    1414//
    1515
    16 #pragma once
     16#ifndef _SCRUBTYVARS_H
     17#define _SCRUBTYVARS_H
    1718
    1819#include <string>
     
    9495} // namespace GenPoly
    9596
     97#endif // _SCRUBTYVARS_H
     98
    9699// Local Variables: //
    97100// tab-width: 4 //
  • src/GenPoly/Specialize.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:22:31 2017
    13 // Update Count     : 2
     12// Last Modified On : Tue May 19 07:53:58 2015
     13// Update Count     : 1
    1414//
    1515
    16 #pragma once
     16#ifndef _SPECIALIZE_H
     17#define _SPECIALIZE_H
    1718
    1819#include <list>
     
    2526} // namespace GenPoly
    2627
     28#endif // _SPECIALIZE_H
     29
    2730// Local Variables: //
    2831// tab-width: 4 //
  • src/InitTweak/FixGlobalInit.h

    r0720e049 r3d4b23fa  
    99// Author           : Rob Schluntz
    1010// Created On       : Mon May 04 15:14:56 2016
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:30:54 2017
    13 // Update Count     : 3
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Fri May 06 16:07:47 2016
     13// Update Count     : 2
    1414//
    1515
    16 #pragma once
     16#ifndef FIX_GLOBAL_INIT_H
     17#define FIX_GLOBAL_INIT_H
    1718
    1819#include <string>
     
    3334} // namespace
    3435
     36#endif // GENPOLY_POLYMUTATOR_H
     37
    3538// Local Variables: //
    3639// tab-width: 4 //
  • src/InitTweak/FixInit.h

    r0720e049 r3d4b23fa  
    99// Author           : Rob Schluntz
    1010// Created On       : Wed Jan 13 16:29:30 2016
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:31:06 2017
    13 // Update Count     : 6
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Fri May 13 11:27:52 2016
     13// Update Count     : 5
    1414//
    1515
    16 #pragma once
     16#ifndef FIX_INIT_H
     17#define FIX_INIT_H
    1718
    1819#include <string>
     
    2930} // namespace
    3031
     32#endif // GENPOLY_POLYMUTATOR_H
     33
    3134// Local Variables: //
    3235// tab-width: 4 //
  • src/InitTweak/GenInit.h

    r0720e049 r3d4b23fa  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:31:19 2017
    13 // Update Count     : 4
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Fri May 13 11:27:19 2016
     13// Update Count     : 3
    1414//
    1515
    16 #pragma once
     16#ifndef GEN_INIT_H
     17#define GEN_INIT_H
    1718
    1819#include <string>
     
    3435} // namespace
    3536
     37#endif // INITTWEAK_GENINIT_H
     38
    3639// Local Variables: //
    3740// tab-width: 4 //
  • src/InitTweak/InitTweak.h

    r0720e049 r3d4b23fa  
    99// Author           : Rob Schluntz
    1010// Created On       : Fri May 13 11:26:36 2016
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:30:33 2017
    13 // Update Count     : 4
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Fri May 13 11:35:36 2016
     13// Update Count     : 3
    1414//
    1515
    16 #pragma once
     16#ifndef INIT_TWEAK_H
     17#define INIT_TWEAK_H
    1718
    1819#include <string>
     
    115116} // namespace
    116117
     118#endif // INITTWEAK_GENINIT_H
     119
    117120// Local Variables: //
    118121// tab-width: 4 //
  • src/MakeLibCfa.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Sat May 16 10:42:14 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:31:35 2017
    13 // Update Count     : 2
     12// Last Modified On : Sat May 16 10:43:29 2015
     13// Update Count     : 1
    1414//
    1515
    16 #pragma once
     16#ifndef LIBCFA_MAKELIBCFA_H
     17#define LIBCFA_MAKELIBCFA_H
    1718
    1819#include <list>  // for list
     
    2425} // namespace LibCfa
    2526
     27#endif // LIBCFA_MAKELIBCFA_H
     28
    2629// Local Variables: //
    2730// tab-width: 4 //
  • src/Makefile.am

    r0720e049 r3d4b23fa  
    1010## Author           : Peter A. Buhr
    1111## Created On       : Sun May 31 08:51:46 2015
    12 ## Last Modified By : Andrew Beach
    13 ## Last Modified On : Tus Jul 25 10:34:00 2017
    14 ## Update Count     : 76
     12## Last Modified By : Peter A. Buhr
     13## Last Modified On : Thu Oct 27 20:41:25 2016
     14## Update Count     : 75
    1515###############################################################################
    1616
     
    3737include SynTree/module.mk
    3838include Tuples/module.mk
    39 include Virtual/module.mk
    4039
    4140# put into lib for now
     
    4342cfa_cpplib_PROGRAMS = driver/cfa-cpp
    4443driver_cfa_cpp_SOURCES = ${SRC}
    45 driver_cfa_cpp_LDADD = -ldl                     # yywrap
     44driver_cfa_cpp_LDADD = ${LEXLIB} -ldl                   # yywrap
    4645driver_cfa_cpp_CXXFLAGS = -Wno-deprecated -Wall -Wextra -DDEBUG_ALL -I${abs_top_srcdir}/src/include -DYY_NO_INPUT -O2 -g -std=c++14
    4746driver_cfa_cpp_LDFLAGS = -Xlinker -export-dynamic
  • src/Makefile.in

    r0720e049 r3d4b23fa  
    2323#SRC +=  ArgTweak/Rewriter.cc \
    2424#       ArgTweak/Mutate.cc
    25 
    26 ######################### -*- Mode: Makefile-Gmake -*- ########################
    27 ###############################################################################
    2825
    2926######################### -*- Mode: Makefile-Gmake -*- ########################
     
    257254        Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT) \
    258255        Tuples/driver_cfa_cpp-TupleExpansion.$(OBJEXT) \
    259         Tuples/driver_cfa_cpp-Explode.$(OBJEXT) \
    260         Virtual/driver_cfa_cpp-ExpandCasts.$(OBJEXT)
     256        Tuples/driver_cfa_cpp-Explode.$(OBJEXT)
    261257am_driver_cfa_cpp_OBJECTS = $(am__objects_1)
    262258driver_cfa_cpp_OBJECTS = $(am_driver_cfa_cpp_OBJECTS)
    263 driver_cfa_cpp_DEPENDENCIES =
     259am__DEPENDENCIES_1 =
     260driver_cfa_cpp_DEPENDENCIES = $(am__DEPENDENCIES_1)
    264261driver_cfa_cpp_LINK = $(CXXLD) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) \
    265262        $(driver_cfa_cpp_LDFLAGS) $(LDFLAGS) -o $@
     
    357354        $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk \
    358355        $(srcdir)/SymTab/module.mk $(srcdir)/SynTree/module.mk \
    359         $(srcdir)/Tuples/module.mk $(srcdir)/Virtual/module.mk \
    360         $(top_srcdir)/automake/depcomp $(top_srcdir)/automake/ylwrap \
    361         Parser/lex.cc Parser/parser.cc Parser/parser.hh
     356        $(srcdir)/Tuples/module.mk $(top_srcdir)/automake/depcomp \
     357        $(top_srcdir)/automake/ylwrap Parser/lex.cc Parser/parser.cc \
     358        Parser/parser.hh
    362359DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
    363360ACLOCAL = @ACLOCAL@
     
    535532        SynTree/Attribute.cc SynTree/VarExprReplacer.cc \
    536533        Tuples/TupleAssignment.cc Tuples/TupleExpansion.cc \
    537         Tuples/Explode.cc Virtual/ExpandCasts.cc
     534        Tuples/Explode.cc
    538535MAINTAINERCLEANFILES = Parser/parser.output ${libdir}/${notdir \
    539536        ${cfa_cpplib_PROGRAMS}}
     
    546543cfa_cpplibdir = ${CFA_LIBDIR}
    547544driver_cfa_cpp_SOURCES = ${SRC}
    548 driver_cfa_cpp_LDADD = -ldl                     # yywrap
     545driver_cfa_cpp_LDADD = ${LEXLIB} -ldl                   # yywrap
    549546driver_cfa_cpp_CXXFLAGS = -Wno-deprecated -Wall -Wextra -DDEBUG_ALL -I${abs_top_srcdir}/src/include -DYY_NO_INPUT -O2 -g -std=c++14
    550547driver_cfa_cpp_LDFLAGS = -Xlinker -export-dynamic
     
    554551.SUFFIXES:
    555552.SUFFIXES: .cc .ll .o .obj .yy
    556 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/CodeGen/module.mk $(srcdir)/CodeTools/module.mk $(srcdir)/Concurrency/module.mk $(srcdir)/Common/module.mk $(srcdir)/ControlStruct/module.mk $(srcdir)/GenPoly/module.mk $(srcdir)/InitTweak/module.mk $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk $(srcdir)/SymTab/module.mk $(srcdir)/SynTree/module.mk $(srcdir)/Tuples/module.mk $(srcdir)/Virtual/module.mk $(am__configure_deps)
     553$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/CodeGen/module.mk $(srcdir)/CodeTools/module.mk $(srcdir)/Concurrency/module.mk $(srcdir)/Common/module.mk $(srcdir)/ControlStruct/module.mk $(srcdir)/GenPoly/module.mk $(srcdir)/InitTweak/module.mk $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk $(srcdir)/SymTab/module.mk $(srcdir)/SynTree/module.mk $(srcdir)/Tuples/module.mk $(am__configure_deps)
    557554        @for dep in $?; do \
    558555          case '$(am__configure_deps)' in \
     
    574571            cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
    575572        esac;
    576 $(srcdir)/CodeGen/module.mk $(srcdir)/CodeTools/module.mk $(srcdir)/Concurrency/module.mk $(srcdir)/Common/module.mk $(srcdir)/ControlStruct/module.mk $(srcdir)/GenPoly/module.mk $(srcdir)/InitTweak/module.mk $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk $(srcdir)/SymTab/module.mk $(srcdir)/SynTree/module.mk $(srcdir)/Tuples/module.mk $(srcdir)/Virtual/module.mk $(am__empty):
     573$(srcdir)/CodeGen/module.mk $(srcdir)/CodeTools/module.mk $(srcdir)/Concurrency/module.mk $(srcdir)/Common/module.mk $(srcdir)/ControlStruct/module.mk $(srcdir)/GenPoly/module.mk $(srcdir)/InitTweak/module.mk $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk $(srcdir)/SymTab/module.mk $(srcdir)/SynTree/module.mk $(srcdir)/Tuples/module.mk $(am__empty):
    577574
    578575$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
     
    941938Tuples/driver_cfa_cpp-Explode.$(OBJEXT): Tuples/$(am__dirstamp) \
    942939        Tuples/$(DEPDIR)/$(am__dirstamp)
    943 Virtual/$(am__dirstamp):
    944         @$(MKDIR_P) Virtual
    945         @: > Virtual/$(am__dirstamp)
    946 Virtual/$(DEPDIR)/$(am__dirstamp):
    947         @$(MKDIR_P) Virtual/$(DEPDIR)
    948         @: > Virtual/$(DEPDIR)/$(am__dirstamp)
    949 Virtual/driver_cfa_cpp-ExpandCasts.$(OBJEXT): Virtual/$(am__dirstamp) \
    950         Virtual/$(DEPDIR)/$(am__dirstamp)
    951940driver/$(am__dirstamp):
    952941        @$(MKDIR_P) driver
     
    971960        -rm -f SynTree/*.$(OBJEXT)
    972961        -rm -f Tuples/*.$(OBJEXT)
    973         -rm -f Virtual/*.$(OBJEXT)
    974962
    975963distclean-compile:
     
    10861074@AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-TupleAssignment.Po@am__quote@
    10871075@AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Po@am__quote@
    1088 @AMDEP_TRUE@@am__include@ @am__quote@Virtual/$(DEPDIR)/driver_cfa_cpp-ExpandCasts.Po@am__quote@
    10891076
    10901077.cc.o:
     
    26432630@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    26442631@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-Explode.obj `if test -f 'Tuples/Explode.cc'; then $(CYGPATH_W) 'Tuples/Explode.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/Explode.cc'; fi`
    2645 
    2646 Virtual/driver_cfa_cpp-ExpandCasts.o: Virtual/ExpandCasts.cc
    2647 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Virtual/driver_cfa_cpp-ExpandCasts.o -MD -MP -MF Virtual/$(DEPDIR)/driver_cfa_cpp-ExpandCasts.Tpo -c -o Virtual/driver_cfa_cpp-ExpandCasts.o `test -f 'Virtual/ExpandCasts.cc' || echo '$(srcdir)/'`Virtual/ExpandCasts.cc
    2648 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Virtual/$(DEPDIR)/driver_cfa_cpp-ExpandCasts.Tpo Virtual/$(DEPDIR)/driver_cfa_cpp-ExpandCasts.Po
    2649 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Virtual/ExpandCasts.cc' object='Virtual/driver_cfa_cpp-ExpandCasts.o' libtool=no @AMDEPBACKSLASH@
    2650 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    2651 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Virtual/driver_cfa_cpp-ExpandCasts.o `test -f 'Virtual/ExpandCasts.cc' || echo '$(srcdir)/'`Virtual/ExpandCasts.cc
    2652 
    2653 Virtual/driver_cfa_cpp-ExpandCasts.obj: Virtual/ExpandCasts.cc
    2654 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Virtual/driver_cfa_cpp-ExpandCasts.obj -MD -MP -MF Virtual/$(DEPDIR)/driver_cfa_cpp-ExpandCasts.Tpo -c -o Virtual/driver_cfa_cpp-ExpandCasts.obj `if test -f 'Virtual/ExpandCasts.cc'; then $(CYGPATH_W) 'Virtual/ExpandCasts.cc'; else $(CYGPATH_W) '$(srcdir)/Virtual/ExpandCasts.cc'; fi`
    2655 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Virtual/$(DEPDIR)/driver_cfa_cpp-ExpandCasts.Tpo Virtual/$(DEPDIR)/driver_cfa_cpp-ExpandCasts.Po
    2656 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Virtual/ExpandCasts.cc' object='Virtual/driver_cfa_cpp-ExpandCasts.obj' libtool=no @AMDEPBACKSLASH@
    2657 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    2658 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Virtual/driver_cfa_cpp-ExpandCasts.obj `if test -f 'Virtual/ExpandCasts.cc'; then $(CYGPATH_W) 'Virtual/ExpandCasts.cc'; else $(CYGPATH_W) '$(srcdir)/Virtual/ExpandCasts.cc'; fi`
    26592632
    26602633.ll.cc:
     
    28052778        -rm -f Tuples/$(DEPDIR)/$(am__dirstamp)
    28062779        -rm -f Tuples/$(am__dirstamp)
    2807         -rm -f Virtual/$(DEPDIR)/$(am__dirstamp)
    2808         -rm -f Virtual/$(am__dirstamp)
    28092780        -rm -f driver/$(am__dirstamp)
    28102781
     
    28222793
    28232794distclean: distclean-am
    2824         -rm -rf ./$(DEPDIR) CodeGen/$(DEPDIR) CodeTools/$(DEPDIR) Common/$(DEPDIR) Concurrency/$(DEPDIR) ControlStruct/$(DEPDIR) GenPoly/$(DEPDIR) InitTweak/$(DEPDIR) Parser/$(DEPDIR) ResolvExpr/$(DEPDIR) SymTab/$(DEPDIR) SynTree/$(DEPDIR) Tuples/$(DEPDIR) Virtual/$(DEPDIR)
     2795        -rm -rf ./$(DEPDIR) CodeGen/$(DEPDIR) CodeTools/$(DEPDIR) Common/$(DEPDIR) Concurrency/$(DEPDIR) ControlStruct/$(DEPDIR) GenPoly/$(DEPDIR) InitTweak/$(DEPDIR) Parser/$(DEPDIR) ResolvExpr/$(DEPDIR) SymTab/$(DEPDIR) SynTree/$(DEPDIR) Tuples/$(DEPDIR)
    28252796        -rm -f Makefile
    28262797distclean-am: clean-am distclean-compile distclean-generic \
     
    28682839
    28692840maintainer-clean: maintainer-clean-am
    2870         -rm -rf ./$(DEPDIR) CodeGen/$(DEPDIR) CodeTools/$(DEPDIR) Common/$(DEPDIR) Concurrency/$(DEPDIR) ControlStruct/$(DEPDIR) GenPoly/$(DEPDIR) InitTweak/$(DEPDIR) Parser/$(DEPDIR) ResolvExpr/$(DEPDIR) SymTab/$(DEPDIR) SynTree/$(DEPDIR) Tuples/$(DEPDIR) Virtual/$(DEPDIR)
     2841        -rm -rf ./$(DEPDIR) CodeGen/$(DEPDIR) CodeTools/$(DEPDIR) Common/$(DEPDIR) Concurrency/$(DEPDIR) ControlStruct/$(DEPDIR) GenPoly/$(DEPDIR) InitTweak/$(DEPDIR) Parser/$(DEPDIR) ResolvExpr/$(DEPDIR) SymTab/$(DEPDIR) SynTree/$(DEPDIR) Tuples/$(DEPDIR)
    28712842        -rm -f Makefile
    28722843maintainer-clean-am: distclean-am maintainer-clean-generic
  • src/Parser/DeclarationNode.cc

    r0720e049 r3d4b23fa  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Jul 14 16:55:00 2017
    13 // Update Count     : 1020
     12// Last Modified On : Wed Jun 28 15:27:00 2017
     13// Update Count     : 1019
    1414//
    1515
     
    253253        newnode->type->aggregate.fields = fields;
    254254        newnode->type->aggregate.body = body;
    255         newnode->type->aggregate.tagged = false;
    256         newnode->type->aggregate.parent = nullptr;
    257255        return newnode;
    258256} // DeclarationNode::newAggregate
     
    275273        return newnode;
    276274} // DeclarationNode::newEnumConstant
    277 
    278 DeclarationNode * DeclarationNode::newTreeStruct( Aggregate kind, const string * name, const string * parent, ExpressionNode * actuals, DeclarationNode * fields, bool body ) {
    279         assert( name );
    280         DeclarationNode * newnode = new DeclarationNode;
    281         newnode->type = new TypeData( TypeData::Aggregate );
    282         newnode->type->aggregate.kind = kind;
    283         newnode->type->aggregate.name = name;
    284         newnode->type->aggregate.actuals = actuals;
    285         newnode->type->aggregate.fields = fields;
    286         newnode->type->aggregate.body = body;
    287         newnode->type->aggregate.tagged = true;
    288         newnode->type->aggregate.parent = parent;
    289         return newnode;
    290 } // DeclarationNode::newTreeStruct
    291275
    292276DeclarationNode * DeclarationNode::newName( string * name ) {
  • src/Parser/ExpressionNode.cc

    r0720e049 r3d4b23fa  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:17:07 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Aug  2 11:12:00 2017
    13 // Update Count     : 568
    14 //
    15 
    16 #include <climits>                                                                              // access INT_MAX, UINT_MAX, LONG_MAX, ULONG_MAX, LLONG_MAX
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Jun 28 21:08:15 2017
     13// Update Count     : 542
     14//
     15
     16#include <cassert>
     17#include <cctype>
     18#include <climits>
     19#include <cstdio>
     20#include <algorithm>
    1721#include <sstream>
    1822
     
    2226#include "SynTree/Expression.h"
    2327#include "SynTree/Declaration.h"
     28#include "Common/UnimplementedError.h"
    2429#include "parserutility.h"
     30#include "Common/utility.h"
    2531
    2632using namespace std;
     
    4046// type.
    4147
    42 extern const Type::Qualifiers noQualifiers;             // no qualifiers on constants
     48Type::Qualifiers emptyQualifiers;                               // no qualifiers on constants
    4349
    4450static inline bool checkU( char c ) { return c == 'u' || c == 'U'; }
     
    4955static inline bool checkX( char c ) { return c == 'x' || c == 'X'; }
    5056
    51 Expression * build_constantInteger( const std::string & str ) {
     57Expression *build_constantInteger( const std::string & str ) {
    5258        static const BasicType::Kind kind[2][3] = {
    5359                { BasicType::SignedInt, BasicType::LongSignedInt, BasicType::LongLongSignedInt },
     
    5662        bool dec = true, Unsigned = false;                                      // decimal, unsigned constant
    5763        int size;                                                                                       // 0 => int, 1 => long, 2 => long long
    58         unsigned long long int v;                                                       // converted integral value
     64        unsigned long long int v;                                                               // converted integral value
    5965        size_t last = str.length() - 1;                                         // last character of constant
    60         Expression * ret;
    61 
    62         // special constants
    63         if ( str == "0" ) {
    64                 ret = new ConstantExpr( Constant( (Type *)new ZeroType( noQualifiers ), str, (unsigned long long int)0 ) );
    65                 goto CLEANUP;
    66         } // if
    67         if ( str == "1" ) {
    68                 ret = new ConstantExpr( Constant( (Type *)new OneType( noQualifiers ), str, (unsigned long long int)1 ) );
    69                 goto CLEANUP;
    70         } // if
    71        
     66
    7267        if ( str[0] == '0' ) {                                                          // octal/hex constant ?
    7368                dec = false;
     
    123118        } // if
    124119
    125         ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[Unsigned][size] ), str, v ) );
    126   CLEANUP:
     120        Expression * ret = new ConstantExpr( Constant( new BasicType( emptyQualifiers, kind[Unsigned][size] ), str, v ) );
    127121        delete &str;                                                                            // created by lex
    128122        return ret;
    129123} // build_constantInteger
    130124
    131 Expression * build_constantFloat( const std::string & str ) {
     125Expression *build_constantFloat( const std::string & str ) {
    132126        static const BasicType::Kind kind[2][3] = {
    133127                { BasicType::Float, BasicType::Double, BasicType::LongDouble },
     
    159153        } // if
    160154
    161         Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[complx][size] ), str, v ) );
     155        Expression * ret = new ConstantExpr( Constant( new BasicType( emptyQualifiers, kind[complx][size] ), str, v ) );
    162156        delete &str;                                                                            // created by lex
    163157        return ret;
    164158} // build_constantFloat
    165159
    166 Expression * build_constantChar( const std::string & str ) {
    167         Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, BasicType::Char ), str, (unsigned long long int)(unsigned char)str[1] ) );
     160Expression *build_constantChar( const std::string & str ) {
     161        Expression * ret = new ConstantExpr( Constant( new BasicType( emptyQualifiers, BasicType::Char ), str, (unsigned long long int)(unsigned char)str[1] ) );
    168162        delete &str;                                                                            // created by lex
    169163        return ret;
    170164} // build_constantChar
    171165
    172 ConstantExpr * build_constantStr( const std::string & str ) {
     166ConstantExpr *build_constantStr( const std::string & str ) {
    173167        // string should probably be a primitive type
    174         ArrayType * at = new ArrayType( noQualifiers, new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ),
    175                                                                    new ConstantExpr( Constant::from_ulong( str.size() + 1 - 2 ) ), // +1 for '\0' and -2 for '"'
     168        ArrayType *at = new ArrayType( emptyQualifiers, new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ),
     169                                                                   new ConstantExpr( Constant::from_ulong( str.size() + 1 - 2 ) ),  // +1 for '\0' and -2 for '"'
    176170                                                                   false, false );
    177         ConstantExpr * ret = new ConstantExpr( Constant( at, str, (unsigned long long int)0 ) ); // constant 0 is ignored for pure string value
     171        // constant 0 is ignored for pure string value
     172        ConstantExpr * ret = new ConstantExpr( Constant( at, str, (unsigned long long int)0 ) );
    178173        delete &str;                                                                            // created by lex
    179174        return ret;
    180175} // build_constantStr
     176
     177Expression *build_constantZeroOne( const std::string & str ) {
     178        Expression * ret = new ConstantExpr( Constant( str == "0" ? (Type *)new ZeroType( emptyQualifiers ) : (Type*)new OneType( emptyQualifiers ), str,
     179                                                                                                   str == "0" ? (unsigned long long int)0 : (unsigned long long int)1 ) );
     180        delete &str;                                                                            // created by lex
     181        return ret;
     182} // build_constantChar
    181183
    182184Expression * build_field_name_FLOATINGconstant( const std::string & str ) {
     
    207209} // build_field_name_fraction_constants
    208210
     211
     212
    209213Expression * build_field_name_REALFRACTIONconstant( const std::string & str ) {
    210214        if ( str.find_first_not_of( "0123456789", 1 ) != string::npos ) throw SemanticError( "invalid tuple index " + str );
     
    221225} // build_field_name_REALDECIMALconstant
    222226
    223 NameExpr * build_varref( const string * name ) {
    224         NameExpr * expr = new NameExpr( *name, nullptr );
     227NameExpr * build_varref( const string *name ) {
     228        NameExpr *expr = new NameExpr( *name, nullptr );
    225229        delete name;
    226230        return expr;
    227 } // build_varref
    228 
    229 
    230 static const char * OperName[] = {                                              // must harmonize with OperKinds
     231}
     232
     233static const char *OperName[] = {
    231234        // diadic
    232         "SizeOf", "AlignOf", "OffsetOf", "?+?", "?-?", "?\\?", "?*?", "?/?", "?%?", "||", "&&",
     235        "SizeOf", "AlignOf", "OffsetOf", "?+?", "?-?", "?*?", "?/?", "?%?", "||", "&&",
    233236        "?|?", "?&?", "?^?", "Cast", "?<<?", "?>>?", "?<?", "?>?", "?<=?", "?>=?", "?==?", "?!=?",
    234         "?=?", "?@=?", "?\\=?", "?*=?", "?/=?", "?%=?", "?+=?", "?-=?", "?<<=?", "?>>=?", "?&=?", "?^=?", "?|=?",
     237        "?=?", "?@=?", "?*=?", "?/=?", "?%=?", "?+=?", "?-=?", "?<<=?", "?>>=?", "?&=?", "?^=?", "?|=?",
    235238        "?[?]", "...",
    236239        // monadic
    237240        "+?", "-?", "AddressOf", "*?", "!?", "~?", "++?", "?++", "--?", "?--", "&&"
    238 }; // OperName
    239 
    240 Expression * build_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ) {
    241         Type * targetType = maybeMoveBuildType( decl_node );
     241};
     242
     243Expression *build_cast( DeclarationNode *decl_node, ExpressionNode *expr_node ) {
     244        Type *targetType = maybeMoveBuildType( decl_node );
    242245        if ( dynamic_cast< VoidType * >( targetType ) ) {
    243246                delete targetType;
     
    246249                return new CastExpr( maybeMoveBuild< Expression >(expr_node), targetType );
    247250        } // if
    248 } // build_cast
    249 
    250 Expression * build_virtual_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ) {
    251         Type * targetType = maybeMoveBuildType( decl_node );
    252         Expression * castArg = maybeMoveBuild< Expression >( expr_node );
    253         return new VirtualCastExpr( castArg, targetType );
    254 } // build_virtual_cast
    255 
    256 Expression * build_fieldSel( ExpressionNode * expr_node, Expression * member ) {
    257         UntypedMemberExpr * ret = new UntypedMemberExpr( member, maybeMoveBuild< Expression >(expr_node) );
    258         return ret;
    259 } // build_fieldSel
    260 
    261 Expression * build_pfieldSel( ExpressionNode * expr_node, Expression * member ) {
    262         UntypedExpr * deref = new UntypedExpr( new NameExpr( "*?" ) );
     251}
     252
     253Expression *build_fieldSel( ExpressionNode *expr_node, Expression *member ) {
     254        UntypedMemberExpr *ret = new UntypedMemberExpr( member, maybeMoveBuild< Expression >(expr_node) );
     255        return ret;
     256}
     257
     258Expression *build_pfieldSel( ExpressionNode *expr_node, Expression *member ) {
     259        UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) );
    263260        deref->location = expr_node->location;
    264261        deref->get_args().push_back( maybeMoveBuild< Expression >(expr_node) );
    265         UntypedMemberExpr * ret = new UntypedMemberExpr( member, deref );
    266         return ret;
    267 } // build_pfieldSel
    268 
    269 Expression * build_addressOf( ExpressionNode * expr_node ) {
     262        UntypedMemberExpr *ret = new UntypedMemberExpr( member, deref );
     263        return ret;
     264}
     265
     266Expression *build_addressOf( ExpressionNode *expr_node ) {
    270267                return new AddressExpr( maybeMoveBuild< Expression >(expr_node) );
    271 } // build_addressOf
    272 
    273 Expression * build_sizeOfexpr( ExpressionNode * expr_node ) {
     268}
     269Expression *build_sizeOfexpr( ExpressionNode *expr_node ) {
    274270        return new SizeofExpr( maybeMoveBuild< Expression >(expr_node) );
    275 } // build_sizeOfexpr
    276 
    277 Expression * build_sizeOftype( DeclarationNode * decl_node ) {
     271}
     272Expression *build_sizeOftype( DeclarationNode *decl_node ) {
    278273        return new SizeofExpr( maybeMoveBuildType( decl_node ) );
    279 } // build_sizeOftype
    280 
    281 Expression * build_alignOfexpr( ExpressionNode * expr_node ) {
     274}
     275Expression *build_alignOfexpr( ExpressionNode *expr_node ) {
    282276        return new AlignofExpr( maybeMoveBuild< Expression >(expr_node) );
    283 } // build_alignOfexpr
    284 
    285 Expression * build_alignOftype( DeclarationNode * decl_node ) {
     277}
     278Expression *build_alignOftype( DeclarationNode *decl_node ) {
    286279        return new AlignofExpr( maybeMoveBuildType( decl_node) );
    287 } // build_alignOftype
    288 
    289 Expression * build_offsetOf( DeclarationNode * decl_node, NameExpr * member ) {
     280}
     281Expression *build_offsetOf( DeclarationNode *decl_node, NameExpr *member ) {
    290282        Expression * ret = new UntypedOffsetofExpr( maybeMoveBuildType( decl_node ), member->get_name() );
    291283        delete member;
    292284        return ret;
    293 } // build_offsetOf
    294 
    295 Expression * build_and_or( ExpressionNode * expr_node1, ExpressionNode * expr_node2, bool kind ) {
     285}
     286
     287Expression *build_and_or( ExpressionNode *expr_node1, ExpressionNode *expr_node2, bool kind ) {
    296288        return new LogicalExpr( notZeroExpr( maybeMoveBuild< Expression >(expr_node1) ), notZeroExpr( maybeMoveBuild< Expression >(expr_node2) ), kind );
    297 } // build_and_or
    298 
    299 Expression * build_unary_val( OperKinds op, ExpressionNode * expr_node ) {
     289}
     290
     291Expression *build_unary_val( OperKinds op, ExpressionNode *expr_node ) {
    300292        std::list< Expression * > args;
    301293        args.push_back( maybeMoveBuild< Expression >(expr_node) );
    302294        return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args );
    303 } // build_unary_val
    304 
    305 Expression * build_unary_ptr( OperKinds op, ExpressionNode * expr_node ) {
     295}
     296Expression *build_unary_ptr( OperKinds op, ExpressionNode *expr_node ) {
    306297        std::list< Expression * > args;
    307298        args.push_back( new AddressExpr( maybeMoveBuild< Expression >(expr_node) ) );
    308299        return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args );
    309 } // build_unary_ptr
    310 
    311 Expression * build_binary_val( OperKinds op, ExpressionNode * expr_node1, ExpressionNode * expr_node2 ) {
     300}
     301Expression *build_binary_val( OperKinds op, ExpressionNode *expr_node1, ExpressionNode *expr_node2 ) {
    312302        std::list< Expression * > args;
    313303        args.push_back( maybeMoveBuild< Expression >(expr_node1) );
    314304        args.push_back( maybeMoveBuild< Expression >(expr_node2) );
    315305        return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args );
    316 } // build_binary_val
    317 
    318 Expression * build_binary_ptr( OperKinds op, ExpressionNode * expr_node1, ExpressionNode * expr_node2 ) {
     306}
     307Expression *build_binary_ptr( OperKinds op, ExpressionNode *expr_node1, ExpressionNode *expr_node2 ) {
    319308        std::list< Expression * > args;
    320309        args.push_back( new AddressExpr( maybeMoveBuild< Expression >(expr_node1) ) );
    321310        args.push_back( maybeMoveBuild< Expression >(expr_node2) );
    322311        return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args );
    323 } // build_binary_ptr
    324 
    325 Expression * build_cond( ExpressionNode * expr_node1, ExpressionNode * expr_node2, ExpressionNode * expr_node3 ) {
     312}
     313
     314Expression *build_cond( ExpressionNode *expr_node1, ExpressionNode *expr_node2, ExpressionNode *expr_node3 ) {
    326315        return new ConditionalExpr( notZeroExpr( maybeMoveBuild< Expression >(expr_node1) ), maybeMoveBuild< Expression >(expr_node2), maybeMoveBuild< Expression >(expr_node3) );
    327 } // build_cond
    328 
    329 Expression * build_comma( ExpressionNode * expr_node1, ExpressionNode * expr_node2 ) {
     316}
     317
     318Expression *build_comma( ExpressionNode *expr_node1, ExpressionNode *expr_node2 ) {
    330319        return new CommaExpr( maybeMoveBuild< Expression >(expr_node1), maybeMoveBuild< Expression >(expr_node2) );
    331 } // build_comma
    332 
    333 Expression * build_attrexpr( NameExpr * var, ExpressionNode * expr_node ) {
     320}
     321
     322Expression *build_attrexpr( NameExpr *var, ExpressionNode * expr_node ) {
    334323        return new AttrExpr( var, maybeMoveBuild< Expression >(expr_node) );
    335 } // build_attrexpr
    336 
    337 Expression * build_attrtype( NameExpr * var, DeclarationNode * decl_node ) {
     324}
     325Expression *build_attrtype( NameExpr *var, DeclarationNode * decl_node ) {
    338326        return new AttrExpr( var, maybeMoveBuildType( decl_node ) );
    339 } // build_attrtype
    340 
    341 Expression * build_tuple( ExpressionNode * expr_node ) {
     327}
     328
     329Expression *build_tuple( ExpressionNode * expr_node ) {
    342330        std::list< Expression * > exprs;
    343331        buildMoveList( expr_node, exprs );
    344332        return new UntypedTupleExpr( exprs );;
    345 } // build_tuple
    346 
    347 Expression * build_func( ExpressionNode * function, ExpressionNode * expr_node ) {
     333}
     334
     335Expression *build_func( ExpressionNode * function, ExpressionNode * expr_node ) {
    348336        std::list< Expression * > args;
    349337        buildMoveList( expr_node, args );
    350338        return new UntypedExpr( maybeMoveBuild< Expression >(function), args, nullptr );
    351 } // build_func
    352 
    353 Expression * build_range( ExpressionNode * low, ExpressionNode * high ) {
     339}
     340
     341Expression *build_range( ExpressionNode * low, ExpressionNode *high ) {
    354342        return new RangeExpr( maybeMoveBuild< Expression >( low ), maybeMoveBuild< Expression >( high ) );
    355 } // build_range
    356 
    357 Expression * build_asmexpr( ExpressionNode * inout, ConstantExpr * constraint, ExpressionNode * operand ) {
     343}
     344
     345Expression *build_asmexpr( ExpressionNode *inout, ConstantExpr *constraint, ExpressionNode *operand ) {
    358346        return new AsmExpr( maybeMoveBuild< Expression >( inout ), constraint, maybeMoveBuild< Expression >(operand) );
    359 } // build_asmexpr
    360 
    361 Expression * build_valexpr( StatementNode * s ) {
     347}
     348
     349Expression *build_valexpr( StatementNode *s ) {
    362350        return new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >(s) ) );
    363 } // build_valexpr
    364 
    365 Expression * build_typevalue( DeclarationNode * decl ) {
     351}
     352Expression *build_typevalue( DeclarationNode *decl ) {
    366353        return new TypeExpr( maybeMoveBuildType( decl ) );
    367 } // build_typevalue
    368 
    369 Expression * build_compoundLiteral( DeclarationNode * decl_node, InitializerNode * kids ) {
     354}
     355
     356Expression *build_compoundLiteral( DeclarationNode *decl_node, InitializerNode *kids ) {
    370357        Declaration * newDecl = maybeBuild< Declaration >(decl_node); // compound literal type
    371358        if ( DeclarationWithType * newDeclWithType = dynamic_cast< DeclarationWithType * >( newDecl ) ) { // non-sue compound-literal type
     
    393380                assert( false );
    394381        } // if
    395 } // build_compoundLiteral
     382}
    396383
    397384// Local Variables: //
  • src/Parser/InitializerNode.cc

    r0720e049 r3d4b23fa  
    1010// Created On       : Sat May 16 13:20:24 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 28 23:27:20 2017
    13 // Update Count     : 26
     12// Last Modified On : Sat Oct  1 23:09:51 2016
     13// Update Count     : 21
    1414//
    1515
     
    2222#include "SynTree/Initializer.h"
    2323
    24 InitializerNode::InitializerNode( ExpressionNode * _expr, bool aggrp, ExpressionNode * des )
    25                 : expr( _expr ), aggregate( aggrp ), designator( des ), kids( nullptr ), maybeConstructed( true ) {
     24InitializerNode::InitializerNode( ExpressionNode *_expr, bool aggrp, ExpressionNode *des )
     25                : expr( _expr ), aggregate( aggrp ), designator( des ), kids( 0 ), maybeConstructed( true ) {
    2626        if ( aggrp )
    2727                kids = dynamic_cast< InitializerNode * >( get_next() );
    2828
    29         if ( kids )
    30                 set_last( nullptr );
    31 } // InitializerNode::InitializerNode
     29        if ( kids != 0 )
     30                set_last( 0 );
     31}
    3232
    33 InitializerNode::InitializerNode( InitializerNode * init, bool aggrp, ExpressionNode * des )
    34                 : expr( nullptr ), aggregate( aggrp ), designator( des ), kids( nullptr ), maybeConstructed( true ) {
    35         if ( init )
     33InitializerNode::InitializerNode( InitializerNode *init, bool aggrp, ExpressionNode *des )
     34                : expr( 0 ), aggregate( aggrp ), designator( des ), kids( 0 ), maybeConstructed( true ) {
     35        if ( init != 0 )
    3636                set_last( init );
    3737
     
    3939                kids = dynamic_cast< InitializerNode * >( get_next() );
    4040
    41         if ( kids )
    42                 set_next( nullptr );
    43 } // InitializerNode::InitializerNode
     41        if ( kids != 0 )
     42                set_next( 0 );
     43}
    4444
    4545InitializerNode::~InitializerNode() {
     
    4747        delete designator;
    4848        delete kids;
    49 } // InitializerNode::~InitializerNode
     49}
    5050
    5151void InitializerNode::print( std::ostream &os, int indent ) const {
    5252        os << std::string( indent, ' ' ) << "Initializer expression" << std::endl;
    53 } // InitializerNode::print
     53}
    5454
    5555void InitializerNode::printOneLine( std::ostream &os ) const {
    5656        if ( ! aggregate ) {
    57                 if ( designator ) {
     57                if ( designator != 0 ) {
    5858                        os << "designated by: (";
    5959                        ExpressionNode *curdes = designator;
    60                         while ( curdes != nullptr) {
     60                        while ( curdes != 0) {
    6161                                curdes->printOneLine(os);
    6262                                curdes = (ExpressionNode *)(curdes->get_next());
     
    6565                        os << ")";
    6666                } // if
    67                 if ( expr ) expr->printOneLine( os );
     67                if ( expr ) expr->printOneLine(os);
    6868        } else {  // It's an aggregate
    6969                os << "[--";
    70                 if ( next_init() != nullptr )
    71                         next_init()->printOneLine( os );
     70                if ( next_init() != 0 )
     71                        next_init()->printOneLine(os);
    7272                if (aggregate) os << "--]";
    7373        } // if
     
    7676        if ( (moreInit = dynamic_cast< InitializerNode * >( get_next() ) ) ) {
    7777                moreInit->printOneLine( os );
    78         } // if
    79 } // InitializerNode::printOneLine
     78        }
     79}
    8080
    81 Initializer * InitializerNode::build() const {
     81Initializer *InitializerNode::build() const {
    8282        if ( aggregate ) {
    8383                // steal designators from children
     
    9393                return new ListInit( initlist, designlist, maybeConstructed );
    9494        } else {
    95                 if ( get_expression() ) {
     95                if ( get_expression() != 0) {
    9696                        return new SingleInit( maybeBuild< Expression >( get_expression() ), maybeConstructed );
    97                 } // if
     97                }
    9898        } // if
    99         return nullptr;
    100 } // InitializerNode::build
     99        return 0;
     100}
    101101
    102102// Local Variables: //
  • src/Parser/LinkageSpec.h

    r0720e049 r3d4b23fa  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:24:28 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:32:16 2017
    13 // Update Count     : 14
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Fri Jul  7 11:03:00 2017
     13// Update Count     : 13
    1414//
    1515
    16 #pragma once
     16#ifndef LINKAGESPEC_H
     17#define LINKAGESPEC_H
    1718
    1819#include <string>
     
    7778};
    7879
     80#endif // LINKAGESPEC_H
     81
    7982// Local Variables: //
    8083// tab-width: 4 //
  • src/Parser/ParseNode.h

    r0720e049 r3d4b23fa  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:28:16 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 27 12:08:08 2017
    13 // Update Count     : 788
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Mon Jun 12 13:00:00 2017
     13// Update Count     : 779
    1414//
    1515
    16 #pragma once
     16#ifndef PARSENODE_H
     17#define PARSENODE_H
    1718
    1819#include <string>
     
    140141};
    141142
    142 // Must harmonize with OperName.
    143143enum class OperKinds {
    144144        // diadic
    145         SizeOf, AlignOf, OffsetOf, Plus, Minus, Exp, Mul, Div, Mod, Or, And,
     145        SizeOf, AlignOf, OffsetOf, Plus, Minus, Mul, Div, Mod, Or, And,
    146146        BitOr, BitAnd, Xor, Cast, LShift, RShift, LThan, GThan, LEThan, GEThan, Eq, Neq,
    147         Assign, AtAssn, ExpAssn, MulAssn, DivAssn, ModAssn, PlusAssn, MinusAssn, LSAssn, RSAssn, AndAssn, ERAssn, OrAssn,
     147        Assign, AtAssn, MulAssn, DivAssn, ModAssn, PlusAssn, MinusAssn, LSAssn, RSAssn, AndAssn, ERAssn, OrAssn,
    148148        Index, Range,
    149149        // monadic
     
    159159Expression * build_constantFloat( const std::string &str );
    160160Expression * build_constantChar( const std::string &str );
     161Expression * build_constantZeroOne( const std::string &str );
    161162ConstantExpr * build_constantStr( const std::string &str );
    162163Expression * build_field_name_FLOATINGconstant( const std::string & str );
     
    169170
    170171Expression * build_cast( DeclarationNode * decl_node, ExpressionNode * expr_node );
    171 Expression * build_virtual_cast( DeclarationNode * decl_node, ExpressionNode * expr_node );
    172172Expression * build_fieldSel( ExpressionNode * expr_node, Expression * member );
    173173Expression * build_pfieldSel( ExpressionNode * expr_node, Expression * member );
     
    248248        static DeclarationNode * newAsmStmt( StatementNode * stmt ); // gcc external asm statement
    249249
    250         // Perhaps this would best fold into newAggragate.
    251         static DeclarationNode * newTreeStruct( Aggregate kind, const std::string * name, const std::string * parent, ExpressionNode * actuals, DeclarationNode * fields, bool body );
    252 
    253250        DeclarationNode();
    254251        ~DeclarationNode();
     
    335332
    336333        static UniqueName anonymous;
    337 
    338         // Temp to test TreeStruct
    339         const std::string * parent_name;
    340334}; // DeclarationNode
    341335
     
    449443std::ostream & operator<<( std::ostream & out, const ParseNode * node );
    450444
     445#endif // PARSENODE_H
     446
    451447// Local Variables: //
    452448// tab-width: 4 //
  • src/Parser/ParserTypes.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Sat Sep 22 08:58:10 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:33:28 2017
    13 // Update Count     : 350
     12// Last Modified On : Wed Jun 28 22:10:17 2017
     13// Update Count     : 349
    1414//
    1515
    16 #pragma once
     16#ifndef PARSER_HH
     17#define PARSER_HH
    1718
    1819int yylex();
     
    4142}; // Token
    4243
     44#endif // PARSER_HH
     45
    4346// Local Variables: //
    4447// tab-width: 4 //
  • src/Parser/TypeData.cc

    r0720e049 r3d4b23fa  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Aug  9 13:50:00 2017
    13 // Update Count     : 567
     12// Last Modified On : Wed Jun 28 15:28:00 2017
     13// Update Count     : 564
    1414//
    1515
     
    6363                aggregate.fields = nullptr;
    6464                aggregate.body = false;
    65                 aggregate.tagged = false;
    66                 aggregate.parent = nullptr;
    6765                break;
    6866          case AggregateInst:
     
    123121                delete aggregate.actuals;
    124122                delete aggregate.fields;
    125                 delete aggregate.parent;
    126123                // delete aggregate;
    127124                break;
     
    195192                newtype->aggregate.kind = aggregate.kind;
    196193                newtype->aggregate.body = aggregate.body;
    197                 newtype->aggregate.tagged = aggregate.tagged;
    198                 newtype->aggregate.parent = aggregate.parent ? new string( *aggregate.parent ) : nullptr;
    199194                break;
    200195          case AggregateInst:
     
    454449          case TypeData::Builtin:
    455450                if(td->builtintype == DeclarationNode::Zero) {
    456                         return new ZeroType( noQualifiers );
     451                        return new ZeroType( emptyQualifiers );
    457452                }
    458453                else if(td->builtintype == DeclarationNode::One) {
    459                         return new OneType( noQualifiers );
     454                        return new OneType( emptyQualifiers );
    460455                }
    461456                else {
     
    624619        switch ( td->aggregate.kind ) {
    625620          case DeclarationNode::Struct:
    626                 if ( td->aggregate.tagged ) {
    627                         at = new StructDecl( *td->aggregate.name, td->aggregate.parent, attributes, linkage );
    628                         buildForall( td->aggregate.params, at->get_parameters() );
    629                         break;
    630                 }
    631621          case DeclarationNode::Coroutine:
    632622          case DeclarationNode::Monitor:
     
    748738} // buildAggInst
    749739
    750 NamedTypeDecl * buildSymbolic( const TypeData * td, const string & name, Type::StorageClasses scs, LinkageSpec::Spec linkage ) {
     740NamedTypeDecl * buildSymbolic( const TypeData * td, const string & name, Type::StorageClasses scs ) {
    751741        assert( td->kind == TypeData::Symbolic );
    752742        NamedTypeDecl * ret;
    753743        assert( td->base );
    754744        if ( td->symbolic.isTypedef ) {
    755                 ret = new TypedefDecl( name, scs, typebuild( td->base ), linkage );
     745                ret = new TypedefDecl( name, scs, typebuild( td->base ) );
    756746        } else {
    757747                ret = new TypeDecl( name, scs, typebuild( td->base ), TypeDecl::Any );
     
    817807                return buildEnum( td, attributes );
    818808        } else if ( td->kind == TypeData::Symbolic ) {
    819                 return buildSymbolic( td, name, scs, linkage );
     809                return buildSymbolic( td, name, scs );
    820810        } else {
    821811                return (new ObjectDecl( name, scs, linkage, bitfieldWidth, typebuild( td ), init, attributes ))->set_asmName( asmName );
  • src/Parser/TypeData.h

    r0720e049 r3d4b23fa  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 15:18:36 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:32:47 2017
    13 // Update Count     : 188
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Jun 28 15:29:00 2017
     13// Update Count     : 186
    1414//
    1515
    16 #pragma once
     16#ifndef TYPEDATA_H
     17#define TYPEDATA_H
    1718
    1819#include "ParseNode.h"
     
    3031                DeclarationNode * fields;
    3132                bool body;
    32 
    33                 bool tagged;
    34                 const std::string * parent;
    3533        };
    3634
     
    115113void buildKRFunction( const TypeData::Function_t & function );
    116114
     115#endif // TYPEDATA_H
     116
    117117// Local Variables: //
    118118// tab-width: 4 //
  • src/Parser/TypedefTable.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Sat May 16 15:24:36 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:33:14 2017
    13 // Update Count     : 34
     12// Last Modified On : Wed Jun 28 21:56:34 2017
     13// Update Count     : 33
    1414//
    1515
    16 #pragma once
     16#ifndef TYPEDEFTABLE_H
     17#define TYPEDEFTABLE_H
    1718
    1819#include <map>
     
    9091};
    9192
     93#endif // TYPEDEFTABLE_H
     94
    9295// Local Variables: //
    9396// tab-width: 4 //
  • src/Parser/lex.ll

    r0720e049 r3d4b23fa  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Thu Jul 27 21:46:06 2017
    13  * Update Count     : 550
     12 * Last Modified On : Wed Jul 12 18:04:44 2017
     13 * Update Count     : 535
    1414 */
    1515
    1616%option yylineno
    17 %option noyywrap
    1817%option nounput
    1918
     
    126125op_unary {op_unary_only}|{op_unary_binary}|{op_unary_pre_post}
    127126
    128 op_binary_only "/"|"%"|"\\"|"^"|"&"|"|"|"<"|">"|"="|"=="|"!="|"<<"|">>"|"<="|">="|"+="|"-="|"*="|"/="|"%="|"\\="|"&="|"|="|"^="|"<<="|">>="
     127op_binary_only "/"|"%"|"^"|"&"|"|"|"<"|">"|"="|"=="|"!="|"<<"|">>"|"<="|">="|"+="|"-="|"*="|"/="|"%="|"&="|"|="|"^="|"<<="|">>="
    129128op_binary_over {op_unary_binary}|{op_binary_only}
    130129                                // op_binary_not_over "?"|"->"|"."|"&&"|"||"|"@="
     
    137136
    138137%%
    139                                 /* line directives */
     138                                   /* line directives */
    140139^{h_white}*"#"{h_white}*[0-9]+{h_white}*["][^"\n]+["].*"\n" {
    141140        /* " stop highlighting */
     
    233232int                             { KEYWORD_RETURN(INT); }
    234233__int128                { KEYWORD_RETURN(INT); }                                // GCC
    235 __int128_t              { KEYWORD_RETURN(INT); }                                // GCC
    236234__label__               { KEYWORD_RETURN(LABEL); }                              // GCC
    237235long                    { KEYWORD_RETURN(LONG); }
     
    268266__typeof                { KEYWORD_RETURN(TYPEOF); }                             // GCC
    269267__typeof__              { KEYWORD_RETURN(TYPEOF); }                             // GCC
    270 __uint128_t             { KEYWORD_RETURN(INT); }                                // GCC
    271268union                   { KEYWORD_RETURN(UNION); }
    272269unsigned                { KEYWORD_RETURN(UNSIGNED); }
    273270__builtin_va_list { KEYWORD_RETURN(VALIST); }                   // GCC
    274 virtual                 { KEYWORD_RETURN(VIRTUAL); }                    // CFA
    275271void                    { KEYWORD_RETURN(VOID); }
    276272volatile                { KEYWORD_RETURN(VOLATILE); }
     
    289285
    290286                                /* numeric constants */
     287"0"                             { NUMERIC_RETURN(ZERO); }                               // CFA
     288"1"                             { NUMERIC_RETURN(ONE); }                                // CFA
    291289{decimal_constant} { NUMERIC_RETURN(INTEGERconstant); }
    292290{octal_constant} { NUMERIC_RETURN(INTEGERconstant); }
     
    339337"-"                             { ASCIIOP_RETURN(); }
    340338"*"                             { ASCIIOP_RETURN(); }
    341 "\\"                    { ASCIIOP_RETURN(); }                                   // CFA, exponentiation
    342339"/"                             { ASCIIOP_RETURN(); }
    343340"%"                             { ASCIIOP_RETURN(); }
     
    364361"+="                    { NAMEDOP_RETURN(PLUSassign); }
    365362"-="                    { NAMEDOP_RETURN(MINUSassign); }
    366 "\\="                   { NAMEDOP_RETURN(EXPassign); }                  // CFA, exponentiation
    367363"*="                    { NAMEDOP_RETURN(MULTassign); }
    368364"/="                    { NAMEDOP_RETURN(DIVassign); }
     
    419415
    420416                                /* unknown characters */
    421 .                               { printf("unknown character(s):\"%s\" on line %d\n", yytext, yylineno); }
     417.                       { printf("unknown character(s):\"%s\" on line %d\n", yytext, yylineno); }
    422418
    423419%%
  • src/Parser/parser.yy

    r0720e049 r3d4b23fa  
    99// Author           : Peter A. Buhr
    1010// Created On       : Sat Sep  1 20:22:55 2001
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Aug  4 13:33:00 2017
    13 // Update Count     : 2475
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Jul 12 18:23:36 2017
     13// Update Count     : 2426
    1414//
    1515
     
    118118%token RESTRICT                                                                                 // C99
    119119%token ATOMIC                                                                                   // C11
    120 %token FORALL LVALUE MUTEX VIRTUAL                                              // CFA
    121 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED
     120%token FORALL LVALUE MUTEX                                                              // CFA
     121%token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED ZERO_T ONE_T
     122%token VALIST                                                                                   // GCC
    122123%token BOOL COMPLEX IMAGINARY                                                   // C99
    123 %token ZERO_T ONE_T                                                                             // CFA
    124 %token VALIST                                                                                   // GCC
    125124%token TYPEOF LABEL                                                                             // GCC
    126125%token ENUM STRUCT UNION
     
    142141// converted into the tuple index (.)(1). e.g., 3.x
    143142%token<tok>     REALDECIMALconstant     REALFRACTIONconstant    FLOATINGconstant
     143%token<tok> ZERO                                ONE                                             // CFA
    144144
    145145// multi-character operators
     
    151151%token ELLIPSIS                                                                                 // ...
    152152
    153 %token EXPassign        MULTassign      DIVassign       MODassign       // \=   *=      /=      %=
     153%token MULTassign       DIVassign       MODassign                               // *=   /=      %=/
    154154%token PLUSassign       MINUSassign                                                     // +=   -=
    155155%token LSassign         RSassign                                                        // <<=  >>=
     
    158158%token ATassign                                                                                 // @=
    159159
    160 %type<tok> identifier  no_attr_identifier
     160%type<tok> identifier  no_attr_identifier  zero_one
    161161%type<tok> identifier_or_type_name  no_attr_identifier_or_type_name  attr_name
    162162%type<constant> string_literal
     
    168168%type<op> ptrref_operator                               unary_operator                          assignment_operator
    169169%type<en> primary_expression                    postfix_expression                      unary_expression
    170 %type<en> cast_expression                               exponential_expression          multiplicative_expression       additive_expression
    171 %type<en> shift_expression                              relational_expression           equality_expression
    172 %type<en> AND_expression                                exclusive_OR_expression         inclusive_OR_expression
    173 %type<en> logical_AND_expression                logical_OR_expression
    174 %type<en> conditional_expression                constant_expression                     assignment_expression           assignment_expression_opt
     170%type<en> cast_expression                               multiplicative_expression       additive_expression                     shift_expression
     171%type<en> relational_expression                 equality_expression                     AND_expression                          exclusive_OR_expression
     172%type<en> inclusive_OR_expression               logical_AND_expression          logical_OR_expression           conditional_expression
     173%type<en> constant_expression                   assignment_expression           assignment_expression_opt
    175174%type<en> comma_expression                              comma_expression_opt
    176 %type<en> argument_expression_list              argument_expression                     default_initialize_opt
     175%type<en> argument_expression_list              argument_expression                     assignment_opt
    177176%type<fctl> for_control_expression
    178177%type<en> subrange
     
    182181%type<en> asm_clobbers_list_opt
    183182%type<flag> asm_volatile_opt
    184 %type<en> handler_predicate_opt
    185183
    186184// statements
     
    360358        ;
    361359
     360zero_one:                                                                                               // CFA
     361        ZERO
     362        | ONE
     363        ;
     364
    362365string_literal:
    363366        string_literal_list                                                     { $$ = build_constantStr( *$1 ); }
     
    379382        IDENTIFIER                                                                                      // typedef name cannot be used as a variable name
    380383                { $$ = new ExpressionNode( build_varref( $1 ) ); }
     384        | zero_one
     385                { $$ = new ExpressionNode( build_constantZeroOne( *$1 ) ); }
    381386        | tuple
    382387        | '(' comma_expression ')'
     
    478483                        $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) );
    479484                }
     485        | zero_one fraction_constants
     486                {
     487                        $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantZeroOne( *$1 ), $2 ) );
     488                }
    480489        ;
    481490
     
    528537        | ALIGNOF unary_expression                                                      // GCC, variable alignment
    529538                { $$ = new ExpressionNode( build_alignOfexpr( $2 ) ); }
    530         | ALIGNOF '(' type_no_function ')'                                      // GCC, type alignment
     539        | ALIGNOF '(' type_no_function ')'                              // GCC, type alignment
    531540                { $$ = new ExpressionNode( build_alignOftype( $3 ) ); }
    532541        | OFFSETOF '(' type_no_function ',' no_attr_identifier ')'
     
    560569        | '(' type_no_function ')' cast_expression
    561570                { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
    562                 // VIRTUAL cannot be opt because of look ahead issues
    563         | '(' VIRTUAL ')' cast_expression
    564                 { $$ = new ExpressionNode( build_virtual_cast( nullptr, $4 ) ); }
    565         | '(' VIRTUAL type_no_function ')' cast_expression
    566                 { $$ = new ExpressionNode( build_virtual_cast( $3, $5 ) ); }
    567571//      | '(' type_no_function ')' tuple
    568572//              { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
    569573        ;
    570574
    571 exponential_expression:
     575multiplicative_expression:
    572576        cast_expression
    573         | exponential_expression '\\' cast_expression
    574                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Exp, $1, $3 ) ); }
    575         ;
    576 
    577 multiplicative_expression:
    578         exponential_expression
    579         | multiplicative_expression '*' exponential_expression
     577        | multiplicative_expression '*' cast_expression
    580578                { $$ = new ExpressionNode( build_binary_val( OperKinds::Mul, $1, $3 ) ); }
    581         | multiplicative_expression '/' exponential_expression
     579        | multiplicative_expression '/' cast_expression
    582580                { $$ = new ExpressionNode( build_binary_val( OperKinds::Div, $1, $3 ) ); }
    583         | multiplicative_expression '%' exponential_expression
     581        | multiplicative_expression '%' cast_expression
    584582                { $$ = new ExpressionNode( build_binary_val( OperKinds::Mod, $1, $3 ) ); }
    585583        ;
     
    680678        '='                                                                                     { $$ = OperKinds::Assign; }
    681679        | ATassign                                                                      { $$ = OperKinds::AtAssn; }
    682         | EXPassign                                                                     { $$ = OperKinds::ExpAssn; }
    683680        | MULTassign                                                            { $$ = OperKinds::MulAssn; }
    684681        | DIVassign                                                                     { $$ = OperKinds::DivAssn; }
     
    942939
    943940with_statement:
    944         WITH '(' tuple_expression_list ')' compound_statement
     941        WITH identifier_list compound_statement
    945942                { $$ = (StatementNode *)0; }                                    // FIX ME
    946943        ;
     
    969966
    970967handler_clause:
    971         handler_key '(' push push exception_declaration pop handler_predicate_opt ')' compound_statement pop
    972                 { $$ = new StatementNode( build_catch( $1, $5, $7, $9 ) ); }
    973         | handler_clause handler_key '(' push push exception_declaration pop handler_predicate_opt ')' compound_statement pop
    974                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, $6, $8, $10 ) ) ); }
    975         ;
    976 
    977 handler_predicate_opt:
    978         //empty
    979                 { $$ = nullptr; }
    980         | ';' conditional_expression
    981                 { $$ = $2; }
     968        // TEMPORARY, TEST EXCEPTIONS
     969        handler_key '(' push push INTEGERconstant pop ')' compound_statement pop
     970                { $$ = new StatementNode( build_catch( $1, nullptr, new ExpressionNode( build_constantInteger( *$5 ) ), $8 ) ); }
     971        | handler_clause handler_key '(' push push INTEGERconstant pop ')' compound_statement pop
     972                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, nullptr, new ExpressionNode( build_constantInteger( *$6 ) ), $9 ) ) ); }
     973
     974        | handler_key '(' push push exception_declaration pop ')' compound_statement pop
     975                { $$ = new StatementNode( build_catch( $1, $5, nullptr, $8 ) ); }
     976        | handler_clause handler_key '(' push push exception_declaration pop ')' compound_statement pop
     977                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, $6, nullptr, $9 ) ) ); }
    982978        ;
    983979
     
    15061502        | IMAGINARY                                                                                     // C99
    15071503                { $$ = DeclarationNode::newComplexType( DeclarationNode::Imaginary ); }
     1504        | VALIST                                                                                        // GCC, __builtin_va_list
     1505                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }
    15081506        | ZERO_T
    15091507                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); }
    15101508        | ONE_T
    15111509                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); }
    1512         | VALIST                                                                                        // GCC, __builtin_va_list
    1513                 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }
    15141510        ;
    15151511
     
    18491845cfa_parameter_declaration:                                                              // CFA, new & old style parameter declaration
    18501846        parameter_declaration
    1851         | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name default_initialize_opt
     1847        | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name assignment_opt
    18521848                { $$ = $1->addName( $2 ); }
    1853         | cfa_abstract_tuple identifier_or_type_name default_initialize_opt
     1849        | cfa_abstract_tuple identifier_or_type_name assignment_opt
    18541850                // To obtain LR(1), these rules must be duplicated here (see cfa_abstract_declarator).
    18551851                { $$ = $1->addName( $2 ); }
    1856         | type_qualifier_list cfa_abstract_tuple identifier_or_type_name default_initialize_opt
     1852        | type_qualifier_list cfa_abstract_tuple identifier_or_type_name assignment_opt
    18571853                { $$ = $2->addName( $3 )->addQualifiers( $1 ); }
    18581854        | cfa_function_specifier
     
    18711867parameter_declaration:
    18721868                // No SUE declaration in parameter list.
    1873         declaration_specifier_nobody identifier_parameter_declarator default_initialize_opt
     1869        declaration_specifier_nobody identifier_parameter_declarator assignment_opt
    18741870                {
    18751871                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    18761872                        $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr );
    18771873                }
    1878         | declaration_specifier_nobody type_parameter_redeclarator default_initialize_opt
     1874        | declaration_specifier_nobody type_parameter_redeclarator assignment_opt
    18791875                {
    18801876                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    18841880
    18851881abstract_parameter_declaration:
    1886         declaration_specifier_nobody default_initialize_opt
     1882        declaration_specifier_nobody assignment_opt
    18871883                { $$ = $1->addInitializer( $2 ? new InitializerNode( $2 ) : nullptr ); }
    1888         | declaration_specifier_nobody abstract_parameter_declarator default_initialize_opt
     1884        | declaration_specifier_nobody abstract_parameter_declarator assignment_opt
    18891885                { $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); }
    18901886        ;
     
    19301926        | '=' initializer
    19311927                { $$ = $2; }
    1932         | '=' VOID
    1933                 { $$ = nullptr; }
    19341928        | ATassign initializer
    19351929                { $$ = $2->set_maybeConstructed( false ); }
     
    22282222        // empty
    22292223                { $$ = (StatementNode *)0; }                                    // FIX ME
    2230         | WITH '(' tuple_expression_list ')'
     2224        | WITH identifier_list
    22312225                { $$ = (StatementNode *)0; }                                    // FIX ME
    22322226        ;
     
    30513045        ;
    30523046
    3053 default_initialize_opt:
     3047assignment_opt:
    30543048        // empty
    30553049                { $$ = nullptr; }
  • src/Parser/parserutility.cc

    r0720e049 r3d4b23fa  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 15:30:39 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Tus Jul 18 10:12:00 2017
    13 // Update Count     : 8
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Jun 28 22:11:32 2017
     13// Update Count     : 7
    1414//
    1515
     
    2626        UntypedExpr *comparison = new UntypedExpr( new NameExpr( "?!=?" ) );
    2727        comparison->get_args().push_back( orig );
    28         comparison->get_args().push_back( new ConstantExpr( Constant( new ZeroType( noQualifiers ), "0", (unsigned long long int)0 ) ) );
     28        comparison->get_args().push_back( new ConstantExpr( Constant( new ZeroType( emptyQualifiers ), "0", (unsigned long long int)0 ) ) );
    2929        return new CastExpr( comparison, new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
    3030}
  • src/Parser/parserutility.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Sat May 16 15:31:46 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:32:58 2017
    13 // Update Count     : 4
     12// Last Modified On : Wed Jun 28 22:11:40 2017
     13// Update Count     : 3
    1414//
    1515
    16 #pragma once
     16#ifndef PARSEUTILITY_H
     17#define PARSEUTILITY_H
    1718
    1819#include "SynTree/SynTree.h"
    1920
    2021Expression *notZeroExpr( Expression *orig );
     22
     23#endif // PARSEUTILITY_H
    2124
    2225// Local Variables: //
  • src/ResolvExpr/Alternative.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Sat May 16 23:45:43 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:36:36 2017
    13 // Update Count     : 3
     12// Last Modified On : Sat May 16 23:54:39 2015
     13// Update Count     : 2
    1414//
    1515
    16 #pragma once
     16#ifndef ALTERNATIVE_H
     17#define ALTERNATIVE_H
    1718
    1819#include <list>
     
    4647} // namespace ResolvExpr
    4748
     49#endif // ALTERNATIVE_H
     50
    4851// Local Variables: //
    4952// tab-width: 4 //
  • src/ResolvExpr/AlternativeFinder.cc

    r0720e049 r3d4b23fa  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sat May 16 23:52:08 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Jul 26 11:33:00 2017
    13 // Update Count     : 31
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Mar 17 09:14:17 2017
     13// Update Count     : 30
    1414//
    1515
     
    878878        }
    879879
    880         void AlternativeFinder::visit( VirtualCastExpr * castExpr ) {
    881                 assertf( castExpr->get_result(), "Implicate virtual cast targets not yet supported." );
    882                 AlternativeFinder finder( indexer, env );
    883                 // don't prune here, since it's guaranteed all alternatives will have the same type
    884                 // (giving the alternatives different types is half of the point of ConstructorExpr nodes)
    885                 finder.findWithAdjustment( castExpr->get_arg(), false );
    886                 for ( Alternative & alt : finder.alternatives ) {
    887                         alternatives.push_back( Alternative(
    888                                 new VirtualCastExpr( alt.expr->clone(), castExpr->get_result()->clone() ),
    889                                 alt.env, alt.cost ) );
    890                 }
    891         }
    892 
    893880        void AlternativeFinder::visit( UntypedMemberExpr *memberExpr ) {
    894881                AlternativeFinder funcFinder( indexer, env );
  • src/ResolvExpr/AlternativeFinder.h

    r0720e049 r3d4b23fa  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sat May 16 23:56:12 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Jul 26 11:24:00 2017
    13 // Update Count     : 4
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Tue Apr 19 11:44:53 2016
     13// Update Count     : 2
    1414//
    1515
    16 #pragma once
     16#ifndef ALTERNATIVEFINDER_H
     17#define ALTERNATIVEFINDER_H
    1718
    1819#include <set>
     
    4950                virtual void visit( AddressExpr *addressExpr );
    5051                virtual void visit( CastExpr *castExpr );
    51                 virtual void visit( VirtualCastExpr *castExpr );
    5252                virtual void visit( UntypedMemberExpr *memberExpr );
    5353                virtual void visit( MemberExpr *memberExpr );
     
    132132} // namespace ResolvExpr
    133133
     134#endif // ALTERNATIVEFINDER_H
     135
    134136// Local Variables: //
    135137// tab-width: 4 //
  • src/ResolvExpr/AlternativePrinter.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Sun May 17 06:55:43 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:37:09 2017
    13 // Update Count     : 4
     12// Last Modified On : Sun May 17 06:57:12 2015
     13// Update Count     : 3
    1414//
    1515
    16 #pragma once
     16#ifndef ALTERNATIVEPRINTER_H
     17#define ALTERNATIVEPRINTER_H
    1718
    1819#include <iostream>
     
    3334} // namespace ResolvExpr
    3435
     36#endif // ALTERNATIVEPRINTER_H
     37
    3538// Local Variables: //
    3639// tab-width: 4 //
  • src/ResolvExpr/ConversionCost.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Sun May 17 09:37:28 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:38:24 2017
    13 // Update Count     : 4
     12// Last Modified On : Wed Mar  2 17:35:56 2016
     13// Update Count     : 3
    1414//
    1515
    16 #pragma once
     16#ifndef CONVERSIONCOST_H
     17#define CONVERSIONCOST_H
    1718
    1819#include "SynTree/Visitor.h"
     
    5051} // namespace ResolvExpr
    5152
     53#endif // CONVERSIONCOST_H */
     54
    5255// Local Variables: //
    5356// tab-width: 4 //
  • src/ResolvExpr/Cost.h

    r0720e049 r3d4b23fa  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 09:39:50 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:35:55 2017
    13 // Update Count     : 5
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Jul 22 16:43:10 2015
     13// Update Count     : 4
    1414//
    1515
    16 #pragma once
     16#ifndef COST_H
     17#define COST_H
    1718
    1819#include <iostream>
     
    113114} // namespace ResolvExpr
    114115
     116#endif // COST_H
     117
    115118// Local Variables: //
    116119// tab-width: 4 //
  • src/ResolvExpr/CurrentObject.cc

    r0720e049 r3d4b23fa  
    3838                                return constExpr->get_constant()->get_ival();
    3939                        } else {
    40                                 assertf( false, "Non-integer constant expression in getConstValue %s", toString( constExpr ).c_str() ); // xxx - might be semantic error
     40                                assertf( false, "Non-integer constant expression in getConstValue", toString( constExpr ).c_str() ); // xxx - might be semantic error
    4141                        }
    4242                } else if ( dynamic_cast< OneType * >( constExpr->get_result() ) ) {
     
    163163                                setPosition( castExpr->get_arg() );
    164164                        } else if ( VariableExpr * varExpr = dynamic_cast< VariableExpr * >( expr ) ) {
    165                                 assertf( dynamic_cast<EnumInstType *> ( varExpr->get_result() ), "ArrayIterator given variable that isn't an enum constant : %s", toString( expr ).c_str() );
     165                                assertf( dynamic_cast<EnumInstType *> ( varExpr->get_result() ), "ArrayIterator given variable that isn't an enum constant", toString( expr ).c_str() );
    166166                                index = 0; // xxx - get actual value of enum constant
    167167                        } else if ( dynamic_cast< SizeofExpr * >( expr ) || dynamic_cast< AlignofExpr * >( expr ) ) {
     
    505505                        curTypes = newTypes;
    506506                        newTypes.clear();
    507                         assertf( desigAlts.size() == curTypes.size(), "Designator alternatives (%zu) and current types (%zu) out of sync", desigAlts.size(), curTypes.size() );
     507                        assertf( desigAlts.size() == curTypes.size(), "Designator alternatives (%d) and current types (%d) out of sync", desigAlts.size(), curTypes.size() );
    508508                } // for
    509509                if ( desigAlts.size() > 1 ) {
  • src/ResolvExpr/CurrentObject.h

    r0720e049 r3d4b23fa  
    99// Author           : Rob Schluntz
    1010// Created On       : Thu Jun  8 11:07:25 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:36:48 2017
    13 // Update Count     : 3
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Thu Jun  8 11:07:41 2017
     13// Update Count     : 2
    1414//
    1515
    16 #pragma once
     16#ifndef CURRENT_OBJECT_H
     17#define CURRENT_OBJECT_H
    1718
    1819#include <stack>
     
    5051} // namespace ResolvExpr
    5152
     53#endif // CURRENT_OBJECT_H
     54
    5255// Local Variables: //
    5356// tab-width: 4 //
  • src/ResolvExpr/FindOpenVars.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Sun May 17 09:46:04 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:35:18 2017
    13 // Update Count     : 3
     12// Last Modified On : Sun May 17 09:47:20 2015
     13// Update Count     : 2
    1414//
    1515
    16 #pragma once
     16#ifndef FINDOPENVARS_H
     17#define FINDOPENVARS_H
    1718
    1819#include "Unify.h"
     
    2425} // namespace ResolvExpr
    2526
     27#endif // FINDOPENVARS_H
     28
    2629// Local Variables: //
    2730// tab-width: 4 //
  • src/ResolvExpr/RenameVars.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Sun May 17 12:10:28 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:33:54 2017
    13 // Update Count     : 4
     12// Last Modified On : Wed Mar  2 17:36:39 2016
     13// Update Count     : 3
    1414//
    1515
    16 #pragma once
     16#ifndef RESOLVEXPR_RENAMEVARS_H
     17#define RESOLVEXPR_RENAMEVARS_H
    1718
    1819#include <list>
     
    5556} // namespace ResolvExpr
    5657
     58#endif // RENAMEVARS_H
     59
    5760// Local Variables: //
    5861// tab-width: 4 //
  • src/ResolvExpr/ResolveTypeof.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Sun May 17 12:14:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:38:35 2017
    13 // Update Count     : 3
     12// Last Modified On : Sun May 17 12:16:29 2015
     13// Update Count     : 2
    1414//
    1515
    16 #pragma once
     16#ifndef RESOLVETYPEOF_H
     17#define RESOLVETYPEOF_H
    1718
    1819#include "SynTree/SynTree.h"
     
    2324} // namespace ResolvExpr
    2425
     26#endif // RESOLVETYPEOF_H
     27
    2528// Local Variables: //
    2629// tab-width: 4 //
  • src/ResolvExpr/Resolver.cc

    r0720e049 r3d4b23fa  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 12:17:01 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Tus Aug  8 16:06:00 2017
    13 // Update Count     : 212
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Mar 23 17:23:14 2017
     13// Update Count     : 211
    1414//
    1515
     
    7171                virtual void visit( ReturnStmt *returnStmt ) override;
    7272                virtual void visit( ThrowStmt *throwStmt ) override;
    73                 virtual void visit( CatchStmt *catchStmt ) override;
    7473
    7574                virtual void visit( SingleInit *singleInit ) override;
     
    369368
    370369        void Resolver::visit( ThrowStmt *throwStmt ) {
    371                 // TODO: Replace *exception type with &exception type.
    372370                if ( throwStmt->get_expr() ) {
    373                         StructDecl * exception_decl =
    374                                 lookupStruct( "__cfaehm__base_exception_t" );
    375                         assert( exception_decl );
    376                         Expression * wrapped = new CastExpr(
    377                                 throwStmt->get_expr(),
    378                                 new PointerType(
    379                                         noQualifiers,
    380                                         new StructInstType(
    381                                                 noQualifiers,
    382                                                 exception_decl
    383                                                 )
    384                                         )
    385                                 );
     371                        Expression * wrapped = new CastExpr( throwStmt->get_expr(), new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
    386372                        Expression * newExpr = findSingleExpression( wrapped, *this );
    387373                        throwStmt->set_expr( newExpr );
    388                 }
    389         }
    390 
    391         void Resolver::visit( CatchStmt *catchStmt ) {
    392                 if ( catchStmt->get_cond() ) {
    393                         Expression * wrapped = new CastExpr(
    394                                 catchStmt->get_cond(),
    395                                 new BasicType( noQualifiers, BasicType::Bool )
    396                                 );
    397                         catchStmt->set_cond( findSingleExpression( wrapped, *this ) );
    398374                }
    399375        }
  • src/ResolvExpr/Resolver.h

    r0720e049 r3d4b23fa  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 12:18:34 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:36:57 2017
    13 // Update Count     : 3
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Thu Apr 14 15:06:53 2016
     13// Update Count     : 2
    1414//
    1515
    16 #pragma once
     16#ifndef RESOLVER_H
     17#define RESOLVER_H
    1718
    1819#include "SynTree/SynTree.h"
     
    2829} // namespace ResolvExpr
    2930
     31#endif // RESOLVER_H
     32
    3033// Local Variables: //
    3134// tab-width: 4 //
  • src/ResolvExpr/TypeEnvironment.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Sun May 17 12:24:58 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:35:45 2017
    13 // Update Count     : 3
     12// Last Modified On : Sun May 17 12:26:52 2015
     13// Update Count     : 2
    1414//
    1515
    16 #pragma once
     16#ifndef TYPEENVIRONMENT_H
     17#define TYPEENVIRONMENT_H
    1718
    1819#include <string>
     
    9899} // namespace ResolvExpr
    99100
     101#endif // TYPEENVIRONMENT_H */
     102
    100103// Local Variables: //
    101104// tab-width: 4 //
  • src/ResolvExpr/TypeMap.h

    r0720e049 r3d4b23fa  
    99// Author           : Aaron B. Moss
    1010// Created On       : Fri Feb 19 13:55:00 2016
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:37:19 2017
    13 // Update Count     : 2
    14 //
    15 
    16 #pragma once
     11// Last Modified By : Aaron B. Moss
     12// Last Modified On : Fri Feb 19 13:55:00 2016
     13// Update Count     : 1
     14//
     15
     16#ifndef _TYPEMAP_H
     17#define _TYPEMAP_H
    1718
    1819#include <map>
     
    203204}  // namespace ResolvExpr
    204205
     206#endif // _TYPEMAP_H
     207
    205208// Local Variables: //
    206209// tab-width: 4 //
  • src/ResolvExpr/Unify.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Sun May 17 13:09:04 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 23:09:34 2017
    13 // Update Count     : 3
     12// Last Modified On : Sun May 17 13:10:34 2015
     13// Update Count     : 2
    1414//
    1515
    16 #pragma once
     16#ifndef UNIFY_H
     17#define UNIFY_H
    1718
    1819#include <map>
     
    7172} // namespace ResolvExpr
    7273
     74#endif // UNIFY_H
     75
    7376// Local Variables: //
    7477// tab-width: 4 //
  • src/ResolvExpr/typeops.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Sun May 17 07:28:22 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:36:18 2017
    13 // Update Count     : 3
     12// Last Modified On : Sun May 17 07:33:11 2015
     13// Update Count     : 2
    1414//
    1515
    16 #pragma once
     16#ifndef TYPEOPS_H
     17#define TYPEOPS_H
    1718
    1819#include "SynTree/SynTree.h"
     
    156157} // namespace ResolvExpr
    157158
     159#endif // TYPEOPS_H
     160
    158161// Local Variables: //
    159162// tab-width: 4 //
  • src/SymTab/AddVisit.h

    r0720e049 r3d4b23fa  
    1414//
    1515
    16 #include "SynTree/Statement.h"
    17 
    1816namespace SymTab {
    1917        void addDecls( std::list< Declaration* > &declsToAdd, std::list< Statement* > &statements, std::list< Statement* >::iterator i );
     
    3028
    3129                        if ( stmt == stmts.end() ) break;
    32 
     30                       
    3331                        // run mutator on statement
    3432                        maybeAccept( *stmt, visitor );
     
    6159
    6260                        if ( decl == translationUnit.end() ) break;
    63 
     61                       
    6462                        // run mutator on declaration
    6563                        maybeAccept( *decl, visitor );
  • src/SymTab/Autogen.cc

    r0720e049 r3d4b23fa  
    1010// Created On       : Thu Mar 03 15:45:56 2016
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Jul 14 16:41:00 2017
    13 // Update Count     : 62
     12// Last Modified On : Wed Jun 28 15:30:00 2017
     13// Update Count     : 61
    1414//
     15
     16#include <list>
     17#include <iterator>
     18#include "SynTree/Visitor.h"
     19#include "SynTree/Type.h"
     20#include "SynTree/Statement.h"
     21#include "SynTree/TypeSubstitution.h"
     22#include "Common/utility.h"
     23#include "AddVisit.h"
     24#include "MakeLibCfa.h"
    1525#include "Autogen.h"
    16 
    17 #include <algorithm>               // for count_if
    18 #include <cassert>                 // for safe_dynamic_cast, assert, assertf
    19 #include <iterator>                // for back_insert_iterator, back_inserter
    20 #include <list>                    // for list, _List_iterator, list<>::iter...
    21 #include <set>                     // for set, _Rb_tree_const_iterator
    22 #include <vector>                  // for vector
    23 
    24 #include "AddVisit.h"              // for addVisit
    25 #include "Common/ScopedMap.h"      // for ScopedMap<>::const_iterator, Scope...
    26 #include "Common/utility.h"        // for cloneAll, operator+
    27 #include "GenPoly/DeclMutator.h"   // for DeclMutator
    28 #include "GenPoly/ScopedSet.h"     // for ScopedSet, ScopedSet<>::iterator
    29 #include "SymTab/Mangler.h"        // for Mangler
    30 #include "SynTree/Mutator.h"       // for maybeMutate
    31 #include "SynTree/Statement.h"     // for CompoundStmt, ReturnStmt, ExprStmt
    32 #include "SynTree/Type.h"          // for FunctionType, Type, TypeInstType
    33 #include "SynTree/Visitor.h"       // for maybeAccept, Visitor, acceptAll
    34 
    35 class Attribute;
     26#include "GenPoly/ScopedSet.h"
     27#include "Common/ScopedMap.h"
     28#include "SymTab/Mangler.h"
     29#include "GenPoly/DeclMutator.h"
    3630
    3731namespace SymTab {
     
    407401        void makeStructFunctions( StructDecl *aggregateDecl, StructInstType *refType, unsigned int functionNesting, std::list< Declaration * > & declsToAdd, const std::vector< FuncData > & data ) {
    408402                // Builtins do not use autogeneration.
    409                 if ( aggregateDecl->get_linkage() == LinkageSpec::BuiltinCFA ||
     403                if ( aggregateDecl->get_linkage() == LinkageSpec::Builtin ||
    410404                         aggregateDecl->get_linkage() == LinkageSpec::BuiltinC ) {
    411405                        return;
     
    518512                // Make function polymorphic in same parameters as generic union, if applicable
    519513                const std::list< TypeDecl* > & typeParams = aggregateDecl->get_parameters(); // List of type variables to be placed on the generated functions
    520 
     514               
    521515                // default ctor/dtor need only first parameter
    522516                // void ?{}(T *); void ^?{}(T *);
  • src/SymTab/Autogen.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Sun May 17 21:53:34 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:50:25 2017
    13 // Update Count     : 15
     12// Last Modified On : Wed Jun 21 17:25:26 2017
     13// Update Count     : 14
    1414//
    1515
    16 #pragma once
     16#ifndef AUTOGEN_H
     17#define AUTOGEN_H
    1718
    18 #include <cassert>                // for assert
    19 #include <iterator>               // for back_insert_iterator, back_inserter
    20 #include <list>                   // for list
    21 #include <string>                 // for string, operator==
    22 
    23 #include "Common/UniqueName.h"    // for UniqueName
    24 #include "InitTweak/InitTweak.h"  // for InitExpander
    25 #include "Parser/LinkageSpec.h"   // for C
    26 #include "SynTree/Constant.h"     // for Constant
    27 #include "SynTree/Declaration.h"  // for ObjectDecl, Declaration (ptr only)
    28 #include "SynTree/Expression.h"   // for UntypedExpr, NameExpr, VariableExpr
    29 #include "SynTree/Initializer.h"  // for SingleInit
    30 #include "SynTree/Label.h"        // for Label, noLabels
    31 #include "SynTree/Statement.h"    // for Statement (ptr only), CompoundStmt
    32 #include "SynTree/Type.h"         // for Type, ArrayType, Type::Qualifiers
     19#include <string>
     20#include "SynTree/Statement.h"
     21#include "SynTree/Expression.h"
     22#include "SynTree/Declaration.h"
     23#include "SynTree/Initializer.h"
     24#include "InitTweak/InitTweak.h"
    3325
    3426namespace SymTab {
     
    163155                if ( isUnnamedBitfield( obj ) ) return;
    164156
    165                 bool addCast = (fname == "?{}" || fname == "^?{}") && ( !obj || ( obj && ! obj->get_bitfieldWidth() ) );
     157                bool addCast = (fname == "?{}" || fname == "^?{}") && ( !obj || ( obj && obj->get_bitfieldWidth() == NULL ) );
    166158                std::list< Statement * > stmts;
    167159                genCall( srcParam, dstParam, fname, back_inserter( stmts ), obj->get_type(), addCast, forward );
     
    182174        }
    183175} // namespace SymTab
    184 
    185 // Local Variables: //
    186 // tab-width: 4 //
    187 // mode: c++ //
    188 // compile-command: "make install" //
    189 // End: //
    190 
     176#endif // AUTOGEN_H
  • src/SymTab/FixFunction.cc

    r0720e049 r3d4b23fa  
    1515
    1616#include "FixFunction.h"
    17 
    18 #include <list>                   // for list
    19 
    20 #include "Common/utility.h"       // for maybeClone
    21 #include "SynTree/Declaration.h"  // for FunctionDecl, ObjectDecl, Declarati...
    22 #include "SynTree/Type.h"         // for ArrayType, PointerType, Type, Basic...
     17#include "SynTree/Declaration.h"
     18#include "SynTree/Type.h"
     19#include "SynTree/Expression.h"
     20#include "Common/utility.h"
    2321
    2422namespace SymTab {
  • src/SymTab/FixFunction.h

    r0720e049 r3d4b23fa  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // FixFunction.h --
     7// FixFunction.h -- 
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 17:02:08 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:45:55 2017
    13 // Update Count     : 4
     12// Last Modified On : Wed Mar  2 17:34:06 2016
     13// Update Count     : 3
    1414//
    1515
    16 #pragma once
     16#ifndef FIXFUNCTION_H
     17#define FIXFUNCTION_H
    1718
    18 #include "SynTree/Mutator.h"  // for Mutator
    19 #include "SynTree/SynTree.h"  // for Types
     19#include "SynTree/Mutator.h"
    2020
    2121namespace SymTab {
     
    4444                virtual Type* mutate(ZeroType *zeroType);
    4545                virtual Type* mutate(OneType *oneType);
    46 
     46 
    4747                bool isVoid;
    4848        };
    4949} // namespace SymTab
     50
     51#endif // FIXFUNCTION_H
    5052
    5153// Local Variables: //
  • src/SymTab/ImplementationType.cc

    r0720e049 r3d4b23fa  
    1515
    1616#include "ImplementationType.h"
    17 
    18 #include <list>                   // for list, _List_iterator, list<>::iterator
    19 
    20 #include "SymTab/Indexer.h"       // for Indexer
    21 #include "SynTree/Declaration.h"  // for NamedTypeDecl
    22 #include "SynTree/Type.h"         // for TupleType, Type, ArrayType, Pointer...
    23 #include "SynTree/Visitor.h"      // for Visitor
     17#include "SynTree/Type.h"
     18#include "SynTree/Declaration.h"
     19#include "SynTree/Visitor.h"
     20#include "SymTab/Indexer.h"
     21#include "Common/utility.h"
    2422
    2523
  • src/SymTab/ImplementationType.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Sun May 17 21:35:41 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:46:19 2017
    13 // Update Count     : 3
     12// Last Modified On : Sun May 17 21:37:15 2015
     13// Update Count     : 2
    1414//
    1515
    16 #pragma once
     16#ifndef IMPLEMENTATIONTYPE_H
     17#define IMPLEMENTATIONTYPE_H
    1718
    18 class Type;
     19#include "SynTree/SynTree.h"
     20#include "SymTab/Indexer.h"
    1921
    2022namespace SymTab {
    21 class Indexer;
    22 
    2323        Type *implementationType( Type *, const SymTab::Indexer &indexer );
    2424
     
    3131} // namespace SymTab
    3232
     33#endif // IMPLEMENTATIONTYPE_H
     34
    3335// Local Variables: //
    3436// tab-width: 4 //
  • src/SymTab/Indexer.cc

    r0720e049 r3d4b23fa  
    1616#include "Indexer.h"
    1717
    18 #include <cassert>                 // for assert, safe_dynamic_cast
    19 #include <iostream>                // for operator<<, basic_ostream, ostream
    20 #include <string>                  // for string, operator<<, operator!=
    21 #include <unordered_map>           // for operator!=, unordered_map<>::const...
    22 #include <unordered_set>           // for unordered_set
    23 #include <utility>                 // for pair, make_pair, move
    24 
    25 #include "Common/SemanticError.h"  // for SemanticError
    26 #include "Common/utility.h"        // for cloneAll
    27 #include "InitTweak/InitTweak.h"   // for isConstructor, isCopyFunction, isC...
    28 #include "Mangler.h"               // for Mangler
    29 #include "Parser/LinkageSpec.h"    // for isMangled, isOverridable, Spec
    30 #include "ResolvExpr/typeops.h"    // for typesCompatible
    31 #include "SynTree/Constant.h"      // for Constant
    32 #include "SynTree/Declaration.h"   // for DeclarationWithType, FunctionDecl
    33 #include "SynTree/Expression.h"    // for Expression, ImplicitCopyCtorExpr
    34 #include "SynTree/Initializer.h"   // for Initializer
    35 #include "SynTree/Statement.h"     // for CompoundStmt, Statement, ForStmt (...
    36 #include "SynTree/Type.h"          // for Type, StructInstType, UnionInstType
     18#include <string>
     19#include <typeinfo>
     20#include <unordered_map>
     21#include <unordered_set>
     22#include <utility>
     23#include <algorithm>
     24
     25#include "Mangler.h"
     26
     27#include "Common/utility.h"
     28
     29#include "ResolvExpr/typeops.h"
     30
     31#include "SynTree/Declaration.h"
     32#include "SynTree/Type.h"
     33#include "SynTree/Expression.h"
     34#include "SynTree/Initializer.h"
     35#include "SynTree/Statement.h"
     36
     37#include "InitTweak/InitTweak.h"
    3738
    3839#define debugPrint(x) if ( doDebug ) { std::cout << x; }
  • src/SymTab/Indexer.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Sun May 17 21:38:55 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:46:34 2017
    13 // Update Count     : 7
     12// Last Modified On : Wed Mar  2 17:34:14 2016
     13// Update Count     : 6
    1414//
    1515
    16 #pragma once
     16#ifndef INDEXER_H
     17#define INDEXER_H
    1718
    18 #include <iosfwd>             // for ostream
    19 #include <list>               // for list
    20 #include <string>             // for string
     19#include <list>
     20#include <string>
    2121
    22 #include "SynTree/Visitor.h"  // for Visitor
    23 #include "SynTree/SynTree.h"  // for AST nodes
     22#include "SynTree/Visitor.h"
    2423
    2524namespace SymTab {
     
    127126
    128127                struct Impl;
    129 
    130128                Impl *tables;         ///< Copy-on-write instance of table data structure
    131129                unsigned long scope;  ///< Scope index of this pointer
     
    147145} // namespace SymTab
    148146
     147#endif // INDEXER_H
     148
    149149// Local Variables: //
    150150// tab-width: 4 //
  • src/SymTab/Mangler.cc

    r0720e049 r3d4b23fa  
    1313// Update Count     : 21
    1414//
     15
     16#include <cassert>
     17#include <string>
     18#include <algorithm>
     19#include <iterator>
     20#include <functional>
     21#include <set>
     22
     23#include "SynTree/Declaration.h"
     24#include "SynTree/Type.h"
     25#include "SynTree/Expression.h"
     26#include "SynTree/Initializer.h"
     27#include "SynTree/Statement.h"
    1528#include "Mangler.h"
    16 
    17 #include <algorithm>                // for copy, transform
    18 #include <cassert>                  // for assert, assertf
    19 #include <functional>               // for const_mem_fun_t, mem_fun
    20 #include <iterator>                 // for ostream_iterator, back_insert_ite...
    21 #include <list>                     // for _List_iterator, list, _List_const...
    22 #include <string>                   // for string, operator<<, basic_string
    23 
    24 #include "CodeGen/OperatorTable.h"  // for OperatorInfo, operatorLookup
    25 #include "Common/utility.h"         // for toString
    26 #include "Parser/LinkageSpec.h"     // for Spec, isOverridable, AutoGen, Int...
    27 #include "SynTree/Declaration.h"    // for TypeDecl, DeclarationWithType
    28 #include "SynTree/Expression.h"     // for TypeExpr, Expression, operator<<
    29 #include "SynTree/Type.h"           // for Type, ReferenceToType, Type::Fora...
     29#include "CodeGen/OperatorTable.h"
    3030
    3131namespace SymTab {
  • src/SymTab/Mangler.h

    r0720e049 r3d4b23fa  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Mangler.h --
     7// Mangler.h -- 
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 21:44:03 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:45:30 2017
    13 // Update Count     : 15
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Aug 19 15:48:46 2015
     13// Update Count     : 14
    1414//
    1515
    16 #pragma once
     16#ifndef MANGLER_H
     17#define MANGLER_H
    1718
    18 #include <map>                // for map, map<>::value_compare
    19 #include <sstream>            // for ostringstream
    20 #include <string>             // for string
    21 #include <utility>            // for pair
    22 
    23 #include "SynTree/SynTree.h"  // for Types
    24 #include "SynTree/Visitor.h"  // for Visitor, maybeAccept
     19#include <sstream>
     20#include "SynTree/SynTree.h"
     21#include "SynTree/Visitor.h"
    2522
    2623namespace SymTab {
     
    5148                virtual void visit( ZeroType *zeroType );
    5249                virtual void visit( OneType *oneType );
    53 
     50 
    5451                std::string get_mangleName() { return mangleName.str(); }
    5552          private:
     
    6158                bool mangleOverridable;         ///< Specially mangle overridable built-in methods
    6259                bool typeMode;                  ///< Produce a unique mangled name for a type
    63 
     60 
    6461                Mangler( bool mangleOverridable, bool typeMode );
    6562                Mangler( const Mangler & );
    66 
     63 
    6764                void mangleDecl( DeclarationWithType *declaration );
    6865                void mangleRef( ReferenceToType *refType, std::string prefix );
    6966                void mangleGenericRef( ReferenceToType *refType, std::string prefix );
    70 
     67 
    7168                void printQualifiers( Type *type );
    7269        }; // Mangler
     
    8077} // SymTab
    8178
     79#endif // MANGLER_H
     80
    8281// Local Variables: //
    8382// tab-width: 4 //
  • src/SymTab/TypeEquality.cc

    r0720e049 r3d4b23fa  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // TypeEquality.cc --
     7// TypeEquality.cc -- 
    88//
    99// Author           : Rob Schluntz
     
    1313// Update Count     : 37
    1414//
     15
     16#include <list>
     17#include <iterator>
     18#include "Validate.h"
     19#include "SynTree/Visitor.h"
     20#include "SynTree/Type.h"
     21#include "SynTree/Statement.h"
     22#include "SynTree/TypeSubstitution.h"
     23#include "Indexer.h"
    1524#include "TypeEquality.h"
    16 
    17 #include <cassert>                // for assert
    18 #include <list>                   // for list, list<>::iterator, _List_iterator
    19 #include <string>                 // for operator==, string, basic_string
    20 
    21 #include "SynTree/Constant.h"     // for Constant
    22 #include "SynTree/Declaration.h"  // for DeclarationWithType
    23 #include "SynTree/Expression.h"   // for ConstantExpr, Expression
    24 #include "SynTree/Type.h"         // for Type, ArrayType, FunctionType, Enum...
    25 #include "SynTree/Visitor.h"      // for Visitor
    2625
    2726namespace SymTab {
    2827        class TypeEquality : public Visitor {
    2928  public:
    30                 TypeEquality( Type * other, bool vlaErr ) : result( true ), other( other ),
     29                TypeEquality( Type * other, bool vlaErr ) : result( true ), other( other ), 
    3130                        vlaErr( vlaErr ) {}
    3231                bool result;
     
    7271                handleQualifiers( basicType );
    7372                if ( BasicType * bt = dynamic_cast< BasicType * >( other ) ) {
    74                         result = result && basicType->get_kind() == bt->get_kind();
     73                        result = result && basicType->get_kind() == bt->get_kind(); 
    7574                } else {
    7675                        result = false;
     
    9998
    10099                        if ( vlaErr ) {
    101                                 // useful for comparing typedef types - in this case, we
     100                                // useful for comparing typedef types - in this case, we 
    102101                                // want types to appear distinct if either is a VLA type
    103102                                if ( arrayType->get_isVarLen() || at->get_isVarLen() ) {
     
    147146
    148147                        // parameter types must be equivalent
    149                         it1 = funcType->get_parameters().begin();
     148                        it1 = funcType->get_parameters().begin(); 
    150149                        it2 = ft->get_parameters().begin();
    151150                        for ( ; it1 != funcType->get_parameters().end(); ++it1, ++it2 ) {
  • src/SymTab/TypeEquality.h

    r0720e049 r3d4b23fa  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // TypeEquality.h --
     7// TypeEquality.h -- 
    88//
    99// Author           : Rob Schluntz
     
    1414//
    1515
    16 class Type;
    17 
    1816namespace SymTab {
    1917  // compare types t1 and t2 for equality
    20   // if vlaErr is true, then if at least one of the types is a
    21   // variable-length array type, then the result will be false
     18  // if vlaErr is true, then if at least one of the types is a 
     19  // variable-length array type, then the result will be false 
    2220  bool typeEquals( Type * t1, Type * t2, bool vlaErr = false );
    2321} // namespace SymTab
  • src/SymTab/Validate.cc

    r0720e049 r3d4b23fa  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 21:50:04 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Tus Aug  8 13:27:00 2017
    13 // Update Count     : 358
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Mar 30 16:50:13 2017
     13// Update Count     : 357
    1414//
    1515
     
    3838//   definition occurs later in the input.
    3939
     40#include <algorithm>
     41#include <iterator>
     42#include <list>
     43
     44#include "CodeGen/CodeGenerator.h"
     45
     46#include "Common/PassVisitor.h"
     47#include "Common/ScopedMap.h"
     48#include "Common/UniqueName.h"
     49#include "Common/utility.h"
     50
     51#include "Concurrency/Keywords.h"
     52
     53#include "GenPoly/DeclMutator.h"
     54
     55#include "InitTweak/InitTweak.h"
     56
     57#include "AddVisit.h"
     58#include "Autogen.h"
     59#include "FixFunction.h"
     60// #include "ImplementationType.h"
     61#include "Indexer.h"
     62#include "MakeLibCfa.h"
     63#include "TypeEquality.h"
    4064#include "Validate.h"
    4165
    42 #include <cstddef>                     // for size_t
    43 #include <algorithm>                   // for move, transform
    44 #include <cassert>                     // for safe_dynamic_cast, assertf
    45 #include <iterator>                    // for back_inserter, inserter, back_...
    46 #include <list>                        // for list, _List_iterator, list<>::...
    47 #include <map>                         // for _Rb_tree_iterator, map, map<>:...
    48 #include <memory>                      // for unique_ptr, allocator
    49 #include <string>                      // for string, operator+, operator==
    50 #include <tuple>                       // for get
    51 #include <utility>                     // for pair, make_pair
    52 
    53 #include "AddVisit.h"                  // for addVisit
    54 #include "Autogen.h"                   // for SizeType, autogenerateRoutines
    55 #include "CodeGen/CodeGenerator.h"     // for genName
    56 #include "Common/PassVisitor.h"        // for PassVisitor, WithDeclsToAdd
    57 #include "Common/ScopedMap.h"          // for ScopedMap<>::const_iterator
    58 #include "Common/SemanticError.h"      // for SemanticError
    59 #include "Common/UniqueName.h"         // for UniqueName
    60 #include "Common/utility.h"            // for operator+, cloneAll, deleteAll
    61 #include "Concurrency/Keywords.h"      // for applyKeywords, implementMutexF...
    62 #include "FixFunction.h"               // for FixFunction
    63 #include "Indexer.h"                   // for Indexer
    64 #include "InitTweak/InitTweak.h"       // for isCtorDtor, isCtorDtorAssign
    65 #include "Parser/LinkageSpec.h"        // for C, Cforall
    66 #include "ResolvExpr/typeops.h"        // for extractResultType, typesCompat...
    67 #include "SynTree/Attribute.h"         // for Attribute
    68 #include "SynTree/Constant.h"          // for Constant
    69 #include "SynTree/Declaration.h"       // for EnumDecl, StructDecl, UnionDecl
    70 #include "SynTree/Expression.h"        // for TypeExpr, CompoundLiteralExpr
    71 #include "SynTree/Initializer.h"       // for ListInit, Initializer, noDesig...
    72 #include "SynTree/Mutator.h"           // for mutateAll, Mutator
    73 #include "SynTree/Statement.h"         // for CompoundStmt, DeclStmt, Return...
    74 #include "SynTree/Type.h"              // for Type, TypeInstType, TraitInstType
    75 #include "SynTree/TypeSubstitution.h"  // for TypeSubstitution, applySubstit...
    76 #include "SynTree/Visitor.h"           // for acceptAll, Visitor
     66#include "ResolvExpr/typeops.h"
     67
     68#include "SynTree/Attribute.h"
     69#include "SynTree/Expression.h"
     70#include "SynTree/Mutator.h"
     71#include "SynTree/Statement.h"
     72#include "SynTree/Type.h"
     73#include "SynTree/TypeSubstitution.h"
     74#include "SynTree/Visitor.h"
    7775
    7876#define debugPrint( x ) if ( doDebug ) { std::cout << x; }
     
    607605                // a return statement in a void-returning function in C. The expression is treated as if it
    608606                // were cast to void.
    609                 if ( ! returnStmt->get_expr() && returnVals.size() != 0 ) {
     607                if ( returnStmt->get_expr() == NULL && returnVals.size() != 0 ) {
    610608                        throw SemanticError( "Non-void function returns no values: " , returnStmt );
    611609                }
     
    686684                Type *designatorType = tyDecl->get_base()->stripDeclarator();
    687685                if ( StructInstType *aggDecl = dynamic_cast< StructInstType * >( designatorType ) ) {
    688                         return new StructDecl( aggDecl->get_name(), DeclarationNode::Struct, noAttributes, tyDecl->get_linkage() );
     686                        return new StructDecl( aggDecl->get_name() );
    689687                } else if ( UnionInstType *aggDecl = dynamic_cast< UnionInstType * >( designatorType ) ) {
    690                         return new UnionDecl( aggDecl->get_name(), noAttributes, tyDecl->get_linkage() );
     688                        return new UnionDecl( aggDecl->get_name() );
    691689                } else if ( EnumInstType *enumDecl = dynamic_cast< EnumInstType * >( designatorType ) ) {
    692                         return new EnumDecl( enumDecl->get_name(), noAttributes, tyDecl->get_linkage() );
     690                        return new EnumDecl( enumDecl->get_name() );
    693691                } else {
    694692                        return ret->clone();
     
    783781                                type = new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() );
    784782                        } // if
    785                         TypedefDeclPtr tyDecl( new TypedefDecl( aggDecl->get_name(), Type::StorageClasses(), type, aggDecl->get_linkage() ) );
     783                        TypedefDeclPtr tyDecl( new TypedefDecl( aggDecl->get_name(), Type::StorageClasses(), type ) );
    786784                        typedefNames[ aggDecl->get_name() ] = std::make_pair( std::move( tyDecl ), scopeLevel );
    787785                } // if
     
    838836        void validateGeneric( Aggr * inst ) {
    839837                std::list< TypeDecl * > * params = inst->get_baseParameters();
    840                 if ( params ) {
     838                if ( params != NULL ) {
    841839                        std::list< Expression * > & args = inst->get_parameters();
    842840
     
    903901                FunctionType * ftype = functionDecl->get_functionType();
    904902                std::list< DeclarationWithType * > & retVals = ftype->get_returnVals();
    905                 assertf( retVals.size() == 0 || retVals.size() == 1, "Function %s has too many return values: %zu", functionDecl->get_name().c_str(), retVals.size() );
     903                assertf( retVals.size() == 0 || retVals.size() == 1, "Function %s has too many return values: %d", functionDecl->get_name().c_str(), retVals.size() );
    906904                if ( retVals.size() == 1 ) {
    907905                        // ensure all function return values have a name - use the name of the function to disambiguate (this also provides a nice bit of help for debugging).
     
    939937        void ArrayLength::previsit( ObjectDecl * objDecl ) {
    940938                if ( ArrayType * at = dynamic_cast< ArrayType * >( objDecl->get_type() ) ) {
    941                         if ( at->get_dimension() ) return;
     939                        if ( at->get_dimension() != nullptr ) return;
    942940                        if ( ListInit * init = dynamic_cast< ListInit * >( objDecl->get_init() ) ) {
    943941                                at->set_dimension( new ConstantExpr( Constant::from_ulong( init->get_initializers().size() ) ) );
  • src/SymTab/Validate.h

    r0720e049 r3d4b23fa  
    1111// Created On       : Sun May 17 21:53:34 2015
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Sat Jul 22 09:46:07 2017
    14 // Update Count     : 4
     13// Last Modified On : Tue May 19 16:49:43 2015
     14// Update Count     : 3
    1515//
    1616
    17 #pragma once
     17#ifndef VALIDATE_H
     18#define VALIDATE_H
    1819
    19 #include <list>  // for list
    20 
    21 class Declaration;
    22 class Type;
     20#include "SynTree/SynTree.h"
    2321
    2422namespace SymTab {
     
    3028} // namespace SymTab
    3129
     30#endif // VALIDATE_H
     31
    3232// Local Variables: //
    3333// tab-width: 4 //
  • src/SymTab/module.mk

    r0720e049 r3d4b23fa  
    1010## Author           : Richard C. Bilson
    1111## Created On       : Mon Jun  1 17:49:17 2015
    12 ## Last Modified By : Andrew Beach
    13 ## Last Modified On : Thr Aug 10 16:08:00 2017
    14 ## Update Count     : 4
     12## Last Modified By : Rob Schluntz
     13## Last Modified On : Tue Jul 07 16:22:23 2015
     14## Update Count     : 2
    1515###############################################################################
    1616
  • src/SynTree/AddStmtVisitor.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Wed Jun 22 12:05:48 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:51:08 2017
    13 // Update Count     : 9
     12// Last Modified On : Tue Jul 12 17:50:32 2016
     13// Update Count     : 8
    1414//
    1515
    16 #pragma once
     16#ifndef ADD_STATEMENT_VISITOR_H
     17#define ADD_STATEMENT_VISITOR_H
    1718
    1819#include <list>
     
    4142};
    4243
    43 // Local Variables: //
    44 // tab-width: 4 //
    45 // mode: c++ //
    46 // compile-command: "make install" //
    47 // End: //
     44#endif // ADD_STATEMENT_VISITOR_H
  • src/SynTree/AggregateDecl.cc

    r0720e049 r3d4b23fa  
    1010// Created On       : Sun May 17 23:56:39 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Aug  4 14:22:00 2017
    13 // Update Count     : 22
     12// Last Modified On : Tus Jun 27 15:30:00 2017
     13// Update Count     : 21
    1414//
    1515
     
    4040        using std::endl;
    4141
    42         os << typeString() << " " << get_name() << ":";
    43         if ( get_linkage() != LinkageSpec::Cforall ) {
    44                 os << " " << LinkageSpec::linkageName( get_linkage() );
    45         } // if
    46         os << " with body " << has_body() << endl;
     42        os << typeString() << " " << get_name();
     43        os << string( indent+2, ' ' ) << "with body " << has_body() << endl;
    4744
    4845        if ( ! parameters.empty() ) {
  • src/SynTree/ApplicationExpr.cc

    r0720e049 r3d4b23fa  
    4444}
    4545
    46 ApplicationExpr::ApplicationExpr( Expression *funcExpr, const std::list< Expression * > & argList ) : function( funcExpr ), args( argList ) {
     46ApplicationExpr::ApplicationExpr( Expression *funcExpr ) : function( funcExpr ) {
    4747        PointerType *pointer = safe_dynamic_cast< PointerType* >( funcExpr->get_result() );
    4848        FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() );
  • src/SynTree/Attribute.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:54:14 2017
    13 // Update Count     : 39
     12// Last Modified On : Wed Jan 18 16:27:11 2017
     13// Update Count     : 38
    1414//
    1515
    16 #pragma once
     16#ifndef GCC_ATTRIBUTE_H
     17#define GCC_ATTRIBUTE_H
    1718
    1819#include "SynTree.h"
     
    4142const std::list< Attribute * > noAttributes;
    4243
     44#endif
     45
    4346// Local Variables: //
    4447// tab-width: 4 //
  • src/SynTree/BaseSyntaxNode.h

    r0720e049 r3d4b23fa  
    1414//
    1515
    16 #pragma once
     16#ifndef BASE_SYNTAX_NODE_H
     17#define BASE_SYNTAX_NODE_H
    1718
    1819#include "Common/utility.h"
     
    2829};
    2930
     31#endif // BASE_SYNTAX_NODE_H
     32
    3033// Local Variables: //
    3134// tab-width: 4 //
  • src/SynTree/Constant.cc

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Jul 14 14:50:00 2017
    13 // Update Count     : 29
     12// Last Modified On : Thr Jun 22 10:11:00 2017
     13// Update Count     : 28
    1414//
    1515
     
    4646}
    4747
    48 Constant Constant::null( Type * ptrtype ) {
    49         if ( nullptr == ptrtype ) {
    50                 ptrtype = new PointerType(
    51                         Type::Qualifiers(),
    52                         new VoidType( Type::Qualifiers() )
    53                         );
    54         }
    55 
    56         return Constant( ptrtype, "0", (unsigned long long int)0 );
    57 }
    58 
    5948unsigned long long Constant::get_ival() const {
    6049        assertf( safe_dynamic_cast<BasicType*>(type)->isInteger(), "Attempt to retrieve ival from non-integer constant." );
  • src/SynTree/Constant.h

    r0720e049 r3d4b23fa  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:54:46 2017
    13 // Update Count     : 17
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thr Jun 22 10:13:00 2017
     13// Update Count     : 15
    1414//
    1515
    16 #pragma once
     16#ifndef CONSTANT_H
     17#define CONSTANT_H
    1718
    1819#include "SynTree.h"
     
    4344        static Constant from_double( double d );
    4445
    45         /// generates a null pointer value for the given type. void * if omitted.
    46         static Constant null( Type * ptrtype = nullptr );
    47 
    4846        virtual void accept( Visitor & v ) { v.visit( this ); }
    4947        virtual Constant * acceptMutator( Mutator & m ) { return m.mutate( this ); }
     
    6058};
    6159
     60#endif // CONSTANT_H
     61
    6262// Local Variables: //
    6363// tab-width: 4 //
  • src/SynTree/Declaration.cc

    r0720e049 r3d4b23fa  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Aug  9 14:38:00 2017
    13 // Update Count     : 25
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Mar 16 07:49:18 2017
     13// Update Count     : 24
    1414//
    1515
     
    2828
    2929Declaration::Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage )
    30                 : name( name ), linkage( linkage ), storageClasses( scs ), uniqueId( 0 ) {
     30                : name( name ), storageClasses( scs ), linkage( linkage ), uniqueId( 0 ) {
    3131}
    3232
    3333Declaration::Declaration( const Declaration &other )
    34         : BaseSyntaxNode( other ), name( other.name ), linkage( other.linkage ), extension( other.extension ), storageClasses( other.storageClasses ), uniqueId( other.uniqueId ) {
     34        : BaseSyntaxNode( other ), name( other.name ), storageClasses( other.storageClasses ), linkage( other.linkage ), uniqueId( other.uniqueId ) {
    3535}
    3636
  • src/SynTree/Declaration.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Aug  9 14:45:00 2017
    13 // Update Count     : 126
    14 //
    15 
    16 #pragma once
     12// Last Modified On : Tus Jun 27 15:31:00 2017
     13// Update Count     : 122
     14//
     15
     16#ifndef DECLARATION_H
     17#define DECLARATION_H
    1718
    1819#include <string>
     
    2728class Declaration : public BaseSyntaxNode {
    2829  public:
    29         std::string name;
    30         LinkageSpec::Spec linkage;
    31         bool extension = false;
    32 
    3330        Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage );
    3431        Declaration( const Declaration &other );
     
    5754        static void dumpIds( std::ostream &os );
    5855        static Declaration *declFromId( UniqueId id );
    59 
    60   private:
     56  private:
     57        std::string name;
    6158        Type::StorageClasses storageClasses;
     59        LinkageSpec::Spec linkage;
    6260        UniqueId uniqueId;
     61        bool extension = false;
    6362};
    6463
    6564class DeclarationWithType : public Declaration {
    6665  public:
     66        DeclarationWithType( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, Type::FuncSpecifiers fs );
     67        DeclarationWithType( const DeclarationWithType &other );
     68        virtual ~DeclarationWithType();
     69
     70        std::string get_mangleName() const { return mangleName; }
     71        DeclarationWithType * set_mangleName( std::string newValue ) { mangleName = newValue; return this; }
     72
     73        std::string get_scopedMangleName() const { return mangleName + "_" + std::to_string(scopeLevel); }
     74
     75        int get_scopeLevel() const { return scopeLevel; }
     76        DeclarationWithType * set_scopeLevel( int newValue ) { scopeLevel = newValue; return this; }
     77
     78        ConstantExpr *get_asmName() const { return asmName; }
     79        DeclarationWithType * set_asmName( ConstantExpr *newValue ) { asmName = newValue; return this; }
     80
     81        std::list< Attribute * >& get_attributes() { return attributes; }
     82        const std::list< Attribute * >& get_attributes() const { return attributes; }
     83
     84        Type::FuncSpecifiers get_funcSpec() const { return fs; }
     85        //void set_functionSpecifiers( Type::FuncSpecifiers newValue ) { fs = newValue; }
     86
     87        virtual DeclarationWithType *clone() const = 0;
     88        virtual DeclarationWithType *acceptMutator( Mutator &m ) = 0;
     89
     90        virtual Type *get_type() const = 0;
     91        virtual void set_type(Type *) = 0;
     92  private:
    6793        // this represents the type with all types and typedefs expanded it is generated by SymTab::Validate::Pass2
    6894        std::string mangleName;
     
    7298        ConstantExpr *asmName;
    7399        std::list< Attribute * > attributes;
    74 
    75         DeclarationWithType( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, Type::FuncSpecifiers fs );
    76         DeclarationWithType( const DeclarationWithType &other );
    77         virtual ~DeclarationWithType();
    78 
    79         std::string get_mangleName() const { return mangleName; }
    80         DeclarationWithType * set_mangleName( std::string newValue ) { mangleName = newValue; return this; }
    81 
    82         std::string get_scopedMangleName() const { return mangleName + "_" + std::to_string(scopeLevel); }
    83 
    84         int get_scopeLevel() const { return scopeLevel; }
    85         DeclarationWithType * set_scopeLevel( int newValue ) { scopeLevel = newValue; return this; }
    86 
    87         ConstantExpr *get_asmName() const { return asmName; }
    88         DeclarationWithType * set_asmName( ConstantExpr *newValue ) { asmName = newValue; return this; }
    89 
    90         std::list< Attribute * >& get_attributes() { return attributes; }
    91         const std::list< Attribute * >& get_attributes() const { return attributes; }
    92 
    93         Type::FuncSpecifiers get_funcSpec() const { return fs; }
    94         //void set_functionSpecifiers( Type::FuncSpecifiers newValue ) { fs = newValue; }
    95 
    96         virtual DeclarationWithType *clone() const = 0;
    97         virtual DeclarationWithType *acceptMutator( Mutator &m ) = 0;
    98 
    99         virtual Type *get_type() const = 0;
    100         virtual void set_type(Type *) = 0;
    101 
    102   private:
    103100        Type::FuncSpecifiers fs;
    104101};
     
    107104        typedef DeclarationWithType Parent;
    108105  public:
    109         Type *type;
    110         Initializer *init;
    111         Expression *bitfieldWidth;
    112 
    113106        ObjectDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init,
    114107                                const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() );
     
    130123        virtual void print( std::ostream &os, int indent = 0 ) const;
    131124        virtual void printShort( std::ostream &os, int indent = 0 ) const;
     125  private:
     126        Type *type;
     127        Initializer *init;
     128        Expression *bitfieldWidth;
    132129};
    133130
     
    135132        typedef DeclarationWithType Parent;
    136133  public:
    137         FunctionType *type;
    138         CompoundStmt *statements;
    139 
    140134        FunctionDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements,
    141135                                  const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() );
     
    156150        virtual void print( std::ostream &os, int indent = 0 ) const;
    157151        virtual void printShort( std::ostream &os, int indent = 0 ) const;
     152  private:
     153        FunctionType *type;
     154        CompoundStmt *statements;
    158155};
    159156
     
    161158        typedef Declaration Parent;
    162159  public:
    163         Type *base;
    164         std::list< TypeDecl* > parameters;
    165         std::list< DeclarationWithType* > assertions;
    166 
    167160        NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *type );
    168161        NamedTypeDecl( const NamedTypeDecl &other );
     
    179172        virtual void print( std::ostream &os, int indent = 0 ) const;
    180173        virtual void printShort( std::ostream &os, int indent = 0 ) const;
     174  protected:
     175  private:
     176        Type *base;
     177        std::list< TypeDecl* > parameters;
     178        std::list< DeclarationWithType* > assertions;
    181179};
    182180
     
    185183  public:
    186184        enum Kind { Any, Dtype, Ftype, Ttype };
    187 
    188         Type * init;
    189         bool sized;
    190 
    191185        /// Data extracted from a type decl
    192186        struct Data {
     
    223217  private:
    224218        Kind kind;
     219        Type * init;
     220        bool sized;
    225221};
    226222
     
    228224        typedef NamedTypeDecl Parent;
    229225  public:
    230         TypedefDecl( const std::string &name, Type::StorageClasses scs, Type *type, LinkageSpec::Spec spec = LinkageSpec::Cforall ) : Parent( name, scs, type ) { set_linkage( spec ); }
     226        TypedefDecl( const std::string &name, Type::StorageClasses scs, Type *type ) : Parent( name, scs, type ) {}
    231227        TypedefDecl( const TypedefDecl &other ) : Parent( other ) {}
    232228
     
    242238        typedef Declaration Parent;
    243239  public:
     240        AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall );
     241        AggregateDecl( const AggregateDecl &other );
     242        virtual ~AggregateDecl();
     243
     244        std::list<Declaration*>& get_members() { return members; }
     245        std::list<TypeDecl*>& get_parameters() { return parameters; }
     246
     247        std::list< Attribute * >& get_attributes() { return attributes; }
     248        const std::list< Attribute * >& get_attributes() const { return attributes; }
     249
     250        bool has_body() const { return body; }
     251        AggregateDecl * set_body( bool body ) { AggregateDecl::body = body; return this; }
     252
     253        virtual void print( std::ostream &os, int indent = 0 ) const;
     254        virtual void printShort( std::ostream &os, int indent = 0 ) const;
     255  protected:
     256        virtual std::string typeString() const = 0;
     257
     258  private:
    244259        std::list<Declaration*> members;
    245260        std::list<TypeDecl*> parameters;
    246261        bool body;
    247262        std::list< Attribute * > attributes;
    248 
    249         AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall );
    250         AggregateDecl( const AggregateDecl &other );
    251         virtual ~AggregateDecl();
    252 
    253         std::list<Declaration*>& get_members() { return members; }
    254         std::list<TypeDecl*>& get_parameters() { return parameters; }
    255 
    256         std::list< Attribute * >& get_attributes() { return attributes; }
    257         const std::list< Attribute * >& get_attributes() const { return attributes; }
    258 
    259         bool has_body() const { return body; }
    260         AggregateDecl * set_body( bool body ) { AggregateDecl::body = body; return this; }
    261 
    262         virtual void print( std::ostream &os, int indent = 0 ) const;
    263         virtual void printShort( std::ostream &os, int indent = 0 ) const;
    264   protected:
    265         virtual std::string typeString() const = 0;
    266263};
    267264
     
    269266        typedef AggregateDecl Parent;
    270267  public:
    271         StructDecl( const std::string &name, DeclarationNode::Aggregate kind = DeclarationNode::Struct, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ), kind( kind ), tagged( false ), parent_name( "" ) {}
    272         StructDecl( const std::string &name, const std::string *parent, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ), kind( DeclarationNode::Struct ), tagged( true ), parent_name( parent ? *parent : "" ) {}
     268        StructDecl( const std::string &name, DeclarationNode::Aggregate kind = DeclarationNode::Struct, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ), kind( kind ) {}
    273269        StructDecl( const StructDecl &other ) : Parent( other ) {}
    274270
     
    277273        bool is_thread() { return kind == DeclarationNode::Thread; }
    278274
    279         // Tagged/Tree Structure Excetion
    280         bool get_tagged() { return tagged; }
    281         void set_tagged( bool newValue ) { tagged = newValue; }
    282         bool has_parent() { return parent_name != ""; }
    283         std::string get_parentName() { return parent_name; }
    284 
    285275        virtual StructDecl *clone() const { return new StructDecl( *this ); }
    286276        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    289279        DeclarationNode::Aggregate kind;
    290280        virtual std::string typeString() const;
    291 
    292         bool tagged;
    293         std::string parent_name;
    294281};
    295282
     
    337324class AsmDecl : public Declaration {
    338325  public:
    339         AsmStmt *stmt;
    340 
    341326        AsmDecl( AsmStmt *stmt );
    342327        AsmDecl( const AsmDecl &other );
     
    351336        virtual void print( std::ostream &os, int indent = 0 ) const;
    352337        virtual void printShort( std::ostream &os, int indent = 0 ) const;
     338  private:
     339        AsmStmt *stmt;
    353340};
    354341
    355342std::ostream & operator<<( std::ostream & out, const Declaration * decl );
    356343std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data );
     344
     345#endif // DECLARATION_H
    357346
    358347// Local Variables: //
  • src/SynTree/Expression.cc

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jul 25 14:15:47 2017
    13 // Update Count     : 54
     12// Last Modified On : Thu Mar 30 16:41:13 2017
     13// Update Count     : 52
    1414//
    1515
     
    298298        if ( result->isVoid() ) {
    299299                os << "nothing";
    300         } else {
    301                 result->print( os, indent+2 );
    302         } // if
    303         os << std::endl;
    304         Expression::print( os, indent );
    305 }
    306 
    307 VirtualCastExpr::VirtualCastExpr( Expression *arg_, Type *toType ) : Expression(), arg(arg_) {
    308         set_result(toType);
    309 }
    310 
    311 VirtualCastExpr::VirtualCastExpr( const VirtualCastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ) {
    312 }
    313 
    314 VirtualCastExpr::~VirtualCastExpr() {
    315         delete arg;
    316 }
    317 
    318 void VirtualCastExpr::print( std::ostream &os, int indent ) const {
    319         os << "Virtual Cast of:" << std::endl << std::string( indent+2, ' ' );
    320         arg->print(os, indent+2);
    321         os << std::endl << std::string( indent, ' ' ) << "to:" << std::endl;
    322         os << std::string( indent+2, ' ' );
    323         if ( ! result ) {
    324                 os << "unknown";
    325300        } else {
    326301                result->print( os, indent+2 );
     
    528503}
    529504
    530 AsmExpr::AsmExpr( const AsmExpr & other ) : Expression( other ), inout( maybeClone( other.inout ) ), constraint( maybeClone( other.constraint ) ), operand( maybeClone( other.operand ) ) {}
     505AsmExpr::AsmExpr( const AsmExpr & other ) : inout( maybeClone( other.inout ) ), constraint( maybeClone( other.constraint ) ), operand( maybeClone( other.operand ) ) {}
    531506
    532507
  • src/SynTree/Expression.h

    r0720e049 r3d4b23fa  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Aug  8 11:54:00 2017
    13 // Update Count     : 44
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Mar 30 16:44:00 2017
     13// Update Count     : 41
    1414//
    1515
    16 #pragma once
     16#ifndef EXPRESSION_H
     17#define EXPRESSION_H
    1718
    1819#include <map>
     
    2930class Expression : public BaseSyntaxNode{
    3031  public:
    31         Type * result;
    32         TypeSubstitution * env;
    33         Expression * argName; // if expression is used as an argument, it can be "designated" by this name
    34         bool extension = false;
    35 
    3632        Expression( Expression * _aname = nullptr );
    3733        Expression( const Expression & other );
     
    5450        virtual Expression * acceptMutator( Mutator & m ) = 0;
    5551        virtual void print( std::ostream & os, int indent = 0 ) const;
     52  protected:
     53        Type * result;
     54        TypeSubstitution * env;
     55        Expression * argName; // if expression is used as an argument, it can be "designated" by this name
     56        bool extension = false;
    5657};
    5758
     
    7980class ApplicationExpr : public Expression {
    8081  public:
    81         Expression * function;
    82 
    83         ApplicationExpr( Expression * function, const std::list<Expression *> & args = std::list< Expression * >() );
     82        ApplicationExpr( Expression * function );
    8483        ApplicationExpr( const ApplicationExpr & other );
    8584        virtual ~ApplicationExpr();
     
    9493        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    9594        virtual void print( std::ostream & os, int indent = 0 ) const;
    96 
    97   private:
     95  private:
     96        Expression * function;
    9897        std::list<Expression *> args;
    9998        InferredParams inferParams;
     
    105104class UntypedExpr : public Expression {
    106105  public:
    107         Expression * function;
    108         std::list<Expression*> args;
    109 
    110106        UntypedExpr( Expression * function, const std::list<Expression *> & args = std::list< Expression * >(), Expression *_aname = nullptr );
    111107        UntypedExpr( const UntypedExpr & other );
     
    128124        virtual void print( std::ostream & os, int indent = 0 ) const;
    129125        virtual void printArgs(std::ostream & os, int indent = 0) const;
     126  private:
     127        Expression * function;
     128        std::list<Expression*> args;
    130129};
    131130
     
    133132class NameExpr : public Expression {
    134133  public:
    135         std::string name;
    136 
    137134        NameExpr( std::string name, Expression *_aname = nullptr );
    138135        NameExpr( const NameExpr & other );
     
    146143        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    147144        virtual void print( std::ostream & os, int indent = 0 ) const;
     145  private:
     146        std::string name;
    148147};
    149148
     
    154153class AddressExpr : public Expression {
    155154  public:
    156         Expression * arg;
    157 
    158155        AddressExpr( Expression * arg, Expression *_aname = nullptr );
    159156        AddressExpr( const AddressExpr & other );
     
    167164        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    168165        virtual void print( std::ostream & os, int indent = 0 ) const;
     166  private:
     167        Expression * arg;
    169168};
    170169
     
    172171class LabelAddressExpr : public Expression {
    173172  public:
    174         Expression * arg;
    175 
    176173        LabelAddressExpr( Expression * arg );
    177174        LabelAddressExpr( const LabelAddressExpr & other );
     
    185182        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    186183        virtual void print( std::ostream & os, int indent = 0 ) const;
     184  private:
     185        Expression * arg;
    187186};
    188187
     
    190189class CastExpr : public Expression {
    191190  public:
    192         Expression * arg;
    193 
    194191        CastExpr( Expression * arg, Expression *_aname = nullptr );
    195192        CastExpr( Expression * arg, Type * toType, Expression *_aname = nullptr );
     
    198195
    199196        Expression * get_arg() const { return arg; }
    200         void set_arg( Expression * newValue ) { arg = newValue; }
     197        void set_arg(Expression * newValue ) { arg = newValue; }
    201198
    202199        virtual CastExpr * clone() const { return new CastExpr( * this ); }
     
    204201        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    205202        virtual void print( std::ostream & os, int indent = 0 ) const;
    206 };
    207 
    208 /// VirtualCastExpr repersents a virtual dynamic cast, e.g. (virtual exception)e
    209 class VirtualCastExpr : public Expression {
    210   public:
     203  private:
    211204        Expression * arg;
    212 
    213         VirtualCastExpr( Expression * arg, Type * toType );
    214         VirtualCastExpr( const VirtualCastExpr & other );
    215         virtual ~VirtualCastExpr();
    216 
    217         Expression * get_arg() const { return arg; }
    218         void set_arg( Expression * newValue ) { arg = newValue; }
    219 
    220         virtual VirtualCastExpr * clone() const { return new VirtualCastExpr( * this ); }
    221         virtual void accept( Visitor & v ) { v.visit( this ); }
    222         virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    223         virtual void print( std::ostream & os, int indent = 0 ) const;
    224205};
    225206
     
    227208class UntypedMemberExpr : public Expression {
    228209  public:
    229         Expression * member;
    230         Expression * aggregate;
    231 
    232210        UntypedMemberExpr( Expression * member, Expression * aggregate, Expression *_aname = nullptr );
    233211        UntypedMemberExpr( const UntypedMemberExpr & other );
     
    243221        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    244222        virtual void print( std::ostream & os, int indent = 0 ) const;
     223  private:
     224        Expression * member;
     225        Expression * aggregate;
    245226};
    246227
     
    249230class MemberExpr : public Expression {
    250231  public:
    251         DeclarationWithType * member;
    252         Expression * aggregate;
    253 
    254232        MemberExpr( DeclarationWithType * member, Expression * aggregate, Expression *_aname = nullptr );
    255233        MemberExpr( const MemberExpr & other );
     
    265243        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    266244        virtual void print( std::ostream & os, int indent = 0 ) const;
     245  private:
     246        DeclarationWithType * member;
     247        Expression * aggregate;
    267248};
    268249
     
    271252class VariableExpr : public Expression {
    272253  public:
    273         DeclarationWithType * var;
    274 
    275254        VariableExpr( DeclarationWithType * var, Expression *_aname = nullptr );
    276255        VariableExpr( const VariableExpr & other );
     
    284263        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    285264        virtual void print( std::ostream & os, int indent = 0 ) const;
     265  private:
     266        DeclarationWithType * var;
    286267};
    287268
     
    289270class ConstantExpr : public Expression {
    290271  public:
    291         Constant constant;
    292 
    293272        ConstantExpr( Constant constant, Expression *_aname = nullptr );
    294273        ConstantExpr( const ConstantExpr & other );
     
    302281        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    303282        virtual void print( std::ostream & os, int indent = 0 ) const;
     283  private:
     284        Constant constant;
    304285};
    305286
     
    307288class SizeofExpr : public Expression {
    308289  public:
    309         Expression * expr;
    310         Type * type;
    311         bool isType;
    312 
    313290        SizeofExpr( Expression * expr, Expression *_aname = nullptr );
    314291        SizeofExpr( const SizeofExpr & other );
     
    327304        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    328305        virtual void print( std::ostream & os, int indent = 0 ) const;
    329 };
    330 
    331 /// AlignofExpr represents an alignof expression
    332 class AlignofExpr : public Expression {
    333   public:
     306  private:
    334307        Expression * expr;
    335308        Type * type;
    336309        bool isType;
    337 
     310};
     311
     312/// AlignofExpr represents an alignof expression
     313class AlignofExpr : public Expression {
     314  public:
    338315        AlignofExpr( Expression * expr, Expression *_aname = nullptr );
    339316        AlignofExpr( const AlignofExpr & other );
     
    352329        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    353330        virtual void print( std::ostream & os, int indent = 0 ) const;
     331  private:
     332        Expression * expr;
     333        Type * type;
     334        bool isType;
    354335};
    355336
     
    357338class UntypedOffsetofExpr : public Expression {
    358339  public:
    359         Type * type;
    360         std::string member;
    361 
    362340        UntypedOffsetofExpr( Type * type, const std::string & member, Expression *_aname = nullptr );
    363341        UntypedOffsetofExpr( const UntypedOffsetofExpr & other );
     
    373351        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    374352        virtual void print( std::ostream & os, int indent = 0 ) const;
     353  private:
     354        Type * type;
     355        std::string member;
    375356};
    376357
     
    378359class OffsetofExpr : public Expression {
    379360  public:
    380         Type * type;
    381         DeclarationWithType * member;
    382 
    383361        OffsetofExpr( Type * type, DeclarationWithType * member, Expression *_aname = nullptr );
    384362        OffsetofExpr( const OffsetofExpr & other );
     
    394372        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    395373        virtual void print( std::ostream & os, int indent = 0 ) const;
     374  private:
     375        Type * type;
     376        DeclarationWithType * member;
    396377};
    397378
     
    399380class OffsetPackExpr : public Expression {
    400381public:
    401         StructInstType * type;
    402 
    403382        OffsetPackExpr( StructInstType * type_, Expression * aname_ = 0 );
    404383        OffsetPackExpr( const OffsetPackExpr & other );
     
    411390        virtual void accept( Visitor & v ) { v.visit( this ); }
    412391        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    413         virtual void print( std::ostream & os, int indent = 0 ) const;
     392
     393        virtual void print( std::ostream & os, int indent = 0 ) const;
     394
     395private:
     396        StructInstType * type;
    414397};
    415398
     
    417400class AttrExpr : public Expression {
    418401  public:
    419         Expression * attr;
    420         Expression * expr;
    421         Type * type;
    422         bool isType;
    423 
    424402        AttrExpr(Expression * attr, Expression * expr, Expression *_aname = nullptr );
    425403        AttrExpr( const AttrExpr & other );
     
    440418        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    441419        virtual void print( std::ostream & os, int indent = 0 ) const;
     420  private:
     421        Expression * attr;
     422        Expression * expr;
     423        Type * type;
     424        bool isType;
    442425};
    443426
     
    445428class LogicalExpr : public Expression {
    446429  public:
    447         Expression * arg1;
    448         Expression * arg2;
    449 
    450430        LogicalExpr( Expression * arg1, Expression * arg2, bool andp = true, Expression *_aname = nullptr );
    451431        LogicalExpr( const LogicalExpr & other );
     
    462442        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    463443        virtual void print( std::ostream & os, int indent = 0 ) const;
    464 
    465   private:
     444  private:
     445        Expression * arg1;
     446        Expression * arg2;
    466447        bool isAnd;
    467448};
     
    470451class ConditionalExpr : public Expression {
    471452  public:
    472         Expression * arg1;
    473         Expression * arg2;
    474         Expression * arg3;
    475 
    476453        ConditionalExpr( Expression * arg1, Expression * arg2, Expression * arg3, Expression *_aname = nullptr );
    477454        ConditionalExpr( const ConditionalExpr & other );
     
    489466        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    490467        virtual void print( std::ostream & os, int indent = 0 ) const;
     468  private:
     469        Expression * arg1;
     470        Expression * arg2;
     471        Expression * arg3;
    491472};
    492473
     
    494475class CommaExpr : public Expression {
    495476  public:
    496         Expression * arg1;
    497         Expression * arg2;
    498 
    499477        CommaExpr( Expression * arg1, Expression * arg2, Expression *_aname = nullptr );
    500478        CommaExpr( const CommaExpr & other );
     
    510488        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    511489        virtual void print( std::ostream & os, int indent = 0 ) const;
     490  private:
     491        Expression * arg1;
     492        Expression * arg2;
    512493};
    513494
     
    515496class TypeExpr : public Expression {
    516497  public:
    517         Type * type;
    518 
    519498        TypeExpr( Type * type );
    520499        TypeExpr( const TypeExpr & other );
     
    528507        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    529508        virtual void print( std::ostream & os, int indent = 0 ) const;
     509  private:
     510        Type * type;
    530511};
    531512
     
    533514class AsmExpr : public Expression {
    534515  public:
     516        AsmExpr( Expression * inout, ConstantExpr * constraint, Expression * operand ) : inout( inout ), constraint( constraint ), operand( operand ) {}
     517        AsmExpr( const AsmExpr & other );
     518        virtual ~AsmExpr() { delete inout; delete constraint; delete operand; };
     519
     520        Expression * get_inout() const { return inout; }
     521        void set_inout( Expression * newValue ) { inout = newValue; }
     522
     523        ConstantExpr * get_constraint() const { return constraint; }
     524        void set_constraint( ConstantExpr * newValue ) { constraint = newValue; }
     525
     526        Expression * get_operand() const { return operand; }
     527        void set_operand( Expression * newValue ) { operand = newValue; }
     528
     529        virtual AsmExpr * clone() const { return new AsmExpr( * this ); }
     530        virtual void accept( Visitor & v ) { v.visit( this ); }
     531        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
     532        virtual void print( std::ostream & os, int indent = 0 ) const;
     533  private:
     534        // https://gcc.gnu.org/onlinedocs/gcc-4.7.1/gcc/Machine-Constraints.html#Machine-Constraints
    535535        Expression * inout;
    536536        ConstantExpr * constraint;
    537537        Expression * operand;
    538 
    539         AsmExpr( Expression * inout, ConstantExpr * constraint, Expression * operand ) : inout( inout ), constraint( constraint ), operand( operand ) {}
    540         AsmExpr( const AsmExpr & other );
    541         virtual ~AsmExpr() { delete inout; delete constraint; delete operand; };
    542 
    543         Expression * get_inout() const { return inout; }
    544         void set_inout( Expression * newValue ) { inout = newValue; }
    545 
    546         ConstantExpr * get_constraint() const { return constraint; }
    547         void set_constraint( ConstantExpr * newValue ) { constraint = newValue; }
    548 
    549         Expression * get_operand() const { return operand; }
    550         void set_operand( Expression * newValue ) { operand = newValue; }
    551 
    552         virtual AsmExpr * clone() const { return new AsmExpr( * this ); }
    553         virtual void accept( Visitor & v ) { v.visit( this ); }
    554         virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    555         virtual void print( std::ostream & os, int indent = 0 ) const;
    556 
    557         // https://gcc.gnu.org/onlinedocs/gcc-4.7.1/gcc/Machine-Constraints.html#Machine-Constraints
    558538};
    559539
     
    562542class ImplicitCopyCtorExpr : public Expression {
    563543public:
     544        ImplicitCopyCtorExpr( ApplicationExpr * callExpr );
     545        ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other );
     546        virtual ~ImplicitCopyCtorExpr();
     547
     548        ApplicationExpr * get_callExpr() const { return callExpr; }
     549        void set_callExpr( ApplicationExpr * newValue ) { callExpr = newValue; }
     550
     551        std::list< ObjectDecl * > & get_tempDecls() { return tempDecls; }
     552        std::list< ObjectDecl * > & get_returnDecls() { return returnDecls; }
     553        std::list< Expression * > & get_dtors() { return dtors; }
     554
     555        virtual ImplicitCopyCtorExpr * clone() const { return new ImplicitCopyCtorExpr( * this ); }
     556        virtual void accept( Visitor & v ) { v.visit( this ); }
     557        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
     558        virtual void print( std::ostream & os, int indent = 0 ) const;
     559  private:
    564560        ApplicationExpr * callExpr;
    565561        std::list< ObjectDecl * > tempDecls;
    566562        std::list< ObjectDecl * > returnDecls;
    567563        std::list< Expression * > dtors;
    568 
    569         ImplicitCopyCtorExpr( ApplicationExpr * callExpr );
    570         ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other );
    571         virtual ~ImplicitCopyCtorExpr();
    572 
    573         ApplicationExpr * get_callExpr() const { return callExpr; }
    574         void set_callExpr( ApplicationExpr * newValue ) { callExpr = newValue; }
    575 
    576         std::list< ObjectDecl * > & get_tempDecls() { return tempDecls; }
    577         std::list< ObjectDecl * > & get_returnDecls() { return returnDecls; }
    578         std::list< Expression * > & get_dtors() { return dtors; }
    579 
    580         virtual ImplicitCopyCtorExpr * clone() const { return new ImplicitCopyCtorExpr( * this ); }
    581         virtual void accept( Visitor & v ) { v.visit( this ); }
    582         virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    583         virtual void print( std::ostream & os, int indent = 0 ) const;
    584564};
    585565
     
    587567class ConstructorExpr : public Expression {
    588568public:
    589         Expression * callExpr;
    590 
    591569        ConstructorExpr( Expression * callExpr );
    592570        ConstructorExpr( const ConstructorExpr & other );
     
    600578        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    601579        virtual void print( std::ostream & os, int indent = 0 ) const;
     580private:
     581        Expression * callExpr;
    602582};
    603583
     
    605585class CompoundLiteralExpr : public Expression {
    606586  public:
    607         Initializer * initializer;
    608 
    609587        CompoundLiteralExpr( Type * type, Initializer * initializer );
    610588        CompoundLiteralExpr( const CompoundLiteralExpr & other );
     
    618596        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    619597        virtual void print( std::ostream & os, int indent = 0 ) const;
     598  private:
     599        Initializer * initializer;
    620600};
    621601
     
    623603class RangeExpr : public Expression {
    624604  public:
    625         Expression * low, * high;
    626 
    627605        RangeExpr( Expression * low, Expression * high );
    628606        RangeExpr( const RangeExpr & other );
     
    637615        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    638616        virtual void print( std::ostream & os, int indent = 0 ) const;
     617  private:
     618        Expression * low, * high;
    639619};
    640620
     
    642622class UntypedTupleExpr : public Expression {
    643623  public:
    644         std::list<Expression*> exprs;
    645 
    646624        UntypedTupleExpr( const std::list< Expression * > & exprs, Expression *_aname = nullptr );
    647625        UntypedTupleExpr( const UntypedTupleExpr & other );
     
    654632        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    655633        virtual void print( std::ostream & os, int indent = 0 ) const;
     634  private:
     635        std::list<Expression*> exprs;
    656636};
    657637
     
    659639class TupleExpr : public Expression {
    660640  public:
    661         std::list<Expression*> exprs;
    662 
    663641        TupleExpr( const std::list< Expression * > & exprs, Expression *_aname = nullptr );
    664642        TupleExpr( const TupleExpr & other );
     
    671649        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    672650        virtual void print( std::ostream & os, int indent = 0 ) const;
     651  private:
     652        std::list<Expression*> exprs;
    673653};
    674654
     
    676656class TupleIndexExpr : public Expression {
    677657  public:
    678         Expression * tuple;
    679         unsigned int index;
    680 
    681658        TupleIndexExpr( Expression * tuple, unsigned int index );
    682659        TupleIndexExpr( const TupleIndexExpr & other );
     
    692669        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    693670        virtual void print( std::ostream & os, int indent = 0 ) const;
     671  private:
     672        Expression * tuple;
     673        unsigned int index;
    694674};
    695675
     
    697677class TupleAssignExpr : public Expression {
    698678  public:
    699         StmtExpr * stmtExpr = nullptr;
    700 
    701679        TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname = nullptr );
    702680        TupleAssignExpr( const TupleAssignExpr & other );
     
    710688        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    711689        virtual void print( std::ostream & os, int indent = 0 ) const;
     690  private:
     691        StmtExpr * stmtExpr = nullptr;
    712692};
    713693
     
    715695class StmtExpr : public Expression {
    716696public:
     697        StmtExpr( CompoundStmt * statements );
     698        StmtExpr( const StmtExpr & other );
     699        virtual ~StmtExpr();
     700
     701        CompoundStmt * get_statements() const { return statements; }
     702        StmtExpr * set_statements( CompoundStmt * newValue ) { statements = newValue; return this; }
     703
     704        std::list< ObjectDecl * > & get_returnDecls() { return returnDecls; }
     705        std::list< Expression * > & get_dtors() { return dtors; }
     706
     707        virtual StmtExpr * clone() const { return new StmtExpr( * this ); }
     708        virtual void accept( Visitor & v ) { v.visit( this ); }
     709        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
     710        virtual void print( std::ostream & os, int indent = 0 ) const;
     711private:
    717712        CompoundStmt * statements;
    718713        std::list< ObjectDecl * > returnDecls; // return variable(s) for stmt expression
    719714        std::list< Expression * > dtors; // destructor(s) for return variable(s)
    720 
    721         StmtExpr( CompoundStmt * statements );
    722         StmtExpr( const StmtExpr & other );
    723         virtual ~StmtExpr();
    724 
    725         CompoundStmt * get_statements() const { return statements; }
    726         StmtExpr * set_statements( CompoundStmt * newValue ) { statements = newValue; return this; }
    727 
    728         std::list< ObjectDecl * > & get_returnDecls() { return returnDecls; }
    729         std::list< Expression * > & get_dtors() { return dtors; }
    730 
    731         virtual StmtExpr * clone() const { return new StmtExpr( * this ); }
    732         virtual void accept( Visitor & v ) { v.visit( this ); }
    733         virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    734         virtual void print( std::ostream & os, int indent = 0 ) const;
    735715};
    736716
    737717class UniqueExpr : public Expression {
    738718public:
     719        UniqueExpr( Expression * expr, long long idVal = -1 );
     720        UniqueExpr( const UniqueExpr & other );
     721        ~UniqueExpr();
     722
     723        Expression * get_expr() const { return expr; }
     724        UniqueExpr * set_expr( Expression * newValue ) { expr = newValue; return this; }
     725
     726        ObjectDecl * get_object() const { return object; }
     727        UniqueExpr * set_object( ObjectDecl * newValue ) { object = newValue; return this; }
     728
     729        VariableExpr * get_var() const { return var; }
     730        UniqueExpr * set_var( VariableExpr * newValue ) { var = newValue; return this; }
     731
     732        int get_id() const { return id; }
     733
     734        virtual UniqueExpr * clone() const { return new UniqueExpr( * this ); }
     735        virtual void accept( Visitor & v ) { v.visit( this ); }
     736        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
     737        virtual void print( std::ostream & os, int indent = 0 ) const;
     738private:
    739739        Expression * expr;
    740740        ObjectDecl * object;
    741741        VariableExpr * var;
    742 
    743         UniqueExpr( Expression * expr, long long idVal = -1 );
    744         UniqueExpr( const UniqueExpr & other );
    745         ~UniqueExpr();
    746 
    747         Expression * get_expr() const { return expr; }
    748         UniqueExpr * set_expr( Expression * newValue ) { expr = newValue; return this; }
    749 
    750         ObjectDecl * get_object() const { return object; }
    751         UniqueExpr * set_object( ObjectDecl * newValue ) { object = newValue; return this; }
    752 
    753         VariableExpr * get_var() const { return var; }
    754         UniqueExpr * set_var( VariableExpr * newValue ) { var = newValue; return this; }
    755 
    756         int get_id() const { return id; }
    757 
    758         virtual UniqueExpr * clone() const { return new UniqueExpr( * this ); }
    759         virtual void accept( Visitor & v ) { v.visit( this ); }
    760         virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    761         virtual void print( std::ostream & os, int indent = 0 ) const;
    762 
    763 private:
    764742        int id;
    765743        static long long count;
     
    778756class UntypedInitExpr : public Expression {
    779757public:
    780         Expression * expr;
    781         std::list<InitAlternative> initAlts;
    782 
    783758        UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts );
    784759        UntypedInitExpr( const UntypedInitExpr & other );
     
    794769        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    795770        virtual void print( std::ostream & os, int indent = 0 ) const;
     771private:
     772        Expression * expr;
     773        std::list<InitAlternative> initAlts;
    796774};
    797775
    798776class InitExpr : public Expression {
    799777public:
    800         Expression * expr;
    801         Designation * designation;
    802 
    803778        InitExpr( Expression * expr, Designation * designation );
    804779        InitExpr( const InitExpr & other );
     
    815790        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    816791        virtual void print( std::ostream & os, int indent = 0 ) const;
     792private:
     793        Expression * expr;
     794        Designation * designation;
    817795};
    818796
    819797
    820798std::ostream & operator<<( std::ostream & out, const Expression * expr );
     799
     800#endif // EXPRESSION_H
    821801
    822802// Local Variables: //
  • src/SynTree/Initializer.cc

    r0720e049 r3d4b23fa  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Thr Aug  3 11:33:00 2016
    13 // Update Count     : 29
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Fri May 13 13:23:03 2016
     13// Update Count     : 28
    1414//
    1515
     
    7474                        }
    7575                }
    76                 assertf( initializers.size() == designations.size(), "Created ListInit with mismatching initializers (%lu) and designations (%lu)", initializers.size(), designations.size() );
     76                assertf( initializers.size() == designations.size(), "Created ListInit with mismatching initializers (%d) and designations (%d)", initializers.size(), designations.size() );
    7777}
    7878
  • src/SynTree/Initializer.h

    r0720e049 r3d4b23fa  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Aug  9 10:19:00 2017
    13 // Update Count     : 22
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Mar 23 16:12:42 2017
     13// Update Count     : 20
    1414//
    1515
    16 #pragma once
     16#ifndef INITIALIZER_H
     17#define INITIALIZER_H
    1718
    1819#include <cassert>
     
    2728class Designation : public BaseSyntaxNode {
    2829public:
    29         std::list< Expression * > designators;
    30 
    3130        Designation( const std::list< Expression * > & designators );
    3231        Designation( const Designation & other );
     
    3938        virtual Designation * acceptMutator( Mutator &m ) { return m.mutate( this ); }
    4039        virtual void print( std::ostream &os, int indent = 0 ) const;
     40private:
     41        std::list< Expression * > designators;
    4142};
    4243
     
    6364class SingleInit : public Initializer {
    6465  public:
    65         //Constant *value;
    66         Expression *value;      // has to be a compile-time constant
    67 
    6866        SingleInit( Expression *value, bool maybeConstructed = false );
    6967        SingleInit( const SingleInit &other );
     
    7775        virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    7876        virtual void print( std::ostream &os, int indent = 0 ) const;
     77  private:
     78        //Constant *value;
     79        Expression *value;      // has to be a compile-time constant
    7980};
    8081
     
    8384class ListInit : public Initializer {
    8485  public:
    85         std::list<Initializer *> initializers;  // order *is* important
    86         std::list<Designation *> designations;  // order/length is consistent with initializers
    87 
    8886        ListInit( const std::list<Initializer*> &initializers,
    8987                          const std::list<Designation *> &designators = {}, bool maybeConstructed = false );
     
    105103        virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    106104        virtual void print( std::ostream &os, int indent = 0 ) const;
     105  private:
     106        std::list<Initializer *> initializers;  // order *is* important
     107        std::list<Designation *> designations;  // order/length is consistent with initializers
    107108};
    108109
     
    113114class ConstructorInit : public Initializer {
    114115  public:
    115         Statement * ctor;
    116         Statement * dtor;
    117 
    118116        ConstructorInit( Statement * ctor, Statement * dtor, Initializer * init );
    119117        ConstructorInit( const ConstructorInit &other );
     
    133131
    134132  private:
     133        Statement * ctor;
     134        Statement * dtor;
    135135        // C-style initializer made up of SingleInit and ListInit nodes to use as a fallback
    136136        // if an appropriate constructor definition is not found by the resolver
     
    141141std::ostream & operator<<( std::ostream & out, const Designation * des );
    142142
     143#endif // INITIALIZER_H
     144
    143145// Local Variables: //
    144146// tab-width: 4 //
  • src/SynTree/Label.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Wed Jun 8 12:53:12 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:52:44 2017
    13 // Update Count     : 3
     12// Last Modified On : Sun Aug  7 14:44:29 2016
     13// Update Count     : 2
    1414//
    1515
    16 #pragma once
     16#ifndef LABEL_H
     17#define LABEL_H
    1718
    1819#include <string>
     
    5051static const std::list< Label > noLabels;
    5152
     53#endif // LABEL_H
     54
    5255// Local Variables: //
    5356// tab-width: 4 //
  • src/SynTree/Mutator.cc

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Jul 24 16:32:00 2017
    13 // Update Count     : 25
     12// Last Modified On : Thu Jun 22 13:43:00 2017
     13// Update Count     : 24
    1414//
    1515
     
    235235}
    236236
    237 Expression *Mutator::mutate( VirtualCastExpr *castExpr ) {
    238         castExpr->set_env( maybeMutate( castExpr->get_env(), *this ) );
    239         castExpr->set_result( maybeMutate( castExpr->get_result(), *this ) );
    240         castExpr->set_arg( maybeMutate( castExpr->get_arg(), *this ) );
    241         return castExpr;
    242 }
    243 
    244237Expression *Mutator::mutate( UntypedMemberExpr *memberExpr ) {
    245238        memberExpr->set_env( maybeMutate( memberExpr->get_env(), *this ) );
  • src/SynTree/Mutator.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Jul 24 16:31:00 2017
    13 // Update Count     : 16
     12// Last Modified On : Thu Jun  8 15:45:00 2017
     13// Update Count     : 14
    1414//
    1515#include <cassert>
     
    1818#include "Common/SemanticError.h"
    1919
    20 #pragma once
     20#ifndef MUTATOR_H
     21#define MUTATOR_H
    2122
    2223class Mutator {
     
    5960        virtual Expression* mutate( LabelAddressExpr *labAddressExpr );
    6061        virtual Expression* mutate( CastExpr *castExpr );
    61         virtual Expression* mutate( VirtualCastExpr *castExpr );
    6262        virtual Expression* mutate( UntypedMemberExpr *memberExpr );
    6363        virtual Expression* mutate( MemberExpr *memberExpr );
     
    150150}
    151151
     152#endif // MUTATOR_H
     153
    152154// Local Variables: //
    153155// tab-width: 4 //
  • src/SynTree/NamedTypeDecl.cc

    r0720e049 r3d4b23fa  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Aug  9 13:28:00 2017
    13 // Update Count     : 14
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Mar 16 07:49:44 2017
     13// Update Count     : 13
    1414//
    1515
     
    3838        if ( get_name() != "" ) {
    3939                os << get_name() << ": ";
    40         } // if
    41         if ( get_linkage() != LinkageSpec::Cforall ) {
    42                 os << LinkageSpec::linkageName( get_linkage() ) << " ";
    4340        } // if
    4441        get_storageClasses().print( os );
  • src/SynTree/Statement.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Thr Aug  3 14:08:00 2017
    13 // Update Count     : 69
     12// Last Modified On : Mon Jun 12 13:35:00 2017
     13// Update Count     : 67
    1414//
    1515
    16 #pragma once
     16#ifndef STATEMENT_H
     17#define STATEMENT_H
    1718
    1819#include "BaseSyntaxNode.h"
     
    2627class Statement : public BaseSyntaxNode {
    2728  public:
    28         std::list<Label> labels;
    29 
    3029        Statement( std::list<Label> labels );
    3130        virtual ~Statement();
     
    3837        virtual Statement *acceptMutator( Mutator &m ) = 0;
    3938        virtual void print( std::ostream &os, int indent = 0 ) const;
     39  protected:
     40        std::list<Label> labels;
    4041};
    4142
    4243class CompoundStmt : public Statement {
    4344  public:
    44         std::list<Statement*> kids;
    45 
    4645        CompoundStmt( std::list<Label> labels );
    4746        CompoundStmt( const CompoundStmt &other );
     
    5655        virtual CompoundStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    5756        virtual void print( std::ostream &os, int indent = 0 ) const;
     57  private:
     58        std::list<Statement*> kids;
    5859};
    5960
     
    6768        virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    6869        virtual void print( std::ostream &os, int indent = 0 ) const;
     70
     71  private:
    6972};
    7073
    7174class ExprStmt : public Statement {
    7275  public:
    73         Expression *expr;
    74 
    7576        ExprStmt( std::list<Label> labels, Expression *expr );
    7677        ExprStmt( const ExprStmt &other );
     
    8485        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    8586        virtual void print( std::ostream &os, int indent = 0 ) const;
     87  private:
     88        Expression *expr;
    8689};
    8790
    8891class AsmStmt : public Statement {
    8992  public:
    90         bool voltile;
    91         ConstantExpr *instruction;
    92         std::list<Expression *> output, input;
    93         std::list<ConstantExpr *> clobber;
    94         std::list<Label> gotolabels;
    95 
    9693        AsmStmt( std::list<Label> labels, bool voltile, ConstantExpr *instruction, std::list<Expression *> input, std::list<Expression *> output, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels );
    9794        AsmStmt( const AsmStmt &other );
     
    115112        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    116113        virtual void print( std::ostream &os, int indent = 0 ) const;
     114  private:
     115        bool voltile;
     116        ConstantExpr *instruction;
     117        std::list<Expression *> output, input;
     118        std::list<ConstantExpr *> clobber;
     119        std::list<Label> gotolabels;
    117120};
    118121
    119122class IfStmt : public Statement {
    120123  public:
    121         Expression *condition;
    122         Statement *thenPart;
    123         Statement *elsePart;
    124 
    125124        IfStmt( std::list<Label> labels, Expression *condition, Statement *thenPart, Statement *elsePart );
    126125        IfStmt( const IfStmt &other );
     
    138137        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    139138        virtual void print( std::ostream &os, int indent = 0 ) const;
     139  private:
     140        Expression *condition;
     141        Statement *thenPart;
     142        Statement *elsePart;
    140143};
    141144
    142145class SwitchStmt : public Statement {
    143146  public:
    144         Expression * condition;
    145 
    146147        SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &statements );
    147148        SwitchStmt( const SwitchStmt &other );
     
    159160        virtual void print( std::ostream &os, int indent = 0 ) const;
    160161  private:
     162        Expression * condition;
    161163        std::list<Statement *> statements;
    162164};
     
    164166class CaseStmt : public Statement {
    165167  public:
    166         Expression * condition;
    167         std::list<Statement *> stmts;
    168 
    169168        CaseStmt( std::list<Label> labels, Expression *conditions, std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError);
    170169        CaseStmt( const CaseStmt &other );
     
    188187        virtual void print( std::ostream &os, int indent = 0 ) const;
    189188  private:
     189        Expression * condition;
     190        std::list<Statement *> stmts;
    190191        bool _isDefault;
    191192};
     
    193194class WhileStmt : public Statement {
    194195  public:
    195         Expression *condition;
    196         Statement *body;
    197         bool isDoWhile;
    198 
    199196        WhileStmt( std::list<Label> labels, Expression *condition,
    200197               Statement *body, bool isDoWhile = false );
     
    213210        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    214211        virtual void print( std::ostream &os, int indent = 0 ) const;
     212  private:
     213        Expression *condition;
     214        Statement *body;
     215        bool isDoWhile;
    215216};
    216217
    217218class ForStmt : public Statement {
    218219  public:
    219         std::list<Statement *> initialization;
    220         Expression *condition;
    221         Expression *increment;
    222         Statement *body;
    223 
    224220        ForStmt( std::list<Label> labels, std::list<Statement *> initialization,
    225221             Expression *condition = 0, Expression *increment = 0, Statement *body = 0 );
     
    240236        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    241237        virtual void print( std::ostream &os, int indent = 0 ) const;
     238  private:
     239        std::list<Statement *> initialization;
     240        Expression *condition;
     241        Expression *increment;
     242        Statement *body;
    242243};
    243244
     
    246247        enum Type { Goto = 0, Break, Continue };
    247248
    248         // originalTarget kept for error messages.
    249         const Label originalTarget;
     249        BranchStmt( std::list<Label> labels, Label target, Type ) throw (SemanticError);
     250        BranchStmt( std::list<Label> labels, Expression *computedTarget, Type ) throw (SemanticError);
     251
     252        Label get_originalTarget() { return originalTarget; }
     253        Label get_target() { return target; }
     254        void set_target( Label newValue ) { target = newValue; }
     255
     256        Expression *get_computedTarget() { return computedTarget; }
     257        void set_target( Expression * newValue ) { computedTarget = newValue; }
     258
     259        Type get_type() { return type; }
     260        const char *get_typename() { return brType[ type ]; }
     261
     262        virtual BranchStmt *clone() const { return new BranchStmt( *this ); }
     263        virtual void accept( Visitor &v ) { v.visit( this ); }
     264        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     265        virtual void print( std::ostream &os, int indent = 0 ) const;
     266  private:
     267        static const char *brType[];
     268        Label originalTarget;  // can give better error messages if we remember the label name that the user entered
    250269        Label target;
    251270        Expression *computedTarget;
    252271        Type type;
    253 
    254         BranchStmt( std::list<Label> labels, Label target, Type ) throw (SemanticError);
    255         BranchStmt( std::list<Label> labels, Expression *computedTarget, Type ) throw (SemanticError);
    256 
    257         Label get_originalTarget() { return originalTarget; }
    258         Label get_target() { return target; }
    259         void set_target( Label newValue ) { target = newValue; }
    260 
    261         Expression *get_computedTarget() { return computedTarget; }
    262         void set_target( Expression * newValue ) { computedTarget = newValue; }
    263 
    264         Type get_type() { return type; }
    265         const char *get_typename() { return brType[ type ]; }
    266 
    267         virtual BranchStmt *clone() const { return new BranchStmt( *this ); }
    268         virtual void accept( Visitor &v ) { v.visit( this ); }
    269         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    270         virtual void print( std::ostream &os, int indent = 0 ) const;
    271   private:
    272         static const char *brType[];
    273272};
    274273
    275274class ReturnStmt : public Statement {
    276275  public:
    277         Expression *expr;
    278 
    279276        ReturnStmt( std::list<Label> labels, Expression *expr );
    280277        ReturnStmt( const ReturnStmt &other );
     
    288285        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    289286        virtual void print( std::ostream &os, int indent = 0 ) const;
     287  private:
     288        Expression *expr;
    290289};
    291290
     
    293292  public:
    294293        enum Kind { Terminate, Resume };
    295 
    296         const Kind kind;
    297         Expression * expr;
    298         Expression * target;
    299294
    300295        ThrowStmt( std::list<Label> labels, Kind kind, Expression * expr, Expression * target = nullptr );
     
    312307        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    313308        virtual void print( std::ostream &os, int indent = 0 ) const;
     309  private:
     310        Kind kind;
     311        Expression * expr;
     312        Expression * target;
    314313};
    315314
    316315class TryStmt : public Statement {
    317316  public:
     317        TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 );
     318        TryStmt( const TryStmt &other );
     319        virtual ~TryStmt();
     320
     321        CompoundStmt *get_block() const { return block; }
     322        void set_block( CompoundStmt *newValue ) { block = newValue; }
     323        std::list<CatchStmt *>& get_catchers() { return handlers; }
     324
     325        FinallyStmt *get_finally() const { return finallyBlock; }
     326        void set_finally( FinallyStmt *newValue ) { finallyBlock = newValue; }
     327
     328        virtual TryStmt *clone() const { return new TryStmt( *this ); }
     329        virtual void accept( Visitor &v ) { v.visit( this ); }
     330        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     331        virtual void print( std::ostream &os, int indent = 0 ) const;
     332
     333  private:
    318334        CompoundStmt *block;
    319335        std::list<CatchStmt *> handlers;
    320336        FinallyStmt *finallyBlock;
    321 
    322         TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 );
    323         TryStmt( const TryStmt &other );
    324         virtual ~TryStmt();
    325 
    326         CompoundStmt *get_block() const { return block; }
    327         void set_block( CompoundStmt *newValue ) { block = newValue; }
    328         std::list<CatchStmt *>& get_catchers() { return handlers; }
    329 
    330         FinallyStmt *get_finally() const { return finallyBlock; }
    331         void set_finally( FinallyStmt *newValue ) { finallyBlock = newValue; }
    332 
    333         virtual TryStmt *clone() const { return new TryStmt( *this ); }
    334         virtual void accept( Visitor &v ) { v.visit( this ); }
    335         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    336         virtual void print( std::ostream &os, int indent = 0 ) const;
    337337};
    338338
     
    340340  public:
    341341        enum Kind { Terminate, Resume };
    342 
    343         const Kind kind;
    344         Declaration *decl;
    345         Expression *cond;
    346         Statement *body;
    347342
    348343        CatchStmt( std::list<Label> labels, Kind kind, Declaration *decl,
     
    363358        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    364359        virtual void print( std::ostream &os, int indent = 0 ) const;
     360
     361  private:
     362        Kind kind;
     363        Declaration *decl;
     364        Expression *cond;
     365        Statement *body;
    365366};
    366367
    367368class FinallyStmt : public Statement {
    368369  public:
    369         CompoundStmt *block;
    370 
    371370        FinallyStmt( std::list<Label> labels, CompoundStmt *block );
    372371        FinallyStmt( const FinallyStmt &other );
     
    380379        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    381380        virtual void print( std::ostream &os, int indent = 0 ) const;
     381  private:
     382        CompoundStmt *block;
    382383};
    383384
     
    386387class DeclStmt : public Statement {
    387388  public:
    388         Declaration *decl;
    389 
    390389        DeclStmt( std::list<Label> labels, Declaration *decl );
    391390        DeclStmt( const DeclStmt &other );
     
    399398        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    400399        virtual void print( std::ostream &os, int indent = 0 ) const;
     400  private:
     401        Declaration *decl;
    401402};
    402403
     
    407408class ImplicitCtorDtorStmt : public Statement {
    408409  public:
    409         // Non-owned pointer to the constructor/destructor statement
    410         Statement * callStmt;
    411 
    412410        ImplicitCtorDtorStmt( Statement * callStmt );
    413411        ImplicitCtorDtorStmt( const ImplicitCtorDtorStmt & other );
     
    421419        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    422420        virtual void print( std::ostream &os, int indent = 0 ) const;
     421
     422  private:
     423        // Non-owned pointer to the constructor/destructor statement
     424        Statement * callStmt;
    423425};
    424426
    425427
    426428std::ostream & operator<<( std::ostream & out, const Statement * statement );
     429
     430#endif // STATEMENT_H
    427431
    428432// Local Variables: //
  • src/SynTree/SynTree.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Jul 24 16:54:00 2017
    13 // Update Count     : 11
     12// Last Modified On : Thu Jun  8 17:00:00 2017
     13// Update Count     : 9
    1414//
    1515
    16 #pragma once
     16#ifndef SYNTREE_H
     17#define SYNTREE_H
    1718
    1819#include <string>
     
    6667class LabelAddressExpr;
    6768class CastExpr;
    68 class VirtualCastExpr;
    6969class MemberExpr;
    7070class UntypedMemberExpr;
     
    135135class Attribute;
    136136
     137#endif // SYNTREE_H
     138
    137139// Local Variables: //
    138140// tab-width: 4 //
  • src/SynTree/Type.cc

    r0720e049 r3d4b23fa  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Aug  2 11:11:00 2017
    13 // Update Count     : 29
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Mar 17 08:42:47 2017
     13// Update Count     : 28
    1414//
    1515
     
    8888}
    8989
    90 // Empty Variable declarations:
    91 const Type::FuncSpecifiers noFuncSpecifiers;
    92 const Type::StorageClasses noStorageClasses;
    93 const Type::Qualifiers noQualifiers;
    94 
    9590std::ostream & operator<<( std::ostream & out, const Type * type ) {
    9691        if ( type ) {
  • src/SynTree/Type.h

    r0720e049 r3d4b23fa  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Aug  9 14:25:00 2017
    13 // Update Count     : 152
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Mar 23 16:16:36 2017
     13// Update Count     : 149
    1414//
    1515
    16 #pragma once
     16#ifndef TYPE_H
     17#define TYPE_H
    1718
    1819#include "BaseSyntaxNode.h"
     
    127128        }; // Qualifiers
    128129
    129         typedef std::list<TypeDecl *> ForallList;
    130 
    131         Qualifiers tq;
    132         ForallList forall;
    133         std::list< Attribute * > attributes;
    134 
    135130        Type( const Qualifiers & tq, const std::list< Attribute * > & attributes );
    136131        Type( const Type & other );
     
    151146        void set_atomic( bool newValue ) { tq.is_atomic = newValue; }
    152147
     148        typedef std::list<TypeDecl *> ForallList;
    153149        ForallList& get_forall() { return forall; }
    154150
     
    170166        virtual Type *acceptMutator( Mutator & m ) = 0;
    171167        virtual void print( std::ostream & os, int indent = 0 ) const;
    172 };
    173 
    174 extern const Type::FuncSpecifiers noFuncSpecifiers;
    175 extern const Type::StorageClasses noStorageClasses;
    176 extern const Type::Qualifiers noQualifiers;                     // no qualifiers on constants
     168  private:
     169        Qualifiers tq;
     170        ForallList forall;
     171        std::list< Attribute * > attributes;
     172};
     173
     174extern Type::Qualifiers emptyQualifiers;                                // no qualifiers on constants
    177175
    178176class VoidType : public Type {
     
    214212                LongDoubleImaginary,
    215213                NUMBER_OF_BASIC_TYPES
    216         } kind;
     214        };
    217215
    218216        static const char *typeNames[];                                         // string names for basic types, MUST MATCH with Kind
     
    229227
    230228        bool isInteger() const;
     229  private:
     230        Kind kind;
    231231};
    232232
    233233class PointerType : public Type {
    234234  public:
    235         Type *base;
    236 
    237         // In C99, pointer types can be qualified in many ways e.g., int f( int a[ static 3 ] )
    238         Expression *dimension;
    239         bool isVarLen;
    240         bool isStatic;
    241 
    242235        PointerType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    243236        PointerType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
     
    260253        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    261254        virtual void print( std::ostream & os, int indent = 0 ) const;
    262 };
    263 
    264 class ArrayType : public Type {
    265   public:
     255  private:
    266256        Type *base;
     257
     258        // In C99, pointer types can be qualified in many ways e.g., int f( int a[ static 3 ] )
    267259        Expression *dimension;
    268260        bool isVarLen;
    269261        bool isStatic;
    270 
     262};
     263
     264class ArrayType : public Type {
     265  public:
    271266        ArrayType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    272267        ArrayType( const ArrayType& );
     
    288283        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    289284        virtual void print( std::ostream & os, int indent = 0 ) const;
     285  private:
     286        Type *base;
     287        Expression *dimension;
     288        bool isVarLen;
     289        bool isStatic;
    290290};
    291291
    292292class FunctionType : public Type {
    293293  public:
     294        FunctionType( const Type::Qualifiers & tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
     295        FunctionType( const FunctionType& );
     296        virtual ~FunctionType();
     297
     298        std::list<DeclarationWithType*> & get_returnVals() { return returnVals; }
     299        std::list<DeclarationWithType*> & get_parameters() { return parameters; }
     300        bool get_isVarArgs() const { return isVarArgs; }
     301        void set_isVarArgs( bool newValue ) { isVarArgs = newValue; }
     302        bool isTtype() const;
     303
     304        virtual FunctionType *clone() const { return new FunctionType( *this ); }
     305        virtual void accept( Visitor & v ) { v.visit( this ); }
     306        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     307        virtual void print( std::ostream & os, int indent = 0 ) const;
     308  private:
    294309        std::list<DeclarationWithType*> returnVals;
    295310        std::list<DeclarationWithType*> parameters;
     
    300315        // - an unprototyped declaration
    301316        bool isVarArgs;
    302 
    303         FunctionType( const Type::Qualifiers & tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    304         FunctionType( const FunctionType& );
    305         virtual ~FunctionType();
    306 
    307         std::list<DeclarationWithType*> & get_returnVals() { return returnVals; }
    308         std::list<DeclarationWithType*> & get_parameters() { return parameters; }
    309         bool get_isVarArgs() const { return isVarArgs; }
    310         void set_isVarArgs( bool newValue ) { isVarArgs = newValue; }
    311         bool isTtype() const;
    312 
    313         virtual FunctionType *clone() const { return new FunctionType( *this ); }
    314         virtual void accept( Visitor & v ) { v.visit( this ); }
    315         virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    316         virtual void print( std::ostream & os, int indent = 0 ) const;
    317317};
    318318
    319319class ReferenceToType : public Type {
    320320  public:
    321         std::list< Expression* > parameters;
    322         std::string name;
    323         bool hoistType;
    324 
    325321        ReferenceToType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes );
    326322        ReferenceToType( const ReferenceToType & other );
     
    341337  protected:
    342338        virtual std::string typeString() const = 0;
     339        std::list< Expression* > parameters;
     340        std::string name;
     341  private:
     342        bool hoistType;
    343343};
    344344
     
    346346        typedef ReferenceToType Parent;
    347347  public:
     348        StructInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseStruct( 0 ) {}
     349        StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     350        StructInstType( const StructInstType & other ) : Parent( other ), baseStruct( other.baseStruct ) {}
     351
     352        StructDecl *get_baseStruct() const { return baseStruct; }
     353        void set_baseStruct( StructDecl *newValue ) { baseStruct = newValue; }
     354
     355        /// Accesses generic parameters of base struct (NULL if none such)
     356        std::list<TypeDecl*> * get_baseParameters();
     357
     358        virtual bool isComplete() const;
     359
     360        /// Looks up the members of this struct named "name" and places them into "foundDecls".
     361        /// Clones declarations into "foundDecls", caller responsible for freeing
     362        void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const;
     363
     364        virtual StructInstType *clone() const { return new StructInstType( *this ); }
     365        virtual void accept( Visitor & v ) { v.visit( this ); }
     366        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     367
     368        virtual void print( std::ostream & os, int indent = 0 ) const;
     369  private:
     370        virtual std::string typeString() const;
     371
    348372        // this decl is not "owned" by the struct inst; it is merely a pointer to elsewhere in the tree,
    349373        // where the structure used in this type is actually defined
    350374        StructDecl *baseStruct;
    351 
    352         StructInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseStruct( 0 ) {}
    353         StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    354         StructInstType( const StructInstType & other ) : Parent( other ), baseStruct( other.baseStruct ) {}
    355 
    356         StructDecl *get_baseStruct() const { return baseStruct; }
    357         void set_baseStruct( StructDecl *newValue ) { baseStruct = newValue; }
    358 
    359         /// Accesses generic parameters of base struct (NULL if none such)
    360         std::list<TypeDecl*> * get_baseParameters();
     375};
     376
     377class UnionInstType : public ReferenceToType {
     378        typedef ReferenceToType Parent;
     379  public:
     380        UnionInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseUnion( 0 ) {}
     381        UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     382        UnionInstType( const UnionInstType & other ) : Parent( other ), baseUnion( other.baseUnion ) {}
     383
     384        UnionDecl *get_baseUnion() const { return baseUnion; }
     385        void set_baseUnion( UnionDecl * newValue ) { baseUnion = newValue; }
     386
     387        /// Accesses generic parameters of base union (NULL if none such)
     388        std::list< TypeDecl * > * get_baseParameters();
    361389
    362390        virtual bool isComplete() const;
    363391
    364         /// Looks up the members of this struct named "name" and places them into "foundDecls".
     392        /// looks up the members of this union named "name" and places them into "foundDecls"
    365393        /// Clones declarations into "foundDecls", caller responsible for freeing
    366394        void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const;
    367395
    368         virtual StructInstType *clone() const { return new StructInstType( *this ); }
     396        virtual UnionInstType *clone() const { return new UnionInstType( *this ); }
    369397        virtual void accept( Visitor & v ) { v.visit( this ); }
    370398        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     
    373401  private:
    374402        virtual std::string typeString() const;
    375 };
    376 
    377 class UnionInstType : public ReferenceToType {
    378         typedef ReferenceToType Parent;
    379   public:
     403
    380404        // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree,
    381405        // where the union used in this type is actually defined
    382406        UnionDecl *baseUnion;
    383 
    384         UnionInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseUnion( 0 ) {}
    385         UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    386         UnionInstType( const UnionInstType & other ) : Parent( other ), baseUnion( other.baseUnion ) {}
    387 
    388         UnionDecl *get_baseUnion() const { return baseUnion; }
    389         void set_baseUnion( UnionDecl * newValue ) { baseUnion = newValue; }
    390 
    391         /// Accesses generic parameters of base union (NULL if none such)
    392         std::list< TypeDecl * > * get_baseParameters();
    393 
    394         virtual bool isComplete() const;
    395 
    396         /// looks up the members of this union named "name" and places them into "foundDecls"
    397         /// Clones declarations into "foundDecls", caller responsible for freeing
    398         void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const;
    399 
    400         virtual UnionInstType *clone() const { return new UnionInstType( *this ); }
    401         virtual void accept( Visitor & v ) { v.visit( this ); }
    402         virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    403 
    404         virtual void print( std::ostream & os, int indent = 0 ) const;
    405   private:
    406         virtual std::string typeString() const;
    407407};
    408408
     
    410410        typedef ReferenceToType Parent;
    411411  public:
     412        EnumInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
     413        EnumInstType( const Type::Qualifiers & tq, EnumDecl * baseEnum, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     414        EnumInstType( const EnumInstType & other ) : Parent( other ), baseEnum( other.baseEnum ) {}
     415
     416        EnumDecl *get_baseEnum() const { return baseEnum; }
     417        void set_baseEnum( EnumDecl *newValue ) { baseEnum = newValue; }
     418
     419        virtual bool isComplete() const;
     420
     421        virtual EnumInstType *clone() const { return new EnumInstType( *this ); }
     422        virtual void accept( Visitor & v ) { v.visit( this ); }
     423        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     424  private:
     425        virtual std::string typeString() const;
     426
    412427        // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree,
    413428        // where the union used in this type is actually defined
    414429        EnumDecl *baseEnum = nullptr;
    415 
    416         EnumInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
    417         EnumInstType( const Type::Qualifiers & tq, EnumDecl * baseEnum, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    418         EnumInstType( const EnumInstType & other ) : Parent( other ), baseEnum( other.baseEnum ) {}
    419 
    420         EnumDecl *get_baseEnum() const { return baseEnum; }
    421         void set_baseEnum( EnumDecl *newValue ) { baseEnum = newValue; }
    422 
    423         virtual bool isComplete() const;
    424 
    425         virtual EnumInstType *clone() const { return new EnumInstType( *this ); }
    426         virtual void accept( Visitor & v ) { v.visit( this ); }
    427         virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    428   private:
    429         virtual std::string typeString() const;
    430430};
    431431
     
    433433        typedef ReferenceToType Parent;
    434434  public:
     435        TraitInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
     436        TraitInstType( const TraitInstType & other );
     437        ~TraitInstType();
     438
     439        std::list< Declaration* >& get_members() { return members; }
     440
     441        virtual bool isComplete() const;
     442
     443        virtual TraitInstType *clone() const { return new TraitInstType( *this ); }
     444        virtual void accept( Visitor & v ) { v.visit( this ); }
     445        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     446  private:
     447        virtual std::string typeString() const;
     448
    435449        // this member is filled in by the validate pass, which instantiates the members of the correponding
    436450        // aggregate with the actual type parameters specified for this use of the context
    437451        std::list< Declaration* > members;
    438 
    439         TraitInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
    440         TraitInstType( const TraitInstType & other );
    441         ~TraitInstType();
    442 
    443         std::list< Declaration* >& get_members() { return members; }
    444 
    445         virtual bool isComplete() const;
    446 
    447         virtual TraitInstType *clone() const { return new TraitInstType( *this ); }
    448         virtual void accept( Visitor & v ) { v.visit( this ); }
    449         virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    450   private:
    451         virtual std::string typeString() const;
    452452};
    453453
     
    455455        typedef ReferenceToType Parent;
    456456  public:
     457        TypeInstType( const Type::Qualifiers & tq, const std::string & name, TypeDecl *baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     458        TypeInstType( const Type::Qualifiers & tq, const std::string & name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     459        TypeInstType( const TypeInstType & other );
     460        ~TypeInstType();
     461
     462        TypeDecl *get_baseType() const { return baseType; }
     463        void set_baseType( TypeDecl *newValue );
     464        bool get_isFtype() const { return isFtype; }
     465        void set_isFtype( bool newValue ) { isFtype = newValue; }
     466
     467        virtual bool isComplete() const;
     468
     469        virtual TypeInstType *clone() const { return new TypeInstType( *this ); }
     470        virtual void accept( Visitor & v ) { v.visit( this ); }
     471        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     472        virtual void print( std::ostream & os, int indent = 0 ) const;
     473  private:
     474        virtual std::string typeString() const;
    457475        // this decl is not "owned" by the type inst; it is merely a pointer to elsewhere in the tree,
    458476        // where the type used here is actually defined
    459477        TypeDecl *baseType;
    460478        bool isFtype;
    461 
    462         TypeInstType( const Type::Qualifiers & tq, const std::string & name, TypeDecl *baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    463         TypeInstType( const Type::Qualifiers & tq, const std::string & name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    464         TypeInstType( const TypeInstType & other );
    465         ~TypeInstType();
    466 
    467         TypeDecl *get_baseType() const { return baseType; }
    468         void set_baseType( TypeDecl *newValue );
    469         bool get_isFtype() const { return isFtype; }
    470         void set_isFtype( bool newValue ) { isFtype = newValue; }
    471 
    472         virtual bool isComplete() const;
    473 
    474         virtual TypeInstType *clone() const { return new TypeInstType( *this ); }
    475         virtual void accept( Visitor & v ) { v.visit( this ); }
    476         virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    477         virtual void print( std::ostream & os, int indent = 0 ) const;
    478   private:
    479         virtual std::string typeString() const;
    480479};
    481480
    482481class TupleType : public Type {
    483482  public:
    484         std::list<Type *> types;
    485         std::list<Declaration *> members;
    486 
    487483        TupleType( const Type::Qualifiers & tq, const std::list< Type * > & types, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    488484        TupleType( const TupleType& );
     
    513509        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    514510        virtual void print( std::ostream & os, int indent = 0 ) const;
     511  private:
     512        std::list<Type *> types;
     513        std::list<Declaration *> members;
    515514};
    516515
    517516class TypeofType : public Type {
    518517  public:
    519         Expression *expr;
    520 
    521518        TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    522519        TypeofType( const TypeofType& );
     
    532529        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    533530        virtual void print( std::ostream & os, int indent = 0 ) const;
     531  private:
     532        Expression *expr;
    534533};
    535534
    536535class AttrType : public Type {
    537536  public:
    538         std::string name;
    539         Expression *expr;
    540         Type *type;
    541         bool isType;
    542 
    543537        AttrType( const Type::Qualifiers & tq, const std::string & name, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    544538        AttrType( const Type::Qualifiers & tq, const std::string & name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     
    561555        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    562556        virtual void print( std::ostream & os, int indent = 0 ) const;
     557  private:
     558        std::string name;
     559        Expression *expr;
     560        Type *type;
     561        bool isType;
    563562};
    564563
     
    602601
    603602std::ostream & operator<<( std::ostream & out, const Type * type );
     603
     604#endif // TYPE_H
    604605
    605606// Local Variables: //
  • src/SynTree/TypeDecl.cc

    r0720e049 r3d4b23fa  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Aug  9 14:35:00 2017
    13 // Update Count     : 6
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Mar 16 07:49:58 2017
     13// Update Count     : 5
    1414//
    1515
     
    1818#include "Common/utility.h"
    1919
    20 TypeDecl::TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, Type * init ) : Parent( name, scs, type ), init( init ), sized( kind == Any || kind == Ttype ), kind( kind ) {
     20TypeDecl::TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, Type * init ) : Parent( name, scs, type ), kind( kind ), init( init ), sized( kind == Any || kind == Ttype ) {
    2121}
    2222
    23 TypeDecl::TypeDecl( const TypeDecl &other ) : Parent( other ), init( maybeClone( other.init ) ), sized( other.sized ), kind( other.kind ) {
     23TypeDecl::TypeDecl( const TypeDecl &other ) : Parent( other ), kind( other.kind ), init( maybeClone( other.init ) ), sized( other.sized ) {
    2424}
    2525
  • src/SynTree/TypeExpr.cc

    r0720e049 r3d4b23fa  
    2121}
    2222
    23 TypeExpr::TypeExpr( const TypeExpr &other ) : Expression( other ), type( maybeClone( other.type ) ) {
     23TypeExpr::TypeExpr( const TypeExpr &other ) : type( maybeClone( other.type ) ) {
    2424}
    2525
  • src/SynTree/TypeSubstitution.h

    r0720e049 r3d4b23fa  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:52:24 2017
    13 // Update Count     : 3
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Fri Apr 29 15:00:20 2016
     13// Update Count     : 2
    1414//
    1515
    16 #pragma once
     16#ifndef TYPESUBSTITUTION_H
     17#define TYPESUBSTITUTION_H
    1718
    1819#include <map>
     
    179180std::ostream & operator<<( std::ostream & out, const TypeSubstitution & sub );
    180181
     182#endif // TYPESUBSTITUTION_H
     183
    181184// Local Variables: //
    182185// tab-width: 4 //
  • src/SynTree/VarExprReplacer.h

    r0720e049 r3d4b23fa  
    99// Author           : Rob Schluntz
    1010// Created On       : Wed Jan 13 16:29:30 2016
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:53:41 2017
    13 // Update Count     : 6
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Fri May 13 11:27:52 2016
     13// Update Count     : 5
    1414//
    1515
    16 #pragma once
     16#ifndef VAR_EXPR_REPLACER_H
     17#define VAR_EXPR_REPLACER_H
    1718
    1819#include <map>
     
    3435};
    3536
     37#endif // VAR_EXPR_REPLACER_H
     38
    3639// Local Variables: //
    3740// tab-width: 4 //
  • src/SynTree/Visitor.cc

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Jul 24 16:30:00 2017
    13 // Update Count     : 27
     12// Last Modified On : Thu Jun 22 13:41:00 2017
     13// Update Count     : 26
    1414//
    1515
     
    192192}
    193193
    194 void Visitor::visit( VirtualCastExpr *castExpr ) {
    195         maybeAccept( castExpr->get_result(), *this );
    196         maybeAccept( castExpr->get_arg(), *this );
    197 }
    198 
    199194void Visitor::visit( UntypedMemberExpr *memberExpr ) {
    200195        maybeAccept( memberExpr->get_result(), *this );
  • src/SynTree/Visitor.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Jul 24 16:28:00 2017
    13 // Update Count     : 13
     12// Last Modified On : Thr Jun 08 15:45:00 2017
     13// Update Count     : 11
    1414//
    1515
    16 #pragma once
     16#ifndef VISITOR_H
     17#define VISITOR_H
    1718
    1819#include "SynTree.h"
     
    6061        virtual void visit( NameExpr *nameExpr );
    6162        virtual void visit( CastExpr *castExpr );
    62         virtual void visit( VirtualCastExpr *castExpr );
    6363        virtual void visit( AddressExpr *addressExpr );
    6464        virtual void visit( LabelAddressExpr *labAddressExpr );
     
    174174}
    175175
     176#endif // VISITOR_H
     177
    176178// Local Variables: //
    177179// tab-width: 4 //
  • src/Tuples/Explode.h

    r0720e049 r3d4b23fa  
    99// Author           : Rob Schluntz
    1010// Created On       : Wed Nov 9 13:12:24 2016
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:55:16 2017
    13 // Update Count     : 3
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Nov 9 13:20:24 2016
     13// Update Count     : 2
    1414//
    1515
    16 #pragma once
     16#ifndef _EXPLODE_H_
     17#define _EXPLODE_H_
    1718
    1819#include "ResolvExpr/AlternativeFinder.h"
     
    9495} // namespace Tuples
    9596
     97#endif // _TUPLE_ASSIGNMENT_H_
     98
    9699// Local Variables: //
    97100// tab-width: 4 //
  • src/Tuples/TupleExpansion.cc

    r0720e049 r3d4b23fa  
    6666                };
    6767
    68                 struct TupleTypeReplacer : public WithDeclsToAdd, public WithGuards, public WithTypeSubstitution {
    69                         Type * postmutate( TupleType * tupleType );
    70 
    71                         void premutate( CompoundStmt * ) {
    72                                 GuardScope( typeMap );
     68                class TupleTypeReplacer : public GenPoly::DeclMutator {
     69                  public:
     70                        typedef GenPoly::DeclMutator Parent;
     71                        using Parent::mutate;
     72
     73                        virtual Type * mutate( TupleType * tupleType ) override;
     74
     75                        virtual CompoundStmt * mutate( CompoundStmt * stmt ) override {
     76                                typeMap.beginScope();
     77                                stmt = Parent::mutate( stmt );
     78                                typeMap.endScope();
     79                                return stmt;
    7380                        }
    7481                  private:
     
    104111                mutateAll( translationUnit, assnExpander );
    105112
    106                 PassVisitor<TupleTypeReplacer> replacer;
    107                 mutateAll( translationUnit, replacer );
     113                TupleTypeReplacer replacer;
     114                replacer.mutateDeclarationList( translationUnit );
    108115
    109116                PassVisitor<TupleIndexExpander> idxExpander;
     
    211218        }
    212219
    213         Type * TupleTypeReplacer::postmutate( TupleType * tupleType ) {
     220        Type * TupleTypeReplacer::mutate( TupleType * tupleType ) {
     221                tupleType = safe_dynamic_cast< TupleType * > ( Parent::mutate( tupleType ) );
    214222                unsigned tupleSize = tupleType->size();
    215223                if ( ! typeMap.count( tupleSize ) ) {
     
    218226                        decl->set_body( true );
    219227                        for ( size_t i = 0; i < tupleSize; ++i ) {
    220                                 TypeDecl * tyParam = new TypeDecl( toString( "tuple_param_", tupleSize, "_", i ), Type::StorageClasses(), nullptr, TypeDecl::Any );
     228                                TypeDecl * tyParam = new TypeDecl( toString( "tuple_param_", i ), Type::StorageClasses(), nullptr, TypeDecl::Any );
    221229                                decl->get_members().push_back( new ObjectDecl( toString("field_", i ), Type::StorageClasses(), LinkageSpec::C, nullptr, new TypeInstType( Type::Qualifiers(), tyParam->get_name(), tyParam ), nullptr ) );
    222230                                decl->get_parameters().push_back( tyParam );
     
    227235                        }
    228236                        typeMap[tupleSize] = decl;
    229                         declsToAddBefore.push_back( decl );
     237                        addDeclaration( decl );
    230238                }
    231239                Type::Qualifiers qualifiers = tupleType->get_qualifiers();
     
    233241                StructDecl * decl = typeMap[tupleSize];
    234242                StructInstType * newType = new StructInstType( qualifiers, decl );
    235                 for ( auto p : group_iterate( tupleType->get_types(), decl->get_parameters() ) ) {
    236                         Type * t = std::get<0>(p);
    237                         TypeDecl * td = std::get<1>(p);
     243                for ( Type * t : *tupleType ) {
    238244                        newType->get_parameters().push_back( new TypeExpr( t->clone() ) );
    239                         if ( env ) {
    240                                 // add bindings to the type environment.
    241                                 // xxx - This may not be sufficient, it may be necessary to rename type variables on StructInstType?
    242                                 env->add( td->get_name(), t->clone() );
    243                         }
    244245                }
    245246                delete tupleType;
  • src/Tuples/Tuples.h

    r0720e049 r3d4b23fa  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:55:00 2017
    13 // Update Count     : 16
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Nov 9 13:17:58 2016
     13// Update Count     : 15
    1414//
    1515
    16 #pragma once
     16#ifndef _TUPLES_H_
     17#define _TUPLES_H_
    1718
    1819#include <string>
     
    4849} // namespace Tuples
    4950
     51#endif // _TUPLE_ASSIGNMENT_H_
     52
    5053// Local Variables: //
    5154// tab-width: 4 //
  • src/benchmark/create_pthrd.c

    r0720e049 r3d4b23fa  
    1414                n = atoi(argv[1]);
    1515        }
    16         printf("create %lu pthreads ... ", n);
     16        printf("%lu\n", n);
    1717
    1818        for (size_t i = 0; i < n; i++) {
    1919                pthread_t thread;
    2020                if (pthread_create(&thread, NULL, foo, NULL) < 0) {
    21                         perror( "failure" );
    2221                        return 1;
    2322                }
    2423
    2524                if (pthread_join( thread, NULL) < 0) {
    26                         perror( "failure" );
    2725                        return 1;
    2826                }
    2927        }
    30         printf("finish\n");
     28        pthread_exit(NULL);
     29        return 0;
    3130}
  • src/libcfa/Makefile.am

    r0720e049 r3d4b23fa  
    1111## Created On       : Sun May 31 08:54:01 2015
    1212## Last Modified By : Andrew Beach
    13 ## Last Modified On : Wed Jul 26 14:15:00 2017
    14 ## Update Count     : 221
     13## Last Modified On : Wed Jun 28 15:36:00 2017
     14## Update Count     : 215
    1515###############################################################################
    1616
     
    3939
    4040AM_CCASFLAGS = @CFA_FLAGS@
    41 
    42 #CFLAGS for most libcfa src
    43 #use -no-include-stdhdr to prevent rebuild cycles
    44 #The built sources must not depend on the installed headers
    45 CFLAGS = -quiet -no-include-stdhdr -I${abs_top_srcdir}/src/libcfa/stdhdr -XCFA -t -B${abs_top_srcdir}/src/driver ${EXTRA_FLAGS}
     41CFLAGS = -quiet -no-include-stdhdr -XCFA -t -B${abs_top_srcdir}/src/driver ${EXTRA_FLAGS}
    4642CC = ${abs_top_srcdir}/src/driver/cfa
    4743
    48 headers = fstream iostream iterator limits rational stdlib \
     44headers = assert fstream iostream iterator limits math rational stdlib \
    4945          containers/maybe containers/pair containers/result containers/vector
    5046
     
    5551
    5652libobjs = ${headers:=.o}
    57 libsrc = libcfa-prelude.c interpose.c libhdr/libdebug.c ${headers:=.c} \
    58          assert.c exception.c virtual.c
     53libsrc = libcfa-prelude.c interpose.c libhdr/libdebug.c ${headers:=.c} exception.c
    5954
    6055# not all platforms support concurrency, add option do disable it
     
    7368        ${AM_V_CC}@BACKEND_CC@ -DHAVE_CONFIG_H -I. -I../.. -O2 ${EXTRA_FLAGS} -c -o $@ $<
    7469
    75 libcfa_a-virtual.o : virtual.c
    76         ${AM_V_CC}@BACKEND_CC@ -DHAVE_CONFIG_H -I. -I../.. -O2 ${EXTRA_FLAGS} -c -o $@ $<
    77 
    7870concurrency/libcfa_d_a-invoke.o : concurrency/invoke.c
    7971        ${AM_V_CC}@BACKEND_CC@ -DHAVE_CONFIG_H -I. -I../.. -D__CFA_DEBUG__ -O0 ${EXTRA_FLAGS} -c -o $@ $<
    8072
    8173libcfa_d_a-exception.o : exception.c
    82         ${AM_V_CC}@BACKEND_CC@ -DHAVE_CONFIG_H -I. -I../.. -D__CFA_DEBUG__ -O0 ${EXTRA_FLAGS} -c -o $@ $<
    83 
    84 libcfa_d_a-virtual.o : virtual.c
    8574        ${AM_V_CC}@BACKEND_CC@ -DHAVE_CONFIG_H -I. -I../.. -D__CFA_DEBUG__ -O0 ${EXTRA_FLAGS} -c -o $@ $<
    8675
     
    9584
    9685cfa_includedir = $(CFA_INCDIR)
    97 nobase_cfa_include_HEADERS = ${headers} ${stdhdr} math gmp concurrency/invoke.h
     86nobase_cfa_include_HEADERS = ${headers} ${stdhdr} gmp concurrency/invoke.h
    9887
    9988CLEANFILES = libcfa-prelude.c
  • src/libcfa/Makefile.in

    r0720e049 r3d4b23fa  
    149149libcfa_d_a_LIBADD =
    150150am__libcfa_d_a_SOURCES_DIST = libcfa-prelude.c interpose.c \
    151         libhdr/libdebug.c fstream.c iostream.c iterator.c limits.c \
    152         rational.c stdlib.c containers/maybe.c containers/pair.c \
    153         containers/result.c containers/vector.c \
     151        libhdr/libdebug.c assert.c fstream.c iostream.c iterator.c \
     152        limits.c math.c rational.c stdlib.c containers/maybe.c \
     153        containers/pair.c containers/result.c containers/vector.c \
    154154        concurrency/coroutine.c concurrency/thread.c \
    155         concurrency/kernel.c concurrency/monitor.c assert.c \
    156         exception.c virtual.c concurrency/CtxSwitch-@MACHINE_TYPE@.S \
    157         concurrency/alarm.c concurrency/invoke.c \
    158         concurrency/preemption.c
     155        concurrency/kernel.c concurrency/monitor.c exception.c \
     156        concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/alarm.c \
     157        concurrency/invoke.c concurrency/preemption.c
    159158am__dirstamp = $(am__leading_dot)dirstamp
    160159@BUILD_CONCURRENCY_TRUE@am__objects_1 = concurrency/libcfa_d_a-coroutine.$(OBJEXT) \
     
    162161@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_d_a-kernel.$(OBJEXT) \
    163162@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_d_a-monitor.$(OBJEXT)
    164 am__objects_2 = libcfa_d_a-fstream.$(OBJEXT) \
    165         libcfa_d_a-iostream.$(OBJEXT) libcfa_d_a-iterator.$(OBJEXT) \
    166         libcfa_d_a-limits.$(OBJEXT) libcfa_d_a-rational.$(OBJEXT) \
     163am__objects_2 = libcfa_d_a-assert.$(OBJEXT) \
     164        libcfa_d_a-fstream.$(OBJEXT) libcfa_d_a-iostream.$(OBJEXT) \
     165        libcfa_d_a-iterator.$(OBJEXT) libcfa_d_a-limits.$(OBJEXT) \
     166        libcfa_d_a-math.$(OBJEXT) libcfa_d_a-rational.$(OBJEXT) \
    167167        libcfa_d_a-stdlib.$(OBJEXT) \
    168168        containers/libcfa_d_a-maybe.$(OBJEXT) \
     
    177177        libcfa_d_a-interpose.$(OBJEXT) \
    178178        libhdr/libcfa_d_a-libdebug.$(OBJEXT) $(am__objects_2) \
    179         libcfa_d_a-assert.$(OBJEXT) libcfa_d_a-exception.$(OBJEXT) \
    180         libcfa_d_a-virtual.$(OBJEXT) $(am__objects_3)
     179        libcfa_d_a-exception.$(OBJEXT) $(am__objects_3)
    181180am_libcfa_d_a_OBJECTS = $(am__objects_4)
    182181libcfa_d_a_OBJECTS = $(am_libcfa_d_a_OBJECTS)
     
    184183libcfa_a_LIBADD =
    185184am__libcfa_a_SOURCES_DIST = libcfa-prelude.c interpose.c \
    186         libhdr/libdebug.c fstream.c iostream.c iterator.c limits.c \
    187         rational.c stdlib.c containers/maybe.c containers/pair.c \
    188         containers/result.c containers/vector.c \
     185        libhdr/libdebug.c assert.c fstream.c iostream.c iterator.c \
     186        limits.c math.c rational.c stdlib.c containers/maybe.c \
     187        containers/pair.c containers/result.c containers/vector.c \
    189188        concurrency/coroutine.c concurrency/thread.c \
    190         concurrency/kernel.c concurrency/monitor.c assert.c \
    191         exception.c virtual.c concurrency/CtxSwitch-@MACHINE_TYPE@.S \
    192         concurrency/alarm.c concurrency/invoke.c \
    193         concurrency/preemption.c
     189        concurrency/kernel.c concurrency/monitor.c exception.c \
     190        concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/alarm.c \
     191        concurrency/invoke.c concurrency/preemption.c
    194192@BUILD_CONCURRENCY_TRUE@am__objects_5 = concurrency/libcfa_a-coroutine.$(OBJEXT) \
    195193@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-thread.$(OBJEXT) \
    196194@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-kernel.$(OBJEXT) \
    197195@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-monitor.$(OBJEXT)
    198 am__objects_6 = libcfa_a-fstream.$(OBJEXT) libcfa_a-iostream.$(OBJEXT) \
    199         libcfa_a-iterator.$(OBJEXT) libcfa_a-limits.$(OBJEXT) \
     196am__objects_6 = libcfa_a-assert.$(OBJEXT) libcfa_a-fstream.$(OBJEXT) \
     197        libcfa_a-iostream.$(OBJEXT) libcfa_a-iterator.$(OBJEXT) \
     198        libcfa_a-limits.$(OBJEXT) libcfa_a-math.$(OBJEXT) \
    200199        libcfa_a-rational.$(OBJEXT) libcfa_a-stdlib.$(OBJEXT) \
    201200        containers/libcfa_a-maybe.$(OBJEXT) \
     
    210209        libcfa_a-interpose.$(OBJEXT) \
    211210        libhdr/libcfa_a-libdebug.$(OBJEXT) $(am__objects_6) \
    212         libcfa_a-assert.$(OBJEXT) libcfa_a-exception.$(OBJEXT) \
    213         libcfa_a-virtual.$(OBJEXT) $(am__objects_7)
     211        libcfa_a-exception.$(OBJEXT) $(am__objects_7)
    214212am_libcfa_a_OBJECTS = $(am__objects_8)
    215213libcfa_a_OBJECTS = $(am_libcfa_a_OBJECTS)
     
    260258    *) (install-info --version) >/dev/null 2>&1;; \
    261259  esac
    262 am__nobase_cfa_include_HEADERS_DIST = fstream iostream iterator limits \
    263         rational stdlib containers/maybe containers/pair \
     260am__nobase_cfa_include_HEADERS_DIST = assert fstream iostream iterator \
     261        limits math rational stdlib containers/maybe containers/pair \
    264262        containers/result containers/vector concurrency/coroutine \
    265263        concurrency/thread concurrency/kernel concurrency/monitor \
    266         ${shell echo stdhdr/*} math gmp concurrency/invoke.h
     264        ${shell echo stdhdr/*} gmp concurrency/invoke.h
    267265HEADERS = $(nobase_cfa_include_HEADERS)
    268266am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
     
    308306CFA_NAME = @CFA_NAME@
    309307CFA_PREFIX = @CFA_PREFIX@
    310 
    311 #CFLAGS for most libcfa src
    312 #use -no-include-stdhdr to prevent rebuild cycles
    313 #The built sources must not depend on the installed headers
    314 CFLAGS = -quiet -no-include-stdhdr -I${abs_top_srcdir}/src/libcfa/stdhdr -XCFA -t -B${abs_top_srcdir}/src/driver ${EXTRA_FLAGS}
     308CFLAGS = -quiet -no-include-stdhdr -XCFA -t -B${abs_top_srcdir}/src/driver ${EXTRA_FLAGS}
    315309CPP = @CPP@
    316310CPPFLAGS = @CPPFLAGS@
     
    418412EXTRA_FLAGS = -g -Wall -Werror -Wno-unused-function -I${abs_top_srcdir}/src/libcfa/libhdr -imacros libcfa-prelude.c @CFA_FLAGS@
    419413AM_CCASFLAGS = @CFA_FLAGS@
    420 headers = fstream iostream iterator limits rational stdlib \
     414headers = assert fstream iostream iterator limits math rational stdlib \
    421415        containers/maybe containers/pair containers/result \
    422416        containers/vector $(am__append_3)
    423417libobjs = ${headers:=.o}
    424418libsrc = libcfa-prelude.c interpose.c libhdr/libdebug.c ${headers:=.c} \
    425         assert.c exception.c virtual.c $(am__append_4)
     419        exception.c $(am__append_4)
    426420libcfa_a_SOURCES = ${libsrc}
    427421libcfa_a_CFLAGS = -nodebug -O2
     
    430424stdhdr = ${shell echo stdhdr/*}
    431425cfa_includedir = $(CFA_INCDIR)
    432 nobase_cfa_include_HEADERS = ${headers} ${stdhdr} math gmp concurrency/invoke.h
     426nobase_cfa_include_HEADERS = ${headers} ${stdhdr} gmp concurrency/invoke.h
    433427CLEANFILES = libcfa-prelude.c
    434428all: all-am
     
    596590@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-libcfa-prelude.Po@am__quote@
    597591@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-limits.Po@am__quote@
     592@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-math.Po@am__quote@
    598593@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-rational.Po@am__quote@
    599594@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-stdlib.Po@am__quote@
    600 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-virtual.Po@am__quote@
    601595@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-assert.Po@am__quote@
    602596@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-exception.Po@am__quote@
     
    607601@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-libcfa-prelude.Po@am__quote@
    608602@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-limits.Po@am__quote@
     603@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-math.Po@am__quote@
    609604@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-rational.Po@am__quote@
    610605@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-stdlib.Po@am__quote@
    611 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-virtual.Po@am__quote@
    612606@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/CtxSwitch-@MACHINE_TYPE@.Po@am__quote@
    613607@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-alarm.Po@am__quote@
     
    703697@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libhdr/libcfa_d_a-libdebug.obj `if test -f 'libhdr/libdebug.c'; then $(CYGPATH_W) 'libhdr/libdebug.c'; else $(CYGPATH_W) '$(srcdir)/libhdr/libdebug.c'; fi`
    704698
     699libcfa_d_a-assert.o: assert.c
     700@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-assert.o -MD -MP -MF $(DEPDIR)/libcfa_d_a-assert.Tpo -c -o libcfa_d_a-assert.o `test -f 'assert.c' || echo '$(srcdir)/'`assert.c
     701@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-assert.Tpo $(DEPDIR)/libcfa_d_a-assert.Po
     702@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='assert.c' object='libcfa_d_a-assert.o' libtool=no @AMDEPBACKSLASH@
     703@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     704@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-assert.o `test -f 'assert.c' || echo '$(srcdir)/'`assert.c
     705
     706libcfa_d_a-assert.obj: assert.c
     707@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-assert.obj -MD -MP -MF $(DEPDIR)/libcfa_d_a-assert.Tpo -c -o libcfa_d_a-assert.obj `if test -f 'assert.c'; then $(CYGPATH_W) 'assert.c'; else $(CYGPATH_W) '$(srcdir)/assert.c'; fi`
     708@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-assert.Tpo $(DEPDIR)/libcfa_d_a-assert.Po
     709@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='assert.c' object='libcfa_d_a-assert.obj' libtool=no @AMDEPBACKSLASH@
     710@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     711@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-assert.obj `if test -f 'assert.c'; then $(CYGPATH_W) 'assert.c'; else $(CYGPATH_W) '$(srcdir)/assert.c'; fi`
     712
    705713libcfa_d_a-fstream.o: fstream.c
    706714@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-fstream.o -MD -MP -MF $(DEPDIR)/libcfa_d_a-fstream.Tpo -c -o libcfa_d_a-fstream.o `test -f 'fstream.c' || echo '$(srcdir)/'`fstream.c
     
    759767@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-limits.obj `if test -f 'limits.c'; then $(CYGPATH_W) 'limits.c'; else $(CYGPATH_W) '$(srcdir)/limits.c'; fi`
    760768
     769libcfa_d_a-math.o: math.c
     770@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-math.o -MD -MP -MF $(DEPDIR)/libcfa_d_a-math.Tpo -c -o libcfa_d_a-math.o `test -f 'math.c' || echo '$(srcdir)/'`math.c
     771@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-math.Tpo $(DEPDIR)/libcfa_d_a-math.Po
     772@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='math.c' object='libcfa_d_a-math.o' libtool=no @AMDEPBACKSLASH@
     773@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     774@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-math.o `test -f 'math.c' || echo '$(srcdir)/'`math.c
     775
     776libcfa_d_a-math.obj: math.c
     777@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-math.obj -MD -MP -MF $(DEPDIR)/libcfa_d_a-math.Tpo -c -o libcfa_d_a-math.obj `if test -f 'math.c'; then $(CYGPATH_W) 'math.c'; else $(CYGPATH_W) '$(srcdir)/math.c'; fi`
     778@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-math.Tpo $(DEPDIR)/libcfa_d_a-math.Po
     779@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='math.c' object='libcfa_d_a-math.obj' libtool=no @AMDEPBACKSLASH@
     780@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     781@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-math.obj `if test -f 'math.c'; then $(CYGPATH_W) 'math.c'; else $(CYGPATH_W) '$(srcdir)/math.c'; fi`
     782
    761783libcfa_d_a-rational.o: rational.c
    762784@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-rational.o -MD -MP -MF $(DEPDIR)/libcfa_d_a-rational.Tpo -c -o libcfa_d_a-rational.o `test -f 'rational.c' || echo '$(srcdir)/'`rational.c
     
    899921@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-monitor.obj `if test -f 'concurrency/monitor.c'; then $(CYGPATH_W) 'concurrency/monitor.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/monitor.c'; fi`
    900922
    901 libcfa_d_a-assert.o: assert.c
    902 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-assert.o -MD -MP -MF $(DEPDIR)/libcfa_d_a-assert.Tpo -c -o libcfa_d_a-assert.o `test -f 'assert.c' || echo '$(srcdir)/'`assert.c
    903 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-assert.Tpo $(DEPDIR)/libcfa_d_a-assert.Po
    904 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='assert.c' object='libcfa_d_a-assert.o' libtool=no @AMDEPBACKSLASH@
    905 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    906 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-assert.o `test -f 'assert.c' || echo '$(srcdir)/'`assert.c
    907 
    908 libcfa_d_a-assert.obj: assert.c
    909 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-assert.obj -MD -MP -MF $(DEPDIR)/libcfa_d_a-assert.Tpo -c -o libcfa_d_a-assert.obj `if test -f 'assert.c'; then $(CYGPATH_W) 'assert.c'; else $(CYGPATH_W) '$(srcdir)/assert.c'; fi`
    910 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-assert.Tpo $(DEPDIR)/libcfa_d_a-assert.Po
    911 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='assert.c' object='libcfa_d_a-assert.obj' libtool=no @AMDEPBACKSLASH@
    912 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    913 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-assert.obj `if test -f 'assert.c'; then $(CYGPATH_W) 'assert.c'; else $(CYGPATH_W) '$(srcdir)/assert.c'; fi`
    914 
    915923libcfa_d_a-exception.obj: exception.c
    916924@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-exception.obj -MD -MP -MF $(DEPDIR)/libcfa_d_a-exception.Tpo -c -o libcfa_d_a-exception.obj `if test -f 'exception.c'; then $(CYGPATH_W) 'exception.c'; else $(CYGPATH_W) '$(srcdir)/exception.c'; fi`
     
    920928@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-exception.obj `if test -f 'exception.c'; then $(CYGPATH_W) 'exception.c'; else $(CYGPATH_W) '$(srcdir)/exception.c'; fi`
    921929
    922 libcfa_d_a-virtual.obj: virtual.c
    923 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-virtual.obj -MD -MP -MF $(DEPDIR)/libcfa_d_a-virtual.Tpo -c -o libcfa_d_a-virtual.obj `if test -f 'virtual.c'; then $(CYGPATH_W) 'virtual.c'; else $(CYGPATH_W) '$(srcdir)/virtual.c'; fi`
    924 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-virtual.Tpo $(DEPDIR)/libcfa_d_a-virtual.Po
    925 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='virtual.c' object='libcfa_d_a-virtual.obj' libtool=no @AMDEPBACKSLASH@
    926 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    927 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-virtual.obj `if test -f 'virtual.c'; then $(CYGPATH_W) 'virtual.c'; else $(CYGPATH_W) '$(srcdir)/virtual.c'; fi`
    928 
    929930concurrency/libcfa_d_a-alarm.o: concurrency/alarm.c
    930931@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-alarm.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-alarm.Tpo -c -o concurrency/libcfa_d_a-alarm.o `test -f 'concurrency/alarm.c' || echo '$(srcdir)/'`concurrency/alarm.c
     
    997998@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libhdr/libcfa_a-libdebug.obj `if test -f 'libhdr/libdebug.c'; then $(CYGPATH_W) 'libhdr/libdebug.c'; else $(CYGPATH_W) '$(srcdir)/libhdr/libdebug.c'; fi`
    998999
     1000libcfa_a-assert.o: assert.c
     1001@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-assert.o -MD -MP -MF $(DEPDIR)/libcfa_a-assert.Tpo -c -o libcfa_a-assert.o `test -f 'assert.c' || echo '$(srcdir)/'`assert.c
     1002@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-assert.Tpo $(DEPDIR)/libcfa_a-assert.Po
     1003@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='assert.c' object='libcfa_a-assert.o' libtool=no @AMDEPBACKSLASH@
     1004@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1005@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-assert.o `test -f 'assert.c' || echo '$(srcdir)/'`assert.c
     1006
     1007libcfa_a-assert.obj: assert.c
     1008@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-assert.obj -MD -MP -MF $(DEPDIR)/libcfa_a-assert.Tpo -c -o libcfa_a-assert.obj `if test -f 'assert.c'; then $(CYGPATH_W) 'assert.c'; else $(CYGPATH_W) '$(srcdir)/assert.c'; fi`
     1009@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-assert.Tpo $(DEPDIR)/libcfa_a-assert.Po
     1010@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='assert.c' object='libcfa_a-assert.obj' libtool=no @AMDEPBACKSLASH@
     1011@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1012@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-assert.obj `if test -f 'assert.c'; then $(CYGPATH_W) 'assert.c'; else $(CYGPATH_W) '$(srcdir)/assert.c'; fi`
     1013
    9991014libcfa_a-fstream.o: fstream.c
    10001015@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-fstream.o -MD -MP -MF $(DEPDIR)/libcfa_a-fstream.Tpo -c -o libcfa_a-fstream.o `test -f 'fstream.c' || echo '$(srcdir)/'`fstream.c
     
    10531068@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-limits.obj `if test -f 'limits.c'; then $(CYGPATH_W) 'limits.c'; else $(CYGPATH_W) '$(srcdir)/limits.c'; fi`
    10541069
     1070libcfa_a-math.o: math.c
     1071@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-math.o -MD -MP -MF $(DEPDIR)/libcfa_a-math.Tpo -c -o libcfa_a-math.o `test -f 'math.c' || echo '$(srcdir)/'`math.c
     1072@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-math.Tpo $(DEPDIR)/libcfa_a-math.Po
     1073@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='math.c' object='libcfa_a-math.o' libtool=no @AMDEPBACKSLASH@
     1074@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1075@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-math.o `test -f 'math.c' || echo '$(srcdir)/'`math.c
     1076
     1077libcfa_a-math.obj: math.c
     1078@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-math.obj -MD -MP -MF $(DEPDIR)/libcfa_a-math.Tpo -c -o libcfa_a-math.obj `if test -f 'math.c'; then $(CYGPATH_W) 'math.c'; else $(CYGPATH_W) '$(srcdir)/math.c'; fi`
     1079@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-math.Tpo $(DEPDIR)/libcfa_a-math.Po
     1080@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='math.c' object='libcfa_a-math.obj' libtool=no @AMDEPBACKSLASH@
     1081@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1082@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-math.obj `if test -f 'math.c'; then $(CYGPATH_W) 'math.c'; else $(CYGPATH_W) '$(srcdir)/math.c'; fi`
     1083
    10551084libcfa_a-rational.o: rational.c
    10561085@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-rational.o -MD -MP -MF $(DEPDIR)/libcfa_a-rational.Tpo -c -o libcfa_a-rational.o `test -f 'rational.c' || echo '$(srcdir)/'`rational.c
     
    11931222@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-monitor.obj `if test -f 'concurrency/monitor.c'; then $(CYGPATH_W) 'concurrency/monitor.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/monitor.c'; fi`
    11941223
    1195 libcfa_a-assert.o: assert.c
    1196 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-assert.o -MD -MP -MF $(DEPDIR)/libcfa_a-assert.Tpo -c -o libcfa_a-assert.o `test -f 'assert.c' || echo '$(srcdir)/'`assert.c
    1197 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-assert.Tpo $(DEPDIR)/libcfa_a-assert.Po
    1198 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='assert.c' object='libcfa_a-assert.o' libtool=no @AMDEPBACKSLASH@
    1199 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    1200 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-assert.o `test -f 'assert.c' || echo '$(srcdir)/'`assert.c
    1201 
    1202 libcfa_a-assert.obj: assert.c
    1203 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-assert.obj -MD -MP -MF $(DEPDIR)/libcfa_a-assert.Tpo -c -o libcfa_a-assert.obj `if test -f 'assert.c'; then $(CYGPATH_W) 'assert.c'; else $(CYGPATH_W) '$(srcdir)/assert.c'; fi`
    1204 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-assert.Tpo $(DEPDIR)/libcfa_a-assert.Po
    1205 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='assert.c' object='libcfa_a-assert.obj' libtool=no @AMDEPBACKSLASH@
    1206 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    1207 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-assert.obj `if test -f 'assert.c'; then $(CYGPATH_W) 'assert.c'; else $(CYGPATH_W) '$(srcdir)/assert.c'; fi`
    1208 
    12091224libcfa_a-exception.obj: exception.c
    12101225@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-exception.obj -MD -MP -MF $(DEPDIR)/libcfa_a-exception.Tpo -c -o libcfa_a-exception.obj `if test -f 'exception.c'; then $(CYGPATH_W) 'exception.c'; else $(CYGPATH_W) '$(srcdir)/exception.c'; fi`
     
    12131228@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    12141229@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-exception.obj `if test -f 'exception.c'; then $(CYGPATH_W) 'exception.c'; else $(CYGPATH_W) '$(srcdir)/exception.c'; fi`
    1215 
    1216 libcfa_a-virtual.obj: virtual.c
    1217 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-virtual.obj -MD -MP -MF $(DEPDIR)/libcfa_a-virtual.Tpo -c -o libcfa_a-virtual.obj `if test -f 'virtual.c'; then $(CYGPATH_W) 'virtual.c'; else $(CYGPATH_W) '$(srcdir)/virtual.c'; fi`
    1218 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-virtual.Tpo $(DEPDIR)/libcfa_a-virtual.Po
    1219 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='virtual.c' object='libcfa_a-virtual.obj' libtool=no @AMDEPBACKSLASH@
    1220 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    1221 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-virtual.obj `if test -f 'virtual.c'; then $(CYGPATH_W) 'virtual.c'; else $(CYGPATH_W) '$(srcdir)/virtual.c'; fi`
    12221230
    12231231concurrency/libcfa_a-alarm.o: concurrency/alarm.c
     
    15131521        ${AM_V_CC}@BACKEND_CC@ -DHAVE_CONFIG_H -I. -I../.. -O2 ${EXTRA_FLAGS} -c -o $@ $<
    15141522
    1515 libcfa_a-virtual.o : virtual.c
    1516         ${AM_V_CC}@BACKEND_CC@ -DHAVE_CONFIG_H -I. -I../.. -O2 ${EXTRA_FLAGS} -c -o $@ $<
    1517 
    15181523concurrency/libcfa_d_a-invoke.o : concurrency/invoke.c
    15191524        ${AM_V_CC}@BACKEND_CC@ -DHAVE_CONFIG_H -I. -I../.. -D__CFA_DEBUG__ -O0 ${EXTRA_FLAGS} -c -o $@ $<
    15201525
    15211526libcfa_d_a-exception.o : exception.c
    1522         ${AM_V_CC}@BACKEND_CC@ -DHAVE_CONFIG_H -I. -I../.. -D__CFA_DEBUG__ -O0 ${EXTRA_FLAGS} -c -o $@ $<
    1523 
    1524 libcfa_d_a-virtual.o : virtual.c
    15251527        ${AM_V_CC}@BACKEND_CC@ -DHAVE_CONFIG_H -I. -I../.. -D__CFA_DEBUG__ -O0 ${EXTRA_FLAGS} -c -o $@ $<
    15261528
  • src/libcfa/assert.c

    r0720e049 r3d4b23fa  
    99// Author           : Thierry Delisle
    1010// Created On       : Mon Nov 28 12:27:26 2016
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 20 15:10:26 2017
    13 // Update Count     : 2
     11// Last Modified By : Thierry Delisle
     12// Last Modified On : Mon Nov 28 12:27:26 2016
     13// Update Count     : 0
    1414//
    1515
    16 #include <assert.h>
    17 #include <stdarg.h>                                                             // varargs
    18 #include <stdio.h>                                                              // fprintf
     16#include "assert"
     17#include "stdlib"                                                                               // abort
     18
    1919#include "libhdr/libdebug.h"
    2020
    2121extern "C" {
     22        #include <stdarg.h>                                                             // varargs
     23        #include <stdio.h>                                                              // fprintf
     24
    2225        extern const char * __progname;                                         // global name of running executable (argv[0])
    2326
     
    4447                abort();
    4548        }
     49
    4650}
    4751
  • src/libcfa/concurrency/CtxSwitch-i386.S

    r0720e049 r3d4b23fa  
     1//                               -*- Mode: Asm -*-
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    910// Author           : Thierry Delisle
    1011// Created On       : Tue Dec 6 12:27:26 2016
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:29:25 2017
    13 // Update Count     : 1
     12// Last Modified By : Thierry Delisle
     13// Last Modified On : Tue Dec 6 12:27:26 2016
     14// Update Count     : 0
    1415//
    1516// This  library is free  software; you  can redistribute  it and/or  modify it
     
    9899
    99100// Local Variables: //
    100 // mode: c //
    101 // tab-width: 4 //
     101// compile-command: "make install" //
    102102// End: //
  • src/libcfa/concurrency/CtxSwitch-x86_64.S

    r0720e049 r3d4b23fa  
     1//                               -*- Mode: Asm -*-
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    910// Author           : Thierry Delisle
    1011// Created On       : Mon Nov 28 12:27:26 2016
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:28:11 2017
    13 // Update Count     : 1
     12// Last Modified By : Thierry Delisle
     13// Last Modified On : Mon Nov 28 12:27:26 2016
     14// Update Count     : 0
    1415//
    1516// This  library is free  software; you  can redistribute  it and/or  modify it
  • src/libcfa/concurrency/alarm.c

    r0720e049 r3d4b23fa  
     1//                              -*- Mode: CFA -*-
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    910// Author           : Thierry Delisle
    1011// Created On       : Fri Jun 2 11:31:25 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:35:18 2017
    13 // Update Count     : 1
     12// Last Modified By : Thierry Delisle
     13// Last Modified On : --
     14// Update Count     : 0
    1415//
    1516
     
    3031
    3132//=============================================================================================
    32 // time type
    33 //=============================================================================================
    34 
    35 #define one_second         1_000_000_000ul
    36 #define one_milisecond         1_000_000ul
    37 #define one_microsecond            1_000ul
    38 #define one_nanosecond                 1ul
    39 
    40 __cfa_time_t zero_time = { 0 };
    41 
    42 void ?{}( __cfa_time_t * this ) { this->val = 0; }
    43 void ?{}( __cfa_time_t * this, zero_t zero ) { this->val = 0; }
    44 
    45 void ?{}( itimerval * this, __cfa_time_t * alarm ) {
    46         this->it_value.tv_sec = alarm->val / one_second;                        // seconds
    47         this->it_value.tv_usec = max( (alarm->val % one_second) / one_microsecond, 1000 ); // microseconds
    48         this->it_interval.tv_sec = 0;
    49         this->it_interval.tv_usec = 0;
    50 }
    51 
    52 
    53 void ?{}( __cfa_time_t * this, timespec * curr ) {
    54         uint64_t secs  = curr->tv_sec;
    55         uint64_t nsecs = curr->tv_nsec;
    56         this->val = (secs * one_second) + nsecs;
    57 }
    58 
    59 __cfa_time_t ?=?( __cfa_time_t * this, zero_t rhs ) {
    60         this->val = 0;
    61         return *this;
    62 }
    63 
    64 __cfa_time_t from_s ( uint64_t val ) { __cfa_time_t ret; ret.val = val * 1_000_000_000ul; return ret; }
    65 __cfa_time_t from_ms( uint64_t val ) { __cfa_time_t ret; ret.val = val *     1_000_000ul; return ret; }
    66 __cfa_time_t from_us( uint64_t val ) { __cfa_time_t ret; ret.val = val *         1_000ul; return ret; }
    67 __cfa_time_t from_ns( uint64_t val ) { __cfa_time_t ret; ret.val = val *             1ul; return ret; }
    68 
    69 //=============================================================================================
    7033// Clock logic
    7134//=============================================================================================
     
    7437        timespec curr;
    7538        clock_gettime( CLOCK_REALTIME, &curr );
    76         return (__cfa_time_t){ &curr };
     39        __cfa_time_t curr_time = ((__cfa_time_t)curr.tv_sec * TIMEGRAN) + curr.tv_nsec;
     40        // LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO, "Kernel : current time is %lu\n", curr_time );
     41        return curr_time;
    7742}
    7843
    7944void __kernel_set_timer( __cfa_time_t alarm ) {
    80         itimerval val = { &alarm };
     45        LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO, "Kernel : set timer to %lu\n", (__cfa_time_t)alarm );
     46        itimerval val;
     47        val.it_value.tv_sec = alarm / TIMEGRAN;                 // seconds
     48        val.it_value.tv_usec = (alarm % TIMEGRAN) / ( TIMEGRAN / 1_000_000L ); // microseconds
     49        val.it_interval.tv_sec = 0;
     50        val.it_interval.tv_usec = 0;
    8151        setitimer( ITIMER_REAL, &val, NULL );
    8252}
     
    8656//=============================================================================================
    8757
    88 void ?{}( alarm_node_t * this, thread_desc * thrd, __cfa_time_t alarm = zero_time, __cfa_time_t period = zero_time ) {
     58void ?{}( alarm_node_t * this, thread_desc * thrd, __cfa_time_t alarm = 0, __cfa_time_t period = 0 ) {
    8959        this->thrd = thrd;
    9060        this->alarm = alarm;
     
    9565}
    9666
    97 void ?{}( alarm_node_t * this, processor   * proc, __cfa_time_t alarm = zero_time, __cfa_time_t period = zero_time ) {
     67void ?{}( alarm_node_t * this, processor   * proc, __cfa_time_t alarm = 0, __cfa_time_t period = 0 ) {
    9868        this->proc = proc;
    9969        this->alarm = alarm;
     
    183153
    184154void register_self( alarm_node_t * this ) {
    185         alarm_list_t * alarms = &event_kernel->alarms;
     155        disable_interrupts();
     156        verify( !systemProcessor->pending_alarm );
     157        lock( &systemProcessor->alarm_lock DEBUG_CTX2 );
     158        {
     159                verify( validate( &systemProcessor->alarms ) );
     160                bool first = !systemProcessor->alarms.head;
    186161
    187         disable_interrupts();
    188         lock( &event_kernel->lock DEBUG_CTX2 );
    189         {
    190                 verify( validate( alarms ) );
    191                 bool first = !alarms->head;
    192 
    193                 insert( alarms, this );
     162                insert( &systemProcessor->alarms, this );
     163                if( systemProcessor->pending_alarm ) {
     164                        tick_preemption();
     165                }
    194166                if( first ) {
    195                         __kernel_set_timer( alarms->head->alarm - __kernel_get_time() );
     167                        __kernel_set_timer( systemProcessor->alarms.head->alarm - __kernel_get_time() );
    196168                }
    197169        }
    198         unlock( &event_kernel->lock );
     170        unlock( &systemProcessor->alarm_lock );
    199171        this->set = true;
    200172        enable_interrupts( DEBUG_CTX );
     
    202174
    203175void unregister_self( alarm_node_t * this ) {
     176        // LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO, "Kernel : unregister %p start\n", this );
    204177        disable_interrupts();
    205         lock( &event_kernel->lock DEBUG_CTX2 );
     178        lock( &systemProcessor->alarm_lock DEBUG_CTX2 );
    206179        {
    207                 verify( validate( &event_kernel->alarms ) );
    208                 remove( &event_kernel->alarms, this );
     180                verify( validate( &systemProcessor->alarms ) );
     181                remove( &systemProcessor->alarms, this );
    209182        }
    210         unlock( &event_kernel->lock );
     183        unlock( &systemProcessor->alarm_lock );
    211184        enable_interrupts( DEBUG_CTX );
    212185        this->set = false;
     186        // LIB_DEBUG_PRINT_BUFFER_LOCAL( STDERR_FILENO, "Kernel : unregister %p end\n", this );
    213187}
    214 
    215 // Local Variables: //
    216 // mode: c //
    217 // tab-width: 4 //
    218 // End: //
  • src/libcfa/concurrency/alarm.h

    r0720e049 r3d4b23fa  
     1//                              -*- Mode: CFA -*-
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    910// Author           : Thierry Delisle
    1011// Created On       : Fri Jun 2 11:31:25 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:59:27 2017
    13 // Update Count     : 3
     12// Last Modified By : Thierry Delisle
     13// Last Modified On : --
     14// Update Count     : 0
    1415//
    1516
    16 #pragma once
     17#ifndef ALARM_H
     18#define ALARM_H
    1719
    1820#include <stdbool.h>
    19 #include <stdint.h>
    2021
    21 #include <assert.h>
     22#include "assert"
     23
     24typedef unsigned long int __cfa_time_t;
    2225
    2326struct thread_desc;
    2427struct processor;
    2528
    26 struct timespec;
    27 struct itimerval;
    28 
    29 //=============================================================================================
    30 // time type
    31 //=============================================================================================
    32 
    33 struct __cfa_time_t {
    34         uint64_t val;
    35 };
    36 
    37 // ctors
    38 void ?{}( __cfa_time_t * this );
    39 void ?{}( __cfa_time_t * this, zero_t zero );
    40 void ?{}( __cfa_time_t * this, timespec * curr );
    41 void ?{}( itimerval * this, __cfa_time_t * alarm );
    42 
    43 __cfa_time_t ?=?( __cfa_time_t * this, zero_t rhs );
    44 
    45 // logical ops
    46 static inline bool ?==?( __cfa_time_t lhs, __cfa_time_t rhs ) { return lhs.val == rhs.val; }
    47 static inline bool ?!=?( __cfa_time_t lhs, __cfa_time_t rhs ) { return lhs.val != rhs.val; }
    48 static inline bool ?>? ( __cfa_time_t lhs, __cfa_time_t rhs ) { return lhs.val >  rhs.val; }
    49 static inline bool ?<? ( __cfa_time_t lhs, __cfa_time_t rhs ) { return lhs.val <  rhs.val; }
    50 static inline bool ?>=?( __cfa_time_t lhs, __cfa_time_t rhs ) { return lhs.val >= rhs.val; }
    51 static inline bool ?<=?( __cfa_time_t lhs, __cfa_time_t rhs ) { return lhs.val <= rhs.val; }
    52 
    53 static inline bool ?==?( __cfa_time_t lhs, zero_t rhs ) { return lhs.val == rhs; }
    54 static inline bool ?!=?( __cfa_time_t lhs, zero_t rhs ) { return lhs.val != rhs; }
    55 static inline bool ?>? ( __cfa_time_t lhs, zero_t rhs ) { return lhs.val >  rhs; }
    56 static inline bool ?<? ( __cfa_time_t lhs, zero_t rhs ) { return lhs.val <  rhs; }
    57 static inline bool ?>=?( __cfa_time_t lhs, zero_t rhs ) { return lhs.val >= rhs; }
    58 static inline bool ?<=?( __cfa_time_t lhs, zero_t rhs ) { return lhs.val <= rhs; }
    59 
    60 // addition/substract
    61 static inline __cfa_time_t ?+?( __cfa_time_t lhs, __cfa_time_t rhs ) {
    62         __cfa_time_t ret;
    63         ret.val = lhs.val + rhs.val;
    64         return ret;
    65 }
    66 
    67 static inline __cfa_time_t ?-?( __cfa_time_t lhs, __cfa_time_t rhs ) {
    68         __cfa_time_t ret;
    69         ret.val = lhs.val - rhs.val;
    70         return ret;
    71 }
    72 
    73 __cfa_time_t from_s ( uint64_t );
    74 __cfa_time_t from_ms( uint64_t );
    75 __cfa_time_t from_us( uint64_t );
    76 __cfa_time_t from_ns( uint64_t );
    77 
    78 extern __cfa_time_t zero_time;
    79 
    8029//=============================================================================================
    8130// Clock logic
    8231//=============================================================================================
     32
     33#define TIMEGRAN 1_000_000_000L                         // nanosecond granularity, except for timeval
    8334
    8435__cfa_time_t __kernel_get_time();
     
    10556typedef alarm_node_t ** __alarm_it_t;
    10657
    107 void ?{}( alarm_node_t * this, thread_desc * thrd, __cfa_time_t alarm = zero_time, __cfa_time_t period = zero_time );
    108 void ?{}( alarm_node_t * this, processor   * proc, __cfa_time_t alarm = zero_time, __cfa_time_t period = zero_time );
     58void ?{}( alarm_node_t * this, thread_desc * thrd, __cfa_time_t alarm = 0, __cfa_time_t period = 0 );
     59void ?{}( alarm_node_t * this, processor   * proc, __cfa_time_t alarm = 0, __cfa_time_t period = 0 );
    10960void ^?{}( alarm_node_t * this );
    11061
     
    12576void unregister_self( alarm_node_t * this );
    12677
     78#endif
     79
    12780// Local Variables: //
    128 // mode: c //
     81// mode: CFA //
    12982// tab-width: 6 //
    13083// End: //
  • src/libcfa/concurrency/coroutine

    r0720e049 r3d4b23fa  
    1010// Author           : Thierry Delisle
    1111// Created On       : Mon Nov 28 12:27:26 2016
    12 // Last Modified By : Peter A. Buhr
    13 // Last Modified On : Sat Jul 22 09:57:17 2017
    14 // Update Count     : 2
     12// Last Modified By : Thierry Delisle
     13// Last Modified On : Mon Nov 28 12:27:26 2016
     14// Update Count     : 0
    1515//
    1616
    17 #pragma once
     17#ifndef COROUTINES_H
     18#define COROUTINES_H
    1819
    19 #include <assert.h>
     20#include "assert"
    2021#include "invoke.h"
    2122
     
    6263
    6364// Get current coroutine
    64 extern thread_local coroutine_desc * volatile this_coroutine;
     65extern volatile thread_local coroutine_desc * this_coroutine;
    6566
    6667// Private wrappers for context switch and stack creation
     
    128129}
    129130
     131#endif //COROUTINES_H
     132
    130133// Local Variables: //
    131134// mode: c //
  • src/libcfa/concurrency/coroutine.c

    r0720e049 r3d4b23fa  
     1//                              -*- Mode: CFA -*-
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    910// Author           : Thierry Delisle
    1011// Created On       : Mon Nov 28 12:27:26 2016
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:34:57 2017
    13 // Update Count     : 1
     12// Last Modified By : Thierry Delisle
     13// Last Modified On : Mon Nov 28 12:27:26 2016
     14// Update Count     : 0
    1415//
    1516
     
    2526}
    2627
    27 #include "kernel_private.h"
     28#include "kernel"
     29#include "libhdr.h"
    2830
    2931#define __CFA_INVOKE_PRIVATE__
    3032#include "invoke.h"
    3133
     34extern volatile thread_local processor * this_processor;
    3235
    3336//-----------------------------------------------------------------------------
  • src/libcfa/concurrency/invoke.c

    r0720e049 r3d4b23fa  
     1//                              -*- Mode: C -*-
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    910// Author           : Thierry Delisle
    1011// Created On       : Tue Jan 17 12:27:26 2016
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:28:33 2017
    13 // Update Count     : 1
     12// Last Modified By : Thierry Delisle
     13// Last Modified On : --
     14// Update Count     : 0
    1415//
    1516
     
    141142#endif
    142143}
    143 
    144 // Local Variables: //
    145 // mode: c //
    146 // tab-width: 4 //
    147 // End: //
  • src/libcfa/concurrency/invoke.h

    r0720e049 r3d4b23fa  
     1//                              -*- Mode: C -*-
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    910// Author           : Thierry Delisle
    1011// Created On       : Tue Jan 17 12:27:26 2016
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:28:56 2017
    13 // Update Count     : 1
     12// Last Modified By : Thierry Delisle
     13// Last Modified On : --
     14// Update Count     : 0
    1415//
    1516
     
    129130}
    130131#endif
    131 
    132 // Local Variables: //
    133 // mode: c //
    134 // tab-width: 4 //
    135 // End: //
  • src/libcfa/concurrency/kernel

    r0720e049 r3d4b23fa  
     1//                              -*- Mode: CFA -*-
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    910// Author           : Thierry Delisle
    1011// Created On       : Tue Jan 17 12:27:26 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:58:39 2017
    13 // Update Count     : 2
     12// Last Modified By : Thierry Delisle
     13// Last Modified On : --
     14// Update Count     : 0
    1415//
    1516
    16 #pragma once
     17#ifndef KERNEL_H
     18#define KERNEL_H
    1719
    1820#include <stdbool.h>
     
    2628//-----------------------------------------------------------------------------
    2729// Locks
    28 void lock      ( spinlock * DEBUG_CTX_PARAM2 );       // Lock the spinlock, spin if already acquired
    29 void lock_yield( spinlock * DEBUG_CTX_PARAM2 );       // Lock the spinlock, yield repeatedly if already acquired
    30 bool try_lock  ( spinlock * DEBUG_CTX_PARAM2 );       // Lock the spinlock, return false if already acquired
    31 void unlock    ( spinlock * );                        // Unlock the spinlock
     30bool try_lock  ( spinlock * DEBUG_CTX_PARAM2 );
     31void lock      ( spinlock * DEBUG_CTX_PARAM2 );
     32void lock_yield( spinlock * DEBUG_CTX_PARAM2 );
     33void unlock    ( spinlock * );
    3234
    3335struct semaphore {
     
    4648// Cluster
    4749struct cluster {
    48         spinlock ready_queue_lock;                      // Ready queue locks
    49         __thread_queue_t ready_queue;                   // Ready queue for threads
    50         unsigned long long int preemption;              // Preemption rate on this cluster
     50        __thread_queue_t ready_queue;
     51        spinlock lock;
    5152};
    5253
     
    7576static inline void ^?{}(FinishAction * this) {}
    7677
    77 // Processor
    78 // Wrapper around kernel threads
    7978struct processor {
    80         // Main state
    81         struct processorCtx_t * runner;                 // Coroutine ctx who does keeps the state of the processor
    82         cluster * cltr;                                 // Cluster from which to get threads
    83         pthread_t kernel_thread;                        // Handle to pthreads
     79        struct processorCtx_t * runner;
     80        cluster * cltr;
     81        pthread_t kernel_thread;
    8482
    85         // Termination
    86         volatile bool do_terminate;                     // Set to true to notify the processor should terminate
    87         semaphore terminated;                           // Termination synchronisation
     83        semaphore terminated;
     84        volatile bool is_terminated;
    8885
    89         // RunThread data
    90         struct FinishAction finish;                     // Action to do after a thread is ran
     86        struct FinishAction finish;
    9187
    92         // Preemption data
    93         struct alarm_node_t * preemption_alarm;         // Node which is added in the discrete event simulaiton
    94         bool pending_preemption;                        // If true, a preemption was triggered in an unsafe region, the processor must preempt as soon as possible
     88        struct alarm_node_t * preemption_alarm;
     89        unsigned int preemption;
    9590
    96 #ifdef __CFA_DEBUG__
    97         char * last_enable;                             // Last function to enable preemption on this processor
    98 #endif
     91        bool pending_preemption;
     92
     93        char * last_enable;
    9994};
    10095
     
    10398void ^?{}(processor * this);
    10499
     100#endif //KERNEL_H
     101
    105102// Local Variables: //
    106 // mode: c //
    107 // tab-width: 4 //
     103// mode: CFA //
     104// tab-width: 6 //
    108105// End: //
  • src/libcfa/concurrency/kernel.c

    r0720e049 r3d4b23fa  
     1//                              -*- Mode: CFA -*-
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    910// Author           : Thierry Delisle
    1011// Created On       : Tue Jan 17 12:27:26 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:33:18 2017
    13 // Update Count     : 2
     12// Last Modified By : Thierry Delisle
     13// Last Modified On : --
     14// Update Count     : 0
    1415//
    1516
     
    4142//-----------------------------------------------------------------------------
    4243// Kernel storage
    43 KERNEL_STORAGE(cluster,           mainCluster);
    44 KERNEL_STORAGE(processor,         mainProcessor);
    45 KERNEL_STORAGE(processorCtx_t,    mainProcessorCtx);
    46 KERNEL_STORAGE(thread_desc,       mainThread);
     44#define KERNEL_STORAGE(T,X) static char X##Storage[sizeof(T)]
     45
     46KERNEL_STORAGE(processorCtx_t, systemProcessorCtx);
     47KERNEL_STORAGE(cluster, systemCluster);
     48KERNEL_STORAGE(system_proc_t, systemProcessor);
     49KERNEL_STORAGE(thread_desc, mainThread);
    4750KERNEL_STORAGE(machine_context_t, mainThreadCtx);
    4851
    49 cluster *     mainCluster;
    50 processor *   mainProcessor;
     52cluster * systemCluster;
     53system_proc_t * systemProcessor;
    5154thread_desc * mainThread;
    5255
     
    5457// Global state
    5558
    56 thread_local coroutine_desc * volatile this_coroutine;
    57 thread_local thread_desc *    volatile this_thread;
    58 thread_local processor *      volatile this_processor;
    59 
     59volatile thread_local processor * this_processor;
     60volatile thread_local coroutine_desc * this_coroutine;
     61volatile thread_local thread_desc * this_thread;
    6062volatile thread_local bool preemption_in_progress = 0;
    6163volatile thread_local unsigned short disable_preempt_count = 1;
     
    8385
    8486        this->limit = (void *)(((intptr_t)this->base) - this->size);
    85         this->context = &storage_mainThreadCtx;
     87        this->context = &mainThreadCtxStorage;
    8688        this->top = this->base;
    8789}
     
    123125
    124126void ?{}(processor * this) {
    125         this{ mainCluster };
     127        this{ systemCluster };
    126128}
    127129
     
    129131        this->cltr = cltr;
    130132        (&this->terminated){ 0 };
    131         this->do_terminate = false;
     133        this->is_terminated = false;
    132134        this->preemption_alarm = NULL;
     135        this->preemption = default_preemption();
    133136        this->pending_preemption = false;
    134137
     
    139142        this->cltr = cltr;
    140143        (&this->terminated){ 0 };
    141         this->do_terminate = false;
     144        this->is_terminated = false;
    142145        this->preemption_alarm = NULL;
     146        this->preemption = default_preemption();
    143147        this->pending_preemption = false;
    144148        this->kernel_thread = pthread_self();
    145149
    146150        this->runner = runner;
    147         LIB_DEBUG_PRINT_SAFE("Kernel : constructing main processor context %p\n", runner);
     151        LIB_DEBUG_PRINT_SAFE("Kernel : constructing system processor context %p\n", runner);
    148152        runner{ this };
    149153}
    150154
     155LIB_DEBUG_DO( bool validate( alarm_list_t * this ); )
     156
     157void ?{}(system_proc_t * this, cluster * cltr, processorCtx_t * runner) {
     158        (&this->alarms){};
     159        (&this->alarm_lock){};
     160        this->pending_alarm = false;
     161
     162        (&this->proc){ cltr, runner };
     163
     164        verify( validate( &this->alarms ) );
     165}
     166
    151167void ^?{}(processor * this) {
    152         if( ! this->do_terminate ) {
     168        if( ! this->is_terminated ) {
    153169                LIB_DEBUG_PRINT_SAFE("Kernel : core %p signaling termination\n", this);
    154                 this->do_terminate = true;
     170                this->is_terminated = true;
    155171                P( &this->terminated );
    156172                pthread_join( this->kernel_thread, NULL );
     
    160176void ?{}(cluster * this) {
    161177        ( &this->ready_queue ){};
    162         ( &this->ready_queue_lock ){};
    163 
    164         this->preemption = default_preemption();
     178        ( &this->lock ){};
    165179}
    166180
     
    185199
    186200                thread_desc * readyThread = NULL;
    187                 for( unsigned int spin_count = 0; ! this->do_terminate; spin_count++ )
     201                for( unsigned int spin_count = 0; ! this->is_terminated; spin_count++ )
    188202                {
    189203                        readyThread = nextThread( this->cltr );
     
    329343        verifyf( thrd->next == NULL, "Expected null got %p", thrd->next );
    330344
    331         lock(   &this_processor->cltr->ready_queue_lock DEBUG_CTX2 );
    332         append( &this_processor->cltr->ready_queue, thrd );
    333         unlock( &this_processor->cltr->ready_queue_lock );
     345        lock( &systemProcessor->proc.cltr->lock DEBUG_CTX2 );
     346        append( &systemProcessor->proc.cltr->ready_queue, thrd );
     347        unlock( &systemProcessor->proc.cltr->lock );
    334348
    335349        verify( disable_preempt_count > 0 );
     
    338352thread_desc * nextThread(cluster * this) {
    339353        verify( disable_preempt_count > 0 );
    340         lock( &this->ready_queue_lock DEBUG_CTX2 );
     354        lock( &this->lock DEBUG_CTX2 );
    341355        thread_desc * head = pop_head( &this->ready_queue );
    342         unlock( &this->ready_queue_lock );
     356        unlock( &this->lock );
    343357        verify( disable_preempt_count > 0 );
    344358        return head;
     
    438452        // Start by initializing the main thread
    439453        // SKULLDUGGERY: the mainThread steals the process main thread
    440         // which will then be scheduled by the mainProcessor normally
    441         mainThread = (thread_desc *)&storage_mainThread;
     454        // which will then be scheduled by the systemProcessor normally
     455        mainThread = (thread_desc *)&mainThreadStorage;
    442456        current_stack_info_t info;
    443457        mainThread{ &info };
     
    445459        LIB_DEBUG_PRINT_SAFE("Kernel : Main thread ready\n");
    446460
    447         // Initialize the main cluster
    448         mainCluster = (cluster *)&storage_mainCluster;
    449         mainCluster{};
    450 
    451         LIB_DEBUG_PRINT_SAFE("Kernel : main cluster ready\n");
    452 
    453         // Initialize the main processor and the main processor ctx
     461        // Initialize the system cluster
     462        systemCluster = (cluster *)&systemClusterStorage;
     463        systemCluster{};
     464
     465        LIB_DEBUG_PRINT_SAFE("Kernel : System cluster ready\n");
     466
     467        // Initialize the system processor and the system processor ctx
    454468        // (the coroutine that contains the processing control flow)
    455         mainProcessor = (processor *)&storage_mainProcessor;
    456         mainProcessor{ mainCluster, (processorCtx_t *)&storage_mainProcessorCtx };
     469        systemProcessor = (system_proc_t *)&systemProcessorStorage;
     470        systemProcessor{ systemCluster, (processorCtx_t *)&systemProcessorCtxStorage };
     471
     472        // Add the main thread to the ready queue
     473        // once resume is called on systemProcessor->runner the mainThread needs to be scheduled like any normal thread
     474        ScheduleThread(mainThread);
    457475
    458476        //initialize the global state variables
    459         this_processor = mainProcessor;
     477        this_processor = &systemProcessor->proc;
    460478        this_thread = mainThread;
    461479        this_coroutine = &mainThread->cor;
     480        disable_preempt_count = 1;
    462481
    463482        // Enable preemption
    464483        kernel_start_preemption();
    465484
    466         // Add the main thread to the ready queue
    467         // once resume is called on mainProcessor->runner the mainThread needs to be scheduled like any normal thread
    468         ScheduleThread(mainThread);
    469 
    470         // SKULLDUGGERY: Force a context switch to the main processor to set the main thread's context to the current UNIX
     485        // SKULLDUGGERY: Force a context switch to the system processor to set the main thread's context to the current UNIX
    471486        // context. Hence, the main thread does not begin through CtxInvokeThread, like all other threads. The trick here is that
    472487        // mainThread is on the ready queue when this call is made.
    473         resume( mainProcessor->runner );
     488        resume( systemProcessor->proc.runner );
    474489
    475490
     
    486501        disable_interrupts();
    487502
    488         // SKULLDUGGERY: Notify the mainProcessor it needs to terminates.
     503        // SKULLDUGGERY: Notify the systemProcessor it needs to terminates.
    489504        // When its coroutine terminates, it return control to the mainThread
    490505        // which is currently here
    491         mainProcessor->do_terminate = true;
     506        systemProcessor->proc.is_terminated = true;
    492507        suspend();
    493508
     
    497512        kernel_stop_preemption();
    498513
    499         // Destroy the main processor and its context in reverse order of construction
     514        // Destroy the system processor and its context in reverse order of construction
    500515        // These were manually constructed so we need manually destroy them
    501         ^(mainProcessor->runner){};
    502         ^(mainProcessor){};
     516        ^(systemProcessor->proc.runner){};
     517        ^(systemProcessor){};
    503518
    504519        // Final step, destroy the main thread since it is no longer needed
     
    684699        return top;
    685700}
    686 
    687701// Local Variables: //
    688702// mode: c //
  • src/libcfa/concurrency/kernel_private.h

    r0720e049 r3d4b23fa  
     1//                              -*- Mode: CFA -*-
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    910// Author           : Thierry Delisle
    1011// Created On       : Mon Feb 13 12:27:26 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:58:09 2017
    13 // Update Count     : 2
     12// Last Modified By : Thierry Delisle
     13// Last Modified On : --
     14// Update Count     : 0
    1415//
    1516
    16 #pragma once
     17#ifndef KERNEL_PRIVATE_H
     18#define KERNEL_PRIVATE_H
    1719
    1820#include "libhdr.h"
     
    2931extern "C" {
    3032        void disable_interrupts();
    31         void enable_interrupts_noPoll();
     33        void enable_interrupts_noRF();
    3234        void enable_interrupts( DEBUG_CTX_PARAM );
    3335}
     
    4345thread_desc * nextThread(cluster * this);
    4446
    45 //Block current thread and release/wake-up the following resources
    4647void BlockInternal(void);
    4748void BlockInternal(spinlock * lock);
     
    6465void spin(processor * this, unsigned int * spin_count);
    6566
    66 struct event_kernel_t {
     67struct system_proc_t {
     68        processor proc;
     69
    6770        alarm_list_t alarms;
    68         spinlock lock;
     71        spinlock alarm_lock;
     72
     73        bool pending_alarm;
    6974};
    7075
    71 extern event_kernel_t * event_kernel;
    72 
    73 extern thread_local coroutine_desc * volatile this_coroutine;
    74 extern thread_local thread_desc *    volatile this_thread;
    75 extern thread_local processor *      volatile this_processor;
    76 
     76extern cluster * systemCluster;
     77extern system_proc_t * systemProcessor;
     78extern volatile thread_local processor * this_processor;
     79extern volatile thread_local coroutine_desc * this_coroutine;
     80extern volatile thread_local thread_desc * this_thread;
    7781extern volatile thread_local bool preemption_in_progress;
    7882extern volatile thread_local unsigned short disable_preempt_count;
     
    8791extern void ThreadCtxSwitch(coroutine_desc * src, coroutine_desc * dst);
    8892
    89 //-----------------------------------------------------------------------------
    90 // Utils
    91 #define KERNEL_STORAGE(T,X) static char storage_##X[sizeof(T)]
     93#endif //KERNEL_PRIVATE_H
    9294
    9395// Local Variables: //
  • src/libcfa/concurrency/monitor

    r0720e049 r3d4b23fa  
     1//                              -*- Mode: CFA -*-
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    910// Author           : Thierry Delisle
    1011// Created On       : Thd Feb 23 12:27:26 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:59:01 2017
    13 // Update Count     : 3
     12// Last Modified By : Thierry Delisle
     13// Last Modified On : --
     14// Update Count     : 0
    1415//
    1516
    16 #pragma once
     17#ifndef MONITOR_H
     18#define MONITOR_H
    1719
    1820#include <stddef.h>
    1921
    20 #include <assert.h>
     22#include "assert"
    2123#include "invoke.h"
    2224#include "stdlib"
     
    9799void __accept_internal( unsigned short count, __acceptable_t * acceptables, void (*func)(void) );
    98100
    99 // Local Variables: //
    100 // mode: c //
    101 // tab-width: 4 //
    102 // End: //
     101#endif //MONITOR_H
  • src/libcfa/concurrency/monitor.c

    r0720e049 r3d4b23fa  
     1//                              -*- Mode: CFA -*-
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    910// Author           : Thierry Delisle
    1011// Created On       : Thd Feb 23 12:27:26 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jul 31 14:59:05 2017
    13 // Update Count     : 3
     12// Last Modified By : Thierry Delisle
     13// Last Modified On : --
     14// Update Count     : 0
    1415//
    1516
     
    484485        if( !this->monitors ) {
    485486                // LIB_DEBUG_PRINT_SAFE("Branding\n");
    486                 assertf( thrd->current_monitors != NULL, "No current monitor to brand condition %p", thrd->current_monitors );
     487                assertf( thrd->current_monitors != NULL, "No current monitor to brand condition", thrd->current_monitors );
    487488                this->monitor_count = thrd->current_monitor_count;
    488489
     
    527528        return head;
    528529}
    529 
    530 // Local Variables: //
    531 // mode: c //
    532 // tab-width: 4 //
    533 // End: //
  • src/libcfa/concurrency/preemption.c

    r0720e049 r3d4b23fa  
     1//                              -*- Mode: CFA -*-
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    910// Author           : Thierry Delisle
    1011// Created On       : Mon Jun 5 14:20:42 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:36:05 2017
    13 // Update Count     : 2
     12// Last Modified By : Thierry Delisle
     13// Last Modified On : --
     14// Update Count     : 0
    1415//
    1516
     
    3334#endif
    3435
    35 //TODO move to defaults
    3636#define __CFA_DEFAULT_PREEMPTION__ 10000
    3737
    38 //TODO move to defaults
    3938__attribute__((weak)) unsigned int default_preemption() {
    4039        return __CFA_DEFAULT_PREEMPTION__;
    4140}
    4241
    43 // Short hands for signal context information
    4442#define __CFA_SIGCXT__ ucontext_t *
    4543#define __CFA_SIGPARMS__ __attribute__((unused)) int sig, __attribute__((unused)) siginfo_t *sfp, __attribute__((unused)) __CFA_SIGCXT__ cxt
    4644
    47 // FwdDeclarations : timeout handlers
    4845static void preempt( processor   * this );
    4946static void timeout( thread_desc * this );
    5047
    51 // FwdDeclarations : Signal handlers
    5248void sigHandler_ctxSwitch( __CFA_SIGPARMS__ );
     49void sigHandler_alarm    ( __CFA_SIGPARMS__ );
    5350void sigHandler_segv     ( __CFA_SIGPARMS__ );
    5451void sigHandler_abort    ( __CFA_SIGPARMS__ );
    5552
    56 // FwdDeclarations : sigaction wrapper
    5753static void __kernel_sigaction( int sig, void (*handler)(__CFA_SIGPARMS__), int flags );
    58 
    59 // FwdDeclarations : alarm thread main
    60 void * alarm_loop( __attribute__((unused)) void * args );
    61 
    62 // Machine specific register name
     54LIB_DEBUG_DO( bool validate( alarm_list_t * this ); )
     55
    6356#ifdef __x86_64__
    6457#define CFA_REG_IP REG_RIP
     
    6760#endif
    6861
    69 KERNEL_STORAGE(event_kernel_t, event_kernel);         // private storage for event kernel
    70 event_kernel_t * event_kernel;                        // kernel public handle to even kernel
    71 static pthread_t alarm_thread;                        // pthread handle to alarm thread
    72 
    73 void ?{}(event_kernel_t * this) {
    74         (&this->alarms){};
    75         (&this->lock){};
    76 }
    7762
    7863//=============================================================================================
     
    8065//=============================================================================================
    8166
    82 // Get next expired node
    83 static inline alarm_node_t * get_expired( alarm_list_t * alarms, __cfa_time_t currtime ) {
    84         if( !alarms->head ) return NULL;                          // If no alarms return null
    85         if( alarms->head->alarm >= currtime ) return NULL;        // If alarms head not expired return null
    86         return pop(alarms);                                       // Otherwise just pop head
    87 }
    88 
    89 // Tick one frame of the Discrete Event Simulation for alarms
    9067void tick_preemption() {
    91         alarm_node_t * node = NULL;                     // Used in the while loop but cannot be declared in the while condition
    92         alarm_list_t * alarms = &event_kernel->alarms;  // Local copy for ease of reading
    93         __cfa_time_t currtime = __kernel_get_time();    // Check current time once so we everything "happens at once"
    94 
    95         //Loop throught every thing expired
    96         while( node = get_expired( alarms, currtime ) ) {
    97 
    98                 // Check if this is a kernel
     68        // LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO, "Ticking preemption\n" );
     69
     70        alarm_list_t * alarms = &systemProcessor->alarms;
     71        __cfa_time_t currtime = __kernel_get_time();
     72        while( alarms->head && alarms->head->alarm < currtime ) {
     73                alarm_node_t * node = pop(alarms);
     74                // LIB_DEBUG_PRINT_BUFFER_LOCAL( STDERR_FILENO, "Ticking %p\n", node );
     75
    9976                if( node->kernel_alarm ) {
    10077                        preempt( node->proc );
     
    10481                }
    10582
    106                 // Check if this is a periodic alarm
    107                 __cfa_time_t period = node->period;
    108                 if( period > 0 ) {
    109                         node->alarm = currtime + period;    // Alarm is periodic, add currtime to it (used cached current time)
    110                         insert( alarms, node );             // Reinsert the node for the next time it triggers
     83                verify( validate( alarms ) );
     84
     85                if( node->period > 0 ) {
     86                        node->alarm = currtime + node->period;
     87                        insert( alarms, node );
    11188                }
    11289                else {
    113                         node->set = false;                  // Node is one-shot, just mark it as not pending
    114                 }
    115         }
    116 
    117         // If there are still alarms pending, reset the timer
    118         if( alarms->head ) { __kernel_set_timer( alarms->head->alarm - currtime ); }
    119 }
    120 
    121 // Update the preemption of a processor and notify interested parties
     90                        node->set = false;
     91                }
     92        }
     93
     94        if( alarms->head ) {
     95                __kernel_set_timer( alarms->head->alarm - currtime );
     96        }
     97
     98        verify( validate( alarms ) );
     99        // LIB_DEBUG_PRINT_BUFFER_LOCAL( STDERR_FILENO, "Ticking preemption done\n" );
     100}
     101
    122102void update_preemption( processor * this, __cfa_time_t duration ) {
     103        LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO, "Processor : %p updating preemption to %lu\n", this, duration );
     104
    123105        alarm_node_t * alarm = this->preemption_alarm;
     106        duration *= 1000;
    124107
    125108        // Alarms need to be enabled
     
    151134
    152135extern "C" {
    153         // Disable interrupts by incrementing the counter
    154136        void disable_interrupts() {
    155137                __attribute__((unused)) unsigned short new_val = __atomic_add_fetch_2( &disable_preempt_count, 1, __ATOMIC_SEQ_CST );
    156                 verify( new_val < 65_000u );              // If this triggers someone is disabling interrupts without enabling them
    157         }
    158 
    159         // Enable interrupts by decrementing the counter
    160         // If counter reaches 0, execute any pending CtxSwitch
     138                verify( new_val < (unsigned short)65_000 );
     139                verify( new_val != (unsigned short) 0 );
     140        }
     141
     142        void enable_interrupts_noRF() {
     143                __attribute__((unused)) unsigned short prev = __atomic_fetch_add_2( &disable_preempt_count, -1, __ATOMIC_SEQ_CST );
     144                verify( prev != (unsigned short) 0 );
     145        }
     146
    161147        void enable_interrupts( DEBUG_CTX_PARAM ) {
    162                 processor * proc   = this_processor;      // Cache the processor now since interrupts can start happening after the atomic add
    163                 thread_desc * thrd = this_thread;         // Cache the thread now since interrupts can start happening after the atomic add
    164 
     148                processor * proc   = this_processor;
     149                thread_desc * thrd = this_thread;
    165150                unsigned short prev = __atomic_fetch_add_2( &disable_preempt_count, -1, __ATOMIC_SEQ_CST );
    166                 verify( prev != 0u );                     // If this triggers someone is enabled already enabled interruptsverify( prev != 0u );
    167 
    168                 // Check if we need to prempt the thread because an interrupt was missed
     151                verify( prev != (unsigned short) 0 );
    169152                if( prev == 1 && proc->pending_preemption ) {
    170153                        proc->pending_preemption = false;
     
    172155                }
    173156
    174                 // For debugging purposes : keep track of the last person to enable the interrupts
    175157                LIB_DEBUG_DO( proc->last_enable = caller; )
    176158        }
    177 
    178         // Disable interrupts by incrementint the counter
    179         // Don't execute any pending CtxSwitch even if counter reaches 0
    180         void enable_interrupts_noPoll() {
    181                 __attribute__((unused)) unsigned short prev = __atomic_fetch_add_2( &disable_preempt_count, -1, __ATOMIC_SEQ_CST );
    182                 verify( prev != 0u );                     // If this triggers someone is enabled already enabled interrupts
    183         }
    184 }
    185 
    186 // sigprocmask wrapper : unblock a single signal
     159}
     160
    187161static inline void signal_unblock( int sig ) {
    188162        sigset_t mask;
     
    195169}
    196170
    197 // sigprocmask wrapper : block a single signal
    198171static inline void signal_block( int sig ) {
    199172        sigset_t mask;
     
    206179}
    207180
    208 // kill wrapper : signal a processor
     181static inline bool preemption_ready() {
     182        return disable_preempt_count == 0 && !preemption_in_progress;
     183}
     184
     185static inline void defer_ctxSwitch() {
     186        this_processor->pending_preemption = true;
     187}
     188
     189static inline void defer_alarm() {
     190        systemProcessor->pending_alarm = true;
     191}
     192
    209193static void preempt( processor * this ) {
    210194        pthread_kill( this->kernel_thread, SIGUSR1 );
    211195}
    212196
    213 // reserved for future use
    214197static void timeout( thread_desc * this ) {
    215198        //TODO : implement waking threads
    216199}
    217200
    218 
    219 // Check if a CtxSwitch signal handler shoud defer
    220 // If true  : preemption is safe
    221 // If false : preemption is unsafe and marked as pending
    222 static inline bool preemption_ready() {
    223         bool ready = disable_preempt_count == 0 && !preemption_in_progress; // Check if preemption is safe
    224         this_processor->pending_preemption = !ready;                        // Adjust the pending flag accordingly
    225         return ready;
    226 }
    227 
    228201//=============================================================================================
    229202// Kernel Signal Startup/Shutdown logic
    230203//=============================================================================================
    231204
    232 // Startup routine to activate preemption
    233 // Called from kernel_startup
     205static pthread_t alarm_thread;
     206void * alarm_loop( __attribute__((unused)) void * args );
     207
    234208void kernel_start_preemption() {
    235209        LIB_DEBUG_PRINT_SAFE("Kernel : Starting preemption\n");
    236 
    237         // Start with preemption disabled until ready
    238         disable_preempt_count = 1;
    239 
    240         // Initialize the event kernel
    241         event_kernel = (event_kernel_t *)&storage_event_kernel;
    242         event_kernel{};
    243 
    244         // Setup proper signal handlers
    245         __kernel_sigaction( SIGUSR1, sigHandler_ctxSwitch, SA_SIGINFO );         // CtxSwitch handler
    246         // __kernel_sigaction( SIGSEGV, sigHandler_segv     , SA_SIGINFO );      // Failure handler
    247         // __kernel_sigaction( SIGBUS , sigHandler_segv     , SA_SIGINFO );      // Failure handler
     210        __kernel_sigaction( SIGUSR1, sigHandler_ctxSwitch, SA_SIGINFO );
     211        // __kernel_sigaction( SIGSEGV, sigHandler_segv     , SA_SIGINFO );
     212        // __kernel_sigaction( SIGBUS , sigHandler_segv     , SA_SIGINFO );
    248213
    249214        signal_block( SIGALRM );
     
    252217}
    253218
    254 // Shutdown routine to deactivate preemption
    255 // Called from kernel_shutdown
    256219void kernel_stop_preemption() {
    257220        LIB_DEBUG_PRINT_SAFE("Kernel : Preemption stopping\n");
    258221
    259         // Block all signals since we are already shutting down
    260222        sigset_t mask;
    261223        sigfillset( &mask );
    262224        sigprocmask( SIG_BLOCK, &mask, NULL );
    263225
    264         // Notify the alarm thread of the shutdown
    265226        sigval val = { 1 };
    266227        pthread_sigqueue( alarm_thread, SIGALRM, val );
    267 
    268         // Wait for the preemption thread to finish
    269228        pthread_join( alarm_thread, NULL );
    270 
    271         // Preemption is now fully stopped
    272 
    273229        LIB_DEBUG_PRINT_SAFE("Kernel : Preemption stopped\n");
    274230}
    275231
    276 // Raii ctor/dtor for the preemption_scope
    277 // Used by thread to control when they want to receive preemption signals
    278232void ?{}( preemption_scope * this, processor * proc ) {
    279         (&this->alarm){ proc, zero_time, zero_time };
     233        (&this->alarm){ proc };
    280234        this->proc = proc;
    281235        this->proc->preemption_alarm = &this->alarm;
    282 
    283         update_preemption( this->proc, from_us(this->proc->cltr->preemption) );
     236        update_preemption( this->proc, this->proc->preemption );
    284237}
    285238
     
    287240        disable_interrupts();
    288241
    289         update_preemption( this->proc, zero_time );
     242        update_preemption( this->proc, 0 );
    290243}
    291244
     
    294247//=============================================================================================
    295248
    296 // Context switch signal handler
    297 // Receives SIGUSR1 signal and causes the current thread to yield
    298249void sigHandler_ctxSwitch( __CFA_SIGPARMS__ ) {
    299250        LIB_DEBUG_DO( last_interrupt = (void *)(cxt->uc_mcontext.gregs[CFA_REG_IP]); )
    300 
    301         // Check if it is safe to preempt here
    302         if( !preemption_ready() ) { return; }
    303 
    304         preemption_in_progress = true;                      // Sync flag : prevent recursive calls to the signal handler
    305         signal_unblock( SIGUSR1 );                          // We are about to CtxSwitch out of the signal handler, let other handlers in
    306         preemption_in_progress = false;                     // Clear the in progress flag
    307 
    308         // Preemption can occur here
    309 
    310         BlockInternal( (thread_desc*)this_thread );         // Do the actual CtxSwitch
    311 }
    312 
    313 // Main of the alarm thread
    314 // Waits on SIGALRM and send SIGUSR1 to whom ever needs it
     251        if( preemption_ready() ) {
     252                preemption_in_progress = true;
     253                signal_unblock( SIGUSR1 );
     254                this_processor->pending_preemption = false;
     255                preemption_in_progress = false;
     256                BlockInternal( (thread_desc*)this_thread );
     257        }
     258        else {
     259                defer_ctxSwitch();
     260        }
     261}
     262
    315263void * alarm_loop( __attribute__((unused)) void * args ) {
    316         // Block sigalrms to control when they arrive
    317264        sigset_t mask;
    318265        sigemptyset( &mask );
     
    323270        }
    324271
    325         // Main loop
    326272        while( true ) {
    327                 // Wait for a sigalrm
    328273                siginfo_t info;
    329274                int sig = sigwaitinfo( &mask, &info );
    330 
    331                 // If another signal arrived something went wrong
    332                 assertf(sig == SIGALRM, "Kernel Internal Error, sigwait: Unexpected signal %d (%d : %d)\n", sig, info.si_code, info.si_value.sival_int);
    333 
    334                 LIB_DEBUG_PRINT_SAFE("Kernel : Caught alarm from %d with %d\n", info.si_code, info.si_value.sival_int );
    335                 // Switch on the code (a.k.a. the sender) to
    336                 switch( info.si_code )
     275                if( sig < 0 ) {
     276                        abortf( "internal error, sigwait" );
     277                }
     278                else if( sig == SIGALRM )
    337279                {
    338                 // Timers can apparently be marked as sent for the kernel
    339                 // In either case, tick preemption
    340                 case SI_TIMER:
    341                 case SI_KERNEL:
    342                         LIB_DEBUG_PRINT_SAFE("Kernel : Preemption thread tick\n");
    343                         lock( &event_kernel->lock DEBUG_CTX2 );
    344                         tick_preemption();
    345                         unlock( &event_kernel->lock );
    346                         break;
    347                 // Signal was not sent by the kernel but by an other thread
    348                 case SI_QUEUE:
    349                         // For now, other thread only signal the alarm thread to shut it down
    350                         // If this needs to change use info.si_value and handle the case here
    351                         goto EXIT;
    352                 }
    353         }
    354 
    355 EXIT:
     280                        LIB_DEBUG_PRINT_SAFE("Kernel : Caught signal %d (%d)\n", sig, info.si_value.sival_int );
     281                        if( info.si_value.sival_int == 0 )
     282                        {
     283                                LIB_DEBUG_PRINT_SAFE("Kernel : Preemption thread tick\n");
     284                                lock( &systemProcessor->alarm_lock DEBUG_CTX2 );
     285                                tick_preemption();
     286                                unlock( &systemProcessor->alarm_lock );
     287                        }
     288                        else if( info.si_value.sival_int == 1 )
     289                        {
     290                                break;
     291                        }
     292                }
     293                else
     294                {
     295                        LIB_DEBUG_PRINT_SAFE("Kernel : Unexpected signal %d (%d)\n", sig, info.si_value.sival_int);
     296                }
     297        }
     298
    356299        LIB_DEBUG_PRINT_SAFE("Kernel : Preemption thread stopping\n");
    357300        return NULL;
    358301}
    359302
    360 // Sigaction wrapper : register an signal handler
    361303static void __kernel_sigaction( int sig, void (*handler)(__CFA_SIGPARMS__), int flags ) {
    362304        struct sigaction act;
     
    374316}
    375317
    376 // Sigaction wrapper : restore default handler
     318typedef void (*sa_handler_t)(int);
     319
    377320static void __kernel_sigdefault( int sig ) {
    378321        struct sigaction act;
    379322
    380         act.sa_handler = SIG_DFL;
     323        // act.sa_handler = SIG_DFL;
    381324        act.sa_flags = 0;
    382325        sigemptyset( &act.sa_mask );
     
    486429//      raise( SIGABRT );
    487430// }
    488 
    489 // Local Variables: //
    490 // mode: c //
    491 // tab-width: 4 //
    492 // End: //
  • src/libcfa/concurrency/preemption.h

    r0720e049 r3d4b23fa  
     1//                              -*- Mode: CFA -*-
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    910// Author           : Thierry Delisle
    1011// Created On       : Mon Jun 5 14:20:42 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:34:25 2017
    13 // Update Count     : 1
     12// Last Modified By : Thierry Delisle
     13// Last Modified On : --
     14// Update Count     : 0
    1415//
    1516
    16 #pragma once
     17#ifndef PREEMPTION_H
     18#define PREEMPTION_H
    1719
    1820#include "alarm.h"
     
    3335void ^?{}( preemption_scope * this );
    3436
    35 // Local Variables: //
    36 // mode: c //
    37 // tab-width: 4 //
    38 // End: //
     37#endif //PREEMPTION_H
  • src/libcfa/concurrency/thread

    r0720e049 r3d4b23fa  
     1//                              -*- Mode: CFA -*-
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    910// Author           : Thierry Delisle
    1011// Created On       : Tue Jan 17 12:27:26 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:59:40 2017
    13 // Update Count     : 3
     12// Last Modified By : Thierry Delisle
     13// Last Modified On : --
     14// Update Count     : 0
    1415//
    1516
    16 #pragma once
     17#ifndef THREADS_H
     18#define THREADS_H
    1719
    18 #include <assert.h>
     20#include "assert"
    1921#include "invoke.h"
    2022
     
    5254}
    5355
    54 extern thread_local thread_desc * volatile this_thread;
     56extern volatile thread_local thread_desc * this_thread;
    5557
    5658forall( dtype T | is_thread(T) )
     
    8284void yield( unsigned times );
    8385
     86#endif //THREADS_H
     87
    8488// Local Variables: //
    8589// mode: c //
  • src/libcfa/concurrency/thread.c

    r0720e049 r3d4b23fa  
     1//                              -*- Mode: CFA -*-
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    910// Author           : Thierry Delisle
    1011// Created On       : Tue Jan 17 12:27:26 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:34:46 2017
    13 // Update Count     : 1
     12// Last Modified By : Thierry Delisle
     13// Last Modified On : --
     14// Update Count     : 0
    1415//
    1516
     
    8687
    8788void yield( void ) {
    88         BlockInternal( this_thread );
     89        BlockInternal( (thread_desc *)this_thread );
    8990}
    9091
  • src/libcfa/containers/maybe

    r0720e049 r3d4b23fa  
    99// Author           : Andrew Beach
    1010// Created On       : Wed May 24 14:43:00 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 10:00:52 2017
    13 // Update Count     : 4
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Fri Jun 16 15:42:00 2017
     13// Update Count     : 2
    1414//
    1515
    16 #pragma once
     16
     17#ifndef MAYBE_H
     18#define MAYBE_H
    1719
    1820#include <stdbool.h>
     
    6466void set_none(maybe(T) * this);
    6567
    66 // Local Variables: //
    67 // mode: c //
    68 // tab-width: 4 //
    69 // End: //
     68#endif // MAYBE_H
  • src/libcfa/containers/maybe.c

    r0720e049 r3d4b23fa  
    99// Author           : Andrew Beach
    1010// Created On       : Wed May 24 15:40:00 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 20 15:23:50 2017
    13 // Update Count     : 2
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thr May 25 15:24:00 2017
     13// Update Count     : 1
    1414//
    1515
    1616#include <containers/maybe>
    17 #include <assert.h>
     17#include <assert>
    1818
    1919
  • src/libcfa/containers/pair

    r0720e049 r3d4b23fa  
    99// Author           : Aaron Moss
    1010// Created On       : Wed Apr 12 15:32:00 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:59:53 2017
    13 // Update Count     : 2
     11// Last Modified By : Aaron Moss
     12// Last Modified On : Wed Apr 12 15:32:00 2017
     13// Update Count     : 1
    1414//
    1515
    16 #pragma once
     16#ifndef PAIR_H
     17#define PAIR_H
    1718
    1819forall(otype R, otype S) struct pair {
     
    4344int ?>=?(pair(R, S) p, pair(R, S) q);
    4445
     46#endif // PAIR_H
     47
    4548// Local Variables: //
    4649// mode: c //
  • src/libcfa/containers/result

    r0720e049 r3d4b23fa  
    99// Author           : Andrew Beach
    1010// Created On       : Wed May 24 14:45:00 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 10:00:44 2017
    13 // Update Count     : 3
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Fri Jun 16 15:41:00 2017
     13// Update Count     : 2
    1414//
    1515
    16 #pragma once
     16
     17#ifndef RESULT_H
     18#define RESULT_H
    1719
    1820#include <stdbool.h>
     
    7678void set_error(result(T, E) * this, E error);
    7779
    78 // Local Variables: //
    79 // mode: c //
    80 // tab-width: 4 //
    81 // End: //
     80#endif // RESULT_H
  • src/libcfa/containers/result.c

    r0720e049 r3d4b23fa  
    99// Author           : Andrew Beach
    1010// Created On       : Wed May 24 15:40:00 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 20 15:23:58 2017
    13 // Update Count     : 2
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thr May 25 15:27:00 2017
     13// Update Count     : 1
    1414//
    1515
    1616#include <containers/result>
    17 #include <assert.h>
     17#include <assert>
    1818
    1919
  • src/libcfa/containers/vector

    r0720e049 r3d4b23fa  
    1010// Created On       : Tue Jul  5 18:00:07 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 10:01:18 2017
    13 // Update Count     : 3
     12// Last Modified On : Tue Jul  5 18:01:35 2016
     13// Update Count     : 2
    1414//
    1515
    16 #pragma once
     16#ifndef VECTOR_H
     17#define VECTOR_H
    1718
    1819extern "C" {
     
    165166// }
    166167
     168#endif // VECTOR_H
     169
    167170// Local Variables: //
    168171// mode: c //
  • src/libcfa/exception.c

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon Jun 26 15:13:00 2017
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Aug  4 15:20:00 2017
    13 // Update Count     : 6
    14 //
    15 
    16 #include <stddef.h> // for size_t
     12// Last Modified On : Tus Jul 11 16:36:00 2017
     13// Update Count     : 1
     14//
    1715
    1816#include "exception.h"
     
    2422#include <unwind.h>
    2523
    26 // FIX ME: temporary hack to keep ARM build working
    27 #ifndef _URC_FATAL_PHASE1_ERROR
    28 #define _URC_FATAL_PHASE1_ERROR 2
    29 #endif // ! _URC_FATAL_PHASE1_ERROR
    30 #ifndef _URC_FATAL_PHASE2_ERROR
    31 #define _URC_FATAL_PHASE2_ERROR 2
    32 #endif // ! _URC_FATAL_PHASE2_ERROR
    33 
    3424#include "lsda.h"
    3525
    36 
    37 // Base exception vtable is abstract, you should not have base exceptions.
    38 struct __cfaehm__base_exception_t_vtable
    39                 ___cfaehm__base_exception_t_vtable_instance = {
    40         .parent = NULL,
    41         .size = 0,
    42         .copy = NULL,
    43         .free = NULL,
    44         .msg = NULL
    45 };
    46 
    47 
    4826// Temperary global exception context. Does not work with concurency.
    49 struct exception_context_t {
     27struct shared_stack_t {
    5028    struct __cfaehm__try_resume_node * top_resume;
    5129    struct __cfaehm__try_resume_node * current_resume;
    5230
    53     exception * current_exception;
     31    exception current_exception;
    5432    int current_handler_index;
    5533} shared_stack = {NULL, NULL, 0, 0};
    5634
    57 // Get the current exception context.
    58 // There can be a single global until multithreading occurs, then each stack
    59 // needs its own. It will have to be updated to handle that.
    60 struct exception_context_t * this_exception_context() {
    61         return &shared_stack;
    62 }
    63 //#define SAVE_EXCEPTION_CONTEXT(to_name)
    64 //struct exception_context_t * to_name = this_exception_context();
    65 //exception * this_exception() {
    66 //    return this_exception_context()->current_exception;
    67 //}
    68 
    69 
    70 // This macro should be the only thing that needs to change across machines.  Used in the personality function, way down
    71 // in termination.
     35
     36
     37// This macro should be the only thing that needs to change across machines.
     38// Used in the personality function, way down in termination.
    7239// struct _Unwind_Context * -> _Unwind_Reason_Code(*)(exception *)
    7340#define MATCHER_FROM_CONTEXT(ptr_to_context) \
     
    8047
    8148        // DEBUG
    82         printf("Throwing resumption exception\n");
     49        printf("Throwing resumption exception %d\n", *except);
    8350
    8451        struct __cfaehm__try_resume_node * original_head = shared_stack.current_resume;
     
    9461        }
    9562
    96         printf("Unhandled exception\n");
     63        printf("Unhandled exception %d\n", *except);
    9764        shared_stack.current_resume = original_head;
    9865
     
    10269}
    10370
    104 // Do we control where exceptions get thrown even with concurency?  If not these are not quite thread safe, the cleanup
    105 // hook has to be added after the node is built but before it is made the top node.
    106 
     71/* Do we control where exceptions get thrown even with concurency?
     72 * If not these are not quite thread safe, the cleanup hook has to be added
     73 * after the node is built but before it is made the top node.
     74 */
    10775void __cfaehm__try_resume_setup(struct __cfaehm__try_resume_node * node,
    10876                        int (*handler)(exception * except)) {
     
    11987// TERMINATION ===============================================================
    12088
    121 // MEMORY MANAGEMENT (still for integers)
    122 // May have to move to cfa for constructors and destructors (references).
    123 
    124 struct __cfaehm__node {
    125         struct __cfaehm__node * next;
    126 };
    127 
    128 #define NODE_TO_EXCEPT(node) ((exception *)(1 + (node)))
    129 #define EXCEPT_TO_NODE(except) ((struct __cfaehm__node *)(except) - 1)
    130 
    131 // Creates a copy of the indicated exception and sets current_exception to it.
    132 static void __cfaehm__allocate_exception( exception * except ) {
    133         struct exception_context_t * context = this_exception_context();
    134 
    135         // Allocate memory for the exception.
    136         struct __cfaehm__node * store = malloc(
    137                 sizeof( struct __cfaehm__node ) + except->virtual_table->size );
    138 
    139         if ( ! store ) {
    140                 // Failure: cannot allocate exception. Terminate thread.
    141                 abort(); // <- Although I think it might be the process.
    142         }
    143 
    144         // Add the node to the list:
    145         store->next = EXCEPT_TO_NODE(context->current_exception);
    146         context->current_exception = NODE_TO_EXCEPT(store);
    147 
    148         // Copy the exception to storage.
    149         except->virtual_table->copy( context->current_exception, except );
    150 }
    151 
    152 // Delete the provided exception, unsetting current_exception if relivant.
    153 static void __cfaehm__delete_exception( exception * except ) {
    154         struct exception_context_t * context = this_exception_context();
    155 
    156         // DEBUG
    157         printf( "Deleting Exception\n");
    158 
    159         // Remove the exception from the list.
    160         struct __cfaehm__node * to_free = EXCEPT_TO_NODE(except);
    161         struct __cfaehm__node * node;
    162 
    163         if ( context->current_exception == except ) {
    164                 node = to_free->next;
    165                 context->current_exception = (node) ? NODE_TO_EXCEPT(node) : 0;
    166         } else {
    167                 node = EXCEPT_TO_NODE(context->current_exception);
    168                 // It may always be in the first or second position.
    169                 while( to_free != node->next ) {
    170                         node = node->next;
    171                 }
    172                 node->next = to_free->next;
    173         }
    174 
    175         // Free the old exception node.
    176         except->virtual_table->free( except );
    177         free( to_free );
    178 }
    179 
    180 // If this isn't a rethrow (*except==0), delete the provided exception.
    181 void __cfaehm__cleanup_terminate( void * except ) {
    182         if ( *(void**)except ) __cfaehm__delete_exception( *(exception**)except );
    183 }
    184 
     89// Requires -fexceptions to work.
     90
     91// Global which defines the current exception
     92// Currently an int just to make matching easier
     93//int this_exception; (became shared_stack.current_exception)
    18594
    18695// We need a piece of storage to raise the exception
     
    202111}
    203112
    204 // The exception that is being thrown must already be stored.
    205 __attribute__((noreturn)) void __cfaehm__begin_unwind(void) {
    206         if ( ! this_exception_context()->current_exception ) {
    207                 printf("UNWIND ERROR missing exception in begin unwind\n");
    208                 abort();
    209         }
    210 
     113void __cfaehm__throw_terminate( exception * val ) {
     114        // Store the current exception
     115        shared_stack.current_exception = *val;
     116
     117        // DEBUG
     118        printf("Throwing termination exception %d\n", *val);
    211119
    212120        // Call stdlibc to raise the exception
    213121        _Unwind_Reason_Code ret = _Unwind_RaiseException( &this_exception_storage );
    214122
    215         // If we reach here it means something happened.  For resumption to work we need to find a way to return back to
    216         // here.  Most of them will probably boil down to setting a global flag and making the phase 1 either stop or
    217         // fail.  Causing an error on purpose may help avoiding unnecessary work but it might have some weird side
    218         // effects.  If we just pretend no handler was found that would work but may be expensive for no reason since we
    219         // will always search the whole stack.
     123        // If we reach here it means something happened
     124        // For resumption to work we need to find a way to return back to here
     125        // Most of them will probably boil down to setting a global flag and making the phase 1 either stop or fail.
     126        // Causing an error on purpose may help avoiding unnecessary work but it might have some weird side effects.
     127        // If we just pretend no handler was found that would work but may be expensive for no reason since we will always
     128        // search the whole stack
    220129
    221130        if( ret == _URC_END_OF_STACK ) {
    222                 // No proper handler was found.  This can be handled in several way.  C++ calls std::terminate Here we
    223                 // force unwind the stack, basically raising a cancellation.
     131                // No proper handler was found
     132                // This can be handled in several way
     133                // C++ calls std::terminate
     134                // Here we force unwind the stack, basically raising a cancellation
    224135                printf("Uncaught exception %p\n", &this_exception_storage);
    225136
     
    229140        }
    230141
    231         // We did not simply reach the end of the stack without finding a handler.  Something wen't wrong
     142        // We did not simply reach the end of the stack without finding a handler,
     143        // Something wen't wrong
    232144        printf("UNWIND ERROR %d after raise exception\n", ret);
    233145        abort();
    234146}
    235147
    236 void __cfaehm__throw_terminate( exception * val ) {
    237         // DEBUG
    238         printf("Throwing termination exception\n");
    239 
    240         __cfaehm__allocate_exception( val );
    241         __cfaehm__begin_unwind();
    242 }
    243 
     148// Nesting this the other way would probably be faster.
    244149void __cfaehm__rethrow_terminate(void) {
    245150        // DEBUG
    246151        printf("Rethrowing termination exception\n");
    247152
    248         __cfaehm__begin_unwind();
    249 }
    250 
    251 // This is our personality routine.  For every stack frame anotated with ".cfi_personality 0x3,__gcfa_personality_v0".
    252 // This function will be called twice when unwinding.  Once in the search phased and once in the cleanup phase.
     153        __cfaehm__throw_terminate(&shared_stack.current_exception);
     154}
     155
     156// This is our personality routine
     157// For every stack frame anotated with ".cfi_personality 0x3,__gcfa_personality_v0"
     158// This function will be called twice when unwinding
     159// Once in the search phased and once in the cleanup phase
    253160_Unwind_Reason_Code __gcfa_personality_v0 (
    254161                int version, _Unwind_Action actions, unsigned long long exceptionClass,
     
    356263                                        _Unwind_Reason_Code (*matcher)(exception *) =
    357264                                                MATCHER_FROM_CONTEXT(context);
    358                                         int index = matcher(shared_stack.current_exception);
     265                                        int index = matcher(&shared_stack.current_exception);
    359266                                        _Unwind_Reason_Code ret = (0 == index)
    360267                                                ? _URC_CONTINUE_UNWIND : _URC_HANDLER_FOUND;
     
    386293                                // I assume this sets the instruction pointer to the adress of the landing pad
    387294                                // It doesn't actually set it, it only state the value that needs to be set once we return _URC_INSTALL_CONTEXT
    388                                 _Unwind_SetIP( context, ((lsd_info.LPStart) + (callsite_landing_pad)) );
     295                                _Unwind_SetIP( context, lsd_info.LPStart + callsite_landing_pad );
    389296
    390297                                // DEBUG
     
    410317}
    411318
    412 // Try statements are hoisted out see comments for details.  With this could probably be unique and simply linked from
    413 // libcfa but there is one problem left, see the exception table for details
     319// Try statements are hoisted out see comments for details
     320// With this could probably be unique and simply linked from
     321// libcfa but there is one problem left, see the exception table
     322// for details
    414323__attribute__((noinline))
    415324void __cfaehm__try_terminate(void (*try_block)(),
     
    419328        //! printf("%p %p %p %p\n", &try_block, &catch_block, &match_block, &xy);
    420329
    421         // Setup statments: These 2 statments won't actually result in any code, they only setup global tables.
    422         // However, they clobber gcc cancellation support from gcc.  We can replace the personality routine but
    423         // replacing the exception table gcc generates is not really doable, it generates labels based on how the
    424         // assembly works.
    425 
     330        // Setup statments
     331        // These 2 statments won't actually result in any code,
     332        // they only setup global tables.
     333        // However, they clobber gcc cancellation support from gcc.
     334        // We can replace the personality routine but replacing the exception
     335        // table gcc generates is not really doable, it generates labels based
     336        // on how the assembly works.
    426337        // Setup the personality routine
    427338        asm volatile (".cfi_personality 0x3,__gcfa_personality_v0");
     
    429340        asm volatile (".cfi_lsda 0x3, .LLSDACFA2");
    430341
    431         // Label which defines the start of the area for which the handler is setup.
     342        // Label which defines the start of the area for which the handler is setup
    432343        asm volatile (".TRYSTART:");
    433344
     
    443354        // Exceptionnal path
    444355        CATCH : __attribute__(( unused ));
    445         // Label which defines the end of the area for which the handler is setup.
     356        // Label which defines the end of the area for which the handler is setup
    446357        asm volatile (".TRYEND:");
    447         // Label which defines the start of the exception landing pad.  Basically what is called when the exception is
    448         // caught.  Note, if multiple handlers are given, the multiplexing should be done by the generated code, not the
    449         // exception runtime.
     358        // Label which defines the start of the exception landing pad
     359        // basically what will be called when the exception is caught
     360        // Note, if multiple handlers are given, the multiplexing should be done
     361        // by the generated code, not the exception runtime
    450362        asm volatile (".CATCH:");
    451363
    452364        // Exception handler
    453         catch_block( shared_stack.current_handler_index,
    454                      shared_stack.current_exception );
    455 }
    456 
    457 // Exception table data we need to generate.  While this is almost generic, the custom data refers to foo_try_match try
    458 // match, which is no way generic.  Some more works need to be done if we want to have a single call to the try routine.
    459 
    460 #if defined( __x86_64__ ) || defined( __i386__ )
     365        catch_block(shared_stack.current_handler_index,
     366                    &shared_stack.current_exception);
     367}
     368
     369// Exception table data we need to generate
     370// While this is almost generic, the custom data refers to
     371// foo_try_match try match, which is no way generic
     372// Some more works need to be done if we want to have a single
     373// call to the try routine
    461374asm (
    462375        //HEADER
     
    481394//      "       .section        .note.GNU-stack,\"x\",@progbits\n"
    482395);
    483 #endif // __x86_64__ || __i386__
  • src/libcfa/exception.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon Jun 26 15:11:00 2017
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Aug  4 15:20:00 2017
    13 // Update Count     : 5
     12// Last Modified On : Tus Jul 11 16:31:00 2017
     13// Update Count     : 2
    1414//
    1515
    16 #pragma once
     16#ifndef EXCEPTION_H
     17#define EXCEPTION_H
    1718
     19
     20// Later to be a special structure type.
     21typedef int exception;
    1822
    1923#ifdef __CFORALL__
    2024extern "C" {
    2125#endif
    22 
    23 struct __cfaehm__base_exception_t;
    24 typedef struct __cfaehm__base_exception_t exception;
    25 struct __cfaehm__base_exception_t_vtable {
    26         const struct __cfaehm__base_exception_t_vtable * parent;
    27         size_t size;
    28         void (*copy)(struct __cfaehm__base_exception_t *this,
    29                      struct __cfaehm__base_exception_t * other);
    30         void (*free)(struct __cfaehm__base_exception_t *this);
    31         const char (*msg)(struct __cfaehm__base_exception_t *this);
    32 };
    33 struct __cfaehm__base_exception_t {
    34         struct __cfaehm__base_exception_t_vtable const * virtual_table;
    35 };
    36 extern struct __cfaehm__base_exception_t_vtable
    37         ___cfaehm__base_exception_t_vtable_instance;
    38 
    3926
    4027// Used in throw statement translation.
     
    4936    int (*match_block)(exception * except));
    5037
    51 // Clean-up the exception in catch blocks.
    52 void __cfaehm__cleanup_terminate(void * except);
    53 
    5438// Data structure creates a list of resume handlers.
    5539struct __cfaehm__try_resume_node {
     
    5842};
    5943
    60 // These act as constructor and destructor for the resume node.
    6144void __cfaehm__try_resume_setup(
    6245    struct __cfaehm__try_resume_node * node,
     
    6649
    6750// Check for a standard way to call fake deconstructors.
    68 struct __cfaehm__cleanup_hook {};
     51struct __cfaehm__cleanup_hook {
     52};
    6953
    7054#ifdef __CFORALL__
    7155}
    7256#endif
     57
     58#endif //EXCEPTION_H
  • src/libcfa/fstream.c

    r0720e049 r3d4b23fa  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 20 15:20:49 2017
    13 // Update Count     : 252
     12// Last Modified On : Thu Jul  6 18:38:25 2017
     13// Update Count     : 251
    1414//
    1515
    1616#include "fstream"
    1717
     18extern "C" {
    1819#include <stdio.h>                                                                              // vfprintf, vfscanf
    1920#include <stdlib.h>                                                                             // exit
     
    2324#include <float.h>                                                                              // DBL_DIG, LDBL_DIG
    2425#include <complex.h>                                                                    // creal, cimag
    25 #include <assert.h>
     26}
     27#include "assert"
    2628
    2729#define IO_MSG "I/O error: "
  • src/libcfa/interpose.c

    r0720e049 r3d4b23fa  
     1//                              -*- Mode: CFA -*-
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    910// Author           : Thierry Delisle
    1011// Created On       : Wed Mar 29 16:10:31 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:27:33 2017
    13 // Update Count     : 1
     12// Last Modified By :
     13// Last Modified On :
     14// Update Count     : 0
    1415//
    1516
     
    140141        }
    141142}
    142 
    143 // Local Variables: //
    144 // mode: c //
    145 // tab-width: 4 //
    146 // End: //
  • src/libcfa/interpose.h

    r0720e049 r3d4b23fa  
     1//                              -*- Mode: CFA -*-
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    910// Author           : Thierry Delisle
    1011// Created On       : Wed Mar 29 15:56:41 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:33:02 2017
    13 // Update Count     : 2
     12// Last Modified By :
     13// Last Modified On :
     14// Update Count     : 0
    1415//
    1516
    16 #pragma once
     17#ifndef INTERPOSE_H
     18#define INTERPOSE_H
    1719
    1820void * interpose_symbol( const char* symbol, , const char *version );
     
    2123extern __typeof__( exit ) libc_abort __attribute__(( noreturn ));
    2224
    23 // Local Variables: //
    24 // mode: c //
    25 // tab-width: 4 //
    26 // End: //
     25#endif //INTERPOSE_H
  • src/libcfa/iostream

    r0720e049 r3d4b23fa  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug  9 16:42:47 2017
    13 // Update Count     : 131
     12// Last Modified On : Fri Jul  7 08:35:59 2017
     13// Update Count     : 118
    1414//
    1515
     
    4646}; // ostream
    4747
    48 // trait writeable( otype T ) {
    49 //      forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, T );
    50 // }; // writeable
    51 
    52 trait writeable( otype T, dtype ostype | ostream( ostype ) ) {
    53         ostype * ?|?( ostype *, T );
     48trait writeable( otype T ) {
     49        forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, T );
    5450}; // writeable
    5551
     
    8177
    8278// tuples
    83 forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype * ?|?( ostype *, Params ); } )
    84 ostype * ?|?( ostype * os, T arg, Params rest );
     79forall( dtype ostype, otype T, ttype Params | ostream( ostype ) | writeable( T ) | { ostype * ?|?( ostype *, Params ); } ) ostype * ?|?( ostype * os, T arg, Params rest );
    8580
    8681// manipulators
     
    9590
    9691// writes the range [begin, end) to the given stream
    97 forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) )
    98 void write( iterator_type begin, iterator_type end, ostype * os );
     92forall( otype elt_type | writeable( elt_type ), otype iterator_type | iterator( iterator_type, elt_type ), dtype os_type | ostream( os_type ) )
     93void write( iterator_type begin, iterator_type end, os_type *os );
    9994
    100 forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) )
    101 void write_reverse( iterator_type begin, iterator_type end, ostype * os );
     95forall( otype elt_type | writeable( elt_type ), otype iterator_type | iterator( iterator_type, elt_type ), dtype os_type | ostream( os_type ) )
     96void write_reverse( iterator_type begin, iterator_type end, os_type *os );
    10297
    10398//---------------------------------------
  • src/libcfa/iostream.c

    r0720e049 r3d4b23fa  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug  9 16:46:51 2017
    13 // Update Count     : 401
     12// Last Modified On : Thu Jul  6 18:14:17 2017
     13// Update Count     : 396
    1414//
    1515
     
    125125forall( dtype ostype | ostream( ostype ) )
    126126ostype * ?|?( ostype * os, float _Complex fc ) {
    127         if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    128         fmt( os, "%g%+gi", crealf( fc ), cimagf( fc ) );
     127        os | crealf( fc );
     128        _Bool temp = sepDisable( os );                                          // disable separators within complex value
     129        if ( cimagf( fc ) >= 0 ) os | '+';                                      // negative value prints '-'
     130        os | cimagf( fc ) | 'i';
     131        sepReset( os, temp );                                                           // reset separator
    129132        return os;
    130133} // ?|?
     
    132135forall( dtype ostype | ostream( ostype ) )
    133136ostype * ?|?( ostype * os, double _Complex dc ) {
    134         if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    135         fmt( os, "%.*lg%+.*lgi", DBL_DIG, creal( dc ), DBL_DIG, cimag( dc ) );
     137        os | creal( dc );
     138        _Bool temp = sepDisable( os );                                          // disable separators within complex value
     139        if ( cimag( dc ) >= 0 ) os | '+';                                       // negative value prints '-'
     140        os | cimag( dc ) | 'i';
     141        sepReset( os, temp );                                                           // reset separator
    136142        return os;
    137143} // ?|?
     
    139145forall( dtype ostype | ostream( ostype ) )
    140146ostype * ?|?( ostype * os, long double _Complex ldc ) {
    141         if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    142         fmt( os, "%.*Lg%+.*Lgi", LDBL_DIG, creall( ldc ), LDBL_DIG, cimagl( ldc ) );
     147        os | creall( ldc );
     148        _Bool temp = sepDisable( os );                                          // disable separators within complex value
     149        if ( cimagl( ldc ) >= 0 ) os | '+';                                     // negative value prints '-'
     150        os | cimagl( ldc ) | 'i';
     151        sepReset( os, temp );                                                           // reset separator
    143152        return os;
    144153} // ?|?
     
    193202
    194203// tuples
    195 forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype * ?|?( ostype *, Params ); } )
     204forall( dtype ostype, otype T, ttype Params | ostream( ostype ) | writeable( T ) | { ostype * ?|?( ostype *, Params ); } )
    196205ostype * ?|?( ostype * os, T arg, Params rest ) {
    197206        os | arg;                                                                                       // print first argument
     
    256265//---------------------------------------
    257266
    258 forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) )
    259 void write( iterator_type begin, iterator_type end, ostype * os ) {
    260         void print( elt_type i ) { os | i; }
     267forall( otype elttype | writeable( elttype ), otype iteratortype | iterator( iteratortype, elttype ), dtype ostype | ostream( ostype ) )
     268void write( iteratortype begin, iteratortype end, ostype * os ) {
     269        void print( elttype i ) { os | i; }
    261270        for_each( begin, end, print );
    262271} // ?|?
    263272
    264 forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) )
    265 void write_reverse( iterator_type begin, iterator_type end, ostype * os ) {
    266         void print( elt_type i ) { os | i; }
     273forall( otype elttype | writeable( elttype ), otype iteratortype | iterator( iteratortype, elttype ), dtype ostype | ostream( ostype ) )
     274void write_reverse( iteratortype begin, iteratortype end, ostype * os ) {
     275        void print( elttype i ) { os | i; }
    267276        for_each_reverse( begin, end, print );
    268277} // ?|?
  • src/libcfa/libhdr.h

    r0720e049 r3d4b23fa  
    99// Author           : Thierry Delisle
    1010// Created On       : Mon Nov 28 12:27:26 2016
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:56:32 2017
    13 // Update Count     : 1
     11// Last Modified By : Thierry Delisle
     12// Last Modified On : Mon Nov 28 12:27:26 2016
     13// Update Count     : 0
    1414//
    1515
    16 #pragma once
     16#ifndef __LIB_HDR_H__
     17#define __LIB_HDR_H__
    1718
    1819#include "libalign.h"
     
    2021#include "libtools.h"
    2122
     23#endif //__LIB_HDR_H__
     24
    2225// Local Variables: //
    2326// mode: c //
  • src/libcfa/libhdr/libalign.h

    r0720e049 r3d4b23fa  
     1//                              -*- Mode: C++ -*-
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    910// Author           : Thierry Delisle
    1011// Created On       : Mon Nov 28 12:27:26 2016
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 23:05:35 2017
    13 // Update Count     : 2
     12// Last Modified By : Thierry Delisle
     13// Last Modified On : Mon Nov 28 12:27:26 2016
     14// Update Count     : 0
    1415//
    1516// This  library is free  software; you  can redistribute  it and/or  modify it
     
    2728//
    2829
    29 #pragma once
    3030
    31 #include <assert.h>
     31#ifndef __LIB_ALIGN_H__
     32#define __LIB_ALIGN_H__
     33
     34#include "assert"
    3235#include <stdbool.h>
    3336
     
    5861} // uCeiling
    5962
     63
     64#endif // __LIB_ALIGN_H__
     65
     66
    6067// Local Variables: //
    6168// compile-command: "make install" //
  • src/libcfa/libhdr/libdebug.h

    r0720e049 r3d4b23fa  
    99// Author           : Thierry Delisle
    1010// Created On       : Mon Nov 28 12:27:26 2016
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 10:02:24 2017
    13 // Update Count     : 1
     11// Last Modified By : Thierry Delisle
     12// Last Modified On : Mon Nov 28 12:27:26 2016
     13// Update Count     : 0
    1414//
    1515
    16 #pragma once
     16#ifndef __LIB_DEBUG_H__
     17#define __LIB_DEBUG_H__
    1718
    1819#ifdef __CFA_DEBUG__
     
    7778#endif
    7879
     80#endif //__LIB_DEBUG_H__
     81
    7982// Local Variables: //
    8083// mode: c //
  • src/libcfa/libhdr/libtools.h

    r0720e049 r3d4b23fa  
    99// Author           : Thierry Delisle
    1010// Created On       : Mon Nov 28 12:27:26 2016
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 10:02:10 2017
    13 // Update Count     : 1
     11// Last Modified By : Thierry Delisle
     12// Last Modified On : Mon Nov 28 12:27:26 2016
     13// Update Count     : 0
    1414//
    1515
    16 #pragma once
     16#ifndef __LIB_TOOLS_H__
     17#define __LIB_TOOLS_H__
    1718
    1819// void abortf( const char *fmt, ... ) {
     
    2930#endif
    3031
     32#endif //__LIB_TOOLS_H__
     33
    3134// Local Variables: //
    3235// mode: c //
  • src/libcfa/math

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon Apr 18 23:37:04 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Aug  7 07:51:15 2017
    13 // Update Count     : 108
     12// Last Modified On : Fri Jul  7 09:34:15 2017
     13// Update Count     : 61
    1414//
    1515
    1616#pragma once
    1717
    18 #include <math.h>
    19 #include <complex.h>
    20 
    21 //---------------------- General ----------------------
    22 
    23 static inline float ?%?( float x, float y ) { return fmodf( x, y ); }
    24 static inline float fmod( float x, float y ) { return fmodf( x, y ); }
    25 static inline double ?%?( double x, double y ) { return fmod( x, y ); }
     18extern "C" {
     19#include <math.h>                                                                               // fpclassify, isfinite, isnormal, isnan, isinf
     20} // extern "C"
     21
     22float ?%?( float, float );
     23float fmod( float, float );
     24double ?%?( double, double );
    2625// extern "C" { double fmod( double, double ); }
    27 static inline long double ?%?( long double x, long double y ) { return fmodl( x, y ); }
    28 static inline long double fmod( long double x, long double y ) { return fmodl( x, y ); }
    29 
    30 static inline float remainder( float x, float y ) { return remainderf( x, y ); }
     26long double ?%?( long double, long double );
     27long double fmod( long double, long double );
     28
     29float remainder( float, float );
    3130// extern "C" { double remainder( double, double ); }
    32 static inline long double remainder( long double x, long double y ) { return remainderl( x, y ); }
    33 
    34 static inline float remquo( float x, float y, int * quo ) { return remquof( x, y, quo ); }
    35 // extern "C" { double remquo( double x, double y, int * quo ); }
    36 static inline long double remquo( long double x, long double y, int * quo ) { return remquol( x, y, quo ); }
    37 static inline [ int, float ] remquo( float x, float y ) { int quo; x = remquof( x, y, &quo ); return [ quo, x ]; }
    38 static inline [ int, double ] remquo( double x, double y ) { int quo; x = remquo( x, y, &quo ); return [ quo, x ]; }
    39 static inline [ int, long double ] remquo( long double x, long double y ) { int quo; x = remquol( x, y, &quo ); return [ quo, x ]; }
    40 
    41 static inline [ float, float ] div( float x, float y ) { y = modff( x / y, &x ); return [ x, y ]; }
    42 static inline [ double, double ] div( double x, double y ) { y = modf( x / y, &x ); return [ x, y ]; }
    43 static inline [ long double, long double ] div( long double x, long double y ) { y = modfl( x / y, &x ); return [ x, y ]; }
    44 
    45 static inline float fma( float x, float y, float z ) { return fmaf( x, y, z ); }
     31long double remainder( long double, long double );
     32
     33[ int, float ] remquo( float, float );
     34float remquo( float, float, int * );
     35[ int, double ] remquo( double, double );
     36// extern "C" { double remquo( double, double, int * ); }
     37[ int, long double ] remquo( long double, long double );
     38long double remquo( long double, long double, int * );
     39
     40[ int, float ] div( float, float );                                             // alternative name for remquo
     41float div( float, float, int * );
     42[ int, double ] div( double, double );
     43// extern "C" { double div( double, double, int * ); }
     44[ int, long double ] div( long double, long double );
     45long double div( long double, long double, int * );
     46
     47float fma( float, float, float );
    4648// extern "C" { double fma( double, double, double ); }
    47 static inline long double fma( long double x, long double y, long double z ) { return fmal( x, y, z ); }
    48 
    49 static inline float fdim( float x, float y ) { return fdimf( x, y ); }
     49long double fma( long double, long double, long double );
     50
     51float fdim( float, float );
    5052// extern "C" { double fdim( double, double ); }
    51 static inline long double fdim( long double x, long double y ) { return fdiml( x, y ); }
    52 
    53 static inline float nan( const char * tag ) { return nanf( tag ); }
     53long double fdim( long double, long double );
     54
     55float nan( const char * );
    5456// extern "C" { double nan( const char * ); }
    55 static inline long double nan( const char * tag ) { return nanl( tag ); }
     57long double nan( const char * );
    5658
    5759//---------------------- Exponential ----------------------
    5860
    59 static inline float exp( float x ) { return expf( x ); }
     61float exp( float );
    6062// extern "C" { double exp( double ); }
    61 static inline long double exp( long double x ) { return expl( x ); }
    62 static inline float _Complex exp( float _Complex x ) { return cexpf( x ); }
    63 static inline double _Complex exp( double _Complex x ) { return cexp( x ); }
    64 static inline long double _Complex exp( long double _Complex x ) { return cexpl( x ); }
    65 
    66 static inline float exp2( float x ) { return exp2f( x ); }
     63long double exp( long double );
     64float _Complex exp( float _Complex );
     65double _Complex exp( double _Complex );
     66long double _Complex exp( long double _Complex );
     67
     68float exp2( float );
    6769// extern "C" { double exp2( double ); }
    68 static inline long double exp2( long double x ) { return exp2l( x ); }
    69 //static inline float _Complex exp2( float _Complex x ) { return cexp2f( x ); }
    70 //static inline double _Complex exp2( double _Complex x ) { return cexp2( x ); }
    71 //static inline long double _Complex exp2( long double _Complex x ) { return cexp2l( x ); }
    72 
    73 static inline float expm1( float x ) { return expm1f( x ); }
     70long double exp2( long double );
     71// float _Complex exp2( float _Complex );
     72// double _Complex exp2( double _Complex );
     73// long double _Complex exp2( long double _Complex );
     74
     75float expm1( float );
    7476// extern "C" { double expm1( double ); }
    75 static inline long double expm1( long double x ) { return expm1l( x ); }
    76 
    77 static inline float pow( float x, float y ) { return powf( x, y ); }
     77long double expm1( long double );
     78
     79float log( float );
     80// extern "C" { double log( double ); }
     81long double log( long double );
     82float _Complex log( float _Complex );
     83double _Complex log( double _Complex );
     84long double _Complex log( long double _Complex );
     85
     86float log2( float );
     87// extern "C" { double log2( double ); }
     88long double log2( long double );
     89// float _Complex log2( float _Complex );
     90// double _Complex log2( double _Complex );
     91// long double _Complex log2( long double _Complex );
     92
     93float log10( float );
     94// extern "C" { double log10( double ); }
     95long double log10( long double );
     96// float _Complex log10( float _Complex );
     97// double _Complex log10( double _Complex );
     98// long double _Complex log10( long double _Complex );
     99
     100float log1p( float );
     101// extern "C" { double log1p( double ); }
     102long double log1p( long double );
     103
     104int ilogb( float );
     105// extern "C" { int ilogb( double ); }
     106int ilogb( long double );
     107
     108float logb( float );
     109// extern "C" { double logb( double ); }
     110long double logb( long double );
     111
     112//---------------------- Power ----------------------
     113
     114float sqrt( float );
     115// extern "C" { double sqrt( double ); }
     116long double sqrt( long double );
     117float _Complex sqrt( float _Complex );
     118double _Complex sqrt( double _Complex );
     119long double _Complex sqrt( long double _Complex );
     120
     121float cbrt( float );
     122// extern "C" { double cbrt( double ); }
     123long double cbrt( long double );
     124
     125float hypot( float, float );
     126// extern "C" { double hypot( double, double ); }
     127long double hypot( long double, long double );
     128
     129float pow( float, float );
    78130// extern "C" { double pow( double, double ); }
    79 static inline long double pow( long double x, long double y ) { return powl( x, y ); }
    80 static inline float _Complex pow( float _Complex x, float _Complex y ) { return cpowf( x, y ); }
    81 static inline double _Complex pow( double _Complex x, double _Complex y ) { return cpow( x, y ); }
    82 static inline long double _Complex pow( long double _Complex x, long double _Complex y ) { return cpowl( x, y ); }
    83 
    84 //---------------------- Logarithm ----------------------
    85 
    86 static inline float log( float x ) { return logf( x ); }
    87 // extern "C" { double log( double ); }
    88 static inline long double log( long double x ) { return logl( x ); }
    89 static inline float _Complex log( float _Complex x ) { return clogf( x ); }
    90 static inline double _Complex log( double _Complex x ) { return clog( x ); }
    91 static inline long double _Complex log( long double _Complex x ) { return clogl( x ); }
    92 
    93 static inline float log2( float x ) { return log2f( x ); }
    94 // extern "C" { double log2( double ); }
    95 static inline long double log2( long double x ) { return log2l( x ); }
    96 // static inline float _Complex log2( float _Complex x ) { return clog2f( x ); }
    97 // static inline double _Complex log2( double _Complex x ) { return clog2( x ); }
    98 // static inline long double _Complex log2( long double _Complex x ) { return clog2l( x ); }
    99 
    100 static inline float log10( float x ) { return log10f( x ); }
    101 // extern "C" { double log10( double ); }
    102 static inline long double log10( long double x ) { return log10l( x ); }
    103 // static inline float _Complex log10( float _Complex x ) { return clog10f( x ); }
    104 // static inline double _Complex log10( double _Complex x ) { return clog10( x ); }
    105 // static inline long double _Complex log10( long double _Complex x ) { return clog10l( x ); }
    106 
    107 static inline float log1p( float x ) { return log1pf( x ); }
    108 // extern "C" { double log1p( double ); }
    109 static inline long double log1p( long double x ) { return log1pl( x ); }
    110 
    111 static inline int ilogb( float x ) { return ilogbf( x ); }
    112 // extern "C" { int ilogb( double ); }
    113 static inline int ilogb( long double x ) { return ilogbl( x ); }
    114 
    115 static inline float logb( float x ) { return logbf( x ); }
    116 // extern "C" { double logb( double ); }
    117 static inline long double logb( long double x ) { return logbl( x ); }
    118 
    119 static inline float sqrt( float x ) { return sqrtf( x ); }
    120 // extern "C" { double sqrt( double ); }
    121 static inline long double sqrt( long double x ) { return sqrtl( x ); }
    122 static inline float _Complex sqrt( float _Complex x ) { return csqrtf( x ); }
    123 static inline double _Complex sqrt( double _Complex x ) { return csqrt( x ); }
    124 static inline long double _Complex sqrt( long double _Complex x ) { return csqrtl( x ); }
    125 
    126 static inline float cbrt( float x ) { return cbrtf( x ); }
    127 // extern "C" { double cbrt( double ); }
    128 static inline long double cbrt( long double x ) { return cbrtl( x ); }
    129 
    130 static inline float hypot( float x, float y ) { return hypotf( x, y ); }
    131 // extern "C" { double hypot( double, double ); }
    132 static inline long double hypot( long double x, long double y ) { return hypotl( x, y ); }
     131long double pow( long double, long double );
     132float _Complex pow( float _Complex, float _Complex );
     133double _Complex pow( double _Complex, double _Complex );
     134long double _Complex pow( long double _Complex, long double _Complex );
    133135
    134136//---------------------- Trigonometric ----------------------
    135137
    136 static inline float sin( float x ) { return sinf( x ); }
     138float sin( float );
    137139// extern "C" { double sin( double ); }
    138 static inline long double sin( long double x ) { return sinl( x ); }
    139 static inline float _Complex sin( float _Complex x ) { return csinf( x ); }
    140 static inline double _Complex sin( double _Complex x ) { return csin( x ); }
    141 static inline long double _Complex sin( long double _Complex x ) { return csinl( x ); }
    142 
    143 static inline float cos( float x ) { return cosf( x ); }
     140long double sin( long double );
     141float _Complex sin( float _Complex );
     142double _Complex sin( double _Complex );
     143long double _Complex sin( long double _Complex );
     144
     145float cos( float );
    144146// extern "C" { double cos( double ); }
    145 static inline long double cos( long double x ) { return cosl( x ); }
    146 static inline float _Complex cos( float _Complex x ) { return ccosf( x ); }
    147 static inline double _Complex cos( double _Complex x ) { return ccos( x ); }
    148 static inline long double _Complex cos( long double _Complex x ) { return ccosl( x ); }
    149 
    150 static inline float tan( float x ) { return tanf( x ); }
     147long double cos( long double );
     148float _Complex cos( float _Complex );
     149double _Complex cos( double _Complex );
     150long double _Complex cos( long double _Complex );
     151
     152float tan( float );
    151153// extern "C" { double tan( double ); }
    152 static inline long double tan( long double x ) { return tanl( x ); }
    153 static inline float _Complex tan( float _Complex x ) { return ctanf( x ); }
    154 static inline double _Complex tan( double _Complex x ) { return ctan( x ); }
    155 static inline long double _Complex tan( long double _Complex x ) { return ctanl( x ); }
    156 
    157 static inline float asin( float x ) { return asinf( x ); }
     154long double tan( long double );
     155float _Complex tan( float _Complex );
     156double _Complex tan( double _Complex );
     157long double _Complex tan( long double _Complex );
     158
     159float asin( float );
    158160// extern "C" { double asin( double ); }
    159 static inline long double asin( long double x ) { return asinl( x ); }
    160 static inline float _Complex asin( float _Complex x ) { return casinf( x ); }
    161 static inline double _Complex asin( double _Complex x ) { return casin( x ); }
    162 static inline long double _Complex asin( long double _Complex x ) { return casinl( x ); }
    163 
    164 static inline float acos( float x ) { return acosf( x ); }
     161long double asin( long double );
     162float _Complex asin( float _Complex );
     163double _Complex asin( double _Complex );
     164long double _Complex asin( long double _Complex );
     165
     166float acos( float );
    165167// extern "C" { double acos( double ); }
    166 static inline long double acos( long double x ) { return acosl( x ); }
    167 static inline float _Complex acos( float _Complex x ) { return cacosf( x ); }
    168 static inline double _Complex acos( double _Complex x ) { return cacos( x ); }
    169 static inline long double _Complex acos( long double _Complex x ) { return cacosl( x ); }
    170 
    171 static inline float atan( float x ) { return atanf( x ); }
     168long double acos( long double );
     169float _Complex acos( float _Complex );
     170double _Complex acos( double _Complex );
     171long double _Complex acos( long double _Complex );
     172
     173float atan( float );
    172174// extern "C" { double atan( double ); }
    173 static inline long double atan( long double x ) { return atanl( x ); }
    174 static inline float _Complex atan( float _Complex x ) { return catanf( x ); }
    175 static inline double _Complex atan( double _Complex x ) { return catan( x ); }
    176 static inline long double _Complex atan( long double _Complex x ) { return catanl( x ); }
    177 
    178 static inline float atan2( float x, float y ) { return atan2f( x, y ); }
     175long double atan( long double );
     176float _Complex atan( float _Complex );
     177double _Complex atan( double _Complex );
     178long double _Complex atan( long double _Complex );
     179
     180float atan2( float, float );
    179181// extern "C" { double atan2( double, double ); }
    180 static inline long double atan2( long double x, long double y ) { return atan2l( x, y ); }
    181 
    182 // alternative name for atan2
    183 static inline float atan( float x, float y ) { return atan2f( x, y ); }
    184 static inline double atan( double x, double y ) { return atan2( x, y ); }
    185 static inline long double atan( long double x, long double y ) { return atan2l( x, y ); }
     182long double atan2( long double, long double );
     183
     184float atan( float, float );                                                             // alternative name for atan2
     185double atan( double, double );
     186long double atan( long double, long double );
    186187
    187188//---------------------- Hyperbolic ----------------------
    188189
    189 static inline float sinh( float x ) { return sinhf( x ); }
     190float sinh( float );
    190191// extern "C" { double sinh( double ); }
    191 static inline long double sinh( long double x ) { return sinhl( x ); }
    192 static inline float _Complex sinh( float _Complex x ) { return csinhf( x ); }
    193 static inline double _Complex sinh( double _Complex x ) { return csinh( x ); }
    194 static inline long double _Complex sinh( long double _Complex x ) { return csinhl( x ); }
    195 
    196 static inline float cosh( float x ) { return coshf( x ); }
     192long double sinh( long double );
     193float _Complex sinh( float _Complex );
     194double _Complex sinh( double _Complex );
     195long double _Complex sinh( long double _Complex );
     196
     197float cosh( float );
    197198// extern "C" { double cosh( double ); }
    198 static inline long double cosh( long double x ) { return coshl( x ); }
    199 static inline float _Complex cosh( float _Complex x ) { return ccoshf( x ); }
    200 static inline double _Complex cosh( double _Complex x ) { return ccosh( x ); }
    201 static inline long double _Complex cosh( long double _Complex x ) { return ccoshl( x ); }
    202 
    203 static inline float tanh( float x ) { return tanhf( x ); }
     199long double cosh( long double );
     200float _Complex cosh( float _Complex );
     201double _Complex cosh( double _Complex );
     202long double _Complex cosh( long double _Complex );
     203
     204float tanh( float );
    204205// extern "C" { double tanh( double ); }
    205 static inline long double tanh( long double x ) { return tanhl( x ); }
    206 static inline float _Complex tanh( float _Complex x ) { return ctanhf( x ); }
    207 static inline double _Complex tanh( double _Complex x ) { return ctanh( x ); }
    208 static inline long double _Complex tanh( long double _Complex x ) { return ctanhl( x ); }
    209 
    210 static inline float asinh( float x ) { return asinhf( x ); }
     206long double tanh( long double );
     207float _Complex tanh( float _Complex );
     208double _Complex tanh( double _Complex );
     209long double _Complex tanh( long double _Complex );
     210
     211float asinh( float );
    211212// extern "C" { double asinh( double ); }
    212 static inline long double asinh( long double x ) { return asinhl( x ); }
    213 static inline float _Complex asinh( float _Complex x ) { return casinhf( x ); }
    214 static inline double _Complex asinh( double _Complex x ) { return casinh( x ); }
    215 static inline long double _Complex asinh( long double _Complex x ) { return casinhl( x ); }
    216 
    217 static inline float acosh( float x ) { return acoshf( x ); }
     213long double asinh( long double );
     214float _Complex asinh( float _Complex );
     215double _Complex asinh( double _Complex );
     216long double _Complex asinh( long double _Complex );
     217
     218float acosh( float );
    218219// extern "C" { double acosh( double ); }
    219 static inline long double acosh( long double x ) { return acoshl( x ); }
    220 static inline float _Complex acosh( float _Complex x ) { return cacoshf( x ); }
    221 static inline double _Complex acosh( double _Complex x ) { return cacosh( x ); }
    222 static inline long double _Complex acosh( long double _Complex x ) { return cacoshl( x ); }
    223 
    224 static inline float atanh( float x ) { return atanhf( x ); }
     220long double acosh( long double );
     221float _Complex acosh( float _Complex );
     222double _Complex acosh( double _Complex );
     223long double _Complex acosh( long double _Complex );
     224
     225float atanh( float );
    225226// extern "C" { double atanh( double ); }
    226 static inline long double atanh( long double x ) { return atanhl( x ); }
    227 static inline float _Complex atanh( float _Complex x ) { return catanhf( x ); }
    228 static inline double _Complex atanh( double _Complex x ) { return catanh( x ); }
    229 static inline long double _Complex atanh( long double _Complex x ) { return catanhl( x ); }
     227long double atanh( long double );
     228float _Complex atanh( float _Complex );
     229double _Complex atanh( double _Complex );
     230long double _Complex atanh( long double _Complex );
    230231
    231232//---------------------- Error / Gamma ----------------------
    232233
    233 static inline float erf( float x ) { return erff( x ); }
     234float erf( float );
    234235// extern "C" { double erf( double ); }
    235 static inline long double erf( long double x ) { return erfl( x ); }
     236long double erf( long double );
    236237// float _Complex erf( float _Complex );
    237238// double _Complex erf( double _Complex );
    238239// long double _Complex erf( long double _Complex );
    239240
    240 static inline float erfc( float x ) { return erfcf( x ); }
     241float erfc( float );
    241242// extern "C" { double erfc( double ); }
    242 static inline long double erfc( long double x ) { return erfcl( x ); }
     243long double erfc( long double );
    243244// float _Complex erfc( float _Complex );
    244245// double _Complex erfc( double _Complex );
    245246// long double _Complex erfc( long double _Complex );
    246247
    247 static inline float lgamma( float x ) { return lgammaf( x ); }
     248float lgamma( float );
    248249// extern "C" { double lgamma( double ); }
    249 static inline long double lgamma( long double x ) { return lgammal( x ); }
    250 static inline float lgamma( float x, int * sign ) { return lgammaf_r( x, sign ); }
    251 static inline double lgamma( double x, int * sign ) { return lgamma_r( x, sign ); }
    252 static inline long double lgamma( long double x, int * sign ) { return lgammal_r( x, sign ); }
    253 
    254 static inline float tgamma( float x ) { return tgammaf( x ); }
     250long double lgamma( long double );
     251float lgamma( float, int * );
     252double lgamma( double, int * );
     253long double lgamma( long double, int * );
     254
     255float tgamma( float );
    255256// extern "C" { double tgamma( double ); }
    256 static inline long double tgamma( long double x ) { return tgammal( x ); }
     257long double tgamma( long double );
    257258
    258259//---------------------- Nearest Integer ----------------------
    259260
    260 static inline float floor( float x ) { return floorf( x ); }
     261float floor( float );
    261262// extern "C" { double floor( double ); }
    262 static inline long double floor( long double x ) { return floorl( x ); }
    263 
    264 static inline float ceil( float x ) { return ceilf( x ); }
     263long double floor( long double );
     264
     265float ceil( float );
    265266// extern "C" { double ceil( double ); }
    266 static inline long double ceil( long double x ) { return ceill( x ); }
    267 
    268 static inline float trunc( float x ) { return truncf( x ); }
     267long double ceil( long double );
     268
     269float trunc( float );
    269270// extern "C" { double trunc( double ); }
    270 static inline long double trunc( long double x ) { return truncl( x ); }
    271 
    272 static inline float rint( float x ) { return rintf( x ); }
    273 // extern "C" { double rint( double x ); }
    274 static inline long double rint( long double x ) { return rintl( x ); }
    275 static inline long int rint( float x ) { return lrintf( x ); }
    276 static inline long int rint( double x ) { return lrint( x ); }
    277 static inline long int rint( long double x ) { return lrintl( x ); }
    278 static inline long long int rint( float x ) { return llrintf( x ); }
    279 static inline long long int rint( double x ) { return llrint( x ); }
    280 static inline long long int rint( long double x ) { return llrintl( x ); }
    281 
    282 static inline long int lrint( float x ) { return lrintf( x ); }
     271long double trunc( long double );
     272
     273float rint( float );
     274long double rint( long double );
     275long int rint( float );
     276long int rint( double );
     277long int rint( long double );
     278long long int rint( float );
     279long long int rint( double );
     280long long int rint( long double );
     281
     282long int lrint( float );
    283283// extern "C" { long int lrint( double ); }
    284 static inline long int lrint( long double x ) { return lrintl( x ); }
    285 static inline long long int llrint( float x ) { return llrintf( x ); }
     284long int lrint( long double );
     285long long int llrint( float );
    286286// extern "C" { long long int llrint( double ); }
    287 static inline long long int llrint( long double x ) { return llrintl( x ); }
    288 
    289 static inline float nearbyint( float x ) { return nearbyintf( x ); }
     287long long int llrint( long double );
     288
     289float nearbyint( float );
    290290// extern "C" { double nearbyint( double ); }
    291 static inline long double nearbyint( long double x ) { return nearbyintl( x ); }
    292 
    293 static inline float round( float x ) { return roundf( x ); }
    294 // extern "C" { double round( double x ); }
    295 static inline long double round( long double x ) { return roundl( x ); }
    296 static inline long int round( float x ) { return lroundf( x ); }
    297 static inline long int round( double x ) { return lround( x ); }
    298 static inline long int round( long double x ) { return lroundl( x ); }
    299 static inline long long int round( float x ) { return llroundf( x ); }
    300 static inline long long int round( double x ) { return llround( x ); }
    301 static inline long long int round( long double x ) { return llroundl( x ); }
    302 
    303 static inline long int lround( float x ) { return lroundf( x ); }
     291long double nearbyint( long double );
     292
     293float round( float );
     294long double round( long double );
     295long int round( float );
     296long int round( double );
     297long int round( long double );
     298long long int round( float );
     299long long int round( double );
     300long long int round( long double );
     301
     302long int lround( float );
    304303// extern "C" { long int lround( double ); }
    305 static inline long int lround( long double x ) { return lroundl( x ); }
    306 static inline long long int llround( float x ) { return llroundf( x ); }
     304long int lround( long double );
     305long long int llround( float );
    307306// extern "C" { long long int llround( double ); }
    308 static inline long long int llround( long double x ) { return llroundl( x ); }
     307long long int llround( long double );
    309308
    310309//---------------------- Manipulation ----------------------
    311310
    312 static inline float copysign( float x, float y ) { return copysignf( x, y ); }
     311float copysign( float, float );
    313312// extern "C" { double copysign( double, double ); }
    314 static inline long double copysign( long double x, long double y ) { return copysignl( x, y ); }
    315 
    316 static inline float frexp( float x, int * ip ) { return frexpf( x, ip ); }
     313long double copysign( long double, long double );
     314
     315float frexp( float, int * );
    317316// extern "C" { double frexp( double, int * ); }
    318 static inline long double frexp( long double x, int * ip ) { return frexpl( x, ip ); }
    319 
    320 static inline float ldexp( float x, int exp2 ) { return ldexpf( x, exp2 ); }
     317long double frexp( long double, int * );
     318
     319float ldexp( float, int );
    321320// extern "C" { double ldexp( double, int ); }
    322 static inline long double ldexp( long double x, int exp2 ) { return ldexpl( x, exp2 ); }
    323 
    324 static inline [ float, float ] modf( float x ) { float i; x = modff( x, &i ); return [ i, x ]; }
    325 static inline float modf( float x, float * i ) { return modff( x, i ); }
    326 static inline [ double, double ] modf( double x ) { double i; x = modf( x, &i ); return [ i, x ]; }
     321long double ldexp( long double, int );
     322
     323[ float, float ] modf( float );
     324float modf( float, float * );
     325[ double, double ] modf( double );
    327326// extern "C" { double modf( double, double * ); }
    328 static inline [ long double, long double ] modf( long double x ) { long double i; x = modfl( x, &i ); return [ i, x ]; }
    329 static inline long double modf( long double x, long double * i ) { return modfl( x, i ); }
    330 
    331 static inline float nextafter( float x, float y ) { return nextafterf( x, y ); }
     327[ long double, long double ] modf( long double );
     328long double modf( long double, long double * );
     329
     330float nextafter( float, float );
    332331// extern "C" { double nextafter( double, double ); }
    333 static inline long double nextafter( long double x, long double y ) { return nextafterl( x, y ); }
    334 
    335 static inline float nexttoward( float x, long double y ) { return nexttowardf( x, y ); }
     332long double nextafter( long double, long double );
     333
     334float nexttoward( float, long double );
    336335// extern "C" { double nexttoward( double, long double ); }
    337 static inline long double nexttoward( long double x, long double y ) { return nexttowardl( x, y ); }
    338 
    339 static inline float scalbn( float x, int exp ) { return scalbnf( x, exp ); }
     336long double nexttoward( long double, long double );
     337
     338float scalbn( float, int );
    340339// extern "C" { double scalbn( double, int ); }
    341 static inline long double scalbn( long double x, int exp ) { return scalbnl( x, exp ); }
    342 static inline float scalbn( float x, long int exp ) { return scalblnf( x, exp ); }
    343 static inline double scalbn( double x, long int exp ) { return scalbln( x, exp ); }
    344 static inline long double scalbn( long double x, long int exp ) { return scalblnl( x, exp ); }
    345 
    346 static inline float scalbln( float x, long int exp ) { return scalblnf( x, exp ); }
     340long double scalbn( long double, int );
     341
     342float scalbln( float, long int );
    347343// extern "C" { double scalbln( double, long int ); }
    348 static inline long double scalbln( long double x, long int exp ) { return scalblnl( x, exp ); }
     344long double scalbln( long double, long int );
    349345
    350346// Local Variables: //
  • src/libcfa/startup.h

    r0720e049 r3d4b23fa  
     1//                              -*- Mode: CFA -*-
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    910// Author           : Thierry Delisle
    1011// Created On       : Wed Mar 29 15:56:41 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 20 21:37:11 2017
    13 // Update Count     : 2
     12// Last Modified By :
     13// Last Modified On :
     14// Update Count     : 0
    1415//
    1516
    16 #pragma once
     17#ifndef STARTUP_H
     18#define STARTUP_H
    1719
    1820#if GCC_VERSION > 50000
     
    3234#endif
    3335
    34 // Local Variables: //
    35 // mode: c //
    36 // tab-width: 4 //
    37 // End: //
     36#endif //STARTUP_H
  • src/libcfa/stdhdr/assert.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Mon Jul  4 23:25:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jul 31 23:09:32 2017
    13 // Update Count     : 13
     12// Last Modified On : Tue Jul  5 20:34:23 2016
     13// Update Count     : 8
    1414//
    1515
     
    1818#endif //__CFORALL__
    1919
     20// has internal check for multiple expansion
    2021#include_next <assert.h>
    21 
    22 #ifdef NDEBUG
    23         #define assertf( expr, fmt, ... ) ((void)0)
    24 #else
    25         #define __STRINGIFY__(str) #str
    26         #define __VSTRINGIFY__(str) __STRINGIFY__(str)
    27         #define assertf( expr, fmt, ... ) ((expr) ? ((void)0) : __assert_fail_f(__VSTRINGIFY__(expr), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, ## __VA_ARGS__ ))
    28 
    29         void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) __attribute__((noreturn, format( printf, 5, 6) ));
    30 #endif
    3122
    3223#ifdef __CFORALL__
  • src/libcfa/stdhdr/gmp.h

    r0720e049 r3d4b23fa  
     1//                               -*- Mode: C -*-
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    1011// Created On       : Sun May 14 23:46:01 2017
    1112// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 20 18:10:52 2017
    13 // Update Count     : 4
     13// Last Modified On : Sun May 14 23:46:34 2017
     14// Update Count     : 1
    1415//
    1516
  • src/libcfa/stdlib

    r0720e049 r3d4b23fa  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Aug  7 11:19:07 2017
    13 // Update Count     : 223
     12// Last Modified On : Fri Jul  7 09:34:49 2017
     13// Update Count     : 219
    1414//
    1515
     
    1818//---------------------------------------
    1919
     20extern "C" {
    2021#ifndef EXIT_FAILURE
    2122#define EXIT_FAILURE    1                                                               // failing exit status
    2223#define EXIT_SUCCESS    0                                                               // successful exit status
    2324#endif // ! EXIT_FAILURE
     25} // extern "C"
    2426
    2527//---------------------------------------
     
    183185//---------------------------------------
    184186
    185 [ int, int ] div( int num, int denom );
    186 [ long int, long int ] div( long int num, long int denom );
    187 [ long long int, long long int ] div( long long int num, long long int denom );
    188187forall( otype T | { T ?/?( T, T ); T ?%?( T, T ); } )
    189 [ T, T ] div( T num, T demon );
     188[ T, T ] div( T t1, T t2 );
    190189
    191190//---------------------------------------
  • src/libcfa/stdlib.c

    r0720e049 r3d4b23fa  
    1010// Created On       : Thu Jan 28 17:10:29 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Aug  8 17:31:13 2017
    13 // Update Count     : 291
     12// Last Modified On : Thu Jun  1 21:52:57 2017
     13// Update Count     : 280
    1414//
    1515
     
    1818//---------------------------------------
    1919
     20extern "C" {
    2021#define _XOPEN_SOURCE 600                                                               // posix_memalign, *rand48
    2122#include <stdlib.h>                                                                             // malloc, free, calloc, realloc, memalign, posix_memalign, bsearch
     
    2425#include <math.h>                                                                               // fabsf, fabs, fabsl
    2526#include <complex.h>                                                                    // _Complex_I
     27} // extern "C"
    2628
    2729// resize, non-array types
     
    255257//---------------------------------------
    256258
    257 [ int, int ] div( int num, int denom ) { div_t qr = div( num, denom ); return [ qr.quot, qr.rem ]; }
    258 [ long int, long int ] div( long int num, long int denom ) { ldiv_t qr = ldiv( num, denom ); return [ qr.quot, qr.rem ]; }
    259 [ long long int, long long int ] div( long long int num, long long int denom ) { lldiv_t qr = lldiv( num, denom ); return [ qr.quot, qr.rem ]; }
    260259forall( otype T | { T ?/?( T, T ); T ?%?( T, T ); } )
    261 [ T, T ] div( T num, T denom ) { return [ num / denom, num % denom ]; }
     260[ T, T ] div( T t1, T t2 ) { return [ t1 / t2, t1 % t2 ]; }
    262261
    263262//---------------------------------------
  • src/main.cc

    r0720e049 r3d4b23fa  
    1111// Created On       : Fri May 15 23:12:02 2015
    1212// Last Modified By : Andrew Beach
    13 // Last Modified On : Wed Jul 26 14:38:00 2017
    14 // Update Count     : 443
     13// Last Modified On : Fri Jul  7 11:13:00 2017
     14// Update Count     : 442
    1515//
    1616
     
    5858#include "SynTree/Visitor.h"                // for acceptAll
    5959#include "Tuples/Tuples.h"                  // for expandMemberTuples, expan...
    60 #include "Virtual/ExpandCasts.h"            // for expandCasts
    6160
    6261using namespace std;
     
    314313                }
    315314
    316                 OPTPRINT( "virtual expandCasts" ) // Must come after translateEHM
    317                 Virtual::expandCasts( translationUnit );
    318 
    319315                OPTPRINT("instantiateGenerics")
    320316                GenPoly::instantiateGeneric( translationUnit );
  • src/prelude/builtins.c

    r0720e049 r3d4b23fa  
    1 //
    2 // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
    3 //
    4 // The contents of this file are covered under the licence agreement in the
    5 // file "LICENCE" distributed with Cforall.
    6 //
    7 // builtins.c --
    8 //
    9 // Author           : Peter A. Buhr
    10 // Created On       : Fri Jul 21 16:21:03 2017
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Tus Jul 25 15:33:00 2017
    13 // Update Count     : 14
    14 //
    15 
    16 // exception implementation
    17 
    181typedef unsigned long long __cfaabi_exception_type_t;
    192
    20 #include "../libcfa/virtual.h"
    213#include "../libcfa/exception.h"
    22 
    23 // exponentiation operator implementation
    24 
    25 extern "C" {
    26         float powf( float x, float y );
    27         double pow( double x, double y );
    28         long double powl( long double x, long double y );
    29         float _Complex cpowf( float _Complex x, _Complex float z );
    30         double _Complex cpow( double _Complex x, _Complex double z );
    31         long double _Complex cpowl( long double _Complex x, _Complex long double z );
    32 } // extern "C"
    33 
    34 static inline float ?\?( float x, float y ) { return powf( x, y ); }
    35 static inline double ?\?( double x, double y ) { return pow( x, y ); }
    36 static inline long double ?\?( long double x, long double y ) { return powl( x, y ); }
    37 static inline float _Complex ?\?( float _Complex x, _Complex float y ) { return cpowf(x, y ); }
    38 static inline double _Complex ?\?( double _Complex x, _Complex double y ) { return cpow( x, y ); }
    39 static inline long double _Complex ?\?( long double _Complex x, _Complex long double y ) { return cpowl( x, y ); }
    40 
    41 static inline long int ?\?( long int ep, unsigned long int y ) { // disallow negative exponent
    42         if ( y == 0 ) return 1;                                                         // base case
    43     if ( ep == 2 ) return ep << (y - 1);                                // special case, positive shifting only
    44     typeof( ep ) op = 1;                                                                // accumulate odd product
    45     for ( ; y > 1; y >>= 1 ) {                                                  // squaring exponentiation, O(log2 y)
    46                 if ( (y & 1) == 1 ) op *= ep;                                   // odd ?
    47                 ep *= ep;
    48         } // for
    49     return ep * op;
    50 } // ?\?
    51 
    52 // FIX ME, cannot resolve the "T op = 1".
    53 
    54 // static inline forall( otype T | { void ?{}( T * this, one_t ); T ?*?( T, T ); } )
    55 // T ?\?( T ep, unsigned long int y ) {
    56 //     if ( y == 0 ) return 1;
    57 //     T op = 1;
    58 //     for ( ; y > 1; y >>= 1 ) {                                                       // squaring exponentiation, O(log2 y)
    59 //              if ( (y & 1) == 1 ) op = op * ep;                               // odd ?
    60 //              ep = ep * ep;
    61 //     } // for
    62 //     return ep * op;
    63 // } // ?\?
    64 
    65 // unsigned computation may be faster and larger
    66 static inline unsigned long int ?\?( unsigned long int ep, unsigned long int y ) { // disallow negative exponent
    67         if ( y == 0 ) return 1;                                                         // base case
    68     if ( ep == 2 ) return ep << (y - 1);                                // special case, positive shifting only
    69     typeof( ep ) op = 1;                                                                // accumulate odd product
    70     for ( ; y > 1; y >>= 1 ) {                                                  // squaring exponentiation, O(log2 y)
    71                 if ( (y & 1) == 1 ) op *= ep;                                   // odd ?
    72                 ep *= ep;
    73         } // for
    74     return ep * op;
    75 } // ?\?
    76 
    77 static inline double ?\?( long int x, signed long int y ) {     // allow negative exponent
    78     if ( y >=  0 ) return (double)(x \ (unsigned long int)y);
    79     else return 1.0 / x \ (unsigned int)(-y);
    80 } // ?\?
    81 
    82 static inline forall( otype T | { void ?{}( T * this, one_t ); T ?*?( T, T ); double ?/?( double, T ); } )
    83 double ?\?( T x, signed long int y ) {
    84     if ( y >=  0 ) return (double)(x \ (unsigned long int)y);
    85     else return 1.0 / x \ (unsigned long int)(-y);
    86 } // ?\?
    87 
    88 static inline long int ?\=?( long int * x, unsigned long int y ) { *x = *x \ y; return *x; }
    89 static inline unsigned long int ?\=?( unsigned long int * x, unsigned long int y ) { *x = *x \ y; return *x; }
    90 static inline int ?\=?( int * x, unsigned long int y ) { *x = *x \ y; return *x; }
    91 static inline unsigned int ?\=?( unsigned int * x, unsigned long int y ) { *x = *x \ y; return *x; }
    92 
    93 // Local Variables: //
    94 // mode: c //
    95 // tab-width: 4 //
    96 // End: //
  • src/tests/.expect/32/math.txt

    r0720e049 r3d4b23fa  
    22remainder:-1 -1 -1
    33remquo:7 0.0999999 7 0.1 7 0.0999999999999999999
    4 div:7, 0.2 7, 0.2 7, 0.2
     4div:7 0.0999999 7 0.1 7 0.0999999999999999999
    55fma:-2 -2 -2
    66fdim:2 2 2
     
    99exp2:2 2 2
    1010expm1:1.71828 1.71828182845905 1.71828182845904524
    11 pow:1 1 1 0.273957+0.583701i 0.273957253830121+0.583700758758615i 0.273957253830121071+0.583700758758614628i
    12 16 256
    13 912673 256 64 -64 0.015625 -0.015625 18.3791736799526 0.264715-1.1922i
    1411log:0 0 0 0.346574+0.785398i 0.346573590279973+0.785398163397448i 0.346573590279972655+0.78539816339744831i
    1512log2:3 3 3
     
    2118cbrt:3 3 3
    2219hypot:1.41421 1.4142135623731 1.41421356237309505
     20pow:1 1 1 0.273957+0.583701i 0.273957253830121+0.583700758758615i 0.273957253830121071+0.583700758758614628i
    2321sin:0.841471 0.841470984807897 0.841470984807896507 1.29846+0.634964i 1.29845758141598+0.634963914784736i 1.29845758141597729+0.634963914784736108i
    2422cos:0.540302 0.54030230586814 0.540302305868139717 0.83373-0.988898i 0.833730025131149-0.988897705762865i 0.833730025131149049-0.988897705762865096i
     
    5553frexp:0.5 3 0.5 3 0.5 3
    5654ldexp:8 8 8
    57 modf:2 0.3 2 0.3 2 0.3
    58 modf:2, 0.3 2, 0.3 2, 0.3
    59 nextafter:2 2 2
     55modf:2 0.3 2 0.3 2 0.3 nextafter:2 2 2
    6056nexttoward:2 2 2
    6157scalbn:16 16 16
  • src/tests/.expect/64/math.txt

    r0720e049 r3d4b23fa  
    22remainder:-1 -1 -1
    33remquo:7 0.0999999 7 0.1 7 0.0999999999999999999
    4 div:7, 0.2 7, 0.2 7, 0.2
     4div:7 0.0999999 7 0.1 7 0.0999999999999999999
    55fma:-2 -2 -2
    66fdim:2 2 2
     
    99exp2:2 2 2
    1010expm1:1.71828 1.71828182845905 1.71828182845904524
    11 pow:1 1 1 0.273957+0.583701i 0.273957253830121+0.583700758758615i 0.273957253830121071+0.583700758758614627i
    12 16 256
    13 912673 256 64 -64 0.015625 -0.015625 18.3791736799526 0.264715-1.1922i
    1411log:0 0 0 0.346574+0.785398i 0.346573590279973+0.785398163397448i 0.346573590279972655+0.78539816339744831i
    1512log2:3 3 3
     
    2118cbrt:3 3 3
    2219hypot:1.41421 1.4142135623731 1.41421356237309505
     20pow:1 1 1 0.273957+0.583701i 0.273957253830121+0.583700758758615i 0.273957253830121071+0.583700758758614628i
    2321sin:0.841471 0.841470984807897 0.841470984807896507 1.29846+0.634964i 1.29845758141598+0.634963914784736i 1.29845758141597729+0.634963914784736108i
    2422cos:0.540302 0.54030230586814 0.540302305868139717 0.83373-0.988898i 0.833730025131149-0.988897705762865i 0.833730025131149049-0.988897705762865096i
     
    5553frexp:0.5 3 0.5 3 0.5 3
    5654ldexp:8 8 8
    57 modf:2 0.3 2 0.3 2 0.3
    58 modf:2, 0.3 2, 0.3 2, 0.3
    59 nextafter:2 2 2
     55modf:2 0.3 2 0.3 2 0.3 nextafter:2 2 2
    6056nexttoward:2 2 2
    6157scalbn:16 16 16
  • src/tests/alloc.c

    r0720e049 r3d4b23fa  
    1010// Created On       : Wed Feb  3 07:56:22 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 20 16:01:10 2017
    13 // Update Count     : 318
     12// Last Modified On : Fri Jun  2 15:13:03 2017
     13// Update Count     : 316
    1414//
    1515
    16 #include <assert.h>
     16#include <assert>
     17extern "C" {
    1718#include <malloc.h>                                                                             // malloc_usable_size
    1819#include <stdint.h>                                                                             // uintptr_t
    1920#include <stdlib.h>                                                                             // posix_memalign
     21} // extern
    2022#include <fstream>
    2123#include <stdlib>                                                                               // access C malloc, realloc
  • src/tests/attributes.c

    r0720e049 r3d4b23fa  
     1//                               -*- Mode: C -*-
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
     
    1011// Created On       : Mon Feb  6 16:07:02 2017
    1112// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 23:05:52 2017
    13 // Update Count     : 3
     13// Last Modified On : Mon Feb  6 16:08:21 2017
     14// Update Count     : 2
    1415//
    1516
  • src/tests/avltree/avl-private.h

    r0720e049 r3d4b23fa  
    1 #pragma once
     1#ifndef AVL_PRIVATE_H
    22#include "avl.h"
    33
     
    1414forall(otype K | Comparable(K), otype V)
    1515int height(tree(K, V) * t);
     16
     17#endif
  • src/tests/avltree/avl.h

    r0720e049 r3d4b23fa  
    1 #pragma once
     1#ifndef AVL_TREE_H
     2#define AVL_TREE_H
    23
    34extern "C" {
     
    103104//     printTree(t, 0);
    104105// }
     106
     107
     108#endif
  • src/tests/designations.c

    r0720e049 r3d4b23fa  
    99// Author           : Rob Schluntz
    1010// Created On       : Thu Jun 29 15:26:36 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 27 11:46:35 2017
    13 // Update Count     : 3
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Thu Jun 29 15:27:05 2017
     13// Update Count     : 2
    1414//
    1515
     
    8989};
    9090
    91 struct Fred {
    92     double i[3];
    93     int j;
    94     struct Mary {
    95         struct Jane {
    96             double j;
    97         } j;
    98         double i;
    99     } m;
    100 };
    101 struct Fred s1 @= { .m.j : 3 };
    102 struct Fred s2 @= { .i : { [2] : 2 } };
    103 
    10491int main() {
    10592        // simple designation case - starting from beginning of structure, leaves ptr default-initialized (zero)
     
    212199        };
    213200#endif
    214         // array designation
    215         int i[2] = { [1] : 3 };
     201
    216202        // allowed to have 'too many' initialized lists - essentially they are ignored.
    217203        int i1 = { 3 };
     
    254240        const char * str0 = "hello";
    255241        char str1[] = "hello";
    256         const char c1[] = "abc";
    257         const char c2[] = { 'a', 'b', 'c' };
    258         const char c3[][2] = { { 'a', 'b' }, { 'c', 'd'}, { 'c', 'd'} };
    259242}
    260243
  • src/tests/except-0.c

    r0720e049 r3d4b23fa  
    66#include <stdbool.h>
    77
    8 // Local type to mark exits from scopes. (see ERROR)
    98struct signal_exit {
    109        const char * area;
     
    2019}
    2120
    22 
    23 // Local Exception Types and manual vtable types.
    24 //#define TRIVIAL_EXCEPTION(name) //TRIVAL_EXCEPTION(yin)
    25 struct yin;
    26 struct yin_vtable {
    27         struct exception_t_vtable const * parent;
    28         size_t size;
    29     void (*copy)(yin *this, yin * other);
    30     void (*free)(yin *this);
    31     const char (*msg)(yin *this);
    32 };
    33 struct yin {
    34         struct yin_vtable const * parent;
    35 };
    36 void yin_msg(yin) {
    37         return "in";
    38 }
    39 yin_vtable _yin_vtable_instance = {
    40         &_exception_t_vtable_instance, sizeof(yin), ?{}, ^?{}, yin_msg
    41 }
    42 
    43 
    44 void terminate(exception * except_value) {
     21void terminate(int except_value) {
    4522        signal_exit a = {"terminate function"};
    4623        throw except_value;
     
    4825}
    4926
    50 void resume(exception * except_value) {
     27void resume(int except_value) {
    5128        signal_exit a = {"resume function"};
    5229        throwResume except_value;
  • src/tests/gmp.c

    r0720e049 r3d4b23fa  
    1010// Created On       : Tue Apr 19 08:55:51 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 13 16:35:01 2017
    13 // Update Count     : 541
     12// Last Modified On : Wed May 24 22:05:38 2017
     13// Update Count     : 540
    1414//
    1515
     
    9595// Local Variables: //
    9696// tab-width: 4 //
    97 // compile-command: "cfa gmp.c -lgmp" //
     97// compile-command: "cfa gmp.c -l gmp" //
    9898// End: //
  • src/tests/math.c

    r0720e049 r3d4b23fa  
    1010// Created On       : Fri Apr 22 14:59:21 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug  9 07:20:49 2017
    13 // Update Count     : 77
     12// Last Modified On : Wed May 24 13:04:33 2017
     13// Update Count     : 71
    1414//
    1515
     
    3131        l = remquo( 3.6L, 0.5L, &quot );
    3232        sout | quot | l | endl;
    33         sout | "div:" | div( 3.6F, 0.5F ) | div( 3.6D, 0.5D ) | div( 3.6L, 0.5L ) | endl;
     33        f = div( 3.6F, 0.5F, &quot );
     34        sout | "div:" | quot | f;
     35        d = div( 3.6D, 0.5F, &quot );
     36        sout | quot | d;
     37        l = div( 3.6L, 0.5L, &quot );
     38        sout | quot | l | endl;
    3439        sout | "fma:" | fma( 3.0F, -1.0F, 1.0F ) | fma( 3.0D, -1.0D, 1.0D ) | fma( 3.0L, -1.0L, , 1.0L ) | endl;
    3540        sout | "fdim:" | fdim( 1.0F, -1.0F ) | fdim( 1.0D, -1.0D ) | fdim( 1.0L, -1.0L ) | endl;
     
    4146        sout | "exp2:" | exp2( 1.0F ) | exp2( 1.0D ) | exp2( 1.0L ) | endl;
    4247        sout | "expm1:" | expm1( 1.0F ) | expm1( 1.0D ) | expm1( 1.0L ) | endl;
    43         sout | "pow:" | pow( 1.0F, 1.0F ) | pow( 1.0D, 1.0D ) | pow( 1.0L, 1.0L ) | pow( 1.0F+1.0FI, 1.0F+1.0FI ) | pow( 1.0D+1.0DI, 1.0D+1.0DI ) | pow( 1.0DL+1.0LI, 1.0DL+1.0LI ) | endl;
    44 
    45         int b = 4;
    46         unsigned int e = 2;
    47     b \= e;
    48     sout | b | b \ e | endl;
    49     sout | 'a' \ 3u | 2 \ 8u | 4 \ 3u | -4 \ 3u | 4 \ -3 | -4 \ -3 | 4.0 \ 2.1 | (1.0f+2.0fi) \ (3.0f+2.0fi) | endl;
    50 
    51         //---------------------- Logarithm ----------------------
    52 
    5348        sout | "log:" | log( 1.0F ) | log( 1.0D ) | log( 1.0L ) | log( 1.0F+1.0FI ) | log( 1.0D+1.0DI ) | log( 1.0DL+1.0LI ) | endl;
    5449        sout | "log2:" | log2( 8.0F ) | log2( 8.0D ) | log2( 8.0L ) | endl;
     
    5853        sout | "logb:" | logb( 8.0F ) | logb( 8.0D ) | logb( 8.0L ) | endl;
    5954
     55        //---------------------- Power ----------------------
     56
    6057        sout | "sqrt:" | sqrt( 1.0F ) | sqrt( 1.0D ) | sqrt( 1.0L ) | sqrt( 1.0F+1.0FI ) | sqrt( 1.0D+1.0DI ) | sqrt( 1.0DL+1.0LI ) | endl;
    6158        sout | "cbrt:" | cbrt( 27.0F ) | cbrt( 27.0D ) | cbrt( 27.0L ) | endl;
    6259        sout | "hypot:" | hypot( 1.0F, -1.0F ) | hypot( 1.0D, -1.0D ) | hypot( 1.0L, -1.0L ) | endl;
     60        sout | "pow:" | pow( 1.0F, 1.0F ) | pow( 1.0D, 1.0D ) | pow( 1.0L, 1.0L ) | pow( 1.0F+1.0FI, 1.0F+1.0FI ) | pow( 1.0D+1.0DI, 1.0D+1.0DI ) | pow( 1.0DL+1.0LI, 1.0DL+1.0LI ) | endl;
    6361
    6462        //---------------------- Trigonometric ----------------------
     
    132130        sout | di | d;
    133131        l = modf( 2.3L, &ldi );
    134         sout | ldi | l | endl;
    135         sout | "modf:" | modf( 2.3F ) | modf( 2.3D ) | modf( 2.3L ) | endl;
     132        sout | ldi | l;
    136133        sout | "nextafter:" | nextafter( 2.0F, 3.0F ) | nextafter( 2.0D, 3.0D ) | nextafter( 2.0L, 3.0L ) | endl;
    137134        sout | "nexttoward:" | nexttoward( 2.0F, 3.0F ) | nexttoward( 2.0D, 3.0D ) | nexttoward( 2.0L, 3.0L ) | endl;
  • src/tests/maybe.c

    r0720e049 r3d4b23fa  
    99// Author           : Andrew Beach
    1010// Created On       : Thr May 25 16:02:00 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 20 15:24:07 2017
    13 // Update Count     : 1
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Fri May 16 15:43:00 2017
     13// Update Count     : 0
    1414//
    1515
    16 #include <assert.h>
     16#include <assert>
    1717#include <containers/maybe>
    1818
  • src/tests/preempt_longrun/Makefile.am

    r0720e049 r3d4b23fa  
    2525CC = @CFA_BINDIR@/@CFA_NAME@
    2626
    27 TESTS = block create disjoint enter enter3 processor stack wait yield
     27TESTS = barge block create disjoint enter enter3 processor stack wait yield
    2828
    2929.INTERMEDIATE: ${TESTS}
    3030
    3131all-local: ${TESTS:=.run}
    32 
    33 clean-local:
    34         rm -f ${TESTS}
    3532
    3633% : %.c ${CC}
  • src/tests/preempt_longrun/Makefile.in

    r0720e049 r3d4b23fa  
    453453REPEAT = ${abs_top_srcdir}/tools/repeat -s
    454454BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@ -debug -O2 -DPREEMPTION_RATE=${preempt}
    455 TESTS = block create disjoint enter enter3 processor stack wait yield
     455TESTS = barge block create disjoint enter enter3 processor stack wait yield
    456456all: all-am
    457457
     
    635635                TEST_LOGS="$$log_list"; \
    636636        exit $$?
     637barge.log: barge
     638        @p='barge'; \
     639        b='barge'; \
     640        $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
     641        --log-file $$b.log --trs-file $$b.trs \
     642        $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
     643        "$$tst" $(AM_TESTS_FD_REDIRECT)
    637644block.log: block
    638645        @p='block'; \
     
    783790clean: clean-am
    784791
    785 clean-am: clean-generic clean-local mostlyclean-am
     792clean-am: clean-generic mostlyclean-am
    786793
    787794distclean: distclean-am
     
    850857
    851858.PHONY: all all-am all-local check check-TESTS check-am clean \
    852         clean-generic clean-local cscopelist-am ctags-am distclean \
     859        clean-generic cscopelist-am ctags-am distclean \
    853860        distclean-generic distdir dvi dvi-am html html-am info info-am \
    854861        install install-am install-data install-data-am install-dvi \
     
    868875all-local: ${TESTS:=.run}
    869876
    870 clean-local:
    871         rm -f ${TESTS}
    872 
    873877% : %.c ${CC}
    874878        ${AM_V_GEN}${CC} ${CFLAGS} ${<} -o ${@}
  • src/tests/preempt_longrun/create.c

    r0720e049 r3d4b23fa  
    11#include <kernel>
    22#include <thread>
    3 
    4 static const unsigned long N = 2_000ul;
    53
    64#ifndef PREEMPTION_RATE
     
    1816int main(int argc, char* argv[]) {
    1917        processor p;
    20         for(int i = 0; i < N; i++) {
     18        for(int i = 0; i < 10_000ul; i++) {
    2119                worker_t w[7];
    2220        }
  • src/tests/preempt_longrun/enter.c

    r0720e049 r3d4b23fa  
    33#include <thread>
    44
     5#undef N
    56static const unsigned long N  = 70_000ul;
    67
  • src/tests/preempt_longrun/enter3.c

    r0720e049 r3d4b23fa  
    33#include <thread>
    44
     5#undef N
    56static const unsigned long N  = 50_000ul;
    67
  • src/tests/preempt_longrun/processor.c

    r0720e049 r3d4b23fa  
    11#include <kernel>
    22#include <thread>
    3 
    4 static const unsigned long N = 5_000ul;
    53
    64#ifndef PREEMPTION_RATE
     
    1715
    1816int main(int argc, char* argv[]) {
    19         for(int i = 0; i < N; i++) {
     17        for(int i = 0; i < 10_000ul; i++) {
    2018                processor p;
    2119        }
  • src/tests/preempt_longrun/yield.c

    r0720e049 r3d4b23fa  
    11#include <kernel>
    22#include <thread>
    3 
    4 static const unsigned long N = 325_000ul;
    53
    64#ifndef PREEMPTION_RATE
     
    1513
    1614void main(worker_t * this) {
    17         for(int i = 0; i < N; i++) {
     15        for(int i = 0; i < 325_000ul; i++) {
    1816                yield();
    1917        }
  • src/tests/result.c

    r0720e049 r3d4b23fa  
    99// Author           : Andrew Beach
    1010// Created On       : Thr May 25 16:50:00 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 20 15:24:12 2017
    13 // Update Count     : 1
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Fri Jun 16 15:42:00 2017
     13// Update Count     : 0
    1414//
    1515
    16 #include <assert.h>
     16#include <assert>
    1717#include <containers/result>
    1818
  • src/tests/sched-int-barge.c

    r0720e049 r3d4b23fa  
    55#include <thread>
    66
    7 static const unsigned long N = 50_000ul;
    8 
    9 #ifndef PREEMPTION_RATE
    10 #define PREEMPTION_RATE 10_000ul
    11 #endif
    12 
    13 unsigned int default_preemption() {
    14         return 0;
    15 }
    167enum state_t { WAIT, SIGNAL, BARGE };
    178
     
    1910
    2011monitor global_data_t {
    21         volatile bool done;
     12        bool done;
    2213        int counter;
    2314        state_t state;
     
    6051                c->do_wait2 = ((unsigned)rand48()) % (c->do_signal);
    6152
    62                 if(c->do_wait1 == c->do_wait2) sout | "Same" | endl;
     53                // if(c->do_wait1 == c->do_wait2) sout | "Same" | endl;
    6354        }
    6455
     
    8273        }
    8374
    84         if( c->counter >= N ) c->done = true;
     75        if( c->counter >= 100_000 ) c->done = true;
    8576        return !c->done;
    8677}
     
    9889}
    9990
    100 static thread_desc * volatile the_threads;
    101 
    10291int main(int argc, char* argv[]) {
    103         rand48seed(0);
    104         processor p;
    105         {
    106                 Threads t[17];
    107                 the_threads = (thread_desc*)t;
    108         }
     92        rand48seed(0);
     93        processor p;
     94        {
     95                Threads t[17];
     96        }
    10997}
  • src/tests/sched-int-block.c

    r0720e049 r3d4b23fa  
    55#include <thread>
    66
    7 #include <time.h>
    8 
    9 static const unsigned long N = 5_000ul;
    10 
    11 #ifndef PREEMPTION_RATE
    12 #define PREEMPTION_RATE 10_000ul
     7#ifndef N
     8#define N 10_000
    139#endif
    14 
    15 unsigned int default_preemption() {
    16         return PREEMPTION_RATE;
    17 }
    1810
    1911enum state_t { WAITED, SIGNAL, BARGE };
     
    109101
    110102int main(int argc, char* argv[]) {
    111         rand48seed( time( NULL ) );
     103        rand48seed(0);
    112104        done = false;
    113105        processor p;
  • src/tests/sched-int-disjoint.c

    r0720e049 r3d4b23fa  
    44#include <thread>
    55
    6 static const unsigned long N = 10_000ul;
    7 
    8 #ifndef PREEMPTION_RATE
    9 #define PREEMPTION_RATE 10_000ul
     6#ifndef N
     7#define N 10_000
    108#endif
    11 
    12 unsigned int default_preemption() {
    13         return PREEMPTION_RATE;
    14 }
    159
    1610enum state_t { WAIT, SIGNAL, BARGE };
  • src/tests/sched-int-wait.c

    r0720e049 r3d4b23fa  
    55#include <thread>
    66
    7 static const unsigned long N = 10_000ul;
    8 
    9 #ifndef PREEMPTION_RATE
    10 #define PREEMPTION_RATE 10_000ul
     7#ifndef N
     8#define N 10_000
    119#endif
    12 
    13 unsigned int default_preemption() {
    14         return PREEMPTION_RATE;
    15 }
    1610
    1711monitor global_t {};
     
    120114int main(int argc, char* argv[]) {
    121115        waiter_left = 4;
    122         processor p[2];
     116        processor p;
    123117        sout | "Starting" | endl;
    124118        {
  • src/tests/test.py

    r0720e049 r3d4b23fa  
    221221                if   retcode == TestResult.SUCCESS:     result_txt = "Done"
    222222                elif retcode == TestResult.TIMEOUT:     result_txt = "TIMEOUT"
    223                 else :                                          result_txt = "ERROR code %d" % retcode
     223                else :                                          result_txt = "ERROR"
    224224        else :
    225225                if   retcode == TestResult.SUCCESS:     result_txt = "PASSED"
    226226                elif retcode == TestResult.TIMEOUT:     result_txt = "TIMEOUT"
    227                 else :                                          result_txt = "FAILED with code %d" % retcode
     227                else :                                          result_txt = "FAILED"
    228228
    229229        #print result with error if needed
  • src/tests/vector/array.h

    r0720e049 r3d4b23fa  
    99// Author           : Richard C. Bilson
    1010// Created On       : Wed May 27 17:56:53 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 10:04:20 2017
    13 // Update Count     : 6
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Apr 27 17:26:04 2016
     13// Update Count     : 5
    1414//
    1515
    16 #pragma once
     16#ifndef ARRAY_H
     17#define ARRAY_H
    1718
    1819//#include <iterator>
     
    4445elt_type * end( array_type * array );
    4546
     47#endif // ARRAY_H
     48
    4649// Local Variables: //
    4750// tab-width: 4 //
  • src/tests/vector/vector_int.h

    r0720e049 r3d4b23fa  
    99// Author           : Richard C. Bilson
    1010// Created On       : Wed May 27 17:56:53 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 10:04:02 2017
    13 // Update Count     : 4
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Apr 27 17:26:59 2016
     13// Update Count     : 2
    1414//
    1515
    16 #pragma once
     16#ifndef VECTOR_INT_H
     17#define VECTOR_INT_H
    1718
    1819// A flexible array, similar to a C++ vector, that holds integers and can be resized dynamically
     
    2526
    2627void ?{}( vector_int * );                                                               // allocate vector with default capacity
    27 void ?{}( vector_int *, int reserve );                                  // allocate vector with specified capacity
    28 void ?{}( vector_int * vec, vector_int other );                 // copy constructor
     28void ?{}( vector_int *, int reserve );          // allocate vector with specified capacity
     29void ?{}( vector_int * vec, vector_int other ); // copy constructor
    2930void ^?{}( vector_int * );                                                              // deallocate vector's storage
    3031
     
    3536
    3637lvalue int ?[?]( vector_int * vec, int index );                 // access to arbitrary element (does not resize)
    37 int last( vector_int * vec );                                                   // return last element
     38int last( vector_int * vec );                                                           // return last element
     39
     40#endif // VECTOR_INT_H
    3841
    3942// Local Variables: //
  • tools/cfa.nanorc

    r0720e049 r3d4b23fa  
    88
    99# Types
    10 color green "\<(forall|trait|(o|d|f|t)type|mutex|_Bool|volatile|virtual)\>"
     10color green "\<(forall|otype|dtype|ftype|trait|mutex|_Bool|volatile)\>"
    1111color green "\<(float|double|bool|char|int|short|long|sizeof|enum|void|auto)\>"
    1212color green "\<(static|const|struct|union|typedef|extern|(un)?signed|inline)\>"
     
    1414
    1515# Declarations
    16 color brightgreen "\<(struct|union|typedef|trait|coroutine|monitor|thread)\>"
    17 color brightgreen "\<(with)\>"
     16color brightgreen "\<(struct|union|typedef|trait|coroutine|monitor)\>"
    1817
    1918# Control Flow Structures
  • tools/prettyprinter/ParserTypes.h

    r0720e049 r3d4b23fa  
    1313// Created On       : Sun Dec 16 15:00:49 2001
    1414// Last Modified By : Peter A. Buhr
    15 // Last Modified On : Sat Jul 22 10:13:09 2017
    16 // Update Count     : 175
     15// Last Modified On : Wed Jun 28 22:59:27 2017
     16// Update Count     : 174
    1717//
    1818
    19 #pragma once
     19#ifndef __PARSER_HH__
     20#define __PARSER_HH__
    2021
    2122int yylex();
     
    2526#include "token.h"
    2627
     28#endif // __PARSER_HH__
     29
    2730// Local Variables: //
    2831// mode: c++ //
  • tools/prettyprinter/filter.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Tue Apr  9 22:31:18 2002
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 10:12:55 2017
    13 // Update Count     : 11
     12// Last Modified On : Thu Jun 29 08:28:32 2017
     13// Update Count     : 10
    1414//
    1515
    16 #pragma once
     16#ifndef __FILTER_H__
     17#define __FILTER_H__
    1718
    1819#include "ParserTypes.h"
     
    2728void HTML( Token * tree );
    2829
     30#endif // __FILTER_H__
     31
    2932// Local Variables: //
    3033// mode: c++ //
  • tools/prettyprinter/lex.ll

    r0720e049 r3d4b23fa  
    1 /*
     1/*                               -*- Mode: C -*-
     2 *
    23 * Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
    34 *
     
    1011 * Created On       : Sat Dec 15 11:45:59 2001
    1112 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Fri Jul 21 23:06:16 2017
    13  * Update Count     : 254
     13 * Last Modified On : Wed Jun 28 22:57:17 2017
     14 * Update Count     : 253
    1415 */
    1516
  • tools/prettyprinter/test.y

    r0720e049 r3d4b23fa  
    1515        ;
    1616
    17 rules1  :
    18         /* empty */
    19         {}
     17rules1  : /* empty */
    2018        | xxx
    2119          /* fred */ yyy
  • tools/prettyprinter/token.cc

    r0720e049 r3d4b23fa  
     1//                              -*- Mode: C++ -*-
    12//
    2 // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
    3 //
    4 // The contents of this file are covered under the licence agreement in the
    5 // file "LICENCE" distributed with Cforall.
     3// Copyright (C) Peter A. Buhr 2017
    64//
    75// Pretty Printer, Copyright (C) Richard C. Bilson and Rodolfo G. Esteves 2001
     
    1210// Created On       : Wed Jun 28 22:46:23 2017
    1311// Last Modified By : Peter A. Buhr
    14 // Last Modified On : Fri Jul 21 23:07:04 2017
    15 // Update Count     : 10
     12// Last Modified On : Thu Jun 29 09:33:49 2017
     13// Update Count     : 9
    1614//
    1715
  • tools/prettyprinter/token.h

    r0720e049 r3d4b23fa  
    1010// Created On       : Wed Jun 28 22:47:58 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 10:12:42 2017
    13 // Update Count     : 6
     12// Last Modified On : Wed Jun 28 23:02:06 2017
     13// Update Count     : 5
    1414//
    1515
    16 #pragma once
     16#ifndef __TOKEN_H__
     17#define __TOKEN_H__
    1718
    1819struct Token {
     
    3435};
    3536
     37#endif // __TOKEN_H__
     38
    3639// Local Variables: //
    3740// tab-width: 4 //
Note: See TracChangeset for help on using the changeset viewer.